File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change 1+ import 'dart:io' ;
2+
13import 'package:flutter/material.dart' ;
24import 'package:intl/intl.dart' ;
35
@@ -6,21 +8,23 @@ import '../l10n/l10n.dart';
68extension DateTimeX on DateTime {
79 String formatAndLocalize (AppLocalizations l10n, {bool simple = false }) {
810 final now = DateTime .now ();
9- final locale = WidgetsBinding .instance.platformDispatcher.locale;
11+
12+ final countryCode =
13+ Platform .localeName == 'und' ? 'en_US' : Platform .localeName;
1014
1115 if (! simple && year == now.year && month == now.month) {
1216 if (day == now.day - 1 ) {
1317 return '${l10n .yesterday }, ${DateFormat .Hm (
14- locale . countryCode ,
18+ countryCode ,
1519 ).format (this )}' ;
1620 } else if (day == now.day) {
1721 return DateFormat .Hm (
18- locale. countryCode,
22+ countryCode,
1923 ).format (this );
2024 }
2125 }
2226 return DateFormat .yMd (
23- locale. countryCode,
27+ countryCode,
2428 ).add_Hm ().format (this );
2529 }
2630
Original file line number Diff line number Diff line change @@ -4,6 +4,7 @@ import 'package:flutter/widgets.dart';
44export 'package:flutter_gen/gen_l10n/app_localizations.dart' ;
55
66final List <Locale > supportedLocales = {
7+ const Locale ('US' ),
78 const Locale ('en' ),
89 const Locale ('en_US' ),
910 ...List .of (AppLocalizations .supportedLocales)..remove (const Locale ('en' )),
You can’t perform that action at this time.
0 commit comments