Fix CastButton and CastIcon
- CastButton padding - CastIcon `setState() after dispose()`
This commit is contained in:
parent
2eb46b4f0f
commit
8fefb7dbe9
2 changed files with 18 additions and 6 deletions
|
|
@ -5,17 +5,22 @@ import 'CastIcon.dart';
|
||||||
|
|
||||||
class CastButton extends StatelessWidget {
|
class CastButton extends StatelessWidget {
|
||||||
final Color color;
|
final Color color;
|
||||||
|
final EdgeInsets padding;
|
||||||
|
|
||||||
CastButton({
|
CastButton({
|
||||||
required this.color,
|
this.color = const Color(0xFFFFFFFF), // white
|
||||||
|
this.padding = const EdgeInsets.all(8.0),
|
||||||
});
|
});
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
return GestureDetector(
|
return GestureDetector(
|
||||||
|
child: Padding(
|
||||||
|
padding: padding,
|
||||||
child: CastIcon(
|
child: CastIcon(
|
||||||
color: color,
|
color: color,
|
||||||
),
|
),
|
||||||
|
),
|
||||||
onTap: () => FlutterCastFramework.castContext.showCastChooserDialog());
|
onTap: () => FlutterCastFramework.castContext.showCastChooserDialog());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -39,7 +39,10 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
|
||||||
}
|
}
|
||||||
|
|
||||||
void _onCastStateChanged() {
|
void _onCastStateChanged() {
|
||||||
|
if (!mounted) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
if (!mounted) return;
|
||||||
_castState = FlutterCastFramework.castContext.state.value;
|
_castState = FlutterCastFramework.castContext.state.value;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
@ -101,6 +104,7 @@ class _ConnectingIconState extends State<_ConnectingIcon> {
|
||||||
if (!this.mounted) return;
|
if (!this.mounted) return;
|
||||||
|
|
||||||
setState(() {
|
setState(() {
|
||||||
|
if (!mounted) return;
|
||||||
_frameIndex = 0;
|
_frameIndex = 0;
|
||||||
isAnimating = true;
|
isAnimating = true;
|
||||||
});
|
});
|
||||||
|
|
@ -111,9 +115,12 @@ class _ConnectingIconState extends State<_ConnectingIcon> {
|
||||||
|
|
||||||
if (_frameIndex < _connectingAnimationFrames.length - 1) {
|
if (_frameIndex < _connectingAnimationFrames.length - 1) {
|
||||||
await Future.delayed(const Duration(milliseconds: 300));
|
await Future.delayed(const Duration(milliseconds: 300));
|
||||||
|
if (mounted) {
|
||||||
setState(() {
|
setState(() {
|
||||||
|
if (!mounted) return;
|
||||||
_frameIndex += 1;
|
_frameIndex += 1;
|
||||||
});
|
});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
// When I reach the end, I re-start from the beginning
|
// When I reach the end, I re-start from the beginning
|
||||||
await Future.delayed(const Duration(seconds: 1));
|
await Future.delayed(const Duration(seconds: 1));
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue