Skip to content

Instantly share code, notes, and snippets.

@machinescream
Last active February 7, 2019 20:31
Show Gist options
  • Save machinescream/06b2b5b2a3fdc317a9943f5f6734f4aa to your computer and use it in GitHub Desktop.
Save machinescream/06b2b5b2a3fdc317a9943f5f6734f4aa to your computer and use it in GitHub Desktop.
State
import 'dart:async';
class ScreenState {
final valueElementState = _ElementState(value: 0);
/// Global state describes a screen state
}
class _ElementState{
/// Element state describes a view state
var value; /// You can remove this line if you don't need hold a value
final id; /// Will need to save state in database
final valueBroadcaster = StreamController.broadcast();
get valueStream => valueBroadcaster.stream;
_ElementState({this.value, this.id}){
valueBroadcaster.add(value);
/// Adding a default value in to the StreamController
}
}
final state = ScreenState();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment