Open TarikApp opened 4 years ago
I want to use SharedPreferences in main class, but my application typically crashes(white page blocked) I added shared_preferences: ^0.5.7 to pubspec.yaml I have no error with flutter doctor
Thanks in Advance
import 'package:flutter/material.dart'; import 'package:newsapp/screens/onboarding.dart'; import 'screens/home_screen.dart'; import 'package:shared_preferences/shared_preferences.dart';
void main() async{
SharedPreferences prefs = await SharedPreferences.getInstance(); bool seen=prefs.getBool('seen'); Widget _screen; _screen = OnBoarding(); runApp( NewsApp( _screen) );
}
class NewsApp extends StatelessWidget {
final Widget _screen; NewsApp(this._screen);
@override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: _screen, ); } }
I want to use SharedPreferences in main class, but my application typically crashes(white page blocked) I added shared_preferences: ^0.5.7 to pubspec.yaml I have no error with flutter doctor
Thanks in Advance
import 'package:flutter/material.dart'; import 'package:newsapp/screens/onboarding.dart'; import 'screens/home_screen.dart'; import 'package:shared_preferences/shared_preferences.dart';
void main() async{
SharedPreferences prefs = await SharedPreferences.getInstance(); bool seen=prefs.getBool('seen'); Widget _screen; _screen = OnBoarding(); runApp( NewsApp( _screen) );
}
class NewsApp extends StatelessWidget {
final Widget _screen; NewsApp(this._screen);
@override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: _screen, ); } }