title: Flutter :how to call function in statelesswidget?
body: <p>I want to show a list of data with list view and JSON. This code in a file with <code>stateless widget</code>. And this page opened after login. When I try in <code>stateful widget</code>, the code RUN normally. In <code>stateless widget</code>, when I debug it, the code didn't call function getData(). But directly went to </p>
  
  <pre><code>Widget build(BuildContext context) {    
       return new Scaffold( ... 
  </code></pre>
  
  <p>Here is complete code :</p>
  
  <pre><code>class frmClass extends StatelessWidget{
    List&lt;dynamic&gt; dta;
    get setState =&gt; null;
  
    Future&lt;String&gt; getData() async {
        var uri ='https://xxxx.com/class';
        var map = new Map&lt;String, dynamic&gt;();
        map["username"] = "abc";
        map["password"] = "1234";
  
        http.Response response = await http.post(
          uri,
          body: jsonEncode(map),
        );
  
        Map&lt;String,dynamic&gt; mp = jsonDecode(utf8.decode(response.bodyBytes));
        this.setState(() {
          dta = mp["data"];
          debugPrint(dta.toString());
        });
  
      }
  
    @override
    void initState(){
      this.getData();
    }
  
    @override
    Widget build(BuildContext context) {
  
       return new Scaffold(
         appBar: new AppBar(
             backgroundColor:Colors.transparent,
             elevation: 0.0,
             iconTheme: new IconThemeData(color: Color(0xFF18D191))),
         body: new ListView.builder(
             itemCount: dta == null ? 0 : dta.length,
             itemBuilder: (BuildContext context, int index){
               return new Card(
                 child: new Text(dta[index]["className"]),
               );
             }
         ),
       );
    }
  }
  </code></pre>
  
  <p>How can I fix it?</p>