I have this seperate page that I navigate to it and I am testing my Question widget with a ListView.builder(). The error occurs when I navigate to the page, at ListView.builder(). I am new to ListView/GridView builders so I followed some tutorials about it. I can't figure out the issue here.
import 'package:flutter/material.dart';
import 'consonants.dart';
import 'functions.dart';
import 'question_bank.dart';
int sum = 0;
class HTP extends StatefulWidget {
HTP({ Key? key }) : super(key: key);
@override
State<HTP> createState() => HTPState();
}
class HTPState extends State<HTP> {
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: title,
home: Scaffold(
backgroundColor: Color(0xFF88FFEF),
appBar: AppBar(
backgroundColor: theme_color,
title: const Text(title,
style: TextStyle(
fontSize: 25,
fontWeight: FontWeight.w400,
color: Colors.white
)
)
),
body: ListView(
padding: const EdgeInsets.all(5),
children: [
Text('TITLE',
style: TextStyle(
fontSize: 28, fontWeight: FontWeight.w700)
),
Question(
'A',
'1. ...\n2. ...',
['a', 'b', 'c'],
['etc 1', 'etc 2', 'etc 3']
)
]
)
)
);
}
Widget Question(String group_name, String conditions, List<String> subgroups, List<String> options) {
return Column(
children: [
Text('GROUP $group_name',
style: TextStyle(
fontWeight: FontWeight.w800,
fontSize: 18,
color: theme_color
)
),
Align(
alignment: Alignment.centerLeft,
child: Text(conditions,
style: TextStyle(fontSize: 16)
)
),
Align(
alignment: Alignment.centerLeft,
child: ListView.builder(
itemCount: question_points.length,
itemBuilder: (context, index) {
return ListTile(
title: Text(question_points[index].toString())
);
}
)
)
],
);
}
}
I am going to display the arguments passed to the widget without using a for loop.
Add to your nested ListView in the Question Widget:
shrinkWrap: true
physics: const NeverScrollableScrollPhysics()
.