Skip to content

[web] setSemanticsEnabled(true) makes TextField with obscureText:true print out obscured text #90794

@FallenRiteMonk

Description

@FallenRiteMonk

With the following line after a runApp call
RendererBinding.instance!.setSemanticsEnabled(true);
TextFields with obscureText: true are unusable, due to onChange and textController.text always return obscured text on web.

This behavior was noticed once I updated from 2.2.3 to 2.5.0 and still persists in 2.5.1.

The below example shows the described problem. Removing RendererBinding.instance!.setSemanticsEnabled(true); results in TextField returning to desired effect.

import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';

void main() { 
  runApp(MyApp());
  RendererBinding.instance!.setSemanticsEnabled(true);
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  final String title;

  const MyHomePage({
    Key? key,
    required this.title,
  }) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String? _text;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            Text(
              'You have entered: $_text',
            ),
            TextFormField(
            obscureText: true,
            onChanged: (text) {
              print('Entered: $text');
              setState(() {
                _text = text;
              });
            },
          )
          ],
        ),
      ),
    );
  }
}

Metadata

Metadata

Assignees

Labels

P2Important issues not at the top of the work lista: accessibilityAccessibility, e.g. VoiceOver or TalkBack. (aka a11y)a: text inputEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowfound in release: 2.5Found to occur in 2.5found in release: 2.6Found to occur in 2.6has reproducible stepsThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyr: fixedIssue is closed as already fixed in a newer version

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions