19

Use case: Messaging app you edit your message: keyboard, blinking cursor and initial text appears but pointer (cursor) is not

But on Flutter when you use initial text (or via textController) there are always pointer(cursor) which is not wanted

Example

enter image description here enter image description here

Steps to reproduce: run flutter create bug

edit main.dart to replace center text (line 100) to MyStatefulPage(),

class MyStatefulPage extends StatefulWidget {
  @override
  State<MyStatefulPage> createState() {
    return _MyStatefulPageState();
  }
}
class _MyStatefulPageState extends State<MyStatefulPage> {

  TextEditingController controller;

  @override
  void initState() {
    super.initState();
    controller = new TextEditingController();
    controller.text = 'My Initial Text';
  } 

  @override
  Widget build(BuildContext context) {
    return TextField(
      decoration: InputDecoration(
       border: InputBorder.none
      ),
      // showCursor: false,
      controller: controller,
      autofocus: true,
      maxLines: 8,
    );
  }
}

With that code when you open app keyboard will appear but so will pointer(cursor) I want to hide this cursor(pointer).

Note: it's only for Android.

srikanth7785
  • 1,382
  • 1
  • 7
  • 22
Philip Dolenko
  • 618
  • 1
  • 6
  • 12
  • Hi, @philip did you resolve your issue? – DmDev Sep 06 '22 at 12:55
  • Hi @DMDev No, this question was created almost 2 years ago. Maybe some of the answers are correct but I haven't tested them if you will find a solution please post it here as well, Thanks! – Philip Dolenko Sep 12 '22 at 15:40

6 Answers6

29

TextField set enableInteractiveSelection property to false can resolve this issue

menttofly
  • 291
  • 3
  • 5
2

TextFormField cursorHeight: 0 and cursorWidth: 0 can hide the cursor.

2

in textformfield use showCursor: false

Aaishah
  • 21
  • 2
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 20 '22 at 16:10
0

TextFormField(enableInteractiveSelection: false)

ajaybadole
  • 121
  • 1
  • 1
  • 6
0

readOnly: true, hide the cursor

0

To hide the blinking cursor

enter image description here

Add this line of code

showCursor: false

To hide the editing pointer

enter image description here

Add this line of code

enableInteractiveSelection: false
Lekr0
  • 653
  • 1
  • 8
  • 17