flutter_forge 0.0.1 copy "flutter_forge: ^0.0.1" to clipboard
flutter_forge: ^0.0.1 copied to clipboard

discontinued
outdated

A robust opinionated framework for building state based applications in a modular, testable, and composable style.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:forge/forge.dart';

import 'compose_with_parent_owning_state.dart';
import 'compose_component_owning_state.dart';
import 'send_action_to_child_store.dart';
import 'some_state_from_parent_other_owned.dart';
import 'counter.dart';

void main() {
  runApp(const ProviderScope(child: 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 Home(),
    );
  }
}

final composeWithParentOwningStateStore = Store(initialState: const ComposeWithParentOwningStateState(counter: CounterState(count: 10)));
final someStateFromParentOtherOwnedStore = Store(initialState: const SomeStateFromParentOtherOwnedState(isLoggedIn: false));

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Riverpod Composable Arch Examples')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Padding(
              padding: const EdgeInsets.all(8),
              child: ElevatedButton(
                onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => const ComposeComponentOwningState())); },
                child: const Text('Compose with Component Owning State'),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(8),
              child: ElevatedButton(
                onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => ComposeWithParentOwningState(store: composeWithParentOwningStateStore))); },
                child: const Text('Compose with Parent Owning State'),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(8),
              child: ElevatedButton(
                onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => const SendActionToChildStore())); },
                child: const Text('Send Action to Child Store'),
              ),
            ),
            Padding(
              padding: const EdgeInsets.all(8),
              child: ElevatedButton(
                onPressed: () { Navigator.push(context, MaterialPageRoute(builder: (context) => SomeStateFromParentOtherOwned(store: someStateFromParentOtherOwnedStore))); },
                child: const Text('Some State From Parent Other Owned'),
              ),
            ),
          ]
        )
      )
    );
  }
}
copied to clipboard
3
likes
0
points
56
downloads

Publisher

verified publisherupte.ch

Weekly Downloads

2024.08.23 - 2025.03.07

A robust opinionated framework for building state based applications in a modular, testable, and composable style.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, flutter_riverpod

More

Packages that depend on flutter_forge