click_text_field 0.0.10 copy "click_text_field: ^0.0.10" to clipboard
click_text_field: ^0.0.10 copied to clipboard

A flutter TextField which is able to click the highlight text part, by setting the regex. Also a string callBack function can be set.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:click_text_field/click_text_field.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
     return MaterialApp(
      title: 'click_text_field',
      theme: ThemeData(
        brightness: Brightness.dark
      ),
      home: const MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({Key? key}) : super(key: key);


  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  /// ClickTextEditingController
  final ClickTextEditingController textEditingController = ClickTextEditingController();

  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('click_text_field'),
      ),
      body: SingleChildScrollView(
        child: Column(
          children: [
            // ClickTextEditor(),
            ClickTextField(
                controller: textEditingController,
                regExp: RegExp(r'people a|people b|people c'),
                clickTextStyle: TextStyle(
                  background: Paint()
                    ..style = PaintingStyle.stroke
                    ..strokeWidth = 2
                    ..color = Colors.cyanAccent,
                ),
                onTapText: (clickCallBack) => {
                  debugPrint('U click the highlight text $clickCallBack'),
                }
            ),
            // SuggestClickTextField(
            //     controller: ClickTextEditingController(),
            //     regExp: RegExp(r'people a|people b|people c|embed c|building d|人物一'),
            //     textStyle: const TextStyle(
            //       color: Colors.deepPurple
            //     ),
            //     clickTextStyle: TextStyle(
            //       background: Paint()
            //         ..style = PaintingStyle.stroke
            //         ..strokeWidth = 2
            //         ..color = Colors.cyanAccent,
            //     ),
            //     onTapText: (clickCallBack) => {
            //       debugPrint('U click the highlight text $clickCallBack'),
            //     }
            // ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
pub points
27%
popularity

Publisher

unverified uploader

A flutter TextField which is able to click the highlight text part, by setting the regex. Also a string callBack function can be set.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, string_scanner

More

Packages that depend on click_text_field