Manage the state of your widgets using imperative programming concepts.

Overview

Imperative Flutter

Manage the state of your widgets using imperative programming concepts.

Setup

Intall imperative_flutter package in pubspec.yaml

dependencies:
  imperative_flutter: ^0.0.2

Then it's just import in your code

import 'package:imperative_flutter/imperative_flutter.dart';

Usage

ImperativeProvider is responsible for storing and handling the references for ImperativeBuilder, it can be global scope when MaterialApp is his child or local scope when Scaffold is your child.

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ImperativeProvider(
      child: MaterialApp(
        title: 'Imperative Flutter Demo',
        home: MyHomePage(),
      ),
    );
  }
}

ImperativeBuilder is responsible for store the state of our widget and reconstructing it when that state is changed, note that the id must be unique for each ImperativeProvider Scope.

// Inside StatelessWidget

ImperativeBuilder<int>(
    id: 'count',
    initialData: 0,
    /* the builder method will be called every time the state changes,
    updating only the widget within the scope */
    builder: (context, snapshot) {
        return Container(
            height: 48,
            width: 48,
            color: Colors.pink,
            child: Center(
                child: Text(
                    '${snapshot.data}',
                    style: TextStyle(color: Colors.white),
                  ),
            ),
        );
    },
),

// ...

class Whatever extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    // Get instance of ImperativeProvider
    final imperative = ImperativeProvider.of(context);

    return ElevatedButton.icon(
            onPressed: () {
                // Get current state of ImperativeBuilder where id equal 'count'
                final value = imperative.getState<int>('count');
                // Set state of ImperativeBuilder where id equal 'count' and rebuild
                imperative.setState('count', value + 1);
            },
            icon: Icon(Icons.add),
            label: Text('plus'),
    ),
  }
You might also like...

Example of use bloc + freezed with a state that contains a list

blocfreezedlistexample A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you s

Mar 21, 2022

London App Brewery State Management Project

todey_flutter A new Flutter application. Getting Started This project is a starting point for a Flutter application. A few resources to get you starte

Nov 1, 2021

Timer based on provider state manager

timer_provider Timer based on provider state manager Getting Started This project is a starting point for a Flutter application. A few resources to ge

Nov 6, 2021

Flutter State Management with provider :rocket:

Flutter State Management with provider :rocket:

Flutter - Gerenciamento de Estados com Provider Objetivos ao completar os estudos Aprenda a gerenciar o estado da sua aplicação com Single Source of T

Dec 6, 2021

Flutter physics concepts - Physics Concepts by Ayush P Gupta

Flutter physics concepts - Physics Concepts by Ayush P Gupta

Physics Concepts by Ayush P Gupta A Flutter project for physics concepts. About Learn Physics Concept in more visual ways. Wave Theory, Ray Optics are

Apr 30, 2022

Implementing Functional Programming concepts in Dart & Flutter.

Functional Programming in Dart The code is part of an Article series that demonstrates Functional Programming concepts in Dart & Flutter. Table of Con

Dec 21, 2022

Sol - an imperative, statically-typed language designed as a tool for learning how to program

SOL: Simple Obvious Language Sol is an imperative, statically-typed language designed as a tool for learning how to program. It is simple, in that it

Oct 6, 2022

Concepts used Flutter layout,State management, Blockchain integration, Http api integration, Smart contracts

HS_CryptoCoin_Wallet First project using Flutter with Blockchain Getting Started This project is a starting point for a Flutter application. A few res

Dec 23, 2021

Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Fpdart Functional programming in Dart and Flutter. All the main functional programming types and patterns fully documented, tested, and with examples.

Dec 26, 2022

A simple to-do list built using flutter based on BLoC state management to manage your daily tasks .

A simple to-do list built using flutter based on BLoC state management to manage your daily tasks .

📝 Table of Contents About ScreenShots from the app Demo vedio Contributors About A to-do list flutter app to manage your daily tasks. it is built bas

Oct 12, 2022

State Persistence - Persist state across app launches. By default this library store state as a local JSON file called `data.json` in the applications data directory. Maintainer: @slightfoot

State Persistence Persist state across app launches. By default this library store state as a local JSON file called data.json in the applications dat

Sep 28, 2022

Repository to practice and study some advanced concepts of flutter bloc

flutter_weather A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started

Mar 31, 2022

A counter app to learn Flutter Bloc Concepts

counter A counter app to learn Flutter Bloc Concepts Flutter Bloc Crash Course Short Notes For every interaction, the app should be in a different sta

Oct 24, 2021

Apex Legends heroes app concepts built with Flutter.

Apex Legends heroes app concepts built with Flutter.

Apex Legends 👑 A little bit of fun. Built with Flutter Installation Clone the repo git clone https://github.com/ys-sherzad/ApexLegends.git On you pr

Sep 26, 2022

Busca cep list - A project developed in Flutter for the Flutter Challenge that addresses the main basic concepts used in various Apps

Busca cep list - A project developed in Flutter for the Flutter Challenge that addresses the main basic concepts used in various Apps

Busca CEP - Desafio Flutter Projeto Busca CEP em Flutter Este é um projeto desen

Feb 9, 2022

Todo app codelab - A simple UI for todo app to showcase Flutter features and core concepts

Todo app codelab - A simple UI for todo app to showcase Flutter features and core concepts

Codelab Todo App A simple todo app UI for to showcase Flutter and Dart core conc

May 12, 2022

Flutter project to study and apply concepts of HTTP2 protocol

test_http2 A new Flutter project. Getting Started This project is a starting point for a Flutter application. A few resources to get you started if th

Feb 19, 2022

Arisprovider - A mixture between dependency injection (DI) and state management, built with widgets for widgets

A mixture between dependency injection (DI) and state management, built with wid

Jan 9, 2022
Owner
Jeovane Santos
Desenvolvedor mobile e back-end
Jeovane Santos
A lightweight, yet powerful way to bind your application state with your business logic.

binder A lightweight, yet powerful way to bind your application state with your business logic. The vision As other state management pattern, binder a

Romain Rastel 172 Nov 16, 2022
MobX for the Dart language. Hassle-free, reactive state-management for your Dart and Flutter apps.

Language: English | Português | Chinese mobx.dart MobX for the Dart language. Supercharge the state-management in your Dart apps with Transparent Func

MobX 2.2k Dec 27, 2022
Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.

Languages: English (this file), Indonesian, Urdu, Chinese, Brazilian Portuguese, Spanish, Russian, Polish, Korean, French. About Get Installing Counte

Jonny Borges 8k Jan 8, 2023
A predictable state management library that helps implement the BLoC design pattern

A predictable state management library that helps implement the BLoC design pattern. Package Pub bloc bloc_test flutter_bloc angular_bloc hydrated_blo

Felix Angelov 9.9k Dec 31, 2022
A simple way to access state while robust and testable.

A state-management library that: catches programming errors at compile time rather than at runtime removes nesting for listening/combining objects ens

Remi Rousselet 3.9k Jan 3, 2023
Another state management solution

VxState VxState is a state management library built for Flutter apps with focus on simplicity. It is inspired by StoreKeeper & libraries like Redux, V

Pawan Kumar 42 Dec 24, 2022
A flutter boilerplate project with GetX state management.

flutter_getx_boilerplate Languages: English (this file), Chinese. Introduction During my study of Flutter, I have been using the flutter_bloc state ma

Kevin Zhang 234 Jan 5, 2023
Flutter MVU architecture/state management package

mvu_flutter No mutability. No builders. No connectors. No reducers. No StreamControllers and subscription management. A truly declarative state manage

Yakov Karpov 7 Jul 29, 2021
Simple global state management for Flutter

Slices Slices is a minimalist state manegement, focused specifically for applications that needs a global state where different "pieces" of the applic

Erick 5 Jun 15, 2021
The modular state management solution for flutter.

The modular state management solution for flutter. Easy debugging : each event is predictable and goes into a single pipeline Centralized state : soli

Aloïs Deniel 44 Jul 6, 2022