DateTime的国际化不起作用

DateTime的国际化不起作用,datetime,internationalization,flutter,Datetime,Internationalization,Flutter,我有一个演示应用程序,国际化无法正常运行。 我的时间代码是+3(北塞浦路斯)。语言是TR。日期部分为TR工作。 但时间不起作用。示例显示的不是08:27:18,而是05:27.18 GMT时间 更多信息: 示例: 需要帮忙吗 import 'package:flutter/material.dart'; import 'package:intl/intl.dart'; import 'package:intl/date_symbol_data_local.dart'; void main()

我有一个演示应用程序,国际化无法正常运行。 我的时间代码是+3(北塞浦路斯)。语言是TR。日期部分为TR工作。 但时间不起作用。示例显示的不是08:27:18,而是05:27.18 GMT时间

更多信息:

示例:

需要帮忙吗

import 'package:flutter/material.dart';
import 'package:intl/intl.dart';
import 'package:intl/date_symbol_data_local.dart';

void main() => runApp(new MyApp());

class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
        return new MaterialApp(
            title: 'Internationalization',
            theme: new ThemeData(
                primarySwatch: Colors.blue,
            ),
            home: new MyHomePage(title: 'Internationalization'),
        );
    }
}

class MyHomePage extends StatefulWidget {
    MyHomePage({Key key, this.title}) : super(key: key);

    final String title;

    @override
    _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
    DateFormat dateFormat;
    DateFormat timeFormat;

    @override
    void initState() {
        super.initState();
        initializeDateFormatting();
        dateFormat = new DateFormat.yMMMMd('tr_TR');
        timeFormat = new DateFormat.Hms('tr_TR');
    }

    void _refresh() {
        setState(() {});
    }

    @override
    Widget build(BuildContext context) {
        var dateTime = new DateTime.now();
        return new Scaffold(
            appBar: new AppBar(
                title: new Text(widget.title),
                backgroundColor: Colors.pinkAccent,
            ),
            body: new Center(
                child: new Column(
                    mainAxisAlignment: MainAxisAlignment.center,
                    children: <Widget>[
                        new Text(dateFormat.format(dateTime),
                            style: new TextStyle(
                                fontSize: 24.0,
                                fontWeight: FontWeight.bold,
                                    color: Colors.pinkAccent,
                            ),
                        ),
                        new Text(timeFormat.format(dateTime),
                            style: new TextStyle(
                                fontSize: 22.0,
                                    fontWeight: FontWeight.bold
                            ),
                        ),
                    ],
                ),
            ),
            floatingActionButton: new FloatingActionButton(
                onPressed: _refresh,
                tooltip: 'Refresh',
                child: new Icon(Icons.refresh),
            ),
        );
    }
}
导入“包装:颤振/材料.省道”;
导入“包:intl/intl.dart”;
导入“package:intl/date_symbol_data_local.dart”;
void main()=>runApp(新的MyApp());
类MyApp扩展了无状态小部件{
@凌驾
小部件构建(构建上下文){
返回新材料PP(
标题:"国际化",,
主题:新主题数据(
主样本:颜色。蓝色,
),
主页:新MyHomePage(标题:“国际化”),
);
}
}
类MyHomePage扩展StatefulWidget{
MyHomePage({Key,this.title}):超级(Key:Key);
最后的字符串标题;
@凌驾
_MyHomePageState createState()=>new_MyHomePageState();
}
类_MyHomePageState扩展状态{
日期格式日期格式;
日期格式时间格式;
@凌驾
void initState(){
super.initState();
初始化为teformatting();
dateFormat=newdateformat.yMMMMd('tr_tr');
timeFormat=new DateFormat.Hms('tr_tr');
}
void_refresh(){
setState((){});
}
@凌驾
小部件构建(构建上下文){
var dateTime=new dateTime.now();
归还新脚手架(
appBar:新的appBar(
标题:新文本(widget.title),
背景颜色:Colors.pinkAccent,
),
正文:新中心(
子:新列(
mainAxisAlignment:mainAxisAlignment.center,
儿童:[
新文本(dateFormat.format(dateTime),
样式:新文本样式(
字体大小:24.0,
fontWeight:fontWeight.bold,
颜色:Colors.pinkAccent,
),
),
新文本(timeFormat.format(dateTime),
样式:新文本样式(
字体大小:22.0,
fontWeight:fontWeight.bold
),
),
],
),
),
floatingActionButton:新的floatingActionButton(
onPressed:\u刷新,
工具提示:“刷新”,
子:新图标(图标。刷新),
),
);
}
}

有@GünterZöchbauer帮助。我检查我的android模拟器

我的模拟器是Nexus 5X API 26。
将模拟器语言设置为TR,区域设置为土耳其,上述代码运行良好。

请直接将相关代码添加到问题中,而不是仅链接到外部资源。@GünterZöchbauer,谢谢。我现在就这么做了。也许你的代码在我这边工作得很好。@GünterZöchbauer。谢谢它现在正在工作。我的模拟器是Nexus 5X API 26。正在设置模拟器语言和区域。这是非常基本的配置。但我无法在颤振文档中找到鳍。使用intl:^0.15.6必须显示此配置并使其更好。