2

When I use two nested Listviews and ListView.builder it still scroll, but the child Listview.builder with the shirnkSwap property cannot be scrolled anymore, but I don't want to use the height attribute in the widget container because it is very ugly.

Flutter 1.9.4 SDK

// My Home Screen

  @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,
      ),
    );
  }
}

Thank you for reading. Hope your help!

4
  • still wondering why you have to use ListView on the parent widget like this, ListView(children: <Widget>[TopHomeScreenBody(), BottomHomeScreen()]), why dont you change it to Column ? Commented Oct 17, 2019 at 3:20
  • If i change it to column in horizontal screen the topscreenbottom() will fix size at the top and cant scroll, and the content bottomhomescreen() just in little bit area with censored by topscreenbody(). I try change to column and in listview.builder(bottomhomescreen) wrap with expand widget, it can scroll best in vertical screen, but in horizontal screen is bad. Commented Oct 18, 2019 at 0:11
  • sorry, dont really understand what you mean, but why do you need scrollable widget inside a scrollable widget ? like ListView inside a ListView, i dont think its the best practice of using ListView, if you already determined the consecutive widget on the Home Screen, then i think using Colum is the best practice, and if there's some problem with the children, you have to fix the children, not changing the Column, as for me, i always use Column inside a SingleChildScrollView, if you can provide me the UI that you want to create, i'll try to help you create it Commented Oct 18, 2019 at 3:52
  • Can you pick me on facebook, or social net like that, i need 10 reputation for post images, i am newbie Commented Oct 18, 2019 at 11:59

1 Answer 1

7

If you mean that you dont want your listview.builder to scroll try adding this physics: NeverScrollableScrollPhysics(),

Sign up to request clarification or add additional context in comments.

2 Comments

I want all listview.builder can scroll. Sr for my question make mistake.
I was understood, In body of scaffold i use column inside singlechildscrollview, and in column i have 2 custom widget, tophomescreen and bottomscreen widget, in bottomhomescreen have listview.builder, i push physics: NeverScrollableScrollPhysics(), all widget in column can scroll, thanks you so much.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.