This is a Flutter plugin that gives you basic access to Android's PackageManager
and WallpaperManager
classes. As such, it is designed to help you build launchers for Android. Currently, it offers the following methods:
getAllApps()
- This method returns a map containing the labels, package names, and icons of all the launchable apps installed on a user's device. The icons are available as byte arrays.
launchApp()
- Takes a package name as its only argument. As its name suggests, it lets you launch apps.
getWallpaper()
- Returns the current wallpaper of the user, as a byte array that you can directly pass to the Image.memory()
method. Note that on devices running Android Oreo or higher, this method will work only if your app has the READ_EXTERNAL_STORAGE
permission.
To use this plugin, add launcher_assist
as a dependency in your pubspec.yaml file.
import 'package:launcher_assist/launcher_assist.dart';
.
.
.
// Get all apps
LauncherAssist.getAllApps().then((apps) {
setState(() {
numberOfInstalledApps = apps.length;
installedApps = apps;
});
});
example/lib/main.dart
// Copyright 2017 Ashraff Hathibelagal.
// Use of this source code is governed by an Apache license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
import 'package:launcher_assist/launcher_assist.dart';
void main() => runApp(new MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
var numberOfInstalledApps;
var installedApps;
var wallpaper;
@override
initState() {
super.initState();
// Get all apps
LauncherAssist.getAllApps().then((apps) {
setState(() {
numberOfInstalledApps = apps.length;
installedApps = apps;
});
});
// Get wallpaper as binary data
LauncherAssist.getWallpaper().then((imageData) {
setState(() {
wallpaper = imageData;
});
});
}
@override
Widget build(BuildContext context) {
return new MaterialApp(
home: new Scaffold(
appBar: new AppBar(
title: new Text('Launcher Assist'),
),
body: new Column(children: <Widget>[
new Text("Found $numberOfInstalledApps apps installed"),
new RaisedButton(
child: new Text("Launch Something"),
onPressed: () {
// Launch the first app available
LauncherAssist.launchApp(installedApps[0]["package"]);
}),
wallpaper != null
? new Image.memory(wallpaper, fit: BoxFit.scaleDown)
: new Center()
])),
);
}
}
Add this to your package's pubspec.yaml file:
dependencies:
launcher_assist: ^1.1.3
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
.
Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:launcher_assist/launcher_assist.dart';
Version | Uploaded | Documentation | Archive |
---|---|---|---|
1.1.3 | Feb 2, 2019 |
|
|
1.1.2 | Feb 1, 2019 |
|
|
1.1.1 | Feb 1, 2019 |
|
|
1.1.0 | Feb 1, 2019 |
|
|
1.0.4 | Mar 24, 2018 |
|
|
1.0.3 | Mar 19, 2018 |
|
|
1.0.2 | Mar 19, 2018 |
|
|
1.0.1 | Mar 19, 2018 |
|
|
1.0.0 | Mar 19, 2018 |
|
|
0.0.5 | Mar 19, 2018 |
|
|
Popularity:
Describes how popular the package is relative to other packages.
[more]
|
68
|
Health:
Code health derived from static analysis.
[more]
|
100
|
Maintenance:
Reflects how tidy and up-to-date the package is.
[more]
|
100
|
Overall:
Weighted score of the above.
[more]
|
84
|
We analyzed this package on Feb 14, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:
Detected platforms: Flutter
References Flutter, and has no conflicting libraries.
Package | Constraint | Resolved | Available |
---|---|---|---|
Direct dependencies | |||
Dart SDK | >=2.0.0 <3.0.0 | ||
flutter | 0.0.0 | ||
Transitive dependencies | |||
collection | 1.14.11 | ||
meta | 1.1.6 | 1.1.7 | |
sky_engine | 0.0.99 | ||
typed_data | 1.1.6 | ||
vector_math | 2.0.8 |