Created
October 2, 2020 18:54
-
-
Save guilhermecarvalhocarneiro/3abae358b5922832432a0eb020a15750 to your computer and use it in GitHub Desktop.
Cubit
This file contains hidden or 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
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