word_search 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

word_search #

Coverage

Word Search

A word search puzzle generator built with dart

Example Usage #

import 'package:word_search/word_search.dart';

/**
 * The main file to test out the word search library
 */
void main() {
  print('Word Search Library!');

  // Create a list of words to be jumbled into a puzzle
  final List<String> wl = ['hello', 'world', 'foo', 'bar', 'baz', 'dart'];

  // Create the puzzle sessting object
  final WSSettings ws = WSSettings(
    width: 10,
    height: 10,
    orientations: List.from([
      WSOrientation.horizontal,
      WSOrientation.vertical,
      WSOrientation.diagonal,
    ]),
  );

  // Create new instance of the WordSearch class
  final WordSearch wordSearch = WordSearch();

  // Create a new puzzle
  final WSNewPuzzle newPuzzle = wordSearch.newPuzzle(wl, ws);

  /// Check if there are errors generated while creating the puzzle
  if (newPuzzle.errors.isEmpty) {
    // The puzzle output
    print('Puzzle 2D List');
    print(newPuzzle.toString());

    // Solve puzzle for given word list
    final WSSolved solved =
        wordSearch.solvePuzzle(newPuzzle.puzzle, ['dart', 'word']);
    // All found words by solving the puzzle
    print('Found Words!');
    solved.found.forEach((element) {
      print('word: ${element.word}, orientation: ${element.orientation}');
      print('x:${element.x}, y:${element.y}');
    });

    // All words that could not be found
    print('Not found Words!');
    solved.notFound.forEach((element) {
      print('word: ${element}');
    });
  } else {
    // Notify the user of the errors
    newPuzzle.errors.forEach((error) {
      print(error);
    });
  }
}

Example Output #

Word Search output

Testing #

This library uses test_coverage testing library.

To run tests

pub run test_coverage

To view coverage report

genhtml -o coverage coverage/lcov.info

Note: If you do not have genhtml on your command line you can use brew install lcov on mac.

0.1.2 #

  • Updated readme to be more user friendly

0.1.1 #

  • Updated pubspec file to have leaner description

0.1.0 #

  • Updated src files to use helpers as per pub.dev recommendations
  • Updated pubspec file to have more elaborate description

0.0.1 #

  • Added core implementation for the word search puzzle

example/main.dart

import 'package:word_search/word_search.dart';

/**
 * The main file to test out the word search library
 */
void main() {
  print('Word Search Library!');

  // Create a list of words to be jumbled into a puzzle
  final List<String> wl = ['hello', 'world', 'foo', 'bar', 'baz', 'dart'];

  // Create the puzzle sessting object
  final WSSettings ws = WSSettings(
    width: 10,
    height: 10,
    orientations: List.from([
      WSOrientation.horizontal,
      WSOrientation.vertical,
      WSOrientation.diagonal,
    ]),
  );

  // Create new instance of the WordSearch class
  final WordSearch wordSearch = WordSearch();

  // Create a new puzzle
  final WSNewPuzzle newPuzzle = wordSearch.newPuzzle(wl, ws);

  /// Check if there are errors generated while creating the puzzle
  if (newPuzzle.errors.isEmpty) {
    // The puzzle output
    print('Puzzle 2D List');
    print(newPuzzle.toString());

    // Solve puzzle for given word list
    final WSSolved solved =
        wordSearch.solvePuzzle(newPuzzle.puzzle, ['dart', 'word']);
    // All found words by solving the puzzle
    print('Found Words!');
    solved.found.forEach((element) {
      print('word: ${element.word}, orientation: ${element.orientation}');
      print('x:${element.x}, y:${element.y}');
    });

    // All words that could not be found
    print('Not found Words!');
    solved.notFound.forEach((element) {
      print('word: ${element}');
    });
  } else {
    // Notify the user of the errors
    newPuzzle.errors.forEach((error) {
      print(error);
    });
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  word_search: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:word_search/word_search.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
40
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
70
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
Dev dependencies
test ^1.14.5
test_coverage ^0.4.1