flutter_cora_riverpod 0.0.1-dev.3 copy "flutter_cora_riverpod: ^0.0.1-dev.3" to clipboard
flutter_cora_riverpod: ^0.0.1-dev.3 copied to clipboard

A simple Flutter package for separating UI and business logic using a view-controller pattern.

flutter_cora_riverpod #

codecov

flutter_cora_riverpod is a simple Flutter package for implementing the view-controller pattern, helping you separate UI and business logic to maintain cleaner and more organized code.

Features #

  • Separate UI (View) from business logic (State).
  • Promote clean architecture for Flutter applications.
  • Lightweight and easy to integrate into existing projects

Getting started #

To use this package, add flutter_cora_riverpod as a dependency in your pubspec.yaml file

dependencies:
  flutter_cora_riverpod: <latest_version>

Usage #

Here is a simple example of how to use flutter_cora_riverpod.

/// Provider for the counter label.
final labelProvider = Provider.autoDispose((ref) => 'Count');

/// example_view.dart
class ExampleView extends CoraConsumerView<ExampleState> {
  const ExampleView({
    required this.name,
    super.key,
  });

  final String name;

  @override
  Widget build(ExampleState state) {
    return Column(
      children: [
        Text(state.ref.watch(labelProvider)),
        Text(
          '${state.count}',
          style: Theme.of(state.context).textTheme.titleLarge,
        ),
      ],
    );
  }

  @override
  ExampleState createState() => ExampleState();
}

/// example_state.dart
class ExampleState extends CoraConsumerState<ExampleView> {
  int count = 1;

  @override
  void initState() {
    super.initState();
    print('name: ${widget.name}');
    print('label: ${ref.read(labelProvider)}');
  }
}
0
likes
0
points
118
downloads

Publisher

verified publisheralbinpk.dev

Weekly Downloads

A simple Flutter package for separating UI and business logic using a view-controller pattern.

Repository (GitHub)
View/report issues

Topics

#mvc #riverpod #view-controller #architecture #clean-code

License

unknown (license)

Dependencies

flutter, flutter_riverpod

More

Packages that depend on flutter_cora_riverpod