title: Flutter: Object was given an infinite size during layout
body: <p>I'm battling an issue where I'm given the error &quot;<strong>Object was given an infinite size during layout</strong>&quot;
  and
  &quot;This probably means that it is a render object that tries to be as big as possible, but it was put inside another render object that allows its children to pick their own size.&quot;.</p>
  <p>I understand what it means, but not how I can still keep my current widget tree <strong>responsive</strong> (it renders when running, so for a front-end user there seems to be no problem) while still fixing this issue. Currently I don't set the size of certain things to keep things responsive, and <strong>would like to avoid hard coding sizes of widgets if possible</strong>.</p>
  <p>Any help or pointer in the right direction is greatly appreciated :)</p>
  <p>Here's my current code:</p>
  <pre><code>    class EditArtikel extends StatefulWidget {
    final String path;
  
    EditArtikel({this.path});
  
    @override
    _EditArtikelState createState() =&gt; _EditArtikelState(path: path);
  }
  
  class _EditArtikelState extends State&lt;EditArtikel&gt; {
    final String path;
  
    _EditArtikelState({this.path});
  
    final titleController = TextEditingController();
    final subtitleController = TextEditingController();
    final authorController = TextEditingController();
    final textController = TextEditingController();
  
    File imageFile;
  
    List&lt;DropdownMenuItem&lt;dynamic&gt;&gt; dropdownMenuItemFromList() {
      List&lt;DropdownMenuItem&lt;dynamic&gt;&gt; itemsList = [];
      for (var i = 1; i &lt; currentTags.length; i++) {
        itemsList.add(new DropdownMenuItem(
          child: Text(currentTags[i]),
          value: currentTags[i],
        ));
      }
      return itemsList;
    }
  
    var _selectedValue = &quot;&quot;;
  
    @override
    Widget build(BuildContext context) {
      final isAdmin = Provider.of&lt;bool&gt;(context);
      var pathElements = path.split('/');
      final String artikelID = pathElements[3];
      List&lt;DropdownMenuItem&lt;dynamic&gt;&gt; items = dropdownMenuItemFromList();
  
      if (isAdmin == true) {
        return LayoutBuilder(
          builder: (context, constraint) {
            return GlobalScaffold(
              body: Container(
                height: constraint.maxHeight,
                child: SingleChildScrollView(
                  child: StreamBuilder&lt;ArtikelData&gt;(
                      stream:
                          DatabaseService(pathID: artikelID).artikelByArtikelID,
                      builder: (context, snapshot) {
                        if (snapshot.hasData) {
                          titleController.text == &quot;&quot;
                              ? titleController.text = snapshot.data.title
                              : titleController.text;
  
                          subtitleController.text == &quot;&quot;
                              ? subtitleController.text = snapshot.data.subtitle
                              : subtitleController.text;
  
                          authorController.text == &quot;&quot;
                              ? authorController.text = snapshot.data.author
                              : authorController.text;
  
                          textController.text == &quot;&quot;
                              ? textController.text = snapshot.data.text
                              : textController.text;
  
                          _selectedValue == &quot;&quot;
                              ? _selectedValue =
                                  currentTags.contains(snapshot.data.tags)
                                      ? snapshot.data.tags
                                      : currentTags[1]
                              : _selectedValue = _selectedValue;
  
                          FirebaseStorageImage fbImage = new FirebaseStorageImage(
                            fileName: artikelID,
                            storageLocation: fbRefArtiklarImages,
                          );
  
                          return Container(
                            color: primaryColor,
                            padding: EdgeInsets.symmetric(
                                horizontal: 20, vertical: 15),
                            child: Column(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              crossAxisAlignment: CrossAxisAlignment.start,
                              children: &lt;Widget&gt;[
                                Column(
                                  crossAxisAlignment: CrossAxisAlignment.start,
                                  children: &lt;Widget&gt;[
                                    GradientHeading(
                                      large: true,
                                      text: &quot;Redigera artikel&quot;,
                                    ),
                                    SizedBox(height: 15),
                                    CustomTextFormField(
                                      labelText: &quot;Rubrik&quot;,
                                      controller: titleController,
                                    ),
                                    CustomTextFormField(
                                      labelText: &quot;Underrubrik&quot;,
                                      controller: subtitleController,
                                    ),
                                    Padding(
                                      padding: EdgeInsets.only(bottom: 7),
                                      child: DropdownButtonFormField(
                                        decoration: customInputDecoration(&quot;Tags&quot;),
                                        value: _selectedValue,
                                        isDense: true,
                                        onChanged: (value) {
                                          setState(() {
                                            _selectedValue = value;
                                          });
                                        },
                                        items: items,
                                      ),
                                    ),
                                    CustomTextFormField(
                                      labelText: &quot;Skriven av&quot;,
                                      controller: authorController,
                                    ),
                                    CustomTextFormField(
                                      labelText: &quot;Text&quot;,
                                      multiline: true,
                                      controller: textController,
                                    ),
                                    NormalButton(
                                      text: &quot;Ladda upp ny bild&quot;,
                                      outlined: true,
                                      outlinedBgColor: primaryColor,
                                      onPressed: () async {
                                        FocusScope.of(context).unfocus();
                                        imageFile = await ChooseImage()
                                            .chooseImageFromGallery();
                                        setState(() {});
                                      },
                                    ),
                                    ConditionalBuilder(
                                      condition: imageFile == null,
                                      ifTrue: NormalButton(
                                        text: &quot;Ta bort originalbild&quot;,
                                        shouldOverideColor: true,
                                        overriddenColor: redWarningColor,
                                        onPressed: () async {
                                          FocusScope.of(context).unfocus();
                                          showDialog(
                                            context: context,
                                            barrierDismissible: true,
                                            builder: (_) =&gt; AlertDialog(
                                              content: Text(
                                                  &quot;Vill du radera originalbilden?&quot;),
                                              actions: &lt;Widget&gt;[
                                                FlatButton(
                                                  child: Text(&quot;Avbryt&quot;),
                                                  onPressed: () {
                                                    Navigator.of(context).pop();
                                                  },
                                                ),
                                                FlatButton(
                                                  child: Text(&quot;Radera&quot;),
                                                  onPressed: () async {
                                                    await StorageService()
                                                        .deleteArtikelImageToStorage(
                                                            artikelID);
                                                    setState(() {});
                                                    Navigator.of(context).pop();
                                                  },
                                                ),
                                              ],
                                            ),
                                          );
                                        },
                                      ),
                                    ),
                                    ConditionalBuilder(
                                      condition: imageFile != null,
                                      ifTrue: NormalButton(
                                        text: &quot;Ta bort bild&quot;,
                                        shouldOverideColor: true,
                                        overriddenColor: redWarningColor,
                                        onPressed: () {
                                          FocusScope.of(context).unfocus();
                                          imageFile = null;
                                          setState(() {});
                                        },
                                      ),
                                    ),
                                    ConditionalBuilder(
                                      condition: imageFile != null,
                                      ifTrue: imageFile != null
                                          ? Image(
                                              image: FileImage(imageFile),
                                            )
                                          : Container(),
                                      ifFalse: fbImage,
                                    ),
                                    SizedBox(height: 40),
                                  ],
                                ),
                                NormalButton(
                                  text: &quot;Publisera ändringar&quot;,
                                  onPressed: () async {
                                    if (titleController.text != &quot;&quot; &amp;&amp;
                                        subtitleController.text != &quot;&quot; &amp;&amp;
                                        authorController.text != &quot;&quot; &amp;&amp;
                                        textController.text != &quot;&quot;) {
                                      DatabaseService().editArtikel(
                                        artikelID,
                                        titleController.text,
                                        subtitleController.text,
                                        _selectedValue,
                                        authorController.text,
                                        textController.text,
                                        imageFile,
                                      );
                                      Navigator.pop(context);
                                    } else {
                                      showDialog(
                                        context: context,
                                        barrierDismissible: true,
                                        builder: (_) =&gt; AlertDialog(
                                          content:
                                              Text(&quot;Du måste fylla i alla fält&quot;),
                                          actions: &lt;Widget&gt;[
                                            FlatButton(
                                              child: Text(&quot;OK&quot;),
                                              onPressed: () {
                                                Navigator.of(context).pop();
                                              },
                                            )
                                          ],
                                        ),
                                      );
                                    }
                                  },
                                ),
                              ],
                            ),
                          );
                        } else {
                          return LoadingWidget();
                        }
                      }),
                ),
              ),
            );
          },
        );
      } else {
        return GlobalScaffold(
          body: Center(
            child: Text(&quot;Du har inte tillgång till den här sidan&quot;),
          ),
        );
      }
    }
  }
  </code></pre>
  <p>And here's the error log:
  <a href="https://i.stack.imgur.com/FWjBx.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FWjBx.png" alt="enter image description here" /></a>
  <a href="https://i.stack.imgur.com/fkXUq.png" rel="noreferrer"><img src="https://i.stack.imgur.com/fkXUq.png" alt="enter image description here" /></a></p>