From 7e572edf7e8e8d66a0efd6edafef678d84dc1794 Mon Sep 17 00:00:00 2001 From: Alan Mantoux Date: Sat, 18 Nov 2023 14:30:54 +0100 Subject: [PATCH 1/7] Adapt to Flutter API changes --- packages/fleather/lib/src/widgets/editor.dart | 12 ++++++++++++ .../lib/src/widgets/single_child_scroll_view.dart | 3 ++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/fleather/lib/src/widgets/editor.dart b/packages/fleather/lib/src/widgets/editor.dart index 517e8eb7..889f44bb 100644 --- a/packages/fleather/lib/src/widgets/editor.dart +++ b/packages/fleather/lib/src/widgets/editor.dart @@ -747,6 +747,15 @@ class RawEditor extends StatefulWidget { /// abstract class EditorState extends State implements TextSelectionDelegate { + @override + bool lookUpEnabled = true; + + @override + bool shareEnabled = true; + + @override + bool searchWebEnabled = true; + ClipboardStatusNotifier? get clipboardStatus; ScrollController get scrollController; @@ -1637,6 +1646,9 @@ class RawEditorState extends EditorState onSelectAll: selectAllEnabled ? () => selectAll(SelectionChangedCause.toolbar) : null, + onLookUp: null, + onSearchWeb: null, + onShare: null, onLiveTextInput: null); } diff --git a/packages/fleather/lib/src/widgets/single_child_scroll_view.dart b/packages/fleather/lib/src/widgets/single_child_scroll_view.dart index c60aee9d..dfb00488 100644 --- a/packages/fleather/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/fleather/lib/src/widgets/single_child_scroll_view.dart @@ -305,7 +305,8 @@ class _RenderSingleChildViewport extends RenderBox @override RevealedOffset getOffsetToReveal(RenderObject target, double alignment, - {Rect? rect}) { + {Rect? rect, Axis? axis}) { + // axis is ignored as we only support SingleDimensionViewport rect ??= target.paintBounds; if (target is! RenderBox) { return RevealedOffset(offset: offset.pixels, rect: rect); From 4ca1b7f6cae27f99000e9ab1b9d7ad90a559883b Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Thu, 30 Nov 2023 20:16:53 +0330 Subject: [PATCH 2/7] Fix tests --- packages/fleather/example/ios/Podfile.lock | 4 +- .../ios/Runner.xcodeproj/project.pbxproj | 3 +- .../xcshareddata/xcschemes/Runner.xcscheme | 2 +- .../test/rendering/rendering_tools.dart | 302 +++++++++++++++--- .../fleather/test/widgets/editor_test.dart | 2 +- 5 files changed, 264 insertions(+), 49 deletions(-) diff --git a/packages/fleather/example/ios/Podfile.lock b/packages/fleather/example/ios/Podfile.lock index 727a6ad2..fb67027a 100644 --- a/packages/fleather/example/ios/Podfile.lock +++ b/packages/fleather/example/ios/Podfile.lock @@ -15,8 +15,8 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 - url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993 + url_launcher_ios: 08a3dfac5fb39e8759aeb0abbd5d9480f30fc8b4 PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 -COCOAPODS: 1.11.3 +COCOAPODS: 1.14.2 diff --git a/packages/fleather/example/ios/Runner.xcodeproj/project.pbxproj b/packages/fleather/example/ios/Runner.xcodeproj/project.pbxproj index a62b94e9..a9267b4e 100644 --- a/packages/fleather/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/fleather/example/ios/Runner.xcodeproj/project.pbxproj @@ -164,7 +164,7 @@ 97C146E61CF9000F007C117D /* Project object */ = { isa = PBXProject; attributes = { - LastUpgradeCheck = 1300; + LastUpgradeCheck = 1430; ORGANIZATIONNAME = ""; TargetAttributes = { 97C146ED1CF9000F007C117D = { @@ -213,6 +213,7 @@ files = ( ); inputPaths = ( + "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}", ); name = "Thin Binary"; outputPaths = ( diff --git a/packages/fleather/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/packages/fleather/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme index 3db53b6e..b52b2e69 100644 --- a/packages/fleather/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme +++ b/packages/fleather/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme @@ -1,6 +1,6 @@ - BindingBase.checkInstance(_instance); + static TestRenderingFlutterBinding get instance => BindingBase.checkInstance(_instance); static TestRenderingFlutterBinding? _instance; @override void initInstances() { super.initInstances(); _instance = this; + // TODO(goderbauer): Create (fake) window if embedder doesn't provide an implicit view. + assert(platformDispatcher.implicitView != null); + _renderView = initRenderView(platformDispatcher.implicitView!); + } + + @override + RenderView get renderView => _renderView; + late RenderView _renderView; + + @override + PipelineOwner get pipelineOwner => rootPipelineOwner; + + /// Creates a [RenderView] object to be the root of the + /// [RenderObject] rendering tree, and initializes it so that it + /// will be rendered when the next frame is requested. + /// + /// Called automatically when the binding is created. + RenderView initRenderView(FlutterView view) { + final RenderView renderView = RenderView(view: view); + rootPipelineOwner.rootNode = renderView; + addRenderView(renderView); + renderView.prepareInitialFrame(); + return renderView; + } + + @override + PipelineOwner createRootPipelineOwner() { + return PipelineOwner( + onSemanticsOwnerCreated: () { + renderView.scheduleInitialSemantics(); + }, + onSemanticsUpdate: (SemanticsUpdate update) { + renderView.updateSemantics(update); + }, + onSemanticsOwnerDisposed: () { + renderView.clearSemantics(); + }, + ); } /// Creates and initializes the binding. This function is /// idempotent; calling it a second time will just return the /// previously-created instance. - static TestRenderingFlutterBinding ensureInitialized( - {VoidCallback? onErrors}) { + static TestRenderingFlutterBinding ensureInitialized({ VoidCallback? onErrors }) { if (_instance != null) { return _instance!; } @@ -128,13 +162,11 @@ class TestRenderingFlutterBinding extends BindingBase onErrors!(); if (_errors.isNotEmpty) { _errors.forEach(FlutterError.dumpErrorToConsole); - fail( - 'There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); + fail('There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); } } else { _errors.forEach(FlutterError.dumpErrorToConsole); - fail( - 'Caught error while rendering frame. See preceding logs for details.'); + fail('Caught error while rendering frame. See preceding logs for details.'); } } } @@ -142,33 +174,33 @@ class TestRenderingFlutterBinding extends BindingBase @override void drawFrame() { - assert(phase != EnginePhase.build, - 'rendering_tester does not support testing the build phase; use flutter_test instead'); + assert(phase != EnginePhase.build, 'rendering_tester does not support testing the build phase; use flutter_test instead'); final FlutterExceptionHandler? oldErrorHandler = FlutterError.onError; FlutterError.onError = _errors.add; try { - pipelineOwner.flushLayout(); + rootPipelineOwner.flushLayout(); if (phase == EnginePhase.layout) { return; } - pipelineOwner.flushCompositingBits(); + rootPipelineOwner.flushCompositingBits(); if (phase == EnginePhase.compositingBits) { return; } - pipelineOwner.flushPaint(); + rootPipelineOwner.flushPaint(); if (phase == EnginePhase.paint) { return; } - renderView.compositeFrame(); + for (final RenderView renderView in renderViews) { + renderView.compositeFrame(); + } if (phase == EnginePhase.composite) { return; } - pipelineOwner.flushSemantics(); + rootPipelineOwner.flushSemantics(); if (phase == EnginePhase.flushSemantics) { return; } - assert(phase == EnginePhase.flushSemantics || - phase == EnginePhase.sendSemanticsUpdate); + assert(phase == EnginePhase.flushSemantics || phase == EnginePhase.sendSemanticsUpdate); } finally { FlutterError.onError = oldErrorHandler; if (_errors.isNotEmpty) { @@ -176,29 +208,39 @@ class TestRenderingFlutterBinding extends BindingBase onErrors!(); if (_errors.isNotEmpty) { _errors.forEach(FlutterError.dumpErrorToConsole); - fail( - 'There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); + fail('There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); } } else { _errors.forEach(FlutterError.dumpErrorToConsole); - fail( - 'Caught error while rendering frame. See preceding logs for details.'); + fail('Caught error while rendering frame. See preceding logs for details.'); } } } } } +/// Place the box in the render tree, at the given size and with the given +/// alignment on the screen. +/// +/// If you've updated `box` and want to lay it out again, use [pumpFrame]. +/// +/// Once a particular [RenderBox] has been passed to [layout], it cannot easily +/// be put in a different place in the tree or passed to [layout] again, because +/// [layout] places the given object into another [RenderBox] which you would +/// need to unparent it from (but that box isn't itself made available). +/// +/// The EnginePhase must not be [EnginePhase.build], since the rendering layer +/// has no build phase. +/// +/// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError]. void layout( - RenderBox box, { - // If you want to just repump the last box, call pumpFrame(). + RenderBox box, { // If you want to just repump the last box, call pumpFrame(). BoxConstraints? constraints, Alignment alignment = Alignment.center, EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors, }) { - assert(box.parent == - null); // We stick the box in another, so you can't reuse it easily, sorry. + assert(box.parent == null); // We stick the box in another, so you can't reuse it easily, sorry. TestRenderingFlutterBinding.instance.renderView.child = null; if (constraints != null) { @@ -218,10 +260,8 @@ void layout( /// Pumps a single frame. /// /// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError]. -void pumpFrame( - {EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors}) { - assert(TestRenderingFlutterBinding.instance.renderView.child != - null); // call layout() first! +void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors }) { + assert(TestRenderingFlutterBinding.instance.renderView.child != null); // call layout() first! if (onErrors != null) { TestRenderingFlutterBinding.instance.onErrors = onErrors; @@ -230,3 +270,177 @@ void pumpFrame( TestRenderingFlutterBinding.instance.phase = phase; TestRenderingFlutterBinding.instance.drawFrame(); } + +class TestCallbackPainter extends CustomPainter { + const TestCallbackPainter({ required this.onPaint }); + + final VoidCallback onPaint; + + @override + void paint(Canvas canvas, Size size) { + onPaint(); + } + + @override + bool shouldRepaint(TestCallbackPainter oldPainter) => true; +} + +class RenderSizedBox extends RenderBox { + RenderSizedBox(this._size); + + final Size _size; + + @override + double computeMinIntrinsicWidth(double height) { + return _size.width; + } + + @override + double computeMaxIntrinsicWidth(double height) { + return _size.width; + } + + @override + double computeMinIntrinsicHeight(double width) { + return _size.height; + } + + @override + double computeMaxIntrinsicHeight(double width) { + return _size.height; + } + + @override + bool get sizedByParent => true; + + @override + void performResize() { + size = constraints.constrain(_size); + } + + @override + void performLayout() { } + + @override + bool hitTestSelf(Offset position) => true; +} + +class FakeTickerProvider implements TickerProvider { + @override + Ticker createTicker(TickerCallback onTick, [ bool disableAnimations = false ]) { + return FakeTicker(); + } +} + +class FakeTicker implements Ticker { + @override + bool muted = false; + + @override + void absorbTicker(Ticker originalTicker) { } + + @override + String? get debugLabel => null; + + @override + bool get isActive => throw UnimplementedError(); + + @override + bool get isTicking => throw UnimplementedError(); + + @override + bool get scheduled => throw UnimplementedError(); + + @override + bool get shouldScheduleTick => throw UnimplementedError(); + + @override + void dispose() { } + + @override + void scheduleTick({ bool rescheduling = false }) { } + + @override + TickerFuture start() { + throw UnimplementedError(); + } + + @override + void stop({ bool canceled = false }) { } + + @override + void unscheduleTick() { } + + @override + String toString({ bool debugIncludeStack = false }) => super.toString(); + + @override + DiagnosticsNode describeForError(String name) { + return DiagnosticsProperty(name, this, style: DiagnosticsTreeStyle.errorProperty); + } +} + +class TestClipPaintingContext extends PaintingContext { + TestClipPaintingContext() : this._(ContainerLayer()); + + TestClipPaintingContext._(this._containerLayer) : super(_containerLayer, Rect.zero); + + final ContainerLayer _containerLayer; + + @override + ClipRectLayer? pushClipRect( + bool needsCompositing, + Offset offset, + Rect clipRect, + PaintingContextCallback painter, { + Clip clipBehavior = Clip.hardEdge, + ClipRectLayer? oldLayer, + }) { + this.clipBehavior = clipBehavior; + return null; + } + + Clip clipBehavior = Clip.none; + + @mustCallSuper + void dispose() { + _containerLayer.dispose(); + } +} + +class TestPushLayerPaintingContext extends PaintingContext { + TestPushLayerPaintingContext() : super(ContainerLayer(), Rect.zero); + + final List pushedLayers = []; + + @override + void pushLayer( + ContainerLayer childLayer, + PaintingContextCallback painter, + Offset offset, { + Rect? childPaintBounds + }) { + pushedLayers.add(childLayer); + super.pushLayer(childLayer, painter, offset, childPaintBounds: childPaintBounds); + } +} + +// Absorbs errors that don't have "overflowed" in their error details. +void absorbOverflowedErrors() { + final Iterable errorDetails = TestRenderingFlutterBinding.instance.takeAllFlutterErrorDetails(); + final Iterable filtered = errorDetails.where((FlutterErrorDetails details) { + return !details.toString().contains('overflowed'); + }); + if (filtered.isNotEmpty) { + filtered.forEach(FlutterError.reportError); + } +} + +// Reports any FlutterErrors. +void expectNoFlutterErrors() { + final Iterable errorDetails = TestRenderingFlutterBinding.instance.takeAllFlutterErrorDetails(); + errorDetails.forEach(FlutterError.reportError); +} + +RenderConstrainedBox get box200x200 => + RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 200.0, width: 200.0)); \ No newline at end of file diff --git a/packages/fleather/test/widgets/editor_test.dart b/packages/fleather/test/widgets/editor_test.dart index a064c41c..5d5b21d3 100644 --- a/packages/fleather/test/widgets/editor_test.dart +++ b/packages/fleather/test/widgets/editor_test.dart @@ -181,7 +181,7 @@ void main() { expect( editor.selection, const TextSelection.collapsed( - offset: 3, affinity: TextAffinity.downstream)); + offset: 3, affinity: TextAffinity.upstream)); }); testWidgets( From f8256318e33d790402a3d8b71f3c85cf683bcfe6 Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Thu, 30 Nov 2023 20:19:56 +0330 Subject: [PATCH 3/7] Disable lookup, search and share --- packages/fleather/lib/src/widgets/editor.dart | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/fleather/lib/src/widgets/editor.dart b/packages/fleather/lib/src/widgets/editor.dart index 889f44bb..c01c0256 100644 --- a/packages/fleather/lib/src/widgets/editor.dart +++ b/packages/fleather/lib/src/widgets/editor.dart @@ -748,13 +748,13 @@ class RawEditor extends StatefulWidget { abstract class EditorState extends State implements TextSelectionDelegate { @override - bool lookUpEnabled = true; + bool lookUpEnabled = false; @override - bool shareEnabled = true; + bool shareEnabled = false; @override - bool searchWebEnabled = true; + bool searchWebEnabled = false; ClipboardStatusNotifier? get clipboardStatus; From 4a53fbd08b118b26cb90d928a16a5f0ad0fac6f8 Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Thu, 30 Nov 2023 20:23:02 +0330 Subject: [PATCH 4/7] Format --- .../test/rendering/rendering_tools.dart | 107 +++++++++++------- 1 file changed, 67 insertions(+), 40 deletions(-) diff --git a/packages/fleather/test/rendering/rendering_tools.dart b/packages/fleather/test/rendering/rendering_tools.dart index daeff7ef..1586f238 100644 --- a/packages/fleather/test/rendering/rendering_tools.dart +++ b/packages/fleather/test/rendering/rendering_tools.dart @@ -10,12 +10,22 @@ import 'package:flutter/gestures.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/scheduler.dart'; import 'package:flutter/services.dart'; -import 'package:flutter_test/flutter_test.dart' show EnginePhase, TestDefaultBinaryMessengerBinding, fail; +import 'package:flutter_test/flutter_test.dart' + show EnginePhase, TestDefaultBinaryMessengerBinding, fail; export 'package:flutter/foundation.dart' show FlutterError, FlutterErrorDetails; -export 'package:flutter_test/flutter_test.dart' show EnginePhase, TestDefaultBinaryMessengerBinding; - -class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, ServicesBinding, GestureBinding, PaintingBinding, SemanticsBinding, RendererBinding, TestDefaultBinaryMessengerBinding { +export 'package:flutter_test/flutter_test.dart' + show EnginePhase, TestDefaultBinaryMessengerBinding; + +class TestRenderingFlutterBinding extends BindingBase + with + SchedulerBinding, + ServicesBinding, + GestureBinding, + PaintingBinding, + SemanticsBinding, + RendererBinding, + TestDefaultBinaryMessengerBinding { /// Creates a binding for testing rendering library functionality. /// /// If [onErrors] is not null, it is called if [FlutterError] caught any errors @@ -25,10 +35,11 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser /// /// Errors caught between frames will cause the test to fail unless /// [FlutterError.onError] has been overridden. - TestRenderingFlutterBinding({ this.onErrors }) { + TestRenderingFlutterBinding({this.onErrors}) { FlutterError.onError = (FlutterErrorDetails details) { FlutterError.dumpErrorToConsole(details); - Zone.current.parent!.handleUncaughtError(details.exception, details.stack!); + Zone.current.parent! + .handleUncaughtError(details.exception, details.stack!); }; } @@ -37,7 +48,8 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser /// Provides access to the features exposed by this binding. The binding must /// be initialized before using this getter; this is typically done by calling /// [TestRenderingFlutterBinding.ensureInitialized]. - static TestRenderingFlutterBinding get instance => BindingBase.checkInstance(_instance); + static TestRenderingFlutterBinding get instance => + BindingBase.checkInstance(_instance); static TestRenderingFlutterBinding? _instance; @override @@ -87,7 +99,8 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser /// Creates and initializes the binding. This function is /// idempotent; calling it a second time will just return the /// previously-created instance. - static TestRenderingFlutterBinding ensureInitialized({ VoidCallback? onErrors }) { + static TestRenderingFlutterBinding ensureInitialized( + {VoidCallback? onErrors}) { if (_instance != null) { return _instance!; } @@ -162,11 +175,13 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser onErrors!(); if (_errors.isNotEmpty) { _errors.forEach(FlutterError.dumpErrorToConsole); - fail('There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); + fail( + 'There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); } } else { _errors.forEach(FlutterError.dumpErrorToConsole); - fail('Caught error while rendering frame. See preceding logs for details.'); + fail( + 'Caught error while rendering frame. See preceding logs for details.'); } } } @@ -174,7 +189,8 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser @override void drawFrame() { - assert(phase != EnginePhase.build, 'rendering_tester does not support testing the build phase; use flutter_test instead'); + assert(phase != EnginePhase.build, + 'rendering_tester does not support testing the build phase; use flutter_test instead'); final FlutterExceptionHandler? oldErrorHandler = FlutterError.onError; FlutterError.onError = _errors.add; try { @@ -200,7 +216,8 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser if (phase == EnginePhase.flushSemantics) { return; } - assert(phase == EnginePhase.flushSemantics || phase == EnginePhase.sendSemanticsUpdate); + assert(phase == EnginePhase.flushSemantics || + phase == EnginePhase.sendSemanticsUpdate); } finally { FlutterError.onError = oldErrorHandler; if (_errors.isNotEmpty) { @@ -208,11 +225,13 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser onErrors!(); if (_errors.isNotEmpty) { _errors.forEach(FlutterError.dumpErrorToConsole); - fail('There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); + fail( + 'There are more errors than the test inspected using TestRenderingFlutterBinding.takeFlutterErrorDetails.'); } } else { _errors.forEach(FlutterError.dumpErrorToConsole); - fail('Caught error while rendering frame. See preceding logs for details.'); + fail( + 'Caught error while rendering frame. See preceding logs for details.'); } } } @@ -234,13 +253,15 @@ class TestRenderingFlutterBinding extends BindingBase with SchedulerBinding, Ser /// /// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError]. void layout( - RenderBox box, { // If you want to just repump the last box, call pumpFrame(). + RenderBox box, { + // If you want to just repump the last box, call pumpFrame(). BoxConstraints? constraints, Alignment alignment = Alignment.center, EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors, }) { - assert(box.parent == null); // We stick the box in another, so you can't reuse it easily, sorry. + assert(box.parent == + null); // We stick the box in another, so you can't reuse it easily, sorry. TestRenderingFlutterBinding.instance.renderView.child = null; if (constraints != null) { @@ -260,8 +281,10 @@ void layout( /// Pumps a single frame. /// /// If `onErrors` is not null, it is set as [TestRenderingFlutterBinding.onError]. -void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors }) { - assert(TestRenderingFlutterBinding.instance.renderView.child != null); // call layout() first! +void pumpFrame( + {EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors}) { + assert(TestRenderingFlutterBinding.instance.renderView.child != + null); // call layout() first! if (onErrors != null) { TestRenderingFlutterBinding.instance.onErrors = onErrors; @@ -272,7 +295,7 @@ void pumpFrame({ EnginePhase phase = EnginePhase.layout, VoidCallback? onErrors } class TestCallbackPainter extends CustomPainter { - const TestCallbackPainter({ required this.onPaint }); + const TestCallbackPainter({required this.onPaint}); final VoidCallback onPaint; @@ -319,7 +342,7 @@ class RenderSizedBox extends RenderBox { } @override - void performLayout() { } + void performLayout() {} @override bool hitTestSelf(Offset position) => true; @@ -327,7 +350,7 @@ class RenderSizedBox extends RenderBox { class FakeTickerProvider implements TickerProvider { @override - Ticker createTicker(TickerCallback onTick, [ bool disableAnimations = false ]) { + Ticker createTicker(TickerCallback onTick, [bool disableAnimations = false]) { return FakeTicker(); } } @@ -337,7 +360,7 @@ class FakeTicker implements Ticker { bool muted = false; @override - void absorbTicker(Ticker originalTicker) { } + void absorbTicker(Ticker originalTicker) {} @override String? get debugLabel => null; @@ -355,10 +378,10 @@ class FakeTicker implements Ticker { bool get shouldScheduleTick => throw UnimplementedError(); @override - void dispose() { } + void dispose() {} @override - void scheduleTick({ bool rescheduling = false }) { } + void scheduleTick({bool rescheduling = false}) {} @override TickerFuture start() { @@ -366,24 +389,26 @@ class FakeTicker implements Ticker { } @override - void stop({ bool canceled = false }) { } + void stop({bool canceled = false}) {} @override - void unscheduleTick() { } + void unscheduleTick() {} @override - String toString({ bool debugIncludeStack = false }) => super.toString(); + String toString({bool debugIncludeStack = false}) => super.toString(); @override DiagnosticsNode describeForError(String name) { - return DiagnosticsProperty(name, this, style: DiagnosticsTreeStyle.errorProperty); + return DiagnosticsProperty(name, this, + style: DiagnosticsTreeStyle.errorProperty); } } class TestClipPaintingContext extends PaintingContext { TestClipPaintingContext() : this._(ContainerLayer()); - TestClipPaintingContext._(this._containerLayer) : super(_containerLayer, Rect.zero); + TestClipPaintingContext._(this._containerLayer) + : super(_containerLayer, Rect.zero); final ContainerLayer _containerLayer; @@ -415,20 +440,20 @@ class TestPushLayerPaintingContext extends PaintingContext { @override void pushLayer( - ContainerLayer childLayer, - PaintingContextCallback painter, - Offset offset, { - Rect? childPaintBounds - }) { + ContainerLayer childLayer, PaintingContextCallback painter, Offset offset, + {Rect? childPaintBounds}) { pushedLayers.add(childLayer); - super.pushLayer(childLayer, painter, offset, childPaintBounds: childPaintBounds); + super.pushLayer(childLayer, painter, offset, + childPaintBounds: childPaintBounds); } } // Absorbs errors that don't have "overflowed" in their error details. void absorbOverflowedErrors() { - final Iterable errorDetails = TestRenderingFlutterBinding.instance.takeAllFlutterErrorDetails(); - final Iterable filtered = errorDetails.where((FlutterErrorDetails details) { + final Iterable errorDetails = + TestRenderingFlutterBinding.instance.takeAllFlutterErrorDetails(); + final Iterable filtered = + errorDetails.where((FlutterErrorDetails details) { return !details.toString().contains('overflowed'); }); if (filtered.isNotEmpty) { @@ -438,9 +463,11 @@ void absorbOverflowedErrors() { // Reports any FlutterErrors. void expectNoFlutterErrors() { - final Iterable errorDetails = TestRenderingFlutterBinding.instance.takeAllFlutterErrorDetails(); + final Iterable errorDetails = + TestRenderingFlutterBinding.instance.takeAllFlutterErrorDetails(); errorDetails.forEach(FlutterError.reportError); } -RenderConstrainedBox get box200x200 => - RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 200.0, width: 200.0)); \ No newline at end of file +RenderConstrainedBox get box200x200 => RenderConstrainedBox( + additionalConstraints: + const BoxConstraints.tightFor(height: 200.0, width: 200.0)); From fd20efa1d897d35c294231c0b6386c1743f8632a Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Thu, 30 Nov 2023 21:08:28 +0330 Subject: [PATCH 5/7] Suppress linter for textScaleFactor usages --- packages/fleather/lib/src/rendering/paragraph_proxy.dart | 2 ++ packages/fleather/lib/src/widgets/text_line.dart | 1 + 2 files changed, 3 insertions(+) diff --git a/packages/fleather/lib/src/rendering/paragraph_proxy.dart b/packages/fleather/lib/src/rendering/paragraph_proxy.dart index 10726184..527ca7d6 100644 --- a/packages/fleather/lib/src/rendering/paragraph_proxy.dart +++ b/packages/fleather/lib/src/rendering/paragraph_proxy.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use + import 'dart:ui'; import 'package:flutter/rendering.dart'; diff --git a/packages/fleather/lib/src/widgets/text_line.dart b/packages/fleather/lib/src/widgets/text_line.dart index 81738fcc..06cbe7b8 100644 --- a/packages/fleather/lib/src/widgets/text_line.dart +++ b/packages/fleather/lib/src/widgets/text_line.dart @@ -136,6 +136,7 @@ class _TextLineState extends State { text: text, textAlign: textAlign, strutStyle: strutStyle, + // ignore: deprecated_member_use textScaleFactor: MediaQuery.textScaleFactorOf(context), ), ); From 7d034693aa481e49f866241da1468a85455d85e8 Mon Sep 17 00:00:00 2001 From: Amir Panahandeh Date: Thu, 30 Nov 2023 21:12:33 +0330 Subject: [PATCH 6/7] Upgrade action flutter version --- .github/workflows/fleather.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/fleather.yml b/.github/workflows/fleather.yml index 53273b93..d1f78508 100644 --- a/.github/workflows/fleather.yml +++ b/.github/workflows/fleather.yml @@ -10,7 +10,7 @@ jobs: - uses: actions/checkout@v3 - uses: subosito/flutter-action@v2 with: - flutter-version: "3.13.0" + flutter-version: "3.16.0" cache: true # Manually Update this `key` cache-key: "20230512" From 4d652ecf156561af26a6fc32c5ae6e8709e40dab Mon Sep 17 00:00:00 2001 From: Alan Mantoux Date: Thu, 30 Nov 2023 20:31:11 +0100 Subject: [PATCH 7/7] Remove use of deprecated member textScaleFactor --- .../fleather/lib/src/rendering/paragraph_proxy.dart | 12 +++++------- .../fleather/lib/src/widgets/rich_text_proxy.dart | 8 ++++---- packages/fleather/lib/src/widgets/text_line.dart | 3 +-- .../test/rendering/editable_text_line_test.dart | 6 +++--- 4 files changed, 13 insertions(+), 16 deletions(-) diff --git a/packages/fleather/lib/src/rendering/paragraph_proxy.dart b/packages/fleather/lib/src/rendering/paragraph_proxy.dart index 527ca7d6..f09f6cfb 100644 --- a/packages/fleather/lib/src/rendering/paragraph_proxy.dart +++ b/packages/fleather/lib/src/rendering/paragraph_proxy.dart @@ -1,5 +1,3 @@ -// ignore_for_file: deprecated_member_use - import 'dart:ui'; import 'package:flutter/rendering.dart'; @@ -12,7 +10,7 @@ class RenderParagraphProxy extends RenderProxyBox implements RenderContentProxyBox { RenderParagraphProxy({ required TextStyle textStyle, - required double textScaleFactor, + required TextScaler textScaler, required TextWidthBasis textWidthBasis, RenderParagraph? child, TextDirection? textDirection, @@ -23,7 +21,7 @@ class RenderParagraphProxy extends RenderProxyBox text: TextSpan(text: ' ', style: textStyle), textAlign: TextAlign.left, textDirection: textDirection, - textScaleFactor: textScaleFactor, + textScaler: textScaler, strutStyle: strutStyle, locale: locale, textWidthBasis: textWidthBasis, @@ -50,9 +48,9 @@ class RenderParagraphProxy extends RenderProxyBox markNeedsLayout(); } - set textScaleFactor(double value) { - if (_prototypePainter.textScaleFactor == value) return; - _prototypePainter.textScaleFactor = value; + set textScaler(TextScaler value) { + if (_prototypePainter.textScaler == value) return; + _prototypePainter.textScaler = value; markNeedsLayout(); } diff --git a/packages/fleather/lib/src/widgets/rich_text_proxy.dart b/packages/fleather/lib/src/widgets/rich_text_proxy.dart index 7a6c90dc..e91609b9 100644 --- a/packages/fleather/lib/src/widgets/rich_text_proxy.dart +++ b/packages/fleather/lib/src/widgets/rich_text_proxy.dart @@ -11,14 +11,14 @@ class RichTextProxy extends SingleChildRenderObjectWidget { required this.locale, required this.strutStyle, required this.textAlign, - this.textScaleFactor = 1.0, + this.textScaler = TextScaler.noScaling, this.textWidthBasis = TextWidthBasis.parent, this.textHeightBehavior, }) : super(key: key, child: child); final TextStyle textStyle; final TextAlign textAlign; - final double textScaleFactor; + final TextScaler textScaler; final Locale? locale; final StrutStyle strutStyle; final TextWidthBasis textWidthBasis; @@ -29,7 +29,7 @@ class RichTextProxy extends SingleChildRenderObjectWidget { return RenderParagraphProxy( textStyle: textStyle, textDirection: Directionality.of(context), - textScaleFactor: textScaleFactor, + textScaler: textScaler, locale: locale, strutStyle: strutStyle, textWidthBasis: textWidthBasis, @@ -43,7 +43,7 @@ class RichTextProxy extends SingleChildRenderObjectWidget { renderObject.textStyle = textStyle; renderObject.textDirection = Directionality.of(context); renderObject.textAlign = textAlign; - renderObject.textScaleFactor = textScaleFactor; + renderObject.textScaler = textScaler; renderObject.locale = locale; renderObject.strutStyle = strutStyle; renderObject.textWidthBasis = textWidthBasis; diff --git a/packages/fleather/lib/src/widgets/text_line.dart b/packages/fleather/lib/src/widgets/text_line.dart index 06cbe7b8..f758a6bf 100644 --- a/packages/fleather/lib/src/widgets/text_line.dart +++ b/packages/fleather/lib/src/widgets/text_line.dart @@ -136,8 +136,7 @@ class _TextLineState extends State { text: text, textAlign: textAlign, strutStyle: strutStyle, - // ignore: deprecated_member_use - textScaleFactor: MediaQuery.textScaleFactorOf(context), + textScaler: MediaQuery.textScalerOf(context), ), ); } diff --git a/packages/fleather/test/rendering/editable_text_line_test.dart b/packages/fleather/test/rendering/editable_text_line_test.dart index f561398c..b4fbfb54 100644 --- a/packages/fleather/test/rendering/editable_text_line_test.dart +++ b/packages/fleather/test/rendering/editable_text_line_test.dart @@ -42,7 +42,7 @@ void main() { inlineCodeTheme: InlineCodeThemeData(style: const TextStyle())); renderBox.body = RenderParagraphProxy( textStyle: const TextStyle(), - textScaleFactor: 1, + textScaler: TextScaler.noScaling, child: RenderParagraph( const TextSpan( text: 'A text with that will be broken into multiple lines'), @@ -82,7 +82,7 @@ void main() { renderBox.body = RenderParagraphProxy( child: renderParagraph, textStyle: const TextStyle(), - textScaleFactor: 1, + textScaler: TextScaler.noScaling, textDirection: TextDirection.ltr, textWidthBasis: TextWidthBasis.parent); layout(renderBox); @@ -118,7 +118,7 @@ void main() { renderBox.body = RenderParagraphProxy( child: renderParagraph, textStyle: const TextStyle(), - textScaleFactor: 1, + textScaler: TextScaler.noScaling, textDirection: TextDirection.ltr, textWidthBasis: TextWidthBasis.parent); layout(renderBox);