Flutter: Object was given an infinite size during layout Flutter: Object was given an infinite size during layout dart dart

Flutter: Object was given an infinite size during layout


From where I can see, you have the problem because you are inserting the StreamBuilder inside the SingleChildScrollView which has an infinite height to grow, and StreamBuilder asks for his parent's height.

StreamBuilder needs a parent that has a fixed size, so he can understand how much space he has to render his children.

what you need to do is to put the SingleChildScrollView inside a Container with a given size (You can put all the body inside a LayoutBuilder and use the constrains.maxHeight as the height to the container, so SingleChildScrollView knows its size).

like this: (Since I don't have your widgets, I can't run this code... so maybe there are some parentheses missing)

I hope this helps!

return GlobalScaffold(       body: LayoutBuilder(         builder: (ctx, constrains){           return GlobalScaffold(      body: Container(        height: constrains.maxHeight,        child: SingleChildScrollView(          child: Container(            padding: EdgeInsets.symmetric(horizontal: 20, vertical: 15),            child: Column(              crossAxisAlignment: CrossAxisAlignment.start,              children: <Widget>[                GradientHeading(text: "Guider", large: true),                ConditionalBuilder(                  condition: isAdmin,                  ifTrue: Column(                    children: <Widget>[                      NormalButton(                        text: "Skapa ny guide",                        onPressed: () {                          Navigator.pushNamed(context, createNewArtikelRoute);                        },                      ),                      NormalButton(                        text: "Lägg till ny kategori",                        outlined: true,                        onPressed: () {},                      ),                    ],                  ),                ),                SizedBox(height: 10),                StreamBuilder<List<GuiderCategoriesData>>(                  stream: DatabaseService().guiderCategoriesByPopularity,                  builder: (context, snapshot) {                    if (snapshot.connectionState == ConnectionState.active) {                      return GuiderCategories(                        snapshot: snapshot,                        numberOfCategories: snapshot.data.length,                      );                    } else if (!snapshot.hasData) {                      return GuiderCategories(                        hasNoCategories: true,                      );                    } else {                      return LoadingWidget();                    }                  },                ),              ],            ),          ),        ),      ),    );  }  )  );