title: How to filter specific data from an API flutter?
body: <p>I have an API <a href="https://sdgfortb.herokuapp.com/onetreeplanted" rel="nofollow noreferrer">https://sdgfortb.herokuapp.com/onetreeplanted</a></p>
  <p>This is how I fetch data.</p>
  <pre><code>Future&lt;List&lt;TreeInfo&gt;&gt; fetchGoals(http.Client client) async {
  final response =
    await client.get('https://sdgfortb.herokuapp.com/onetreeplanted');
  
  // Use the compute function to run parseGoalss in a separate isolate.
  
  return compute(parseGoalss, response.body);
   }
  
  // A function that converts a response body into a List&lt;TreeInfo&gt;.
  List&lt;TreeInfo&gt; parseGoalss(String responseBody) {
  final parsed = jsonDecode(responseBody).cast&lt;Map&lt;String, dynamic&gt;&gt;();
  
   return parsed.map&lt;TreeInfo&gt;((json) =&gt; TreeInfo.fromJson(json)).toList();
  } 
  </code></pre>
  <p>This is my model</p>
  <pre><code>class TreeInfo {
    String region;
    String country;
    String name;
    String overview;
    String impact;
    String treespecies;
    String imagelink;
  
    TreeInfo(
        {this.region,
        this.country,
        this.name,
        this.overview,
        this.impact,
        this.treespecies,
        this.imagelink});
  
    factory TreeInfo.fromJson(Map&lt;String, dynamic&gt; json) {
      return TreeInfo(
        region: json[&quot;region&quot;] as String,
        country: json[&quot;country&quot;] as String,
        name: json[&quot;name&quot;] as String,
        overview: json[&quot;overview&quot;] as String,
        treespecies: json[&quot;tree_species&quot;] as String,
        impact: json[&quot;impact&quot;] as String,
        imagelink: json[&quot;image_link&quot;] as String,
      );
    }
  }
  </code></pre>
  <p>Fetching Data
  class Loading extends StatelessWidget {
  final String destination;</p>
  <pre><code>  Loading({this.destination});
    @override
    Widget build(BuildContext context) {    
      return FutureBuilder&lt;List&lt;TreeInfo&gt;&gt;(
        future: fetchGoals(http.Client()),
        builder: (context, snapshot) {
          if (snapshot.hasError) print(snapshot.error);
  
          return snapshot.hasData
              ? GoalPage(
                  goals: snapshot.data,
                 // destination: destination,
                )
              : Center(
                  child: CircularProgressIndicator(
                  backgroundColor: Colors.greenAccent,
                ));
        },
      );
    }
  }
  class GoalPage extends StatelessWidget {
       
    List&lt;Goals&gt; goals;
  
    GoalPage({this.goals});
    @override
    Widget build(BuildContext context) {
      return Scaffold(
               Container(
                    height: 470,
                    padding: const EdgeInsets.only(left: 32),
                    child: Swiper(
                      itemCount: goals.length,
                      itemWidth: MediaQuery.of(context).size.width - 2 * 64,
                      layout: SwiperLayout.STACK,
                      pagination: SwiperPagination(
                        builder:
                            DotSwiperPaginationBuilder(activeSize: 8, space: 3),
                      ),
                      itemBuilder: (context, index) {
                        return InkWell(
                          onTap: () {
                            Navigator.push(
                              context,
                              PageRouteBuilder(
                                pageBuilder: (context, a, b) =&gt; DetailPage(
                                  goalInfo: goals[index],
                                ),
                              ),
                            );
                          },
  </code></pre>
  <p>I want to fetch the array which includes the region as North America.</p>
  <p>There are three other regions but I want to get data from North America from the API</p>