0

I want to add exit button to my project , i tried using

    import 'dart:io';
    .
    .
    .
    RaisedButton(
    child: Text("exit"),
    onPressed: () {
    exit(0);
    },
    )

and

import 'package:flutter/services.dart';
.
.
.
RaisedButton(
child: Text("exit"),
onPressed: () {
SystemNavigator.pop();
},
)

but in both cases app still running in background on Android platform , is there any other solution ? Thanks in advance

Hasan
  • 328
  • 1
  • 4
  • 15

1 Answers1

0

The function exit(0); will close your app.

I could only test the Android side of things, but there it stays in the recent applications, but with a blacked out screen and it completely restarts once it's opened again.

However closing an app through a button in the app itself is rather unusual, as the operating system is there to handle this job for you. Or have you seen any popular app that has a close button? ;)

leodriesch
  • 5,308
  • 5
  • 30
  • 52
  • sometimes you have to implement a specific design , to complete your work ,I don't say this is a good done but I have to do, Am I wrong ? @01leo – Hasan Nov 30 '18 at 05:31
  • this solution does not kill the app. its just popout the app and does not display to use. User can see opened app in background or opened apps list. Any suggestion to kill the app forcefully ?? – Kamlesh Oct 29 '20 at 07:10
  • This will kill the whole VM process and is most likely that Apple store will suspend your app. – Anil Poudyal Jul 24 '21 at 03:09