flutter modal_progress_hud code example

Example 1: model progress hud flutter

Used to add loading..... when logging in and during registration

Example 2: hud flutter

bool spooner = false;
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.white,
      body: ModalProgressHUD(
        inAsyncCall: spooner,
        child: RoundedButton(
                title: 'Register',
                color: Colors.lightBlueAccent,
                onPressed: () async {
                  setState(() {
                    spooner = true;
                  });
                  try {
                    final newUser = await _auth.createUserWithEmailAndPassword(
                        email: email, password: password);
                    if (newUser != null) {
                      Navigator.pushNamed(context, ChatScreen.id);
                    }
                    setState(() {
                      spooner = false;
                    });
                  } catch (e) {
                    print(e);
                  }
                },
              ),
            ],
}

Tags:

Misc Example