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];
}
SessionManager _sessionManager;
SessionManager? _sessionManager;
SessionManager get sessionManager {
if (_sessionManager == null) {
_sessionManager = SessionManager(_channel);
var result = _sessionManager;
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) {
if (onMessageReceived == null) return;
var thisOnMessageReceived = onMessageReceived;
if (thisOnMessageReceived == null) return;
final namespace = arguments['namespace'];
final message = arguments['message'];
onMessageReceived(namespace, message);
thisOnMessageReceived(namespace, message);
}
void sendMessage(String namespace, String message) {
final argsMap = {
'namespace': namespace,
'message': message
};
final argsMap = {'namespace': namespace, 'message': message};
_channel.invokeMethod(PlatformMethodNames.sendMessage, argsMap);
}
}

View file

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

View file

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

View file

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

View file

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