- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我正在尝试使用 Cupertino Widgets
克隆 WhatsApp(iOS 版本)。
在尝试使用 CupertinoSliverNavigationBar
制作 header 时,我注意到无法增加 CupertinoSliverNavigationBar
的高度。
我的代码
return CupertinoPageScaffold(
child: NotificationListener<ScrollNotification>(
onNotification: (scrollNotification) {
if (scrollNotification is ScrollStartNotification) {
_onStartScroll(scrollNotification.metrics);
} else if (scrollNotification is ScrollUpdateNotification) {
_onUpdateScroll(scrollNotification.metrics);
} else if (scrollNotification is ScrollEndNotification) {
_onEndScroll(scrollNotification.metrics);
}
},
child: CustomScrollView(
slivers: <Widget>[
CupertinoSliverNavigationBar(
leading: GestureDetector(
child: Padding(
padding: EdgeInsets.only(top: 10.0),
child: Text(
"Edit",
style: TextStyle(
color: Constants.primaryColor,
fontSize: 18.0,
),
),
),
onTap: ()=>print("Tapped"),
),
trailing: GestureDetector(
child: Icon(
CupertinoIcons.create_solid,
size: 25.0,
),
onTap: ()=>print("Tapped"),
),
automaticallyImplyLeading: false,
largeTitle: Column(
children: <Widget>[
Container(
child: Text(
"Chats",
textAlign: TextAlign.left,
),
),
GestureDetector(
child: SearchBar(),
),
],
),
),
],
),
),
);
截图如下:
我想要实现的目标
我得到了什么
是否有任何解决方法或无论如何可以增加高度?谢谢!
最佳答案
Flutter 纯粹主义者和拥护者会杀了我,但这些尺寸是常量值的一部分(如 MaterialDesign 指南值),2 个快速选项:
选项 1:直接修改SDK:Ctrl(或 Cmd)+ 单击 CustomScrollView,将打开 flutter/lib/src/cupertino/nav_bar.dart
修改第22或26行:
/// This height is constant and independent of accessibility as it is in iOS.
const double _kNavBarPersistentHeight = 44.0;
/// Size increase from expanding the navigation bar into an iOS-11-style large title
/// form in a [CustomScrollView].
const double _kNavBarLargeTitleHeightExtension = 52.0; // change this one!
选项 2:直接在你的项目中复制 nav_bar.dart 并修改它,或者更好的是,获取 CustomScrollView() 的所有依赖项,然后把你自己的名字和你自己的值放在那里......我想这不仅仅是来自的标准设计指南Apple,一些开发人员需要更改这些值的能力。我们也许应该打开一个 Github 请求。
希望我的“hacky”解决方案对您有用!
关于flutter - 如何增加 CupertinoSliverNavigationBar 的高度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56528087/
我正在尝试使用 CupertinoSliverNavigationBar,实际上它很棒,但由于某些原因我无法将尾部放在导航栏的末尾。我抬头一看,我(我猜,我)发现里面有 Padding 这是我的代码
我正在尝试使用 Cupertino Widgets 克隆 WhatsApp(iOS 版本)。 在尝试使用 CupertinoSliverNavigationBar 制作 header 时,我注意到无法
我正在创建一个使用 Cupertino 小部件的 Flutter 应用程序。现在我正在使用 CupertinoSliverNavigationBar,但我确实喜欢多行标题。目前我写了以下内容: @ov
试图研究周围但找不到解决方案。我想使用 CupertinoSliverNavigationBar,它是顶部导航栏的大标题版本,我可以在 Xcode Storyboard 中实现这一点,但只需将按钮添加
我是一名优秀的程序员,十分优秀!