widget_kit_plugin

Creator: coderz1093

Last updated:

Add to Cart

Description:

widget kit plugin

widget_kit #

A small library for interfacing with the very limited parts of WidgetKit that are accessible through platform channels. API based on flutter_widgetkit. iOS and macOS only.
Introduction #
The only parts of WidgetKit that can be accessed through Flutter are the following methods:



Method
Parameters
Description




reloadTimelines
ofKind
Reloads the timelines for all widgets of a particular kind. The ofKind parameter is an identifier that matches the value you used when creating the widget's configuration.


reloadAllTimelines

Reloads the timelines for all configured widgets belonging to the containing app.



This means that this library is not for creating widget user interfaces. This library facilitates some interaction with WidgetKit timelines and basic means for passing arbitrary data to the underlying platform via UserDefaults and app groups. Retrieving that data and applying it to a Widget UI has to be done on the platform level; this is not possible through Flutter.
UserDefaults is used as data can be shared across the iOS app and the widget extension with the use of app groups. This way, data can be set from the main application (Dart) and retrieved in the widget extension (Swift). Again, presentation logic has to be written using Swift/SwiftUI.
Usage #
UserDefaults #
import 'package:widget_kit_plugin/widget_kit_plugin.dart';

void foo() {
// Save some data to user preferences.
await UserDefaults.setString('key', 'value', 'group.tv.gameflow');

// Check if key is present.
await UserDefaults.contains('key'); // true

// Retrieve (typed) value.
await UserDefaults.getString('key'); // 'value'

// Remove pair.
await UserDefaults.remove('key'); // true
}
copied to clipboard
WidgetKit #
import 'package:widget_kit_plugin/widget_kit_plugin.dart';

void bar() {
// Reload all timelines
await WidgetKit.reloadAllTimelines();

// Reload specific timeline
await WidgetKit.reloadTimelines('foo');
}
copied to clipboard
Creating a Widget Extension #
TODO(arnemolland): document widget extension process
While this section is lacking written docs, check out the example app for a reference implementation.

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files:

Customer Reviews

There are no reviews.