flutter: Fix warnings

This commit is contained in:
Calcitem 2021-02-27 20:47:53 +08:00
parent 36b422634c
commit 8600263061
3 changed files with 10 additions and 12 deletions

View File

@ -41,8 +41,8 @@ class StateInfo {
class Position { class Position {
GameResult result = GameResult.pending; GameResult result = GameResult.pending;
List<String> board = List<String>(sqNumber); List<String> board = List.filled(sqNumber, "");
List<String> _grid = List<String>(7 * 7); List<String> _grid = List.filled(7 * 7, "");
GameRecorder recorder; GameRecorder recorder;
@ -90,24 +90,24 @@ class Position {
Move move; Move move;
Position.boardToGrid() { Position.boardToGrid() {
_grid = List<String>(); _grid = [];
for (int sq = 0; sq < board.length; sq++) { for (int sq = 0; sq < board.length; sq++) {
_grid[squareToIndex[sq]] = board[sq]; _grid[squareToIndex[sq]] = board[sq];
} }
} }
Position.gridToBoard() { Position.gridToBoard() {
board = List<String>(); board = [];
for (int i = 0; i < _grid.length; i++) { for (int i = 0; i < _grid.length; i++) {
board[indexToSquare[i]] = _grid[i]; board[indexToSquare[i]] = _grid[i];
} }
} }
Position.clone(Position other) { Position.clone(Position other) {
_grid = List<String>(); _grid = [];
other._grid.forEach((piece) => _grid.add(piece)); other._grid.forEach((piece) => _grid.add(piece));
board = List<String>(); board = [];
other.board.forEach((piece) => board.add(piece)); other.board.forEach((piece) => board.add(piece));
recorder = other.recorder; recorder = other.recorder;

View File

@ -526,8 +526,8 @@ class _GamePageState extends State<GamePage> with RouteAware {
); );
} }
void showSnackbar(String message) { void showSnackBar(String message) {
var currentScaffold = globalScaffoldKey.currentState; //var currentScaffold = globalScaffoldKey.currentState;
ScaffoldMessenger.of(context).hideCurrentSnackBar(); ScaffoldMessenger.of(context).hideCurrentSnackBar();
ScaffoldMessenger.of(context) ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message))); .showSnackBar(SnackBar(content: Text(message)));
@ -535,7 +535,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
Widget createOperatorBar() { Widget createOperatorBar() {
// //
final buttonStyle = TextStyle(color: UIColors.primaryColor, fontSize: 20); //final buttonStyle = TextStyle(color: UIColors.primaryColor, fontSize: 20);
final text = Game.shared.position.manualText; final text = Game.shared.position.manualText;
final manualStyle = final manualStyle =
@ -579,7 +579,7 @@ class _GamePageState extends State<GamePage> with RouteAware {
child: Text(S.of(context).copy, style: manualStyle), child: Text(S.of(context).copy, style: manualStyle),
onPressed: () => onPressed: () =>
Clipboard.setData(ClipboardData(text: text)).then((_) { Clipboard.setData(ClipboardData(text: text)).then((_) {
showSnackbar(S.of(context).moveHistoryCopied); showSnackBar(S.of(context).moveHistoryCopied);
}), }),
), ),
TextButton( TextButton(

View File

@ -28,8 +28,6 @@ class RuleSettingsPage extends StatefulWidget {
} }
class _RuleSettingsPageState extends State<RuleSettingsPage> { class _RuleSettingsPageState extends State<RuleSettingsPage> {
String _version = "";
@override @override
void initState() { void initState() {
super.initState(); super.initState();