morpheme_base 1.2.1 copy "morpheme_base: ^1.2.1" to clipboard
morpheme_base: ^1.2.1 copied to clipboard

MorphemeBase is base for UI project include state management with cubit.

example/lib/main.dart

import 'package:example/cubit/main_cubit.dart';
import 'package:flutter/material.dart';
import 'package:morpheme_base/morpheme_base.dart';

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

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MainPage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MainPage extends StatefulWidget {
  const MainPage({super.key, required this.title});

  final String title;

  @override
  State<MainPage> createState() => _MainPageState();
}

class _MainPageState extends State<MainPage>
    with MorphemeStatePage<MainPage, MainCubit> {
  @override
  MainCubit setCubit() => MainCubit();

  @override
  Widget buildWidget(BuildContext context) {
    final counter =
        context.select((MainCubit element) => element.state.counter);

    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: cubit.increment,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}
2
likes
160
pub points
50%
popularity

Publisher

verified publishermorpheme.design

MorphemeBase is base for UI project include state management with cubit.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_bloc

More

Packages that depend on morpheme_base