Skip to content

Instantly share code, notes, and snippets.

@vicradon
Created April 18, 2020 05:34
Show Gist options
  • Save vicradon/0dcaa634b31cb05fc70cdde90e8ed154 to your computer and use it in GitHub Desktop.
Save vicradon/0dcaa634b31cb05fc70cdde90e8ed154 to your computer and use it in GitHub Desktop.
class Checkout extends StatelessWidget {
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Checkout')),
body: StreamBuilder(
stream: bloc.getStream,
initialData: bloc.allItems,
builder: (context, snapshot) {
return snapshot.data['cart items'].length > 0
? Column(
children: <Widget>[
/// The [checkoutListBuilder] has to be fixed
/// in an expanded widget to ensure it
/// doesn't occupy the whole screen and leaves
/// room for the the RaisedButton
Expanded(child: checkoutListBuilder(snapshot)),
RaisedButton(
onPressed: () {},
child: Text("Checkout"),
color: Theme.of(context).primaryColor,
),
SizedBox(height: 40)
],
)
: Center(child: Text("You haven't taken any item yet"));
},
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment