Daniel
Daniel

Reputation: 25

TextField's obscureText option issue

I'm using a custom TextField widget, and when I use it with obscureText set to true it skips a frame. If I pass a false it doesn't happen. Basically, if the obscureText change through different widgets it does this weird thing. Here is an example of the issue:

https://media.giphy.com/media/zbqxBPA0lyVdkXWzeY/giphy.gif

Widget code:

return TextField(
      controller: controller,
      onChanged: onChanged,
      obscureText: obscureText,
      cursorColor: Global.primaryColor,
      style: TextStyle(
        color: Global.primaryColor,
        fontSize: 14.0,
      ),
      decoration: InputDecoration(
          labelStyle: TextStyle(color: Global.primaryColor),
          focusColor: Global.primaryColor,
          filled: true,
          enabledBorder: UnderlineInputBorder(
            borderRadius: BorderRadius.circular(10),
            borderSide: BorderSide(color: Global.white),
          ),
          focusedBorder: OutlineInputBorder(
            borderRadius: BorderRadius.circular(10),
            borderSide: BorderSide(color: Global.primaryColor),
          ),
          labelText: labelText,
          prefixIcon: Icon(
            prefixIconData,
            size: 18,
            color: Global.primaryColor,
          ),
          suffixIcon: GestureDetector(
            onTap: () {
              //model.isVisible = !model.isVisible;
            },
            child: Icon(
              suffixIconData,
              size: 18,
              color: Global.primaryColor,
            ),
          )),
    );

Upvotes: 0

Views: 354

Answers (1)

Daniel
Daniel

Reputation: 25

I actually found the reason this was happening:

when using obscureText the keyboard doesn't have word suggestion enabled, so a workaround is disabling it by using autocorrect: false

Upvotes: 1

Related Questions