Skip to content

Commit

Permalink
fix navBarTitle not appearing on initial startup
Browse files Browse the repository at this point in the history
  • Loading branch information
dreautall committed Oct 3, 2023
1 parent 9b7200b commit 725d244
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/pages/navigation.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ class NavDestination {
}

class NavPageElements with ChangeNotifier {
NavPageElements(this.defaultTitle);
final Widget defaultTitle;

List<Widget>? _appBarActions;
List<Widget>? get appBarActions => _appBarActions;
set appBarActions(List<Widget>? value) {
Expand Down Expand Up @@ -63,8 +66,8 @@ class NavPageElements with ChangeNotifier {
}

Widget? _appBarTitle;
Widget? get appBarTitle => _appBarTitle;
set appBarTitle(Widget? value) {
Widget get appBarTitle => _appBarTitle ?? defaultTitle;
set appBarTitle(Widget value) {
if (value == appBarTitle) {
log.finer(() => "NavPageElements->setAppBarTitle equal, skipping");
return;
Expand Down Expand Up @@ -130,7 +133,7 @@ class NavPageState extends State<NavPage> with TickerProviderStateMixin {
log.finest(() => "nav build(page: $screenIndex)");

return ChangeNotifierProvider<NavPageElements>(
create: (_) => NavPageElements(),
create: (_) => NavPageElements(Text(navDestinations[0].label)),
builder: (BuildContext context, _) => Scaffold(
appBar: AppBar(
title: context.select((NavPageElements n) => n.appBarTitle),
Expand Down

0 comments on commit 725d244

Please sign in to comment.