Add explicit surface visibility signal
Provide composable shown/current visibility for retained surfaces and migrate visibility readers away from TickerMode. This keeps ticker muting separate from painted and current-surface state.
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'elapsed_clock.dart';
|
||||
import '../motion/surface_visibility.dart';
|
||||
|
||||
/// Builds a running item's elapsed-time text from the [ElapsedClock], and
|
||||
/// rebuilds only itself as that duration advances.
|
||||
@@ -39,7 +40,7 @@ class _LiveElapsedBuilderState extends State<LiveElapsedBuilder> {
|
||||
_unwatch();
|
||||
_clock = clock;
|
||||
}
|
||||
_shown = TickerMode.valuesOf(context).enabled;
|
||||
_shown = SurfaceVisibility.shownOf(context);
|
||||
_sync();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ import 'package:flutter/widgets.dart';
|
||||
|
||||
import 'relative_time.dart';
|
||||
import 'relative_time_clock.dart';
|
||||
import '../motion/surface_visibility.dart';
|
||||
|
||||
/// A relative-time label that rebuilds only itself, and only when its text
|
||||
/// changes. Every label follows one shared minute [RelativeTimeClock] rather
|
||||
@@ -53,7 +54,7 @@ class _RelativeTimeLabelState extends State<RelativeTimeLabel> {
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
_shown = TickerMode.valuesOf(context).enabled;
|
||||
_shown = SurfaceVisibility.shownOf(context);
|
||||
if (_shown && _stale) _advance();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user