How to make simple internationalization with flutter without json file? - flutter

I search to internationalize my app. I have lot of text, I search a simple and fast way to add english trad to my all text.
Here is the structure of all my text
Text('Mytext',
textAlign:TextAlign.center, style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontSize: SizeConfig.safeBlockHorizontal! * 4),
),
I don't know if there is a package of methode to add internationalization like an extention
Text('Mytext.internationalization',
textAlign:TextAlign.center, style: TextStyle(
color: Colors.black,
fontWeight: FontWeight.w400,
fontSize: SizeConfig.safeBlockHorizontal! * 4),
),
If I can avoid to copy paste all my test to a JSON file and trad all, and change all my text structure it will be cool :)

Related

How do implement customMenuBuilder into selectable text class

SelectableText('text',
cursorColor: Colors.red,
showCursor: true,
style: const TextStyle(
fontSize: 14,
fontWeight:
FontWeight.w500,
color: Colors.black))
I initially used toolbar options in the code, but now it has been deprecated and I'm trying to implement customMenuBuilder into the code so as to copy the text that would appear in the text field.

Text is shifted vertically in Flutter

I have the following code:
AutoSizeText.rich(
TextSpan(children: [
const TextSpan(
text: "\$",
style: TextStyle(
color: Colors.white,
fontSize: 45,
height: 1.0,
letterSpacing: .0,
fontWeight: FontWeight.w600,
),
),
TextSpan(
text: widget.budget.truncate().toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 90,
),
),
TextSpan(
text: ".${widget.budget.toStringAsFixed(2).split(".")[1]}",
style: const TextStyle(
color: Colors.white,
fontSize: 45,
),
),
]),
style: GoogleFonts.manrope(
fontSize: 45,
letterSpacing: -4.5,
height: 1.0,
fontWeight: FontWeight.w600,
textStyle: const TextStyle(
leadingDistribution: TextLeadingDistribution.even,
)),
textAlign: TextAlign.center,
maxLines: 1,
);
The code results in this (I also tried with Text.rich instead of AutoSizeText but the result is the same):
In the image, I have wrapped the text in a red container to check its bounding box.
I am implementing this element following a design I made in Figma:
Similatly, in this image the red frame has an autolayout applied with all padding set to 0, in a way that simulates wrapping the text in a Container.
The text looks the same in both the design and the Flutter implementation, but the Flutter one is shifted upwards, which on big text sizes is really noticeable. I figured it might have something to do with the vertical alignment of the text but I could not find any way to fix it.
Is this an expected behaviour or am I doing something wrong?

Quicksand bold not rendering as expected when bold

As in picture R & A word is...
Here are my code as in picture below
child: Text(
'RENTAL SUMMARY',
style: TextStyle(
fontFamily: 'quicksand',
color: Colors.black,
fontWeight: FontWeight.bold,
fontSize: 20,
),
),
Please download the quicksand font from Google fonts. Add this to your pubspec yaml and try again. Maybe the ttf you have is corrupted

How to override theme style in flutter

Hi i need text style for example bodyText3,like this
bodyText3: TextStyle(
fontSize: 16,
height: 1.5,
fontWeight: FontWeight.w600,
color: MyColors.black)
but in flutter we have only this styles.
headline1,
headline2,
headline3,
headline4,
headline5,
headline6,
subtitle1,
subtitle2,
bodyText1,
bodyText2,
caption,
What should i do to add my new style ?
Create a Constant to define the style
const TextStyle bodyText3 = TextStyle(
fontSize: 14,
color: darkGrey,
fontWeight: FontWeight.w700,
);
Use this constant in your Text's style property
Text(
'No',
style: bodyText3,
),

How to include multiple fonts into single text

I have an Arabic text in a pdf file. When I copy the text into Text Widget it becomes weird characters. When I checked the pdf file properties I found that it uses HQPB1, HQPB2, HQPB3, HQPB4 fonts, so I imported all of these fonts to my pubsec.yaml file. The problem is that I can use only one of these 4 fonts at a time but the pdf file uses all of these 4 fonts simultaneously.
this is the original text from pdf
when I added HQPB1.ttf only
when I added HQPB2.ttf only
So I want to include all of these 4 fonts in a Text so that each individual font should be used when it is needed as pdf does.
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(text: 'Hello ', style: TextStyle(fontFamily: "Serif", fontSize: 30, color: Colors.black)),
TextSpan(text: 'bold', style: TextStyle(fontWeight: FontWeight.bold, color: Colors.blue, fontSize: 30)),
TextSpan(text: ' world!', style: TextStyle(fontFamily: "Roboto", fontSize: 30, color: Colors.red)),
],
),
)
Output:
In order to have multiple styles on one Text widget you have to use RichText. RichText has a children[] so you can have custom TextStyle (which will use whatever font you want) for each TextSpan
Check it out here -> https://api.flutter.dev/flutter/widgets/RichText-class.html
const Text.rich(
TextSpan(
children: <TextSpan>[
TextSpan(
text: 'Hello ',
style: TextStyle(
fontFamily: "Serif",
fontSize: 30,
color: Colors.black,
),
),
TextSpan(
text: 'bold',
style: TextStyle(
fontFamily: "Arial",
fontWeight: FontWeight.bold,
color: Colors.blue,
fontSize: 30,
),
),
TextSpan(
text: ' world!',
style: TextStyle(
fontFamily: "Roboto",
fontSize: 30,
color: Colors.red,
),
),
],
),
)