I'm trying to do a get request using HTTP just to get google and display it as text.
My code works in both Android and iOS but not in web.
String _google;
void _onClick() async {
final _res = await http.get('https://www.google.com');
print(_res.body);
setState(() => _google = _res.body);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(''),
),
body: Center(
child: Text(_google ?? 'null'),
),
floatingActionButton: FloatingActionButton(
onPressed: _onClick,
child: Icon(Icons.send),
),
);
}