fuzzy 0.2.1

Fuzzy

Pub Package CI

Fuzzy search in Dart.

This project is basically a code conversion, subset of Fuse.js.

Installation #

add the following to your pubspec.yaml file:

dependencies:
  fuzzy: <1.0.0

then run:

pub get

or with flutter:

flutter packages get

Usage #

import 'package:fuzzy/fuzzy.dart';

void main() {
  final fuse = Fuzzy(['apple', 'banana', 'orange']);

  final result = fuse.search('ran');

  result.map((r) => r.output.first.value).forEach(print);
}

Don't forget to take a look at FuzzyOptions!

CHANGELOG #

0.2.1 #

  • Fix bug for search empty list

0.2.0+8 #

  • Testing GitHub actions

0.2.0 #

  • Make it generic (to use a List

0.1.1 #

  • Add string normalization, from latinize

0.1.0 #

  • First usable version, fixing stupid bugs from conversion, and with tests

0.0.2 #

  • Code ported from Fuse.js

0.0.1 #

  • Initial commit

example/main.dart

import 'package:fuzzy/fuzzy.dart';

void main() {
  final bookList = [
    'Old Man\'s War',
    'The Lock Artist',
    'HTML5',
    'Right Ho Jeeves',
    'The Code of the Wooster',
    'Thank You Jeeves',
    'The DaVinci Code',
    'Angels & Demons',
    'The Silmarillion',
    'Syrup',
    'The Lost Symbol',
    'The Book of Lies',
    'Lamb',
    'Fool',
    'Incompetence',
    'Fat',
    'Colony',
    'Backwards, Red Dwarf',
    'The Grand Design',
    'The Book of Samson',
    'The Preservationist',
    'Fallen',
    'Monster 1959',
  ];
  final fuse = Fuzzy(
    bookList,
    options: FuzzyOptions(
      findAllMatches: true,
      tokenize: true,
      threshold: 0.5,
    ),
  );

  final result = fuse.search('book');

  print(
      'A score of 0 indicates a perfect match, while a score of 1 indicates a complete mismatch.');

  result.forEach((r) {
    print('\nScore: ${r.score}\nTitle: ${r.item}');
  });
}

Use this package as a library

1. Depend on it

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


dependencies:
  fuzzy: ^0.2.1

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:fuzzy/fuzzy.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
80
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]
90
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.5

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
latinize ^0.0.2 0.0.2
Dev dependencies
pedantic ^1.9.0
test ^1.9.4