flutter: Replace S.of(context)! to S.of(context)

Fix: warning: The '!' will have no effect because the receiver can't be null.
This commit is contained in:
Calcitem 2021-03-10 21:29:53 +08:00
parent d359b06a3f
commit dd13661efb
6 changed files with 132 additions and 134 deletions

View File

@ -74,16 +74,16 @@ class _GamePageState extends State<GamePage> with RouteAware {
final winner = Game.shared.position.winner;
Map<String, String> colorWinStrings = {
PieceColor.black: S.of(context)!.blackWin,
PieceColor.white: S.of(context)!.whiteWin,
PieceColor.draw: S.of(context)!.draw
PieceColor.black: S.of(context).blackWin,
PieceColor.white: S.of(context).whiteWin,
PieceColor.draw: S.of(context).draw
};
if (winner == PieceColor.nobody) {
if (Game.shared.position.phase == Phase.placing) {
changeStatus(S.of(context)!.tipPlace);
changeStatus(S.of(context).tipPlace);
} else if (Game.shared.position.phase == Phase.moving) {
changeStatus(S.of(context)!.tipMove);
changeStatus(S.of(context).tipMove);
}
} else {
changeStatus(colorWinStrings[winner]);
@ -121,17 +121,17 @@ class _GamePageState extends State<GamePage> with RouteAware {
if (position.putPiece(sq)) {
if (position.action == Act.remove) {
//Audios.playTone('mill.mp3');
changeStatus(S.of(context)!.tipRemove);
changeStatus(S.of(context).tipRemove);
} else {
//Audios.playTone('place.mp3');
changeStatus(S.of(context)!.tipPlaced);
changeStatus(S.of(context).tipPlaced);
}
ret = true;
print("putPiece: [$sq]");
break;
} else {
print("putPiece: skip [$sq]");
changeStatus(S.of(context)!.tipBanPlace);
changeStatus(S.of(context).tipBanPlace);
}
// If cannot move, retry select, do not break
@ -144,11 +144,11 @@ class _GamePageState extends State<GamePage> with RouteAware {
Game.shared.select(index);
ret = true;
print("selectPiece: [$sq]");
changeStatus(S.of(context)!.tipPlace);
changeStatus(S.of(context).tipPlace);
} else {
Audios.playTone('illegal.mp3');
print("selectPiece: skip [$sq]");
changeStatus(S.of(context)!.tipSelectWrong);
changeStatus(S.of(context).tipSelectWrong);
}
break;
@ -157,11 +157,11 @@ class _GamePageState extends State<GamePage> with RouteAware {
//Audios.playTone('remove.mp3');
ret = true;
print("removePiece: [$sq]");
changeStatus(S.of(context)!.tipRemoved);
changeStatus(S.of(context).tipRemoved);
} else {
Audios.playTone('illegal.mp3');
print("removePiece: skip [$sq]");
changeStatus(S.of(context)!.tipBanRemove);
changeStatus(S.of(context).tipBanRemove);
}
break;
@ -218,7 +218,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
changeStatus(score);
} else {
changeStatus(S.of(context)!.thinking);
changeStatus(S.of(context).thinking);
}
final response = await widget.engine.search(Game.shared.position);
@ -246,7 +246,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
confirm() {
Navigator.of(context).pop();
Game.shared.newGame();
changeStatus(S.of(context)!.gameStarted);
changeStatus(S.of(context).gameStarted);
if (Game.shared.isAiToMove()) {
print("New game, AI to move.");
@ -260,13 +260,13 @@ class _GamePageState extends State<GamePage> with RouteAware {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(S.of(context)!.newGame,
title: Text(S.of(context).newGame,
style: TextStyle(color: UIColors.primaryColor)),
content:
SingleChildScrollView(child: Text(S.of(context)!.restartGame)),
SingleChildScrollView(child: Text(S.of(context).restartGame)),
actions: <Widget>[
TextButton(child: Text(S.of(context)!.restart), onPressed: confirm),
TextButton(child: Text(S.of(context)!.cancel), onPressed: cancel),
TextButton(child: Text(S.of(context).restart), onPressed: confirm),
TextButton(child: Text(S.of(context).cancel), onPressed: cancel),
],
);
},
@ -277,37 +277,36 @@ class _GamePageState extends State<GamePage> with RouteAware {
String loseReasonStr;
//String winnerStr =
// winner == Color.black ? S.of(context).black : S.of(context).white;
String loserStr = winner == PieceColor.black
? S.of(context)!.white
: S.of(context)!.black;
String loserStr =
winner == PieceColor.black ? S.of(context).white : S.of(context).black;
switch (Game.shared.position.gameOverReason) {
case GameOverReason.loseReasonlessThanThree:
loseReasonStr = loserStr + S.of(context)!.loseReasonlessThanThree;
loseReasonStr = loserStr + S.of(context).loseReasonlessThanThree;
break;
case GameOverReason.loseReasonResign:
loseReasonStr = loserStr + S.of(context)!.loseReasonResign;
loseReasonStr = loserStr + S.of(context).loseReasonResign;
break;
case GameOverReason.loseReasonNoWay:
loseReasonStr = loserStr + S.of(context)!.loseReasonNoWay;
loseReasonStr = loserStr + S.of(context).loseReasonNoWay;
break;
case GameOverReason.loseReasonBoardIsFull:
loseReasonStr = loserStr + S.of(context)!.loseReasonBoardIsFull;
loseReasonStr = loserStr + S.of(context).loseReasonBoardIsFull;
break;
case GameOverReason.loseReasonTimeOver:
loseReasonStr = loserStr + S.of(context)!.loseReasonTimeOver;
loseReasonStr = loserStr + S.of(context).loseReasonTimeOver;
break;
case GameOverReason.drawReasonRule50:
loseReasonStr = S.of(context)!.drawReasonRule50;
loseReasonStr = S.of(context).drawReasonRule50;
break;
case GameOverReason.drawReasonBoardIsFull:
loseReasonStr = S.of(context)!.drawReasonBoardIsFull;
loseReasonStr = S.of(context).drawReasonBoardIsFull;
break;
case GameOverReason.drawReasonThreefoldRepetition:
loseReasonStr = S.of(context)!.drawReasonThreefoldRepetition;
loseReasonStr = S.of(context).drawReasonThreefoldRepetition;
break;
default:
loseReasonStr = S.of(context)!.gameOverUnknownReason;
loseReasonStr = S.of(context).gameOverUnknownReason;
break;
}
@ -360,9 +359,9 @@ class _GamePageState extends State<GamePage> with RouteAware {
}
Map<GameResult, String> retMap = {
GameResult.win: S.of(context)!.youWin,
GameResult.lose: S.of(context)!.gameOver,
GameResult.draw: S.of(context)!.draw
GameResult.win: S.of(context).youWin,
GameResult.lose: S.of(context).gameOver,
GameResult.draw: S.of(context).draw
};
var dialogTitle = retMap[result];
@ -382,17 +381,17 @@ class _GamePageState extends State<GamePage> with RouteAware {
content: Text(getGameOverReasonString(
Game.shared.position.gameOverReason,
Game.shared.position.winner) +
S.of(context)!.challengeHarderLevel),
S.of(context).challengeHarderLevel),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.yes),
child: Text(S.of(context).yes),
onPressed: () {
Config.skillLevel++;
Config.save();
Navigator.of(context).pop();
}),
TextButton(
child: Text(S.of(context)!.no),
child: Text(S.of(context).no),
onPressed: () => Navigator.of(context).pop()),
],
);
@ -411,11 +410,11 @@ class _GamePageState extends State<GamePage> with RouteAware {
Game.shared.position.winner)),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.restart),
child: Text(S.of(context).restart),
onPressed: () {
Navigator.of(context).pop();
Game.shared.newGame();
changeStatus(S.of(context)!.gameStarted);
changeStatus(S.of(context).gameStarted);
if (Game.shared.isAiToMove()) {
print("New game, AI to move.");
@ -423,7 +422,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
}
}),
TextButton(
child: Text(S.of(context)!.cancel),
child: Text(S.of(context).cancel),
onPressed: () => Navigator.of(context).pop()),
],
);
@ -448,12 +447,12 @@ class _GamePageState extends State<GamePage> with RouteAware {
Widget createPageHeader() {
/*
Map<EngineType, String> engineTypeToString = {
EngineType.humanVsAi: S.of(context)!.humanVsAi,
EngineType.humanVsHuman: S.of(context)!.humanVsHuman,
EngineType.aiVsAi: S.of(context)!.aiVsAi,
EngineType.humanVsCloud: S.of(context)!.humanVsCloud,
EngineType.humanVsLAN: S.of(context)!.humanVsLAN,
EngineType.testViaLAN: S.of(context)!.testViaLAN,
EngineType.humanVsAi: S.of(context).humanVsAi,
EngineType.humanVsHuman: S.of(context).humanVsHuman,
EngineType.aiVsAi: S.of(context).aiVsAi,
EngineType.humanVsCloud: S.of(context).humanVsCloud,
EngineType.humanVsLAN: S.of(context).humanVsLAN,
EngineType.testViaLAN: S.of(context).testViaLAN,
};
*/
@ -624,7 +623,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
Icons.motion_photos_on,
color: UIColors.secondaryColor,
),
Text(S.of(context)!.newGame,
Text(S.of(context).newGame,
style: TextStyle(color: UIColors.secondaryColor)),
],
),
@ -639,7 +638,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
Icons.restore,
color: UIColors.secondaryColor,
),
Text(S.of(context)!.regret,
Text(S.of(context).regret,
style: TextStyle(color: UIColors.secondaryColor)),
],
),
@ -657,7 +656,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
Icons.list_alt,
color: UIColors.secondaryColor,
),
Text(S.of(context)!.gameRecord,
Text(S.of(context).gameRecord,
style: TextStyle(color: UIColors.secondaryColor)),
],
),
@ -667,21 +666,21 @@ class _GamePageState extends State<GamePage> with RouteAware {
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Colors.transparent,
title: Text(S.of(context)!.gameRecord,
title: Text(S.of(context).gameRecord,
style: TextStyle(color: Colors.yellow)),
content: SingleChildScrollView(
child: Text(manualText, style: manualStyle)),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.copy, style: manualStyle),
child: Text(S.of(context).copy, style: manualStyle),
onPressed: () =>
Clipboard.setData(ClipboardData(text: manualText))
.then((_) {
showSnackBar(S.of(context)!.moveHistoryCopied);
showSnackBar(S.of(context).moveHistoryCopied);
}),
),
TextButton(
child: Text(S.of(context)!.cancel, style: manualStyle),
child: Text(S.of(context).cancel, style: manualStyle),
onPressed: () => Navigator.of(context).pop(),
),
],
@ -698,7 +697,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
Icons.dashboard_outlined,
color: UIColors.secondaryColor,
),
Text(S.of(context)!.hint,
Text(S.of(context).hint,
style: TextStyle(color: UIColors.secondaryColor)),
],
),
@ -708,13 +707,13 @@ class _GamePageState extends State<GamePage> with RouteAware {
builder: (BuildContext context) {
return AlertDialog(
backgroundColor: Colors.transparent,
title: Text(S.of(context)!.analyze,
title: Text(S.of(context).analyze,
style: TextStyle(color: Colors.yellow)),
content: SingleChildScrollView(
child: Text(analyzeText, style: manualStyle)),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.ok, style: manualStyle),
child: Text(S.of(context).ok, style: manualStyle),
onPressed: () => Navigator.of(context).pop(),
),
],

View File

@ -47,7 +47,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
showBoardColorDialog() async {
AlertDialog alert = AlertDialog(
title: Text(S.of(context)!.pick + S.of(context)!.boardColor),
title: Text(S.of(context).pick + S.of(context).boardColor),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: Color(Config.boardBackgroundColor),
@ -58,7 +58,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.confirm),
child: Text(S.of(context).confirm),
onPressed: () {
setState(() => currentColor = pickerColor);
Config.boardBackgroundColor = pickerColor.value;
@ -67,7 +67,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
},
),
TextButton(
child: Text(S.of(context)!.cancel),
child: Text(S.of(context).cancel),
onPressed: () {
Navigator.of(context).pop();
},
@ -86,7 +86,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
showBackgroundColorDialog() async {
AlertDialog alert = AlertDialog(
title: Text(S.of(context)!.pick + S.of(context)!.backgroudColor),
title: Text(S.of(context).pick + S.of(context).backgroudColor),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: Color(Config.darkBackgroundColor),
@ -97,7 +97,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.confirm),
child: Text(S.of(context).confirm),
onPressed: () {
setState(() => currentColor = pickerColor);
Config.darkBackgroundColor = pickerColor.value;
@ -106,7 +106,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
},
),
TextButton(
child: Text(S.of(context)!.cancel),
child: Text(S.of(context).cancel),
onPressed: () {
Navigator.of(context).pop();
},
@ -125,7 +125,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
showBoardLineColorDialog() async {
AlertDialog alert = AlertDialog(
title: Text(S.of(context)!.pick + S.of(context)!.lineColor),
title: Text(S.of(context).pick + S.of(context).lineColor),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: Color(Config.boardLineColor),
@ -136,7 +136,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.confirm),
child: Text(S.of(context).confirm),
onPressed: () {
setState(() => currentColor = pickerColor);
Config.boardLineColor = pickerColor.value;
@ -145,7 +145,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
},
),
TextButton(
child: Text(S.of(context)!.cancel),
child: Text(S.of(context).cancel),
onPressed: () {
Navigator.of(context).pop();
},
@ -164,7 +164,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
showBlackPieceColorDialog() async {
AlertDialog alert = AlertDialog(
title: Text(S.of(context)!.pick + S.of(context)!.blackPieceColor),
title: Text(S.of(context).pick + S.of(context).blackPieceColor),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: Color(Config.blackPieceColor),
@ -175,7 +175,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.confirm),
child: Text(S.of(context).confirm),
onPressed: () {
setState(() => currentColor = pickerColor);
Config.blackPieceColor = pickerColor.value;
@ -184,7 +184,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
},
),
TextButton(
child: Text(S.of(context)!.cancel),
child: Text(S.of(context).cancel),
onPressed: () {
Navigator.of(context).pop();
},
@ -203,7 +203,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
showWhitePieceColorDialog() async {
AlertDialog alert = AlertDialog(
title: Text(S.of(context)!.pick + S.of(context)!.whitePieceColor),
title: Text(S.of(context).pick + S.of(context).whitePieceColor),
content: SingleChildScrollView(
child: ColorPicker(
pickerColor: Color(Config.whitePieceColor),
@ -214,7 +214,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.confirm),
child: Text(S.of(context).confirm),
onPressed: () {
setState(() => currentColor = pickerColor);
Config.whitePieceColor = pickerColor.value;
@ -223,7 +223,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
},
),
TextButton(
child: Text(S.of(context)!.cancel),
child: Text(S.of(context).cancel),
onPressed: () {
Navigator.of(context).pop();
},
@ -505,16 +505,16 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
context: context,
builder: (BuildContext context) {
return AlertDialog(
title: Text(S.of(context)!.restore,
title: Text(S.of(context).restore,
style: TextStyle(color: UIColors.primaryColor)),
content: SingleChildScrollView(
child: Text(S.of(context)!.restoreDefaultSettings +
child: Text(S.of(context).restoreDefaultSettings +
"?\n" +
S.of(context)!.exitApp),
S.of(context).exitApp),
),
actions: <Widget>[
TextButton(child: Text(S.of(context)!.ok), onPressed: confirm),
TextButton(child: Text(S.of(context)!.cancel), onPressed: cancel),
TextButton(child: Text(S.of(context).ok), onPressed: confirm),
TextButton(child: Text(S.of(context).cancel), onPressed: cancel),
],
);
},
@ -532,7 +532,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
backgroundColor: UIColors.lightBackgroundColor,
appBar: AppBar(
centerTitle: true,
title: Text(S.of(context)!.settings),
title: Text(S.of(context).settings),
backgroundColor: UIColors.primaryColor),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
@ -540,7 +540,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 10.0),
Text(S.of(context)!.skillLevel, style: headerStyle),
Text(S.of(context).skillLevel, style: headerStyle),
const SizedBox(height: 10.0),
Card(
color: cardColor,
@ -549,7 +549,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
child: Column(
children: <Widget>[
ListTile(
title: Text(S.of(context)!.skillLevel, style: itemStyle),
title: Text(S.of(context).skillLevel, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(""), // TODO
@ -561,14 +561,14 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.aiIsLazy,
title: Text(S.of(context)!.aiIsLazy, style: itemStyle),
title: Text(S.of(context).aiIsLazy, style: itemStyle),
onChanged: setAiIsLazy,
),
],
),
),
const SizedBox(height: 16),
Text(S.of(context)!.sound, style: headerStyle),
Text(S.of(context).sound, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
@ -577,14 +577,14 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.toneEnabled,
title: Text(S.of(context)!.tone, style: itemStyle),
title: Text(S.of(context).tone, style: itemStyle),
onChanged: setTone,
),
],
),
),
const SizedBox(height: 16),
Text(S.of(context)!.whoMovesFirst, style: headerStyle),
Text(S.of(context).whoMovesFirst, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
@ -595,8 +595,8 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
value: !Config.aiMovesFirst,
title: Text(
Config.aiMovesFirst
? S.of(context)!.ai
: S.of(context)!.human,
? S.of(context).ai
: S.of(context).human,
style: itemStyle),
onChanged: setWhoMovesFirst,
),
@ -604,7 +604,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
),
const SizedBox(height: 16),
Text(S.of(context)!.misc, style: headerStyle),
Text(S.of(context).misc, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
@ -613,7 +613,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.isAutoRestart,
title: Text(S.of(context)!.isAutoRestart, style: itemStyle),
title: Text(S.of(context).isAutoRestart, style: itemStyle),
onChanged: setIsAutoRestart,
),
_buildDivider(),
@ -621,14 +621,14 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
activeColor: UIColors.primaryColor,
value: Config.shufflingEnabled,
title:
Text(S.of(context)!.shufflingEnabled, style: itemStyle),
Text(S.of(context).shufflingEnabled, style: itemStyle),
onChanged: setShufflingEnabled,
),
],
),
),
const SizedBox(height: 16),
Text(S.of(context)!.display, style: headerStyle),
Text(S.of(context).display, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
@ -637,13 +637,13 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.isPieceCountInHandShown,
title: Text(S.of(context)!.isPieceCountInHandShown,
title: Text(S.of(context).isPieceCountInHandShown,
style: itemStyle),
onChanged: setIsPieceCountInHandShown,
),
_buildDivider(),
ListTile(
title: Text(S.of(context)!.boardBorderLineWidth,
title: Text(S.of(context).boardBorderLineWidth,
style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
@ -655,7 +655,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
_buildDivider(),
ListTile(
title: Text(S.of(context)!.boardInnerLineWidth,
title: Text(S.of(context).boardInnerLineWidth,
style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
@ -669,14 +669,14 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
),
const SizedBox(height: 16),
Text(S.of(context)!.color, style: headerStyle),
Text(S.of(context).color, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
child: Column(
children: <Widget>[
ListTile(
title: Text(S.of(context)!.boardColor, style: itemStyle),
title: Text(S.of(context).boardColor, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Config.boardBackgroundColor.toRadixString(16),
@ -690,8 +690,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
_buildDivider(),
ListTile(
title:
Text(S.of(context)!.backgroudColor, style: itemStyle),
title: Text(S.of(context).backgroudColor, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Config.darkBackgroundColor.toRadixString(16),
@ -705,7 +704,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
_buildDivider(),
ListTile(
title: Text(S.of(context)!.lineColor, style: itemStyle),
title: Text(S.of(context).lineColor, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Config.boardLineColor.toRadixString(16),
@ -719,7 +718,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
_buildDivider(),
ListTile(
title:
Text(S.of(context)!.blackPieceColor, style: itemStyle),
Text(S.of(context).blackPieceColor, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Config.blackPieceColor.toRadixString(16),
@ -733,7 +732,7 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
_buildDivider(),
ListTile(
title:
Text(S.of(context)!.whitePieceColor, style: itemStyle),
Text(S.of(context).whitePieceColor, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Config.whitePieceColor.toRadixString(16),
@ -748,14 +747,14 @@ class _GameSettingsPageState extends State<GameSettingsPage> {
),
),
const SizedBox(height: 16),
Text(S.of(context)!.restore, style: headerStyle),
Text(S.of(context).restore, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
child: Column(
children: <Widget>[
ListTile(
title: Text(S.of(context)!.restoreDefaultSettings,
title: Text(S.of(context).restoreDefaultSettings,
style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[

View File

@ -31,32 +31,32 @@ class _HomeDrawerState extends State<HomeDrawer> {
drawerList = <DrawerList>[
DrawerList(
index: DrawerIndex.humanVsAi,
labelName: S.of(context)!.humanVsAi,
labelName: S.of(context).humanVsAi,
icon: Icon(Icons.person),
),
DrawerList(
index: DrawerIndex.humanVsHuman,
labelName: S.of(context)!.humanVsHuman,
labelName: S.of(context).humanVsHuman,
icon: Icon(Icons.group),
),
DrawerList(
index: DrawerIndex.aiVsAi,
labelName: S.of(context)!.aiVsAi,
labelName: S.of(context).aiVsAi,
icon: Icon(Icons.computer),
),
DrawerList(
index: DrawerIndex.settings,
labelName: S.of(context)!.settings,
labelName: S.of(context).settings,
icon: Icon(Icons.settings),
),
DrawerList(
index: DrawerIndex.ruleSettings,
labelName: S.of(context)!.ruleSettings,
labelName: S.of(context).ruleSettings,
icon: Icon(Icons.rule),
),
DrawerList(
index: DrawerIndex.Help,
labelName: S.of(context)!.help,
labelName: S.of(context).help,
icon: Icon(Icons.help),
),
/*
@ -78,7 +78,7 @@ class _HomeDrawerState extends State<HomeDrawer> {
*/
DrawerList(
index: DrawerIndex.About,
labelName: S.of(context)!.about,
labelName: S.of(context).about,
icon: Icon(Icons.info),
),
];
@ -128,9 +128,9 @@ class _HomeDrawerState extends State<HomeDrawer> {
print("ColorizeAnimatedTextKit Tap Event");
},
text: [
S.of(context)!.appName,
S.of(context)!.appName,
S.of(context)!.appName,
S.of(context).appName,
S.of(context).appName,
S.of(context).appName,
],
textStyle: TextStyle(
fontSize: 24.0,

View File

@ -136,18 +136,18 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
context: context,
barrierDismissible: false,
builder: (context) => AlertDialog(
title: Text(S.of(context)!.about + S.of(context)!.appName + " " + mode,
title: Text(S.of(context).about + S.of(context).appName + " " + mode,
style: TextStyle(color: UIColors.primaryColor)),
content: Column(
mainAxisSize: MainAxisSize.min,
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
SizedBox(height: 5),
Text(S.of(context)!.version + ": $_version",
Text(S.of(context).version + ": $_version",
style: TextStyle(fontFamily: '')),
SizedBox(height: 15),
InkWell(
child: Text(S.of(context)!.releaseBaseOn,
child: Text(S.of(context).releaseBaseOn,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -157,7 +157,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
),
SizedBox(height: 15),
InkWell(
child: Text(S.of(context)!.webSite,
child: Text(S.of(context).webSite,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -165,7 +165,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
onTap: () => _launchURL('https://github.com/calcitem/Sanmill'),
),
InkWell(
child: Text(S.of(context)!.whatsNew,
child: Text(S.of(context).whatsNew,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -174,7 +174,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
'https://github.com/calcitem/Sanmill/commits/master'),
),
InkWell(
child: Text(S.of(context)!.fastUpdateChannel,
child: Text(S.of(context).fastUpdateChannel,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -184,13 +184,13 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
),
SizedBox(height: 15),
InkWell(
child: Text(S.of(context)!.thanks),
child: Text(S.of(context).thanks),
),
InkWell(
child: Text(S.of(context)!.thankWho),
child: Text(S.of(context).thankWho),
),
InkWell(
child: Text(S.of(context)!.stockfish,
child: Text(S.of(context).stockfish,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -199,7 +199,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
_launchURL('https://github.com/official-stockfish/Stockfish'),
),
InkWell(
child: Text(S.of(context)!.chessRoad,
child: Text(S.of(context).chessRoad,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -207,7 +207,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
onTap: () => _launchURL('https://github.com/hezhaoyun/chessroad'),
),
InkWell(
child: Text(S.of(context)!.nineChess,
child: Text(S.of(context).nineChess,
style: TextStyle(
fontFamily: '',
color: Colors.blue,
@ -218,7 +218,7 @@ class _NavigationHomeScreenState extends State<NavigationHomeScreen> {
),
actions: <Widget>[
TextButton(
child: Text(S.of(context)!.ok),
child: Text(S.of(context).ok),
onPressed: () => Navigator.of(context).pop()),
],
),

View File

@ -185,21 +185,21 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
return Scaffold(
backgroundColor: UIColors.lightBackgroundColor,
appBar:
AppBar(centerTitle: true, title: Text(S.of(context)!.ruleSettings)),
AppBar(centerTitle: true, title: Text(S.of(context).ruleSettings)),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
const SizedBox(height: 16),
Text(S.of(context)!.rules, style: headerStyle),
Text(S.of(context).rules, style: headerStyle),
Card(
color: cardColor,
margin: const EdgeInsets.symmetric(vertical: 10),
child: Column(
children: <Widget>[
ListTile(
title: Text(S.of(context)!.piecesCount, style: itemStyle),
title: Text(S.of(context).piecesCount, style: itemStyle),
trailing:
Row(mainAxisSize: MainAxisSize.min, children: <Widget>[
Text(Config.piecesCount == 6
@ -217,14 +217,14 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
activeColor: UIColors.primaryColor,
value: Config.hasObliqueLines,
title:
Text(S.of(context)!.hasObliqueLines, style: itemStyle),
Text(S.of(context).hasObliqueLines, style: itemStyle),
onChanged: setHasObliqueLines,
),
_buildDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.hasBannedLocations,
title: Text(S.of(context)!.hasBannedLocations,
title: Text(S.of(context).hasBannedLocations,
style: itemStyle),
onChanged: setHasBannedLocations,
),
@ -232,7 +232,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.isDefenderMoveFirst,
title: Text(S.of(context)!.isDefenderMoveFirst,
title: Text(S.of(context).isDefenderMoveFirst,
style: itemStyle),
onChanged: setIsDefenderMoveFirst,
),
@ -241,14 +241,14 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
activeColor: UIColors.primaryColor,
value: Config.mayRemoveMultiple,
title:
Text(S.of(context)!.mayRemoveMultiple, style: itemStyle),
Text(S.of(context).mayRemoveMultiple, style: itemStyle),
onChanged: setAllowRemoveMultiPiecesWhenCloseMultiMill,
),
_buildDivider(),
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.mayRemoveFromMillsAlways,
title: Text(S.of(context)!.mayRemoveFromMillsAlways,
title: Text(S.of(context).mayRemoveFromMillsAlways,
style: itemStyle),
onChanged: setAllowRemovePieceInMill,
),
@ -257,7 +257,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
activeColor: UIColors.primaryColor,
value: Config.isBlackLoseButNotDrawWhenBoardFull,
title: Text(
S.of(context)!.isBlackLoseButNotDrawWhenBoardFull,
S.of(context).isBlackLoseButNotDrawWhenBoardFull,
style: itemStyle),
onChanged: setIsBlackLoseButNotDrawWhenBoardFull,
),
@ -265,7 +265,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.isLoseButNotChangeSideWhenNoWay,
title: Text(S.of(context)!.isLoseButNotChangeSideWhenNoWay,
title: Text(S.of(context).isLoseButNotChangeSideWhenNoWay,
style: itemStyle),
onChanged: setIsLoseButNotChangeSideWhenNoWay,
),
@ -273,7 +273,7 @@ class _RuleSettingsPageState extends State<RuleSettingsPage> {
SwitchListTile(
activeColor: UIColors.primaryColor,
value: Config.mayFly,
title: Text(S.of(context)!.mayFly, style: itemStyle),
title: Text(S.of(context).mayFly, style: itemStyle),
onChanged: setAllowFlyingAllowed,
),
_buildDivider(),

View File

@ -44,6 +44,6 @@ void main() {
locale: const Locale('en'),
));
await tester.pump();
expect(find.text(S.current!.appName), findsOneWidget);
expect(find.text(S.current.appName), findsOneWidget);
});
}