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

[share] Migrate to null-safety #3311

Merged
merged 3 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions packages/share/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 2.0.0-nullsafety

* Migrate to null safety.

## 0.6.5+5

* Update Flutter SDK constraint.
Expand Down
12 changes: 6 additions & 6 deletions packages/share/lib/share.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ class Share {
/// from [MethodChannel].
static Future<void> share(
String text, {
String subject,
Rect sharePositionOrigin,
String? subject,
Rect? sharePositionOrigin,
}) {
assert(text != null);
assert(text.isNotEmpty);
Expand Down Expand Up @@ -67,10 +67,10 @@ class Share {
/// from [MethodChannel].
static Future<void> shareFiles(
List<String> paths, {
List<String> mimeTypes,
String subject,
String text,
Rect sharePositionOrigin,
List<String>? mimeTypes,
String? subject,
String? text,
Rect? sharePositionOrigin,
}) {
assert(paths != null);
assert(paths.isNotEmpty);
Expand Down
17 changes: 7 additions & 10 deletions packages/share/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@ name: share
description: Flutter plugin for sharing content via the platform share UI, using
the ACTION_SEND intent on Android and UIActivityViewController on iOS.
homepage: https://github.com/flutter/plugins/tree/master/packages/share
# 0.6.y+z is compatible with 1.0.0, if you land a breaking change bump
# the version to 2.0.0.
# See more details: https://github.com/flutter/flutter/wiki/Package-migration-to-1.0.0
version: 0.6.5+5
version: 2.0.0-nullsafety

flutter:
plugin:
Expand All @@ -17,20 +14,20 @@ flutter:
pluginClass: FLTSharePlugin

dependencies:
meta: ^1.0.5
mime: ^0.9.7
meta: ^1.3.0-nullsafety.6
mime: ^1.0.0-nullsafety.0
flutter:
sdk: flutter

dev_dependencies:
test: ^1.3.0
mockito: ^3.0.0
test: ^1.16.0-nullsafety.13
mockito: ^4.1.3
flutter_test:
sdk: flutter
integration_test:
path: ../integration_test
pedantic: ^1.8.0
pedantic: ^1.10.0-nullsafety.3

environment:
sdk: ">=2.1.0 <3.0.0"
flutter: ">=1.12.13+hotfix.5"
sdk: ">=2.12.0-0 <3.0.0"
18 changes: 1 addition & 17 deletions packages/share/test/share_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import 'package:flutter/services.dart';
void main() {
TestWidgetsFlutterBinding.ensureInitialized();

MockMethodChannel mockChannel;
late MockMethodChannel mockChannel;

setUp(() {
mockChannel = MockMethodChannel();
Expand All @@ -26,14 +26,6 @@ void main() {
});
});

test('sharing null fails', () {
expect(
() => Share.share(null),
throwsA(const TypeMatcher<AssertionError>()),
);
verifyZeroInteractions(mockChannel);
});

test('sharing empty fails', () {
expect(
() => Share.share(''),
Expand All @@ -58,14 +50,6 @@ void main() {
}));
});

test('sharing null file fails', () {
expect(
() => Share.shareFiles([null]),
throwsA(const TypeMatcher<AssertionError>()),
);
verifyZeroInteractions(mockChannel);
});

test('sharing empty file fails', () {
expect(
() => Share.shareFiles(['']),
Expand Down
1 change: 1 addition & 0 deletions script/nnbd_plugins.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ readonly NNBD_PLUGINS_LIST=(
"local_auth"
"path_provider"
"plugin_platform_interface"
"share"
"url_launcher"
"video_player"
)
Expand Down