AppBackground class

A widget that provides a customizable background and app bar for your application screens.

AppBackground wraps its child widget with an app bar, handles loading and error states, supports pull-to-refresh, custom actions, a floating action button, bottom navigation, and status bar customization. It is designed to streamline the creation of consistent page layouts throughout your app.

Named Constructors

Use the named constructors to set the background declaratively:

// Solid color background
AppBackground.color(
  color: Colors.white,
  child: MyPage(),
)

// Image background (asset, network, file — any [ImageProvider])
AppBackground.image(
  image: AssetImage('assets/bg.png'),
  child: MyPage(),
)
Inheritance

Constructors

AppBackground({Key? key, required Widget child, String title = '', Widget? titleWidget, bool showBackButton = false, VoidCallback? onBackPressed, Widget? leading, bool showNotification = false, VoidCallback? onNotificationPressed, int? notificationBadgeCount, bool showSearch = false, VoidCallback? onSearchPressed, bool showCall = false, VoidCallback? onCallPressed, bool showOptions = false, List<PopupMenuEntry>? optionMenuItems, void onOptionSelected(dynamic value)?, List<Widget>? actions, Widget? bottomNavigationBar, Widget? floatingActionButton, Color? appBarColor, double? appBarHeight, bool isRefresh = false, Future<void> onRefresh()?, bool isLoading = false, Widget? loadingWidget, bool isError = false, String? errorMessage, VoidCallback? onRetry, bool useSafeArea = true, bool isChildScrollable = true, Color? statusBarColor, Brightness? statusBarBrightness})
Creates an AppBackground with the default background from AppConfig.backgroundColor.
const
AppBackground.color({Key? key, required Color color, required Widget child, String title = '', Widget? titleWidget, bool showBackButton = false, VoidCallback? onBackPressed, Widget? leading, bool showNotification = false, VoidCallback? onNotificationPressed, int? notificationBadgeCount, bool showSearch = false, VoidCallback? onSearchPressed, bool showCall = false, VoidCallback? onCallPressed, bool showOptions = false, List<PopupMenuEntry>? optionMenuItems, void onOptionSelected(dynamic value)?, List<Widget>? actions, Widget? bottomNavigationBar, Widget? floatingActionButton, Color? appBarColor, double? appBarHeight, bool isRefresh = false, Future<void> onRefresh()?, bool isLoading = false, Widget? loadingWidget, bool isError = false, String? errorMessage, VoidCallback? onRetry, bool useSafeArea = true, bool isChildScrollable = true, Color? statusBarColor, Brightness? statusBarBrightness})
Creates an AppBackground with a solid color as the background.
const
AppBackground.image({Key? key, required ImageProvider<Object> image, required Widget child, String title = '', Widget? titleWidget, bool showBackButton = false, VoidCallback? onBackPressed, Widget? leading, bool showNotification = false, VoidCallback? onNotificationPressed, int? notificationBadgeCount, bool showSearch = false, VoidCallback? onSearchPressed, bool showCall = false, VoidCallback? onCallPressed, bool showOptions = false, List<PopupMenuEntry>? optionMenuItems, void onOptionSelected(dynamic value)?, List<Widget>? actions, Widget? bottomNavigationBar, Widget? floatingActionButton, Color? appBarColor, double? appBarHeight, bool isRefresh = false, Future<void> onRefresh()?, bool isLoading = false, Widget? loadingWidget, bool isError = false, String? errorMessage, VoidCallback? onRetry, bool useSafeArea = true, bool isChildScrollable = true, Color? statusBarColor, Brightness? statusBarBrightness})
Creates an AppBackground with an image displayed behind all content.
const

Properties

actions List<Widget>?
Additional custom action widgets to display in the app bar.
final
appBarColor Color?
Background color of the app bar.
final
appBarHeight double?
Height of the app bar. Defaults to AppConfig.defaultAppBarHeight.
final
backgroundColor Color?
The solid color used when constructed via AppBackground.color.
final
backgroundImage ImageProvider<Object>?
The image provider used when constructed via AppBackground.image.
final
bottomNavigationBar Widget?
Optional bottom navigation bar widget.
final
child Widget
The main content widget to display within the background and app bar wrapper.
final
errorMessage String?
Error message to display in the error state.
final
floatingActionButton Widget?
Optional floating action button widget.
final
hashCode int
The hash code for this object.
no setterinherited
isChildScrollable bool
Whether the child widget should be scrollable.
final
isError bool
Whether to show the error state overlay.
final
isLoading bool
Whether to show the loading indicator overlay.
final
isRefresh bool
Whether to enable pull-to-refresh functionality.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
leading Widget?
Optional leading widget displayed before the title in the app bar.
final
loadingWidget Widget?
Custom widget to display during loading state. Defaults to AppConfig.loadingWidget.
final
notificationBadgeCount int?
Optional badge count displayed on the notification icon.
final
onBackPressed VoidCallback?
Callback triggered when the back button is pressed.
final
onCallPressed VoidCallback?
Callback triggered when the call icon is pressed.
final
onNotificationPressed VoidCallback?
Callback triggered when the notification icon is pressed.
final
onOptionSelected → void Function(dynamic value)?
Callback triggered when an option menu item is selected.
final
onRefresh Future<void> Function()?
Callback triggered when the user pulls to refresh.
final
onRetry VoidCallback?
Callback triggered when the user taps the retry button in error state.
final
onSearchPressed VoidCallback?
Callback triggered when the search icon is pressed.
final
optionMenuItems List<PopupMenuEntry>?
Menu items for the options popup menu.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
showBackButton bool
Whether to show a back button in the app bar.
final
showCall bool
Whether to show a call icon in the app bar.
final
showNotification bool
Whether to show a notification icon in the app bar.
final
showOptions bool
Whether to show an options menu icon in the app bar.
final
showSearch bool
Whether to show a search icon in the app bar.
final
statusBarBrightness Brightness?
Brightness of the status bar icons.
final
statusBarColor Color?
Background color of the status bar.
final
title String
The title text displayed in the app bar.
final
titleWidget Widget?
Optional custom widget to replace the default title text.
final
useSafeArea bool
Whether to apply safe area padding.
final

Methods

build(BuildContext context) Widget
The child widget to display as the main content.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug, int wrapWidth = 65}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited