文本溢出
class MyWidget extends StatelessWidget {
final text = 'long text..................';
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(Icons.add),
Text(text),
Icon(Icons.add),
]);
}
}
解决
class MyWidget extends StatelessWidget {
final text = 'long text..................';
@override
Widget build(BuildContext context) {
return Row(
children: [
Icon(Icons.add),
Expanded(
child: Text(
text,
),
),
Icon(Icons.add),
]);
}
}
widget 超出屏幕
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Row(
children: [
Chip(label: Text('a')),
Chip(label: Text('b')),
Chip(label: Text('c')),
Chip(label: Text('d')),
Chip(label: Text('e')),
Chip(label: Text('f')),
Chip(label: Text('g')),
Chip(label: Text('h')),
Chip(label: Text('i')),
Chip(label: Text('j')),
]);
}
}
解决
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Wrap(
children: [
Chip(label: Text('a')),
Chip(label: Text('b')),
Chip(label: Text('c')),
Chip(label: Text('d')),
Chip(label: Text('e')),
Chip(label: Text('f')),
Chip(label: Text('g')),
Chip(label: Text('h')),
Chip(label: Text('i')),
Chip(label: Text('j')),
]);
}
}
网友评论