buildPage abstract method

Widget buildPage(
  1. BuildContext context
)

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:

Implementation

Widget buildPage(BuildContext context);