123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- import 'package:flutter/material.dart';
- import 'package:go_router/go_router.dart';
- /// Widget for the root/initial pages in the bottom navigation bar.
- class RootPlaceholderScreen extends StatelessWidget {
- /// Creates a RootScreen
- const RootPlaceholderScreen({
- required this.label,
- required this.detailsPath,
- this.secondDetailsPath,
- super.key,
- });
- /// The label
- final String label;
- /// The path to the detail page
- final String detailsPath;
- /// The path to another detail page
- final String? secondDetailsPath;
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Root of section $label'),
- ),
- body: Center(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text('$label Page', style: Theme.of(context).textTheme.titleLarge),
- const Padding(padding: EdgeInsets.all(4)),
- TextButton(
- onPressed: () {
- context.go(detailsPath, extra: '$label-XYZ');
- },
- child: const Text('View details'),
- ),
- const Padding(padding: EdgeInsets.all(4)),
- if (secondDetailsPath != null)
- TextButton(
- onPressed: () {
- context.go(secondDetailsPath!);
- },
- child: const Text('View more details'),
- ),
- ],
- ),
- ),
- );
- }
- }
|