You can now use the flutter_bidi_text
package — it automatically detects text direction for Text
, TextField
, and TextFormField
based on content.
Example:
import 'package:flutter_bidi_text/bidi_text.dart';
String rtlString = 'فارسی';
String mixedString = 'This is mixed string English and فارسی';
Column(
children: <Widget>[
const BidiText('English'), // Always LTR
const BidiText('فارسی'), // Always RTL
BidiText(ltrString), // Based on content, RTL
BidiText(mixedString), // Based on content, LTR
],
)
It uses bidirectional algorithms under the hood for seamless mixed-language support.