Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question Using FutureBuilder #44

Open
chitgoks opened this issue Jul 20, 2021 · 0 comments
Open

Question Using FutureBuilder #44

chitgoks opened this issue Jul 20, 2021 · 0 comments

Comments

@chitgoks
Copy link

chitgoks commented Jul 20, 2021

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());
            }
          ),
        ),
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant