onInit method

  1. @override
void onInit()
override

Called immediately after the widget is allocated in memory. You might use this to initialize something for the controller.

Implementation

@override
void onInit() {
  super.onInit();
  WidgetsBinding.instance.addObserver(this);

  _keyboardHeightPlugin.onKeyboardHeightChanged((double height) {
    /// Get keyboard height.
    updateKeyboardHeight(height);
    if (height == 0 && onKeyboardZero != null) {
      onKeyboardZero!();
    }
  });

  maxKeyboardHeight.value =
      box.read(_maxKeyboardHeightKey) ?? _minKeyboardHeightDef;
  maxBottomPaddingHeight.value = box.read(_maxBottomPaddingHeightKey) ?? 0.0;
  if (maxBottomPaddingHeight.value > _maxBottomPaddingHeightValueDef) {
    maxBottomPaddingHeight.value =
        Get.context == null ? 0 : MediaQuery.of(Get.context!).padding.bottom;
    box.write(_maxBottomPaddingHeightKey, maxBottomPaddingHeight.value);
  }
}