Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/flutter/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Flutter 使文本在一行中可单击,并处理溢出_Flutter_Flutter Layout - Fatal编程技术网

Flutter 使文本在一行中可单击,并处理溢出

Flutter 使文本在一行中可单击,并处理溢出,flutter,flutter-layout,Flutter,Flutter Layout,我希望变量location标识的字符串可以单击,如果溢出,请使用省略号隐藏溢出的字符。但是,如果location足够短,不需要省略号,我不希望行中剩余的空间可以单击 Row( children: <Widget>[ Text('Location: '), Expanded( child: InkWell( onTap: () { // do something },

我希望变量
location
标识的字符串可以单击,如果溢出,请使用省略号隐藏溢出的字符。但是,如果
location
足够短,不需要省略号,我不希望行中剩余的空间可以单击

Row(
    children: <Widget>[
        Text('Location: '),
        Expanded(
            child: InkWell(
                onTap: () { // do something },
                child: Text(
                    '$location',
                    overflow: TextOverflow.ellipsis,
                ), // Text
            ), // InkWell
        ), // Expanded
    ], // <Widget>[]
),

要使$location仅可单击,只需将“Expanded”替换为“Flexible”,因为Flexible会将小部件的大小缩小到其内容,而不是像Expanded那样缩小到其父级的大小,例如:

子项:行(
儿童:[
文本('位置:'),
//将“扩展”替换为“灵活”
灵活的(
孩子:InkWell(
onTap:(){},
子:文本(
“$location”,
溢出:TextOverflow.省略号,
),//文本
),//InkWell
),//灵活
], // []
),
RichText(
    text: TextSpan(
        children: [
            TextSpan(text: 'Location: '),
            TextSpan(
                text: '$location',
                recognizer: TapGestureRecognizer()
                            ..onTap = () {
                                // do something
                            },
            ),
        ],
    ),
),