59 lines
1.9 KiB
Dart
59 lines
1.9 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_breadcrumb/flutter_breadcrumb.dart';
|
|
import 'package:provider/provider.dart';
|
|
|
|
import 'breadcrumb_controller.dart';
|
|
|
|
class BreadCrumbPage extends StatefulWidget {
|
|
const BreadCrumbPage(
|
|
{Key? key, required this.mainPage, required this.rootName})
|
|
: super(key: key);
|
|
|
|
final Widget mainPage;
|
|
final String rootName;
|
|
|
|
@override
|
|
State<BreadCrumbPage> createState() => _BreadCrumbPageState();
|
|
}
|
|
|
|
class _BreadCrumbPageState extends State<BreadCrumbPage> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return ChangeNotifierProvider<BreadCrumbController>(
|
|
create: (BuildContext context) =>
|
|
BreadCrumbController(widget.mainPage, widget.rootName),
|
|
child: Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Padding(
|
|
padding: const EdgeInsets.only(left: 12, top: 8, bottom: 8),
|
|
child: Consumer<BreadCrumbController>(
|
|
builder: (_, controller, __) => BreadCrumb(
|
|
items: controller
|
|
.getNames()
|
|
.map((e) => BreadCrumbItem(
|
|
padding: const EdgeInsets.all(2),
|
|
content: Text(e,
|
|
style: Theme.of(context).textTheme.labelMedium),
|
|
onTap: () {
|
|
controller.switchPage(e);
|
|
},
|
|
))
|
|
.toList(growable: false),
|
|
divider: Icon(
|
|
Icons.chevron_right,
|
|
color: Theme.of(context).textTheme.labelMedium?.color,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
Divider(color: Colors.white.withOpacity(0.3), height: 1),
|
|
Consumer<BreadCrumbController>(
|
|
builder: (_, value, __) => value.getCurrentPage(),
|
|
)
|
|
],
|
|
),
|
|
);
|
|
}
|
|
}
|