-
-
Save boeledi/1f2ee3e13740fa6a0ea32ff1119a4796 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ShoppingPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
ShoppingBloc bloc = BlocProvider.of<ShoppingBloc>(context)!; | |
return SafeArea( | |
child: Scaffold( | |
appBar: AppBar( | |
title: Text('Shopping Page'), | |
actions: <Widget>[ | |
ShoppingBasket(), | |
], | |
), | |
body: Container( | |
child: StreamBuilder<List<ShoppingItem>>( | |
stream: bloc.items, | |
builder: (BuildContext context, | |
AsyncSnapshot<List<ShoppingItem>> snapshot) { | |
if (!snapshot.hasData) { | |
return Container(); | |
} | |
return GridView.builder( | |
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount( | |
crossAxisCount: 3, | |
childAspectRatio: 1.0, | |
), | |
itemCount: snapshot.data.length, | |
itemBuilder: (BuildContext context, int index) { | |
return ShoppingItemWidget( | |
shoppingItem: snapshot.data[index], | |
); | |
}, | |
); | |
}, | |
), | |
), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment