{\rtf1\ansi\ansicpg1252\cocoartf2577 \cocoatextscaling0\cocoaplatform0{\fonttbl\f0\fnil\fcharset0 Menlo-Regular;\f1\fnil\fcharset0 Menlo-Italic;} {\colortbl;\red255\green255\blue255;\red191\green100\blue38;\red32\green32\blue32;\red88\green118\blue71; \red254\green187\blue91;\red153\green168\blue186;\red173\green169\blue32;\red133\green96\blue154;\red86\green132\blue173; } {\*\expandedcolortbl;;\csgenericrgb\c74902\c39216\c14902;\csgenericrgb\c12549\c12549\c12549;\csgenericrgb\c34510\c46275\c27843; \csgenericrgb\c99608\c73333\c35686;\csgenericrgb\c60000\c65882\c72941;\csgenericrgb\c67843\c66275\c12549;\csgenericrgb\c52157\c37647\c60392;\csgenericrgb\c33725\c51765\c67843; } \margl1440\margr1440\vieww11520\viewh8400\viewkind0 \pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\pardirnatural\partightenfactor0 \f0\fs24 \cf2 \cb3 import \cf4 'package:flutter/material.dart'\cf2 ;\ import \cf4 'package:userstory2translate/localization/localization.dart'\cf2 ;\ import \cf4 'package:userstory2translate/router/custom_router.dart'\cf2 ;\ import \cf4 'package:userstory2translate/router/route_constants.dart'\cf2 ;\ import \cf4 'package:flutter_localizations/flutter_localizations.dart'\cf2 ;\ \ import \cf4 'localization/language_constants.dart'\cf2 ;\ \ void \cf5 main\cf6 () => runApp(\cf5 MyApp\cf6 ())\cf2 ;\ \ class \cf6 MyApp \cf2 extends \cf6 StatefulWidget \{\ \cf2 const \cf6 MyApp(\{Key key\}) : \cf2 super\cf6 (key: key)\cf2 ;\ static void \f1\i \cf5 setLocale \f0\i0 \cf6 (BuildContext context\cf2 , \cf6 Locale newLocale) \{\ _MyAppState state = context.findAncestorStateOfType<_MyAppState>()\cf2 ;\ \cf6 state.setLocale(newLocale)\cf2 ;\ \cf6 \}\ \ \cf7 @override\ \cf6 _MyAppState \cf5 createState\cf6 () => \cf5 _MyAppState\cf6 ()\cf2 ;\ \cf6 \}\ \ \cf2 class \cf6 _MyAppState \cf2 extends \cf6 State \{\ Locale \cf8 _locale\cf2 ;\ \cf5 setLocale\cf6 (Locale locale) \{\ setState(() \{\ \cf8 _locale \cf6 = locale\cf2 ;\ \cf6 \})\cf2 ;\ \cf6 \}\ \ \cf7 @override\ \cf2 void \cf5 didChangeDependencies\cf6 () \{\ getLocale().then((locale) \{\ setState(() \{\ \cf2 this\cf6 .\cf8 _locale \cf6 = locale\cf2 ;\ \cf6 \})\cf2 ;\ \cf6 \})\cf2 ;\ super\cf6 .didChangeDependencies()\cf2 ;\ \cf6 \}\ \ \cf7 @override\ \cf6 Widget \cf5 build\cf6 (BuildContext context) \{\ \cf2 if \cf6 (\cf2 this\cf6 .\cf8 _locale \cf6 == \cf2 null\cf6 ) \{\ \cf2 return \cf5 Container\cf6 (\ child: \cf5 Center\cf6 (\ child: \cf5 CircularProgressIndicator\cf6 (\ valueColor: \cf5 AlwaysStoppedAnimation\cf6 (Colors. \f1\i \cf8 blue \f0\i0 \cf6 [\cf9 800\cf6 ]))\cf2 ,\ \cf6 )\cf2 ,\ \cf6 )\cf2 ;\ \cf6 \} \cf2 else \cf6 \{\ \cf2 return \cf5 MaterialApp\cf6 (\ debugShowCheckedModeBanner: \cf2 false,\ \cf6 title: \cf4 "Flutter Localization Demo"\cf2 ,\ \cf6 theme: \cf5 ThemeData\cf6 (primarySwatch: Colors. \f1\i \cf8 blue \f0\i0 \cf6 )\cf2 ,\ \cf6 locale: \cf8 _locale\cf2 ,\ \cf6 supportedLocales: [\ \cf5 Locale\cf6 (\cf4 "en"\cf2 , \cf4 "US"\cf6 )\cf2 ,\ \cf5 Locale\cf6 (\cf4 "fa"\cf2 , \cf4 "IR"\cf6 )\cf2 ,\ \cf5 Locale\cf6 (\cf4 "es"\cf2 , \cf4 "SP"\cf6 )\cf2 ,\ \cf5 Locale\cf6 (\cf4 "hi"\cf2 , \cf4 "IN"\cf6 )\ ]\cf2 ,\ \cf6 localizationsDelegates: [\ DemoLocalization. \f1\i \cf8 delegate \f0\i0 \cf2 ,\ \cf6 GlobalMaterialLocalizations. \f1\i \cf8 delegate \f0\i0 \cf2 ,\ \cf6 GlobalWidgetsLocalizations. \f1\i \cf8 delegate \f0\i0 \cf2 ,\ \cf6 GlobalCupertinoLocalizations. \f1\i \cf8 delegate \f0\i0 \cf2 ,\ \cf6 ]\cf2 ,\ \cf6 localeResolutionCallback: (locale\cf2 , \cf6 supportedLocales) \{\ \cf2 for \cf6 (\cf2 var \cf6 supportedLocale \cf2 in \cf6 supportedLocales) \{\ \cf2 if \cf6 (supportedLocale.\cf8 languageCode \cf6 == locale.\cf8 languageCode \cf6 &&\ supportedLocale.\cf8 countryCode \cf6 == locale.\cf8 countryCode\cf6 ) \{\ \cf2 return \cf6 supportedLocale\cf2 ;\ \cf6 \}\ \}\ \cf2 return \cf6 supportedLocales.\cf8 first\cf2 ;\ \cf6 \}\cf2 ,\ \cf6 onGenerateRoute: CustomRouter. \f1\i \cf5 generatedRoute \f0\i0 \cf2 ,\ \cf6 initialRoute: homeRoute\cf2 ,\ \cf6 )\cf2 ;\ \cf6 \}\ \}\ \}\ }