我正在尝试使用 BoxDecoration 小部件中的 boxShadow 参数仅向容器小部件的右侧添加阴影。
new Container(
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.5),
boxShadow: [
BoxShadow(
blurRadius: 5.0
),
],
),
),
Run Code Online (Sandbox Code Playgroud)
此代码有效,但会在容器的每个可能的一侧添加阴影。我希望它只在右侧。
我一直在制作一个应用程序,其中有一个水平列表的列表(类似于 Spotify)。在这些水平列表中是使用 CachedNetworkImage 小部件显示的缩略图。
我还没有设法使滚动性能变得平滑(每帧少于 16 毫秒,或接近该值)。
这是一些示例代码(使用 lorem picsum 获取随机生成的 jpeg):
Widget build(BuildContext context) {
return new Scaffold(
backgroundColor: Colors.black,
body: new CustomScrollbar(
child: new ListView.builder(
controller: _scrollController,
itemCount: 30,
itemBuilder: (context, index){
return new Padding(
padding: const EdgeInsets.symmetric(vertical: 10.0),
child: new Container(
width: double.infinity,
height: 100.0,
child: new ListView.builder(
scrollDirection: Axis.horizontal,
itemCount: 20,
itemBuilder: (context, innerIndex){
return new Padding(
padding: const EdgeInsets.symmetric(horizontal: 10.0),
child: new Container(
height: 100.0,
width: 100.0,
alignment: Alignment.center,
decoration: BoxDecoration(
border: Border.all(color: Colors.white, width: …Run Code Online (Sandbox Code Playgroud) 我有一个黑色背景的脚手架,它的抽屉也是黑色的。由于打开抽屉时发生的淡入淡出效果是淡入“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)