We are trying to upgrade our e-commerce site with multi language English and Arabic interface, but the right to left RTL text direction got missed up in web HTML rendering with Flutter 3.7
How to solve this issue? we are super excited to work on the new version of #flutter
for example:
- correct expected output: 23.5
- wrong web html rendering result: 5.23
Another example:
- correct expected output: (test) (هذا نص تجريبي (اختبار
- wrong web html rendering result: )test() هذا نص تجريبي )اختبار
we have tried this code sample, but it was not working
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const HomePage(),
);
}
}
class HomePage extends StatelessWidget {
const HomePage({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: const [
Directionality(
textDirection: TextDirection.rtl,
child: Text(
'سعر المنتج 23.5 دولار',
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
),
SizedBox(height: 20),
Directionality(
textDirection: TextDirection.rtl,
child: Text(
'(test) (هذا نص تجريبي (اختبار',
style: TextStyle(fontSize: 30, fontWeight: FontWeight.bold),
),
),
],
),
);
}
}
is there a way to fix this?
Your column has problem.
I fixed his problem by
CrossAxisAlignment.stretchfor cover width of screen andMainAxisAlignment.startfor start side .If using
Directionalityas parent of widget and setrtl, start side always isRight.