Skip to content

Selection handles position is off when switch between obscureText and non-obscureText #34607

Closed

Description

@chunhtai
import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  bool obscureText = false;
  TextEditingController controller = TextEditingController(text: 'asd asd');
  @override
  Widget build(BuildContext context) {

    return Scaffold(
      appBar: AppBar(

        title: Text(widget.title),
        actions: <Widget>[IconButton(
          icon: Icon(Icons.clear),
          onPressed: () {
            setState(() {
              obscureText = !obscureText;
            });
          },
        )]
      ),
      body: Center(

        child: Column(

          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            TextField( controller: controller,
              obscureText: obscureText,
            ),
          ],
        ),
      ),
    );
  }
}

1, select at the end of text
2, click the 'X' button in the top right
3, you will see the text gets shorten because obscured characters are smaller. however the selection handles does not update its position.

This also apply to changing text width or height without changing the texteditingvalue, ex changing style , structstyle.

Activity

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: material_uimaterial_ui package in flutter/packages
    on Jun 17, 2019
  2. chunhtai commented on Jun 17, 2019

    @chunhtai
    ContributorAuthor
  3. justinmc commented on Jun 17, 2019

    @justinmc
    Contributor

    Thanks @chunhtai. Looks like the handles are off when I change other stuff like font size as well. I'll take a look.

  4. chunhtai commented on Jun 17, 2019

    @chunhtai
    ContributorAuthor

    Actually, I am looking into it as well, I can fix this issue

  5. self-assigned this
    on Jun 17, 2019
  6. justinmc commented on Jun 17, 2019

    @justinmc
    Contributor

    Oh great, thanks!

  7. github-actions commented on Aug 29, 2021

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  8. locked as resolved and limited conversation to collaborators on Aug 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

a: text inputEntering text in a text field or keyboard related problemsframeworkflutter/packages/flutter repository. See also f: labels.p: material_uimaterial_ui package in flutter/packages

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions