buildPage abstract method
Builds the main content of the page.
This method must be implemented by all pages to define their UI structure. It's called by the base delegate's build method and wrapped with necessary providers and listeners.
Parameters:
context: The build context for this widget
Example usage with BLoC:
@override
Widget buildPage(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My Page')),
body: BlocBuilder<MyBloc, MyState>(
builder: (context, state) {
return Column(
children: [
Text('Counter: ${state.count}'),
ElevatedButton(
onPressed: () => bloc.add(CounterEvent.increment()),
child: Text('Increment'),
),
],
);
},
),
);
}
Example usage with Cubit:
@override
Widget buildPage(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('My Page')),
body: BlocBuilder<MyCubit, MyState>(
builder: (context, state) {
return Column(
children: [
Text('Counter: ${state.count}'),
ElevatedButton(
onPressed: () => bloc.increment(),
child: Text('Increment'),
),
],
);
},
),
);
}
Best Practices:
- Wrap with buildLoadingOverlay if loading states are needed
- Use BlocBuilder or BlocConsumer for reactive UI updates
- Access bloc instance via the
blocproperty - Keep the UI logic separate from business logic
Implementation
Widget buildPage(BuildContext context);