root_placeholder_page.dart 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import 'package:flutter/material.dart';
  2. import 'package:go_router/go_router.dart';
  3. /// Widget for the root/initial pages in the bottom navigation bar.
  4. class RootPlaceholderScreen extends StatelessWidget {
  5. /// Creates a RootScreen
  6. const RootPlaceholderScreen({
  7. required this.label,
  8. required this.detailsPath,
  9. this.secondDetailsPath,
  10. super.key,
  11. });
  12. /// The label
  13. final String label;
  14. /// The path to the detail page
  15. final String detailsPath;
  16. /// The path to another detail page
  17. final String? secondDetailsPath;
  18. @override
  19. Widget build(BuildContext context) {
  20. return Scaffold(
  21. appBar: AppBar(
  22. title: Text('Root of section $label'),
  23. ),
  24. body: Center(
  25. child: Column(
  26. mainAxisSize: MainAxisSize.min,
  27. children: <Widget>[
  28. Text('$label Page', style: Theme.of(context).textTheme.titleLarge),
  29. const Padding(padding: EdgeInsets.all(4)),
  30. TextButton(
  31. onPressed: () {
  32. context.go(detailsPath, extra: '$label-XYZ');
  33. },
  34. child: const Text('View details'),
  35. ),
  36. const Padding(padding: EdgeInsets.all(4)),
  37. if (secondDetailsPath != null)
  38. TextButton(
  39. onPressed: () {
  40. context.go(secondDetailsPath!);
  41. },
  42. child: const Text('View more details'),
  43. ),
  44. ],
  45. ),
  46. ),
  47. );
  48. }
  49. }