getPresentationWidgetsCustomBodyTemplate function

String getPresentationWidgetsCustomBodyTemplate(
  1. String projectName
)

Implementation

String getPresentationWidgetsCustomBodyTemplate(String projectName) {
  return '''
import 'package:flutter/material.dart';
import 'package:${projectName}/core/theme/app_colors.dart';
import 'package:${projectName}/core/utils/responsive_size.dart';
import 'package:${projectName}/presentation/widgets/text_widget.dart';

import 'no_internet_widget.dart';

class CustomBody extends StatelessWidget {
  final Widget child;
  final Widget bottomNavigationBar;
  final Widget? drawer;
  final Color? backgroundColor;
  final Color? appBackgroundColor;
  final bool isLoading;
  final String? title;
  final Widget? titleWidget;
  final double? titleSpacing;
  final Widget? appBarLeading;
  final List<Widget>? actions;
  final bool centerTitle;
  final EdgeInsetsGeometry? padding;
  final Key scaffoldKey;
  final String message;

  const CustomBody({
    super.key,
    required this.child,
    this.bottomNavigationBar = const SizedBox(),
    this.drawer,
    this.backgroundColor,
    this.appBackgroundColor,
    this.isLoading = false,
    this.title,
    this.titleWidget,
    this.titleSpacing,
    this.appBarLeading,
    this.actions,
    this.centerTitle = true,
    this.padding,
    this.scaffoldKey = const Key("custom_body_scaffold"),
    this.message = "",
  });

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      key: scaffoldKey,
      backgroundColor: backgroundColor ?? AppColors.background,

      /// ✅ FIX 1: Let scaffold handle keyboard properly
      resizeToAvoidBottomInset: true,
      appBar: appBarLeading != null
          ? AppBar(
              backgroundColor: appBackgroundColor ?? AppColors.background,
              title: titleWidget ??
                  TextWidget(
                    text: title ?? "",
                    textSize: 18,
                    fontWeight: FontWeight.w400,
                    color: AppColors.black,
                    isTitle: true,
                  ),
              centerTitle: centerTitle,
              titleSpacing: titleSpacing,
              leading: appBarLeading,
              actions: actions,
              scrolledUnderElevation: 0,
              surfaceTintColor: Colors.transparent,
            )
          : null,
      body: SafeArea(
        top: false,
        child: Stack(
          children: [
            Padding(
              padding: padding ?? const EdgeInsets.all(0),
              child: Container(
                decoration: BoxDecoration(
                  color: backgroundColor ?? AppColors.white,
                  borderRadius: BorderRadius.only(
                    topLeft: Radius.circular(20.sp),
                    topRight: Radius.circular(20.sp),
                  ),
                ),
                child: message.isNotEmpty ? NoInternetWidget() : child,
              ),
            ),

            /// Loader Overlay
            if (isLoading)
              Container(
                color: AppColors.black.withValues(alpha: 0.10),
                child: Center(
                  child: CircularProgressIndicator(
                    strokeWidth: 3,
                    color: AppColors.primary,
                  ),
                ),
              ),
          ],
        ),
      ),
      drawer: drawer,
      bottomNavigationBar: SafeArea(top: false, child: bottomNavigationBar),
    );
  }
}
''';
}