BaseBlocPage<B extends MainBloc<MainBlocEvent, MainBlocState> > class
abstract
A base class for all stateless widget pages in the application that use a Bloc.
This class extends BasePageStatelessDelegate and provides a foundation for creating stateless widget pages that are associated with a specific Bloc.
Type Parameters:
B: The type of Bloc this page will use. Must extend MainBloc.
Features:
- Built-in loading state management via CommonBloc
- Automatic dependency injection using GetIt
- Navigation support via AppNavigator
- Built-in loading overlay with timeout
- Automatic lifecycle management
The class manages:
- Loading indicator display and hiding
- Common bloc integration
- Navigation setup
- Dependency injection
Usage example:
class MyHomePage extends BaseBlocPage<MyBloc> {
const MyHomePage({super.key});
@override
Widget buildPage(BuildContext context) {
return buildLoadingOverlay(
child: Scaffold(
appBar: AppBar(title: const Text('My Page')),
body: BlocBuilder<MyBloc, MyState>(
builder: (context, state) {
return Text('${state.someData}');
},
),
floatingActionButton: FloatingActionButton(
onPressed: () => bloc.add(const MyEvent()),
child: const Icon(Icons.add),
),
),
);
}
}
This approach provides a clean and consistent way to create stateless widget pages with bloc integration, with all the necessary functionality inherited from the base class.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- BasePageStatelessDelegate<
B> - BaseBlocPage
- Mixed-in types
Constructors
- BaseBlocPage({Key? key})
Properties
- bloc → B
-
Access the stateManager as a Bloc with the correct type.
no setter
- commonBloc → CommonBloc
-
The common bloc instance for managing loading states.
no setterinherited
- di → GetIt
-
no setterinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- stateManager → B
-
The state manager instance for this page (could be a Bloc or Cubit), automatically initialized with dependencies.
latefinalinherited
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
inherited
-
buildLoadingOverlay(
{required Widget child, String? loadingKey = LoadingKey.global, Widget? loadingWidget}) → Widget -
override
-
buildLoadingOverlayWidget(
{required Widget child, String? loadingKey = LoadingKey.global, Widget? loadingWidget, Duration timeout = const Duration(seconds: 30)}) → Widget -
Builds the loading overlay widget using BlocBuilder.
inherited
-
buildPage(
BuildContext context) → Widget -
Builds the main content of the page.
inherited
-
buildPageListeners(
{required Widget child}) → Widget -
Builds any additional bloc listeners.
override
-
buildPageLoading(
) → Widget -
Builds the loading indicator widget.
inherited
-
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
-
hideLoading(
{String? key = LoadingKey.global}) → void -
Hides the loading overlay for a specific key.
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