flutter android 中发送http申请后,默认会报错。须要批改配置文件。

network_security_config.xml

<?xml version="1.0" encoding="utf-8"?><network-security-config><base-config cleartextTrafficPermitted="true" /></network-security-config>

AndroidManifest.xml

<application        android:name="io.flutter.app.FlutterApplication"        android:label="flutter_study"        android:icon="@mipmap/ic_launcher"        android:networkSecurityConfig="@xml/network_security_config">        <activity            android:name=".MainActivity"            android:launchMode="singleTop"            android:theme="@style/LaunchTheme"            android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"            android:hardwareAccelerated="true"            android:windowSoftInputMode="adjustResize">            <intent-filter>                <action android:name="android.intent.action.MAIN"/>                <category android:name="android.intent.category.LAUNCHER"/>            </intent-filter>        </activity>        <!-- Don't delete the meta-data below.             This is used by the Flutter tool to generate GeneratedPluginRegistrant.java -->        <meta-data            android:name="flutterEmbedding"            android:value="2" />    </application>