【发布时间】:2022-01-01 21:09:58
【问题描述】:
我对 Flutter 完全陌生,我必须做这样的事情。
对于第二部分,我的右图是由左图和另一个颜色为蓝色的图像组成的。
不要混淆! 我将以更好的方式解释: 首先,我必须将这两张图片放入 一行(类似于 android 中的 FrameLayout)
与 右图由左图和另一种颜色的图像(只有一种颜色的图像)制成
我希望你明白了
【问题讨论】:
标签: flutter image flutter-layout
我对 Flutter 完全陌生,我必须做这样的事情。
对于第二部分,我的右图是由左图和另一个颜色为蓝色的图像组成的。
不要混淆! 我将以更好的方式解释: 首先,我必须将这两张图片放入 一行(类似于 android 中的 FrameLayout)
与 右图由左图和另一种颜色的图像(只有一种颜色的图像)制成
我希望你明白了
【问题讨论】:
标签: flutter image flutter-layout
如果您的问题是关于重叠两个小部件,您可以使用Stack 来处理它。
【讨论】:
您可以使用 Stack 和 Positioned 来执行此操作:
这是带有图标的示例:
class StackExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(),
body: new Container(
padding: const EdgeInsets.all(8.0),
height: 500.0,
width: 500.0,
// alignment: FractionalOffset.center,
child: new Stack(
//alignment:new Alignment(x, y)
children: <Widget>[
new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0)),
new Positioned(
left: 20.0,
child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0)),
),
new Positioned(
left:40.0,
child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0)),
)
],
),
),
)
;
}
}
class StackExample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new Scaffold(
appBar: new AppBar(),
body: new Container(
padding: const EdgeInsets.all(8.0),
height: 500.0,
width: 500.0,
// alignment: FractionalOffset.center,
child: new Stack(
//alignment:new Alignment(x, y)
children: <Widget>[
new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
boxShadow: [
new BoxShadow(
blurRadius: 5.0,
offset: const Offset(3.0, 0.0),
color: Colors.grey,
)
]
),
child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0))),
new Positioned(
left: 20.0,
child: new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
boxShadow: [
new BoxShadow(
blurRadius: 5.0,
offset: const Offset(3.0, 0.0),
color: Colors.grey,
)
]
),
child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0))),
),
new Positioned(
left:40.0,
child: new Container(
decoration: new BoxDecoration(
borderRadius: BorderRadius.circular(25.0),
boxShadow: [
new BoxShadow(
blurRadius: 5.0,
offset: const Offset(3.0, 0.0),
color: Colors.grey,
)
]
)
,child: new Icon(Icons.notifications, size: 36.0, color: const Color.fromRGBO(218, 165, 32, 1.0))),
)
],
),
),
)
;
}
}
【讨论】: