initState method

  1. @override
void initState()
override

This method is called when this object is inserted into the tree.

Here, it also adds this object as an observer in WidgetsBinding instance and initializes various fields related to the theme, contrast, and brightness of the app.

Implementation

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

  // Set the initial brightness with the system's current brightness from the first view of the platform dispatcher.
  _platformBrightness = MediaQueryData.fromView(PlatformDispatcher.instance.views.first).platformBrightness;

  // Sets the initial rounded.
  _rounded = widget.initialRounded;

  setCustomThemes(widget.customThemes);

  _customTheme = _customThemes[widget.initialTheme];

  if (widget.initialThemeMode != null) {
    _themeMode = widget.initialThemeMode!;
  }
  if (widget.initialContrast != null) {
    _contrast = widget.initialContrast!;
  }
}