flutty_state 0.1.1 copy "flutty_state: ^0.1.1" to clipboard
flutty_state: ^0.1.1 copied to clipboard

Lightweight and reactive state management solution for Flutter.

flutty_state #

pub package pub points likes

Lightweight and reactive state management utilities for Flutter.

The main value of this package is the set of ready-to-use pages that help you build common app flows quickly:

  • FetchAndSubmitPage: fetch initial data, display it, and handle submission (with refresh + snackbars).
  • SubmitPage: handle form submission lifecycle (loading, success, error) with a clean layout.
  • StaticPage: a simple scrollable page layout with safe area + padding.

Installation #

dependencies:
  flutty_state: ^0.1.1

Usage #

Quick start #

Import:

import 'package:flutty_state/flutty_state.dart';

StaticPage #

StaticPage(
  appBar: AppBar(title: const Text('About')),
  child: const Text('Hello world'),
);

SubmitPage #

SubmitPage(
  appBarBuilder: (_, __, ___) => AppBar(title: const Text('Submit')),
  childBuilder: (submitCubit, context) {
    return FilledButton(
      onPressed: () => submitCubit.submit(
        dataSubmitter: () async => DataSubmitSucceedEmpty(message: 'Saved'),
      ),
      child: const Text('Submit'),
    );
  },
);

FetchAndSubmitPage #

FetchAndSubmitPage<int>(
  appBarBuilder: (data, _, __) => AppBar(title: const Text('Fetch & Submit')),
  dataFetcher: () async => DataFetchSucceed(data: 1),
  builder: (data, submitCubit, context) {
    return Column(
      crossAxisAlignment: CrossAxisAlignment.start,
      children: [
        Text('Fetched value: $data'),
        const SizedBox(height: 12),
        FilledButton(
          onPressed: () => submitCubit.submitAndFetch(
            dataSubmitter: () async => DataSubmitSucceedEmpty(message: 'OK'),
          ),
          child: const Text('Submit + refresh'),
        ),
      ],
    );
  },
);

Example #

See packages/flutty_state/example for a complete demo app showcasing the 3 pages.

API Documentation #

See the API docs for full documentation.

3
likes
160
points
380
downloads

Publisher

unverified uploader

Weekly Downloads

Lightweight and reactive state management solution for Flutter.

Repository (GitHub)
View/report issues

Topics

#state-management #flutter #widget #bloc

License

MIT (license)

Dependencies

bloc, equatable, flutter, flutter_bloc, flutty_ds

More

Packages that depend on flutty_state