text_selection_intent 0.0.1
text_selection_intent: ^0.0.1 copied to clipboard
A Flutter plugin that allows your Android app to appear in the system text selection menu.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:text_selection_intent/text_selection_intent.dart';
void main() {
runApp(const TestApp());
}
class TestApp extends StatelessWidget {
const TestApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(home: TextSelectionExample());
}
}
class TextSelectionExample extends StatefulWidget {
const TextSelectionExample({super.key});
@override
State<TextSelectionExample> createState() => _TextSelectionExampleState();
}
class _TextSelectionExampleState extends State<TextSelectionExample> {
String selectedText = 'No text selected';
@override
void initState() {
super.initState();
TextSelectionIntent.listen((text) {
setState(() {
selectedText = text;
});
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: SelectableText('Text Selection Intent')),
body: Padding(
padding: const EdgeInsets.all(16),
child: Text(selectedText, style: const TextStyle(fontSize: 16)),
),
);
}
}