This is my main.dart page code
import 'package:cwc/OnBoard/landing_page.dart';
import 'package:cwc/OnBoard/login_page.dart';
import 'package:cwc/ui/Home/home_page.dart';
import 'package:cwc/ui/signup/signup_page.dart';
import 'package:firebase_core/firebase_core.dart';
// import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'ApiManager/api_magager.dart';
import 'ApiManager/preference.dart';
// import 'Delete/delete.dart';
import 'Delete/delete.dart';
import 'OnBoard/enter_details.dart';
import 'OnBoard/sign_up_page.dart';
import 'OnBoard/varify_email_page.dart';
import 'constants/constants.dart';
Widget initialRoute = HomePage();
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
var token = await Preferences.loadData("token");
var name = await Preferences.loadData("name");
var zipCode = await Preferences.loadData("zipCode");
var city = await Preferences.loadData("city");
var state = await Preferences.loadData("state");
var country = await Preferences.loadData("country");
var status = await Preferences.loadData("status");
var image = await Preferences.loadData("image");
// Preferences.clearData('token');
print("name -- $name");
print("zipCode -- $zipCode");
print("city -- $city");
print("state -- $state");
print("country -- $country");
print("token -- $token");
print("status -- $status");
print("image -- $image");
if (token == null || token == "null") { // my first condition
initialRoute = LoginPage();
} else if (token != null || token != "null") { // my second condition
if ((name == null || name == "null") ||
(zipCode == null || zipCode == "null") ||
(city == null || city == "null") ||
(state == null || state == "null") ||
(country == null || country == "null")) {
initialRoute = EnterDetails();
}
} else if ((token != null || token != "null") && // my third condition
(name != null || name != "null")) {
print("status1 -- $status");
if ((status == null || status == "null" || status == "inactive")) {
initialRoute = LandingPage();
}
}
await Firebase.initializeApp();
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({Key? key}) : super(key: key);
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
ApiManager apiManager = ApiManager();
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: initialRoute,
// home:SignInScreen(),
);
}
}
This is Code I mentioned three condition. my first and second condition working fine but third condition not working fine I dont know why. I third condtion my token and name is not null then its check again if my status is equal to "inactive" then it should be redirect on my landing page. But These things not working. this things should be work when reload the project.
In this Screenshot token,name,state,city,country not null and my status is inactive. now when I reload the flutter project then it should be redirect on LandingPage But it is going on homepage