Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR DART

onboarding screen flutter

int initScreen;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  SharedPreferences prefs = await SharedPreferences.getInstance();
  initScreen = await prefs.getInt("initScreen");
  await prefs.setInt("initScreen", 1);
  print('initScreen ${initScreen}');
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      initialRoute: initScreen == 0 || initScreen == null ? "first" : "/",
      routes: {
        '/': (context) => MyHomePage(
              title: "demo",
            ),
        "first": (context) => OnboardingScreen(),
      },
    );
  }
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #onboarding #screen #flutter
ADD COMMENT
Topic
Name
9+6 =