flutter - 如何更改 Flutter 中 CupertinoNavigationBar 的高度?

标签 flutter cupertinonavigationbar

我想增加 CupertinoNavigationBar 的高度。代码是这样的:

child: CustomCupertinoNavigationBar(
         padding: EdgeInsetsDirectional.zero,
         backgroundColor: Colors.white,
         middle: Semantics(
           label: "dashboard-main-page-title",
           child: Text(
             "My Title",
             style: TextStyles.HankenSans_Bold_18_PrimaryBlack,
             key: Key('dashboard-main-page-title'),
           ),
         ),
         leading: Semantics(
           label: "dashboard-back-button",
           child: Material(
             color: Colors.white,
             child: CustomBackButton(
               onPressHandler: () {
                 Navigation().openMyAccountPage();
               },
             ),
           ),
         ),
       );

我尝试创建自己的自定义 cupertino。我复制了 cupertino/nav_bar.dart 并将 _kNavBarPersistentHeight 参数更改为 const double _kNavBarPersistentHeight = 58.0; 但它导致在 IOS 中有两个导航栏。有人可以帮我吗?非常感谢。

最佳答案

我解决了这个问题

appBar: PreferredSize(
        preferredSize: Size.fromHeight(100.0),
        child: Container(
          height: 120,
          child: CupertinoNavigationBar(
            padding: EdgeInsetsDirectional.zero,
            backgroundColor: Colors.white,
            middle: Semantics(
              label: "dashboard-main-page-title",
              child: Text(
                CustomerLoyaltyLocalizations.instance.dashboardMainPageTitle,
                style: TextStyles.HankenSans_Bold_18_PrimaryBlack,
                key: Key('dashboard-main-page-title'),
              ),
            ),
            leading: Semantics(
              label: "dashboard-back-button",
              child: Material(
                color: Colors.white,
                child: CustomBackButton(
                  onPressHandler: () {
                    Navigation().openMyAccountPage();
                  },
                ),
              ),
            ),
          ),
        ),
      ),

首先我使用了 PreferredSize,然后在 CupertinoNavigationBar 之前使用了 Container 小部件。

关于flutter - 如何更改 Flutter 中 CupertinoNavigationBar 的高度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69495406/

相关文章:

flutter 2 : Error connecting to the service protocol: failed to connect to http://127. 0.0.1:1039/#58588

Flutter 导航到其他页面中的特定选项卡

flutter - 如何防止多列和 ListView 出现此溢出错误?

flutter - 如何自定义Flutter Material 3 Switch?

flutter - 小部件文本中的文本OverFlow.ellipsis不起作用