flutter how to programmatically exit the app ?

Need to automatically exit in Flutter App? Underneath worked consummately with me in both Android and iOS, I utilized exit(0) from dart:io

import 'dart:io';
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text(widget.title),
      body: new ... (...),
          floatingActionButton: new FloatingActionButton(
            onPressed: ()=> exit(0),
            tooltip: 'Close app',
            child: new Icon(Icons.close),

Thanks for reading this article ❤
If I got something wrong, Let me know in the comments. I would love to improve.
Clap 👏 If this article helps you.

Leave a Comment