getDefaultMaxLengthEnforcement static method

MaxLengthEnforcement getDefaultMaxLengthEnforcement(
  1. [TargetPlatform? platform]
)

Returns a MaxLengthEnforcement that follows the specified platform's convention.

Platform specific behaviors

Different platforms follow different behaviors by default, according to their native behavior.

Implementation

static MaxLengthEnforcement getDefaultMaxLengthEnforcement([
  TargetPlatform? platform,
]) {
  if (kIsWeb) {
    return MaxLengthEnforcement.truncateAfterCompositionEnds;
  } else {
    switch (platform ?? defaultTargetPlatform) {
      case TargetPlatform.android:
      case TargetPlatform.windows:
        return MaxLengthEnforcement.enforced;
      case TargetPlatform.iOS:
      case TargetPlatform.macOS:
      case TargetPlatform.linux:
      case TargetPlatform.fuchsia:
        return MaxLengthEnforcement.truncateAfterCompositionEnds;
    }
  }
}