Skip to content

Instantly share code, notes, and snippets.

@guilhermecarvalhocarneiro
Created October 2, 2020 18:54
Show Gist options
  • Save guilhermecarvalhocarneiro/3abae358b5922832432a0eb020a15750 to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/3abae358b5922832432a0eb020a15750 to your computer and use it in GitHub Desktop.
Cubit
child: 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