build method

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

The child widget to display as the main content.

Implementation

@override
Widget build(BuildContext context) {
  final double topPadding = appBarHeight ??
      (isIOS()
          ? (MediaQuery.of(context).size.width > 700 ? 30.0 : 60.0)
          : 48.0);

  final Widget body = Column(
    children: [
      SizedBox(height: topPadding),
      _buildAppBar(context),
      Expanded(
        child: isRefresh
            ? RefreshIndicator(
                onRefresh: onRefresh!,
                child: _buildChildContent(),
              )
            : _buildChildContent(),
      ),
    ],
  );

  // Apply status bar style
  SystemChrome.setSystemUIOverlayStyle(
    statusBarColor != null || statusBarBrightness != null
        ? SystemUiOverlayStyle(
            statusBarColor: statusBarColor ?? Colors.transparent,
            statusBarIconBrightness: statusBarBrightness ?? Brightness.dark,
          )
        : AppConfig.statusBarStyle,
  );

  return Scaffold(
    body: Stack(
      children: [
        // ── Background layer ─────────────────────────────────────────
        // Renders either an image (AppBackground.image), a solid
        // color (AppBackground.color), or the default AppConfig.backgroundColor.
        Positioned.fill(
          child: _backgroundType == _BackgroundType.image
              ? Image(
                  image: backgroundImage!,
                  fit: BoxFit.cover,
                )
              : _backgroundType == _BackgroundType.color
                  ? ColoredBox(color: backgroundColor!)
                  : ColoredBox(color: AppConfig.backgroundColor),
        ),
        // Main content (with optional SafeArea)
        useSafeArea ? SafeArea(top: false, child: body) : body,
        // Loading overlay
        if (isLoading)
          Positioned.fill(
            child: loadingWidget ??
                const Center(child: CircularProgressIndicator()),
          ),
        // Error overlay
        if (isError) _buildErrorView(context),
      ],
    ),
    bottomNavigationBar: bottomNavigationBar,
    floatingActionButton: floatingActionButton,
  );
}