handoff 0.2.0
handoff: ^0.2.0 copied to clipboard
A Flutter plugin for Apple's Handoff functionality.
Flutter Handoff #
This plugin makes it easy to use Apple's Handoff feature in your Flutter applications.
Currently, it supports opening links from your application on other iCloud connected devices (Macs, iPads, iPhones).
How to use? #
After installing the plugin, you can just call the setHandoffUrl
where appropriate
(probably after navigation to some page):
import 'package:handoff/handoff.dart';
void someFunction() async {
await Handoff.setHandoffUrl(
"https://example.com/some/path",
title: "Some Title",
);
}
and the system will take care of the rest.
On you connected devices, you will see the link in the Dock
or App Switcher
To hide the handoff icon, you can call Handoff.clearHandoff()
.
Automatic Handoff with Route Navigation #
For even easier use, you can use HandoffPageRoute
which automatically sets the handoff URL when the route is entered and clears it when the route is exited:
import 'package:handoff/handoff.dart';
void navigateToPage() {
Navigator.of(context).push(
HandoffPageRoute<void>(
handoffUrl: "https://example.com/some/path",
handoffTitle: "Some Title", // Optional
builder: (context) => MyPageWidget(),
),
);
}
This eliminates the need to manually call setHandoffUrl()
and clearHandoff()
- the route handles it automatically!
Available methods #
Method | Description |
---|---|
setHandoffUrl(String url, {String? title}) |
Sets a handoff URL using a string URL with an optional title |
setHandoffUri(Uri uri, {String? title}) |
Sets a handoff URL using a Uri object with an optional title |
clearHandoff() |
Clears the current handoff activity |
Available classes #
Class | Description |
---|---|
HandoffPageRoute<T> |
A MaterialPageRoute subclass that automatically manages handoff URLs on route enter/exit |