bidi 1.0.0+3
bidi: ^1.0.0+3 copied to clipboard

Implementation of the BIDI algorithm, as described in http://www.unicode.org/reports/tr9/tr9-17.html.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:bidi/bidi.dart' as bidi;

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter BiDi Demo'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);

  final String title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  String _visual;
  final _logicalController = TextEditingController();

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Directionality(
        textDirection: TextDirection.rtl,
        child: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: [
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: TextFormField(
                  controller: _logicalController,
                  decoration: InputDecoration(
                    border: OutlineInputBorder(),
                  ),
                  onChanged: (value) {
                    if (value.isEmpty) {
                      return;
                    }

                    final visual = bidi.logicalToVisual(value);
                    setState(() {
                      _visual = visual.reversed
                          .map((e) => String.fromCharCode(e))
                          .join(' ');
                    });
                  },
                ),
              ),
              Padding(
                padding: const EdgeInsets.all(8.0),
                child: Center(
                  child: Text(
                    _visual ?? '',
                    style: Theme.of(context).textTheme.headline4,
                  ),
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
5
likes
100
pub points
31%
popularity

Publisher

pwa.ir

Implementation of the BIDI algorithm, as described in http://www.unicode.org/reports/tr9/tr9-17.html.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on bidi