Home > database >  Animated Splash Screen showing white page
Animated Splash Screen showing white page

Time:09-29

i wanted to use the AnimatedSplashScreen but in my case it didnt work. This is the AnimatedSplashScreen displayed in my app: AnimatedSplashScreen displayed in my app

Here my SplashScreen-Class:

class SplashScreen extends StatelessWidget {
  const SplashScreen({super.key});

  @override
  Widget build(BuildContext context) {
    final user = AuthService().currentUser;
    String nextScreen =
        user != null ? RoutesEnum.homePage : RoutesEnum.loginPage;

    return AnimatedSplashScreen(
      duration: 1500,
      splash: Icons.home,
      nextScreen: LoginPage(),
      nextRoute: nextScreen,
      splashTransition: SplashTransition.rotationTransition,
    );}}

And my main.dart where the MaterialApp is created:

    void main() async {
      WidgetsFlutterBinding.ensureInitialized();
      await Firebase.initializeApp();
      runApp(MaterialApp(
      debugShowCheckedModeBanner: false,
      theme: mainTheme,
      home: const SplashScreen(),
      routes: {
        //RoutesEnum.splashScreen: (context) => const SplashScreen(),
        RoutesEnum.loginPage: (context) => LoginPage(),
        RoutesEnum.signUpPage: (context) => SignUpPage(),
        RoutesEnum.homePage: (context) => HomePage(),
      },
      ));
      }

What am I doing wrong?

Thanks for ypur help.

Edit:

This is my LoginPage:

class LoginPage extends StatefulWidget {
  @override
  _LoginPageState createState() => _LoginPageState();
}

class _LoginPageState extends State<LoginPage> {
  final authService = AuthService();

  final emailcon = TextEditingController();
  final passwordcon = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      resizeToAvoidBottomInset: false,
      body: Stack(
        children: [
          Padding(
            padding: const EdgeInsets.all(12),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Image.asset(
                  "assets/images/Logo_ohne_Hintergrund.png",
                  color: Colors.white.withOpacity(0.75),
                  colorBlendMode: BlendMode.modulate,
                ),
                addVerticalSpace(60),
                addFormEmailPassword(emailcon, passwordcon),
                addVerticalSpace(20),
                RoundButton(
                  title: "Login",
                  tapfun: () => {
                    if (emailcon.text.toString().isEmpty ||
                        passwordcon.text.toString().isEmpty)
                      {
                        toastmessage("Eingaben prüfen"),
                      }
                    else
                      {
                        authService
                            .signInWithEmailAndPassword(
                              email: emailcon.text.toString(),
                              password: passwordcon.text.toString(),
                            )
                            .then(
                              (value) => {
                                if (value)
                                  {
                                    Navigator.pushReplacementNamed(
                                      context,
                                      RoutesEnum.homePage,
                                    ),
                                  }
                              },
                            ),
                      }
                  },
                ),
                addVerticalSpace(20),
                const Text("- OR -"),
                addVerticalSpace(20),
                GoogleAuthButton(
                  style: AuthButtonStyle(
                    buttonType: AuthButtonType.icon,
                    buttonColor: Theme.of(context).backgroundColor,
                    borderRadius: 25,
                  ),
                  onPressed: () => {
                    authService.signInWithGoogle().then(
                          (value) => {
                            Navigator.pushReplacementNamed(
                              context,
                              RoutesEnum.homePage,
                            ),
                          },
                        ),
                  },
                ),
                addVerticalSpace(20),
                RoundButton(
                  title: "Toast",
                  tapfun: () {
                    toastmessage(
                      authService.currentUser == null
                          ? "NULL"
                          : authService.currentUser!.email.toString(),
                    );
                  },
                ),
              ],
            ),
          ),
          Padding(
            padding: const EdgeInsets.all(30),
            child: Align(
              alignment: Alignment.bottomCenter,
              child: Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  const Text(
                    "Don't have an account?",
                    style: TextStyle(
                      color: Colors.white,
                    ),
                  ),
                  TextButton(
                    onPressed: () {
                      Navigator.pushNamed(
                        context,
                        RoutesEnum.signUpPage,
                      );
                    },
                    child: const Text("Sign Up"),
                  ),
                ],
              ),
            ),
          )
        ],
      ),
    );
  }
}

CodePudding user response:

Use below-mentioned package:

enter image description here

  • Related