美文网首页
flutter 问题记录

flutter 问题记录

作者: wwq2020 | 来源:发表于2020-07-24 14:17 被阅读0次

    文本溢出

    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')),
        ]);
      }
    }
    

    相关文章

      网友评论

          本文标题:flutter 问题记录

          本文链接:https://www.haomeiwen.com/subject/gspjlktx.html