Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created August 20, 2020 12:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermecarvalhocarneiro/0c53806cbc2b3e25af07633da0b215cb to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/0c53806cbc2b3e25af07633da0b215cb to your computer and use it in GitHub Desktop.
BlocConsumer<UsuarioCubit, UsuarioState>(
listener: (context, state) {
if (state is UsuarioProcessState) {
FlutterToast(context).showToast(
child: Container(
color: Colors.blue[200],
width: double.infinity,
child: Column(
children: [
LinearProgressIndicator(),
Padding(
padding: const EdgeInsets.all(8.0),
child: Text("Carregando..."),
),
],
),
),
);
}
if (state is UsuarioErrorState) {
debugPrint(state.error);
}
if (state is UsuarioSuccessState) {
FlutterToast(context).showToast(
child: Container(
color: Colors.blue[200],
width: double.infinity,
child: Padding(
padding: const EdgeInsets.all(8.0),
child: Text(state.successMessage),
),
),
);
}
},
builder: (context, state) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'',
style: Theme.of(context).textTheme.headline4,
),
RaisedButton(
onPressed: () async {
context.bloc<UsuarioCubit>().fetchEscola();
},
child: Text("Carregar"))
],
);
},
),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment