Skip to content
Snippets Groups Projects
Select Git revision
  • 162bc3791d77bf2d0a57fbf3d3944639f525e362
  • master default protected
  • 63-upgrade-framework-and-dependencies
  • 45-improve-app-metadata
  • Release_0.9.0_57 protected
  • Release_0.8.2_56 protected
  • Release_0.8.1_55 protected
  • Release_0.8.0_54 protected
  • Release_0.7.0_53 protected
  • Release_0.6.0_52 protected
  • Release_0.5.0_51 protected
  • Release_0.4.2_50 protected
  • Release_0.4.1_49 protected
  • Release_0.4.0_48 protected
  • Release_0.3.1_47 protected
  • Release_0.3.0_46 protected
  • Release_0.2.2_45 protected
  • Release_0.2.1_44 protected
  • Release_0.2.0_43 protected
  • Release_0.1.2_42 protected
  • Release_0.1.1_41 protected
  • Release_0.1.0_40 protected
  • Release_0.0.39_39 protected
  • Release_0.0.38_38 protected
24 results

cell.dart

Blame
  • key.dart 1.62 KiB
    import 'package:flutter/material.dart';
    import 'package:flutter_custom_toolbox/flutter_toolbox.dart';
    
    import 'package:momomotus/cubit/game_cubit.dart';
    
    class KeyWidget extends StatelessWidget {
      const KeyWidget({
        super.key,
        required this.caption,
      });
    
      final String caption;
    
      @override
      Widget build(BuildContext context) {
        String keyText = caption;
        if (caption == '<') {
          keyText = '⬅️';
        } else if (caption == '!') {
          keyText = '☑️';
        }
    
        const Color keyColor = Colors.black;
    
        if (caption == ' ') {
          return const SizedBox();
        }
    
        return Stack(
          alignment: Alignment.center,
          children: <Widget>[
            const Image(
              image: AssetImage('assets/ui/key.png'),
              fit: BoxFit.fill,
            ),
            Center(
              child: TextButton(
                style: TextButton.styleFrom(
                  padding: const EdgeInsets.all(0),
                ),
                child: Text(
                  keyText,
                  style: const TextStyle(
                    color: keyColor,
                    fontSize: 30.0,
                    fontWeight: FontWeight.w800,
                  ),
                  textAlign: TextAlign.center,
                ),
                onPressed: () {
                  if (caption == '<') {
                    BlocProvider.of<GameCubit>(context).currentGuessRemoveLetter();
                  } else if (caption == '!') {
                    BlocProvider.of<GameCubit>(context).submitWord();
                  } else if (caption != ' ') {
                    BlocProvider.of<GameCubit>(context).currentGuessAddLetter(caption);
                  }
                },
              ),
            ),
          ],
        );
      }
    }