static_shortcuts 0.0.1 copy "static_shortcuts: ^0.0.1" to clipboard
static_shortcuts: ^0.0.1 copied to clipboard

PlatformAndroid

Generate and handle static shortcuts for Android.

example/lib/main.dart

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

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

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

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _shortcutIntent = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  Future<void> initPlatformState() async {
    String shortcutIntent;
    try {
      shortcutIntent = await StaticShortcuts.getShortcutIntentUri() ?? 'No shortcut used / No data retrieved';
    } on PlatformException {
      shortcutIntent = 'Failed to get shortcut intent.';
    }

    // 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(() {
      _shortcutIntent = shortcutIntent;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text('Shortcut Intent: $_shortcutIntent\n'),
        ),
      ),
    );
  }
}
1
likes
130
points
7
downloads

Publisher

unverified uploader

Weekly Downloads

Generate and handle static shortcuts for Android.

Homepage

Documentation

API reference

License

BSD-2-Clause (license)

Dependencies

flutter, image, path, path_provider, plugin_platform_interface, xml, yaml

More

Packages that depend on static_shortcuts

Packages that implement static_shortcuts