flutter_offline icon indicating copy to clipboard operation
flutter_offline copied to clipboard

Question Using FutureBuilder

Open chitgoks opened this issue 3 years ago • 0 comments

how come snapshot.connectionState is always waiting when turning wifi off to on ?

once the future connects to an api, it cant resolve the hostname, like it's still offline. thoughts?

this is how it looks like

OfflineBuilder(
          connectivityBuilder: (context, connectivity, child) {
            final bool connected = connectivity != ConnectivityResult.none;
            print('connected='+connected.toString());
            return connected ? child : Stack(
              fit: StackFit.expand,
              children: [
                Positioned(
                  height: 24.0,
                  left: 0.0,
                  right: 0.0,
                  child: Container(
                    color: connected ? Color(0xFF00EE44) : Color(0xFFEE4400),
                    child: Center(
                      child: Text("${connected ? 'ONLINE' : 'OFFLINE'}"),
                    ),
                  ),
                ),
                Center(
                  child: new Text(
                    'Yay!',
                  ),
                ),
              ],
            );
          },
          child: FutureBuilder<Root?>(
            future: _fetch,
            builder: (context, snapshot) {
              print(snapshot.connectionState);
              if (snapshot.hasData)
                return _getScaffoldBody(snapshot.connectionState);

              return Center(child: CircularProgressIndicator());
            }
          ),
        ),

chitgoks avatar Jul 20 '21 11:07 chitgoks