Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to uninstall an app in flutter programatically?

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

like image 394
Amon Chowdhury Avatar asked Mar 14 '19 13:03

Amon Chowdhury


1 Answers

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.

like image 190
Vicky Salunkhe Avatar answered Oct 25 '22 05:10

Vicky Salunkhe