The non-nullable variable '_preferences' must be initialized. Try adding an initializer expression

Issue I am trying to implement a class where i can call SharedPreferences funtions. import ‘package:shared_preferences/shared_preferences.dart’; class UserPreferences { static SharedPreferences _preferences; static const _keyToken = ‘token’; static Future init() async { _preferences = await SharedPreferences.getInstance(); } static Future setToken(String

Continue reading

Flutter Json FormatException

Issue In my application, i’m trying to retrieve the data from shared preferences and pass that value to the provider. How ever im getting a exception FormatException (FormatException: Unexpected character (at character 2) {token: eyJh… ^ The function to get

Continue reading

Flutter & Shared Preferences: How do i save and read back a List<Object> using setStringList? Also, how do i remove a specific object from the List?

Issue class Restaurant { Restaurant({ required this.name, required this.description, required this.address, required this.imageUrl, }); Restaurant.fromJson(Map<String, Object?> json) : this( name: json[‘name’]! as String, description: json[‘description’]! as String, address: json[‘address’]! as String, imageUrl: json[‘imageUrl’] as String, ); final String name; final

Continue reading