我已经学习了如何通过 StatelessWidget 使用 i18n 进行我的颤振练习,但仍然无法通过 StatefulWidget 工作。
我可以简单地替换以下代码
title: new Text(S.of(context).title)
Run Code Online (Sandbox Code Playgroud)
使用 const 字符串,例如:
title: const Text("A Test Title");
Run Code Online (Sandbox Code Playgroud)
所以我认为其他一切都应该没问题。唯一的问题是 i18n 不起作用。
有人可以帮助我,“如何在 Flutter 上通过 StatefulWidget 使用 i18n?”
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter/widgets.dart';
import 'generated/i18n.dart';
void main() {
runApp(new MyApp());
}
class MyApp extends StatefulWidget {
MyApp({Key key, this.title}) : super(key: key);
final String title;
@override
_MyAppState createState() => new _MyAppState();
}
class _MyAppState extends State<MyApp> {
BuildContext c;
@override
void initState() {
super.initState();
}
@override
void dispose() { …Run Code Online (Sandbox Code Playgroud)