From 7198f591bd38ded72e892aa087e477a6f395f3b2 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 13 Dec 2022 03:43:05 +0100 Subject: [PATCH] Replace print() calls with log() calls. --- lib/chess_bloc/chess_bloc.dart | 5 +++-- lib/chessapp/chess_app.dart | 4 +++- lib/chessapp/chess_board.dart | 6 ++++-- lib/chessapp/chess_square.dart | 4 +++- lib/connection/ws_connection.dart | 4 +++- 5 files changed, 16 insertions(+), 7 deletions(-) diff --git a/lib/chess_bloc/chess_bloc.dart b/lib/chess_bloc/chess_bloc.dart index 23753d0..2159475 100644 --- a/lib/chess_bloc/chess_bloc.dart +++ b/lib/chess_bloc/chess_bloc.dart @@ -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 { static final ChessBloc _instance = ChessBloc._internal(); @@ -29,7 +30,7 @@ class ChessBloc extends Bloc { 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 { 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; } } diff --git a/lib/chessapp/chess_app.dart b/lib/chessapp/chess_app.dart index 9dbcce7..99e7928 100644 --- a/lib/chessapp/chess_app.dart +++ b/lib/chessapp/chess_app.dart @@ -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()); diff --git a/lib/chessapp/chess_board.dart b/lib/chessapp/chess_board.dart index 6ab2282..aa6f920 100644 --- a/lib/chessapp/chess_board.dart +++ b/lib/chessapp/chess_board.dart @@ -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); } diff --git a/lib/chessapp/chess_square.dart b/lib/chessapp/chess_square.dart index 8575ee6..4f0d430 100644 --- a/lib/chessapp/chess_square.dart +++ b/lib/chessapp/chess_square.dart @@ -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().preCheckHandler(PreCheckMove(move: move)); - print('onWillAccept returns $legalMove'); + log('onWillAccept returns $legalMove'); return legalMove; }, onAccept: (move) { diff --git a/lib/connection/ws_connection.dart b/lib/connection/ws_connection.dart index a62602f..1edf0b2 100644 --- a/lib/connection/ws_connection.dart +++ b/lib/connection/ws_connection.dart @@ -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(); }