Home > Software design >  How to show loading indicator in simple way?
How to show loading indicator in simple way?

Time:11-10

I'm coding await user?.reload();//here to reload `UserClass ' and during reloading, want to display indicator.

I learned Using FutureProvider-when() method from river_pod or 'FutureBuilder-snapshot` to implement this indicator.

Is these resolve is general or wonder there is more simple way to implement indicator display like this case ?

thanks for your helpful comment.

void currentUserNotNull(User? user, ref) async {
  try {
    var user = FirebaseAuth.instance.currentUser;
    await user?.reload();//here
    ref.read(authLoadingProvider.notifier).update((state) => false);
  } on FirebaseAuthException catch (e) {
//
  }
}

CodePudding user response:

Iam using this method to loading, you can also use flutter spinners also

Try this

showLoaderDialog(BuildContext context){ AlertDialog alert=AlertDialog( content: new Row( children: [ CircularProgressIndicator(), Container(margin: EdgeInsets.only(left: 7),child:Text("Loading..." )), ],), ); showDialog(barrierDismissible: false, context:context, builder:(BuildContext context){ return alert; }, ); }

CodePudding user response:

I could solve this using flutter_easyloading package like

import 'package:flutter_easyloading/flutter_easyloading.dart';
void currentUserNotNull(User? user, ref) async {
  try {
    EasyLoading.show(maskType: EasyLoadingMaskType.black, status: "Loading...");
    var user = FirebaseAuth.instance.currentUser;
    await user?.reload();//here
    EasyLoading.dismiss();
  } on FirebaseAuthException catch (e) {
//
  }
}

but still wonder I should do this or not...

  • Related