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

The Html widget had two issues in the Container widget with the maxWidth property. #222

Closed
gzlock opened this issue Jan 31, 2020 · 2 comments

Comments

@gzlock
Copy link

gzlock commented Jan 31, 2020

flutter_html version: 0.11.1

flutter doctor:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.12.13+hotfix.7, on Mac OS X 10.15.3 19D76, locale zh-Hans-CN)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[!] IntelliJ IDEA Ultimate Edition (version 2019.3.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
    ✗ Dart plugin not installed; this adds Dart specific functionality.
[✓] Connected device (2 available)

Code:

/// The message contents
/// First message data: 'short message'
/// Second message data: 'message include images, line 1'
///            '<img src="http://via.placeholder.com/350x350/d89cf6">'
///            '<div>line 2</div>'
///            '<img src="http://via.placeholder.com/350x350/d89cf6">'
/// Third message data: 'multiple lines<br/>line 1\nline 2'
final screen = MediaQuery.of(context).size;
Container(
      padding: EdgeInsets.only(left: 5, right: 5, top: 8, bottom: 8),
      constraints: BoxConstraints(maxWidth: screen.width * 0.6),
      decoration: BoxDecoration(
        color: Color.blue,
      ),
      child: Html(
        imageProperties: ImageProperties(
          width: 200,
          fit: BoxFit.fitWidth,
        ),
        data: message.message,
        useRichText: true,
        shrinkToFit: true,
        defaultTextStyle: TextStyle(color: Colors.white),
        renderNewlines: true,
        customTextAlign: (e) => TextAlign.left,
      ),
    );

The first issue:

When the 'useRichText' and 'shrinkToFit' properties both set true,

The "line 2" is centered even if I set customTextAlign: (e) => TextAlign.left

image

How to set the column(belongs to the HtmlRichTextParser) crossAxisAlignment to CrossAxisAlignment.start?

image


The second issue:

When I set the 'useRichText' property to false, the 'line 2' was align to left, well done.

But the multiple line bubble was filled with max width.

It looks like the 'shrinkToFit' property is invalid.

image

@Sub6Resources
Copy link
Owner

Try using version 1.0.0-pre.1.

@Sub6Resources
Copy link
Owner

Closing, since this appears to have fixed your issue. Let me know if you continue to have issues!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants