Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit bb21db8

Browse files
[quick_actions] Migrate to null safety (#3421)
1 parent e68b15f commit bb21db8

File tree

5 files changed

+20
-14
lines changed

5 files changed

+20
-14
lines changed

packages/quick_actions/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 0.5.0-nullsafety
2+
3+
* Migrate to null safety.
4+
15
## 0.4.0+12
26

37
* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))

packages/quick_actions/lib/quick_actions.dart

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ class ShortcutItem {
2222
///
2323
/// Only [icon] should be nullable. It will remain `null` if unset.
2424
const ShortcutItem({
25-
@required this.type,
26-
@required this.localizedTitle,
25+
required this.type,
26+
required this.localizedTitle,
2727
this.icon,
2828
});
2929

@@ -35,7 +35,7 @@ class ShortcutItem {
3535

3636
/// Name of native resource (xcassets etc; NOT a Flutter asset) to be
3737
/// displayed as the icon for this item.
38-
final String icon;
38+
final String? icon;
3939
}
4040

4141
/// Quick actions plugin.
@@ -65,15 +65,16 @@ class QuickActions {
6565
assert(call.method == 'launch');
6666
handler(call.arguments);
6767
});
68-
final String action = await channel.invokeMethod<String>('getLaunchAction');
68+
final String? action =
69+
await channel.invokeMethod<String?>('getLaunchAction');
6970
if (action != null) {
7071
handler(action);
7172
}
7273
}
7374

7475
/// Sets the [ShortcutItem]s to become the app's quick actions.
7576
Future<void> setShortcutItems(List<ShortcutItem> items) async {
76-
final List<Map<String, String>> itemsList =
77+
final List<Map<String, String?>> itemsList =
7778
items.map(_serializeItem).toList();
7879
await channel.invokeMethod<void>('setShortcutItems', itemsList);
7980
}
@@ -82,8 +83,8 @@ class QuickActions {
8283
Future<void> clearShortcutItems() =>
8384
channel.invokeMethod<void>('clearShortcutItems');
8485

85-
Map<String, String> _serializeItem(ShortcutItem item) {
86-
return <String, String>{
86+
Map<String, String?> _serializeItem(ShortcutItem item) {
87+
return <String, String?>{
8788
'type': item.type,
8889
'localizedTitle': item.localizedTitle,
8990
'icon': item.icon,

packages/quick_actions/pubspec.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: quick_actions
22
description: Flutter plugin for creating shortcuts on home screen, also known as
33
Quick Actions on iOS and App Shortcuts on Android.
44
homepage: https://github.com/flutter/plugins/tree/master/packages/quick_actions
5-
version: 0.4.0+12
5+
version: 0.5.0-nullsafety
66

77
flutter:
88
plugin:
@@ -16,17 +16,17 @@ flutter:
1616
dependencies:
1717
flutter:
1818
sdk: flutter
19-
meta: ^1.0.5
19+
meta: ^1.3.0-nullsafety
2020

2121
dev_dependencies:
22-
test: ^1.3.0
23-
mockito: ^3.0.0
22+
test: ^1.16.0-nullsafety
23+
mockito: ^5.0.0-nullsafety.0
2424
flutter_test:
2525
sdk: flutter
2626
integration_test:
2727
path: ../integration_test
28-
pedantic: ^1.8.0
28+
pedantic: ^1.10.0-nullsafety
2929

3030
environment:
31-
sdk: ">=2.1.0 <3.0.0"
31+
sdk: ">=2.12.0-0 <3.0.0"
3232
flutter: ">=1.12.13+hotfix.5"

packages/quick_actions/test/quick_actions_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import 'package:quick_actions/quick_actions.dart';
1010
void main() {
1111
TestWidgetsFlutterBinding.ensureInitialized();
1212

13-
QuickActions quickActions;
13+
late QuickActions quickActions;
1414
final List<MethodCall> log = <MethodCall>[];
1515

1616
setUp(() {

script/nnbd_plugins.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ readonly NNBD_PLUGINS_LIST=(
2020
"path_provider"
2121
"package_info"
2222
"plugin_platform_interface"
23+
"quick_actions"
2324
"sensors"
2425
"share"
2526
"shared_preferences"

0 commit comments

Comments
 (0)