text_editing_watcher 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new67

text_editing_watcher #

A widget that rebuilds when text is changed in TextEditingController

Getting Started #

This simple widget can be used in order to rebuild other widgets based on changes in TextEditingController

              TextEditingWatcher(
                controller: _controller,
                builder: (text) => Text(
                  'You typed: $text',
                  textAlign: TextAlign.start,
                ),
              )

          // use TextEditingWatcher for disabling butting when text is empty
          TextEditingWatcher(
            controller: _controller,
            builder: (text) => RaisedButton(
              child: Text('submit'),
              onPressed: text.isNotEmpty ? () {} : null,
            ),
          )

[0.0.1] - 2020/05/02 #

  • Initial release

[1.0.0] - 2020/05/02 #

  • Removed BuildContext from the builder

example/README.md

example #


class _MyHomePageState extends State<MyHomePage> {
  TextEditingController _controller;

  @override
  void initState() {
    super.initState();
    _controller = TextEditingController();
  }

  @override
  void dispose() {
    super.dispose();
    _controller.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Column(
        children: <Widget>[
          Row(
            children: <Widget>[
              Container(
                width: 100,
                child: TextFormField(
                  decoration: InputDecoration(
                    focusedBorder: UnderlineInputBorder(),
                    isDense: true,
                  ),
                  controller: _controller,
                ),
              ),

              // use TextEditingWatcher in order to rebuild the Text on changes to the
              // TextFormField
              SizedBox(
                width: 50,
              ),
              TextEditingWatcher(
                controller: _controller,
                builder: (text) => Text(
                  'You typed: $text',
                  textAlign: TextAlign.start,
                ),
              )
            ],
          ),

          SizedBox(
            height: 30,
          ),
          // use TextEditingWatcher for disabling butting when text is empty
          TextEditingWatcher(
            controller: _controller,
            builder: (text) => RaisedButton(
              child: Text('submit'),
              onPressed: text.isNotEmpty ? () {} : null,
            ),
          )
        ],
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  text_editing_watcher: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:text_editing_watcher/text_editing_watcher.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
33
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
67
Learn more about scoring.

We analyzed this package on Feb 26, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.5
  • Flutter: 1.12.13+hotfix.8

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test