Skip to content

Example code throw exception #51

@khoadng

Description

@khoadng
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions