9

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

Amon Chowdhury
  • 101
  • 1
  • 5

1 Answers1

6

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.

Vicky Salunkhe
  • 9,869
  • 6
  • 42
  • 59
  • 2
    It's for android only, haven't tested for iOS – Vicky Salunkhe Jun 06 '20 at 10:39
  • 1
    Don't bother. iOS doesn't allow that. – Nishanth Sreedhara Jul 02 '20 at 15:23
  • 1
    This package crashes my app after two attempts of uninstall, if you also faced the issue then you can search for uninstall apps in pub.dev and download the package that is updated recently to solve this error, this is intent specific issue. Also the package provided by flutter team named as android_intent doesn't support deletion of package currently. – Prateek Jan 24 '21 at 11:03