Skip to content

Instantly share code, notes, and snippets.

@anoochit
Created June 7, 2020 02:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anoochit/bebbd9c712751c3f1bf6e6eeee9bf104 to your computer and use it in GitHub Desktop.
Save anoochit/bebbd9c712751c3f1bf6e6eeee9bf104 to your computer and use it in GitHub Desktop.
pawan locale
import 'package:flutter/material.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:pawat/generated/l10n.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
localizationsDelegates: [
S.delegate,
GlobalMaterialLocalizations.delegate,
GlobalWidgetsLocalizations.delegate,
GlobalCupertinoLocalizations.delegate,
],
supportedLocales: S.delegate.supportedLocales,
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: HomePage(),
);
}
}
class HomePage extends StatefulWidget {
HomePage({Key key}) : super(key: key);
@override
_HomePageState createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
Widget _showMessage() {
return Text(S.of(context).textAppTitle);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text("Pawan")),
body: Container(child: _showMessage()),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment