【发布时间】:2023-01-07 00:38:49
【问题描述】:
class Episodes extends StatefulWidget {
const Episodes({super.key});
@override
State<Episodes> createState() => _EpisodesState();
}
class _EpisodesState extends State<Episodes> {
final seasons = ['Season 1', 'Season 2', 'Season 3'];
String? value;
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
//EdgeInsets.only(left: size.width * 0.03, right: size.width * 0.03),
return SingleChildScrollView(
physics: const AlwaysScrollableScrollPhysics(),
child: Column(
children: [
Container(
height: size.height * 0.045,
width: size.width * 0.25,
decoration: BoxDecoration(
color: Colors.grey.withOpacity(0.25),
borderRadius: BorderRadius.circular(5)),
child: DropdownButtonHideUnderline(
child: DropdownButton<String>(
value: value,
alignment: Alignment.center,
isExpanded: true,
//icon: Icon(Icons.arrow_drop_down_outlined,
// size: 12, color: Colors.white),
iconEnabledColor: Colors.white,
//dropdownColor: Colors.transparent,
items: seasons.map(buildMenuItem).toList(),
dropdownColor: Colors.grey.withOpacity(0.3),
onChanged: (value) => setState(() {
this.value = value;
}),
),
),
),
SizedBox(height: size.height * 0.02),
ListView.builder(
shrinkWrap: true,
//physics: const AlwaysScrollableScrollPhysics(),
itemCount: 15,
scrollDirection: Axis.vertical,
itemBuilder: (context, index) {
return Padding(
padding: const EdgeInsets.only(bottom: 8),
child: Container(
color: Colors.red,
height: 15,
width: 15,
),
);
},
),
],
),
);
}
DropdownMenuItem<String> buildMenuItem(String item) => DropdownMenuItem(
value: item,
child: Center(
child: Text(
item,
style: GoogleFonts.poppins(color: Colors.white, fontSize: 12),
),
));
}
我正在尝试构建一个 netflix 克隆,这是标题页中剧集列表的设计。 基本上,我试图在列中包含 listview.builder(vertical);但我收到溢出错误。 此列进一步作为另一个文件中父列的子列之一返回。
到目前为止,我已经尝试将列包装在以下位置: *单子滚动视图, *展开 *SizedBox, Container : 固定高度
以上均无效;我什至尝试玩弄滚动物理,但没有用,溢出错误仍然存在。
我是新来的;我只想摆脱溢出错误。任何帮助将不胜感激! 此外,我希望从 firebase 动态获取详细信息并在此处显示它们。对此的任何提示也将不胜感激!
【问题讨论】:
-
它正在工作,你能包括更多关于它的父部件的信息吗
标签: flutter listview overflow singlechildscrollview