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

Flutter PositionedWidget布局(层叠布局)

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

    PositionedWidget层叠布局

    • 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 Positioned(
                top: 10.0,
                left: 60.0,
                child: new Text('www.winterson.cn')
            ),
            new Positioned(
                bottom: 10.0,
                right: 50.0,
                child: new Text('LuckyLink')
            )
          ],
        );
        return MaterialApp(
            title: 'Link World!',
            home: Scaffold(
                appBar: new AppBar(title: new Text('PositionedWidget层叠布局')),
                body: Center(
                  child: stack
                )
            )
        );
      }
    }
    
    

    【效果】如下:


    image.png

    相关文章

      网友评论

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

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