Flutter 颤振-如何将小部件添加到容器的边框?
假设我有一个普通的容器。如何将小部件(例如,按钮)添加到容器的边框 您可以使用插件。例如,在您的情况下,您可以使用徽章包装容器,并将作为徽章位置的参数修改为准确的底部和右侧值Flutter 颤振-如何将小部件添加到容器的边框?,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,假设我有一个普通的容器。如何将小部件(例如,按钮)添加到容器的边框 您可以使用插件。例如,在您的情况下,您可以使用徽章包装容器,并将作为徽章位置的参数修改为准确的底部和右侧值 Badge( position: BadgePosition.bottomRight(bottom: 0,right: 0),//change this to get the right location badgeContent: YourWidgetAtTheBorder(), ch
Badge(
position: BadgePosition.bottomRight(bottom: 0,right: 0),//change this to get the right location
badgeContent: YourWidgetAtTheBorder(),
child: YourContainer(),
)
您可以使用一个小部件重叠一些小部件,然后只需先创建容器(我使用一张卡来模拟标高和边框效果),然后添加图标、按钮等,通过deault将小部件对齐在左上角,我将其更改为右中角,但是,如果您想要更多的控制,只需将小部件包装在对齐或定位的小部件中,将它们移动到您想要的位置
class MyWidget extends StatelessWidget {
final Size size = Size(400, 400);
@override
Widget build(BuildContext context) {
return Stack(alignment: Alignment.centerRight, children: [
Card(
margin: const EdgeInsets.all(24.0), //half the size the icon so it looks like in the middle of the border
elevation: 8,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8)),
side: BorderSide(color: Colors.blue, width: 2)
),
color: Colors.grey,
child: SizedBox.fromSize(
size: size, child: Center(child: Text('MyText'))
)
),
Icon(Icons.done, size: 48)
]);
}
}
Cóthể 德昂·斯塔克·卢恩·尼亚:)@tại cái容器củ蒙尼翁ằm trongán stack thìcái nósẽ Bị lõm 1英里ế吴伯恩博士ả我Mình xái包装徽章chỉ新罕布什尔州ạ我是希思ấy-chạ恩恩:我的工作做得很好!非常感谢你!