Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/luckey-elijah/controller_builder

Widget for abstracting initializing and disposing TextEditingController, ChangeNotifiers, etc.
https://github.com/luckey-elijah/controller_builder

Last synced: about 1 month ago
JSON representation

Widget for abstracting initializing and disposing TextEditingController, ChangeNotifiers, etc.

Awesome Lists containing this project

README

        

# `controller_builder`

[![style: very good analysis][very_good_analysis_badge]][very_good_analysis_link]
[![License: MIT][license_badge]][license_link]

Widget that abstracts common initialization and disposing of
`TextEditingController`, `ChangeNotifier`, etc.

```dart
ControllerBuilder(
// Create a controller (or any `ChangeNotifier`).
create: () {
final controller = TextEditingController(text: 'Hello, world!');
return controller..addListener(someListener);
},

// The controller you created in now available in the `builder` below.
builder: (context, controller) {
return TextField(
controller: controller,
onChanged: log,
);
},

// Dispose will be called automatically unless
// you provide a `dispose` callback like below.
// You assume responsibility to call dispose then.
dispose: (controller) {
controller
..removeListener(someListener)
..dispose();
},
)
```

[license_badge]: https://img.shields.io/badge/license-MIT-blue.svg
[license_link]: https://opensource.org/licenses/MIT
[very_good_analysis_badge]: https://img.shields.io/badge/style-very_good_analysis-B22C89.svg
[very_good_analysis_link]: https://pub.dev/packages/very_good_analysis