Skip to content
Snippets Groups Projects
Select Git revision
  • 21454327375a1c6adeb4ba86d594f6be873a1911
  • master default protected
  • 58-upgrade-framework-and-dependencies
  • 49-fix-end-game
  • 40-improve-app-metadata
  • 12-improve-layout
  • 4-add-animations
  • Release_0.9.0_46 protected
  • Release_0.8.2_45 protected
  • Release_0.8.1_44 protected
  • Release_0.8.0_43 protected
  • Release_0.7.0_42 protected
  • Release_0.6.0_41 protected
  • Release_0.5.0_40 protected
  • Release_0.4.2_39 protected
  • Release_0.4.1_38 protected
  • Release_0.4.0_37 protected
  • Release_0.3.1_36 protected
  • Release_0.3.0_35 protected
  • Release_0.2.1_34 protected
  • Release_0.2.0_33 protected
  • Release_0.1.2_32 protected
  • Release_0.1.1_31 protected
  • Release_0.1.0_30 protected
  • Release_0.0.29_29 protected
  • Release_0.0.28_28 protected
  • Release_0.0.27_27 protected
27 results

board.dart

Blame
  • board.dart 3.36 KiB
    import 'package:flutter/material.dart';
    
    import '../provider/data.dart';
    import '../utils/game_utils.dart';
    
    class Board {
      static Container buildGameBoard(Data myProvider) {
        String skin = myProvider.skin;
    
        int maxGuessesCount = myProvider.maxGuessesCount;
        int wordLength = int.parse(myProvider.length);
    
        Widget buildCellWidget(
            String cellValue, String cellTip, bool hasFocus, String foundLetter) {
          Color textColor = Colors.white;
          Color focusBorderColor = Colors.yellow.shade700;
          Color defaultBorderColor = Colors.white;
    
          String cellImage = 'empty';
          if (cellTip != '') {
            cellImage = cellTip;
          }
    
          if ((foundLetter != ' ') && (cellValue == ' ')) {
            cellValue = foundLetter;
            cellImage = 'good';
          }
    
          Image imageWidget = Image(
            image: AssetImage('assets/skins/' + skin + '_' + cellImage + '.png'),
            fit: BoxFit.fill,
          );
    
          Widget cellBackground = Container(
            decoration: BoxDecoration(
              border: Border.all(
                width: 4.0,
                color: hasFocus ? focusBorderColor : defaultBorderColor,
                style: BorderStyle.solid,
              ),
            ),
            child: imageWidget,
          );
    
          Text textWidget = Text(
            cellValue,
            style: TextStyle(
              color: textColor,
              fontSize: 40.0,
              fontWeight: FontWeight.w900,
            ),
            textAlign: TextAlign.center,
          );
    
          return Stack(
            alignment: Alignment.center,
            children: <Widget>[
              cellBackground,
              Center(child: textWidget),
            ],
          );
        }
    
        List<String> guesses = myProvider.guesses;
    
        List<TableRow> tableRows = [];
        for (int lineIndex = 0; lineIndex < maxGuessesCount; lineIndex++) {
          String word = '';
          if (lineIndex < guesses.length) {
            word = guesses[lineIndex];