flutter - 根据Appbar的高度更改标题和标题

标签 flutter dart

return Scaffold(
  appBar: 
    PreferredSize(
      preferredSize: Size.fromHeight(120),// change appbar size
    
      child:AppBar(
        backgroundColor: Color.fromARGB(255,254,202,8),
        leading:RawMaterialButton( 
          constraints: BoxConstraints(),
          padding: EdgeInsets.all(0), 
          child: Image.asset("assets/img/home.png",height:110), // set height as 110
        ),

        title:Text("mytitle");
我通过preferredSize更改了应用栏的高度
并将领先的图像高度设置为100AppBar的高度已更改,但前导图标的大小未更改。
还有文字。
如何根据应用栏大小更改行距和文本大小?

最佳答案

无法更改leadingAppBar的大小,但是一种解决方法是使用包含图像和标题的Row并将此行设置为flexibleSpaceAppBar:

AppBar(
              backgroundColor: Color.fromARGB(255, 254, 202, 8),
              flexibleSpace: Row(
                children: <Widget>[
                  RawMaterialButton(
                    constraints: BoxConstraints(),
                    padding: EdgeInsets.all(0),
                    child: Image.asset(
                      "assets/img/home.png",
                      height: 110,
                    ),
                  ),
                  Text("mytitle"),
                ],
              ),
            ),

关于flutter - 根据Appbar的高度更改标题和标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63398323/

相关文章:

flutter - Flutter-Dart-使图像全屏显示

Flutter)如何计算 map 内的特定值

flutter - 错误时更改 InputDecorationTheme 的填充颜色

flutter - flutter :凸起的按钮宽度问题

flutter - 如何在 Flutter 的对话框中访问 Provider 提供者

flutter - 如何在三个容器之间切换

ios - 如何从 Flutter 代码在 Swift 中打开相机 View 以访问自动对焦等相机功能

带有 Web 组件的 Dart 服务器

flutter - 如何在 map 列表中查找 map ?

dart - 有没有办法在 Flutter 的多个 PageRoutes 中使用 InheritedWidget?