如何更改焦点上的 Flutter TextField 边框颜色?

How to change Flutter TextField border color on focus?

我创建了一个带有输入修饰符和 Outlineboraderinput 的简单文本字段。当我在该文本字段上键入时,我想更改边框颜色。 link下方可以看到我的作品。我想要的是将蓝色边框更改为白色:

TextFormField(
  decoration: InputDecoration(
    labelText: "Resevior Name",
    fillColor: Colors.white,
    enabledBorder:OutlineInputBorder(
      borderSide: const BorderSide(color: Colors.white, width: 2.0),
        borderRadius: BorderRadius.circular(25.0),
      ),
    ),
  )

添加焦点边框而不是 enabledBorder

TextFormField(
        decoration: InputDecoration(
          labelText: "Resevior Name",
          fillColor: Colors.white,
          focusedBorder:OutlineInputBorder(
            borderSide: const BorderSide(color: Colors.white, width: 2.0),
            borderRadius: BorderRadius.circular(25.0),
          ),
        ),
      )

在Flutter 2.5中,可以直接在ThemeData中更改TextField的焦点颜色:

theme: ThemeData().copyWith(
  // change the focus border color of the TextField
  colorScheme: ThemeData().colorScheme.copyWith(primary: Colors.amber),
  // change the focus border color when the errorText is set
  errorColor: Colors.purple,
),

Live Demo