Created
November 12, 2021 09:13
-
-
Save jaripekkala/b0c729bd03c1a5a42ea5f7c682fb45ed to your computer and use it in GitHub Desktop.
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'; | |
import 'package:flutter/rendering.dart'; | |
const Color darkBlue = Color.fromARGB(255, 18, 32, 47); | |
void main() { | |
runApp(MyApp()); | |
} | |
class CustomLocalization implements WidgetsLocalizations { | |
@override | |
TextDirection get textDirection => TextDirection.rtl; // <<<<<<<<<<< | |
} | |
class CustomLocalizationDelegate | |
extends LocalizationsDelegate<WidgetsLocalizations> { | |
@override | |
bool isSupported(Locale locale) => true; | |
@override | |
Future<WidgetsLocalizations> load(Locale locale) async => | |
CustomLocalization(); | |
@override | |
bool shouldReload(CustomLocalizationDelegate old) => false; | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
localizationsDelegates: [CustomLocalizationDelegate()], | |
home: Scaffold( | |
appBar: AppBar(title: const Text('main page!')), | |
body: MyWidget(), | |
), | |
); | |
} | |
} | |
class MyWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return ElevatedButton( | |
child: const Text('open second page'), | |
onPressed: () { | |
final route = MaterialPageRoute(builder: (context) { | |
return SecondPage(); | |
}); | |
Navigator.of(context).push(route); | |
}, | |
); | |
} | |
} | |
class SecondPage extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: const Text('second page!')), | |
body: Container( | |
width: double.infinity, | |
child: const Text('foo bar'), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment