Search packages, repositories and app categories

Package detailsv0.0.10+1

chrome_ai

Support for chrome AI in Flutter. This package is a wrapper for the Chrome AI API. It provides a simple way to use the Chrome AI API in Flutter.

30-day downloads
28
Likes
12
Pub points
40

Install package

flutter pub add chrome_ai

Package Overview

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

The chrome_ai package is a Flutter wrapper for the Chrome AI API, enabling developers to integrate Chrome AI capabilities into their Flutter applications. It simplifies access to AI-powered features such as natural language processing and generative responses. Designed for seamless use in Flutter projects, it abstracts complex API interactions into straightforward methods. The package is ideal for apps aiming to leverage AI-driven chat, content generation, or intelligent user assistance. It supports future platform expansion, though current platform support is unspecified.

Use cases

  • AI-powered chat interfaces
  • content generation in apps
  • smart assistant integrations
  • real-time language processing
  • enhanced user interaction with AI
  • automated response systems

Key features

  • Simple API wrapper for Chrome AI
  • Seamless Flutter integration
  • Supports generative AI tasks
  • Clean, easy-to-use methods
  • Future-ready for platform expansion
  • Lightweight and focused

Suitable for

  • Developers building AI-enhanced Flutter apps
  • Teams integrating Chrome AI features
  • Apps requiring real-time text generation
  • Prototyping AI-powered user experiences
  • Projects aiming for minimal setup overhead

Considerations

  • No platform-specific support listed
  • Relies on external Chrome AI API availability
  • Limited documentation implied
  • Requires internet connection for AI calls
  • Dependent on publisher's maintenance
  • Not suitable for offline AI functionality

Original README

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

pub package GitHub

ChromeAI

Recently, Chrome has added window.ai — a Gemini Nano AI model right inside your browser. This means that web developers can instantly and unlimitedly use on-device AI without any configuration.

I believe this will truly transform web applications. The use-cases are endless: smart auto-completion, error correction and validation, natural language filtering, auto-filling forms, UI suggestions, first-pass summarization, and search.

Accordingly, I have developed a library to enable this feature in Flutter. With this library, you can easily utilize the feature in Flutter web as well.

Installation

you can watch this video to see how to enable AI in Chrome and run this library.

1. Enable AI in Chrome

Chrome built-in AI is a preview feature, you need to use chrome version 127 or greater, now in dev or canary channel, may release on stable chanel at Jul 17, 2024.

After then, you should turn on these flags:

  • [chrome://flags/#prompt-api-for-gemini-nano](chrome://flags/#prompt-api-for-gemini-nano): Enabled
  • [chrome://flags/#optimization-guide-on-device-model](chrome://flags/#optimization-guide-on-device-model): Enabled BypassPrefRequirement
  • [chrome://components/](chrome://components/): Click Optimization Guide On Device Model to download the model.
2. Add library
flutter pub add chrome_ai
3. Run your project
1. Open terminal and run web-server
flutter run -d web-server
2. Open Chrome dev or canary, and open your project in http://localhost:port

Usage

Check Availability of Chrome AI
import 'package:chrome_ai/chrome_ai.dart';

final availability = await ChromeAI.canCreateTextSession();
if(availability == AIModelAvailability.no){
    // can not create text session
}else if(availability == AIModelAvailability.afterDownload) {
    // need to download model
}else if(availability == AIModelAvailability.readily){
    // model is ready
}
Generate Text
import 'package:chrome_ai/chrome_ai.dart';

final session = await ChromeAI.createTextSession();
var result = await session.prompt("why is the sky blue?");
print(result);  
Generate Streaming Text
import 'package:chrome_ai/chrome_ai.dart';

final session = await ChromeAI.createTextSession();
final stream = session.promptStreaming("why is the sky blue?");

stream.listen((result) {
  print(result);
}).onError((e, stackTrace) {
  print(e.toString());
});

Need Help!

This project is very new. If you have any questions, please open an issue. Contributions are very welcome.

Categories

Dependencies

Dependency list 1 items

  • js^0.7.1

Source repository

Projects using this package

No data available yet.