Skip to content

Instantly share code, notes, and snippets.

@iapicca
Last active April 13, 2020 07:24
Show Gist options
  • Select an option

  • Save iapicca/7c340ec2f36a87c9db73d72321e1371b to your computer and use it in GitHub Desktop.

Select an option

Save iapicca/7c340ec2f36a87c9db73d72321e1371b to your computer and use it in GitHub Desktop.
Directionality
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