Open stevenspiel opened 2 years ago
Steps to Reproduce Flutter documentation has this example for using Text.rich
Text.rich
const Text.rich( TextSpan( children: <InlineSpan>[ TextSpan(text: 'Flutter is'), WidgetSpan( child: SizedBox( width: 120, height: 50, child: Card( child: Center( child: Text('Hello World!') ) ), ) ), TextSpan(text: 'the best!'), ], ) ),
And the result:
But if I swap Text.rich for AutoSizeText.rich, it throws the error 'dimensions != null': is not true
AutoSizeText.rich
'dimensions != null': is not true
Code sample
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. import 'package:flutter/material.dart'; void main() => runApp(MyApp()); class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( title: 'Flutter Demo', debugShowCheckedModeBanner: false, theme: ThemeData( primarySwatch: Colors.blue, ), home: const MyHomePage(title: 'Flutter Demo Home Page'), ); } } class MyHomePage extends StatelessWidget { final String title; const MyHomePage({ Key? key, required this.title, }) : super(key: key); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text(title), ), body: Center( child: Column( mainAxisAlignment: MainAxisAlignment.center, children: const [ Text.rich(TextSpan( children: <InlineSpan>[ TextSpan(text: 'Flutter is'), WidgetSpan( child: SizedBox( width: 120, height: 50, child: Card(child: Center(child: Text('Hello World!'))), )), TextSpan(text: 'the best!'), ], )), ], ), ), ); } }
Screenshots
Stacktrace
======== Exception caught by widgets library ======================================================= The following assertion was thrown building LayoutBuilder: 'package:flutter/src/widgets/widget_span.dart': Failed assertion: line 105 pos 12: 'dimensions != null': is not true. Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause. In either case, please report this assertion by filing a bug on GitHub: https://github.com/flutter/flutter/issues/new?template=2_bug.md The relevant error-causing widget was: AutoSizeText AutoSizeText:file:///Users/me/mobile/my-app/lib/views/home.dart:71:37 When the exception was thrown, this was the stack: #2 WidgetSpan.build (package:flutter/src/widgets/widget_span.dart:105:12) #3 TextSpan.build (package:flutter/src/painting/text_span.dart:292:15) #4 TextPainter._createParagraph (package:flutter/src/painting/text_painter.dart:601:10) #5 TextPainter.layout (package:flutter/src/painting/text_painter.dart:648:7) #6 _AutoSizeTextState._checkTextFits (package:auto_size_text/src/auto_size_text.dart:406:17) #7 _AutoSizeTextState._calculateFontSize (package:auto_size_text/src/auto_size_text.dart:328:11) #8 _AutoSizeTextState.build.<anonymous closure> (package:auto_size_text/src/auto_size_text.dart:257:22) #9 _LayoutBuilderElement._layout.layoutCallback (package:flutter/src/widgets/layout_builder.dart:122:31) #10 BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2600:19) #11 _LayoutBuilderElement._layout (package:flutter/src/widgets/layout_builder.dart:156:12) #12 RenderObject.invokeLayoutCallback.<anonymous closure> (package:flutter/src/rendering/object.dart:1997:59) #13 PipelineOwner._enableMutationsToDirtySubtrees (package:flutter/src/rendering/object.dart:918:15) #14 RenderObject.invokeLayoutCallback (package:flutter/src/rendering/object.dart:1997:14) #15 RenderConstrainedLayoutBuilder.rebuildIfNecessary (package:flutter/src/widgets/layout_builder.dart:230:7) #16 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:319:5) #17 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #18 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #19 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:829:43) #20 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:931:32) #21 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #22 _RenderSingleChildViewport.performLayout (package:flutter/src/widgets/single_child_scroll_view.dart:504:14) #23 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #24 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #25 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #26 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #27 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #28 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #29 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #30 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #31 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #32 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #33 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #34 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #35 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #36 RenderPositionedBox.performLayout (package:flutter/src/rendering/shifted_box.dart:437:14) #37 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #38 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #39 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:896:45) #40 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:931:32) #41 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #42 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:233:12) #43 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #44 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #45 RenderFlex._computeSizes (package:flutter/src/rendering/flex.dart:896:45) #46 RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:931:32) #47 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #48 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:233:12) #49 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #50 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:233:12) #51 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #52 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12) #53 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1005:7) #54 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7) #55 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:403:14) #56 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #57 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #58 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #59 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #60 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1376:11) #61 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #62 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #63 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #64 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #65 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #66 RenderPadding.performLayout (package:flutter/src/rendering/shifted_box.dart:233:12) #67 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #68 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #69 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:570:43) #70 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:597:12) #71 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #72 _RenderLayoutBuilder.performLayout (package:flutter/src/widgets/layout_builder.dart:321:14) #73 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #74 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12) #75 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1005:7) #76 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7) #77 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:403:14) #78 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #79 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #80 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #81 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #82 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1376:11) #83 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #84 MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12) #85 _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:1005:7) #86 MultiChildLayoutDelegate._callPerformLayout (package:flutter/src/rendering/custom_layout.dart:240:7) #87 RenderCustomMultiChildLayoutBox.performLayout (package:flutter/src/rendering/custom_layout.dart:403:14) #88 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #89 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #90 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #91 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #92 _RenderCustomClip.performLayout (package:flutter/src/rendering/proxy_box.dart:1376:11) #93 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #94 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #95 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #96 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #97 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #98 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #99 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #100 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #101 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:570:43) #102 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:597:12) #103 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #104 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #105 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #106 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #107 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #108 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #109 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #110 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #111 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #112 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #113 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #114 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #115 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #116 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #117 RenderOffstage.performLayout (package:flutter/src/rendering/proxy_box.dart:3430:13) #118 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #119 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #120 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #121 _RenderTheatre.performLayout (package:flutter/src/widgets/overlay.dart:751:15) #122 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #123 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #124 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #125 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #126 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #127 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #128 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #129 RenderConstrainedBox.performLayout (package:flutter/src/rendering/proxy_box.dart:277:14) #130 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #131 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #132 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:570:43) #133 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:597:12) #134 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #135 ChildLayoutHelper.layoutChild (package:flutter/src/rendering/layout_helper.dart:56:11) #136 RenderStack._computeSize (package:flutter/src/rendering/stack.dart:570:43) #137 RenderStack.performLayout (package:flutter/src/rendering/stack.dart:597:12) #138 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #139 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #140 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #141 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #142 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #143 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #144 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #145 RenderProxyBoxMixin.performLayout (package:flutter/src/rendering/proxy_box.dart:116:14) #146 RenderObject.layout (package:flutter/src/rendering/object.dart:1887:7) #147 RenderView.performLayout (package:flutter/src/rendering/view.dart:165:14) #148 RenderObject._layoutWithoutResize (package:flutter/src/rendering/object.dart:1731:7) #149 PipelineOwner.flushLayout (package:flutter/src/rendering/object.dart:887:18) #150 RendererBinding.drawFrame (package:flutter/src/rendering/binding.dart:497:19) #151 WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:883:13) #152 RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5) #153 SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15) #154 SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9) #155 SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:862:7) (elided 6 frames from class _AssertionError, class _RawReceivePortImpl, class _Timer, and dart:async-patch) ====================================================================================================
Version
There's some discussion about this here: https://github.com/leisim/auto_size_text/issues/61
Steps to Reproduce Flutter documentation has this example for using
Text.rich
And the result:
But if I swap
Text.rich
forAutoSizeText.rich
, it throws the error'dimensions != null': is not true
Code sample
Screenshots
Stacktrace
Version