gits_base 3.0.0 copy "gits_base: ^3.0.0" to clipboard
gits_base: ^3.0.0 copied to clipboard

GitsBase is base for UI project include state management with cubit & hydrated.

example/lib/main.dart

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

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

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: 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({Key? key, required this.title}) : super(key: key);

  final String title;

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

class _MainPageState extends State<MainPage>
    with GitsStatePage<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),
      ),
    );
  }
}
3
likes
160
pub points
49%
popularity

Publisher

verified publishergits.id

GitsBase is base for UI project include state management with cubit & hydrated.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

flutter, flutter_bloc

More

Packages that depend on gits_base