【发布时间】:2020-05-27 11:13:21
【问题描述】:
谁能帮帮我?
我正在努力弄清楚如何让彩色容器延伸以匹配其所在行中最高容器的高度。
目前它们没有固定的高度/宽度,并且被包裹在展开的小部件中以获得它们的动态大小。
如果可能,我想保持它们的响应尺寸。一旦屏幕足够小,我已经有一种方法可以切换到列而不是行。一旦在一个列中,我可以使用width: double.infinity,因为没有水平滚动..
这是使用的代码示例(抱歉,内容太多了!):
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Scrollbar(
child: CustomScrollView(
slivers: <Widget>[
SliverNavBar(),
SliverList(
delegate: SliverChildListDelegate(
[
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: _homePageContent(),
);
Footer()
],
),
),
],
),
),
);
}
}
_homePageContent() {
return <Widget>[
_HomePageInfoBox(
backgroundColor: accentColor,
title: 'THIS IS A TITLE',
body:
'Lorem ipsum...',
),
_HomePageInfoBox(
backgroundColor: primaryColorDark,
title: 'THIS IS A TITLE',
body:
'Lorem ipsum....',
),
_HomePageInfoBox(
backgroundColor: primaryColor,
title: 'THIS IS A TITLE',
body:
'Lorem ipsum...',
),
];
}
class _HomePageInfoBox extends StatelessWidget {
const _HomePageInfoBox({
Key key,
@required this.title,
@required this.body,
@required this.backgroundColor,
}) : super(key: key);
final String title;
final String body;
final Color backgroundColor;
@override
Widget build(BuildContext context) {
return Expanded(
Container(
color: backgroundColor,
child: Padding(
padding: const EdgeInsets.all(50),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
Text(
title,
style: TextStyle(
color: primaryTextColor,
fontSize: 25,
fontFamily: 'CoffeeAndTea'),
),
SizedBox(height: 10),
Text(
body,
style: TextStyle(
color: primaryTextColor,
fontSize: 24,
height: 1.4,
fontFamily: 'ElegantSans'),
),
SizedBox(height: 20),
Text(
"Let's Go!",
style: TextStyle(
color: Colors.white, fontFamily: 'CreamCake', fontSize: 30),
textAlign: TextAlign.center,
),
],
),
),
),
);
}
}
【问题讨论】:
-
嗨,伙计,不,遗憾的是没有。我得到一个没有最大高度的渲染框错误。它对你有用还是你有任何其他想法?
标签: flutter dart flutter-layout flutter-web