Last active
April 13, 2020 07:24
-
-
Save iapicca/7c340ec2f36a87c9db73d72321e1371b to your computer and use it in GitHub Desktop.
Directionality
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(App()); | |
| class App extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) => MaterialApp( | |
| home: Directionality( | |
| textDirection: TextDirection.rtl, | |
| child: MyHomePage(), | |
| ), | |
| ); | |
| } | |
| class MyHomePage extends StatelessWidget { | |
| @override | |
| Widget build(BuildContext context) => Scaffold( | |
| body: Center( | |
| child: RichText( | |
| textDirection: Directionality.of(context), | |
| text: TextSpan( | |
| style: DefaultTextStyle.of(context).style, | |
| children: [ | |
| TextSpan(text: 'hello world!'), | |
| WidgetSpan( | |
| child: Container( | |
| width: 30.0, | |
| color: Color.fromRGBO(0, 0, 255, .5), | |
| child: Center( | |
| child: Text('1'), | |
| ), | |
| ), | |
| ), | |
| ], | |
| ), | |
| ), | |
| ), | |
| ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment