I'm trying to build a simple bottom navigation bar, following Flutter documentation, why is this throwing error at the ListView.builder?
List<RouteItem> items = [];
String _server = '';
late SharedPreferences _prefs;
int _selectedIndex = 0;
static const TextStyle optionStyle =
TextStyle(fontSize: 30, fontWeight: FontWeight.bold);
static const List<Widget> _widgetOptions = <Widget>[
Expanded(
child: ListView.builder(
shrinkWrap: true,
padding: const EdgeInsets.all(0.0),
itemCount: items.length,
itemBuilder: (context, i) {
return _buildRow(context, items[i]);
}
),
),
MyWidgetTwo(),
Text(
'SomeText',
style: optionStyle,
),
];
I tried to add Expanded( ... before the ListView.builder as you can see above, by following other suggestions, but it doesn't change
UPDATE: vscode point me out that List is declared as const , and so ListView is dynamic, does creating a widget for ListView and then loading that instead inside List solves the problem?