flutty_state
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.
Libraries
- component/page_content
- data/data_fetch_response
- data/data_submit_response
- data/repository
- flutty_state
- Lightweight and reactive state management solution for Flutter.
- logic/fetch_cubit
- logic/flutty_bloc_observer
- logic/submit_cubit
- notifier/flutty_builder
- notifier/flutty_notifier
- theme_extension
- ui/fetch_and_submit_page
- ui/static_page
- ui/submit_page
- utils