Flutter : Restrict price localization to english only - flutter

My app supports two localizations 1] English 2] Arabic. Localization is working perfectly throughout the app.
But there are certain scenarios where I need to show text only in the English language but app changing it to as per selected localization. So all prices are shown in Arabic for Arabic localization.
I tried to put explicit Locale (NOT sure whether it is supposed to do like this) in a Text widget but still, that didn't work for me.
Text('3434', // Dynamic String from server
locale: Locale('en'),
style: TextStyle(fontSize: 16))
Actual Result When Arabic Localization is selected :
Expected Result :

set font-family specifically to those texts that doesn't need the arabic font. That way, it will override the default one.

We need to set fontFamily to Text Widget to whichever language-specific you want. For me, I just set the fontFamily like this,
Text(
value,
style: TextStyle(fontSize: 16, fontFamily: 'OpenSans'),
),
Hope this will be useful for someone.

Text(item.price, textDirection: TextDirection.ltr,) will make the TextDirection to be always in English 'ltr' left to right.
I hope that helps.

Related

how can I use both sub font family in my app?

I am using font-family called "FFShamelFamily". I added two sub-font families as shown in the picture below. When I run my app, it uses the first sub-fontFamily: "SansOneBook" only. I try to use fontWeight to make use of the second sub-fontFamily:"SansOneBold" but it doesn't show. I mean that I want to use both of the sub-FontFamily, the bold one for titles and the other one for any text in the app. How can I do it?
When using a custom font you need to specify which FontFamily to use on a TextStyle. Your “sub” font FFShamelFamily-SansOneBold is correctly set up in your pubspec.yaml as a weight variation of the same Font Family.
To use it in a textStyle you simply have to use the weight you set it to with the correct family name:
Text(
“Hello, world”,
style: TextStyle(
fontFamily: “FFShamelFamily”,
fontWeight: FontWeight.w900,
),
)
Please check the official flutter documentation for using custom fonts to learn more.

Where are inbuilt icons in flutter located (default location in flutter folder)

I want to use flutter inbuilt icons as assets. So I want default location where all of flutter icons are located in flutter folder of flutter installation.
This would seem to imply that there's a fontFamily named 'MaterialIcons'. Not sure you can get it easily from any part of the Flutter distro, but https://material.io/resources/icons/ will show how to download or reference the font for your material designs.
static const IconData ac_unit_outlined = IconData(0xe005, fontFamily: 'MaterialIcons')
I don't think they are. If you look at the IconData class (https://api.flutter.dev/flutter/widgets/IconData-class.html). You will see that the description says 'A description of an icon fulfilled by a font glyph.'
Taking an example of one of the Icon values:
static const IconData list_alt = IconData(0xe81b, fontFamily: 'MaterialIcons');
I believe what that is telling us is that the Icon is being defined by the position 0xe81b in the Unicode font family called MaterialIcons
Not an answer to the original question, but likely tangentially helpful...
To visually identify & search/filter icons, both from the included MaterialIcons from Google and those created by the Community, check out:
https://materialdesignicons.com/
And to use them, the related pub.dev package for material_design_icons_flutter.

Flutter Text misaligned but textBaseline does not fix it

When trying to underline a mix of English and Japanese (or Chinese or Korean), the underline is not aligned, even when textBaseline is set to ideographic.
Code used to produce the above image:
Text(
"可愛い lovely",
style: TextStyle(
fontSize: 48,
decoration: TextDecoration.underline,
textBaseline: TextBaseline.ideographic,
),
),
I thought the main purpose of ideographic text baseline is to address problems like this, but it made no visible differences. How should textBaseline be used then? And, is there any way to solve the underline misalignment issue in this case?
Edit:
Thanks to user #AnasMohammed pointing out the issue cannot be reproduced on DartPad, I then tried both Android and iOS. Seems like the problem only exists on Android. Sample results and "full code" available: https://i.imgur.com/jOeO5th.png

how to copy custom text in flutter to clipboard?

need a way to copy a custom text that i give it a font-style and other styles if possible in my flutter app, currently while working on my app i can copy the text i want to clipboard and use it later but with out any style.
this is how now i copy the text which dont work for me the way i want.
ClipboardData data = ClipboardData(text:sample);
Clipboard.setData(data);`
this is how i can copy the default text but insted i want to copy a custom text like next.
Text(
sample,
style: TextStyle(
fontSize: 20,
fontFamily: IndieFlower,
),
)`

accessibility does not read some text in flutter how to fix that?

In my new flutter app faild on accessibility test. Some text such as hint text and some other text does not recogonize the accessibility. How to fix that ?
There is 6 tiles in my home screem every tile contain logo and Text. Text contain both english and thai. Some text are read by Accessibility, some text speech english only. I need to read both English and Thai ?.
You can use TextSpan.locale to specify which voice that the screen reader should use.
const Text.rich(
TextSpan(children: [
TextSpan(text: 'UK text. ', locale: Locale('en', 'UK')),
TextSpan(text: 'American text. ', locale: Locale('en', 'US')),
TextSpan(text: 'Dansk text. ', locale: Locale('da', 'DK')),
]),
),
Unfortunately this seem to be the only way we can currently affect which voice that assistive technology should use in Flutter.
On Flutter web and windows, TextSpan.locale is currently not working. (issue#98949)