How to uninstall an app in flutter programatically?

3,758

Add a permission in manifest file

<uses-permission android:name="android.permission.REQUEST_DELETE_PACKAGES" />

add a package in your pubspec.yaml file

intent: ^1.3.4

Use the below shown code and

To uninstall an app pass the package name to it. $packageName is a variable ex, some.app.id

android_intent.Intent()
  ..setAction(android_action.Action.ACTION_DELETE)
  ..setData(Uri.parse("package:$packageName"))
  ..startActivityForResult().then((data) {
    print(data);
  }, onError: (e) {
    print(e);
  });

using this a system generated popup will occur asking to uninstall the app.

So using this you can uninstall apps on your android device using flutter programmatically.

Share:
3,758
Amon Chowdhury
Author by

Amon Chowdhury

Updated on December 10, 2022

Comments

  • Amon Chowdhury
    Amon Chowdhury over 1 year

    I am building a launcher app in flutter. But I couldn't add the uninstall feature. Please help me.