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

            _subscribe();
        }
Esempio n. 2
0
        void didUpdateWidget(StatefulWidget statefulWidget)
        {
            var oldWidget = statefulWidget as FutureBuilder <T>;

            if (oldWidget == null)
            {
                return;
            }

            base.didUpdateWidget(oldWidget);
            if (oldWidget.future != widget.future)
            {
                if (_activeCallbackIdentity != null)
                {
                    _unsubscribe();
                    _snapshot = _snapshot.inState(ConnectionState.none);
                }

                _subscribe();
            }
        }
Esempio n. 3
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);
            }
        }
Esempio n. 4
0
 AsyncSnapshot <T> afterDisconnected(AsyncSnapshot <T> current) => current.inState(ConnectionState.none);
Esempio n. 5
0
 Widget build(BuildContext context, AsyncSnapshot <T> currentSummary) => builder(context, currentSummary);
Esempio n. 6
0
 AsyncSnapshot <T> afterDone(AsyncSnapshot <T> current) => current.inState(ConnectionState.done);
Esempio n. 7
0
 AsyncSnapshot <T> afterError(AsyncSnapshot <T> current, object error)
 {
     return(AsyncSnapshot <T> .withError(ConnectionState.active, error));
 }
Esempio n. 8
0
 AsyncSnapshot <T> afterData(AsyncSnapshot <T> current, T data)
 {
     return(AsyncSnapshot <T> .withData(ConnectionState.active, data));
 }
Esempio n. 9
0
 AsyncSnapshot <T> afterConnected(AsyncSnapshot <T> current) => current.inState(ConnectionState.waiting);
Esempio n. 10
0
 AsyncSnapshot <T> initial() => AsyncSnapshot <T> .withData(ConnectionState.none, initialData);