Skip to content

use TextDecoration.none The text cannot be aligned #454

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

Closed
AntonXu opened this issue Nov 19, 2020 · 9 comments
Closed

use TextDecoration.none The text cannot be aligned #454

AntonXu opened this issue Nov 19, 2020 · 9 comments

Comments

@AntonXu
Copy link

AntonXu commented Nov 19, 2020

use TextDecoration.none The text cannot be aligned

1605785978708

@erickok
Copy link
Contributor

erickok commented Nov 20, 2020

Could you elaborate a bit? What html are you using? Which style rules? Which version of flutter_html?

@AntonXu
Copy link
Author

AntonXu commented Nov 22, 2020

Could you elaborate a bit? What html are you using? Which style rules? Which version of flutter_html?

environment
`[flutter] flutter doctor -v
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale zh-Hans-CN)
• Flutter version 1.22.4 at /Users/anton/Applications/flutter
• Framework revision 1aafb3a8b9 (9 days ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at /Users/anton/Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
• All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.2, Build version 12B45b
• CocoaPods version 1.10.0

[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 48.1.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

[✓] VS Code (version 1.51.1)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.16.0

[✓] Connected device (2 available)
• iPhone 12 Pro Max (mobile) • ED1FFCFC-63B1-4028-9117-52547EA11923 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-2 (simulator)

• No issues found!
exit code 0`

flutter_html version
flutter_html: ^1.0.2

code:

`import 'package:flutter/material.dart';
import 'package:flutter_html/flutter_html.dart';
import 'package:flutter_html/html_parser.dart';
import 'package:flutter_html/style.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@OverRide
Widget build(BuildContext context) {
return new MaterialApp(
title: 'Flutter Demo',
theme: new ThemeData(
primarySwatch: Colors.deepPurple,
),
home: new MyHomePage(title: 'flutter_html Example'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;

@OverRide
_MyHomePageState createState() => new _MyHomePageState();
}

const htmlData = """

  <ol>
        <li>This</li>
        <li><p>is</p></li>
        <li>an</li>
        <li>
        ordered
        <ul>
        <li>With<br /><br />...</li>
        <li>a</li>
        <li>nested</li>
        <li>unordered
        <ol>
        <li>With a nested</li>
        <li>ordered list.</li>
        </ol>
        </li>
        <li>list</li>
        </ul>
        </li>
        <li>list! Lorem ipsum dolor sit amet.</li>
        <li><h2>Header 2</h2></li>
        <h2><li>Header 2</li></h2>
  </ol>
  <h3>Link support:</h3>
  <p>
     中文<a href='https://github.com'>中文链接 Url Link</a>中文 has never been easier.
  </p>
  <h3>Image support:</h3>
  <p>
    <img alt='Google' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' />
    <a href='https://google.com'><img alt='Google' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30dp.png' /></a>
    <img alt='Alt Text of an intentionally broken image' src='https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_92x30d' />
  </p>

""";

class _MyHomePageState extends State {
@OverRide
Widget build(BuildContext context) {
return new Scaffold(
appBar: AppBar(
title: Text('flutter_html Example'),
centerTitle: true,
),
body: SingleChildScrollView(
child: Html(
data: htmlData,
//Optional parameters:
style: {
"html": Style(
backgroundColor: Colors.black12,
// color: Colors.white,
),
// "h1": Style(
// textAlign: TextAlign.center,
// ),
"a": Style(
textDecoration:TextDecoration.none,
),
"table": Style(
backgroundColor: Color.fromARGB(0x50, 0xee, 0xee, 0xee),
),
"tr": Style(
border: Border(bottom: BorderSide(color: Colors.grey)),
),
"th": Style(
padding: EdgeInsets.all(6),
backgroundColor: Colors.grey,
),
"td": Style(
padding: EdgeInsets.all(6),
),
"var": Style(fontFamily: 'serif'),
},
customRender: {
"flutter": (RenderContext context, Widget child, attributes, _) {
return FlutterLogo(
style: (attributes['horizontal'] != null)
? FlutterLogoStyle.horizontal
: FlutterLogoStyle.markOnly,
textColor: context.style.color,
size: context.style.fontSize.size * 5,
);
},
},
onLinkTap: (url) {
print("Opening $url...");
},
onImageTap: (src) {
print(src);
},
onImageError: (exception, stackTrace) {
print(exception);
},
),
),
);
}
}
`
I used the code of the example directly and added the following style only.

"a": Style( textDecoration:TextDecoration.none, ),

Did I do something wrong?
Thanks!

@erickok
Copy link
Contributor

erickok commented Nov 23, 2020

The TextDecoration is the underline style. You probably also want to override the color of the link text (for example color: Colors.black). Or do you mean the alignment is not correct? Sorry your example code is very hard to hear without formatting.

@erickok
Copy link
Contributor

erickok commented Nov 23, 2020

Hmm I think I can reproduce this with latin text too. The links make the alignment go off.

Screenshot 2020-11-23 at 15 36 49

@AntonXu
Copy link
Author

AntonXu commented Nov 24, 2020

@erickok

Sorry, Due to the particularity of Chinese, my links do not use underline. What should I do?

I use this example
https://github.com/Sub6Resources/flutter_html/blob/master/example/lib/main.dart

1606181415349

I added the following style only.

"a": Style( textDecoration:TextDecoration.none, ),

But The text cannot be aligned

aa

I don't know if that I said clearly.

This issue is not exist in version ^0.11.1 , but in version ^1.0.2

Thank you!

@AntonXu
Copy link
Author

AntonXu commented Nov 24, 2020

This issue does not exist in version ^0.11.1 , but in version ^1.0.2

@erickok
Copy link
Contributor

erickok commented Nov 24, 2020

Yes I agree. This is an issue.

@AntonXu
Copy link
Author

AntonXu commented Nov 24, 2020

@erickok
Hmm, I'm looking forward to fixing it. Thank you!

@erickok
Copy link
Contributor

erickok commented Feb 8, 2021

Should be fixed in #499

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