This file contains hidden or 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
import 'dart:async'; | |
import 'dart:math'; | |
import 'package:flutter/material.dart'; | |
import 'package:flutter/services.dart'; | |
// ---------------------------------------------------------------------------- | |
class Box<T> { | |
Box(this.value); |
This file contains hidden or 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
import 'dart:async'; | |
import 'dart:collection'; | |
import 'package:cloud_firestore/cloud_firestore.dart'; | |
import 'package:firebase_core/firebase_core.dart'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
import 'package:signals/signals_flutter.dart'; | |
import 'firebase_options.dart'; |
This file contains hidden or 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
import 'dart:math'; | |
import 'package:flutter/foundation.dart'; | |
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { |
This file contains hidden or 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
/// Parses a plist file into a Dart object. | |
dynamic parsePlist(String plist) { | |
final tokens = RegExp(r'(\s+|<[!?].*?>)|<(/?\w+)[^>]*>|([^<]*)', dotAll: true) | |
.allMatches(plist) | |
.where((match) => match[1] == null) | |
.map((match) => match[2] != null ? (1, match[2]!) : (2, match[3]!)) | |
.followedBy([(0, '')]).iterator | |
..moveNext(); | |
bool at(String s) => tokens.current == (1, s) && tokens.moveNext(); |
This file contains hidden or 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
/// A KV that can be observed for changes to key bindings. | |
class ObservableKV { | |
ObservableKV(this._kv); | |
final KV _kv; | |
final _listeners = <void Function(String, Object?)>[]; | |
Stream<(Object, Object?)> observe(String prefix) { | |
late final StreamController<(Object, Object?)> controller; | |
void listener(String key, Object? value) { |
This file contains hidden or 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
/// A simple key-value store w/persistent sqlite3 database. | |
class KV { | |
KV._(this._db); | |
final Database _db; | |
static Future<KV> open(String name) async { | |
return KV._(sqlite3.open(name)..execute('create table if not exists kv (k text primary key, v jsonb)')); | |
} | |
Future<Object?> get(String key) async { |
This file contains hidden or 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
/// A simple read-optimized in-memory key-value store w/persistent file-based redo log. | |
class KV { | |
KV._(this._file, this._data); | |
final File _file; | |
final Map<String, dynamic> _data; | |
static Future<KV> open(File file) async { | |
final data = <String, dynamic>{}; | |
if (!file.existsSync()) return KV._(file, data); | |
await for (final line in file // |
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const App()); | |
} | |
class App extends StatelessWidget { | |
const App({super.key}); | |
@override |
This file contains hidden or 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
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const App()); | |
} | |
class App extends StatelessWidget { | |
const App({super.key}); | |
@override |
This file contains hidden or 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
import 'dart:async'; | |
import 'package:flutter/material.dart'; | |
/// See [asyncTask]. | |
typedef Task<T> = Future<T?> Function(bool Function() cancelled); | |
/// Runs the future returned by [task] and shows a modal waiting dialog after | |
/// an initial [delay] (default 100 ms) with an optional [label] until the future | |
/// completes. The [task] is passed a function that returns whether the task |