Как я могу динамически изменять fillColor InputDecoration во флаттере?

Я хочу изменить цвет фона TextFormField, когда я выбрал TextFormField для ввода значения.

по умолчанию: цвет фона TextFormField серый в фокусе: цвет фона TextFormField синий.

Что я должен делать?

const _lowColor = Colors.redAccent; // use your own colors const _highColor = Colors.yellow; Color _field1Color = _lowColor; Focus( onFocusChange: (hasFocus) { setState(() => _field1Color = hasFocus ? _highColor : _lowColor) ); }, child: TextFormField( obscureText: (textType == «password») ? true : false, controller: (controller != null) ? controller : null, focusNode: _thisFocus, validator: (value) => (value.isEmpty) ? «Enter the Text» : null, style: _inputStyle, onFieldSubmitted: (String v) => { if (onFieldSubmitted != null) { onFieldSubmitted(v) } }, decoration: InputDecoration( labelText: placeHolder, labelStyle: _labelStyle, filled: true, fillColor: _field1Color, contentPadding: EdgeInsets.only(top: 4,bottom: 4,left: 6,right: 6), enabledBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xffE8E8E8), width: 1.0), borderRadius: BorderRadius.circular(10) ), focusedBorder: OutlineInputBorder( borderSide: BorderSide(color: Color(0xff3FC4FF), width: 1.0), borderRadius: BorderRadius.circular(10) ) ), ), ),

Источник: ledsshop.ru

Стиль жизни - Здоровье!