Flutter - Insecure socket connections are disallowed by platform: 10.0.2.2

I have a similar issue with Flutter running on ios Simulator and Android emulator:

SocketException: Insecure socket connections are disallowed by platform:

Inside the Flutter project go to :

To enable in Ios:

ios folder -> runner folder -> info.plist

Then add the following lines to enable HTTP requests:

<key>NSAppTransportSecurity</key>
    <dict>
        <key>NSAllowsArbitraryLoads</key>
        <true/>
    </dict>

To enable in Android:

Android folder -> app -> src -> main -> AndroidManifest.xml

Add this permission:

<uses-permission android:name="android.permission.INTERNET"/>

then add the following line inside application tag:

android:usesCleartextTraffic="true"

First add-in AndroidManifest file

add this line in the end before closing tag

<uses-permission android:name="android.permission.INTERNET" />

add this line in the beginning find this tag and add it first in it

<application
    android:usesCleartextTraffic="true"