Fix new onboarding still active on restart

This commit is contained in:
Tommy Chow 2023-01-19 05:09:23 -05:00
parent 2569e7274a
commit 5bc224b4bd
2 changed files with 7 additions and 2 deletions

View file

@ -25,9 +25,11 @@ void main() async {
final prefs = await SharedPreferences.getInstance();
final firstRun = prefs.getBool('first_run') ?? true;
// Workaround for clearing stored tokens on uninstall.
// If first time running app, will clear all tokens in the secure storage.
if (prefs.getBool('first_run') != false) {
if (firstRun) {
debugPrint('Clearing secure storage...');
const storage = FlutterSecureStorage();
@ -72,7 +74,7 @@ void main() async {
Provider<FFZApi>(create: (_) => ffzApiService),
Provider<SevenTVApi>(create: (_) => sevenTVApiService),
],
child: MyApp(firstRun: prefs.getBool('first_run') ?? false),
child: MyApp(firstRun: firstRun),
);
},
),

View file

@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_svg/flutter_svg.dart';
import 'package:frosty/widgets/button.dart';
import 'package:shared_preferences/shared_preferences.dart';
class OnboardingScaffold extends StatelessWidget {
final String header;
@ -36,6 +37,8 @@ class OnboardingScaffold extends StatelessWidget {
DeviceOrientation.portraitDown,
]);
if (isLast) SharedPreferences.getInstance().then((prefs) => prefs.setBool('first_run', false));
return Scaffold(
appBar: AppBar(),
body: SafeArea(