Created
April 18, 2020 14:31
-
-
Save techpotatoes/92b5de77510c36d41400bb41a9137fd8 to your computer and use it in GitHub Desktop.
Flutter development series - part4
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 LoyaltyListPage extends StatefulWidget { | |
LoyaltyListPage({Key key}) : super(key: key); | |
@override | |
_LoyaltyListPageState createState() => _LoyaltyListPageState(); | |
} | |
class _LoyaltyListPageState extends State<LoyaltyListPage> { | |
@override | |
void initState() { | |
super.initState(); | |
BlocProvider.of<LoyaltyBloc>(context).add(Fetch()); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Loyalty"), | |
), | |
body: Container( | |
child: | |
BlocBuilder<LoyaltyBloc, LoyaltyState>(builder: (_, state) { | |
switch (state.runtimeType) { | |
case LoyaltyEmpty: | |
return _EmptyWidget(); | |
break; | |
case LoyaltyLoading: | |
return CircularProgressIndicator(); | |
break; | |
case LoyaltyError: | |
return _ErrorWidget(); | |
break; | |
case LoyaltyLoaded: | |
return _LoadedWidget(loyaltyCards: state.props.first); | |
break; | |
default: | |
return _ErrorWidget(); | |
} | |
}), | |
)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment