maac_mvvm_generator 0.0.2 copy "maac_mvvm_generator: ^0.0.2" to clipboard
maac_mvvm_generator: ^0.0.2 copied to clipboard

Automates maac_mvvm setup by generating extensions with stream data getters for annotated fields.

example/lib/main.dart

import 'package:example/example_view_model.dart';
import 'package:flutter/material.dart';
import 'package:maac_mvvm/maac_mvvm.dart';

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

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

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends ViewModelWidget<ExampleViewModel> {
  const MyHomePage({super.key});

  @override
  ExampleViewModel createViewModel() => ExampleViewModel();

  @override
  Widget build(BuildContext context, ExampleViewModel viewModel) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text("Annotation"),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text('You have pushed the button this many times:'),
            StreamDataConsumer(
              streamData: viewModel.count,
              builder: (context, data) {
                return Text(
                  '$data',
                  style: Theme.of(context).textTheme.headlineMedium,
                );
              },
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: () => viewModel.incrementCounter(),
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}
0
likes
0
points
25
downloads

Publisher

unverified uploader

Weekly Downloads

Automates maac_mvvm setup by generating extensions with stream data getters for annotated fields.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

analyzer, build, flutter, maac_mvvm, maac_mvvm_annotation, source_gen

More

Packages that depend on maac_mvvm_generator