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

View File

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

View File

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

View File

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

View File

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