Search code examples
iosflutterfirebasedartflutter-dependencies

Login and Signup Screen not showing and in ios flutter


I am facing a strange issue, I am working on an app that is already built by another developer flutter, and is also available on the app store. When I run the code on the simulator it does not show the login and signup screen but shows the recruiter screen while it works fine on android here is a condition that we check if a user is login or not

Future.delayed(
    const Duration(seconds: 2),
    () => {
          if (_result.userData?.uid != null)
            {
              _permissions(_result.userData?.uid ?? 'oh'),
              if (_result.userData?.atype == 'Recruiter')
                {
                  Navigator.pushReplacementNamed(
                      context, "/Ind_select_ricruiter")
                }
              else
                {
                  if ((_result.userData?.industry1 == '' ||
                      _result.userData?.industry2 == '' ||
                      _result.userData?.industry3 == ''))
                    {
                      Navigator.pushReplacementNamed(
                          context, "/Ind_select_jobseaker")
                    }
                  else
                    {
                      print(_result.userData?.video),
                      if (_result.userData?.video == '')
                        {
                          Navigator.pushReplacementNamed(
                              context, "/ManageVideo")
                        }
                      else
                        {
                          downloadFile(
                              'my file'),
                        
                          Navigator.pushAndRemoveUntil(
                              context,
                              MaterialPageRoute(
                                  builder: (context) => HOmepage_jobseaker(
                                      _result.userData?.video ?? 'oh')),
                              (Route<dynamic> route) => false),
                        }
                    }
                }
            }
          else
            {Navigator.pushReplacementNamed(context, "/signIn")},
        });

Here is the provider of userdata

class UserProvider extends ChangeNotifier {
  UserData? _userData;
  final _storage = const FlutterSecureStorage();
  UserProvider.initialize() {
    _readAll();
  }
  void _readAll() async {
    final all = await _storage.read(key: 'userInfos');
    all == null
        ? print('null')
        : setUserData(UserData(
            uid: json.decode(all)['uid'],
            email: json.decode(all)['email'],
            password: json.decode(all)['password'],
            f_name: json.decode(all)['f_name'],
            l_name: json.decode(all)['l_name'],
            ph: json.decode(all)['ph'],
            atype: json.decode(all)['atype'],
            account_state: json.decode(all)['account_state'],
            gender: json.decode(all)['gender'],
            dob: json.decode(all)['dob'],
            industry1: json.decode(all)['industry1'],
            industry2: json.decode(all)['industry2'],
            industry3: json.decode(all)['industry3'],
            video: json.decode(all)['video'],
          ));
  }

  addNewItem(userData) async {
    const String key = 'userInfos';
    final String value = json.encode(userData!);
    await _storage.write(key: key, value: value);
    _readAll();
  }

  deleteAll() async {
    await _storage.deleteAll();
    _userData = null;
    notifyListeners();
    _readAll();
  }

  UserData? get userData => _userData;

  setUserData(UserData userData) {
    _userData = userData;
    notifyListeners();
  }
}

Is it because of some kind of cache in Xcode that takes the user register and does not show the login screen while I run the app for the first time? I want to show the login screen when the user run the app first time on ios. On Android, it works fine.


Solution

  • I'm guessing that the _result.userData?.uid is a locally saved property and already has a value set on your current simulator?

    You could try running the app with another iOS device,

    • if you're running the app on Xcode, click on the device name shown at the top panel and select a different device from the dropdown.
    • if you're running the app on VSCode, go to the Simulator window, and select a new device as follows,

    enter image description here

    then you can close the previous window and run the app with the new device.

    See whether this works.