Using Flexible Widget to solve render flex overflow errors
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for Flutter Inspector layout tools: visualizing render overflow solutions | |
// This example is adapted from | |
//https://github.com/InMatrix/flutter_error_studies/blob/master/lib/renderflex_overflow_error2.dart | |
import 'package:flutter/material.dart'; | |
class ColumnOverflow extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('RenderFlex OverFlow 2'), | |
), | |
body: Container( | |
child: new Row( | |
children: [ | |
new Padding( | |
padding: EdgeInsets.all(16.0), | |
child: Icon(Icons.message), | |
), | |
// Resolution: Wrap the Column below in an Flexible widget. | |
Flexible( | |
child: | |
new Column( | |
mainAxisSize: MainAxisSize.min, | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text("Title", style: Theme.of(context).textTheme.headline4), | |
Text( | |
"Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed" | |
" do eiusmod tempor incididunt ut labore et dolore magna " | |
"aliqua. Ut enim ad minim veniam, quis nostrud " | |
"exercitation ullamco laboris nisi ut aliquip ex ea " | |
"commodo consequat."), | |
], | |
), | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment