In flutter Text widget there are a property textDirection to set direction of text. Here direction means from which side left or right the text should start appearing on document. Basically in most of languages text starts from left to right side but in Arabic language and Urdu language text starts from right to left side. So if you are creating flutter app in Arabic or Urdu language then you have to use right to left text direction.
Flutter Change Text Direction Right to Left For Arabic Language:
1. Creating text with TextDirection.ltr property to make text direction left to right.
Text(
'Sample Left to Right Direction Text',
style: TextStyle(fontSize: 30, color: Colors.blue),
textDirection: TextDirection.ltr,
)
Screenshot:
Text(
'عينة من نص الاتجاه من اليمين إلى اليسار',
style: TextStyle(fontSize: 30, color: Colors.red),
textDirection: TextDirection.rtl,
),
Screenshot:
import 'package:flutter/material.dart';
void main() => runApp(App());
class App extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(
body: SafeArea(
child: Column(children: [
Text(
'Sample Left to Right Direction Text',
style: TextStyle(fontSize: 30, color: Colors.blue),
textDirection: TextDirection.ltr,
),
Text(
'عينة من نص الاتجاه من اليمين إلى اليسار',
style: TextStyle(fontSize: 30, color: Colors.red),
textDirection: TextDirection.rtl,
),
]))),
);
}
}
Screenshot of flutter app:
Comments
Post a Comment