假设所有屏幕都需要与上图相同大小的水平填充,所以我制作了一个每个屏幕都使用的基本布局小部件.
class BaseLayout extends StatelessWidget {
final Widget child;
const BaseLayout({super.key, required this.child});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Padding(
padding: const EdgeInsets.symmetric(horizontal: 15),
child: SafeArea(child: child)),
);
}
}
class HomeScreen extends StatelessWidget {
const HomeScreen({super.key});
@override
Widget build(BuildContext context) {
return BaseLayout(
child: Column(
children: [
Container( // how to make only this one take whole width of the screen unlike others?
decoration: const BoxDecoration(color: Color(0xffFFFF7E)),
),
// the below Rows need to take the padding and it does due to the BaseLayout
Row(),
Row()
],
),
);
}
}
然而,像黄框这样的小部件必须占据屏幕的整个宽度尺寸(不需要填充).
有可能吗?或者我不应该使用布局并将其交给需要的人.
提前感谢.