Skip to content

Enabling Textfield.obscureText without does not disable autocomplete until the textfield loses and regains focus #122300

@AdamVe

Description

@AdamVe

Touch Bar by default shows typing suggestions. This happens also for Flutter TextFields which have obscureText set to true.

obscureText is usually set for input fields with sensitive content, such as passwords and pins. Showing this content in clear text could be considered to be a security risk.

This issue can be reproduced on MacBooks with Touch Bar or on MacBooks without Touch Bar with Touch Bar simulation turned on (XCode -> Window -> Touch Bar menu).

Steps to Reproduce

  1. run the attached sample code
  2. write in the text field
  3. click the eye icon to reveal the text
  4. click out of the text field and back to the text field
    • now you see your the clear text in the text field and in the touch bar
  5. click the eye icon to obscure the text
    • now the text in the text field is obscured
  6. continue typing (don't click anywhere else)

Expected: the touch bar does not show the obscured text

What really happens: I can see the obscured text as clear text in touch bar. See the attached screen recording:

obscureText_touchbar_bug_main3.9.0-1.0.pre.145.mp4

Please note that for reproducing the issue in master or beta, one needs to change the obscureText property without altering focus.

Details

Code sample
import 'package:flutter/material.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: Scaffold(body: DemoWidget()));
  }
}

class DemoWidget extends StatefulWidget {
  const DemoWidget({super.key});

  @override
  State<DemoWidget> createState() => _DemoWidgetState();
}

class _DemoWidgetState extends State<DemoWidget> {
  bool _obscureText = true;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Container(
        alignment: Alignment.centerLeft,
        padding: const EdgeInsets.all(6),
        child: TextField(
          obscureText: _obscureText,
          decoration: InputDecoration(
            suffixIcon: IconButton(
              icon: Icon(
                _obscureText ? Icons.visibility : Icons.visibility_off,
                color: IconTheme.of(context).color,
              ),
              onPressed: () {
                setState(() {
                  _obscureText = !_obscureText;
                });
              },
            ),
          ),
        ),
      ),
    );
  }
}

Reproduced in stable

[✓] Flutter (Channel stable, 3.7.7, on macOS 13.2.1 22D68 darwin-arm64, locale en-SE)
textfield-obscuretext-touchbar.mp4

Reproduced in main and beta

[✓] Flutter (Channel main, 3.9.0-1.0.pre.121, on macOS 13.2.1 22D68 darwin-arm64, locale en-SE)
[✓] Flutter (Channel beta, 3.8.0-10.1.pre, on macOS 13.2.1 22D68 darwin-arm64, locale en-SE)
mac-touchbar-obscureText-flutter_3.9.0-1.0.pre.121-main.mp4

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: desktopRunning on desktopa: text inputEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.found in release: 3.7Found to occur in 3.7found in release: 3.9Found to occur in 3.9has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input teamworkaround availableThere is a workaround available to overcome the issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions