I am using shared preferences package in flutter to store boolean values.
I have stored boolean value with key name.
But iam getting nosuchmenthodexception.
Edit: Code in text
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
SharedPreferences pref;
Future<void> addStringToSF() async {
pref = await SharedPreferences.getInstance();
}
@override
void initState() async {
super.initState();
await addStringToSF();
}
@override
Widget build(BuildContext context) {
bool present = pref.containsKey('name');
return MaterialApp(
debugShowCheckedModeBanner: false,
home: present == true ? Home() : Register(),
);
}
}