Skip to content

Instantly share code, notes, and snippets.

@pedromassango
Created October 9, 2020 23:27
Show Gist options
  • Save pedromassango/ffb51990892580e43c925f881884ea02 to your computer and use it in GitHub Desktop.
Save pedromassango/ffb51990892580e43c925f881884ea02 to your computer and use it in GitHub Desktop.
Text selection issue
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final _controller = TextEditingController(text: 'Please select me!');
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Bug',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: Scaffold(
appBar: AppBar(
title: Text("Flutter Bug"),
actions: [
IconButton(
icon: Icon(Icons.select_all_rounded),
onPressed: () {
_controller.selection = TextSelection(baseOffset: 7, extentOffset: 13);
},
)
],
),
body: Center(
child: TextField(
controller: _controller,
),
),
),
);
}
}
@pedromassango
Copy link
Author

Hi @justin,
While working on this proposal for text selection, I found out that this piece of code does not show the selection handler, I fear it is a bug. If it is a bug let me know to fix it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment