build method

  1. @protected
Widget build(
  1. BuildContext context
)

Implementation

@protected
Widget build(BuildContext context) {
  screen.context = context;
  Widget? widget;

  // Always use builder if specified
  if (alwaysUseBuilder) {
    widget = builder();
    if (widget != null) return widget;
  }

  // Check screen type and return corresponding widget
  if (screen.isTV) {
    widget =
        tv() ?? largeDesktop() ?? desktop() ?? tablet() ?? phone() ?? watch();
    if (widget != null) return widget;
  }

  if (screen.isLargeDesktop) {
    widget = largeDesktop() ?? desktop() ?? tablet() ?? phone() ?? watch();
    if (widget != null) return widget;
  }

  if (screen.isDesktop) {
    widget = desktop() ?? tablet() ?? phone() ?? watch();
    if (widget != null) return widget;
  }

  if (screen.isLargeTablet) {
    widget = largeTablet() ?? tablet() ?? phone() ?? watch();
    if (widget != null) return widget;
  }

  if (screen.isTablet) {
    widget = tablet() ?? phone() ?? watch();
    if (widget != null) return widget;
  }

  if (screen.isPhone) {
    widget = phone() ?? watch();
    if (widget != null) return widget;
  }

  // Fallback to watch or builder
  return watch() ??
      phone() ??
      tablet() ??
      largeTablet() ??
      desktop() ??
      largeDesktop() ??
      tv() ??
      builder()!;
}