Skip to content

Instantly share code, notes, and snippets.

@MwBakker
Last active January 30, 2024 16:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save MwBakker/c7de66cc9b834be139a7396b81ee06ce to your computer and use it in GitHub Desktop.
Save MwBakker/c7de66cc9b834be139a7396b81ee06ce to your computer and use it in GitHub Desktop.
Option 2
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]),
);
},
);
@riverpod
class SettingsNotifier extends Notifier<Settings?> {
@override
Settings? build() => null;
void set(Settings settings) => state = settings;
}
final settingsProvider = NotifierProvider<SettingsNotifier, Settings?>(
() => SettingsNotifier()
);
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