elbe 0.1.43 elbe: ^0.1.43 copied to clipboard
a toolkit for simplifying frontend development
import 'package:elbe/bit/bit/bit.dart';
import 'package:elbe/elbe.dart';
import 'package:example/routes.dart';
void main() => runApp(_App());
class _App extends StatelessWidget {
_App({Key? key}) : super(key: key);
final GoRouter _appRouter = GoRouter(routes: appRoutes);
@override
Widget build(BuildContext context) =>
BitBuildProvider<ColorModes, ColorModes, String, ColorModeBit>(
create: (_) => ColorModeBit(),
onData: (_, d) => ElbeApp(
router: _appRouter,
mode: d,
debugShowCheckedModeBanner: false,
theme: ThemeData.preset(color: Colors.blueAccent),
));
}
class ColorModeBit extends MapMsgBitControl<ColorModes> {
static const builder = MapMsgBitBuilder<ColorModes, ColorModeBit>.make;
ColorModeBit()
: super.worker((w) => ColorModes.light, initial: ColorModes.light);
void toggle() => state.whenOrNull(onData: (d) {
emit(d == ColorModes.light ? ColorModes.dark : ColorModes.light);
});
}