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

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)

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.

How to use GoogleFonts as default fonts in flutter app?

I'm using GoogleFonts api in my flutter app but right now I am setting the fontStyle for every text manually to GoogleFonts.roberto but I want to set that as default in ThemeData in main.dart. But the fontFamily: GoogleFonts.roberto throws an error saying expected an string value so how can I achive that?
You can use it like this to make or modify an entire text theme to use the "Roboto" font as mentioned in their official document:
MaterialApp(
theme:ThemeData(
textTheme: GoogleFonts.robotoTextTheme(
Theme.of(context).textTheme,
),
);

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,
),
)`

Flutter : Restrict price localization to english only

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.