Fix CastIcon wrong state on creation
This commit is contained in:
parent
eae5f4b761
commit
41d543c343
3 changed files with 5 additions and 2 deletions
|
|
@ -68,6 +68,9 @@ class FlutterCastFrameworkPlugin(private val registrar: Registrar, private val c
|
||||||
Log.d(TAG, "App: ON_RESUME")
|
Log.d(TAG, "App: ON_RESUME")
|
||||||
mSessionManager.addSessionManagerListener(mSessionManagerListener, CastSession::class.java)
|
mSessionManager.addSessionManagerListener(mSessionManagerListener, CastSession::class.java)
|
||||||
mCastSession = mSessionManager.currentCastSession
|
mCastSession = mSessionManager.currentCastSession
|
||||||
|
|
||||||
|
val castState = CastContext.getSharedInstance(registrar.activeContext()).castState
|
||||||
|
channel.invokeMethod(MethodNames.onCastStateChanged, castState)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
@OnLifecycleEvent(Lifecycle.Event.ON_PAUSE)
|
||||||
|
|
|
||||||
|
|
@ -54,7 +54,7 @@ class SessionManager {
|
||||||
void sendMessage(String namespace, String message) {
|
void sendMessage(String namespace, String message) {
|
||||||
final argsMap = {
|
final argsMap = {
|
||||||
'namespace': namespace,
|
'namespace': namespace,
|
||||||
'message': '{"message":"$message"}'
|
'message': message
|
||||||
};
|
};
|
||||||
_channel.invokeMethod(PlatformMethodNames.sendMessage, argsMap);
|
_channel.invokeMethod(PlatformMethodNames.sendMessage, argsMap);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ Widget _getButton(String assetName) {
|
||||||
}
|
}
|
||||||
|
|
||||||
class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
CastState _castState = CastState.unavailable;
|
CastState _castState = FlutterCastFramework.castContext.state.value;
|
||||||
|
|
||||||
CastState get castState => _castState;
|
CastState get castState => _castState;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue