i used this article
https://www.thirdrocktechkno.com/blog/how-to-implement-localization-in-flutter
to make my app multilang.
and i want to fit the banner in my app (no google ads) to the correct lang and correct on_tap
for example now i have just one:
GestureDetector(
child: Column(children: [
Image(
image: AssetImage('assets/me.jpg'), // Here i want to use another image for each lang...
),
]),
onTap: () {
openUrl();
},
),
I use flutter_localizations.
thank you.
I don't have much experience with localization but you can try localizing the pathname.
For example
English pathname: assets/me_en.jpg
Spanish pathname: assets/me_es.jp
... and so on.
Related
I use the easy localization package, how can I check and change the language with just one button?
https://pub.dev/packages/easy_localization
TextButton(
onPressed: () {
// 'En'
// 'Ar'
},
child: Text('Switch lang'),
)
You need to have JSON file for changing the language.
if so, simply you need to take the language by calling
EasyLocalization.of(context)?.locale;
or after importing EasyLocalization package just write context.locale;
For changing use EasyLocalization.of(context)?.setLocale(Locale('EN')); or context.setLocale(Locale('EN'));
want to launch URL in ELEVATEDBUTTON. there are too many button for launch too many URL how can I do this in flutter??
I can't understand how can I do this. can anyone solve this problem
you can map the list while rendering on ui.
...urlList
.map(
(e) => ElevatedButton(
onPressed: () {
launchUrl(Uri.parse(e)); //use .tryParse
},
child: Text("$e"),
),
)
.toList(),
You may create a model class with label and string url.
I am developing a flutter app where appbar icon broke suddenly without any reason. Try to fix but nothing has been found yet.
enter image description here
AppBar(
actions: [
GestureDetector(
onTap: () {},
child: SvgPicture.asset(
iconSearch,
color: VisuColors.white,
),
),
]
)
According to the image and code that you provide, things that come to my mind are:
1- Try to give width and height to SvgPicture.asset like this:
SvgPicture.asset(
iconSearch,
color: VisuColors.white,
width: 15,
height: 15,
),
2- Check the color that you gave to SvgPicture.asset, maybe it has something related to the color.
3- If these 2 solutions didn't solve your problem, check your SVG file and try to use another SVG file to see if the problem is with the file that you use. Because sometimes, the SVG files may be broken (size, color, formatting etc.).
i am displaying image in my UI using mage.network widget, and display Text widget in Stack
like following
Stack(
alignment: Alignment.center,
children: [
Image.network('myImage'),
Text('Hello world')
],
);
also the same idea but with video
Stack(
alignment: Alignment.center,
children: [
VideoPlayer('myVideoFile'),
Text('Hello world')
],
);
now my question : How can i merge ANY Widget that add into stack (in my case Text('Hello world')) into one final result file ?
in other word : if i want to save my image or video into my storage so Of course they will be saved separately from the widgets they have inside Stack . but How could i merge the widgets with them and became one file? so when i save them to my storage and want to open them again i will find the widgets already merged with them
the only way i have now is to screenshot my screen using screenshot plugin and save the result as one file . and the same with video but with record_screen plugin But it is a very bad experience
What should I look for to handle this work?
any plugin ?
Any suggestions?
I save my image in database with backslash (\) in address like this:
\image\carimage\2021_123test.jpg
Ok, when I want to show it in Image.network('imageurl') in flutter it is not possible to show that, because of backslash in path, I update one of iamge from database maunulay like this
/image/carimage/2021_123test.jpg
It work fine. In webpage I can see my images with previous path but in flutter I must change path, how can I do that dynamically
Update:
return Scaffold(
appBar: AppBar(
title: const Text('car pro '),
),
body: controller.obx(
(data) => Center(
child: (Card(
child: Column(
children: [
Image.network('http://mywebsite.com/' + data!['image']),
],
),
)),
),
),
);
You can replace all backlashes with the replaceAll method:
String newImage = image.replaceAll(r'\', r'/');
Edit:
This solution wouldn't work since your image path would need to be a raw string, or contain double backlashes (\\). See this question. But if you add a double backslash to your image path when creating it in the database, then you can use:
Image.network("http://mywebsite.com/" +
data!['image'].replaceAll(r'\', r'/'))