123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- import 'package:flutter/material.dart';
- import 'package:go_router/go_router.dart';
- // TODO(yijing): delete this after implementing the real screen inside bottom navigation bar.
- /// For demonstration purposes
- class DetailsPlaceholderScreen extends StatefulWidget {
- /// Constructs a [DetailsScreen].
- const DetailsPlaceholderScreen({
- required this.label,
- this.param,
- this.extra,
- this.withScaffold = true,
- super.key,
- });
- /// The label to display in the center of the screen.
- final String label;
- /// Optional param
- final String? param;
- /// Optional extra object
- final Object? extra;
- /// Wrap in scaffold
- final bool withScaffold;
- @override
- State<StatefulWidget> createState() => DetailsPlaceholderScreenState();
- }
- /// The state for DetailsScreen
- class DetailsPlaceholderScreenState extends State<DetailsPlaceholderScreen> {
- int _counter = 0;
- @override
- Widget build(BuildContext context) {
- if (widget.withScaffold) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Details Screen - ${widget.label}'),
- ),
- body: _build(context),
- );
- } else {
- return Container(
- color: Theme.of(context).scaffoldBackgroundColor,
- child: _build(context),
- );
- }
- }
- Widget _build(BuildContext context) {
- return Center(
- child: Column(
- mainAxisSize: MainAxisSize.min,
- children: <Widget>[
- Text(
- 'Details for ${widget.label} - Counter: $_counter',
- style: Theme.of(context).textTheme.titleLarge,
- ),
- const Padding(padding: EdgeInsets.all(4)),
- TextButton(
- onPressed: () {
- setState(() {
- _counter++;
- });
- },
- child: const Text('Increment counter'),
- ),
- const Padding(padding: EdgeInsets.all(8)),
- if (widget.param != null)
- Text(
- 'Parameter: ${widget.param!}',
- style: Theme.of(context).textTheme.titleMedium,
- ),
- const Padding(padding: EdgeInsets.all(8)),
- if (widget.extra != null)
- Text(
- 'Extra: ${widget.extra!}',
- style: Theme.of(context).textTheme.titleMedium,
- ),
- if (!widget.withScaffold) ...<Widget>[
- const Padding(padding: EdgeInsets.all(16)),
- TextButton(
- onPressed: () {
- GoRouter.of(context).pop();
- },
- child: const Text(
- '< Back',
- style: TextStyle(fontWeight: FontWeight.bold, fontSize: 18),
- ),
- ),
- ]
- ],
- ),
- );
- }
- }
|