【问题标题】:ListView In TabBarView In Container not scrolling dart容器中的 TabBarView 中的 ListView 不滚动飞镖
【发布时间】:2021-03-24 14:25:17
【问题描述】:

我有以下颤振/飞镖代码,其中位于 tabBarView 和容器内的 listView 不可滚动

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: [])
  ]),
)

这是控制器代码

TabController _controller;
ScrollController _controllerView = new ScrollController();

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

这段代码是否有任何问题导致它无法滚动,而屏幕看起来好像是固定的。请帮助我是颤振/飞镖的初学者

更新:相反,我像这样使用 Litview 并将另一个更改为列。即使它不是我想要的它仍然可以

body: SafeArea(
          child: ListView(),
)

【问题讨论】:

    标签: flutter dart


    【解决方案1】:

    尝试将ListView 包裹在Expanded

    【讨论】:

      【解决方案2】:

      包裹你的容器
      SingleChildScrollView
      

      【讨论】:

      • @Brightcode 您能否为您的容器提供一个固定的高度/宽度(取决于您要滚动的位置)?!
      猜你喜欢
      • 2019-02-20
      • 1970-01-01
      • 2019-06-10
      • 1970-01-01
      • 2019-05-14
      • 2022-06-19
      • 2018-01-02
      • 1970-01-01
      • 2021-09-27
      相关资源
      最近更新 更多