-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
import 'package:flutter/material.dart';
import 'package:rich_text_controller/rich_text_controller.dart';
import 'package:rich_text_controller/models/match_target_item.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
home: RichTextExample(),
);
}
}
class RichTextExample extends StatelessWidget {
RichTextExample({Key? key}) : super(key: key);
// Define your target matches
final targetMatches = [
MatchTargetItem.text(
'highlight', // Match exact text
style: const TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
),
MatchTargetItem.pattern(
r'\bFlutter\b', // Match the word "Flutter"
style: const TextStyle(color: Colors.green),
onTap: (match) {
print('Tapped on match: $match');
},
),
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('RichTextController Example')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: TextField(
controller: RichTextController(
text: 'Type "highlight" or "Flutter" here!',
targetMatches: targetMatches,
onMatch: (matches) {
print('Matched: $matches');
},
),
maxLines: null,
decoration: const InputDecoration(
hintText: 'Start typing...',
border: OutlineInputBorder(),
),
),
),
);
}
}
════════ Exception caught by widgets library ═══════════════════════════════════
The following assertion was thrown building _ScribbleFocusable(state: _ScribbleFocusableState#ee907):
'package:flutter/src/rendering/editable.dart': Failed assertion: line 1320 pos 14: 'readOnly && !obscureText': is not true.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels