Flutter:如何创建一个可滚动的两列?



我有这种Flutter代码片段。

body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Padding(
padding: const EdgeInsets.all(50),
child: Row(
children: [
Expanded(
flex: 1,
child: Column(
children: const [
DateSelection(),
SizedBox(height: 100),
ReportSummaries(),
],
),
),
const SizedBox(width: 50),
Expanded(
flex: 2,
child: CustomTable(results: results), // This should be scrollable.
),
],
),
),
],
),
),

如何使CustomTable可滚动?CustomTable下面有Flutter的DataTable

试试这个布局

SizedBox(
height: MediaQuery.of(context).size.height,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
Expanded(
flex: 1,
child: Column(
children: [], //non scrollable Column
)
),
Expanded(
flex: 2,
child: SingleChildScrollView (
child: Column(
mainAxisSize: MainAxisSize.min,
children: [], // scrollable Column
)
)
)
]
)
)

最新更新