Is there any way I can uninstall an app from my device using Flutter?

Viewed 415

I am using device_apps to list the available apps on my device. I want to uninstall an app by tapping on the Icon button, is there any way I can do the same?enter image description here

1 Answers

Answer inspired from this question and by @Vicky Salunkhe

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);
  });

add a package in your pubspec.yaml file

intent: ^1.3.4

permission in manifest

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

Read more answers here and can also refer here

Related