AFUITextField constructor

AFUITextField({
  1. required AFScreenID screenId,
  2. required AFWidgetID wid,
  3. String? expectedText,
  4. AFTextEditingController? controller,
  5. AFTextEditingControllers? controllers,
  6. AFRouteParamWithFlutterState? parentParam,
  7. bool? enabled,
  8. bool obscureText = false,
  9. bool autofocus = false,
  10. InputDecoration? decoration,
  11. bool autocorrect = true,
  12. TextAlign textAlign = TextAlign.start,
  13. TextInputType? keyboardType,
  14. FocusNode? focusNode,
  15. TextStyle? style,
  16. int? minLines,
  17. int maxLines = 1,
  18. Color? cursorColor,
  19. ValueChanged<String>? onSubmitted,
  20. ValueChanged<String>? onChanged,
  21. String normalizeValue(
    1. String
    )?,
})

Implementation

AFUITextField({
  required this.screenId,
  required this.wid,
  String? expectedText,
  this.controller,
  this.controllers,
  this.parentParam,
  this.enabled,
  this.obscureText = false,
  this.autofocus = false,
  this.decoration,
  this.autocorrect = true,
  this.textAlign = TextAlign.start,
  this.keyboardType,
  this.focusNode,
  this.style,
  this.minLines,
  this.maxLines = 1,
  this.cursorColor,
  this.onSubmitted,
  this.onChanged,
  this.normalizeValue,
}) {
  var textController;
  if(controller != null) {
    assert(controllers == null && parentParam == null, errOnlyOneTextOwner);
    textController = controller;
  } else if(controllers != null) {
    assert(controller == null && parentParam == null, errOnlyOneTextOwner);
    textController = controllers?.access(wid);
  } else if(parentParam != null) {
    final flutterState = parentParam?.flutterState;
    assert(flutterState != null, "If you pass in a parent param, it must be one of the AF...RouteParamWithFlutterState variants");
    assert(controller == null && controllers == null, errOnlyOneTextOwner);
    textController = flutterState?.textControllers?.access(wid);
  } else {
    assert(false, "You must pass in controller, or controllers, or parentParam");
  }

  assert(textController != null, "You must register the text controller for $wid in your route parameter using AFTextEditingControllersHolder.createN or createOne");
  assert(textController?.controller != null);
  if(expectedText != null) {
    assert(textController?.text == expectedText, '''The text value in the text controller was different from the value you passed into
childTextField was different from the value in the text controller for $wid ('$expectedText' != '${textController?.text}').  This can happen if you
normalize or change the value of the text field in your code.  It can also happen in state testing, when you call methods that update the
value that would be in a text field.  In either case, you can resolve the problem by calling AFTextControllersHolder.update in the method
of your SPI that is called with the normalized value, or that is called from the test.  That method is idempotent, it does nothing if called
with the value that is already in the text field.
''');
  }

}