I can't get a list to be displayed in a Gridview.builder.
List<Widget> booksList = [];
return new GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
itemCount: libraryList.length,
itemBuilder: (BuildContext ctx, index) {
return booksList;
);
});
It returns the error "The return type 'List' isn't a 'Widget', as required by the closure's context." and I am stuck on how to proceed.
CodePudding user response:
List<Widget> booksList = [
Text('Hello'),
Text('World')];
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
mainAxisSpacing: 10,
crossAxisSpacing: 10,
),
itemCount: libraryList.length,
itemBuilder: (BuildContext ctx, index) {
return booksList[index];
);
});