Beginning Flutter Debugging

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

Part 1: Beginning Flutter Debugging

08. Debug Common Layout Issues

Episode complete

Play next episode

Next
About this episode
Leave a rating/review
See forum comments
Cinema mode Mark complete Download course materials
Previous episode: 07. Get a Tour of Dart DevTools Next episode: 09. Solve Layout Errors in ListViews

Get immediate access to this and 4,000+ other videos and books.

Take your career further with a Kodeco Personal Plan. With unlimited access to over 40+ books and 4,000+ professional videos in a single subscription, it's simply the best investment you can make in your development career.

Learn more Already a subscriber? Sign in.

Notes: 08. Debug Common Layout Issues

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’re accessing parts of this content for free, with some sections shown as obfuscated text.

Heads up... You’re accessing parts of this content for free, with some sections shown as obfuscated text.

Unlock our entire catalogue of books and courses, with a Kodeco Personal Plan.

Unlock now

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()
)