import 'package:flutter/material.dart'; import 'package:flutter/services.dart' show SystemNavigator; import '../screens/scores.dart'; class MyAppBar extends StatelessWidget implements PreferredSizeWidget { final AppBar? appBar; const MyAppBar({Key? key, this.appBar}) : super(key: key); @override Size get preferredSize => Size.fromHeight(appBar?.preferredSize.height ?? 0.0); @override Widget build(BuildContext context) { return AppBar( title: Text('Hangman'), automaticallyImplyLeading: false, actions: [ PopupMenuButton<String>( onSelected: (String value) { switch (value) { case 'Quitter': SystemNavigator.pop(); break; case 'Scores': Navigator.pushNamed(context, Scores.id); break; } }, itemBuilder: (BuildContext context) { return {'Scores', 'Quitter'}.map((String choice) { return PopupMenuItem<String>( value: choice, child: Text(choice), ); }).toList(); }, ), ], ); } }