Migrate plugin to Sound Null Safety

This commit is contained in:
gianlucaparadise 2021-10-10 18:22:59 +02:00
parent 553ea6cfda
commit fd06559ed6
7 changed files with 20 additions and 21 deletions

View file

@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_cast_framework","path":"/Users/gianluca.paradiso/mydev/cast-your-instructions/flutter_cast_framework/","dependencies":[]}],"android":[{"name":"flutter_cast_framework","path":"/Users/gianluca.paradiso/mydev/cast-your-instructions/flutter_cast_framework/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_cast_framework","dependencies":[]}],"date_created":"2021-09-26 18:47:45.316939","version":"2.5.1"} {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"flutter_cast_framework","path":"/Users/gianluca.paradiso/mydev/cast-your-instructions/flutter_cast_framework/","dependencies":[]}],"android":[{"name":"flutter_cast_framework","path":"/Users/gianluca.paradiso/mydev/cast-your-instructions/flutter_cast_framework/","dependencies":[]}],"macos":[],"linux":[],"windows":[],"web":[]},"dependencyGraph":[{"name":"flutter_cast_framework","dependencies":[]}],"date_created":"2021-10-10 18:22:42.460646","version":"2.5.1"}

View file

@ -18,12 +18,13 @@ class CastContext {
state.value = CastState.values[castState]; state.value = CastState.values[castState];
} }
SessionManager _sessionManager; SessionManager? _sessionManager;
SessionManager get sessionManager { SessionManager get sessionManager {
if (_sessionManager == null) { var result = _sessionManager;
_sessionManager = SessionManager(_channel); if (result == null) {
_sessionManager = result = SessionManager(_channel);
} }
return _sessionManager; return result;
} }
} }

View file

@ -41,21 +41,20 @@ class SessionManager {
} }
} }
MessageReceivedCallback onMessageReceived; MessageReceivedCallback? onMessageReceived;
void platformOnMessageReceived(dynamic arguments) { void platformOnMessageReceived(dynamic arguments) {
if (onMessageReceived == null) return; var thisOnMessageReceived = onMessageReceived;
if (thisOnMessageReceived == null) return;
final namespace = arguments['namespace']; final namespace = arguments['namespace'];
final message = arguments['message']; final message = arguments['message'];
onMessageReceived(namespace, message); thisOnMessageReceived(namespace, message);
} }
void sendMessage(String namespace, String message) { void sendMessage(String namespace, String message) {
final argsMap = { final argsMap = {'namespace': namespace, 'message': message};
'namespace': namespace,
'message': message
};
_channel.invokeMethod(PlatformMethodNames.sendMessage, argsMap); _channel.invokeMethod(PlatformMethodNames.sendMessage, argsMap);
} }
} }

View file

@ -7,7 +7,7 @@ class CastButton extends StatelessWidget {
final Color color; final Color color;
CastButton({ CastButton({
this.color, required this.color,
}); });
@override @override

View file

@ -74,9 +74,7 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
class _ConnectingIcon extends StatefulWidget { class _ConnectingIcon extends StatefulWidget {
final Color color; final Color color;
_ConnectingIcon({ _ConnectingIcon({required this.color});
this.color = _defaultIconColor,
});
@override @override
_ConnectingIconState createState() => _ConnectingIconState(); _ConnectingIconState createState() => _ConnectingIconState();

View file

@ -52,16 +52,17 @@ class FlutterCastFramework {
}); });
} }
static CastContext _castContext; static CastContext? _castContext;
// This must be the plugin entry point // This must be the plugin entry point
static CastContext get castContext { static CastContext get castContext {
if (!_isInitiated || _castContext == null) { var castContext = _castContext;
_castContext = CastContext(_channel); if (!_isInitiated || castContext == null) {
_castContext = castContext = CastContext(_channel);
// TODO: find a better way to init the plugin // TODO: find a better way to init the plugin
_isInitiated = true; _isInitiated = true;
_init(); _init();
} }
return _castContext; return castContext;
} }
} }

View file

@ -4,7 +4,7 @@ version: 0.0.1
homepage: homepage:
environment: environment:
sdk: ">=2.1.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
dependencies: dependencies:
flutter: flutter: