Flutter - Using Expanded or Flexible widgets within a CustomScrollView with SliverList

Viewed 696

I am trying to build a list with dynamic containers using the Expanded widget class, I am getting a error back from flutter stating that expanded needs to be in a Flex container which I understand. But as soon as I wrap my Expandeds in a column I loose functionality I am looking for. I am trying to get away from defining a set height to the "containers as the data can change".

Is there a way to use SliverList with Expanded children ?

Please see my current structure bellow.

class _HomeViewState extends State<HomeView> {
  Widget build(BuildContext context) {
    return PageTemplate(
      back: false,
      child : CustomScrollView(
          shrinkWrap: true,
          slivers: <Widget>[
            SliverPadding(
                padding: const EdgeInsets.all(0.0),
                sliver: SliverList(
                  delegate: SliverChildListDelegate(
                    <Widget>[
                      SizedBox(
                        height: 10,
                      ),
                      Container(
                        padding: EdgeInsets.symmetric(vertical: 16.0),
                        child: Greeting(),
                      ),
                      Expanded(
                        flex: 1,
                        child: Rewards(),
                      ),
                      SizedBox(
                        height: 16,
                      ),
                      Expanded(
                        flex: 1,
                        child: CurrentBalance(),
                      ),
                      Expanded(
                        flex: 1,
                        child: QuickLinks(),
                      ),
                      Expanded(
                        flex: 1,
                        child: HeadlinesUpdates(),
                      ),
                      SizedBox(
                        height: 100,
                      ),
                    ],
                  ),
                ),
            ),
          ]
        ),
      );
  }
}

Thanks

0 Answers
Related