shortcuts 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

shortcuts #

Launcher Shortcuts are the list of actions that come up when you long press on a supporting applications Icon. This plugin allows you to interact with the Android shortcuts API.

It is meant to be used in conjunction with other plugins that allow you to retrieve the application list.

ShortcutsAPI #

  • static Future
  • static Future getShortcutIcon({String packageName, String shortcutID, double width = 50, double height = 50}) : Returns an Icon for the shortcut with the defined sizes.
  • static void launchShortcut({String packageName, String shortcutID}) : Launches shortcut by ID & packageName
  • REQUIRES INTENT FILTER IN ANDROIDMANIFEST.XML, APP MUST BE DEFAULT HOME APP TO BE ABLE TO QUERY FOR SHORTCUTS *
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
                <category android:name="android.intent.category.HOME" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>

1.0.0 #

Fixed an error with getIcon when there was no Shortcut Icon

0.0.4 #

Fixed publishing, Dart SDK and developer API was missing.

0.0.3 #

Added License

0.0.2 #

Fixed dartdoc

0.0.1 #

Initial Release

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:shortcuts/shortcuts.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  Map shortcuts = Map();
  Map icons = Map();
  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    shortcuts = await ShortcutsAPI.getShortcuts("com.spotify.music");
    for(String shortcut in shortcuts.keys){
      Image i = await ShortcutsAPI.getShortcutIcon(packageName: "com.spotify.music", shortcutID: shortcut);
      icons.putIfAbsent(shortcut, () => i);
    }
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await ShortcutsAPI.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    List<Widget> content = [ Text('Running on: $_platformVersion\n')];
    content.addAll(shortcuts.keys.map((e) => ListTile(leading: icons[e], title: Text(shortcuts[e]),)));
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(children: content,),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  shortcuts: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:shortcuts/shortcuts.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
99
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
80
Overall:
Weighted score of the above. [more]
53
Learn more about scoring.

We analyzed this package on Jul 11, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.15
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform Linux

Because:

  • package:shortcuts/shortcuts.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Web

Because:

  • package:shortcuts/shortcuts.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform Windows

Because:

  • package:shortcuts/shortcuts.dart that declares support for platforms: Android, iOS

Package does not support Flutter platform macOS

Because:

  • package:shortcuts/shortcuts.dart that declares support for platforms: Android, iOS

Package not compatible with SDK dart

Because:

  • shortcuts that is a package requiring null.

Health issues and suggestions

Document public APIs. (-1 points)

7 out of 7 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/shortcuts.dart.

Run flutter format to format lib/shortcuts.dart.

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test