假设我有一个这样的gridview:
class ImagesGrid extends StatelessWidget {
@override
Widget build(BuildContext context) {
final size = MediaQuery.of(context).size;
final imagesData = Provider.of<Pictures>(context);
final images = imagesData.items;
return GridView.builder(
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
crossAxisCount: 3,
childAspectRatio: size.width / size.height ,
),
padding: const EdgeInsets.all(10.0),
itemCount: images.length + 1,
itemBuilder: (ctx, i) => ChangeNotifierProvider.value(
value: images[i],
child: images.length == 0 ? Text('No images'): ImageWidget(),
),
);
}
}
现在,假设我希望在其中添加一个FlatButton
作为GridView
最后一项,它将用于添加另一个数据。我该怎么做?