ctrl 0.1.1
ctrl: ^0.1.1 copied to clipboard
A package that allows you to control observables within scopes that are linked to the Widget Lifecycle.
import 'package:ctrl/ctrl.dart';
import 'package:example_playground/view/counter/counter_controller.dart';
import 'package:example_playground/view/form/product_form_controller.dart';
import 'package:example_playground/view/todo/todo_dependencies.dart';
import 'package:flutter/material.dart';
import 'core/routes/app_router.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
// Register Controllers using the built-in service locator
Locator().registerFactory((_) => CounterController());
Locator().registerFactory((_) => ProductFormController());
// Register GetIt dependencies for the Todo feature
await TodosDependencies().setup();
runApp(const MainApp());
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
title: 'Ctrl Playground',
theme: ThemeData(
primarySwatch: Colors.blue,
colorScheme: ColorScheme(
brightness: Brightness.light,
primary: Colors.lightBlue,
onPrimary: Colors.white,
secondary: Colors.blueAccent,
onSecondary: Colors.white,
error: Colors.red,
onError: Colors.white,
surface: Colors.white,
onSurface: Colors.black,
),
useMaterial3: true,
),
routerConfig: appRouter,
debugShowCheckedModeBanner: false,
);
}
}