From ec3e92aaa64488ad8f5ce752ea3d5ccba08422d9 Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Mon, 19 Jun 2023 08:09:43 -0700 Subject: [PATCH 1/7] Flutter 3.10 support --- honey/lib/src/expression/expr.dart | 2 +- honey/lib/src/honey_widgets_binding.dart | 13 +++++++++---- honey/pubspec.yaml | 2 +- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/honey/lib/src/expression/expr.dart b/honey/lib/src/expression/expr.dart index 1c6b547..510a5c9 100644 --- a/honey/lib/src/expression/expr.dart +++ b/honey/lib/src/expression/expr.dart @@ -12,7 +12,7 @@ abstract class Expr {} /// A honey expression that has been evaluated to either a value, list or /// widget. @immutable -abstract class EvaluatedExpr implements Expr { +abstract mixin class EvaluatedExpr implements Expr { /// Should this expression be re-evaluated if something goes wrong? bool get retry; diff --git a/honey/lib/src/honey_widgets_binding.dart b/honey/lib/src/honey_widgets_binding.dart index dac44e6..72d21a7 100644 --- a/honey/lib/src/honey_widgets_binding.dart +++ b/honey/lib/src/honey_widgets_binding.dart @@ -35,9 +35,9 @@ class HoneyWidgetsBinding extends BindingBase BindingBase.checkInstance(_instance); static HoneyWidgetsBinding? _instance; - final _key = GlobalKey(); final _semanticTagProperties = >{}; + final _key = GlobalKey(debugLabel: 'HoneyWidgetBindingKey'); var _testing = false; Widget? _rootWidget; late TestTextInput _testTextInput; @@ -68,7 +68,7 @@ class HoneyWidgetsBinding extends BindingBase Map customFunctions = const {}, }) { if (_instance == null) { - final instance = HoneyWidgetsBinding(); + _instance = HoneyWidgetsBinding(); instance.pipelineOwner.ensureSemantics(); switch (mode) { @@ -85,9 +85,14 @@ class HoneyWidgetsBinding extends BindingBase @override void scheduleAttachRootWidget(Widget rootWidget) { - _rootWidget = rootWidget; + if (_rootWidget?.key != rootWidget.key) { + _rootWidget = rootWidget; + } else { + final view = rootWidget as View; + _rootWidget = rootWidget.child; + } - Widget widget = KeyedSubtree(key: _key, child: rootWidget); + Widget widget = KeyedSubtree(key: _key, child: _rootWidget!); if (!_testing) { widget = HoneyOverlay(child: widget); } diff --git a/honey/pubspec.yaml b/honey/pubspec.yaml index 68b9293..e6f3860 100644 --- a/honey/pubspec.yaml +++ b/honey/pubspec.yaml @@ -5,7 +5,7 @@ homepage: https://honey.dev repository: https://github.com/clickup/honey environment: - sdk: ">=2.18.0 <3.0.0" + sdk: ">=3.0.0 <4.0.0" flutter: ">=3.0.0" dependencies: From a324bc53724c01599e9cc9e2a67d8f7c5e7e4d63 Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Mon, 19 Jun 2023 09:36:37 -0700 Subject: [PATCH 2/7] Added comment about the fix --- honey/lib/src/honey_widgets_binding.dart | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/honey/lib/src/honey_widgets_binding.dart b/honey/lib/src/honey_widgets_binding.dart index 72d21a7..3ba1124 100644 --- a/honey/lib/src/honey_widgets_binding.dart +++ b/honey/lib/src/honey_widgets_binding.dart @@ -85,9 +85,14 @@ class HoneyWidgetsBinding extends BindingBase @override void scheduleAttachRootWidget(Widget rootWidget) { + /// In old flutter versions, when we passed MyApp to a 'runApp' method, it + /// was being passed here. Then when we called runApp again in [reset] method, + /// it was being passed here again constantly. Now after flutter upgrade to 3.10 + /// after calling runApp in [reset] method, the rootWidget is being passed wrapped with View widget + /// so we need to unwrap it here. Otherwise it causes an error with accessing the inactive element. if (_rootWidget?.key != rootWidget.key) { _rootWidget = rootWidget; - } else { + } else if (_rootWidget != rootWidget) { final view = rootWidget as View; _rootWidget = rootWidget.child; } From 63b27935308815cfdaf89716ac265be49a2a917f Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Mon, 19 Jun 2023 10:06:10 -0700 Subject: [PATCH 3/7] Removed debug stuff --- honey/lib/src/honey_widgets_binding.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/honey/lib/src/honey_widgets_binding.dart b/honey/lib/src/honey_widgets_binding.dart index 3ba1124..3474c35 100644 --- a/honey/lib/src/honey_widgets_binding.dart +++ b/honey/lib/src/honey_widgets_binding.dart @@ -37,7 +37,7 @@ class HoneyWidgetsBinding extends BindingBase final _semanticTagProperties = >{}; - final _key = GlobalKey(debugLabel: 'HoneyWidgetBindingKey'); + final _key = GlobalKey(); var _testing = false; Widget? _rootWidget; late TestTextInput _testTextInput; From 1ace67fb79e6badce4220ab1599c4f6f8e6f14b1 Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Mon, 19 Jun 2023 10:17:01 -0700 Subject: [PATCH 4/7] Bring back key place --- honey/lib/src/honey_widgets_binding.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/honey/lib/src/honey_widgets_binding.dart b/honey/lib/src/honey_widgets_binding.dart index 3474c35..f9fcd5a 100644 --- a/honey/lib/src/honey_widgets_binding.dart +++ b/honey/lib/src/honey_widgets_binding.dart @@ -35,9 +35,9 @@ class HoneyWidgetsBinding extends BindingBase BindingBase.checkInstance(_instance); static HoneyWidgetsBinding? _instance; + final _key = GlobalKey(); final _semanticTagProperties = >{}; - final _key = GlobalKey(); var _testing = false; Widget? _rootWidget; late TestTextInput _testTextInput; From 9f88d0f74b7d1eed810b6561c90c1ff8ae2b8ecc Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Tue, 20 Jun 2023 10:57:54 -0700 Subject: [PATCH 5/7] Bump up version to 0.1.3 --- honey/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/honey/pubspec.yaml b/honey/pubspec.yaml index e6f3860..25a22e2 100644 --- a/honey/pubspec.yaml +++ b/honey/pubspec.yaml @@ -1,6 +1,6 @@ name: honey description: The sweet side of testing. An end to end testing framework for Flutter. -version: 0.1.2 +version: 0.1.3 homepage: https://honey.dev repository: https://github.com/clickup/honey From 9b016c0e8c5b7e4b364c4692a17f94de0c31ced2 Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Tue, 20 Jun 2023 11:29:14 -0700 Subject: [PATCH 6/7] Changelog update --- honey/CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/honey/CHANGELOG.md b/honey/CHANGELOG.md index 7005302..034e7ad 100644 --- a/honey/CHANGELOG.md +++ b/honey/CHANGELOG.md @@ -1,3 +1,9 @@ +## 0.1.3 + +### Enahncements + +- Flutter 3.10 support + ## 0.1.2 ### Enahncements From d65cd376190ed6cf0a16c1ff7f6ddd67699a6f46 Mon Sep 17 00:00:00 2001 From: piotrmoskala Date: Mon, 26 Jun 2023 09:26:48 -0700 Subject: [PATCH 7/7] Refactor --- honey/CHANGELOG.md | 2 +- honey/lib/src/honey_widgets_binding.dart | 12 +++++++----- honey/pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/honey/CHANGELOG.md b/honey/CHANGELOG.md index 034e7ad..d7ea025 100644 --- a/honey/CHANGELOG.md +++ b/honey/CHANGELOG.md @@ -1,4 +1,4 @@ -## 0.1.3 +## 0.2.1 ### Enahncements diff --git a/honey/lib/src/honey_widgets_binding.dart b/honey/lib/src/honey_widgets_binding.dart index f9fcd5a..2a19f67 100644 --- a/honey/lib/src/honey_widgets_binding.dart +++ b/honey/lib/src/honey_widgets_binding.dart @@ -86,15 +86,17 @@ class HoneyWidgetsBinding extends BindingBase @override void scheduleAttachRootWidget(Widget rootWidget) { /// In old flutter versions, when we passed MyApp to a 'runApp' method, it - /// was being passed here. Then when we called runApp again in [reset] method, - /// it was being passed here again constantly. Now after flutter upgrade to 3.10 - /// after calling runApp in [reset] method, the rootWidget is being passed wrapped with View widget - /// so we need to unwrap it here. Otherwise it causes an error with accessing the inactive element. + /// was being passed here. Then when we called runApp again in [reset] + /// method, it was being passed here again constantly. + /// Now after flutter upgrade to 3.10 after calling runApp in [reset] + /// method, the rootWidget is being passed wrapped with View widget + /// so we need to unwrap it here. + /// Otherwise it causes an error with accessing the inactive element. if (_rootWidget?.key != rootWidget.key) { _rootWidget = rootWidget; } else if (_rootWidget != rootWidget) { final view = rootWidget as View; - _rootWidget = rootWidget.child; + _rootWidget = view.child; } Widget widget = KeyedSubtree(key: _key, child: _rootWidget!); diff --git a/honey/pubspec.yaml b/honey/pubspec.yaml index 25a22e2..e7c3a86 100644 --- a/honey/pubspec.yaml +++ b/honey/pubspec.yaml @@ -1,6 +1,6 @@ name: honey description: The sweet side of testing. An end to end testing framework for Flutter. -version: 0.1.3 +version: 0.2.1 homepage: https://honey.dev repository: https://github.com/clickup/honey