I'm working on an app that requires asynchronous loading before my main screen shows up.
It initializes some provider classes, thus instead of initializing in main() and using the native splash screen (which I could not get the BuildContext required for provider), I decided to create my own splash screen as a widget.
This approach worked fine until I added a logo using Image.asset().
The image was loading too slowly, often slower than my original initialization, which means that my splash screen stays blank.
Just for reference, this is my splash screen layout:
Container(
alignment: Alignment.center,
color: Theme.of(context).scaffoldBackgroundColor,
child: Center(
child: Image.asset("logo.png"),
)
);
I came across the function precacheImage(), but this also requires BuildContext, thus couldn't be used before the splash screen is shown.
Is there any better approach to this? Thanks in advance.