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
网友评论