https://github.com/melbournedeveloper/papilio
Build beautiful apps with Flutter
https://github.com/melbournedeveloper/papilio
Last synced: 5 months ago
JSON representation
Build beautiful apps with Flutter
- Host: GitHub
- URL: https://github.com/melbournedeveloper/papilio
- Owner: MelbourneDeveloper
- License: bsd-3-clause
- Created: 2022-07-05T12:46:03.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-08-21T05:24:13.000Z (over 3 years ago)
- Last Synced: 2025-02-06T01:51:22.790Z (about 1 year ago)
- Language: Dart
- Size: 5.23 MB
- Stars: 7
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# Papilio
Build beautiful apps with Flutter
Check out the live sample app [Papilio Note](https://www.papilionote.com) in the browser. All source code is available for the sample app [here](https://github.com/MelbourneDeveloper/papilio_note). Or, check out this package's simple example app [here](https://melbournedeveloper.github.io/papilio). Notice that both samples fully integrate with browser navigation.

### Declaritive Framework for Flutter
Compose your app with ease and leave the plumbing up to the framework
### Separation of Concerns
Separate your app's logic from its presentation
### BloC Approach to State Management
Send events to the business logic component and let the framework handle UI changes from the stream
### Compose Your Dependencies
Access you dependencies with dependency injection when you need them in the app. papilio uses the [ioc_container](https://pub.dev/packages/ioc_container) package
### Declarative Approach to Navigation
Specify page names and `StatelessWidget`s to seamlessly transition between pages. Respond to navigation from BloC handlers instead of UI callbacks
You can compose your app like this. It's nice.
```dart
void main() {
const incrementName = '/increment';
const incrementKey = ValueKey(incrementName);
const decrementName = '/decrement';
const decrementKey = ValueKey(decrementName);
final builder = IocContainerBuilder();
builder.addRouting(
(container) => PapilioRoutingConfiguration(
buildRoutes: (delegateBuilder) => delegateBuilder
..addPage(
container: container,
name: incrementName,
initialState: (arguments) => const PageState(0, 0),
pageBody: (context) => const MyHomePage(
title: "Papilio Sample - Increment"),
buildBloc: (blocBuilder, container) => blocBuilder
..addSyncHandler((state, event) =>
state.copyWith(counter: state.counter + 1))
..addSyncHandler((state, event) {
if (event.index == 0) {
return state;
}
container.navigate(decrementKey);
return state;
}))
..addPage(
container: container,
name: decrementName,
initialState: (arguments) => const PageState(10, 1),
pageBody: (context) => const MyHomePage(
title: "Papilio Sample - Decrement"),
buildBloc: (blocBuilder, container) => blocBuilder
..addSyncHandler((state, event) =>
state.copyWith(counter: state.counter - 1))
..addSyncHandler((state, event) {
if (event.index == 1) {
return state;
}
container.navigate(incrementKey);
return state;
})),
currentRouteConfiguration: (page) => page.name == incrementName
? const PageRoute(Page.increment)
: const PageRoute(Page.decrement),
parseRouteInformation: (routeInformation) async =>
routeInformation.location == incrementName
? const PageRoute(Page.increment)
: const PageRoute(Page.decrement),
restoreRouteInformation: (pageRoute) => RouteInformation(
location: pageRoute.page == Page.increment
? incrementName
: decrementName),
onSetNewRoutePath: (delegate, route) async =>
route.page == Page.increment
? delegate.navigate(incrementKey)
: delegate.navigate(decrementKey),
onInit: (delegate, container) =>
delegate.navigate(incrementKey)),
);
final container = builder.toContainer();
runApp(MyApp(container));
}
```
Widget tests in the Papilio Note sample cover this package thoroughly, but this repo will soon have unit tests. View the widget tests [here](https://github.com/MelbourneDeveloper/papilio_note/blob/f999d2685586271c447ec7b5d83b4a36bfe13bd8/src/papilio_note/test/app_test.dart#L34).