Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Loader not init. #50

Open
SaritaAgravat opened this issue Jun 30, 2023 · 4 comments
Open

Loader not init. #50

SaritaAgravat opened this issue Jun 30, 2023 · 4 comments

Comments

@SaritaAgravat
Copy link

Hello ,
i already worked with this loader.

Some pages display the loader, Same functionality worked not another page.

Given the below message.
LateInitializationError: Field '_overlayController@1721390500' has not been initialized.

All routes pages with set the below code.

RoutesApp.locationScreenPage: (context) => LoaderOverlay(
child: LocationScreenPage(),
useDefaultLoading: false,
overlayWidget: Center(
child: SpinKitCubeGrid(
color: AppColor.app_red,
size: 50.0,
),
),
overlayColor: Colors.black,
overlayOpacity: 0.8,
)

And all pages with show and hide according to below code.

Hide.
context.loaderOverlay.hide();
_isLoaderVisible = context.loaderOverlay.visible;

Show :
context.loaderOverlay.show();
_isLoaderVisible = context.loaderOverlay.visible;

Please give suggestions about late LateInitializationError.

@rodrigobastosv
Copy link
Owner

It's not recomended to add one LoaderOverlay for each and every page. The best way to use it, is to add one global loader and use it on all the pages.

@callmephil
Copy link

callmephil commented Aug 25, 2023

If you are using Navigation 2.0 (MaterialApp.router) you can use the builder approach to apply LoaderOverlay to your entire app.

MaterialApp.router(
...
builder: (_, Widget? app) => LoaderOverlay(app),
...
);

@PrimeTimeTran
Copy link

PrimeTimeTran commented Sep 1, 2023

@rodrigobastosv @callmephil could you recommend how to do it when using goRouter and config instead of builder?

MaterialApp.router(
  // code...
  routerConfig: goRouter,
  // more code...
)

@callmephil
Copy link

@rodrigobastosv @callmephil could you recommend how to do it when using goRouter and config instead of builder?

MaterialApp.router(
  // code...
  routerConfig: goRouter,
  // more code...
)

The method I shared is the best I found for GoRouter and Material.router in general.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants