flutter_cora

deploy codecov Pub Version GitHub License GitHub last commit Pub Points

flutter_cora 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.

Note: If you are using flutter_riverpod for state management, check out flutter_cora_riverpod.

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 as a dependency in your pubspec.yaml file

dependencies:
  flutter_cora: ^0.0.1-dev.19

Usage

Here is a simple example of how to use flutter_cora.

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

  final String name;

  @override
  Widget build(BuildContext context, ExampleState state) {
    return Text('Count ${state.count}');
  }

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

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

  @override
  void initState() {
    super.initState();
    print('name: ${widget.name}');
  }
}

Libraries

flutter_cora