Search packages, repositories and app categories

Package detailsv0.19.0

meilisearch

Meilisearch Dart is the Meilisearch API client for Dart and Flutter developers.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
4.2K
Likes
65
Pub points
140

Install package

flutter pub add meilisearch

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

Meilisearch Dart is a lightweight API client for Dart and Flutter applications, enabling seamless integration with Meilisearch, a fast, relevant, and customizable search engine. It allows developers to perform real-time searches, manage indexes, and handle document updates directly from their apps. The client supports all major platforms including Android, iOS, Web, macOS, Windows, and Linux, making it ideal for cross-platform search functionality. With intuitive methods and minimal setup, it simplifies adding powerful search capabilities to any Flutter project.

Use cases

  • Real-time search in mobile apps
  • Index management in Flutter
  • Full-text search across multiple platforms
  • Search suggestions and autocomplete
  • Document indexing and updates
  • Cross-platform search implementation

Key features

  • Simple API for search operations
  • Supports all major platforms
  • Real-time search results
  • Easy index and document handling
  • Lightweight and fast
  • Built-in error handling

Suitable for

  • Flutter developers needing search features
  • Apps requiring fast full-text search
  • Projects targeting multiple platforms
  • Teams using Meilisearch backend
  • Developers wanting low-latency search

Considerations

  • Requires a running Meilisearch server
  • Needs proper API key management
  • Limited to Meilisearch backend
  • Network dependency for search queries
  • Not suitable for offline-only search

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

Meilisearch

Meilisearch Dart

Meilisearch | Meilisearch Cloud | Documentation | Discord | Roadmap | Website | FAQ

Pub Version GitHub Workflow Status License Code Coverage

⚡ The Meilisearch API client written in Dart

Meilisearch Dart is the Meilisearch API client for Dart and Flutter developers.

Meilisearch is an open-source search engine. Learn more about Meilisearch.

Table of Contents

📖 Documentation

This readme contains all the documentation you need to start using this Meilisearch SDK.

For general information on how to use Meilisearch—such as our API reference, tutorials, guides, and in-depth articles—refer to our main documentation website.

🔧 Installation

You can install the meilisearch package by adding a few lines into pubspec.yaml file.

dependencies:
  meilisearch: ^0.19.0

Then open your terminal and update dart packages.

pub get
Run Meilisearch

⚡️ Launch, scale, and streamline in minutes with Meilisearch Cloud—no maintenance, no commitment, cancel anytime. Try it free now.

🪨 Prefer to self-host? Download and deploy our fast, open-source search engine on your own infrastructure.

🚀 Getting started

Add Documents
import 'package:meilisearch/meilisearch.dart';

void main() async {
  var client = MeiliSearchClient('http://127.0.0.1:7700', 'masterKey');

  // An index is where the documents are stored.
  var index = client.index('movies');

  const documents = [
    { 'id': 1, 'title': 'Carol', 'genres': ['Romance', 'Drama'] },
    { 'id': 2, 'title': 'Wonder Woman', 'genres': ['Action', 'Adventure'] },
    { 'id': 3, 'title': 'Life of Pi', 'genres': ['Adventure', 'Drama'] },
    { 'id': 4, 'title': 'Mad Max: Fury Road', 'genres': ['Adventure', 'Science Fiction'] },
    { 'id': 5, 'title': 'Moana', 'genres': ['Fantasy', 'Action']},
    { 'id': 6, 'title': 'Philadelphia', 'genres': ['Drama'] },
  ]

  // If the index 'movies' does not exist, Meilisearch creates it when you first add the documents.
  var task = await index.addDocuments(documents); // => { "uid": 0 }
}

With the uid, you can check the status (enqueued, canceled, processing, succeeded or failed) of your documents addition using the task.

Basic Search
// Meilisearch is typo-tolerant:
var result = await index.search('carlo');

print(result.hits);

JSON Output:

[
  {
    "id": 1,
    "title": "Carol",
    "genres": ["Romance", "Drama"]
  }
]
Custom Search

All the supported options are described in the search parameters section of the documentation.

var result = await index.search(
  'carol',
  attributesToHighlight: ['title'],
);

JSON output:

{
    "hits": [
        {
            "id": 1,
            "title": "Carol",
            "_formatted": {
                "id": 1,
                "title": "<em>Carol</em>"
            }
        }
    ],
    "offset": 0,
    "limit": 20,
    "processingTimeMs": 0,
    "query": "carol"
}
Custom Search With Filters

If you want to enable filtering, you must add your attributes to the filterableAttributes index setting.

await index.updateFilterableAttributes(['id', 'genres']);

You only need to perform this operation once.

Note that MeiliSearch will rebuild your index whenever you update filterableAttributes. Depending on the size of your dataset, this might take time. You can track the process using the task status.

Then, you can perform the search:

await index.search('wonder', filter: ['id > 1 AND genres = Action']);
{
  "hits": [
    {
      "id": 2,
      "title": "Wonder Woman",
      "genres": ["Action","Adventure"]
    }
  ],
  "offset": 0,
  "limit": 20,
  "estimatedTotalHits": 1,
  "processingTimeMs": 0,
  "query": "wonder"
}

Advanced Configuration

Customizing the dio instance

Meilisearch uses dio internally to send requests, you can provide it with your own interceptors or adapter using the MeiliSearchClient.withCustomDio constructor.

Using MeiliDocumentContainer

The MeiliDocumentContainer<T> class contains meilisearch-specific fields (e.g. rankingScoreDetails, _formatted, matchesPosition, etc...).

We define the mapToContainer() extension to help you quickly opt-in to this class, example:

final res = await index
      .search("hello world")
      .asSearchResult() //or .asPaginatedResult() if using page parameters
      .mapToContainer();

🤖 Compatibility with Meilisearch

This package guarantees compatibility with version v1.x of Meilisearch, but some features may not be present. Please check the issues for more info.

💡 Learn more

The following sections in our main documentation website may interest you:

⚙️ Contributing

Any new contribution is more than welcome in this project!

If you want to know more about the development workflow or want to contribute, please visit our contributing guidelines for detailed instructions!


Meilisearch provides and maintains many SDKs and Integration tools like this one. We want to provide everyone with an amazing search experience for any kind of project. If you want to contribute, make suggestions, or just know what's going on right now, visit us in the integration-guides repository.

Categories

Dependencies

Dependency list 5 items

Source repository

Projects using this package