Skip to content

Instantly share code, notes, and snippets.

@MwBakker
MwBakker / 1) initialWidget.dart
Last active February 5, 2024 09:54
initial widget causing error setting providers
class AppInitializationWidget extends ConsumerWidget {
const AppInitializationWidget({super.key, required this.onLoaded});
final WidgetBuilder onLoaded;
@override
Widget build(BuildContext ctx, WidgetRef ref) => CustomFutureBuilder(
futures: [
Firebase.initializeApp(),
DataController.vehicleDB.getVehicleSpecification('type'),
DataController.vehicleDB.getVehicleSpecification('class'),
@MwBakker
MwBakker / 1_start_of_app.dart
Last active January 30, 2024 16:51
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,
@MwBakker
MwBakker / 1_start_of_app.dart
Last active January 30, 2024 16:51
Option 1
class MyApp extends ConsumerWidget {
@override
Widget build(BuildContext ctx, WidgetRef ref) =>
ref.watch(settingsAsyncProvider).when(
loading: () => RowLoading(),
error: (e, s) => CustomError(body: '$e \n \n $s'),
data: (data) {
return MaterialApp(
title: 'MyApp',
localizationsDelegates: AppLocalizations.localizationsDelegates,
@MwBakker
MwBakker / main.dart
Last active November 29, 2022 10:55
import 'dart:convert';
void main() {
final stringifiedJson = '[{"id":"4","name":"Tulpenrallye 2022","location":"50.1213479,8.4964818","description":"Nog maar vijf weken geleden stonden wij aan de finish van de 67eTulpenrallye. Vandaag word jij door ons uitgenodigd voor 68e Tulpenrallye. Hiermee gaan wij een nieuw hoofdstuk toevoegen aan de lange Tulpenrallye geschiedenis. De 68e Tulpenrallye start op maandagochtend 9 mei 2022 in de buurt van Frankfurt in Duitsland. Na een overnachting in Karlsruhe gaat de rally daarna verder in het vertrouwde Frankrijk. Natuurlijk doen we ook Luxemburg en Belgi? aan in deze editie.","website":"tulpenrallye.nl","email":"rallyoffice@tulpenrallye.nl","phone":" +31 (0) 6 41291219","img":"https:\/\/www.tulpenrallye.nl\/wp-content\/uploads\/2021\/11\/VISUAL-2022-LR-1.jpg","vehicle_date_from":"1899-01-01","vehicle_date_to":"1973-01-01","vehicle_type_id":"1","user_id":null,"vehicle_region_id":"1","brand":null,"model":null,"event_id":"4","date":"2023-05-09","begin":"09:00:00","end"
Checkbox(
value: ref.watch(boolNr1.state).state,
onChanged: (value) {
ref.watch(boolNr1.state).state = value;
},
),
Checkbox(
value: ref.watch(boolNr2.state).state,
onChanged: (value) {
ref.watch(boolNr2.state).state = value;
@MwBakker
MwBakker / tab_navigator.dart
Created January 9, 2022 21:50
writers_block
class TabNavigatorRoutes {
static const String root = '/';
static const String detail = '/detail';
}
class TabNavigator extends ConsumerWidget {
final GlobalKey<NavigatorState> navigatorKey;
final String tabItem;
final UserAddInfo userAddInfo;
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:oldtimer_app/models/vehicle.dart';
import 'package:oldtimer_app/services/database/controller_data.dart';
final vehicleStateFuture = FutureProvider<List<Vehicle>>((ref) async {
return DataController.vehicleDB.getUserVehicles(someUID);
},
);
import 'package:flutter_riverpod/flutter_riverpod.dart';
final indexNotifier = StateNotifierProvider<IndexNotifier>((ref) {
return IndexNotifier();
});
class IndexNotifier extends StateNotifier<int> {
IndexNotifier() : super(0);
void changeIndex(int index) {
main()
{
som = 0; k = 4;
int pid, k, som;
pid = fork();
if (pid == 0)
k = 5;
else
wait(0);
for (int i = 3; i <= k; i++)
public async Task<bool> PerformTextualInputAsync(string text)
{
UIElement focusedControl = Keyboard.FocusedElement as UIElement;
if (focusedControl != null)
{
text = text.ToUpper(System.Globalization.CultureInfo.CurrentCulture);
string[] textArray = text.ToCharArray().Select(c => c.ToString()).ToArray();
if (Keyboard.PrimaryDevice.ActiveSource != null)