Search code examples
flutterdartlistviewcenterappbar

how to Add List in TabBarView in flutter


i want to add listviw with column . . . . . . .. . . .

. . . . . ..

in 'a' screen i want to show list.

but i can't and i've get error. idk why.

can anyone help me please ?

this is part of my code:

 Expanded(
            child: Padding(
              padding: const EdgeInsets.only(top: 30),
              child: Container(
                width: 500,
                child: DefaultTabController(
                  length: 3,
                  child: Scaffold(
                    appBar: PreferredSize(
                      preferredSize: Size.fromHeight(50.0),
                      child: const TabBar(
                        tabs: <Widget>[
                          Tab(
                              text: "a",
                          ),
                          Tab(
                            text: "b",
                          ),
                          Tab(
                            text: "c",
                          ),
                        ],
                      ),
                    ),
                    body: const TabBarView(
                      children: <Widget>[
                        Center(
                            child: Text("a "),
//here i want to add listView
                        ),
                        Center(
                          child: Text("b"),
                        ),
                        Center(
                          child: Text("c"),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ),
          ),

Solution

  • just delete 'const' in TabBarView

                body: TabBarView(
                  children: <Widget>[
                    Center(
                        child: Text("a "),
    
                    ),
                    Center(
                      child: Text("b"),
                    ),
                    Center(
                      child: Text("c"),
                    ),
                  ],