From 75727980a7855c230e80138a8dde54603aa64d6c Mon Sep 17 00:00:00 2001 From: Marco Date: Sun, 13 Nov 2022 14:28:30 +0100 Subject: [PATCH] Show server response in main window for debugging purpose. --- lib/chessapp/chess_app.dart | 31 ++++++++++++++++++++++--------- lib/chessapp/chess_square.dart | 3 +-- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/lib/chessapp/chess_app.dart b/lib/chessapp/chess_app.dart index 6106daa..f949cb3 100644 --- a/lib/chessapp/chess_app.dart +++ b/lib/chessapp/chess_app.dart @@ -1,8 +1,9 @@ import 'package:flutter/material.dart'; import 'package:flutter_bloc/flutter_bloc.dart'; import 'package:mchess/chess_bloc/chess_bloc.dart'; +import 'package:mchess/connection/ws_connection.dart'; -import 'chess_board.dart'; +import 'package:mchess/chessapp/chess_board.dart'; class ChessApp extends StatelessWidget { const ChessApp({super.key}); @@ -25,11 +26,13 @@ class ChessApp extends StatelessWidget { ), ), child: Center( - child: FittedBox( - fit: BoxFit.contain, - child: Container( - margin: const EdgeInsets.all(20), - child: BlocProvider( + child: Column( + children: [ + FittedBox( + fit: BoxFit.contain, + child: Container( + margin: const EdgeInsets.all(20), + child: BlocProvider( create: (_) => ChessBloc.getInstance(), child: BlocBuilder( builder: (context, state) { @@ -37,10 +40,20 @@ class ChessApp extends StatelessWidget { bState: state, ); }, - )), + ), + ), + ), ), - ), - ), + StreamBuilder( + stream: ServerConnection.getInstance().channel.stream, + builder: (context, snapshot) { + return Text( + style: const TextStyle(color: Colors.white), + snapshot.data.toString()); + }, + ) + ], + )), ), ), ); diff --git a/lib/chessapp/chess_square.dart b/lib/chessapp/chess_square.dart index 7e6f70c..fba0634 100644 --- a/lib/chessapp/chess_square.dart +++ b/lib/chessapp/chess_square.dart @@ -17,8 +17,7 @@ class ChessSquare extends StatelessWidget { const ChessSquare._( {required this.coordinate, required this.containedPiece, - required this.color, - super.key}); + required this.color}); factory ChessSquare(ChessCoordinate coord, ChessPiece? piece) { Color lightSquares = Colors.brown.shade50;