Ejemplo n.º 1
0
        void initState()
        {
            base.initState();
            _snapshot = AsyncSnapshot <T> .withData(ConnectionState.none, widget.initialData);

            _subscribe();
        }
Ejemplo n.º 2
0
        void _subscribe()
        {
            if (widget.future != null)
            {
                object callbackIdentity = new object();
                _activeCallbackIdentity = callbackIdentity;
                widget.future.then((object dataIn) => {
                    var data = (T)dataIn;
                    if (_activeCallbackIdentity == callbackIdentity)
                    {
                        setState(() => { _snapshot = AsyncSnapshot <T> .withData(ConnectionState.done, data); });
                    }
                }, onError: (Exception error) => {
                    if (_activeCallbackIdentity == callbackIdentity)
                    {
                        setState(() => { _snapshot = AsyncSnapshot <T> .withError(ConnectionState.done, error); });
                    }

                    return(FutureOr.nil);
                });
                _snapshot = _snapshot.inState(ConnectionState.waiting);
            }
        }
Ejemplo n.º 3
0
 AsyncSnapshot <T> afterData(AsyncSnapshot <T> current, T data)
 {
     return(AsyncSnapshot <T> .withData(ConnectionState.active, data));
 }
Ejemplo n.º 4
0
 AsyncSnapshot <T> initial() => AsyncSnapshot <T> .withData(ConnectionState.none, initialData);