- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在努力使电子商务应用程序变得 flutter 朔迷离。
我想使Appbar透明并具有动画效果,所以我使用Sliverappbar,但如果不向下滚动就无法使其透明。
我试图使用堆栈,但是它不起作用并且有错误。
我希望appbar位于顶部时透明,而当我向下滚动时更改为白色。
这是我的 flutter 代码
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
extendBodyBehindAppBar: true,
appBar: AppBar(
backgroundColor: Colors.transparent,
elevation: 0.0,
leading: Icon(
Icons.menu,
size: 30,
),
actions: <Widget>[
IconButton(
icon: Icon(Icons.tune, color: Colors.black, size: 30),
)
],
),
body: _buildBody(),
);
}
Widget _buildBody() {
return CustomScrollView(
slivers: <Widget>[
SliverAppBar(
leading: Icon(
Icons.menu,
size: 30,
),
backgroundColor: Colors.transparent,
actions: <Widget>[
IconButton(
icon: Icon(
Icons.tune,
color: Colors.black,
size: 30,
),
)
],
floating: true,
elevation: 0.0,
snap: false,
),
SliverToBoxAdapter(
child: SizedBox(
height: MediaQuery.of(context).size.height * 0.7,
width: MediaQuery.of(context).size.width,
child: Carousel(
images: [
Image.network(
'https://i.pinimg.com/564x/83/32/37/8332374f18162612dd9f2a4af2fda794.jpg',
fit: BoxFit.cover),
Image.network(
'https://i.pinimg.com/originals/e2/8e/50/e28e5090b7193ec9b2d5b5c6dfaf501c.jpg',
fit: BoxFit.cover),
Image.network(
'https://image-cdn.hypb.st/https%3A%2F%2Fhypebeast.com%2Fwp-content%2Fblogs.dir%2F6%2Ffiles%2F2019%2F09%2Fmschf-fall-winter-lookbook-streetwear-seoul-korea-47.jpg?q=75&w=800&cbr=1&fit=max',
fit: BoxFit.cover)
],
showIndicator: false,
)),
),
SliverToBoxAdapter(
child: Padding(
padding: EdgeInsets.only(
left: 25.0, top: 20.0, right: 0.0, bottom: 20.0),
child: Text('Recommended for You',
style: TextStyle(fontWeight: FontWeight.bold, fontSize: 25)),
),
),
SliverPadding(
padding: EdgeInsets.only(left: 35.0, right: 35.0),
sliver: SliverGrid(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 2,
mainAxisSpacing: 20.0,
crossAxisSpacing: 25.0,
childAspectRatio: 0.67,
),
delegate: SliverChildBuilderDelegate(
(BuildContext context, int index) {
return _buildListItem(context, index);
},
childCount: 13,
),
))
],
);
最佳答案
我能找到的最佳解决方案是在SliverToBoxAdapter中使用常规AppBar而不是使用SliverAppBar。您可以将FlexibleSpace属性设置为Carousel,或将AppBar和Carousel放入堆栈中。
据我所知,flexibleSpace属性在SliverAppBar和常规AppBar中的行为有所不同。它不会在常规AppBar中崩溃,您也不需要将轮播放入FlexibleSpaceBar()中。
您可能需要做一些其他事情才能获得想要的外观(例如,更改高程)。
关于ios - 如何使透明的Sliverappbar flutter ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61042793/
我想实现如下布局: Layout Link 到目前为止,我正在使用 Sliver。但问题是SearchBar!我希望 SliverAppBar 与布局完全一样并固定在顶部。有什么建议吗? 我试图通过此
我在 sliver 应用栏及其内容方面遇到了一些问题。当我向下滚动 SliverList 的内容(在下面的代码中)时,我想调整 flexibleSpace 中的图像大小,以适应列表顶部元素的图像。 现
我在SliverAppBar中使用flexibleSpace,其中包含以下内容: float :true,固定:false,捕捉:true:当我向上滚动时。它显示AppBar和flexibleSpac
我将 Flutter 的 SliverAppBar 与 SliverList 结合使用。应用栏可以很好地处理长列表,滚动很多。但是,如果我有包含 8 个项目的中等大小列表,则应用栏只会部分折叠,直到列
我有一个 SliverAppBar,向上滚动可缩小,向下滚动可展开。 我想在切换 BottomNavigationBar 时扩展 SliverAppBar。 当前情况下,SliverAppBar保持切
我已按照本教程 (https://medium.com/@diegoveloper/flutter-collapsing-toolbar-sliver-app-bar-14b858e87abe) 创建
我有一个 SliverAppBar( float :true,固定:false)。 我想实现的是,在 SliverAppBar 开始压缩/向上滑动之前,用户必须滚动 200 像素(或其他数量)。 最佳
当 AppBar 重新设置动画时(滚动条到达顶部后),SliverAppBar 无法显示内容。 下面包含一个示例项目来演示该问题。复制/粘贴下面的代码(将 rxdart 依赖项添加到 pubspec.
This is what I'm trying to do ,它是 iOS 上一个相当常见的 Widget。这是我的代码: return Scaffold( backgroundColor: Co
我正在使用 NestedScrollView在这里并试图放一个 TabBar在 bottom SliverAppBar 的参数内置于 headerSliverBuilder功能。 TabBar工作正常
我想在 Flutter 中添加自定义 SliverAppBar,如下所示 The SliverAppBar I want 但我只能做如下 The SliverAppBar I get在 https:/
我收到了 SliverAppBar与 AnimatedContainer里面。此动画容器的高度在运行时会发生变化,因此容器会对其大小进行动画处理。我的问题是,expandedHeight我的 Sliv
我对 Appbar 有这些要求,但我找不到解决它们的方法。 当拉伸(stretch) , AppBar 必须显示 两个图像一个在另一个之上并且标题必须隐藏。 当关闭 , AppBar 必须显示标题和
我在 Dribble 中发现了一些 Appbar 设计 https://dribbble.com/shots/9175650-Beauty-Salon-App/attachments/1218583?
我正在尝试在自定义应用栏下方显示一个灵活的 SliverAppBar(假设它是一个高度为 80.0 的容器)。 当将 SliverAppBar 设置为顶部元素时,它工作正常,但当它是第二个时,顶部填充
我显示来自网络的图像,它在滚动时缩小。我想显示没有填充或裁剪的整个图像。但是,如果我用 expandedHeight 注释行 - 没有图像 - 只有 appbar 及其高度。有没有什么小部件,可以根据
我是使用 flutter 的新手,当我编写我的应用程序时,我遇到了一个问题,即如何默认设置 SliverAppBar 折叠状态。为了解决我的困惑,我查看了 flutter 的文档,不幸的是我找不到解决
有没有人在SliverAppBar中使用过Gradient?当它展开时,我可以在 FlexibleSpace 中执行此操作,但当它折叠时,它会变成纯色。可以治疗吗? 最佳答案 在FlexibleSpa
在 Flutter 中,您可以使用 shape 属性在 AppBar 小部件中自定义形状,但此属性在 SliverAppBar 小部件中缺失 AppBar( title: Text('He
这是我的代码,复制自 here : SliverAppBar( expandedHeight: 150.0, flexibleSpace: const FlexibleSpaceBar(
我是一名优秀的程序员,十分优秀!