Created
February 20, 2024 21:45
-
-
Save justinmc/4238f4fa148727caafd9c7fee5273bd3 to your computer and use it in GitHub Desktop.
The different ways to select text in Flutter.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return const MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: Column( | |
children: <Widget>[ | |
SelectableText('Selectable text number one.'), | |
SelectableText('Selectable text number two.'), | |
SelectionArea( | |
child: Column( | |
children: <Widget>[ | |
const Text('Selection Area number one, Text number one.'), | |
const Text('Selection Area number one, Text number two.'), | |
], | |
), | |
), | |
SelectionArea( | |
child: Column( | |
children: <Widget>[ | |
const Text('Selection Area number two, Text number one.'), | |
const Text('Selection Area number two, Text number two.'), | |
], | |
), | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment