cou*_*blo 3 drawer dart flutter
我有一个黑色背景的脚手架,它的抽屉也是黑色的。由于打开抽屉时发生的淡入淡出效果是淡入“Colors.black54”(不透明度为 54% 的黑色),因此抽屉的边框不可见。
我希望它褪色为灰色,不透明度为 54%。
我发现可以做到这一点的唯一方法是直接修改 Flutter 的源代码文件“drawer.dart”(第 382 行),但这不是一个实际的解决方案,它更像是一个 hack。
return new Scaffold(
backgroundColor: Colors.black,
drawer: new Drawer(
child: new Container(
color: Colors.black,
child: new Center(
child: new Text(
'Test',
style: new TextStyle(
color: Colors.white
)
)
),
),
),
);
Run Code Online (Sandbox Code Playgroud)
我在 Github 上提出了一个问题,并得到了这个答案,它可以为您完成所有工作(但在 flutter 的稳定通道上还不存在,仅存在于 1.6.0 及更高版本上)。
“如果您使用的是 Flutter v1.6.0 及更高版本,您可以将抽屉ScrimColor 传递到您的 Scaffold。这是最近在 #31025 中添加的。请在有关 Flutter 通道的文档中查看有关使用更高 Flutter 版本的更多信息。”
https://github.com/flutter/flutter/issues/34171#issuecomment-500590613
return new Scaffold(
backgroundColor: Colors.black,
drawerScrimColor: Colors.grey.withOpacity(0.54),
drawer: new Drawer(
child: new Container(
color: Colors.black,
child: new Center(
child: new Text(
'Test',
style: new TextStyle(
color: Colors.white
)
)
),
),
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2009 次 |
| 最近记录: |