【发布时间】:2021-09-25 03:09:49
【问题描述】:
我是 Flutter 的新手。我有 2 个Containers 和SizedBox。我正在尝试为第一个设置水平滚动:Slider1LocalPage()。
我阅读了它并尝试使用scrollDirection: Axis.horizontal,但它会导致错误。我尝试使用Column,但没有成功。
帮助我的示例将帮助我学习和理解颤振。 这是我在 main.dart
中的小部件主体 body: SingleChildScrollView(
child: Column(
children: <Widget>[
Text(
'Horizontal - can\'t deal with',
style: TextStyle(fontSize: 18),
),
Container(
child: SizedBox(height: 260.0, child: Slider1LocalPage()),
),
Text(
'Vertical',
style: TextStyle(fontSize: 18),
),
Container(
child: SizedBox(height: 290, child: List1LocalPage()),
)
],
),
),
Slider1LocalPage()
class Slider1LocalPage extends StatelessWidget {
@override
Widget build(BuildContext context) => Scaffold(
body: FutureBuilder<List<Record>>(
future: List1Api.getList1Locally(context),
builder: (context, snapshot) {
final records = snapshot.data;
switch (snapshot.connectionState) {
case ConnectionState.waiting:
return Center(child: CircularProgressIndicator());
default:
if (snapshot.hasError) {
return Center(child: Text('Some error occurred!'));
} else {
return buildList1(records);
}
}
},
),
);
Widget buildList1(List<Record> records) => ListView.builder(
physics: BouncingScrollPhysics(),
itemCount: records.length,
itemBuilder: (context, index) {
final record = records[index];
return ListTile(
onTap: () => Navigator.of(context).push(MaterialPageRoute(
builder: (BuildContext context) => ContentPage(record: record),
)),
leading: CircleAvatar(
backgroundImage: NetworkImage(record.urlAvatar),
),
title: Text(record.title1),
subtitle: Text(record.content1),
);
},
);
}
【问题讨论】:
标签: visual-studio flutter dart listview mobile