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
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- AppBackground
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? 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? 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
coloras 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? 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
imagedisplayed behind all content.const
Properties
-
actions
→ List<
Widget> ? -
final
- appBarColor → Color?
-
final
- appBarHeight → double?
-
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
-
final
- child → Widget
-
final
- errorMessage → String?
-
final
- floatingActionButton → Widget?
-
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- isChildScrollable → bool
-
final
- isError → bool
-
final
- isLoading → bool
-
final
- isRefresh → bool
-
final
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
- leading → Widget?
-
final
- loadingWidget → Widget?
-
final
- notificationBadgeCount → int?
-
final
- onBackPressed → VoidCallback?
-
final
- onCallPressed → VoidCallback?
-
final
- onNotificationPressed → VoidCallback?
-
final
- onOptionSelected → void Function(dynamic value)?
-
final
-
onRefresh
→ Future<
void> Function()? -
final
- onRetry → VoidCallback?
-
final
- onSearchPressed → VoidCallback?
-
final
-
optionMenuItems
→ List<
PopupMenuEntry> ? -
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- showBackButton → bool
-
final
- showCall → bool
-
final
- showNotification → bool
-
final
- showOptions → bool
-
final
- showSearch → bool
-
final
- statusBarBrightness → Brightness?
-
final
- statusBarColor → Color?
-
final
- title → String
-
final
- titleWidget → Widget?
-
final
- useSafeArea → bool
-
final
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
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