flutter - 如何自定义 appbar 并在 flutter 中放置 Imageview

标签 flutter flutter-layout

我想设计一个给定图片的布局,

I need to design a screen like this

我使用了 PreferredSize,我的代码是,

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: [
              .
              .
              ],
            ),
          ),
        ),

输出与预期的设计检查不同,

enter image description here

我该如何解决这个问题?

最佳答案

这是您想要的布局代码。

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)
              ],
            ),
          ),
        ),
      ),
    );
  }
}

enter image description here

关于flutter - 如何自定义 appbar 并在 flutter 中放置 Imageview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53810666/

相关文章:

Flutter Android 通知图标(灰色方 block )

firebase - 如何从 flutter 朔迷离的火堆中打印值

Flutter - 在 Android 上访问隐藏方法 Lsun/misc/Unsafe 错误

flutter - 如何使用Flutter同Page导航与Getx路由或Material路由?

flutter - 在选项卡 View 页面之间保留状态

flutter - 如何在 flutter 中创建一个始终停留在页面底部的按钮?

flutter - 如何通过定位和填充小部件为平板电脑增加响应能力?

flutter - 如何设置 Flutter ListTile 的前导和标题之间的填充?

flutter - Flutter 应用程序构建上的任务 ':sms:verifyReleaseResources' 和线程 "main"中的异常 java.lang.NullPointerException 执行失败

android - 如何摆脱 : "FileSystemException: Cannot open file, path = ' . 。 .' (OS Error: Permission denied, errno = 13)"?