flutter - 将宽度设置为行的特定子项

标签 flutter dart flutter-layout

我有一个问题,我需要 backButton 和 actionsButtons(左和右)看起来完整。如果没有空格,标题将被剪切,但不会剪切其他按钮。我怎样才能做到这一点? (我在应用栏标题中有所有内容,因为我需要一个宽度更大的自定义后退按钮):

AppBar(
          backgroundColor: backgroundColor,
          titleSpacing: 0,
          title: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              _getButtonBackIOS(),
              Text(title),
              Expanded(
                child: Row(
                  children: actions,
                ),
              ),
            ],
          ),
          actions: [],
          automaticallyImplyLeading: false,
          leading: null,
        )

看起来像:

enter image description here

我想要这个:

enter image description here

最佳答案

尝试下面的代码希望对您有所帮助。将您的文本小部件包装在 Expanded 中的 Row 部分内,引用 here灵活引用here

 AppBar(
    title: Row(
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Expanded(
          child: Text('Atras'),
        ),
        Expanded(
          child: Text('Filtros offertos'),
        ),
        Expanded(
          child: Text('title'),
        ),
        Expanded(
          child: Text('titleasdas'),
        ),
        Expanded(
          child: Text('title'),
        ),
        Expanded(
          child: Text('titlesfsfsdf'),
        ),
      ],
    ),
  ),

你的结果屏幕像-> image

关于flutter - 将宽度设置为行的特定子项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69752451/

相关文章:

flutter - Flutter:Listview Builder水平内部堆栈小部件

flutter - Flutter-在底部将FlatButton按下

mobile - Flutter - 另一个小部件下方的位置 ListView

dart - 有没有办法禁用所有这些符号链接(symbolic link)到包目录?

flutter - 如何从 flutter 列表中选择随机元素

forms - 表单验证会破坏小部件的对齐方式

flutter - 如何使用回调方法获取 Flutter 中按钮的文本?

dart - asm/socket.h : No such file or directory cross compiling Dart for Raspberry pi

flutter - 在 Flutter 中获取父 widget 的 borderRadius

flutter - 如何在flutter中创建拆分容器?正确的做法应该是什么?定制画家还是芯片?