ctrl 0.1.1 copy "ctrl: ^0.1.1" to clipboard
ctrl: ^0.1.1 copied to clipboard

A package that allows you to control observables within scopes that are linked to the Widget Lifecycle.

example/lib/main.dart

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,
    );
  }
}
0
likes
160
points
92
downloads

Publisher

unverified uploader

Weekly Downloads

A package that allows you to control observables within scopes that are linked to the Widget Lifecycle.

Repository (GitHub)
View/report issues

Topics

#observer #observable #architecture #state-management #reactive

Documentation

Documentation
API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on ctrl