Skip to content

Commit 4f5ddd2

Browse files
authored
Merge pull request #14 from noxasch/13-creating-multiple-widget-override-existing-widget-click-event-data
13 creating multiple widget override existing widget click event data
2 parents 7886769 + cbae1da commit 4f5ddd2

File tree

8 files changed

+34
-19
lines changed

8 files changed

+34
-19
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.2.1
2+
3+
* fix(android): onClickWidget callback should be independent on each widget
4+
15
## 0.2.0
26

37
* rename interface into more generic

app_widget/example/lib/main.dart

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import 'dart:convert';
2+
import 'dart:math';
3+
14
import 'package:flutter/material.dart';
25

36
import 'package:app_widget/app_widget.dart';
@@ -124,12 +127,14 @@ class UpdateWidgetButton extends StatelessWidget {
124127

125128
// send configure
126129
await _appWidgetPlugin.updateWidget(
127-
widgetId: widgetId,
128-
widgetLayout: 'example_layout',
129-
textViews: {
130-
'widget_title': 'App Widget',
131-
'widget_message': 'Updated in flutter'
132-
});
130+
widgetId: widgetId,
131+
widgetLayout: 'example_layout',
132+
textViews: {
133+
'widget_title': 'App Widget',
134+
'widget_message': 'Updated in flutter'
135+
},
136+
payload: jsonEncode({'number': Random.secure().nextInt(10)}),
137+
);
133138
}
134139
},
135140
child: const Text('Update Widget'),
@@ -254,12 +259,14 @@ class ConfigureButton extends StatelessWidget {
254259

255260
// send configure
256261
await _appWidgetPlugin.configureWidget(
257-
widgetId: _widgetId!,
258-
widgetLayout: 'example_layout',
259-
textViews: {
260-
'widget_title': 'App Widget',
261-
'widget_message': 'Configured in flutter'
262-
});
262+
widgetId: _widgetId!,
263+
widgetLayout: 'example_layout',
264+
textViews: {
265+
'widget_title': 'App Widget',
266+
'widget_message': 'Configured in flutter'
267+
},
268+
payload: jsonEncode({'number': Random().nextInt(10)}),
269+
);
263270
messenger.showSnackBar(
264271
const SnackBar(content: Text('Widget has been configured!')));
265272
} else {

app_widget/example/pubspec.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ packages:
77
path: ".."
88
relative: true
99
source: path
10-
version: "0.2.0"
10+
version: "0.2.1"
1111
app_widget_android:
1212
dependency: transitive
1313
description:
1414
name: app_widget_android
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "0.2.0"
17+
version: "0.2.1"
1818
app_widget_platform_interface:
1919
dependency: transitive
2020
description:

app_widget/pubspec.yaml

Lines changed: 2 additions & 2 deletions
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.2.0
3+
version: 0.2.1
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
@@ -14,7 +14,7 @@ dependencies:
1414
sdk: flutter
1515
plugin_platform_interface: ^2.0.2
1616
app_widget_platform_interface: ^0.2.0
17-
app_widget_android: ^0.2.0
17+
app_widget_android: ^0.2.1
1818
# app_widget_platform_interface: # local dev
1919
# path: ../app_widget_platform_interface
2020
# app_widget_android: # local dev

app_widget_android/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.2.1
2+
3+
* fix(android): onClickWidget callback should be independent on each widget
4+
15
## 0.2.0
26

37
* breaking changes: `androidAppName` renamed to `androidPackageName`

app_widget_android/android/src/main/kotlin/tech/noxasch/app_widget/AppWidgetMethodCallHandler.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ class AppWidgetMethodCallHandler(private val context: Context, )
229229
pendingIntentFlag = pendingIntentFlag or PendingIntent.FLAG_IMMUTABLE
230230
}
231231

232-
return PendingIntent.getActivity(context, 0, clickIntent, pendingIntentFlag)
232+
return PendingIntent.getActivity(context, widgetId, clickIntent, pendingIntentFlag)
233233
}
234234

235235
/// force reload the widget and this will trigger onUpdate in broadcast receiver

app_widget_android/example/pubspec.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ packages:
77
path: ".."
88
relative: true
99
source: path
10-
version: "0.2.0"
10+
version: "0.2.1"
1111
app_widget_platform_interface:
1212
dependency: transitive
1313
description:

app_widget_android/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: app_widget_android
22
description: Android implementation for app_widget plugin
3-
version: 0.2.0
3+
version: 0.2.1
44
homepage: https://noxasch.tech/
55
repository: https://github.com/noxasch/flutter_app_widget/tree/master/app_widget_android
66
issue_tracker: https://github.com/noxasch/flutter_app_widget/issues

0 commit comments

Comments
 (0)