static_shortcuts 0.0.2
static_shortcuts: ^0.0.2 copied to clipboard
Generate and handle static shortcuts for Android and access the intent in one line of dart code.
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();
queryShortcutIntent();
}
Future<void> queryShortcutIntent() async {
String? shortcutIntent = await StaticShortcuts.getShortcutIntentUri();
// Do your routing based on the shortcutIntent here.
setState(() {
_shortcutIntent = shortcutIntent ?? "Started without shortcut.";
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('static_shortcuts example app')),
body: Center(child: Text('Shortcut Intent: $_shortcutIntent\n')),
),
);
}
}