Home IOS Development No implementation discovered for technique getAll on channel plugins.flutter.io/shared_preferences

No implementation discovered for technique getAll on channel plugins.flutter.io/shared_preferences

0
No implementation discovered for technique getAll on channel plugins.flutter.io/shared_preferences

[ad_1]

Dealing with an exception on my flutter app.

  • The app runs high quality on android OS, however throws and exception when attempting to run on IOS.

  • The app runs completely on android.

  • Dealing with this challenge on the splash display the place i’m attempting to fetch the login standing from the shared pref.

[VERBOSE-2:dart_vm_initializer.cc(41)] Unhandled Exception: MissingPluginException(No implementation discovered for technique getAll on channel plugins.flutter.io/shared_preferences)

That is my Shared pref implementation.

import 'bundle:shared_preferences/shared_preferences.dart';

import '../mannequin/login/county_list_model.dart';

class SharedPrefHelper {
  // Singleton sample
  SharedPrefHelper._privateConstructor();

  static closing SharedPrefHelper occasion =
  SharedPrefHelper._privateConstructor();

  // SharedPreferences keys
  static const String orgIdKey = 'orgId';
  static const String extAppIdKey = 'extAppId';
  static const String shortCodeKey = 'shortCode';
  static const String isActiveKey = 'isActive';
  static const String title="countyName";
  static const String userNameKey = 'username';
  static const String passWordKey = 'password';

  // SharedPreferences occasion
  late SharedPreferences _prefs;

  // Initialize SharedPreferences
  Future<void> init() async {
    _prefs = await SharedPreferences.getInstance();
  }

  // variables for the County properties
  int get orgId => _prefs.getInt(orgIdKey) ?? 0;

   String  get extAppId => _prefs.getString(extAppIdKey) ?? '';

  String get shortCode => _prefs.getString(shortCodeKey) ?? '';

  String get countyName => _prefs.getString(title) ?? '';
  String get getUsername => _prefs.getString(userNameKey) ?? '';
  String get getPassword => _prefs.getString(passWordKey) ?? '';

  int get isActive => _prefs.getInt(isActiveKey) ?? 0;

  // variable to get login standing
  bool get isLoggedIn => _prefs.getBool('login') ?? false;
  bool get isRememberMe => _prefs.getBool('isRememberMe') ?? false;

  // Operate to save lots of chosen merchandise's properties to shared preferences
  saveSelectedCountyItem(Merchandise chosen) async {
    closing prefs = await SharedPreferences.getInstance();
    prefs.setInt('orgId', chosen.orgId);
    prefs.setString('extAppId', chosen.extAppId);
    prefs.setString('shortCode', chosen.shortCode);
    prefs.setInt('isActive', chosen.isActive);
    prefs.setString('countyName', chosen.title);
  }

  Future<bool> setLogInStatus(bool loginStatus) async {
    closing SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.setBool('login', loginStatus);
  }
  Future<bool> setaccessToken(String token) async {
    closing SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.setString('token', token);
  }

  Future<bool> setUserToken(String token) async {
    closing SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.setString('usertoken', token);
  }

  Future<String> geuserToken() async {
    SharedPreferences pref = await SharedPreferences.getInstance();
    return pref.getString('usertoken') ?? "";
  }

  Future<String> getoken() async {
    SharedPreferences pref = await SharedPreferences.getInstance();
    return pref.getString('token') ?? "";
  }

  Future<bool?> getLogInStatus() async {
    SharedPreferences pref = await SharedPreferences.getInstance();
    return pref.getBool('login') ?? false;
  }
  Future<bool> setUserName(String username) async {
    closing SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.setString('username', username);
  }

  Future<bool> setPassword(String password) async {
    closing SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.setString('password', password);
  }
  Future<bool> setRememberMe(bool isRememberMe) async {
    closing SharedPreferences prefs = await SharedPreferences.getInstance();
    return prefs.setBool('isRememberMe', isRememberMe);
  }


}

That is the splash display the app will get caught.

import 'bundle:civitpermit/constants/color_constants.dart';
import 'bundle:civitpermit/view/dashboard/dash_board.dart';
import 'bundle:flutter/materials.dart';
import 'bundle:supplier/supplier.dart';
import '../../utils/shared_pref.dart';
import '../../view_models/login/login_viewmodel.dart';
import 'login_screen.dart';

class SplashScreen extends StatefulWidget {
  const SplashScreen({tremendous.key});

  @override
  State<SplashScreen> createState() => _SplashScreenState();
}

class _SplashScreenState extends State<SplashScreen> {
  @override
  void initState() {

    closing authViewModel =
        Supplier.of<AuthenticationViewModel>(context, hear: false);
    authViewModel.authenticateClient('');
    _navigateToLogin();
    tremendous.initState();
  }

  @override
  Widget construct(BuildContext context) {
    return SafeArea(
      baby: Scaffold(
        backgroundColor: ColorConstants.primaryColor,
        physique: Heart(
            baby: Picture.asset(
          "property/photos/ic_logo.png",
          peak: 60,
        )),
      ),
    );
  }

  _navigateToLogin() async {
    await Future.delayed(
      const Period(milliseconds: 2000),
      () {},
    );

    SharedPrefHelper.occasion.getLogInStatus().then((worth) {
      if (worth == false) {
        Navigator.pushReplacement(
          context,
          MaterialPageRoute(
            builder: (context) => LoginScreen(),
          ),
        );
      } else {
        Navigator.pushReplacement(
          context,
          MaterialPageRoute(
            builder: (context) => const DashboardScreen(),
          ),
        );
      }
    });
  }
}

[ad_2]

LEAVE A REPLY

Please enter your comment!
Please enter your name here