Skip to content
Snippets Groups Projects
Select Git revision
  • 5d04b26c837cada1640819cd938d130e95dbe7f2
  • master default protected
  • 87-upgrade-framework-and-dependencies
  • 70-improve-app-metadata
  • Release_0.9.0_77 protected
  • Release_0.8.2_76 protected
  • Release_0.8.1_75 protected
  • Release_0.8.0_74 protected
  • Release_0.7.0_73 protected
  • Release_0.6.0_72 protected
  • Release_0.5.0_71 protected
  • Release_0.4.2_70 protected
  • Release_0.4.1_69 protected
  • Release_0.4.0_68 protected
  • Release_0.3.1_67 protected
  • Release_0.3.0_66 protected
  • Release_0.2.1_65 protected
  • Release_0.2.0_64 protected
  • Release_0.1.1_63 protected
  • Release_0.1.0_62 protected
  • Release_0.0.61_61 protected
  • Release_0.0.60_60 protected
  • Release_0.0.59_59 protected
  • Release_0.0.58_58 protected
24 results

activity.dart

Blame
  • keyboard.dart 1.90 KiB
    import 'dart:math';
    
    import 'package:flutter/material.dart';
    
    import '../provider/data.dart';
    import '../utils/game_utils.dart';
    
    class Keyboard {
    
      static Container buildWidget(Data myProvider) {
        final List<List<String>> keys = [
          ['A', 'Z', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P'],
          ['Q', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'M'],
          ['<', ' ', 'W', 'X', 'C', 'V', 'B', 'N', ' ', '!'],
        ];
    
        Widget buildKeyWidget(String key) {
          String displayedText = key;
          if (key == '<') {
            displayedText = '⬅️';
          } else if (key == '!') {
            displayedText = '☑️';
          }
    
          Color keyColor = Colors.black;
    
          return FlatButton(
            child: Text(
              displayedText,
              style: TextStyle(
                color: keyColor,
                fontSize: 30.0,
                fontWeight: FontWeight.w800,
              ),
              textAlign: TextAlign.center
            ),
            onPressed: () {
              if (key == '<') {
                GameUtils.removeLetter(myProvider);
              } else if (key == '!') {
                GameUtils.submitWord(myProvider);
              } else if (key != ' ') {
                GameUtils.addLetter(myProvider, key);
              }
            },
          );
        }
    
        List<TableRow> tableRows = [];
        keys.forEach((row) {
          List<Column> tableCells = [];
          row.forEach((key) {
            tableCells.add(
              Column(
                children: [ buildKeyWidget(key) ]
              )
            );
          });
          tableRows.add(
            TableRow(
              children: tableCells
            )
          );
        });
    
        return Container(
          margin: EdgeInsets.symmetric(horizontal: 2),
          padding: EdgeInsets.all(2),
    
          child: Table(