controllerWithInitialText abstract method

TextEditingControllerImp controllerWithInitialText(
  1. String text
)

Initializes a controller with the given initial text.

It is useful when the initial value is obtained in the build method of the widget tree. (We can not initialize the controller when creating the injectedTextEditingController)

Don't do

final myInjectedController= RM.injectTextEditingController();

// In the widget tree
Widget builder(BuildContext context){
  final initialValue = ...;
   return TextField(
     controller: myInjectedController.controller..text = initialValue,
   )
}

Do

final myInjectedController= RM.injectTextEditingController();

// In the widget tree
Widget builder(BuildContext context){
  final initialValue = ...;
   return TextField(
     controller: myInjectedController.controllerWithInitialText(initialValue) ,
   )
}

Implementation

TextEditingControllerImp controllerWithInitialText(String text);