在Flutter中如何在国际化(Intl)和枚举之间进行通信?
就在下面我留下了一段代码,例如:
'import '../generated/l10n.dart';
enum AminoacidosEnum { TITULO(S.current.title), HELLOWORD(" ");
final String value;
const AminoacidosEnum(this.value); }'
'import 'package:flutter/material.dart'; import 'package:internacionalizacao/enums/aminoacidos_enum.dart';
import '../generated/l10n.dart';
class HomePage extends StatelessWidget { const HomePage({super.key});
@override Widget build(BuildContext context) { return Scaffold( body: Center( //child: Text (AppLocalizations.of(context)!.helloWorld), child: Column(children:[
Text(AminoacidosEnum.TITULO),
Text(S.of(context).helloWorld),
Text(S.of(context).concatenedText('Thiago C. Pedroso')),
Text(
S.of(context).textWithPlaceHolders("Pedroso", 'Thiago Cristian')),
Text(S.of(context).pageNotificationsCount(0)),
Text(S.of(context).pageNotificationsCount(1)),
Text(S.of(context).pageNotificationsCount(2)),
//Text(S.of(context).gender(1)),
Text(S.of(context).gender("male")),
Text(S.current.pageHomeBalance(1234567890, DateTime.now())),
]),
),
);
} }'
Arguments of a constant creation must be constant expressions. Try making the argument a valid constant, or use 'new' to call the constructor. Arguments of a constant creation must be constant expressions. Try making the argument a valid constant, or use 'new' to call the constructor. A value of type 'Null' can't be assigned to a parameter of type 'String' in a const constructor. Try using a subtype, or removing the keyword 'const'.
1条答案
按热度按时间mwecs4sa1#
我得到了我想要的,如果它对某人有用,我已经添加了一些使用它的方法。