Android Flutter and http get


I’m figuring out how to get status code 200 from
This code only works on desktop and android emulator, but it doesn’t work on the android mobile. The variable string id178 is always blank . It doesn’t even print ‘TEST’
setState() should update the variable when you tap
Thank you

This is the manifest file:

<manifest xmlns:android=""
   <!-- The INTERNET permission is required for development. Specifically,
     the Flutter tool needs it to communicate with the running application
     to allow setting breakpoints, to provide hot reload, etc.
   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

import 'package:flutter/material.dart';
import 'package:http/http.dart' as http;

void main() {

class App extends StatelessWidget {
 Widget build(BuildContext context) {
   return MaterialApp(
      home: HomePage(),

class HomePage extends StatefulWidget {
  _HomePageState createState() => _HomePageState();

class _HomePageState extends State<HomePage> {
  String id178 = '';

  getMachinesId() async {
    var url = Uri.parse('');
    var res = await http.get(url);
    id178 = '${res.statusCode} TEST ';

  void initState() {

 Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Colors.black87,
        title: const Text("TEST !",
        style: TextStyle(
            fontSize: 20,
            fontStyle: FontStyle.italic,
            fontWeight: FontWeight.bold,
            color: Color(0xFFbf9b0a))),
      centerTitle: true,
      body: Center(
        child: Text(
          "Server Machine: $id178\n",
          style: const TextStyle(
            fontSize: 10,
            fontWeight: FontWeight.bold,

      floatingActionButton: FloatingActionButton(
         onPressed: () {
           setState(() {
         child: const Icon(Icons.verified_sharp),


As far as I know there are three manifest file

src/main (release)

I’ve edited the wrong manifest…


After you have created new project in visual code, there is a manifest for each subfolder :




In terminal window I run :

flutter build apk --release

so the right "AndroidManifest.xml" file is in the "main" folder

Answered By – ghost239

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published