title: Pagination with Grid List in Flutter
body: <p>I want to have a pagination in my grid list.
  I have a list of items which is coming from an API endpoint. and currently I am displaying 21 records. but the original list is very long. so, I want to have a pagination type where users can see all the items from the list coming from API.</p>
  <p>here's my code.</p>
  <pre><code>class _CategoryPageState extends State&lt;CategoryPage&gt; {
    @override
    void initState() {
      super.initState();
    }
  
    @override
    Widget build(BuildContext context) {
      return FutureBuilder(
        future: getCategoryList(widget.slug, widget.isSubList, widget.token),
        builder: (context, AsyncSnapshot snapshot) {
          switch (snapshot.connectionState) {
            case ConnectionState.none:
            case ConnectionState.waiting:
              return CircularProgress();
            default:
              if (snapshot.hasError)
                return Text('Error: ${snapshot.error}');
              else
                return createListView(context, snapshot, widget.isSubList, widget.token);
          }
        },
      );
    }
  }
  
  Widget createListView(BuildContext context, AsyncSnapshot snapshot, bool isSubList, String token) {
    List&lt;CategoryModel&gt; values = snapshot.data;
  
    return GridView.count(
      crossAxisCount: 3,
  //    physics: NeverScrollableScrollPhysics(),
  //      values[index].imageUrl
      padding: EdgeInsets.all(1.0),
      /*childAspectRatio: 8.0 / 9.0,*/
      children: List&lt;Widget&gt;.generate(values.length, (index) {
        if(values[index].imageUrl == null){
          values[index].imageUrl = 'dummy.jpg';
        }
        return GridTile(
            child: GridTilesCategory(
          name: values[index].name,
          imageUrl: values[index].imageUrl,
          slug: values[index].slug,
          fromSubProducts: isSubList,
          token: token,
          imageType: 'category-images',
        ));
      }),
    );
  }
  
  Future&lt;List&lt;CategoryModel&gt;&gt; getCategoryList(String slug, bool isSubList, String token) async {
    if (isSubList) {
      categories = null;
    }
    if (categories == null) {
      final response = await http.post(
          Urls.ROOT_URL + slug,
          body: json.encode({
            &quot;filter&quot; : {&quot;categoryname&quot;:null,&quot;status&quot; : 1},
            &quot;sortOrder&quot; : &quot;ASC&quot;,
            &quot;sortField&quot; : &quot;&quot;,
            &quot;pageNumber&quot; : 0,
            &quot;pageSize&quot; : 21
          }),
          headers: {
            'content-type': 'application/json',
            'Authorization': 'Bearer $token',
          }
      );
      print(response.toString());
      final responseData = json.decode(response.body);
  
      int statusCode = response.statusCode;
      final body = json.decode(response.body);
      print(body);
      if (statusCode == 200) {
        categories = (body['items'] as List).map((i) =&gt; CategoryModel.fromJson(i)).toList();
  
        return categories;
      } else {
        return categories = List();
      }
    } else {
      return categories;
    }
  }
  
  </code></pre>
  <p>my requirement is like a continue scrolling type pagination.</p>