-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
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
- run the attached sample code
- write in the text field
- click the eye icon to reveal the text
- 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
- click the eye icon to obscure the text
- now the text in the text field is obscured
- 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)