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,16 +5,21 @@ 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: CastIcon(
|
||||
color: color,
|
||||
child: Padding(
|
||||
padding: padding,
|
||||
child: CastIcon(
|
||||
color: color,
|
||||
),
|
||||
),
|
||||
onTap: () => FlutterCastFramework.castContext.showCastChooserDialog());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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));
|
||||
setState(() {
|
||||
_frameIndex += 1;
|
||||
});
|
||||
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));
|
||||
|
|
|
|||
Loading…
Reference in a new issue