Fix CastButton and CastIcon

- CastButton padding
- CastIcon `setState() after dispose()`
This commit is contained in:
gianlucaparadise 2021-10-26 07:42:19 +02:00
parent 2eb46b4f0f
commit 8fefb7dbe9
2 changed files with 18 additions and 6 deletions

View file

@ -5,17 +5,22 @@ import 'CastIcon.dart';
class CastButton extends StatelessWidget {
final Color color;
final EdgeInsets padding;
CastButton({
required this.color,
this.color = const Color(0xFFFFFFFF), // white
this.padding = const EdgeInsets.all(8.0),
});
@override
Widget build(BuildContext context) {
return GestureDetector(
child: Padding(
padding: padding,
child: CastIcon(
color: color,
),
),
onTap: () => FlutterCastFramework.castContext.showCastChooserDialog());
}
}

View file

@ -39,7 +39,10 @@ class _CastIconState extends State<CastIcon> with TickerProviderStateMixin {
}
void _onCastStateChanged() {
if (!mounted) return;
setState(() {
if (!mounted) return;
_castState = FlutterCastFramework.castContext.state.value;
});
}
@ -101,6 +104,7 @@ class _ConnectingIconState extends State<_ConnectingIcon> {
if (!this.mounted) return;
setState(() {
if (!mounted) return;
_frameIndex = 0;
isAnimating = true;
});
@ -111,9 +115,12 @@ class _ConnectingIconState extends State<_ConnectingIcon> {
if (_frameIndex < _connectingAnimationFrames.length - 1) {
await Future.delayed(const Duration(milliseconds: 300));
if (mounted) {
setState(() {
if (!mounted) return;
_frameIndex += 1;
});
}
} else {
// When I reach the end, I re-start from the beginning
await Future.delayed(const Duration(seconds: 1));