I want to show different data on same GridView using two button. eg: A button show brands, B button oppress show categories. How I can do that?

Hi, I am using Grid-view to show data.
List item;
GridView.count(
// Create a grid with 2 columns. If you change the scrollDirection to
// horizontal, this produces 2 rows.
crossAxisCount: 2,
// Generate 100 widgets that display their index in the List.
children: List.generate(100, (index) {
return Center(
child: Text(
item.length,
style: Theme.of(context).textTheme.headline5,
),
);
}),
);

TWO BUTTONS
A B
oppress A : show different data
oppress B : show different data
any help

I think you can simply acheive that goal by using Stateful Widget.

Below is the sample code.

import 'package:flutter/material.dart';

class MyPage extends StatefulWidget {
  @override
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage> {
  bool isBrand = false;
  
  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        GridView.count(
        crossAxisCount: 2, 
        children: isBrand ? brandList : categoryList,
        ),
        ElevatedButton(
        onPressed: () => setState(()=> isBrand = true), 
        child: Text('Button A'),
        ),
        ElevatedButton(
        onPressed: () => setState(()=> isBrand = false), 
        child: Text('Button B'),
        ),
      ],
    );
  }
}