From 845d5bf2239e0eb5aea2fd2e959af275d37e81b0 Mon Sep 17 00:00:00 2001 From: Nick Fisher Date: Wed, 11 Sep 2024 18:01:33 +0800 Subject: [PATCH] (flutter) add const constructor for flutter options --- .../lib/thermion/thermion_flutter_plugin.dart | 21 ++++++++++++------- .../thermion_flutter_platform_interface.dart | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/thermion_flutter/thermion_flutter/lib/thermion/thermion_flutter_plugin.dart b/thermion_flutter/thermion_flutter/lib/thermion/thermion_flutter_plugin.dart index 1c536de2..eba560cc 100644 --- a/thermion_flutter/thermion_flutter/lib/thermion/thermion_flutter_plugin.dart +++ b/thermion_flutter/thermion_flutter/lib/thermion/thermion_flutter_plugin.dart @@ -67,7 +67,6 @@ class ThermionFlutterPlugin { } _initializing = true; - _viewer = await ThermionFlutterPlatform.instance .createViewer(uberarchivePath: uberArchivePath); _appLifecycleListener = AppLifecycleListener( @@ -82,13 +81,14 @@ class ThermionFlutterPlugin { return _viewer!; } - static Future createViewerWithOptions(ThermionFlutterOptions options) async { + static Future createViewerWithOptions( + {ThermionFlutterOptions options = const ThermionFlutterOptions.empty()}) async { if (_initializing) { throw Exception("Existing call to createViewer has not completed."); } _initializing = true; - _viewer = await ThermionFlutterPlatform.instance - .createViewerWithOptions(options); + _viewer = + await ThermionFlutterPlatform.instance.createViewerWithOptions(options); _appLifecycleListener = AppLifecycleListener( onStateChange: _handleStateChange, ); @@ -102,7 +102,11 @@ class ThermionFlutterPlugin { } static Future createTexture( - double width, double height, double offsetLeft, double offsetTop, double pixelRatio) async { + double width, + double height, + double offsetLeft, + double offsetTop, + double pixelRatio) async { return ThermionFlutterPlatform.instance .createTexture(width, height, offsetLeft, offsetTop, pixelRatio); } @@ -117,8 +121,9 @@ class ThermionFlutterPlugin { int width, int height, int offsetLeft, - int offsetTop, double pixelRatio) async { - return ThermionFlutterPlatform.instance - .resizeTexture(texture, width, height, offsetLeft, offsetTop, pixelRatio); + int offsetTop, + double pixelRatio) async { + return ThermionFlutterPlatform.instance.resizeTexture( + texture, width, height, offsetLeft, offsetTop, pixelRatio); } } diff --git a/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart b/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart index deb81de2..03f81098 100644 --- a/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart +++ b/thermion_flutter/thermion_flutter_platform_interface/lib/thermion_flutter_platform_interface.dart @@ -8,6 +8,8 @@ class ThermionFlutterOptions { final String? uberarchivePath; ThermionFlutterOptions({this.uberarchivePath}); + const ThermionFlutterOptions.empty() : uberarchivePath = null; + } abstract class ThermionFlutterPlatform extends PlatformInterface {