Comments (5)
I havent thought about that yet! I am always open for suggestions on how to do anything.
The implementation would be something like this:
Text.rich(TextSpan(children: [
TextSpan(text: 'some text')
.bold(),
TextSpan(text: 'more text')
.italic(),
])
I havent used TextSpan myself before so i am open to other suggestions.
I cannot guarantee that i actually will implement this feature eighter. At the moment i am developing the package by myself and my time is somewhat limited.
It is very easy to learn how the package works and to implement it by yourself if you want the feature, or want to contribute. I am very open for pull requests
from styled_widget.
Ok cool, I have experimented already a bit.
The Text
widget has 2 (mutual exclusive) constructors which makes this a bit harder since extensions can't have constructors, so I tried some things using static methods to achieve a 'short' API:
extension StyledTextWithSpans on Text {
static Text withSpans(List<TextSpan> children) => Text.rich(TextSpan(
children: children,
));
}
extension StyledTextSpan on TextSpan {
...
}
StyledTextWithSpans.withSpans([
TextSpan(text: 'Regular text, and '),
TextSpan(text: 'bold text').textColor(Colors.green).bold(),
]),
However, I realise that the static utility method might not be suitable to be included in this library (maybe in the Flutter framework itself or just in my own code), so it indeed comes down to the API you suggested.
I'll see if I can make a PR out of just the TextSpan
extension.
from styled_widget.
Its best to keep it as close to "native flutter" as possible and only changing whats really needed. With the example i gave above the only thing that has to be implemented is the styled methods for TextSpan
. And these method would basicly be the same as the styled methods for Text
. Eighter you could just copy most of the methods from the Text
extension, or they could share the same methods by having a common mixin
which both of them include. I dont think the last option is currently possible.
If you just use Text.rich()
it would make it a bit easier i think. As i said, rely as much as possible on the flutter framework.
Looking forward to seeing what you come up with!
from styled_widget.
Thanks for helping out on this so quickly! 👍
from styled_widget.
#13 Feature implemented
from styled_widget.
Related Issues (20)
- Documentation lacks many many of the stuff already present inthe tool and is not updated. HOT 1
- overflow property has been removed from Stack in latest master HOT 5
- Newfeature : Add selectable merhod HOT 2
- Null Safety Migration HOT 4
- Animation for all widgets
- Add support for "EdgeInsetsDirectional" in the "padding" extension method! HOT 2
- Make extension params nullable HOT 2
- Null-safety issue with animated translate HOT 7
- adding .toWrap() HOT 1
- Wiki Demo App Missing Argument HOT 2
- How do I know which menu item has been clicked? HOT 1
- Error with animated text when maxLines specified HOT 3
- v0.4.0 - opacity in widget extension got key as positioned parameter HOT 1
- Add dismiss HOT 1
- Effect on Performance HOT 4
- name conflicts with the origin properties HOT 6
- styled_widget
- Deploy the latest version to pub dev . HOT 2
- The border radius method is missin the clip behaiviour input HOT 1
- lint as dev dependency
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from styled_widget.