import 'dart:convert'; import 'dart:io'; import 'package:dio/dio.dart'; import 'package:flutter/material.dart'; import 'package:get_it/get_it.dart'; import 'package:sport/bean/login.dart'; import 'package:sport/services/api/login_api.dart'; import 'package:webview_flutter/webview_flutter.dart'; class TestNetworkPage extends StatelessWidget{ _test1 () async{ var dio = Dio(); var response = await dio.get("https://www.baidu.com"); return response.data; } _test2() async{ var dio = Dio(); var response = await dio.get("https://shoes-api.funfet.com"); return response.data; } _test3 () async{ HttpClient _client = HttpClient(); var request = await _client.getUrl(Uri.parse("https://www.baidu.com")); var response = await request.close(); return response.transform(utf8.decoder).join(); } _test4 () async{ HttpClient _client = HttpClient(); var request = await _client.getUrl(Uri.parse("https://shoes-api.funfet.com")); var response = await request.close(); return response.transform(utf8.decoder).join(); } _test6() async{ var dio = GetIt.I(); var response = await dio.get("https://shoes-api.funfet.com"); return response.data; } Future _test5() async{ var api = GetIt.I(); var response = await api.getLoginInfo("18502088330", password: "123456"); print("1111111111111111122222222222222 ${response}"); return response; } @override Widget build(BuildContext context) { return Scaffold(body: SingleChildScrollView(child: Column(children: [ Container( height: 150, child: WebView(initialUrl: "https://www.baidu.com",),), const Divider(color: Colors.red,), Container( height: 50, child: WebView(initialUrl: "https://shoes-api.funfet.com",),), const Divider(color: Colors.red,), Container( height: 50, child: FutureBuilder( future: _test1(), builder: (_, snapshot){ return Text("百度dio:${snapshot.data}"); }), ), const Divider(color: Colors.red,), Container( height: 50, child: FutureBuilder( future: _test3(), builder: (_, snapshot){ return Text("百度http:${snapshot.data}"); }), ), const Divider(color: Colors.red,), Container( height: 50, child: FutureBuilder( future: _test2(),builder: (_, snapshot){ return Text("趣动dio:${snapshot.data}"); }), ), const Divider(color: Colors.red,), Container( height: 50, child: FutureBuilder( future: _test4(),builder: (_, snapshot){ return Text("趣动http:${snapshot.data}"); }), ),const Divider(color: Colors.red,), Container( height: 50, child: FutureBuilder( future: _test6(),builder: (_, snapshot){ return Text("趣动get dio:${snapshot.data}"); }), ), const Divider(color: Colors.red,), Container( height: 50, child: FutureBuilder( future: _test5(),builder: (_, snapshot){ return Text("趣动get api:${snapshot.data?.code} ${snapshot.data?.msg}"); }), ), ],),),); } }