Unverified Commit 4a3584af authored by Alberto's avatar Alberto Committed by GitHub

chore: Moved didUpdateWidget calls first (#96944)

parent c1e24765
...@@ -218,13 +218,13 @@ class _CupertinoPickerState extends State<CupertinoPicker> { ...@@ -218,13 +218,13 @@ class _CupertinoPickerState extends State<CupertinoPicker> {
@override @override
void didUpdateWidget(CupertinoPicker oldWidget) { void didUpdateWidget(CupertinoPicker oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.scrollController != null && oldWidget.scrollController == null) { if (widget.scrollController != null && oldWidget.scrollController == null) {
_controller = null; _controller = null;
} else if (widget.scrollController == null && oldWidget.scrollController != null) { } else if (widget.scrollController == null && oldWidget.scrollController != null) {
assert(_controller == null); assert(_controller == null);
_controller = FixedExtentScrollController(); _controller = FixedExtentScrollController();
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
...@@ -123,8 +123,8 @@ class _SegmentState<T> extends State<_Segment<T>> with TickerProviderStateMixin< ...@@ -123,8 +123,8 @@ class _SegmentState<T> extends State<_Segment<T>> with TickerProviderStateMixin<
@override @override
void didUpdateWidget(_Segment<T> oldWidget) { void didUpdateWidget(_Segment<T> oldWidget) {
assert(oldWidget.key == widget.key);
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
assert(oldWidget.key == widget.key);
if (oldWidget.shouldScaleContent != widget.shouldScaleContent) { if (oldWidget.shouldScaleContent != widget.shouldScaleContent) {
highlightPressScaleAnimation = highlightPressScaleController.drive( highlightPressScaleAnimation = highlightPressScaleController.drive(
...@@ -213,8 +213,8 @@ class _SegmentSeparatorState extends State<_SegmentSeparator> with TickerProvide ...@@ -213,8 +213,8 @@ class _SegmentSeparatorState extends State<_SegmentSeparator> with TickerProvide
@override @override
void didUpdateWidget(_SegmentSeparator oldWidget) { void didUpdateWidget(_SegmentSeparator oldWidget) {
assert(oldWidget.key == widget.key);
super.didUpdateWidget(oldWidget); super.didUpdateWidget(oldWidget);
assert(oldWidget.key == widget.key);
if (oldWidget.highlighted != widget.highlighted) { if (oldWidget.highlighted != widget.highlighted) {
separatorOpacityController.animateTo( separatorOpacityController.animateTo(
......
...@@ -422,6 +422,7 @@ class _CupertinoTextSelectionToolbarContentState extends State<_CupertinoTextSel ...@@ -422,6 +422,7 @@ class _CupertinoTextSelectionToolbarContentState extends State<_CupertinoTextSel
@override @override
void didUpdateWidget(_CupertinoTextSelectionToolbarContent oldWidget) { void didUpdateWidget(_CupertinoTextSelectionToolbarContent oldWidget) {
super.didUpdateWidget(oldWidget);
// If the children are changing, the current page should be reset. // If the children are changing, the current page should be reset.
if (widget.children != oldWidget.children) { if (widget.children != oldWidget.children) {
_page = 0; _page = 0;
...@@ -429,7 +430,6 @@ class _CupertinoTextSelectionToolbarContentState extends State<_CupertinoTextSel ...@@ -429,7 +430,6 @@ class _CupertinoTextSelectionToolbarContentState extends State<_CupertinoTextSel
_controller.forward(); _controller.forward();
_controller.removeStatusListener(_statusListener); _controller.removeStatusListener(_statusListener);
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
...@@ -230,11 +230,11 @@ class _MaterialBannerState extends State<MaterialBanner> { ...@@ -230,11 +230,11 @@ class _MaterialBannerState extends State<MaterialBanner> {
@override @override
void didUpdateWidget(MaterialBanner oldWidget) { void didUpdateWidget(MaterialBanner oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.animation != oldWidget.animation) { if (widget.animation != oldWidget.animation) {
oldWidget.animation?.removeStatusListener(_onAnimationStatusChanged); oldWidget.animation?.removeStatusListener(_onAnimationStatusChanged);
widget.animation?.addStatusListener(_onAnimationStatusChanged); widget.animation?.addStatusListener(_onAnimationStatusChanged);
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
...@@ -2596,6 +2596,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto ...@@ -2596,6 +2596,7 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
@override @override
void didUpdateWidget(Scaffold oldWidget) { void didUpdateWidget(Scaffold oldWidget) {
super.didUpdateWidget(oldWidget);
// Update the Floating Action Button Animator, and then schedule the Floating Action Button for repositioning. // Update the Floating Action Button Animator, and then schedule the Floating Action Button for repositioning.
if (widget.floatingActionButtonAnimator != oldWidget.floatingActionButtonAnimator) { if (widget.floatingActionButtonAnimator != oldWidget.floatingActionButtonAnimator) {
_floatingActionButtonAnimator = widget.floatingActionButtonAnimator ?? _kDefaultFloatingActionButtonAnimator; _floatingActionButtonAnimator = widget.floatingActionButtonAnimator ?? _kDefaultFloatingActionButtonAnimator;
...@@ -2628,7 +2629,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto ...@@ -2628,7 +2629,6 @@ class ScaffoldState extends State<Scaffold> with TickerProviderStateMixin, Resto
_updatePersistentBottomSheet(); _updatePersistentBottomSheet();
} }
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
...@@ -385,11 +385,11 @@ class _SnackBarState extends State<SnackBar> { ...@@ -385,11 +385,11 @@ class _SnackBarState extends State<SnackBar> {
@override @override
void didUpdateWidget(SnackBar oldWidget) { void didUpdateWidget(SnackBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.animation != oldWidget.animation) { if (widget.animation != oldWidget.animation) {
oldWidget.animation!.removeStatusListener(_onAnimationStatusChanged); oldWidget.animation!.removeStatusListener(_onAnimationStatusChanged);
widget.animation!.addStatusListener(_onAnimationStatusChanged); widget.animation!.addStatusListener(_onAnimationStatusChanged);
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
...@@ -1087,12 +1087,12 @@ class _BackButtonListenerState extends State<BackButtonListener> { ...@@ -1087,12 +1087,12 @@ class _BackButtonListenerState extends State<BackButtonListener> {
@override @override
void didUpdateWidget(covariant BackButtonListener oldWidget) { void didUpdateWidget(covariant BackButtonListener oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.onBackButtonPressed != widget.onBackButtonPressed) { if (oldWidget.onBackButtonPressed != widget.onBackButtonPressed) {
dispatcher?.removeCallback(oldWidget.onBackButtonPressed); dispatcher?.removeCallback(oldWidget.onBackButtonPressed);
dispatcher?.addCallback(widget.onBackButtonPressed); dispatcher?.addCallback(widget.onBackButtonPressed);
dispatcher?.takePriority(); dispatcher?.takePriority();
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
...@@ -164,12 +164,12 @@ class _ValueListenableBuilderState<T> extends State<ValueListenableBuilder<T>> { ...@@ -164,12 +164,12 @@ class _ValueListenableBuilderState<T> extends State<ValueListenableBuilder<T>> {
@override @override
void didUpdateWidget(ValueListenableBuilder<T> oldWidget) { void didUpdateWidget(ValueListenableBuilder<T> oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.valueListenable != widget.valueListenable) { if (oldWidget.valueListenable != widget.valueListenable) {
oldWidget.valueListenable.removeListener(_valueChanged); oldWidget.valueListenable.removeListener(_valueChanged);
value = widget.valueListenable.value; value = widget.valueListenable.value;
widget.valueListenable.addListener(_valueChanged); widget.valueListenable.addListener(_valueChanged);
} }
super.didUpdateWidget(oldWidget);
} }
@override @override
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment