Skip to content

Instantly share code, notes, and snippets.

Last active Oct 23, 2021
What would you like to do?
Completing the main.dart file by adding a shared preference to store temporary data
import 'package:flutter/material.dart';
import 'package:flutter_banking_app/config/palette.dart';
import 'package:flutter_banking_app/screens/home/home_screen.dart';
import 'package:flutter_banking_app/screens/onboarding/onboarding_screen.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:shared_preferences/shared_preferences.dart';
int? initScreen;
Future<void> main() async {
SharedPreferences preferences = await SharedPreferences.getInstance();
initScreen = preferences.getInt('initScreen');
await preferences.setInt('initScreen', 1);
const FlutterBank(),
class FlutterBank extends StatelessWidget {
const FlutterBank({Key? key}) : super(key: key);
Widget build(BuildContext context) {
return ScreenUtilInit(
designSize: const Size(414.0, 896.0),
builder: ()=> MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Banking App',
theme: ThemeData(
primarySwatch: Palette.kCustomColour,
visualDensity: VisualDensity.adaptivePlatformDensity,
bodyText2: TextStyle(
fontSize: 14.0.sp,
initialRoute: initScreen == 0 || initScreen == null
routes: { (context)=> const HomeScreen(), (context)=> const OnboardingScreen(),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment