@@ -120,10 +120,6 @@ class State extends Disposable implements Function {
120120 });
121121 }
122122
123- static const _NONE_STATE_NAME = '__none__' ;
124-
125- State ._none (StateMachine machine) : this ._(_NONE_STATE_NAME , machine);
126-
127123 State ._wildcard () : this ._('__wildcard__' , null , listenTo: false );
128124
129125 /// Stream of enter events. Enter event occurs every time
@@ -148,24 +144,22 @@ class State extends Disposable implements Function {
148144 /// You can check that condition with:
149145 ///
150146 /// initialState.onEnter((change) {
151- /// if (!change.from.isNone ) {
147+ /// if (!change.from == State.none ) {
152148 /// // do something here
153149 /// }
154150 /// })
155151 ///
156152 /// to ignore this false initial event.
157153 ///
158154 /// bool, true if this state is None,
159- /// false otherwise
160- bool get isNone {
161- return name == _NONE_STATE_NAME ;
162- }
155+ /// false otherwise
156+ static final none = State ._('__none__' , null , listenTo: false );
163157
164158 @override
165159 String toString () {
166160 String name = this .name;
167- if (isNone ) {
168- name = ' none - state machine has yet to start' ;
161+ if (this == none ) {
162+ return 'State: none - state machine has yet to start' ;
169163 }
170164 return 'State: $name (active: ${this ()}, machine: ${_machine .name })' ;
171165 }
@@ -199,13 +193,13 @@ class StateChange {
199193 /// }
200194 /// })
201195 bool get isInitial {
202- return this .from.isNone ;
196+ return this .from == State .none ;
203197 }
204198
205199 @override
206200 String toString () {
207201 StringBuffer sb = StringBuffer ();
208- String fromName = from.isNone ? '(none)' : from.name;
202+ String fromName = isInitial ? '(none)' : from.name;
209203 sb.writeln ('StateChange: ${fromName } --> ${to .name }' );
210204 if (payload != null ) {
211205 sb.writeln (' payload: $payload ' );
@@ -284,7 +278,7 @@ class StateMachine extends Disposable {
284278 /// Start the machine in a temporary state.
285279 /// This allows an initial state transition to occur
286280 /// when the machine is started via [start] .
287- _current = State ._none ( this ) ;
281+ _current = State .none ;
288282
289283 manageDisposable (_current);
290284 }
0 commit comments