From b9716b84dbefd8748126c194d8185aeabb11d631 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Tue, 19 Jan 2016 09:07:22 -0800 Subject: [PATCH 1/3] Reimplement Inherited.notifyDescendants to use a registration list ...instead of a deep walk. --- packages/flutter/lib/src/widgets/binding.dart | 16 +++++- .../flutter/lib/src/widgets/framework.dart | 56 ++++++++++++++----- 2 files changed, 57 insertions(+), 15 deletions(-) diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index 0f2102579e..a73cffb85a 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -105,6 +105,18 @@ class WidgetFlutterBinding extends BindingBase with Scheduler, Gesturer, Rendere _dirtyElements.add(element); } + static int _elementSort(BuildableElement a, BuildableElement b) { + if (a.depth < b.depth) + return -1; + if (b.depth < a.depth) + return 1; + if (b.dirty && !a.dirty) + return -1; + if (a.dirty && !b.dirty) + return 1; + return 0; + } + /// Builds all the elements that were marked as dirty using schedule(), in depth order. /// If elements are marked as dirty while this runs, they must be deeper than the algorithm /// has yet reached. @@ -114,14 +126,14 @@ class WidgetFlutterBinding extends BindingBase with Scheduler, Gesturer, Rendere return; Timeline.startSync('Build'); BuildableElement.lockState(() { - _dirtyElements.sort((BuildableElement a, BuildableElement b) => a.depth - b.depth); + _dirtyElements.sort(_elementSort); int dirtyCount = _dirtyElements.length; int index = 0; while (index < dirtyCount) { _dirtyElements[index].rebuild(); index += 1; if (dirtyCount < _dirtyElements.length) { - _dirtyElements.sort((BuildableElement a, BuildableElement b) => a.depth - b.depth); + _dirtyElements.sort(_elementSort); dirtyCount = _dirtyElements.length; } } diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 143c81b3df..eb1cb87faa 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -554,6 +554,7 @@ class _InactiveElements { element.deactivate(); assert(element._debugLifecycleState == _ElementLifecycle.inactive); element.visitChildren(_deactivate); + assert(() { element.debugDeactivated(); return true; }); } void add(Element element) { @@ -851,10 +852,20 @@ abstract class Element implements BuildContext { assert(widget != null); assert(depth != null); assert(_active); + if (_dependencies != null) { + for (InheritedElement dependency in _dependencies) + dependency._dependants.remove(this); + _dependencies.clear(); + } _active = false; assert(() { _debugLifecycleState = _ElementLifecycle.inactive; return true; }); } + /// Called after children have been deactivated. + void debugDeactivated() { + assert(_debugLifecycleState == _ElementLifecycle.inactive); + } + void reactivate() { assert(_debugLifecycleState == _ElementLifecycle.inactive); assert(widget != null); @@ -879,12 +890,20 @@ abstract class Element implements BuildContext { RenderObject findRenderObject() => renderObject; - Set _dependencies; + Set _dependencies; InheritedWidget inheritFromWidgetOfExactType(Type targetType) { - if (_dependencies == null) - _dependencies = new Set(); - _dependencies.add(targetType); - return ancestorWidgetOfExactType(targetType); + Element ancestor = _parent; + while (ancestor != null && ancestor.widget.runtimeType != targetType) + ancestor = ancestor._parent; + if (ancestor != null) { + assert(ancestor is InheritedElement); + _dependencies ??= new Set(); + _dependencies.add(ancestor); + InheritedElement typedAncestor = ancestor; + typedAncestor._dependants.add(this); + return ancestor.widget; + } + return null; } Widget ancestorWidgetOfExactType(Type targetType) { @@ -1359,19 +1378,30 @@ class ParentDataElement extends _ProxyElement { class InheritedElement extends _ProxyElement { InheritedElement(InheritedWidget widget) : super(widget); + Set _dependants = new Set(); + + void debugDeactivated() { + assert(() { + assert(_dependants.isEmpty); + return true; + }); + super.debugDeactivated(); + } + void notifyDescendants(InheritedWidget oldWidget) { if (!widget.updateShouldNotify(oldWidget)) return; final Type ourRuntimeType = widget.runtimeType; - void notifyChildren(Element child) { - if (child._dependencies != null && - child._dependencies.contains(ourRuntimeType)) { - child.dependenciesChanged(ourRuntimeType); - } - if (child.runtimeType != ourRuntimeType) - child.visitChildren(notifyChildren); + for (Element dependant in _dependants) { + dependant.dependenciesChanged(ourRuntimeType); + assert(() { + // check that it really is our descendant + Element ancestor = dependant._parent; + while (ancestor != this && ancestor != null) + ancestor = ancestor._parent; + return ancestor == this; + }); } - visitChildren(notifyChildren); } } From 5494323db90ea4040c9c2043ebc7e1cce84f23b3 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Tue, 19 Jan 2016 09:31:57 -0800 Subject: [PATCH 2/3] Move us to HashSet to avoid the overhead of tracking the order --- examples/stocks/lib/main.dart | 1 + examples/stocks/lib/stock_home.dart | 2 +- packages/cassowary/lib/cassowary.dart | 1 + packages/cassowary/lib/solver.dart | 18 ++++++------------ .../flutter/lib/src/gestures/recognizer.dart | 3 ++- .../flutter/lib/src/material/ink_well.dart | 4 +++- .../flutter/lib/src/scheduler/scheduler.dart | 3 ++- .../flutter/lib/src/widgets/framework.dart | 12 ++++++------ packages/flutter/lib/src/widgets/heroes.dart | 12 +++++++----- .../lib/src/widgets/mixed_viewport.dart | 4 +++- packages/flutter/test/widget/routes_test.dart | 4 +++- .../lib/src/commands/analyze.dart | 3 ++- .../lib/src/test/remote_listener.dart | 3 ++- 13 files changed, 39 insertions(+), 31 deletions(-) diff --git a/examples/stocks/lib/main.dart b/examples/stocks/lib/main.dart index 4b235cd9d8..cfc1b4a81b 100644 --- a/examples/stocks/lib/main.dart +++ b/examples/stocks/lib/main.dart @@ -5,6 +5,7 @@ library stocks; import 'dart:async'; +import 'dart:collection'; import 'dart:math' as math; import 'dart:ui' as ui; diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 62e4c7f1c1..41de2597ed 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -203,7 +203,7 @@ class StockHomeState extends State { stocks: stocks.toList(), onAction: _buyStock, onOpen: (Stock stock, Key arrowKey) { - Set mostValuableKeys = new Set(); + Set mostValuableKeys = new HashSet(); mostValuableKeys.add(arrowKey); Navigator.pushNamed(context, '/stock/${stock.symbol}', mostValuableKeys: mostValuableKeys); }, diff --git a/packages/cassowary/lib/cassowary.dart b/packages/cassowary/lib/cassowary.dart index c78b152571..e687caf9c4 100644 --- a/packages/cassowary/lib/cassowary.dart +++ b/packages/cassowary/lib/cassowary.dart @@ -5,6 +5,7 @@ /// An implementation of the Cassowary constraint solving algorithm in Dart. library cassowary; +import 'dart:collection'; import 'dart:math'; part 'constraint.dart'; diff --git a/packages/cassowary/lib/solver.dart b/packages/cassowary/lib/solver.dart index 3569c7b277..35451a523f 100644 --- a/packages/cassowary/lib/solver.dart +++ b/packages/cassowary/lib/solver.dart @@ -146,13 +146,11 @@ class Solver { Result removeEditVariable(Variable variable) { _EditInfo info = _edits[variable]; - if (info == null) { + if (info == null) return Result.unknownEditVariable; - } - if (removeConstraint(info.constraint) != Result.success) { + if (removeConstraint(info.constraint) != Result.success) return Result.internalSolverError; - } _edits.remove(variable); return Result.success; @@ -173,7 +171,7 @@ class Solver { } Set flushUpdates() { - Set updates = new Set(); + Set updates = new HashSet(); for (Variable variable in _vars.keys) { _Symbol symbol = _vars[variable]; @@ -183,10 +181,8 @@ class Solver { if (variable._applyUpdate(updatedValue) && variable._owner != null) { dynamic context = variable._owner.context; - - if (context != null) { + if (context != null) updates.add(context); - } } } @@ -212,9 +208,8 @@ class Solver { } if (needsCleanup) { - for (dynamic item in applied.reversed) { + for (dynamic item in applied.reversed) undoer(item); - } } return result; @@ -223,9 +218,8 @@ class Solver { _Symbol _symbolForVariable(Variable variable) { _Symbol symbol = _vars[variable]; - if (symbol != null) { + if (symbol != null) return symbol; - } symbol = new _Symbol(_SymbolType.external, tick++); _vars[variable] = symbol; diff --git a/packages/flutter/lib/src/gestures/recognizer.dart b/packages/flutter/lib/src/gestures/recognizer.dart index 921dc2bd3a..c120ef27b5 100644 --- a/packages/flutter/lib/src/gestures/recognizer.dart +++ b/packages/flutter/lib/src/gestures/recognizer.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:collection'; import 'dart:ui' show Point, Offset; import 'arena.dart'; @@ -43,7 +44,7 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer { GestureArena _gestureArena; final List _entries = []; - final Set _trackedPointers = new Set(); + final Set _trackedPointers = new HashSet(); void handleEvent(PointerEvent event); void acceptGesture(int pointer) { } diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index 19f6513b19..f30ba0d662 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:collection'; + import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; @@ -85,7 +87,7 @@ class _InkResponseState extends State { } // else we're probably in deactivate() } ); - _splashes ??= new Set(); + _splashes ??= new HashSet(); _splashes.add(splash); _currentSplash = splash; updateHighlight(true); diff --git a/packages/flutter/lib/src/scheduler/scheduler.dart b/packages/flutter/lib/src/scheduler/scheduler.dart index 3f2107d4ec..7ee637b561 100644 --- a/packages/flutter/lib/src/scheduler/scheduler.dart +++ b/packages/flutter/lib/src/scheduler/scheduler.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:collection'; import 'dart:developer'; import 'dart:ui' as ui; @@ -142,7 +143,7 @@ abstract class Scheduler extends BindingBase { int _nextFrameCallbackId = 0; // positive Map _transientCallbacks = {}; - final Set _removedIds = new Set(); + final Set _removedIds = new HashSet(); int get transientCallbackCount => _transientCallbacks.length; diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index eb1cb87faa..7f44b94724 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -81,7 +81,7 @@ abstract class GlobalKey> extends Key { static final Map _registry = new Map(); static final Map _debugDuplicates = new Map(); static final Map> _removeListeners = new Map>(); - static final Set _removedKeys = new Set(); + static final Set _removedKeys = new HashSet(); void _register(Element element) { assert(() { @@ -129,7 +129,7 @@ abstract class GlobalKey> extends Key { static void registerRemoveListener(GlobalKey key, GlobalKeyRemoveListener listener) { assert(key != null); Set listeners = - _removeListeners.putIfAbsent(key, () => new Set()); + _removeListeners.putIfAbsent(key, () => new HashSet()); bool added = listeners.add(listener); assert(added); } @@ -160,7 +160,7 @@ abstract class GlobalKey> extends Key { try { for (GlobalKey key in _removedKeys) { if (!_registry.containsKey(key) && _removeListeners.containsKey(key)) { - Set localListeners = new Set.from(_removeListeners[key]); + Set localListeners = new HashSet.from(_removeListeners[key]); for (GlobalKeyRemoveListener listener in localListeners) listener(key); } @@ -524,7 +524,7 @@ enum _ElementLifecycle { class _InactiveElements { bool _locked = false; - final Set _elements = new Set(); + final Set _elements = new HashSet(); void _unmount(Element element) { assert(element._debugLifecycleState == _ElementLifecycle.inactive); @@ -897,7 +897,7 @@ abstract class Element implements BuildContext { ancestor = ancestor._parent; if (ancestor != null) { assert(ancestor is InheritedElement); - _dependencies ??= new Set(); + _dependencies ??= new HashSet(); _dependencies.add(ancestor); InheritedElement typedAncestor = ancestor; typedAncestor._dependants.add(this); @@ -1378,7 +1378,7 @@ class ParentDataElement extends _ProxyElement { class InheritedElement extends _ProxyElement { InheritedElement(InheritedWidget widget) : super(widget); - Set _dependants = new Set(); + Set _dependants = new HashSet(); void debugDeactivated() { assert(() { diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index aff4cc23a4..833b9a1217 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:collection'; + import 'package:flutter/animation.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/scheduler.dart'; @@ -98,7 +100,7 @@ class Hero extends StatefulComponent { final bool alwaysAnimate; static Map of(BuildContext context, Set mostValuableKeys) { - mostValuableKeys ??= new Set(); + mostValuableKeys ??= new HashSet(); assert(!mostValuableKeys.contains(null)); // first we collect ALL the heroes, sorted by their tags Map> heroes = >{}; @@ -177,7 +179,7 @@ class HeroState extends State implements HeroHandle { _HeroManifest result = new _HeroManifest( key: _key, config: config, - sourceStates: new Set.from([this]), + sourceStates: new HashSet.from([this]), currentRect: startRect, currentTurns: config.turns.toDouble() ); @@ -268,7 +270,7 @@ class _HeroQuestState implements HeroHandle { _taken = true; Set states = sourceStates; if (targetState != null) - states = states.union(new Set.from([targetState])); + states = states.union(new HashSet.from([targetState])); return new _HeroManifest( key: key, config: child, @@ -351,7 +353,7 @@ class HeroParty { assert(to == null || to.sourceStates.length == 1); assert(to == null || to.currentTurns.floor() == to.currentTurns); HeroState targetState = to != null ? to.sourceStates.elementAt(0) : null; - Set sourceStates = from != null ? from.sourceStates : new Set(); + Set sourceStates = from != null ? from.sourceStates : new HashSet(); sourceStates.remove(targetState); RelativeRect sourceRect = from != null ? from.currentRect : new RelativeRect.fromRect(to.currentRect.toRect(animationArea).center & Size.zero, animationArea); @@ -489,7 +491,7 @@ class HeroController extends NavigatorObserver { Set _getMostValuableKeys() { assert(_from != null); assert(_to != null); - Set result = new Set(); + Set result = new HashSet(); if (_from.settings.mostValuableKeys != null) result.addAll(_from.settings.mostValuableKeys); if (_to.settings.mostValuableKeys != null) diff --git a/packages/flutter/lib/src/widgets/mixed_viewport.dart b/packages/flutter/lib/src/widgets/mixed_viewport.dart index ae29e5bd5c..f60b8dd750 100644 --- a/packages/flutter/lib/src/widgets/mixed_viewport.dart +++ b/packages/flutter/lib/src/widgets/mixed_viewport.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:collection'; + import 'package:flutter/rendering.dart'; import 'framework.dart'; @@ -97,7 +99,7 @@ class _MixedViewportElement extends RenderObjectElement { Map<_ChildKey, Element> _childrenByKey = new Map<_ChildKey, Element>(); /// The child offsets that we've been told are invalid. - final Set _invalidIndices = new Set(); + final Set _invalidIndices = new HashSet(); /// Returns false if any of the previously-cached offsets have been marked as /// invalid and need to be updated. diff --git a/packages/flutter/test/widget/routes_test.dart b/packages/flutter/test/widget/routes_test.dart index 65778dfc09..290ecb07e4 100644 --- a/packages/flutter/test/widget/routes_test.dart +++ b/packages/flutter/test/widget/routes_test.dart @@ -2,13 +2,15 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:collection'; + import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; import 'package:test/test.dart'; final List results = []; -Set routes = new Set(); +Set routes = new HashSet(); class TestRoute extends Route { TestRoute(this.name); diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index 81cd61ec09..6736575ad0 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:collection'; import 'dart:convert'; import 'dart:io'; @@ -31,7 +32,7 @@ class AnalyzeCommand extends FlutterCommand { @override Future runInProject() async { Stopwatch stopwatch = new Stopwatch()..start(); - Set pubSpecDirectories = new Set(); + Set pubSpecDirectories = new HashSet(); List dartFiles = argResults.rest.toList(); bool foundAnyInCurrentDirectory = false; diff --git a/packages/flutter_tools/lib/src/test/remote_listener.dart b/packages/flutter_tools/lib/src/test/remote_listener.dart index 6f0e283c7f..502ebf3875 100644 --- a/packages/flutter_tools/lib/src/test/remote_listener.dart +++ b/packages/flutter_tools/lib/src/test/remote_listener.dart @@ -3,6 +3,7 @@ // found in the LICENSE file. import 'dart:async'; +import 'dart:collection'; import 'dart:convert'; import 'dart:io'; import 'dart:isolate'; @@ -32,7 +33,7 @@ class RemoteListener { final Suite _suite; final WebSocket _socket; - final Set _liveTests = new Set(); + final Set _liveTests = new HashSet(); static Future start(String server, Metadata metadata, Function getMain()) async { WebSocket socket = await WebSocket.connect(server); From 0903cb5fefab2241242e7a4eaaf74ff4fa51bc44 Mon Sep 17 00:00:00 2001 From: Ian Hickson Date: Tue, 19 Jan 2016 09:56:52 -0800 Subject: [PATCH 3/3] Refactor Inherited to avoid all the tree walks during build. --- .../flutter/lib/src/widgets/framework.dart | 69 +++++++++++-------- .../flutter/lib/src/widgets/locale_query.dart | 2 +- 2 files changed, 42 insertions(+), 29 deletions(-) diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 7f44b94724..3ebc4198a4 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -566,20 +566,12 @@ class _InactiveElements { _elements.add(element); } - void _reactivate(Element element) { - assert(element._debugLifecycleState == _ElementLifecycle.inactive); - element.reactivate(); - assert(element._debugLifecycleState == _ElementLifecycle.active); - element.visitChildren(_reactivate); - } - void remove(Element element) { assert(!_locked); assert(_elements.contains(element)); assert(element._parent == null); _elements.remove(element); assert(!element._active); - _reactivate(element); } } @@ -729,6 +721,7 @@ abstract class Element implements BuildContext { final GlobalKey key = widget.key; key._register(this); } + _updateInheritance(); assert(() { _debugLifecycleState = _ElementLifecycle.active; return true; }); } @@ -793,7 +786,7 @@ abstract class Element implements BuildContext { _slot = newSlot; } - Element _findAndActivateElement(GlobalKey key, Widget newWidget) { + Element _retakeInactiveElement(GlobalKey key, Widget newWidget) { Element element = key._currentElement; if (element == null) return null; @@ -809,13 +802,11 @@ abstract class Element implements BuildContext { Element _inflateWidget(Widget newWidget, dynamic newSlot) { Key key = newWidget.key; if (key is GlobalKey) { - Element newChild = _findAndActivateElement(key, newWidget); + Element newChild = _retakeInactiveElement(key, newWidget); if (newChild != null) { assert(newChild._parent == null); assert(() { _debugCheckForCycles(newChild); return true; }); - newChild._parent = this; - newChild._updateDepth(); - newChild.attachRenderObject(newSlot); + newChild.activate(this, newSlot); Element updatedChild = updateChild(newChild, newWidget, newSlot); assert(newChild == updatedChild); return updatedChild; @@ -847,6 +838,26 @@ abstract class Element implements BuildContext { _inactiveElements.add(child); // this eventually calls child.deactivate() } + void activate(Element parent, dynamic newSlot) { + assert(_debugLifecycleState == _ElementLifecycle.inactive); + _reactivate(); + _parent = parent; + _updateDepth(); + _updateInheritance(); + attachRenderObject(newSlot); + assert(_debugLifecycleState == _ElementLifecycle.active); + } + + void _reactivate() { + assert(_debugLifecycleState == _ElementLifecycle.inactive); + assert(widget != null); + assert(depth != null); + assert(!_active); + _active = true; + assert(() { _debugLifecycleState = _ElementLifecycle.active; return true; }); + visitChildren((Element child) => child._reactivate()); + } + void deactivate() { assert(_debugLifecycleState == _ElementLifecycle.active); assert(widget != null); @@ -866,15 +877,6 @@ abstract class Element implements BuildContext { assert(_debugLifecycleState == _ElementLifecycle.inactive); } - void reactivate() { - assert(_debugLifecycleState == _ElementLifecycle.inactive); - assert(widget != null); - assert(depth != null); - assert(!_active); - _active = true; - assert(() { _debugLifecycleState = _ElementLifecycle.active; return true; }); - } - /// Called when an Element is removed from the tree permanently. void unmount() { assert(_debugLifecycleState == _ElementLifecycle.inactive); @@ -890,22 +892,24 @@ abstract class Element implements BuildContext { RenderObject findRenderObject() => renderObject; + Map _inheritedWidgets; Set _dependencies; InheritedWidget inheritFromWidgetOfExactType(Type targetType) { - Element ancestor = _parent; - while (ancestor != null && ancestor.widget.runtimeType != targetType) - ancestor = ancestor._parent; + InheritedElement ancestor = _inheritedWidgets == null ? null : _inheritedWidgets[targetType]; if (ancestor != null) { assert(ancestor is InheritedElement); _dependencies ??= new HashSet(); _dependencies.add(ancestor); - InheritedElement typedAncestor = ancestor; - typedAncestor._dependants.add(this); + ancestor._dependants.add(this); return ancestor.widget; } return null; } + void _updateInheritance() { + _inheritedWidgets = _parent?._inheritedWidgets; + } + Widget ancestorWidgetOfExactType(Type targetType) { Element ancestor = _parent; while (ancestor != null && ancestor.widget.runtimeType != targetType) @@ -1378,7 +1382,16 @@ class ParentDataElement extends _ProxyElement { class InheritedElement extends _ProxyElement { InheritedElement(InheritedWidget widget) : super(widget); - Set _dependants = new HashSet(); + final Set _dependants = new HashSet(); + + void _updateInheritance() { + final Map incomingWidgets = _parent?._inheritedWidgets; + if (incomingWidgets != null) + _inheritedWidgets = new Map.from(incomingWidgets); + else + _inheritedWidgets = new Map(); + _inheritedWidgets[widget.runtimeType] = this; + } void debugDeactivated() { assert(() { diff --git a/packages/flutter/lib/src/widgets/locale_query.dart b/packages/flutter/lib/src/widgets/locale_query.dart index bba7021207..f6980bda50 100644 --- a/packages/flutter/lib/src/widgets/locale_query.dart +++ b/packages/flutter/lib/src/widgets/locale_query.dart @@ -21,7 +21,7 @@ class LocaleQuery extends InheritedWidget { /// The data from the closest instance of this class that encloses the given context. static LocaleQueryData of(BuildContext context) { LocaleQuery query = context.inheritFromWidgetOfExactType(LocaleQuery); - return query == null ? null : query.data; + return query?.data; } bool updateShouldNotify(LocaleQuery old) => data != old.data;