'on login page navigation am sending the response

Am trying to achieve app that if person logged in the response of app is sent to another screen. here it is asking to add the same details in splash screen, am using shared preferences to see the user is logged in or not. how can we fix this issue.

splash.dart

  @override
  void initState() {
    super.initState();
    // navigate();
    getValidationData().whenComplete(() async {
      Future.delayed(const Duration(seconds: 6), () {
        PageNavigator(ctx: context).nextPageOnly(
            page: finalEmail == null ? const LoginPage() : const HomeScreen(// what to do here));
      });
    });
  }

login.dart

        ///Save users data and then navigate to homepage
        final int userId = res['userId'];
        final String token = res['token'];
        final bool recharge = res['recharge'];
        final String name = res['name'];
        PageNavigator(ctx: context).nextPageOnly(
            page: HomeScreen(
          userId: userId,
          token: token,
          recharge: recharge,
          name: name,
        ));

home.dart

class HomeScreen extends StatefulWidget {
  final int userId;
  final String token;
  final bool recharge;
  final String name;

  const HomeScreen({
    Key? key,
    required this.userId,
    required this.token,
    required this.recharge,
    required this.name,
  }) : super(key: key);


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source