flutter_mvc 3.0.0-beta.1 copy "flutter_mvc: ^3.0.0-beta.1" to clipboard
flutter_mvc: ^3.0.0-beta.1 copied to clipboard

A state management framework that focuses on the separation of UI and logic.

Flutter Mvc #

Features #

Flutter Mvc is a Flutter framework that includes UI and logic separation, state management, and dependency injection.

Getting started #

import 'package:flutter/material.dart';
import 'package:flutter_mvc/flutter_mvc.dart';

void main() {
  runApp(const MyApp());
}

class TestMvcController extends MvcController {
  int count = 0;
  @override
  MvcView view() => TestMvcView();

  void tapAdd() {
    count++;
    $("#test").update();
  }
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: Mvc(create: () => TestMvcController()),
    );
  }
}

class TestMvcView extends MvcView<TestMvcController, dynamic> {
  @override
  Widget buildView() {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: const Text("Test"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            MvcBuilder<TestMvcController>(
              classes: const ["test"],
              id: "test",
              builder: (context) {
                return Text(
                  '${context.controller.count}',
                  style: Theme.of(context).textTheme.headlineMedium,
                );
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: controller.tapAdd,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

2
likes
0
pub points
40%
popularity

Publisher

verified publisherybz.im

A state management framework that focuses on the separation of UI and logic.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

dart_dependency_injection, flutter

More

Packages that depend on flutter_mvc