Split AppBar Menu button into its own widget

Saves us the need to the GlobalKey as well.
This commit is contained in:
Vishesh Handa
2019-12-03 22:35:23 +01:00
parent 04fa042f37
commit f86a878a9c
2 changed files with 27 additions and 16 deletions

View File

@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
import 'package:badges/badges.dart';
import 'package:gitjournal/state_container.dart';
class GJAppBarMenuButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
final container = StateContainer.of(context);
final appState = container.appState;
bool shouldShowBadge =
!appState.remoteGitRepoConfigured && appState.hasJournalEntries;
var appBarMenuButton = BadgeIconButton(
key: const ValueKey("DrawerButton"),
icon: const Icon(Icons.menu),
itemCount: shouldShowBadge ? 1 : 0,
onPressed: () {
Scaffold.of(context).openDrawer();
},
);
return appBarMenuButton;
}
}