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, MyBloc bloc) {
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
- StatefulWidget
- BasePageStatelessDelegate<
B> - BaseBlocPage
- Mixed-in types
Constructors
- BaseBlocPage({Key? key})
-
const
Properties
Methods
-
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.
inherited
-
buildPage(
BuildContext context, B stateManager) → 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(
) → StatefulElement -
Creates a StatefulElement to manage this widget's location in the tree.
inherited
-
createState(
) → State< BasePageStatelessDelegate< B> > -
Creates the mutable state for this widget at a given 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