11// ignore_for_file: library_private_types_in_public_api
22
33import 'package:flutter/material.dart' ;
4+ import 'package:flutter/services.dart' ;
45import 'package:sizer/sizer.dart' ;
56import 'package:taskwarrior/config/app_settings.dart' ;
67import 'package:taskwarrior/model/storage/storage_widget.dart' ;
@@ -122,6 +123,13 @@ class _NavDrawerState extends State<NavDrawer> {
122123 );
123124 },
124125 ),
126+ buildMenuItem (
127+ icon: Icons .exit_to_app,
128+ text: 'Exit' ,
129+ onTap: () {
130+ _showExitConfirmationDialog (context);
131+ },
132+ ),
125133 ],
126134 ),
127135 ),
@@ -136,7 +144,7 @@ class _NavDrawerState extends State<NavDrawer> {
136144 onTap: onTap,
137145 child: Container (
138146 color: AppSettings .isDarkMode ? Colors .black : Colors .white,
139- padding: const EdgeInsets .symmetric (vertical: 12 , horizontal: 10 ),
147+ padding: const EdgeInsets .symmetric (vertical: 18 , horizontal: 10 ),
140148 child: Row (
141149 children: [
142150 Icon (
@@ -157,3 +165,31 @@ class _NavDrawerState extends State<NavDrawer> {
157165 );
158166 }
159167}
168+
169+ Future <void > _showExitConfirmationDialog (BuildContext context) async {
170+ return showDialog <void >(
171+ context: context,
172+ barrierDismissible: false , // Prevents closing the dialog by tapping outside
173+ builder: (BuildContext context) {
174+ return AlertDialog (
175+ title: const Text ('Exit App' ),
176+ content: const Text ('Are you sure you want to exit the app?' ),
177+ actions: < Widget > [
178+ TextButton (
179+ child: const Text ('Cancel' ),
180+ onPressed: () {
181+ Navigator .of (context).pop (); // Close the dialog
182+ },
183+ ),
184+ TextButton (
185+ child: const Text ('Exit' ),
186+ onPressed: () {
187+ Navigator .of (context).pop (); // Close the dialog
188+ SystemNavigator .pop (); // Exit the app
189+ },
190+ ),
191+ ],
192+ );
193+ },
194+ );
195+ }
0 commit comments