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
property styles #367
Comments
Why do you need to parse the |
when i need to apply changes to incoming styles. |
Ah I see, it's possible we will make the parsed key-value pairs available during |
Making it easier for users of this package to handle inline styles and/or customize rendering behaviors. Related to #367
Making it easier for users of this package to handle inline styles and/or customize rendering behaviors. Related to #367
Version import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
/// in your `WidgetFactory` or `BuildOp`
for (final style in meta.element.styles) {
print('${style.key}=${style.value}');
} Please try upgrading and let me know whether it works for you. Thank you. |
as far as i understand i cannot use this in the custom styles builder? |
No problem, you can use it in HtmlWidget(
html,
customStylesBuilder: (element) {
for (final style in element.styles) {
if (style.key == 'foo') {
return {'foo': 'bar'};
}
}
return null;
},
), |
It is not a field, it is an extension. Does your |
as i'm saying, nope. |
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart'; That should be enough. If you follow that import, it will |
I think I have figured it out. In the first version of your code, you used It's possible to skip the typing completely, using |
nope, using import as dom was the first thing i did. |
I have just revisited this with Flutter 2 and it seems to work fine. import 'package:flutter/material.dart';
import 'package:flutter_widget_from_html/flutter_widget_from_html.dart';
import 'package:html/dom.dart' as dom;
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Issue 367'),
),
body: HtmlWidget(
'Foo',
customStylesBuilder: (dom.Element element) {
for (final style in element.styles) {
if (style.key == 'foo') {
return {'foo': 'bar'};
}
}
return null;
},
),
);
}
} |
Yeah, on 2.0 seems to be working fine with either of |
would be real nice to add property styles to element in custom styles builder so people won't need to write smth like this every time they need to parse style properties
The text was updated successfully, but these errors were encountered: