ToyZ-95/another_flutter_splash_screen

double splash screen

Closed this issue · 8 comments

Am I supposed to see double splash screen? I first see the standard flutter splash screen before seeing the splash screen.

Steps to reproduce:

goRouterConfig = GoRouter(
    initialLocation: AppRoute.splash.path,
    navigatorKey: rootNavigatorKey,
    routes: [
      GoRoute(
        path: AppRoute.splash.path,
        name: AppRoute.splash.name,
        pageBuilder: (context, state) => NoTransitionPage(
          key: state.pageKey,
          child: const SplashPage(),
        ),
      ),
      GoRoute(
        path: AppRoute.login.path,
        name: AppRoute.login.name,
        pageBuilder: (context, state) => NoTransitionPage(
          key: state.pageKey,
          child: const LoginPage(),
        ),
      ),
    ],
  );

SplashPage:

import 'package:another_flutter_splash_screen/another_flutter_splash_screen.dart';


class SplashPage extends StatefulWidget {
  const SplashPage({super.key});

  @override
  State<SplashPage> createState() => _SplashPageState();
}

class _SplashPageState extends State<SplashPage> {
  data(BuildContext context) {}
  @override
  Widget build(BuildContext context) {
    return FlutterSplashScreen(
      duration: const Duration(milliseconds: 5000),
      splashScreenBody: Container(
        padding: EdgeInsets.only(bottom: 100, top: MediaQuery.of(context).size.height * 0.2),
        decoration: BoxDecoration(
          image: DecorationImage(
            image: Assets.images.welcomeBackground.image().image,
            fit: BoxFit.fill,
          ),
        ),
        child: Column(
          children: [
            Assets.images.appLogoWithName.image(height: percentHeight(context, 6)),
            Expanded(child: Container()),
            Text(context.l10n.splashTitle, style: textSH4),
          ],
        ),
      ),
      asyncNavigationCallback: () async {
        await Future.delayed(const Duration(seconds: 3));
        if (context.mounted) context.replace(AppRoute.login.path);
      },
    );
  }
}

are you seeing splash screen with flutter logo? @MiroslavBlagoev

Looking into it. Will update you guys

Hi @ToyZ-95 , I dug into it, and I found out that on Android 12 and above, the splash screen can only be a solid color. This might be the reason.
Here's a source: https://developer.android.com/develop/ui/views/launch/splash-screen

Hi @MiroslavBlagoev, Thank you very much for your efforts.
May I ask you if there is a way to tackle it or something?
Because I think this solid color screen shows before the flutter app starts.
And I don't think this is a bug as this is the default behaviour of android app.

What do you suggest @MiroslavBlagoev ?

Yes, this is the default behavior and it cannot be changed. If you want, you can inform the users of this issue on Android 12 or above on your package page in pub.dev so that they know why it doesn't work.

Yeah Sure, Thanks for your suggestion. I will update it next release.
Closing the issue.