Flutter - Add color to portion of text with intl plugin for localization - flutter

I'm using the flutter plugin Intl for localize my app, everything work great, I can use variable in my strings like
//Somewere in code
String displayname = 'toto';
S.of(context).whyDeserveSecondChance(displayName),
Which prints the correct String in the correct language with the correct displayname.
My problem here, is that I want my displayname to appear on screen with a different color, I know that I can split my string in 3 but in some language it will just not work, so I have to keep it one string with the ${displayname}
I've search all day with no luck, does someone have a clue for me?

Related

Flutter `TextFormField` with RichText or `SpanText` in `initialValue`

I have some TextFormFields that I would like to have populated with RichText or SpanText instead of String in initialValue.
Is there a packaged that can help me with this?
The reason is that I am "highligting" phone numbers, emails and links by using this neat trick described here: https://stackoverflow.com/a/58361777/4475206 and it works like a charm when using it in a 'ordinary' Text.rich widget, but not so when using TextFormField when we need to set the initialValue parameter which just accepts String.
Checkout rich_input Package. It helps you to add strings with different text styles to text field

Flutter - Text form field input format as de (German) locale

I have a TextFormField I want to accept input 12.32 as 12,32 because that's how we write float numbers in German.
I tried searching for the solution could not find it. Please comment the link if you find the solution.
EDIT
For anyone who is facing the problem, That's how I fixed it.
https://dev.to/mohitkyadav/format-double-according-to-locale-1122
To parse texts in a country/locale specific way, you can use the class NumberFormat.

Flutter-Conditional formatting based on unique characters within a string. Is it possible?

I am new to flutter and have an application that uses a realtime database composed of long text strings. I am unable to separate the string itself into different sections and am wondering if it would be possible to apply conditional formatting with RichText(). I have seen that package of easy_rich_text and wanted to do something similar, but don't see an option to modify the string after the target text has been identified.
For example, if I had a string with "Apples are /red/ fruit", I could have flutter detect the string within the // and have font color red, while the remainder is black. Is this possible? And if so, How should I go about writing code for this?
Thanks in advance
Using the package flutter_html is probably the easiest way:
Widget widget = Html(data: 'Apples are <span style="color: #ff0000">red</span> fruits');
https://api.flutter.dev/flutter/widgets/RichText-class.html
Try this. It sounds like it should do the trick.
To be clear you need to parse the string yourself and thei render the results into the widget.

How to prevent writing before prefix in GWT valuebox

I am using GWT ValeBox with GWT Renderer to show amount with $ as prefix.
Now I want not to allow user to type any thing before dollar sign. I tried various GWT event handlers like ValueChangeHandler and some others but unable to achieve goal.
Still struggling for it. If anybody know good solution for it, please share here.
Regards,
The easiest would be to not include the currency as part of the value, but next to the field.
Alternatively, you could replace the value with a numeric-only value on focus, and reformat it as a currency on blur.
Couple of solutions:
Use a label before the valuebox. Label value will be $ and valuebox will contain the numeric value.
You can use empty text in the valuebox. Empty text will specify user to enter $ value.

How to have users enter a formatted date in wicket?

I am using wicket and eclipse and trying to create a text box to have users enter a date that will format itself (i.e. user pushes keys "20130607" and in the text box they will see "2013-06-07") I've tried
...
private DateTextField <String> EffectiveDateStart;
private DateTextField <String> EffectiveDateEnd;
...
EffectiveDateStart = new DateTextField<String>("EffectiveDateStart","yyyy.MM.dd");
EffectiveDateEnd = new DateTextField<String>("EffectiveDateEnd","yyyy.MM.dd");
...
myForm.add(EffectiveDateStart);
myForm.add(EffectiveDateEnd);
...
And when I try to compile it I get the error "type org.apache.wicket.datetime.markup.html.form.DateTextField does not take parameters" even though the Java docs show parameters on the constructor. I don't think the problem is in the form because it contains other textfields and labels and it works fine right now.
Also sorry if this is a stupid question, most other examples I found gloss over actually making the box and go into how to format it. I am very new to wicket and programming.
I would do this in JavaScript. There are a lot of JQuery plugins for this. First from Google Search:
http://digitalbush.com/projects/masked-input-plugin/#demo
Here there are more:
http://plugins.jquery.com/tag/mask/
Doing it on wickets side is possible but an overkill if you ask me.