Giter VIP home page Giter VIP logo

flutter_package_manager's Introduction

Package Manager for Android

This plugin offers the ability of android's PackageManager. You can retrieve the app name, app launcher icon through this package with its package name. The package should be installed on a device.

This plugin supports android only and it is based on androidx.

How to use

See the ./example and ./lib folders for the details.

Modify minSdkVersion of the android gradle

In the android/app folder open the build.gradle file and edit minSdkVersion to greater than or equal to 22.

Get package information from the package name

import 'package:flutter_package_manager/flutter_package_manager.dart';

/// ... other codes

Future<PackageInfo> getPackageInfo() async {
  final PackageInfo info =
    await FlutterPackageManager.getPackageInfo('com.facebook.katana');
  return info;
}

PackageInfo class contains packageName, appName and appIconByteArray. appIconByteArray is an array of base64 byte image of app icon. You can get flutter's Image widget icon by appIcon getter. If the app is not installed, than null is returned.

Get package names of the all applications installed on the device

import 'package:flutter_package_manager/flutter_package_manager.dart';

/// ... other codes

Future<List> getInstalledPackages() async {
  // All apps including system apps
  List packages = await FlutterPackageManager.getInstalledPackages();

  // Apps installed by user
  List userInstalledPackages = await FlutterPackageManager.getUserInstalledPackages();
  return packages;
}

flutter_package_manager's People

Contributors

wurikiji avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

flutter_package_manager's Issues

some problem about null safety?

When I use this plugin, I got some problems.
e: .pub-cache\hosted\pub.flutter-io.cn\flutter_package_manager-0.2.0\android\src\main\kotlin\dev\wurikiji\flutter_package_manager\FlutterPackageManagerPlugin.kt: (85, 76): Type mismatch: inferred type is ApplicationInfo? but ApplicationInfo was expected
e: .pub-cache\hosted\pub.flutter-io.cn\flutter_package_manager-0.2.0\android\src\main\kotlin\dev\wurikiji\flutter_package_manager\FlutterPackageManagerPlugin.kt: (86, 76): Type mismatch: inferred type is String? but String was expected
e: .pub-cache\hosted\pub.flutter-io.cn\flutter_package_manager-0.2.0\android\src\main\kotlin\dev\wurikiji\flutter_package_manager\FlutterPackageManagerPlugin.kt: (86, 101): Type mismatch: inferred type is Drawable? but Drawable was expected

FAILURE: Build failed with an exception.

  • What went wrong:
    Execution failed for task ':flutter_package_manager:compileDebugKotlin'.

Compilation error. See log for more details

image
I already change minsdk version to 22.
image
Flutter version 2.0.2 , Dart version 2.12.1.
environment in pubspec.yaml.
image

But I downloaded your code and ran the example, it is no problem.
please help me.

Getting Kotlin Errors

I get the following error after trying to build. Version min sdk version is 22.

Launching lib/main.dart on sdk gphone x86 64 arm64 in debug mode...
lib/main.dart:1
e: /Users/khadim/.pub-cache/hosted/pub.dartlang.org/flutter_package_manager-0.2.0/android/src/main/kotlin/dev/wurikiji/flutter_package_manager/FlutterPackageManagerPlugin.kt: (85, 76): Type mismatch: inferred type is ApplicationInfo? but ApplicationInfo was expected
e: /Users/khadim/.pub-cache/hosted/pub.dartlang.org/flutter_package_manager-0.2.0/android/src/main/kotlin/dev/wurikiji/flutter_package_manager/FlutterPackageManagerPlugin.kt: (86, 76): Type mismatch: inferred type is String? but String was expected
e: /Users/khadim/.pub-cache/hosted/pub.dartlang.org/flutter_package_manager-0.2.0/android/src/main/kotlin/dev/wurikiji/flutter_package_manager/FlutterPackageManagerPlugin.kt: (86, 101): Type mismatch: inferred type is Drawable? but Drawable was expected

FAILURE: Build failed with an exception.


* What went wrong:
Execution failed for task ':flutter_package_manager:compileDebugKotlin'.
> Compilation error. See log for more details

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

Issue in release mode build

Hi, I am getting below error, when I tried to build my app in release mode. Could you please have a look?

Could not create service of type ResourceSnapshotterCacheService using GradleUserHomeScopeServices.createResourceSnapshotterCacheService().

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 2s

The plugin flutter_package_manager could not be built due to the issue above.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.