I want to return a bool in this method but it return a Future
@override
Widget build(BuildContext context) {
return Scaffold(
body: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 0, right: 0, top: 110, bottom: 5),
child: SingleChildScrollView(
child: Column(
children: <Widget>[
QuestionCards(),
cla().then((value) => { //this can't be add like this
YoutubeViewer(
videoId: 'hVQUbKs6qN8', topic: 'topic1'),
}
)
],
).
),
],
),
);
}
Future<bool> cla() async {
bool d = false;
try {
final result = await InternetAddress.lookup('google.com');
if (result.isNotEmpty && result[0].rawAddress.isNotEmpty) {
print('connected');
return Future<bool>.value(true);
}
} on SocketException catch (_) {
print('not connected');
return Future<bool>.value(false);
}
}
If someone can tell me that what need to be changed in this It would be really helpful Thank you