Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TextEditingController] listeners are triggered inconsistently #45804

Open
sweatfryash opened this issue Nov 29, 2019 · 8 comments
Open

[TextEditingController] listeners are triggered inconsistently #45804

sweatfryash opened this issue Nov 29, 2019 · 8 comments
Labels
a: text input Entering text in a text field or keyboard related problems found in release: 2.2 Found to occur in 2.2 framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team

Comments

@sweatfryash
Copy link

sweatfryash commented Nov 29, 2019

  • at andriod
  1. type 1
    2.delete it

console shows:
1
(space)

  • at ios
  1. type 1
  2. delete it

console shows:
1
1
(space)

Maybe I am not understood, so you can see this simple demo about that problem
demo

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

class MyHomePage extends StatefulWidget{
  @override
  State<StatefulWidget> createState() {
    return MyHomePageState();
  }

}

class MyHomePageState extends State<MyHomePage>{
  //create a controller for TextField
  TextEditingController _controller = TextEditingController();


  @override
  void initState() {
    super.initState();
    //add a listener
    _controller.addListener((){
      if(_controller.text.isEmpty){
          print('++++++++ now (_controller.text.isEmpty) is TRUE ++++++++');
          print(_controller.text);
          print(_controller.text.runtimeType);
      }else{
          print('-------- now (_controller.text.isEmpty) is FALSE ---------');
          print(_controller.text);
          print(_controller.text.runtimeType);
      }
      setState(() {});
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: (Text('Demo')),
      ),
      body: Center(
        child: TextField(
          controller: _controller,
          decoration: InputDecoration(
            hintText: 'type and delete and look the console'
          ),
        ),
      ),
    );
  }
}
@sweatfryash sweatfryash changed the title When delete the last char in TextField, the TextField have a strange status When delete the last char in TextField, the TextField have a strange status at ios Nov 29, 2019
@iapicca iapicca added a: text input Entering text in a text field or keyboard related problems platform-ios iOS applications specifically labels Nov 29, 2019
@HansMuller HansMuller added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Dec 4, 2019
@VladyslavBondarenko
Copy link

Hi @sweatfryash
It seems to be fixed, I checked with dev v1.15.18, the behaviour is as intended, as you described for android.
Closing, if you disagree please write in the comments and I will reopen it
Thank you

@lock
Copy link

lock bot commented Apr 4, 2020

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.

@lock lock bot locked and limited conversation to collaborators Apr 4, 2020
@AlexV525
Copy link
Member

AlexV525 commented Aug 9, 2021

This issue is reproduced in 2.2.3. Android works fine but iOS reports twice change, see screenshots for how it changed during the deletion:

On Android (works fine):
image
Selection range is consistent when deleting the character.

On iOS (not working well, selection splitted):

  • First start/baseOffset fields were reduced as the key was pressed, but the character was not deleted at this time, which means it got selected.
    image

  • And the remove process eventually.
    image

@AlexV525 AlexV525 reopened this Aug 9, 2021
@flutter flutter unlocked this conversation Aug 9, 2021
@AlexV525 AlexV525 changed the title When delete the last char in TextField, the TextField have a strange status at ios [TextEditingController] listeners are triggered inconsistently Aug 9, 2021
@AlexV525 AlexV525 added the found in release: 2.2 Found to occur in 2.2 label Aug 9, 2021
@loic-hamdi
Copy link

This still exists in Flutter Channel stable, 3.0.5

It seems that the listener is triggered 2 times when you delete a character

@semsturgut-toast
Copy link

I can confirm that this problem is still happening in Flutter 3.3.4 • channel stable

@akurnaz
Copy link

akurnaz commented Feb 10, 2023

Same issue in Flutter 3.7.3 • channel stable

@kamami
Copy link

kamami commented May 24, 2023

Issue still exists in Flutter 3.10.1 • channel stable

@goderbauer goderbauer added the P2 Important issues not at the top of the work list label May 30, 2023
@adityanahak-cred
Copy link

do we have any update on this?

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team labels Jul 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
a: text input Entering text in a text field or keyboard related problems found in release: 2.2 Found to occur in 2.2 framework flutter/packages/flutter repository. See also f: labels. P2 Important issues not at the top of the work list platform-ios iOS applications specifically team-ios Owned by iOS platform team triaged-ios Triaged by iOS platform team
Projects
None yet
Development

No branches or pull requests