title: Flutter, problem using InitState method and problem using setState
body: <p>I have tried many things to get to call an API and get data, this has been satisfactory but I have not been able to do it from the correct method, when I do it from build it works perfectly but it is not the right place, when I try to do it in initState it simply does not it works, it doesn't even execute the print ();</p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:http/http.dart' as http;
  import 'dart:convert';
  
  class Post {
    final List&lt;dynamic&gt; data;
  
    Post({this.data});
  
    factory Post.fromJson(Map&lt;String, dynamic&gt; json) {
      return Post(
        data: json['response'],
      );
    }
  }
  
  class LoaderPublicity extends StatefulWidget {
  
  
    @override
    State&lt;StatefulWidget&gt; createState() {
      // TODO: implement createState
      return _LoaderPublicity();
    }
  }
  
  class _LoaderPublicity extends State&lt;LoaderPublicity&gt; {
    List allPublicity;
  
    @override
    void initState() {
      super.initState();
      getPublicity().then((value) {
        print(allPublicity);
      });
      print(allPublicity);
    }
  
    //Obtener todas las publicidades desde el api
    Future&lt;void&gt; getPublicity() async {
      var response = await http.post(
          'http://contablenift.co:3008/consult/getGeneralPublicity',
          body: {'actividad': "Turistico", 'location': "No"});
      print('????????2');
      if (response.statusCode == 200) {
        setState(() {
          allPublicity = Post.fromJson(json.decode(response.body)).data;
        });
      }
    }
  
    @override
    Widget build(BuildContext context) {
      getPublicity();
      // TODO: implement build
      return Container(
        child: Column(
          children: &lt;Widget&gt;[Text('Aqui va la publicidad')],
        ),
      );
    }
  }
  </code></pre>
  
  <p>**
  Solved the problem, after going to the entire development team we realized that my phone did not have internet, happy day**</p>