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 createState() => _BreadCrumbPageState(); } class _BreadCrumbPageState extends State { @override Widget build(BuildContext context) { return ChangeNotifierProvider( 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( 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( builder: (_, value, __) => value.getCurrentPage(), ) ], ), ); } }