title: How to pass Future<Either<Response, List<dynamic>>> function as parameter to Widget?
body: <p>I created a general ListPage as below:</p>
  <pre><code>class ListPage extends StatelessWidget {
    final context;
    final Future&lt;Either&lt;Response, List&lt;dynamic&gt;&gt;&gt; futureFuncion;
    final classListItem, classDetailPage;
  
    const ListPage(this.context,this.futureFuncion,this.classListItem,this.classDetailPage, {Key key,}) : super(key: key);
  
    @override
    Widget build(BuildContext context) {
      return Container(
        padding: const EdgeInsets.all(10.0),
        child: Column(children: [Expanded(child: _getData())]));
    }
  
    FutureBuilder _getData() {
      return FutureBuilder&lt;Either&lt;ResponseError, List&gt;&gt;(
        future: futureFuncion,
        builder: (BuildContext context, AsyncSnapshot&lt;Either&lt;ResponseError, List&gt;&gt; snapshot) {
          if (snapshot.hasError) {
            return globals.showSnapshotError(snapshot);
          } else if (!snapshot.hasData) {
            return globals.showLoading('Loading...');
          } else {
            return snapshot.data.fold((l) {
              return Error().showError(l.error, l.errorDescription);
            }, (r) {
              return ListView(children: _buildList(context, r));
            });
          }
        },
      );
    }
  }
  </code></pre>
  <p>I use code as below to create List Page:</p>
  <pre><code>class RequestListPage extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      String url = globals.debug ? 'assets/data/list.json' : 'domain.com/list';
      return Scaffold(
        appBar: AppBar(toolbarHeight: 50,centerTitle: true,title: Text(&quot;List&quot;)),
        body: ListPage(
          context,
          debug
              ? LoadDataFromJsonFile().loadListData(context, url, '$Response')
              : RequestApi().getListData(url, '$Response'),
          RequestListItem,
          RequestDetailPage,
        ),
      );
    }
    Widget _buildList(context, list) {
      List&lt;Widget&gt; children = [];
      list.forEach((item) {
        children.add(_buildTile(context, item));
      });
      return ListView(children: children);
    }
    ListTile _buildTile(context, item) {
      return ListTile(
        title: _buildListItem(context, item),
        onTap: () =&gt; showDetail(context, item),
      );
    }
    Widget _buildListItem(context, item) {
      return classListItem;
    }
    void showDetail(context, item) {
      Navigator.of(context).push(
        MaterialPageRoute(builder: (BuildContext context) =&gt; classDetailPage(context, item)),
        );
      }
    }
  }
  </code></pre>
  <p>When I run this code, I got error as below, what can I do?</p>
  <pre><code>Attempted to use type 'RequestListItem' as a function. Since types do not define a method 'call', this is not possible. Did you intend to call the RequestListItem constructor and forget the 'new' operator?
  Receiver: RequestListItem
  Tried calling: RequestListItem(Instance of 'StatefulElement', Instance of 'Response')
  </code></pre>