Code Monkey home page Code Monkey logo

statemanagement01's Introduction

statemanagement01

State Management Example 01

In a complex app, sometimes a Global Variable 'attached' to a widget, can be changed by some 'EXTERNAL EVENT' such as (1) A timer that run in another thread, or (2) socket.io server emit event (3) Others ......

Let's call this global variable gintCount and the app has 3 pages, namely:

Page 1: A 'Dynamic' page that need to display the latest value of gintCount.

Page 2: Another 'Dynamic' page that need to display the latest value of gintCount, with a Text Input Field.

Page 3: A 'Static' page that do nothing when gintCount changes.

Suppose the user is doing something in Page 1 or Page 2, when and where should we 'Refresh' the page to display the latest value that may/might be changed by EXTERNAL event?

I read the other Q&A in stackoverflow and it is said that there are 4 ways for the State Management of Flutter, they are namely:

Using setState

Using ScopedModal

Using Rxdart with BLoC

Using Redux

Since I'm a newbie in Flutter, I am completely lost in 2 to 4, so I've build an app using no. 1, i.e. setState. to demonstrate how we can manage states in flutter. And I hope, in the future, I am able to (or somebody else) provide answers by using no. 2 to 4.

To create this App Manually

  1. Download the zip file from github

  2. Create a new Flutter App in Android Studio.

  3. In file pubspec.yaml,include the following lines after dependencies:

threading:

  1. 'Tools' -> 'Flutter' -> 'Flutter Packages Get'

  2. Copy all the dart files from the zip file to your 'lib' directory

  3. Run the app in emulator or device.

statemanagement01's People

Contributors

lichiukenneth avatar lhcdims avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.