Flutter 如何在应用程序栏中的图像文件下方放置文本?
我有一个应用程序栏,我需要在应用程序栏中的图像下方放置一个文本。文本应直接在下方对齐。我已经尝试了很多方法,但是我找不到一个方法去做。[我现在获得的输出图像][1]Flutter 如何在应用程序栏中的图像文件下方放置文本?,flutter,dart,flutter-layout,android-appbarlayout,flutter-appbar,Flutter,Dart,Flutter Layout,Android Appbarlayout,Flutter Appbar,我有一个应用程序栏,我需要在应用程序栏中的图像下方放置一个文本。文本应直接在下方对齐。我已经尝试了很多方法,但是我找不到一个方法去做。[我现在获得的输出图像][1] appBar: new PreferredSize( preferredSize: const Size.fromHeight(240.0), child: new AppBar( centerTitle: true, title: Row(),
appBar:
new PreferredSize(
preferredSize: const Size.fromHeight(240.0),
child: new AppBar(
centerTitle: true,
title: Row(),
flexibleSpace: Container(
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [reddish, blushish],
),
),
),
bottom: new PreferredSize(
child: new Container(
child: new Image.asset('assets/rewahub_icon.png'),
padding: const EdgeInsets.all(80.0),
),
preferredSize: const Size.fromHeight(100.0)),
),
),
I am not able to place a text below the Png file that is image file. I would like to place a text below the Image file. Please do help me with this.
[1]: https://i.stack.imgur.com/P45ya.jpg
您可以在一列中对齐所有要从同一位置开始的小部件 并使用MainAxisAlignment属性,如:
MainAxisAlignment.start
如果还需要一些空格,可以使用填充。可以将图像包装在列中,并在此列中添加文本小部件
child: Column(
children: <Widget>[
new Image.asset('assets/rewahub_icon.png'),
Text('I got my text here'),
],
)
child:Column(
儿童:[
新建Image.asset('assets/rewahub_icon.png'),
Text('我在这里收到了我的文本'),
],
)
Hi Salah,谢谢你的回复。对不起,我不明白你刚才提到的概念。请提供一个示例代码供我参考。例如:Column(mainAxisAlignment:MainAxisAlignmentstart,children[Imageasset(“”),Text(“”)