0 purchases
controller builder
controller_builder #
Widget that abstracts common initialization and disposing of
TextEditingController, ChangeNotifier, etc.
ControllerBuilder<TextEditingController>(
// 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();
},
)
copied to clipboard
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.