Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💪 Null safety support #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class Button extends StatelessWidget {
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(4.0),
child: RaisedButton(
child: ElevatedButton(
onPressed: function,
child: Text(
title,
Expand Down
103 changes: 34 additions & 69 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
@@ -1,69 +1,62 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.13"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.0"
async:
dependency: transitive
description:
name: async
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.1"
version: "2.6.1"
boolean_selector:
dependency: transitive
description:
name: boolean_selector
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
charcode:
version: "2.1.0"
characters:
dependency: transitive
description:
name: charcode
name: characters
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.3"
collection:
version: "1.1.0"
charcode:
dependency: transitive
description:
name: collection
name: charcode
url: "https://pub.dartlang.org"
source: hosted
version: "1.14.12"
convert:
version: "1.2.0"
clock:
dependency: transitive
description:
name: convert
name: clock
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.1"
crypto:
version: "1.1.0"
collection:
dependency: transitive
description:
name: crypto
name: collection
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.4"
version: "1.15.0"
cupertino_icons:
dependency: "direct main"
description:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "0.1.3"
fake_async:
dependency: transitive
description:
name: fake_async
url: "https://pub.dartlang.org"
source: hosted
version: "1.2.0"
flutter:
dependency: "direct main"
description: flutter
Expand All @@ -74,62 +67,41 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.12"
matcher:
dependency: transitive
description:
name: matcher
url: "https://pub.dartlang.org"
source: hosted
version: "0.12.6"
version: "0.12.10"
meta:
dependency: transitive
description:
name: meta
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.8"
version: "1.3.0"
path:
dependency: transitive
description:
name: path
url: "https://pub.dartlang.org"
source: hosted
version: "1.6.4"
version: "1.8.0"
pedantic:
dependency: transitive
description:
name: pedantic
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.0"
petitparser:
dependency: transitive
description:
name: petitparser
url: "https://pub.dartlang.org"
source: hosted
version: "2.4.0"
presentation_displays:
dependency: "direct main"
description:
path: ".."
relative: true
source: path
version: "0.1.7"
quiver:
dependency: transitive
description:
name: quiver
url: "https://pub.dartlang.org"
source: hosted
version: "2.1.3"
version: "0.2.0"
sky_engine:
dependency: transitive
description: flutter
Expand All @@ -141,63 +113,56 @@ packages:
name: source_span
url: "https://pub.dartlang.org"
source: hosted
version: "1.7.0"
version: "1.8.1"
stack_trace:
dependency: transitive
description:
name: stack_trace
url: "https://pub.dartlang.org"
source: hosted
version: "1.9.3"
version: "1.10.0"
stream_channel:
dependency: transitive
description:
name: stream_channel
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
version: "2.1.0"
string_scanner:
dependency: transitive
description:
name: string_scanner
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.5"
version: "1.1.0"
term_glyph:
dependency: transitive
description:
name: term_glyph
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.0"
version: "1.2.0"
test_api:
dependency: transitive
description:
name: test_api
url: "https://pub.dartlang.org"
source: hosted
version: "0.2.15"
version: "0.3.0"
typed_data:
dependency: transitive
description:
name: typed_data
url: "https://pub.dartlang.org"
source: hosted
version: "1.1.6"
version: "1.3.0"
vector_math:
dependency: transitive
description:
name: vector_math
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.8"
xml:
dependency: transitive
description:
name: xml
url: "https://pub.dartlang.org"
source: hosted
version: "3.6.1"
version: "2.1.0"
sdks:
dart: ">=2.7.0 <3.0.0"
dart: ">=2.12.0 <3.0.0"
flutter: ">=1.10.0"
8 changes: 4 additions & 4 deletions lib/display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -110,13 +110,13 @@ class Display {
/// Each logical display has a unique id.
/// The default display has id [DEFAULT_DISPLAY]
/// </p>
int displayId = DEFAULT_DISPLAY;
int? displayId = DEFAULT_DISPLAY;

/// Returns a combination of flags that describe the capabilities of the display.
/// @return The display flags.
///
/// See [FLAG_SUPPORTS_PROTECTED_BUFFERS], [FLAG_SECURE], [FLAG_PRIVATE]
int flag;
int? flag;

/// Returns the rotation of the screen from its "natural" orientation.
/// The returned value may be [ROTATION_0]
Expand All @@ -130,15 +130,15 @@ class Display {
/// degrees counter-clockwise, to compensate rendering will be rotated by
/// 90 degrees clockwise and thus the returned value here will be
/// [ROTATION_90].
int rotation;
int? rotation;

/// Gets the name of the display.
/// <p>
/// Note that some displays may be renamed by the user.
/// </p>
///
/// @return The display's name.
String name;
String? name;

Display({this.displayId, this.flag, this.name, this.rotation});
}
28 changes: 14 additions & 14 deletions lib/displays_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const String DISPLAY_CATEGORY_PRESENTATION =
/// Provide you with the method for you to work with [SecondaryDisplay].
class DisplayManager {
final _displayChannel = "presentation_displays_plugin";
MethodChannel _displayMethodChannel;
MethodChannel? _displayMethodChannel;

DisplayManager() {
_displayMethodChannel = MethodChannel(_displayChannel);
Expand All @@ -52,14 +52,14 @@ class DisplayManager {
/// @return An array containing all displays sorted by order of preference.
///
/// See [DISPLAY_CATEGORY_PRESENTATION]
FutureOr<List<Display>> getDisplays({String category}) async {
List<dynamic> origins = await jsonDecode(await _displayMethodChannel
?.invokeMethod(_listDisplay, category)) ??
Future<List<Display>> getDisplays({String? category}) async {
List<dynamic> origins = await jsonDecode((await _displayMethodChannel
?.invokeMethod(_listDisplay, category))) ??
[];
List<Display> displays = [];
origins.forEach((element) {
Map map = jsonDecode(jsonEncode(element));
displays.add(displayFromJson(map));
displays.add(displayFromJson(map as Map<String, dynamic>));
});
return displays;
}
Expand All @@ -73,10 +73,10 @@ class DisplayManager {
///
/// @return The display's name.
/// May be null.
FutureOr<String> getNameByDisplayId(int displayId, {String category}) async {
List<Display> displays = await getDisplays(category: category) ?? [];
Future<String?> getNameByDisplayId(int displayId, {String? category}) async {
List<Display> displays = await getDisplays(category: category);

String name;
String? name;
displays.forEach((element) {
if (element.displayId == displayId) name = element.name;
});
Expand All @@ -92,9 +92,9 @@ class DisplayManager {
///
/// @return The display's name
/// May be null.
FutureOr<String> getNameByIndex(int index, {String category}) async {
List<Display> displays = await getDisplays(category: category) ?? [];
String name;
Future<String?> getNameByIndex(int index, {String? category}) async {
List<Display> displays = await getDisplays(category: category);
String? name;
if (index >= 0 && index <= displays.length) name = displays[index].name;
return name;
}
Expand All @@ -108,8 +108,8 @@ class DisplayManager {
/// </P>
///
/// return [Future<bool>] about the status has been display or not
Future<bool> showSecondaryDisplay(
{@required int displayId, @required String routerName}) {
Future<bool?>? showSecondaryDisplay(
{required int displayId, required String routerName}) {
return _displayMethodChannel?.invokeMethod(
_showPresentation,
"{"
Expand Down Expand Up @@ -170,7 +170,7 @@ class DisplayManager {
/// </p>
///
/// return [Future<bool>] the value to determine whether or not the data has been transferred successfully
Future<bool> transferDataToPresentation(dynamic arguments) {
Future<bool?>? transferDataToPresentation(dynamic arguments) {
return _displayMethodChannel?.invokeMethod(
_transferDataToPresentation, arguments);
}
Expand Down
6 changes: 3 additions & 3 deletions lib/secondary_display.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,21 @@ typedef ArgumentsCallback = Function(dynamic arguments);
/// [SecondaryDisplay.callback] instance of [ArgumentsCallback] to receive data transmitted from the [DisplayManager].
/// [SecondaryDisplay.child] child widget of secondary display
class SecondaryDisplay extends StatefulWidget {
SecondaryDisplay({@required this.callback, this.child});
SecondaryDisplay({required this.callback, this.child});

/// instance of [ArgumentsCallback] to receive data transmitted from the [DisplaysManager].
final ArgumentsCallback callback;

/// Your Flutter UI on Presentation Screen
final Widget child;
final Widget? child;

@override
_SecondaryDisplayState createState() => _SecondaryDisplayState();
}

class _SecondaryDisplayState extends State<SecondaryDisplay> {
final _presentationChannel = "presentation_displays_plugin_engine";
MethodChannel _presentationMethodChannel;
late MethodChannel _presentationMethodChannel;

@override
void initState() {
Expand Down
Loading