Replace print() calls with log() calls.

This commit is contained in:
Marco 2022-12-13 03:43:05 +01:00
parent e696d3cd3d
commit 7198f591bd
5 changed files with 16 additions and 7 deletions

View File

@ -4,6 +4,7 @@ import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mchess/chess_bloc/chess_events.dart';
import 'package:mchess/chessapp/chess_utils.dart';
import 'package:mchess/connection/ws_connection.dart';
import 'dart:developer';
class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
static final ChessBloc _instance = ChessBloc._internal();
@ -29,7 +30,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
newPosition[event.endSquare] = state.position[event.startSquare]!;
newPosition[event.startSquare] = const ChessPiece.none();
print('emitting new state with position $newPosition');
log('emitting new state with position $newPosition');
emit(ChessBoardState(
state.flipped,
ChessColor.black,
@ -43,7 +44,7 @@ class ChessBloc extends Bloc<ChessEvent, ChessBoardState> {
ServerConnection.getInstance().send(
'pc ${event.move.startSquare.toString()} ${event.move.endSquare.toString()}');
print('Pretending to check a move before you drop a piece');
log('Pretending to check a move before you drop a piece');
return true;
}
}

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:mchess/chess_bloc/chess_bloc.dart';
@ -51,7 +53,7 @@ class ChessApp extends StatelessWidget {
return StreamBuilder(
stream: ServerConnection.getInstance().channel.stream,
builder: (context, snapshot) {
print(snapshot.data.toString());
log(snapshot.data.toString());
return Text(
style: const TextStyle(color: Colors.white),
snapshot.data.toString());

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:mchess/chess_bloc/chess_bloc.dart';
@ -31,7 +33,7 @@ class ChessBoard extends StatelessWidget {
@override
Widget build(BuildContext context) {
print("ChessBoard's build()");
log("ChessBoard's build()");
return Column(children: _buildBoard(bState.flipped));
}
@ -72,7 +74,7 @@ class ChessBoard extends StatelessWidget {
/* Calculate index in squares[] from column and row */
int index = (coord.row - 1) * 8 + (coord.column - 1);
print("getSquareAtCoordinates: index calculated to $index");
log("getSquareAtCoordinates: index calculated to $index");
return squares.elementAt(index);
}

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
@ -86,7 +88,7 @@ class ChessSquare extends StatelessWidget {
move!.endSquare = coordinate;
final legalMove =
context.read<ChessBloc>().preCheckHandler(PreCheckMove(move: move));
print('onWillAccept returns $legalMove');
log('onWillAccept returns $legalMove');
return legalMove;
},
onAccept: (move) {

View File

@ -1,3 +1,5 @@
import 'dart:developer';
import 'package:web_socket_channel/web_socket_channel.dart';
class ServerConnection {
@ -8,7 +10,7 @@ class ServerConnection {
static final ServerConnection _instance = ServerConnection._internal();
ServerConnection._internal() {
print("ServerConnection._interal constructor is called");
log("ServerConnection._interal constructor is called");
connect();
}