[quick_actions] Migrate to null safety (#3421)
diff --git a/packages/quick_actions/CHANGELOG.md b/packages/quick_actions/CHANGELOG.md
index a0c1b1f..774ccac 100644
--- a/packages/quick_actions/CHANGELOG.md
+++ b/packages/quick_actions/CHANGELOG.md
@@ -1,3 +1,7 @@
+## 0.5.0-nullsafety
+
+* Migrate to null safety.
+
## 0.4.0+12
* Fix outdated links across a number of markdown files ([#3276](https://github.com/flutter/plugins/pull/3276))
diff --git a/packages/quick_actions/lib/quick_actions.dart b/packages/quick_actions/lib/quick_actions.dart
index 933162a..8756612 100644
--- a/packages/quick_actions/lib/quick_actions.dart
+++ b/packages/quick_actions/lib/quick_actions.dart
@@ -22,8 +22,8 @@
///
/// Only [icon] should be nullable. It will remain `null` if unset.
const ShortcutItem({
- @required this.type,
- @required this.localizedTitle,
+ required this.type,
+ required this.localizedTitle,
this.icon,
});
@@ -35,7 +35,7 @@
/// Name of native resource (xcassets etc; NOT a Flutter asset) to be
/// displayed as the icon for this item.
- final String icon;
+ final String? icon;
}
/// Quick actions plugin.
@@ -65,7 +65,8 @@
assert(call.method == 'launch');
handler(call.arguments);
});
- final String action = await channel.invokeMethod<String>('getLaunchAction');
+ final String? action =
+ await channel.invokeMethod<String?>('getLaunchAction');
if (action != null) {
handler(action);
}
@@ -73,7 +74,7 @@
/// Sets the [ShortcutItem]s to become the app's quick actions.
Future<void> setShortcutItems(List<ShortcutItem> items) async {
- final List<Map<String, String>> itemsList =
+ final List<Map<String, String?>> itemsList =
items.map(_serializeItem).toList();
await channel.invokeMethod<void>('setShortcutItems', itemsList);
}
@@ -82,8 +83,8 @@
Future<void> clearShortcutItems() =>
channel.invokeMethod<void>('clearShortcutItems');
- Map<String, String> _serializeItem(ShortcutItem item) {
- return <String, String>{
+ Map<String, String?> _serializeItem(ShortcutItem item) {
+ return <String, String?>{
'type': item.type,
'localizedTitle': item.localizedTitle,
'icon': item.icon,
diff --git a/packages/quick_actions/pubspec.yaml b/packages/quick_actions/pubspec.yaml
index e76cd9c..46bc53e 100644
--- a/packages/quick_actions/pubspec.yaml
+++ b/packages/quick_actions/pubspec.yaml
@@ -2,7 +2,7 @@
description: Flutter plugin for creating shortcuts on home screen, also known as
Quick Actions on iOS and App Shortcuts on Android.
homepage: https://github.com/flutter/plugins/tree/master/packages/quick_actions
-version: 0.4.0+12
+version: 0.5.0-nullsafety
flutter:
plugin:
@@ -16,17 +16,17 @@
dependencies:
flutter:
sdk: flutter
- meta: ^1.0.5
+ meta: ^1.3.0-nullsafety
dev_dependencies:
- test: ^1.3.0
- mockito: ^3.0.0
+ test: ^1.16.0-nullsafety
+ mockito: ^5.0.0-nullsafety.0
flutter_test:
sdk: flutter
integration_test:
path: ../integration_test
- pedantic: ^1.8.0
+ pedantic: ^1.10.0-nullsafety
environment:
- sdk: ">=2.1.0 <3.0.0"
+ sdk: ">=2.12.0-0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
diff --git a/packages/quick_actions/test/quick_actions_test.dart b/packages/quick_actions/test/quick_actions_test.dart
index ffb6de1..8066719 100644
--- a/packages/quick_actions/test/quick_actions_test.dart
+++ b/packages/quick_actions/test/quick_actions_test.dart
@@ -10,7 +10,7 @@
void main() {
TestWidgetsFlutterBinding.ensureInitialized();
- QuickActions quickActions;
+ late QuickActions quickActions;
final List<MethodCall> log = <MethodCall>[];
setUp(() {
diff --git a/script/nnbd_plugins.sh b/script/nnbd_plugins.sh
index 0e1d3c4..447e874 100644
--- a/script/nnbd_plugins.sh
+++ b/script/nnbd_plugins.sh
@@ -20,6 +20,7 @@
"path_provider"
"package_info"
"plugin_platform_interface"
+ "quick_actions"
"sensors"
"share"
"shared_preferences"