Last active
January 30, 2024 16:51
-
-
Save MwBakker/c7de66cc9b834be139a7396b81ee06ce to your computer and use it in GitHub Desktop.
Option 2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Vehicult extends ConsumerWidget { | |
@override | |
Widget build(BuildContext ctx, WidgetRef ref) => CustomFutureBuilder( | |
future: DataController.fileDB.processSettingsFile(), | |
loading: RowLoading(), | |
onDone: (st) { | |
ref.read(settingsProvider).set(st.data); | |
return MaterialApp( | |
title: 'MyApp', | |
localizationsDelegates: AppLocalizations.localizationsDelegates, | |
supportedLocales: AppLocalizations.supportedLocales, | |
theme: ThemeData(primaryColor: PrimaryColor), | |
locale: ref.watch(localeProvider), | |
home: _getHome(ctx, st.data[6]), | |
); | |
}, | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@riverpod | |
class SettingsNotifier extends Notifier<Settings?> { | |
@override | |
Settings? build() => null; | |
void set(Settings settings) => state = settings; | |
} | |
final settingsProvider = NotifierProvider<SettingsNotifier, Settings?>( | |
() => SettingsNotifier() | |
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
InkWell( | |
child: Icon(Icons.check, size: 32, color: Colors.white70), | |
onTap: () async { | |
await DataController.fileDB.writeSettingsFile(settings); // it's a void | |
ref.read(settingsProvider).set(settings). | |
} | |
), |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment