Fix CastIcon wrong state on creation

This commit is contained in:
gianlucaparadise 2019-11-16 06:10:27 +01:00
parent eae5f4b761
commit 41d543c343
3 changed files with 5 additions and 2 deletions

View file

@ -68,6 +68,9 @@ class FlutterCastFrameworkPlugin(private val registrar: Registrar, private val c
Log.d(TAG, "App: ON_RESUME")
mSessionManager.addSessionManagerListener(mSessionManagerListener, CastSession::class.java)
mCastSession = mSessionManager.currentCastSession
val castState = CastContext.getSharedInstance(registrar.activeContext()).castState
channel.invokeMethod(MethodNames.onCastStateChanged, castState)
}
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)

View file

@ -54,7 +54,7 @@ class SessionManager {
void sendMessage(String namespace, String message) {
final argsMap = {
'namespace': namespace,
'message': '{"message":"$message"}'
'message': message
};
_channel.invokeMethod(PlatformMethodNames.sendMessage, argsMap);
}

View file

@ -17,7 +17,7 @@ Widget _getButton(String assetName) {
}
class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
CastState _castState = CastState.unavailable;
CastState _castState = FlutterCastFramework.castContext.state.value;
CastState get castState => _castState;