Skip to content

Commit ab66f55

Browse files
authored
Reland Resolve breaking change of adding a method to ChangeNotifier. (flutter#134983)
1 parent a9183f6 commit ab66f55

20 files changed

+31
-35
lines changed

packages/flutter/lib/src/foundation/change_notifier.dart

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ mixin class ChangeNotifier implements Listenable {
207207
@protected
208208
bool get hasListeners => _count > 0;
209209

210-
/// Dispatches event of object creation to [MemoryAllocations.instance].
210+
/// Dispatches event of the [object] creation to [MemoryAllocations.instance].
211211
///
212212
/// If the event was already dispatched or [kFlutterMemoryAllocationsEnabled]
213213
/// is false, the method is noop.
@@ -227,16 +227,16 @@ mixin class ChangeNotifier implements Listenable {
227227
/// Make sure to invoke it with condition `if (kFlutterMemoryAllocationsEnabled) ...`
228228
/// so that the method is tree-shaken away when the flag is false.
229229
@protected
230-
void maybeDispatchObjectCreation() {
230+
static void maybeDispatchObjectCreation(ChangeNotifier object) {
231231
// Tree shaker does not include this method and the class MemoryAllocations
232232
// if kFlutterMemoryAllocationsEnabled is false.
233-
if (kFlutterMemoryAllocationsEnabled && !_creationDispatched) {
233+
if (kFlutterMemoryAllocationsEnabled && !object._creationDispatched) {
234234
MemoryAllocations.instance.dispatchObjectCreated(
235235
library: _flutterFoundationLibrary,
236236
className: '$ChangeNotifier',
237-
object: this,
237+
object: object,
238238
);
239-
_creationDispatched = true;
239+
object._creationDispatched = true;
240240
}
241241
}
242242

@@ -271,7 +271,7 @@ mixin class ChangeNotifier implements Listenable {
271271
assert(ChangeNotifier.debugAssertNotDisposed(this));
272272

273273
if (kFlutterMemoryAllocationsEnabled) {
274-
maybeDispatchObjectCreation();
274+
maybeDispatchObjectCreation(this);
275275
}
276276

277277
if (_count == _listeners.length) {
@@ -535,7 +535,7 @@ class ValueNotifier<T> extends ChangeNotifier implements ValueListenable<T> {
535535
/// Creates a [ChangeNotifier] that wraps this value.
536536
ValueNotifier(this._value) {
537537
if (kFlutterMemoryAllocationsEnabled) {
538-
maybeDispatchObjectCreation();
538+
ChangeNotifier.maybeDispatchObjectCreation(this);
539539
}
540540
}
541541

packages/flutter/lib/src/rendering/paragraph.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ class _SelectableFragment with Selectable, ChangeNotifier implements TextLayoutM
13211321
required this.range,
13221322
}) : assert(range.isValid && !range.isCollapsed && range.isNormalized) {
13231323
if (kFlutterMemoryAllocationsEnabled) {
1324-
maybeDispatchObjectCreation();
1324+
ChangeNotifier.maybeDispatchObjectCreation(this);
13251325
}
13261326
_selectionGeometry = _getSelectionGeometry();
13271327
}

packages/flutter/lib/src/services/restoration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ class RestorationManager extends ChangeNotifier {
155155
/// with the engine to get restoration messages (by calling [initChannels]).
156156
RestorationManager() {
157157
if (kFlutterMemoryAllocationsEnabled) {
158-
maybeDispatchObjectCreation();
158+
ChangeNotifier.maybeDispatchObjectCreation(this);
159159
}
160160
initChannels();
161161
}

packages/flutter/lib/src/widgets/draggable_scrollable_sheet.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1074,7 +1074,7 @@ class _DraggableScrollableActuatorState extends State<DraggableScrollableActuato
10741074
class _ResetNotifier extends ChangeNotifier {
10751075
_ResetNotifier() {
10761076
if (kFlutterMemoryAllocationsEnabled) {
1077-
maybeDispatchObjectCreation();
1077+
ChangeNotifier.maybeDispatchObjectCreation(this);
10781078
}
10791079
}
10801080
/// Whether someone called [sendReset] or not.

packages/flutter/lib/src/widgets/focus_manager.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ class FocusNode with DiagnosticableTreeMixin, ChangeNotifier {
439439
this.debugLabel = debugLabel;
440440

441441
if (kFlutterMemoryAllocationsEnabled) {
442-
maybeDispatchObjectCreation();
442+
ChangeNotifier.maybeDispatchObjectCreation(this);
443443
}
444444
}
445445

@@ -1468,7 +1468,7 @@ class FocusManager with DiagnosticableTreeMixin, ChangeNotifier {
14681468
/// documentation in that method for caveats to watch out for.
14691469
FocusManager() {
14701470
if (kFlutterMemoryAllocationsEnabled) {
1471-
maybeDispatchObjectCreation();
1471+
ChangeNotifier.maybeDispatchObjectCreation(this);
14721472
}
14731473
rootScope._manager = this;
14741474
}

packages/flutter/lib/src/widgets/focus_traversal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1788,7 +1788,7 @@ class _FocusTraversalGroupNode extends FocusNode {
17881788
required this.policy,
17891789
}) {
17901790
if (kFlutterMemoryAllocationsEnabled) {
1791-
maybeDispatchObjectCreation();
1791+
ChangeNotifier.maybeDispatchObjectCreation(this);
17921792
}
17931793
}
17941794

packages/flutter/lib/src/widgets/navigator.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3390,7 +3390,7 @@ class _History extends Iterable<_RouteEntry> with ChangeNotifier {
33903390
/// Creates an instance of [_History].
33913391
_History() {
33923392
if (kFlutterMemoryAllocationsEnabled) {
3393-
maybeDispatchObjectCreation();
3393+
ChangeNotifier.maybeDispatchObjectCreation(this);
33943394
}
33953395
}
33963396

packages/flutter/lib/src/widgets/restoration.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -457,7 +457,7 @@ abstract class RestorableProperty<T> extends ChangeNotifier {
457457
/// Creates a [RestorableProperty].
458458
RestorableProperty(){
459459
if (kFlutterMemoryAllocationsEnabled) {
460-
maybeDispatchObjectCreation();
460+
ChangeNotifier.maybeDispatchObjectCreation(this);
461461
}
462462
}
463463

packages/flutter/lib/src/widgets/router.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1467,7 +1467,7 @@ class PlatformRouteInformationProvider extends RouteInformationProvider with Wid
14671467
required RouteInformation initialRouteInformation,
14681468
}) : _value = initialRouteInformation {
14691469
if (kFlutterMemoryAllocationsEnabled) {
1470-
maybeDispatchObjectCreation();
1470+
ChangeNotifier.maybeDispatchObjectCreation(this);
14711471
}
14721472
}
14731473

packages/flutter/lib/src/widgets/scroll_controller.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ class ScrollController extends ChangeNotifier {
6565
this.onDetach,
6666
}) : _initialScrollOffset = initialScrollOffset {
6767
if (kFlutterMemoryAllocationsEnabled) {
68-
maybeDispatchObjectCreation();
68+
ChangeNotifier.maybeDispatchObjectCreation(this);
6969
}
7070
}
7171

0 commit comments

Comments
 (0)