提问人:Abdusattarov Abdusamad 提问时间:8/8/2023 最后编辑:toyota SupraAbdusattarov Abdusamad 更新时间:8/8/2023 访问量:55
在行中颤动两个 Listview
Flutter two Listview in Row
问:
我里面有 2 个列表视图行小部件,我把它们放在一个 SingleChildScrollView 中,以便两者都具有相同的滚动。但什么都看不见。
代码如下:
child: Row(children: [
SingleChildScrollView(
child: Row(
children: [
Expanded(
child: ListView(
physics: NeverScrollableScrollPhysics(),
controller: _scrollController2,
children: your_history.map((item) {
return Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [
Text("Sizning javobingiz:"),
Text(item)
],
),
],
),
),
Divider(
color: Colors.black,
),
],
);
}).toList(),
),
),
Expanded(
child: ListView(
physics: NeverScrollableScrollPhysics(),
controller: _scrollController,
children: true_history.map((item) {
return Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [Text("To'g'ri javob:"), Text(item)],
),
],
),
),
Divider(
color: Colors.black,
),
],
);
}).toList(),
),
),
],
),
),
]),
SingleChildScrollView ning ichiga joyladim.Ammo hech narsa ko'rinmayabdi. 仅使用字符串列表
错误如下:
RenderBox was not laid out: RenderPointerListener#fb2be relayoutBoundary=up5 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1966 pos 12: 'hasSize'
答:
0赞
pixel
8/8/2023
#1
删除第一个,它将开始工作。
您不需要使列表可滚动,因为 ListView 本身是可滚动的。Row
SingleChildScrollView
SingleChildScrollView
Row(
children: [
Expanded(
child: ListView(
physics: NeverScrollableScrollPhysics(),
controller: _scrollController2,
children: your_history.map((item) {
return Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [
Text("Sizning javobingiz:"),
Text(item)
],
),
],
),
),
Divider(
color: Colors.black,
),
],
);
}).toList(),
),
),
Expanded(
child: ListView(
physics: NeverScrollableScrollPhysics(),
controller: _scrollController,
children: true_history.map((item) {
return Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [Text("To'g'ri javob:"), Text(item)],
),
],
),
),
Divider(
color: Colors.black,
),
],
);
}).toList(),
),
),
],
),
0赞
Genius_balu
8/8/2023
#2
List your_history = ['1','2','3','4','1','2','3','4','1','2','3','4','1','2','3','4','1','2','3','4','1','2','3','4'];
List true_history = ['1','2','3','4'];
return Scaffold(
body: SingleChildScrollView(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Expanded(
child: ListView(
physics: NeverScrollableScrollPhysics(),
primary: false,
shrinkWrap: true,
// controller: _scrollController2,
children: your_history.map((item) {
return Column(
children: [
Container(
child:Column(
children: [
Text("Sizning javobingiz:"),
Text(item)
],
),
),
Divider(
color: Colors.black,
),
],
);
}).toList(),
),
),
Expanded(
child: ListView(
physics: NeverScrollableScrollPhysics(),
primary: false,
shrinkWrap: true,
// controller: _scrollController,
children: true_history.map((item) {
return Column(
children: [
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
Column(
children: [Text("To'g'ri javob:"), Text(item)],
),
],
),
),
Divider(
color: Colors.black,
),
],
);
}).toList(),
),
),
],
)),
);
评论