Guest User

Untitled

a guest
Apr 26th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.37 KB | None | 0 0
  1. import 'package:flutter/material.dart';
  2. import 'package:intl/intl.dart';
  3. import 'package:intl/date_symbol_data_local.dart';
  4.  
  5. void main() => runApp(new MyApp());
  6.  
  7. class MyApp extends StatelessWidget {
  8. @override
  9. Widget build(BuildContext context) {
  10. return new MaterialApp(
  11. title: 'Internationalization',
  12. theme: new ThemeData(
  13. primarySwatch: Colors.blue,
  14. ),
  15. home: new MyHomePage(title: 'Internationalization'),
  16. );
  17. }
  18. }
  19.  
  20. class MyHomePage extends StatefulWidget {
  21. MyHomePage({Key key, this.title}) : super(key: key);
  22.  
  23. final String title;
  24.  
  25. @override
  26. _MyHomePageState createState() => new _MyHomePageState();
  27. }
  28.  
  29. class _MyHomePageState extends State<MyHomePage> {
  30. DateFormat dateFormat;
  31. DateFormat timeFormat;
  32.  
  33. @override
  34. void initState() {
  35. super.initState();
  36. initializeDateFormatting();
  37. dateFormat = new DateFormat.yMMMMd('tr_TR');
  38. timeFormat = new DateFormat.Hms('tr_TR');
  39. }
  40.  
  41. void _refresh() {
  42. setState(() {});
  43. }
  44.  
  45. @override
  46. Widget build(BuildContext context) {
  47. var dateTime = new DateTime.now();
  48. return new Scaffold(
  49. appBar: new AppBar(
  50. title: new Text(widget.title),
  51. backgroundColor: Colors.pinkAccent,
  52. ),
  53. body: new Center(
  54. child: new Column(
  55. mainAxisAlignment: MainAxisAlignment.center,
  56. children: <Widget>[
  57. new Text(dateFormat.format(dateTime),
  58. style: new TextStyle(
  59. fontSize: 24.0,
  60. fontWeight: FontWeight.bold,
  61. color: Colors.pinkAccent,
  62. ),
  63. ),
  64. new Text(timeFormat.format(dateTime),
  65. style: new TextStyle(
  66. fontSize: 22.0,
  67. fontWeight: FontWeight.bold
  68. ),
  69. ),
  70. ],
  71. ),
  72. ),
  73. floatingActionButton: new FloatingActionButton(
  74. onPressed: _refresh,
  75. tooltip: 'Refresh',
  76. child: new Icon(Icons.refresh),
  77. ),
  78. );
  79. }
  80. }
Add Comment
Please, Sign In to add comment