Skip to content

A State Management for Flutter inspired by Entity Component System Architecture

License

Notifications You must be signed in to change notification settings

Jonel-Code/flutter_component_state_system

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Component State System

A basic Flutter State Management inspired by Entity Component System (ECS) pattern. This Uses the App as the "Entity" containing "Components" that are being Mananged by running a "System".

Features

A basic management that uses Flutter's InheritedWidget and ValueNotifier to manage state.

Usage

AppStateProvider - Used to mount the ComponentStateSystem instance to the widget tree. ConsumeComponents - Used to consume a list of Component instances available in the ComponentStateSystem.

AppStateProvider(
    onInit: (app) {
        // run a system on initialization of the state
        app.runSystem(
            TestInitAppStateSystem(),
        );
    },
    child: ConsumeComponents(
        strict: false,
        /// consume the that has been intialized by TestInitAppStateSystem
        types: const [TestLoadingData],
        builder: (context, components) {
            final data = components.tryRead<TestLoadingData>();
            if (data == null) return const CircularProgressIndicator();
            final listenable = data.storeValue;
            return ListenableBuilder(
                listenable: listenable,
                builder: (_, __) => Text(
                'data ${listenable.value}',
                ),
            );
        },
    ),
)

Additional information

This package is still in Proof of Concept stage and is not recommended for production use. Contributions are welcome.

About

A State Management for Flutter inspired by Entity Component System Architecture

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages