Skip to content

Instantly share code, notes, and snippets.

@justinmc
Created February 20, 2024 21:45
Show Gist options
  • Save justinmc/4238f4fa148727caafd9c7fee5273bd3 to your computer and use it in GitHub Desktop.
Save justinmc/4238f4fa148727caafd9c7fee5273bd3 to your computer and use it in GitHub Desktop.
The different ways to select text in Flutter.
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