Commit d05d3610 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Enforce didUpdateWidget() @mustCallSuper (#9421)

parent 2480c4d4
......@@ -49,6 +49,7 @@ class _CupertinoActivityIndicatorState extends State<CupertinoActivityIndicator>
@override
void didUpdateWidget(CupertinoActivityIndicator oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.animating != oldWidget.animating) {
if (widget.animating)
_controller.repeat();
......
......@@ -291,6 +291,7 @@ class _BottomNavigationBarState extends State<BottomNavigationBar> with TickerPr
@override
void didUpdateWidget(BottomNavigationBar oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.currentIndex != oldWidget.currentIndex) {
if (widget.type == BottomNavigationBarType.shifting)
_pushCircle(widget.currentIndex);
......
......@@ -372,6 +372,7 @@ class _MonthPickerState extends State<MonthPicker> {
@override
void didUpdateWidget(MonthPicker oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.selectedDate != oldWidget.selectedDate) {
_dayPickerController = new PageController(initialPage: _monthDelta(widget.firstDate, widget.selectedDate));
_currentDisplayedMonthDate =
......
......@@ -480,6 +480,7 @@ class _DropdownButtonState<T> extends State<DropdownButton<T>> {
@override
void didUpdateWidget(DropdownButton<T> oldWidget) {
super.didUpdateWidget(oldWidget);
_updateSelectedIndex();
}
......
......@@ -84,6 +84,7 @@ class _ExpandIconState extends State<ExpandIcon> with SingleTickerProviderStateM
@override
void didUpdateWidget(ExpandIcon oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.isExpanded != oldWidget.isExpanded) {
if (widget.isExpanded) {
_controller.forward();
......
......@@ -196,6 +196,7 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr
@override
void didUpdateWidget(_FloatingActionButtonTransition oldWidget) {
super.didUpdateWidget(oldWidget);
final bool oldChildIsNull = oldWidget.child == null;
final bool newChildIsNull = widget.child == null;
if (oldChildIsNull == newChildIsNull && oldWidget.child?.key == widget.child?.key)
......
......@@ -183,6 +183,7 @@ class _TextFieldState extends State<TextField> {
@override
void didUpdateWidget(TextField oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.controller == null && oldWidget.controller != null)
_controller == new TextEditingController.fromValue(oldWidget.controller.value);
else if (widget.controller != null && oldWidget.controller == null)
......
......@@ -479,6 +479,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin {
@override
void didUpdateWidget(_Dial oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.mode != oldWidget.mode && !_dragging)
_animateTo(_getThetaForTime(widget.selectedTime));
}
......
......@@ -107,6 +107,7 @@ class _StreamBuilderBaseState<T, S> extends State<StreamBuilderBase<T, S>> {
@override
void didUpdateWidget(StreamBuilderBase<T, S> oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.stream != widget.stream) {
if (_subscription != null) {
_unsubscribe();
......@@ -419,6 +420,7 @@ class _FutureBuilderState<T> extends State<FutureBuilder<T>> {
@override
void didUpdateWidget(FutureBuilder<T> oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.future != widget.future) {
if (_activeCallbackIdentity != null) {
_unsubscribe();
......
......@@ -236,6 +236,7 @@ class EditableTextState extends State<EditableText> implements TextInputClient {
@override
void didUpdateWidget(EditableText oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.controller != oldWidget.controller) {
oldWidget.controller.removeListener(_didChangeTextEditingValue);
widget.controller.addListener(_didChangeTextEditingValue);
......
......@@ -831,7 +831,7 @@ abstract class State<T extends StatefulWidget> {
///
/// If you override this, make sure your method starts with a call to
/// super.didUpdateWidget(oldWidget).
// TODO(abarth): Add @mustCallSuper.
@mustCallSuper
@protected
void didUpdateWidget(covariant T oldWidget) { }
......
......@@ -368,6 +368,7 @@ class RawGestureDetectorState extends State<RawGestureDetector> {
@override
void didUpdateWidget(RawGestureDetector oldWidget) {
super.didUpdateWidget(oldWidget);
_syncAll(widget.gestures);
}
......
......@@ -244,6 +244,7 @@ class _ImageState extends State<Image> {
@override
void didUpdateWidget(Image oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.image != oldWidget.image)
_resolveImage();
}
......
......@@ -148,6 +148,7 @@ abstract class AnimatedWidgetBaseState<T extends ImplicitlyAnimatedWidget> exten
@override
void didUpdateWidget(T oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.curve != oldWidget.curve)
_updateCurve();
_controller.duration = widget.duration;
......
......@@ -716,6 +716,7 @@ class NavigatorState extends State<Navigator> with TickerProviderStateMixin {
@override
void didUpdateWidget(Navigator oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.observers != widget.observers) {
for (NavigatorObserver observer in oldWidget.observers)
observer._navigator = null;
......
......@@ -122,6 +122,7 @@ class _GlowingOverscrollIndicatorState extends State<GlowingOverscrollIndicator>
@override
void didUpdateWidget(GlowingOverscrollIndicator oldWidget) {
super.didUpdateWidget(oldWidget);
if (oldWidget.color != widget.color || oldWidget.axis != widget.axis) {
_leadingController.color = widget.color;
_leadingController.axis = widget.axis;
......
......@@ -60,6 +60,7 @@ class _RawKeyboardListenerState extends State<RawKeyboardListener> {
@override
void didUpdateWidget(RawKeyboardListener oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.focusNode != oldWidget.focusNode) {
oldWidget.focusNode.removeListener(_handleFocusChanged);
widget.focusNode.addListener(_handleFocusChanged);
......
......@@ -442,6 +442,7 @@ class _ModalScopeState extends State<_ModalScope> {
@override
void didUpdateWidget(_ModalScope oldWidget) {
super.didUpdateWidget(oldWidget);
assert(widget.route == oldWidget.route);
}
......
......@@ -39,6 +39,7 @@ class _StatusTransitionState extends State<StatusTransitionWidget> {
@override
void didUpdateWidget(StatusTransitionWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.animation != oldWidget.animation) {
oldWidget.animation.removeStatusListener(_animationStatusChanged);
widget.animation.addStatusListener(_animationStatusChanged);
......
......@@ -74,6 +74,7 @@ class _AnimatedState extends State<AnimatedWidget> {
@override
void didUpdateWidget(AnimatedWidget oldWidget) {
super.didUpdateWidget(oldWidget);
if (widget.listenable != oldWidget.listenable) {
oldWidget.listenable.removeListener(_handleChange);
widget.listenable.addListener(_handleChange);
......
......@@ -55,6 +55,7 @@ class _WillPopScopeState extends State<WillPopScope> {
@override
void didUpdateWidget(WillPopScope oldWidget) {
super.didUpdateWidget(oldWidget);
assert(_route == ModalRoute.of(context));
if (widget.onWillPop != oldWidget.onWillPop && _route != null) {
if (oldWidget.onWillPop != null)
......
......@@ -23,6 +23,7 @@ class ProbeWidgetState extends State<ProbeWidget> {
@override
void didUpdateWidget(ProbeWidget oldWidget) {
super.didUpdateWidget(oldWidget);
setState(() {});
}
......
......@@ -78,6 +78,7 @@ class TriggerableState extends State<TriggerableWidget> {
@override
void didUpdateWidget(TriggerableWidget oldWidget) {
super.didUpdateWidget(oldWidget);
widget.trigger.callback = fire;
}
......
......@@ -30,6 +30,7 @@ class TestWidgetState extends State<TestWidget> {
@override
void didUpdateWidget(TestWidget oldWidget) {
super.didUpdateWidget(oldWidget);
syncedState = widget.syncedState;
// we explicitly do NOT sync the persistentState from the new instance
// because we're using that to track whether we got recreated
......
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