Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception with TextField when maxLines = null #12046

Closed
amardeep opened this issue Sep 12, 2017 · 8 comments · Fixed by #12833
Closed

Exception with TextField when maxLines = null #12046

amardeep opened this issue Sep 12, 2017 · 8 comments · Fixed by #12833
Assignees
Labels
a: text input Entering text in a text field or keyboard related problems c: crash Stack traces logged to the console f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.

Comments

@amardeep
Copy link

amardeep commented Sep 12, 2017

I want a TextField with no limit on the number of lines.

https://docs.flutter.io/flutter/material/TextField/maxLines.html suggests that maxLines should be set to null.
But that throws an exception.

To reproduce, add a TextField with maxlines=null, type any text, and then click/tap on the text. I see the following error when running on ios simulator on the following line:

return new CompositedTransformFollower(
      ...
          children: <Widget>[
            new Positioned(
              left: point.dx,
              top: point.dy,
              child: widget.selectionControls.buildHandle(
                context,
                type,
                widget.renderObject.size.height / widget.renderObject.maxLines,
      ...
    );
══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
The following NoSuchMethodError was thrown building _TextSelectionHandleOverlay(dirty, state:
_TextSelectionHandleOverlayState#29ce3):
The method 'toDouble' was called on null.
Receiver: null
Tried calling: toDouble()
When the exception was thrown, this was the stack:
#0      Object._noSuchMethod (dart:core-patch/object_patch.dart:42)
#1      Object.noSuchMethod (dart:core-patch/object_patch.dart:46)
#2      double./ (dart:core-patch/double.dart:39)
#3      _TextSelectionHandleOverlayState.build (package:flutter/src/widgets/text_selection.dart:512:49)
#4      StatefulElement.build (package:flutter/src/widgets/framework.dart:3628:27)
#5      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3538:15)
#6      Element.rebuild (package:flutter/src/widgets/framework.dart:3439:5)
#7      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3518:5)
#8      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3656:22)
#9      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3513:5)
#10     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2882:14)
#11     Element.updateChild (package:flutter/src/widgets/framework.dart:2685:12)
#12     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4520:14)
#13     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2882:14)
#14     Element.updateChild (package:flutter/src/widgets/framework.dart:2685:12)
#15     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3550:16)
#16     Element.rebuild (package:flutter/src/widgets/framework.dart:3439:5)
#17     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3518:5)
#18     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3656:22)
#19     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3513:5)
#20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2882:14)
#21     Element.updateChild (package:flutter/src/widgets/framework.dart:2685:12)
#22     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3550:16)
#23     Element.rebuild (package:flutter/src/widgets/framework.dart:3439:5)
#24     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3518:5)
#25     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3656:22)
#26     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3513:5)
#27     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2882:14)
#28     Element.updateChild (package:flutter/src/widgets/framework.dart:2685:12)
#29     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4312:32)
#30     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4635:17)
#31     Element.updateChild (package:flutter/src/widgets/framework.dart:2674:15)
#32     _TheatreElement.update (package:flutter/src/widgets/overlay.dart:507:16)
#33     Element.updateChild (package:flutter/src/widgets/framework.dart:2674:15)
#34     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3550:16)
#35     Element.rebuild (package:flutter/src/widgets/framework.dart:3439:5)
#36     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2260:33)
#37     BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:530:20)
#38     BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:194:5)
#39     BindingBase&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:713:15)
#40     BindingBase&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:649:9)
#41     _invoke (file:///b/build/slave/Mac_Engine/build/src/flutter/lib/ui/hooks.dart:86)
#42     _drawFrame (file:///b/build/slave/Mac_Engine/build/src/flutter/lib/ui/hooks.dart:75)
════════════════════════════════════════════════════════════════════════════════════════════════════
Another exception was thrown: NoSuchMethodError: The method 'toDouble' was called on null.

Flutter Doctor

Paste the output of running flutter doctor here.

flutter doctor
[✓] Flutter (on Mac OS X 10.12.5 16F73, locale en-US, channel alpha)
• Flutter at /Users/amardeep/soft/flutter
• Framework revision 1c372c6 (12 days ago), 2017-08-31 15:54:45 -0700
• Engine revision f9e00a7
• Tools Dart version 1.25.0-dev.11.0

[✓] Android toolchain - develop for Android devices (Android SDK 26.0.1)
• Android SDK at /Users/amardeep/Library/Android/sdk
• Platform android-26, build-tools 26.0.1
• ANDROID_HOME = /Users/amardeep/Library/Android/sdk
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] iOS toolchain - develop for iOS devices (Xcode 8.3.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 8.3.3, Build version 8E3004b
• ios-deploy 1.9.1
• CocoaPods version 1.2.1

[✓] Android Studio
• Android Studio at /Applications/Android Studio 3.0 Preview.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b736)

[✓] Android Studio (version 2.3)
• Android Studio at /Applications/Android Studio.app/Contents
• Java version OpenJDK Runtime Environment (build 1.8.0_112-release-b06)

[✓] Connected devices
• iPhone 6 • 0E6F51C9-C9EA-499C-83FB-7637FF9B1305 • ios • iOS 10.3 (simulator)

@Hixie Hixie added this to the 3: Current Milestone milestone Sep 12, 2017
@Hixie Hixie added a: text input Entering text in a text field or keyboard related problems framework flutter/packages/flutter repository. See also f: labels. f: material design flutter/packages/flutter/material repository. labels Sep 12, 2017
@gspencergoog gspencergoog self-assigned this Sep 15, 2017
@gspencergoog gspencergoog assigned xster and unassigned gspencergoog Sep 18, 2017
@gdomingues
Copy link

I'm facing the same issue here. In the meanwhile I just set a huge number of lines (20) in order to prevent this exception being thrown.

@Hixie Hixie added the c: crash Stack traces logged to the console label Oct 3, 2017
@gusmd
Copy link

gusmd commented Oct 5, 2017

Just stumbled upon this. @gdomingues suggestion does help with the exception, but has the side-effect of making the TextField height become that of maxLines lines of text even without any text.

@pcomans
Copy link

pcomans commented Oct 17, 2017

+1 this is blocking us as well.

@sethladd
Copy link
Contributor

If you're blocked on this, or really want to see this fixed, please "thumbs up" this issue. That helps us easily sort bugs and requests. Thank you!

@eseidelGoogle
Copy link
Contributor

@maryx mentioned today that this is blocking her app.

@Hixie
Copy link
Contributor

Hixie commented Nov 1, 2017

cc @jason-simmons who said he would take a look

@vemarav
Copy link

vemarav commented May 14, 2018

@amardeep
maxLines: null works if you specify keyboardType: TextInputType.text

Here Working Example

maxlines_issue

DaveShuckerow pushed a commit to DaveShuckerow/flutter that referenced this issue May 14, 2018
@github-actions
Copy link

github-actions bot commented Sep 3, 2021

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems c: crash Stack traces logged to the console f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet