美文网首页
Flutter StackWidget布局(层叠布局)

Flutter StackWidget布局(层叠布局)

作者: 前端新阳 | 来源:发表于2020-05-25 22:46 被阅读0次

Stack层叠布局

  • main.dart代码:
import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    var stack = new Stack(
      alignment: const FractionalOffset(0.5, 0.8),
      children: <Widget>[
        new CircleAvatar(
          backgroundImage: new NetworkImage('https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1590427060579&di=a8e073b47836e525e9f0b53e72f41ee7&imgtype=0&src=http%3A%2F%2Fa2.att.hudong.com%2F36%2F48%2F19300001357258133412489354717.jpg'),
          radius: 100.0
        ),
        new Container(
          decoration: new BoxDecoration(
            color: Colors.lightBlue,
          ),
          padding: EdgeInsets.all(5.0),
          child: Text('Link'),
        )
      ],
    );
    return MaterialApp(
        title: 'Link World!',
        home: Scaffold(
            appBar: new AppBar(title: new Text('StackWidget层叠布局')),
            body: Center(
              child: stack
            )
        )
    );
  }
}

【效果】如下:


image.png

相关文章

网友评论

      本文标题:Flutter StackWidget布局(层叠布局)

      本文链接:https://www.haomeiwen.com/subject/yfcpahtx.html