简体   繁体   中英

ListView In TabBarView In Container not scrolling dart

I have the following flutter/dart code where the listView which is inside a tabBarView and also inside a container isn't scrollable

Container(
  height: MediaQuery.of(context).size.height,
  child: TabBarView(controller: _controller, children: [
    ListView(
        physics: const AlwaysScrollableScrollPhysics(), // new
        controller: _controllerView,
        children: [
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: CustomText(
              text: "User Details",
              size: 20,
              weight: FontWeight.bold,
              color: darkPrimary,
            ),
          ),
        
          ListTile(
            leading: Icon(Icons.date_range_rounded),
            title: CustomText(
              text: "Joined",
              color: grey,
              size: 15,
              weight: FontWeight.bold,
            ),
            subtitle: CustomText(
              text: "Jan 2020",
              size: 18,
              color: darkPrimary,
              weight: FontWeight.bold,
            ),
            dense: true,
          ),
          ListTile(
            leading: Icon(Icons.remove_red_eye_rounded),
            title: CustomText(
              text: "Active",
              color: grey,
              size: 15,
              weight: FontWeight.bold,
            ),
            subtitle: CustomText(
              text: "3 days ago",
              size: 18,
              color: darkPrimary,
              weight: FontWeight.bold,
            ),
            dense: true,
          ),
          
          Padding(
            padding: const EdgeInsets.all(16.0),
            child: CustomText(
              text: "Description",
              size: 20,
              weight: FontWeight.bold,
              color: darkPrimary,
            ),
          ),
          Padding(
            padding: const EdgeInsets.symmetric(horizontal: 16.0),
            child: CustomText(
              text:
                  "khfkjsh dkjash dkjash kdhask dhkas dkashkd askd asdh aksjhdkasj dkhhas dk askdh ask dhas hdas dh ask daskhh daskj daks dka  asdh as dasjh",
              size: 15,
              weight: FontWeight.bold,
              color: grey[700],
            ),
          ),
        ]),
    ListView(children: [])
  ]),
)

This is the controller code

TabController _controller;
ScrollController _controllerView = new ScrollController();

  @override
  void initState() {
    super.initState();
    _controller = new TabController(length: 2, vsync: this);
  }

Is there any problem with this code that is making it not scrollable instead the screen looks as if it is fixed. please help me out am a beginner in flutter/dart

Update: Instead I used Litview on like this and changed the other to column. even though its not what i want its still ok

body: SafeArea(
          child: ListView(),
)
try to wrap the ListView in Expanded or Stack

Wrap your container with

SingleChildScrollView

try to wrap the ListView in Expanded

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM