Skip to content

Commit 54a346c

Browse files
committed
chore: bump version
1 parent 90596f3 commit 54a346c

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

app_widget/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.4.0
2+
* breaking changes: `configureWidget` and `updateWidget` accept `layoutId` instead of `layoutName`
3+
* breaking changes: `onConfigureWidget` now accept 3 params (`widgetId`, `layoutId`, `layoutName`)
4+
15
## 0.3.1
26
* fix(android): fix trigger update widget updating the widget multiple time
37

app_widget/README.md

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ and can be manage fully from flutter side keeping app codebase logic in flutter.
1313
| --- | --- |
1414
|![screen_shot](assets/screen_shot.webp) | ![gif](assets/example_app.gif) |
1515

16-
## Caveat
16+
## Note
17+
- Please see the changelogs for breaking changes
18+
- Every minor version update might introduce a breaking changes as this plugin is still considered alpha
19+
20+
## Caveats
1721

1822
Configuring or opening a screen from the widget is slower (unless the app is still active in the background)
1923
compare to native because we need to wait for flutter engine to start. Hence as you can see from the gif there
@@ -23,6 +27,8 @@ So this shouldn't be an issue. Although we can notice significant delay in old p
2327

2428
## Plaform Support
2529

30+
As of current state I have no capacity to support for iOS, but help is welcome.
31+
2632
| Android | iOS |
2733
| :-----: | :-: |
2834
| ✔️ | |
@@ -211,10 +217,14 @@ await appWidgetPlugin.configureWidget(...)
211217
```dart
212218
// this method can be declare as a top level function or inside a widget as a member function
213219
@pragma('vm:entry-point')
214-
void onConfigureWidget(int widgetId) async {
220+
void onConfigureWidget(int widgetId, int layoutId, String layoutName) async {
215221
// handle widget configuration
216222
// eg:
217223
// redirect or use launchUrl and deeplink redirect to configuration page
224+
// store widgetId, layoutId and layoutName in sharedPref
225+
// use layoutName to build proper payload
226+
227+
// layoutName: tech.noxasch.app_widget_example:layout/example_layout
218228
}
219229
220230
// onConfigureWidget callback are optional
@@ -229,7 +239,7 @@ final appWidgetPlugin = AppWidgetPlugin(
229239
await appWidgetPlugin.configureWidget(
230240
// change to androidPackageName - we needed as param since there is no standard on how long the domain name can be
231241
widgetId: _widgetId!,
232-
widgetLayout: 'example_layout',
242+
layoutId: _layoutId!,
233243
textViews: {
234244
'widget_title': 'MY WIDGET',
235245
'widget_message': 'This is my widget message'
@@ -264,7 +274,9 @@ final appWidgetPlugin = AppWidgetPlugin(
264274
```
265275

266276
#### updateWidget
267-
Make sure you store the `widgetId` during widget configuration.
277+
Make sure you store the `widgetId` and `layoutId` during widget configuration.
278+
279+
Tips: Store `layoutName` to easily manage payload textViews for multiple layout
268280

269281
Most of the time you'll want to update widget via workmanager. See [below](#handling-widget-update-using-in-flutter-workmanger)
270282
how to use the plugin in workmanager.
@@ -325,9 +337,10 @@ inside the callback.
325337
```dart
326338
// Using workmanager chained OneOffTask
327339
@pragma('vm:entry-point')
328-
void onConfigureWidget(int widgetId) async {
340+
void onConfigureWidget(int widgetId, int layoutId) async {
329341
final sharedPrefs = await SharedPreferences.getInstance();
330342
await sharedPrefs.setInt('widget_id', widgetId);
343+
await sharedPrefs.setInt('layout_id', layoutId);
331344
// register task druing configure event in onConfigure callback
332345
await Workmanager().registerOneOffTask(
333346
'UpdateMyWidget',
@@ -353,6 +366,7 @@ void onConfigureWidget(int widgetId) async {
353366
void onConfigureWidget(int widgetId) async {
354367
final sharedPrefs = await SharedPreferences.getInstance();
355368
await sharedPrefs.setInt('widget_id', widgetId);
369+
await sharedPrefs.setInt('layout_id', layoutId);
356370
// register task druing configure event in onConfigure callback
357371
await Workmanager().registerPeriodicTask(
358372
'$kUpdateWidgetTask-$widgetId',
@@ -367,6 +381,7 @@ void onConfigureWidget(int widgetId) async {
367381
initialDelay: const Duration(minutes: kWidgetUpdateIntervalInMinutes),
368382
inputData: {
369383
'widgetId': widgetId,
384+
'layoutId': layoutId,
370385
'payload': payload,
371386
},
372387
);
@@ -404,11 +419,12 @@ Future<void> updateWidgetWorker() async {
404419
final repo = db.todosRepository;
405420
406421
final widgetId = sharedPrefs.getInt('widget_id');
422+
final layoutId = sharedPrefs.getInt('layout_id');
407423
408424
if (widgetId != null) {
409425
await appWidgetPlugin.updateWidget(
410-
widgetId: _widgetId!,
411-
widgetLayout: 'example_layout',
426+
widgetId: widgetId!,
427+
layoutId: layoutId,
412428
textViews: {
413429
'widget_title': 'MY WIDGET',
414430
'widget_message': 'This is my widget message'
@@ -503,14 +519,14 @@ void main() {
503519
...
504520
), isTrue);
505521
506-
// testing if your method that call configureWidget sending the expected argumetns
522+
// testing if your method that call configureWidget sending the expected arguments - interface level only
507523
expect(log, <Matcher>[
508524
isMethodCall(
509525
'configureWidget',
510526
arguments: <String, Object>{
511527
'androidPackageName': 'appname', // androidPackageName is included behind the scene
512528
'widgetId': 1,
513-
'widgetLayout': 'layoutname',
529+
'layoutId': 1,
514530
'textViews': {},
515531
'payload': '{"itemId": 1, "stringUid": "uid"}'
516532
},

app_widget/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: app_widget
22
description: Flutter plugin to manage app widget / home screen widget from within flutter app.
3-
version: 0.3.1
3+
version: 0.4.0
44
homepage: https://noxasch.tech/
55
repository: https://github.com/noxasch/flutter_app_widget/tree/master/app_widget
66
issue_tracker: https://github.com/noxasch/flutter_app_widget/issues

0 commit comments

Comments
 (0)