【问题标题】:Change a textfield Thumb in Flutter?在 Flutter 中更改文本字段 Thumb?
【发布时间】:2019-01-26 12:33:45
【问题描述】:

我正在尝试更新我的文本字段以使用红色而不是绿色/蓝色。这是我目前的状态。

这是我的代码:

                TextField(
                    focusNode: focusNode,
                    autocorrect: false,
                    autofocus: false,
                    style: TextStyle(color: Colors.white),
                    cursorColor: Colors.white,
                    decoration: InputDecoration.collapsed(
                        hintStyle: TextStyle(color: Colors.white),
                        hintText: "FirstName"),
                  )

【问题讨论】:

    标签: android flutter flutter-layout


    【解决方案1】:

    https://docs.flutter.io/flutter/material/ThemeData/textSelectionHandleColor.html

             final theme = Theme.of(context);
             return Theme(data: theme.copyWith(
               textSelectionHandleColor: Colors.red,
               child: TextField(
                    focusNode: focusNode,
                    autocorrect: false,
                    autofocus: false,
                    style: TextStyle(color: Colors.white),
                    cursorColor: Colors.white,
                    decoration: InputDecoration.collapsed(
                        hintStyle: TextStyle(color: Colors.white),
                        hintText: "FirstName"),
                  )
             )
    

    【讨论】:

    • 这似乎不适用于 Flutter 1.17.3。根据我的调查是因为这个问题:github.com/flutter/flutter/issues/36220
    • 正在进行几个主题更改,但它适用于 Flutter 1.19.0-1.0.pre。
    猜你喜欢
    • 1970-01-01
    • 2022-09-29
    • 2021-10-16
    • 2018-08-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多