levit_flutter_core 0.0.6 copy "levit_flutter_core: ^0.0.6" to clipboard
levit_flutter_core: ^0.0.6 copied to clipboard

Flutter widgets for the Levit framework - bridges reactive state and DI to the Flutter widget tree.

levit_flutter_core #

Pub Version Platforms License: MIT codecov

Purpose & Scope #

levit_flutter_core is the low-level Flutter binding layer for Levit.

This package is responsible for:

  • LScope / LAsyncScope: widget-tree-scoped dependency injection.
  • LWatch: reactive rebuild boundaries based on accessed values.
  • LView, LAsyncView, LScopedView: controller/view orchestration widgets.
  • Builder widgets (LBuilder, selector/status builders) for focused reactive rendering.

This package does not include:

  • Higher-level convenience widgets and runtime helpers provided by levit_flutter.

Conceptual Overview #

levit_flutter_core bridges two scope models:

  • Flutter tree scope via InheritedWidget.
  • Levit execution scope via Zone-based current scope.

The package ensures widget lifecycle events and DI lifecycle events stay synchronized, so registrations created for a subtree are disposed when that subtree unmounts.

Getting Started #

dependencies:
  levit_flutter_core: ^latest
import 'package:flutter/material.dart';
import 'package:levit_flutter_core/levit_flutter_core.dart';

class CounterController extends LevitController {
  final count = 0.lx;
  void increment() => count(count() + 1);
}

void main() {
  runApp(
    MaterialApp(
      home: LScope.put(
        () => CounterController(),
        child: Builder(
          builder: (context) {
            final controller = context.levit.find<CounterController>();
            return Scaffold(
              body: Center(
                child: LWatch(() => Text('Count: ${controller.count()}')),
              ),
              floatingActionButton: FloatingActionButton(
                onPressed: controller.increment,
                child: const Icon(Icons.add),
              ),
            );
          },
        ),
      ),
    ),
  );
}

Design Principles #

  • Tree-owned lifecycles: widget mount/unmount controls scope setup/disposal.
  • Fine-grained rebuilds: widgets rebuild only for values read during build.
  • Explicit composition: sync and async scope/view variants remain explicit.
  • Minimal API surface: package stays focused on foundational bindings.
1
likes
160
points
141
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Flutter widgets for the Levit framework - bridges reactive state and DI to the Flutter widget tree.

Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #state-management #widget

License

MIT (license)

Dependencies

flutter, levit_dart_core

More

Packages that depend on levit_flutter_core