Skip to content
Snippets Groups Projects
Select Git revision
  • 66513394a209811dd97838effb6aa2433b928336
  • master default protected
  • 101-upgrade-framework-and-dependencies
  • 84-improve-app-metadata
  • 82-fix-colors
  • 23-add-timer
  • 65-update-icons
  • Release_0.10.0_87 protected
  • Release_0.9.2_86 protected
  • Release_0.9.1_85 protected
  • Release_0.9.0_84 protected
  • Release_0.8.0_83 protected
  • Release_0.7.0_82 protected
  • Release_0.6.0_81 protected
  • Release_0.5.2_80 protected
  • Release_0.5.1_79 protected
  • Release_0.5.0_78 protected
  • Release_0.4.1_77 protected
  • Release_0.4.0_76 protected
  • Release_0.3.1_75 protected
  • Release_0.3.0_74 protected
  • Release_0.2.1_73 protected
  • Release_0.2.0_72 protected
  • Release_0.1.22_71 protected
  • Release_0.1.21_70 protected
  • Release_0.1.20_69 protected
  • Release_0.1.19_68 protected
27 results

batch.sh

Blame
  • game_pick_word.dart 5.19 KiB
    import 'package:flutter/material.dart';
    import 'package:provider/provider.dart';
    
    import '../provider/data.dart';
    import '../utils/random_pick_word.dart';
    import '../utils/get_image_from_word.dart';
    
    class GamePickWordPage extends StatelessWidget {
      int _count = 4;
    
      Future<void> startGame(BuildContext context, Data myProvider) async {
        await pickWord(context, myProvider);
        await pickImage(context, myProvider, myProvider.word);
      }
    
      Future<void> pickWord(BuildContext context, Data myProvider) async {
        List words;
        RandomPickWord randomPickWord;
        int attempts = 0;
        do {
          randomPickWord = RandomPickWord();
          await randomPickWord.init(_count);
          if (randomPickWord.words != null) {
            words = randomPickWord.words;
            break;
          }
          attempts++;
        } while (attempts < 3);
    
        if ((words != null) && (words.length == _count)) {
          myProvider.updateWord = words.take(1).toList()[0];
          myProvider.updateOtherWords = words.skip(1).toList();
        }
      }
    
      Future<void> pickImage(BuildContext context, Data myProvider, String word) async {
        List images;
        RandomPickImage randomPickImage;
        int attempts = 0;
        do {
          randomPickImage = RandomPickImage();
          await randomPickImage.init(word, _count);
          if (randomPickImage.images != null) {
            images = randomPickImage.images;
            break;
          }
          attempts++;
        } while (attempts < 3);
    
    
        if ((images != null) && (images.length == _count)) {
          myProvider.updateImages = images;
        }
      }
    
      Container _buildImageContainer(String image, Color color) {
        String imageAsset = 'assets/placeholder.png';
        if (image != null) {
            imageAsset = 'assets/images/'+image;
        }
    
        return Container(
          padding: EdgeInsets.all(5),
          child: FlatButton(
            color: Colors.teal,
            child: Image(image: AssetImage(imageAsset)),
          ),
        );
      }