click_text_field 0.0.2 copy "click_text_field: ^0.0.2" to clipboard
click_text_field: ^0.0.2 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 const MaterialApp(
      title: 'click_text_field',
      home: MyHomePage(),
    );
  }
}

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


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

class _MyHomePageState extends State<MyHomePage> {

  /// 章节内容输入框控制器
  final ClickTextEditingController textEditingController = ClickTextEditingController();
  /// flag
  bool changeRegex = false;

  @override
  void initState() {
    super.initState();
    textEditingController.setRegExp(RegExp(r'people a'));
    textEditingController.setOnTapEvent((strCallBack) => {
      debugPrint('U click the highlight text $strCallBack'),
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.grey,
      body: Column(
        children: [
          TextButton(
            child: const Text('Click reset regex'),
            onPressed: () {
              textEditingController.setRegExp(
                  changeRegex ?
                  RegExp(r'people a') : RegExp(r'people a')
              );
              changeRegex = !changeRegex;
            },
          ),
          TextField(
            controller: textEditingController,
            maxLines: null,
          ),
        ]
      )
    );
  }
}
0
likes
0
pub points
0%
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

License

unknown (license)

Dependencies

flutter, string_scanner

More

Packages that depend on click_text_field