Files
FlutterUnit/lib/views/widgets/MultiChildRenderObjectWidget/Stack/node2_positioned.dart
2020-05-03 23:05:53 +08:00

54 lines
1.2 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020-03-30
/// contact me by email 1981462002@qq.com
/// 说明:
// {
// "widgetId": 97,
// "name": 'Stack和Positioned结合使用',
// "priority": 2,
// "subtitle":
// "Positioned组件只能用与Stack中可以指定左上右下的距离对某个组件进行位置精确安放。",
// }
class PositionedStack extends StatelessWidget {
@override
Widget build(BuildContext context) {
var yellowBox = Container(
color: Colors.yellow,
height: 100,
width: 100,
);
var redBox = Container(
color: Colors.red,
height: 90,
width: 90,
);
var greenBox = Container(
color: Colors.green,
height: 80,
width: 80,
);
var cyanBox = Container(
color: Colors.cyanAccent,
height: 70,
width: 70,
);
return Container(
width: 200,
height: 120,
color: Colors.grey.withAlpha(33),
child: Stack(
children: <Widget>[yellowBox, redBox, greenBox,
Positioned(
child: cyanBox,
bottom: 10,
right: 10,
)
],
));
}
}