我有一个应用程序,其中包含两个容器,它们相互靠近/重叠,分别使用Row()/Column()小部件。这两个容器在其盒子装饰参数中都有投影效果。如果它们彼此接近,则位于顶部/左侧的一个会在另一个上投下阴影。
有没有一种方法可以使小部件不绘制阴影?
编辑:这是我的意思的示例。 我不希望第一个容器从第二个容器中产生阴影,而是希望两个容器都在阴影上方。
以下是此示例的代码:您可以将其复制粘贴到dartpad.dev进行快速测试。
有没有一种方法可以使小部件不绘制阴影?
编辑:这是我的意思的示例。 我不希望第一个容器从第二个容器中产生阴影,而是希望两个容器都在阴影上方。
以下是此示例的代码:您可以将其复制粘贴到dartpad.dev进行快速测试。
import 'package:flutter/material.dart';
final Color darkBlue = Colors.grey[200]!;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.light().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: Row(
children: [
SizedBox(width: 20),
Container(
height: 100,
width: 300,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [BoxShadow(
blurRadius: 20,
color: Colors.black.withOpacity(0.6)
)]
),
),
Container(
height: 100,
width: 300,
decoration: BoxDecoration(
color: Colors.white,
boxShadow: [BoxShadow(
blurRadius: 20,
color: Colors.black
)]
),
),
]
),
),
),
);
}
}