Skip to content
pubscout

string_similarity

2.2.0, released 8 months ago by jeremylandon.com

Finds the degree of similarity between strings using Dice's Coefficient.

WASM-ready
$ flutter pub add string_similarity
Source repository

What it does

Calculates the similarity fraction between two strings or finds the best matching string from a list of targets. It uses Dice's Coefficient and provides convenient string extensions.

AI-written summary of version 2.2.0, based on the package's README and metadata. Report an inaccuracy

Use it when

  • You need to implement fuzzy string searching or matching
  • You want to compare how similar two strings are

Skip it when

  • Comparing strings shorter than 2 characters, as they always return 0.0

Strengths

  • Provides both extension methods and static methods
  • Often performs better than Levenshtein distance for text comparison

Weaknesses

  • Strings shorter than 2 characters are not meaningful and return a similarity score of 0.0
  • Comparison is case and diacritic sensitive

Setup

Kind
Pure Dart
Effort
Low
Code generation
No
Direct dependencies
0
import 'package:string_similarity/string_similarity.dart';

var similarity = 'french'.similarityTo('quebec');
var matches = 'healed'.bestMatch(['edward', 'sealed', 'theatre']);

Alternatives

Packages that do the same job and could replace string_similarity.

Works with

Packages commonly used together with string_similarity: ones it builds on, ones built on it, and its own family.