Skip to content

A text layout should be able to have indents for consecutive sentences or for the first sentence #12255

@johanhenselmans

Description

@johanhenselmans

Steps to Reproduce

I am trying to layout a poem: when the text line is too long for the widget width, the line should be softwrapped to the next line, with an indent: everybody understands that the sentence should have been on one line.

Also, it is quite familiar to indent the first line of a paragraph. So it should be possible to somehow do s softwrap indent or a first line indent (this could also be negative, so the first line of a sentence protrudes to the left in the case of left-to-right example.

At the moment I resolved it by creating a function that calculates the width of words in a sentence, and when the sentence is too long for the width of the widget, insert a newline and some spaces.

The calculation however, is crude: it does not take into account ligatures and different widths of characters.
img_0428
img_0427

If the problem is with your application's rendering, please attach a screenshot and any relevant source code.
If you are getting an exception in the logs, and your code is implicated in the first few frames, then please include the source code for the functions involved.

Logs

Run your application with flutter run and attach all the log output.

Run flutter analyze and attach any output of that command also.

Flutter Doctor

Paste the output of running flutter doctor here.
breitlings:examples johan [master] $ flutter doctor
[✓] Flutter (on Mac OS X 10.13 17A365, locale en, channel master)
• Flutter at /Applications/Developing/flutter
• Framework revision a08b5e0 (9 hours ago), 2017-09-25 18:56:37 -0700
• Engine revision 0052126
• Tools Dart version 1.25.0-dev.11.0

[✓] Android toolchain - develop for Android devices (Android SDK 26.0.1)
• Android SDK at /Applications/Developing/android-sdk-mac_x86
• Platform android-26, build-tools 26.0.1
• ANDROID_HOME = /Applications/Developing/android-sdk-mac_x86
• Java binary at: /Applications/Developing/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 9.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 9.0, Build version 9A235
• ios-deploy 1.9.2
• CocoaPods version 1.3.1

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

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

[✓] IntelliJ IDEA Community Edition (version 2017.2.4)
• Flutter plugin version 17.0
• Dart plugin version 172.4155.35

[✗] Cannot determine if IntelliJ is installed
✗ Directory listing failed

[✓] Connected devices
• LG H440n • LGH440n1a15d72 • android-arm • Android 6.0 (API 23)
• iPad van Johan • bd30d3f168d079bd5e41a905a26d8c040afcd02a • ios • iOS 11.0

For more information about diagnosing and reporting Flutter bugs, please see https://flutter.io/bug-reports/.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions