launcher_assist 0.0.3 launcher_assist: ^0.0.3 copied to clipboard
This plugin makes it easy for you to create launcher apps with Flutter. It helps you quickly get details about all the installed apps. It also helps you get the current wallpaper. Of course, it lets y [...]
// 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:flutter/services.dart';
import 'package:launcher_assist/launcher_assist.dart';
import 'dart:convert';
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 a base64 string
LauncherAssist.getWallpaperBase64().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(BASE64.decode(wallpaper),
fit: BoxFit.scaleDown) : new Center()
]
)
),
);
}
}