From 2110dfe0f5fbdd08e4cb6f1611ab5eeb3070ebff Mon Sep 17 00:00:00 2001 From: Jonah Williams Date: Wed, 6 Nov 2019 10:38:56 -0800 Subject: [PATCH] remove yield from inherited model (#44233) --- packages/flutter/lib/src/widgets/inherited_model.dart | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/flutter/lib/src/widgets/inherited_model.dart b/packages/flutter/lib/src/widgets/inherited_model.dart index f03fae4a014..ed6dbe2517c 100644 --- a/packages/flutter/lib/src/widgets/inherited_model.dart +++ b/packages/flutter/lib/src/widgets/inherited_model.dart @@ -119,12 +119,12 @@ abstract class InheritedModel extends InheritedWidget { // The [result] will be a list of all of context's type T ancestors concluding // with the one that supports the specified model [aspect]. - static Iterable _findModels>(BuildContext context, Object aspect) sync* { + static void _findModels>(BuildContext context, Object aspect, List results) { final InheritedElement model = context.ancestorInheritedElementForWidgetOfExactType(T); if (model == null) return; - yield model; + results.add(model); assert(model.widget is T); final T modelWidget = model.widget; @@ -139,7 +139,7 @@ abstract class InheritedModel extends InheritedWidget { if (modelParent == null) return; - yield* _findModels(modelParent, aspect); + _findModels(modelParent, aspect, results); } /// Makes [context] dependent on the specified [aspect] of an [InheritedModel] @@ -163,7 +163,8 @@ abstract class InheritedModel extends InheritedWidget { // Create a dependency on all of the type T ancestor models up until // a model is found for which isSupportedAspect(aspect) is true. - final List models = _findModels(context, aspect).toList(); + final List models = []; + _findModels(context, aspect, models); if (models.isEmpty) { return null; }