Last active
April 9, 2023 15:19
-
-
Save dickermoshe/aa55719bcd6fbdcab90b6e4faa8451cd to your computer and use it in GitHub Desktop.
Flutter RTL bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
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 MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
const MyHomePage({super.key, required this.title}); | |
final String title; | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
double wordSpacingAmount = 20; | |
String englishText = 'Lorem ipsum dolor sit amet'; | |
String hebrewText = 'טקסט ללא רווח בין מילים'; | |
String arabicText = 'نص مع عدم وجود مسافات بين الكلمات'; | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: Center( | |
child: Column( | |
mainAxisAlignment: MainAxisAlignment.center, | |
children: <Widget>[ | |
const Text( | |
'English', | |
style: TextStyle(fontSize: 24), | |
), | |
Text( | |
englishText, | |
style: const TextStyle(), | |
), | |
Text( | |
englishText, | |
style: TextStyle(wordSpacing: wordSpacingAmount), | |
), | |
const SizedBox(height: 20), | |
const Text( | |
'Hebrew', | |
style: TextStyle(fontSize: 24), | |
), | |
Text( | |
hebrewText, | |
style: const TextStyle(), | |
), | |
Text( | |
hebrewText, | |
style: TextStyle(wordSpacing: wordSpacingAmount), | |
), | |
const SizedBox(height: 20), | |
const Text( | |
'Arabic', | |
style: TextStyle(fontSize: 24), | |
), | |
Text( | |
arabicText, | |
style: const TextStyle(), | |
), | |
Text( | |
arabicText, | |
style: TextStyle(wordSpacing: wordSpacingAmount), | |
), | |
const SizedBox(height: 20), | |
const Text( | |
'Hebrew with RTL', | |
textDirection: TextDirection.rtl, | |
style: TextStyle(fontSize: 24), | |
), | |
Text( | |
hebrewText, | |
style: const TextStyle(), | |
), | |
Text( | |
hebrewText, | |
style: TextStyle(wordSpacing: wordSpacingAmount), | |
), | |
const SizedBox(height: 20), | |
const Text( | |
'Arabic with RTL', | |
textDirection: TextDirection.rtl, | |
style: TextStyle(fontSize: 24), | |
), | |
Text( | |
arabicText, | |
style: const TextStyle(), | |
), | |
Text( | |
arabicText, | |
style: TextStyle(wordSpacing: wordSpacingAmount), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment