如何将堆栈的子项定位在右下角或左下角? (有反应)
how to position children of stack in bottom right or left in flutter? (responsive)
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('snackbar'),
),
body: Center(
child: Stack(
fit: StackFit.passthrough,
alignment: Alignment.center,
children: [
Container(
width: 400,
height: 400,
color: Colors.amber,
),
Container(
width: 200,
height: 200,
color: Colors.cyan,
),
RaisedButton(
child: Text(
'click me',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
onPressed: () {
Get.dialog(MyDialog());
},
),
]),
),
floatingActionButton: FloatingActionButton(onPressed: () {
incFun();
Get.snackbar(
'Hi',
'i am a simple $_increament',
snackPosition: SnackPosition.BOTTOM,
icon: Icon(Icons.add_comment),
);
}),
);
}
enter image description here
我试图在不使用尺寸的情况下对齐小部件
我尝试定位和对齐小部件,但他们将按钮放在屏幕底部
我想在右下角的琥珀色容器中设置按钮
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('snackbar'),
),
body: Center(
child: Stack(
fit: StackFit.loose, // Just Changed this line
alignment: Alignment.bottomRight, // Just changed this line
children: [
Container(
width: 400,
height: 400,
color: Colors.amber,
),
Container(
width: 200,
height: 200,
color: Colors.cyan,
),
RaisedButton(
child: Text(
'click me',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
onPressed: () {
Get.dialog(MyDialog());
},
),
]),
),
floatingActionButton: FloatingActionButton(onPressed: () {
incFun();
Get.snackbar(
'Hi',
'i am a simple $_increament',
snackPosition: SnackPosition.BOTTOM,
icon: Icon(Icons.add_comment),
);
}),
);
}
刚改了两行注释。休息是一样的..
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('snackbar'),
),
body: Center(
child: Stack(
fit: StackFit.passthrough,
alignment: Alignment.center,
children: [
Container(
width: 400,
height: 400,
color: Colors.amber,
),
Container(
width: 200,
height: 200,
color: Colors.cyan,
),
RaisedButton(
child: Text(
'click me',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
onPressed: () {
Get.dialog(MyDialog());
},
),
]),
),
floatingActionButton: FloatingActionButton(onPressed: () {
incFun();
Get.snackbar(
'Hi',
'i am a simple $_increament',
snackPosition: SnackPosition.BOTTOM,
icon: Icon(Icons.add_comment),
);
}),
);
}
enter image description here
我试图在不使用尺寸的情况下对齐小部件 我尝试定位和对齐小部件,但他们将按钮放在屏幕底部 我想在右下角的琥珀色容器中设置按钮
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('snackbar'),
),
body: Center(
child: Stack(
fit: StackFit.loose, // Just Changed this line
alignment: Alignment.bottomRight, // Just changed this line
children: [
Container(
width: 400,
height: 400,
color: Colors.amber,
),
Container(
width: 200,
height: 200,
color: Colors.cyan,
),
RaisedButton(
child: Text(
'click me',
style: TextStyle(color: Colors.white),
),
color: Colors.blue,
onPressed: () {
Get.dialog(MyDialog());
},
),
]),
),
floatingActionButton: FloatingActionButton(onPressed: () {
incFun();
Get.snackbar(
'Hi',
'i am a simple $_increament',
snackPosition: SnackPosition.BOTTOM,
icon: Icon(Icons.add_comment),
);
}),
);
}
刚改了两行注释。休息是一样的..