Multiple widgets layout issues

2,526 views
Skip to first unread message

Jamie Sutherland

unread,
Nov 4, 2019, 9:52:56 AM11/4/19
to Flutter Development (flutter-dev)
Hi there,
I am developing an app that pulls data from differtent json sources. One part pulls the data to create buttons that lead on to the next page to pull the relevant json data.
I can get it to pull that data and display it in the buttons, where my issue start is displaying this along with other widgets on the page.

when i add other containers, columns or Row etc to the homepage the screen goes white and there is nothing displayed.
in my debug i get:
the last part of the error can be  Scaffold or Center, depending on if it is row, column, container etc


════════ Exception caught by rendering library ═════════════════════════════════
RenderBox was not laid out: RenderRepaintBoundary#58443 relayoutBoundary=up6 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1681 pos 12: 'hasSize'
User-created ancestor of the error-causing widget was
    Scaffold

My HomePage: 

class _HomePageScreen extends State<HomePage>{
@override

 Widget build(BuildContext context){
return Scaffold(
 appBar: AppBar(
   title:Text('Home'),
 ),
  drawer: HasSideBarDrawer(),
 body:Container(
   child: questionList(1),
 ),
  );
}



here is my questionList function
questionList(parentid){
 return FutureBuilder<List<QuestionButton>>(
       future: fetchQuestions(http.Client(),parentid),
   builder: (context, snapshot){
      if (snapshot.hasError) print(snapshot.error);

          return snapshot.hasData
             ? QuestionList(questionButtons: snapshot.data)
             : Center(child: CircularProgressIndicator());
   },    
 );
}



Here is the code for creating my Raised Button:


class HAButtons extends StatefulWidget {
final childID;
final id;
final buttonTitle;

HAButtons({this.childID,this.id,this.buttonTitle});

 @override
 _HAButtonsState createState() => _HAButtonsState();
   
}

class _HAButtonsState extends State<HAButtons>{
@override
Widget build(BuildContext context){
return
RaisedButton(
       color: Colors.lightBlue,
       onPressed:() => _buttonPushed(widget.childID, widget.id,widget.buttonTitle),
       textColor: Colors.white30,
       elevation: 5.0,
       shape: RoundedRectangleBorder(borderRadius: new BorderRadius.circular(10.0)),
       splashColor: Colors.white54,
     child:
      new Text(widget.buttonTitle,
       style: TextStyle(
         color: Colors.white,
         fontWeight: FontWeight.w600,
         fontSize: 15.0,
         ),  
         ),
 );
}

_buttonPushed(String parentID, String id, String selectedTitle){
   Navigator.push(
     context,
     new MaterialPageRoute(
       builder: (context) => ContentPage(parentID:parentID, id: id, selectedTitle: selectedTitle,),
   )
   );
   }
}

Thomas Verbeek

unread,
Nov 4, 2019, 10:44:36 AM11/4/19
to Flutter Development (flutter-dev)
This error usually appears when flutter has problems rendering because of missing size information. Try to wrap the problematic widgets inside of a Expanded widget.

Cheers,
Tom.


--
You received this message because you are subscribed to the Google Groups "Flutter Development (flutter-dev)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to flutter-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/flutter-dev/84728f42-cbb6-4f69-93fe-7b6e95385d69%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages