appBarChild method

PreferredSize? appBarChild(
  1. Widget child, {
  2. bool isThin = true,
  3. bool? centerTitle,
  4. List<Widget>? actions,
  5. Widget? leading,
  6. Widget? bottom,
  7. IconThemeData? iconTheme,
})

Implementation

PreferredSize? appBarChild(
  Widget child, {
  bool isThin = true,
  bool? centerTitle,
  List<Widget>? actions,
  Widget? leading,
  Widget? bottom,
  // Color? backgroundColor,
  IconThemeData? iconTheme,
}) {
  final height = bottom == null ? kToolbarHeight : kToolbarHeight * 2;
  final bottomWidget = bottom == null
      ? null
      : PreferredSize(
          preferredSize: const Size.fromHeight(kToolbarHeight),
          child: bottom,
        );

  if (isThin) {
    return PreferredSize(
      preferredSize: Size.fromHeight(height),
      child: Container(
        color: color.background(BackgroundColorType.primary),
        child: Center(
          child: Container(
            constraints:
                const BoxConstraints(maxWidth: OneGrid.maxWidth + 16 * 2),
            child: AppBar(
              title: child,
              centerTitle: centerTitle,
              leading: leading,
              actions: actions,
              bottom: bottomWidget,
              iconTheme: iconTheme,
            ),
          ),
        ),
      ),
    );
  } else {
    return PreferredSize(
      preferredSize: Size.fromHeight(height),
      child: Container(
        color: color.background(BackgroundColorType.primary),
        child: AppBar(
          title: child,
          centerTitle: centerTitle,
          leading: leading,
          actions: actions,
          bottom: bottomWidget,
          iconTheme: iconTheme,
        ),
      ),
    );
  }
}