title: Dart Flutter: Function not executing
body: <p>I am new to Dart &amp; Flutter, I am trying to test <code>Future</code> functionality. I wrote a short <code>async</code> function, in which two <code>Future</code> objects are nested.
  <strong>Problem:</strong> The function does not execute, and when I try to attribute it to a variable I get an error <code>This expression has a type of 'void' so its value can't be used.</code> and <code>Only static members can be accessed in initializers.</code>.
  Here is the code: [![enter image description here][1]][1]</p>
  <pre><code>  @override
    _ChoseLocationState createState() =&gt; _ChoseLocationState();
  }
  
  class _ChoseLocationState extends State&lt;ChoseLocation&gt; {
    int counter = 0;
    
    void simulateRequest() async {
  
      // first future holds family name
      String famNameFunc = await Future.delayed(Duration(seconds: 2), (){
        String famName = 'Shanshi';
        return famName;
      });
  
  
      // second future holds first name
      String compName = await Future.delayed(Duration(seconds: 1), (){
        String fstName = 'Yoshi';
        String compName = '$fstName - $famNameFunc';
        return compName;
      });
  
      print(compName);
    }
  
    dynamic funcex = simulateRequest();
  
    @override
    void initState() {
      super.initState();
      print('This is the initial state.');
    }
    
    
    @override
    Widget build(BuildContext context) {
      print('This is the build function processing.');
      return Scaffold(
          appBar: AppBar(
            backgroundColor: Colors.red,
            title: Text('Set Location'),
            centerTitle: true,
            ),
          body: RaisedButton(
            onPressed: (){
            setState(() {
              counter++;
            });
          },
            color: Colors.blue,
            child: Text('Counter is: $counter'),
          ),
        );
    }
  }```
  
  [1]: https://i.stack.imgur.com/XmvY9.png
  </code></pre>