A flutter plugin provides the best way to exit the app doesn't call exit(0)
in dart code.
add plugin to your pubspec.yaml
flutter_exit_app: release
- import plugin
import 'package:flutter_exit_app/flutter_exit_app.dart';
- call exit app static method
// call this to exit app
FlutterExitApp.exitApp();
for IOS if you need to force exit app set iosForceExit
to true
// force exit in ios
FlutterExitApp.exitApp(iosForceExit: true);