簡體   English   中英

如何滾動嵌套在 Flutter 中的 Listview

[英]How to scroll Listview nested in Flutter

當我使用兩個嵌套的 Listview 和 ListView.builder 時,它仍然會滾動,但是具有 shirnkSwap 屬性的子 Listview.builder 無法再滾動,但我不想在小部件容器中使用 height 屬性,因為它非常難看。

Flutter 1.9.4 SDK

// 我的主屏幕

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Color(0xFFEEF0F2),
      appBar: AppBar(
        backgroundColor: Color(0xFF396DF0),
        elevation: 0,
        leading: LeadinguttonIcon(),
        title: Text('TheGoal'),
        actions: <Widget>[ActionIconButton()],
      ),
      body:
          ListView(children: <Widget>[TopHomeScreenBody(), BottomHomeScreen()]),
    );
  }
}```

**//  TopHomeScreenBody**

```class TopHomeScreenBody extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return ClipPath(
      clipper: BodyClipper(),
      child: Container(
        color: Color(0xFF396DF0),
        padding: EdgeInsets.only(top: 10, right: 22, left: 22, bottom: 30),
        height: 250,
        width: double.infinity,
        child: Container(
          decoration: BoxDecoration(
              color: Colors.white,
              borderRadius: BorderRadius.all(Radius.circular(15))),
          child: Column(
            crossAxisAlignment: CrossAxisAlignment.center,
            mainAxisAlignment: MainAxisAlignment.spaceEvenly,
            children: <Widget>[MainText(), SubText()],
          ),
        ),
      ),
    );
  }
}```

**// BottomHomeScreen** 


```class BottomHomeScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
//  IT CAN SCROLL WHEN ADD HEIGHT BUT I
//  DONT WANT USE HEIGHT HERE BECAUSE VERY UGLY APP
//    height: 400,
      padding: EdgeInsets.all(25),
      decoration: BoxDecoration(
        color: Color(0xFFEEF0F2),
      ),
      child: ListView.builder(
        shrinkWrap: true,
        itemBuilder: (context, index) {
          return BottomGoalTitle(
            text: '${goalList[index].text}',
            decsText: '${goalList[index].decsText}',
            color: goalList[index].color,
            icon: goalList[index].icon,
          );
        },
        itemCount: goalList.length,
      ),
    );
  }
}

感謝您的閱讀。 希望您的幫助!

如果你的意思是你不希望你的listview.builder滾動嘗試添加這個physics: NeverScrollableScrollPhysics(),

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM