How to add more items in Flutter body

Issue

I’m learning Flutter and right now I’m calling _buildStackCardsList widget in the body but I’m trying to add additional text right above _buildStackedCardsList method but I’m not really sure how to implement that. every time I tried to wrap with containers or columns the stackedCard got to disappear.

  body: _buildStackedCardsList()
}


  Widget _buildStackedCardsList() {
  }

so this is what I trying to do

enter image description here

any suggestion, thanks

Solution

Flutters widget reference is a nice place to start when looking what widgets you can use and how you can implement your layout with it: https://flutter.dev/docs/reference/widgets

Judging from your wireframe I would add a Column widget https://api.flutter.dev/flutter/widgets/Column-class.html

body: Column(
  children: <Widget>[
    Text('Your Text'),
    Expanded(child: _buildStackedCardsList()),
  ],
)

Update: Due to size calculation you can not render a ListView as a direct child of Column. It can be for example wrapped in a Expanded widget. The answer to a similar question can be found here: https://stackoverflow.com/a/57132247/4668136

Answered By – Dimitri L.

Answer Checked By – Timothy Miller (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.