Beginning Flutter Debugging

Sep 29 2022 Dart 2.18, Flutter 3.3, Visual Studio Code / Android Studio

Part 1: Beginning Flutter Debugging

8. Debug Common Layout Issues

Episode complete

Play next episode

Next
Save for later
About this episode
See versions
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 7. Get a Tour of Dart DevTools Next episode: 9. Solve Layout Errors in ListViews

Prerequesites: A decent understanding of Flutter layout, especially Rows and Columns widgets. The student materials have been reviewed and are updated as of SEPTEMBER 2022.

Heads up... You've reached locked video content where the transcript will be shown as obfuscated text.

You can unlock the rest of this video course, and our entire catalogue of books and videos, with a kodeco.com Professional subscription.

One of the most common error that occurs while building layouts is the overflow error. This happens when a widget tries to take more space beyond the boundaries of its parent widget. You can see the overflow warning sign at different parts of our UI. The sign also shows you how many pixels the widget overflows and this can help you make the neccessary adjustments.

class CardItem extends StatelessWidget {
  const CardItem({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 120, // From 100 to 120
Wrap(
  spacing: 8,
  children:[
    ...
)
Row(
  children: <Widget>[
    const Trivia(message: "..."),
    const Trivia(message: "..."),
  ],
)
Row(
  //crossAxisAlignment: CrossAxisAlignment.start,
  children: <Widget>[
    const Expanded(
      child: Trivia(message: '...'),
    ),
    const Expanded(
      child: Trivia(message: '...'),
    ),
  ],
)
// Main Column ie Body of the Scaffold
Column(
  children: [
    // New Code
    const Text('Some Header Here'),
    ListView(
      children: List.generate(
        20,
        (index) => ListTile(
          title: Text('Item $index'),
        ),
      ),
    ),
  ]
)
shrinkWrap: true,
...
Expanded(
  child: ListView()
)