Flutter 如何自定义appbar并在Flatter中放置Imageview
我想根据给定的图像设计一个布局 我使用了PreferredSize,我的代码是Flutter 如何自定义appbar并在Flatter中放置Imageview,flutter,flutter-layout,Flutter,Flutter Layout,我想根据给定的图像设计一个布局 我使用了PreferredSize,我的代码是 PreferredSize( preferredSize: Size.fromHeight(200.0), child: AppBar( // title: Text('Profile'), title: Row( children: <Widget>[ I
PreferredSize(
preferredSize: Size.fromHeight(200.0),
child: AppBar(
// title: Text('Profile'),
title: Row(
children: <Widget>[
Icon(Icons.account_circle, size: 150.0),
Text('data'),
],
),
bottom: TabBar(
tabs: [
.
.
],
),
),
),
PreferredSize(
首选尺寸:尺寸。从高度(200.0),
孩子:AppBar(
//标题:文本(“概要文件”),
标题:世界其他地区(
儿童:[
图标(Icons.account_圆圈,尺寸:150.0),
文本(“数据”),
],
),
底部:选项卡栏(
选项卡:[
.
.
],
),
),
),
输出与预期的设计检查不同
如何修复此问题?以下是所需布局的代码
class MyHomePage1 extends StatefulWidget {
@override
_MyHomePage1State createState() => _MyHomePage1State();
}
class _MyHomePage1State extends State<MyHomePage1> {
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 3,
initialIndex: 0,
child: Scaffold(
appBar: AppBar(
title: Text('AppBar'),
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Icon(
Icons.account_circle,
size: 70.0,
color: Colors.white,
),
Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Account Name',
style: TextStyle(color: Colors.white),
),
Text(
'Email Address',
style: TextStyle(color: Colors.white),
),
],
),
],
),
),
),
bottom: PreferredSize(
preferredSize: Size.square(140.0),
child: TabBar(
tabs: [
Icon(Icons.train),
Icon(Icons.directions_bus),
Icon(Icons.motorcycle)
],
),
),
),
),
);
}
}
类MyHomePage1扩展了StatefulWidget{
@凌驾
_MyHomePage1State createState()=>\u MyHomePage1State();
}
类_MyHomePage1State扩展状态{
@凌驾
小部件构建(构建上下文){
返回DefaultTabController(
长度:3,
初始索引:0,
孩子:脚手架(
appBar:appBar(
标题:文本(“AppBar”),
flexibleSpace:FlexibleSpaceBar(
标题:对,
标题:中心(
孩子:排(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
图标(
Icons.account_圈,
尺寸:70.0,
颜色:颜色,白色,
),
纵队(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
正文(
“帐户名”,
样式:TextStyle(颜色:Colors.white),
),
正文(
“电子邮件地址”,
样式:TextStyle(颜色:Colors.white),
),
],
),
],
),
),
),
底部:首选尺寸(
首选尺寸:方形尺寸(140.0),
孩子:TabBar(
选项卡:[
图标(Icons.train),
图标(图标、方向和总线),
图标(图标。摩托车)
],
),
),
),
),
);
}
}