Package selection guidance compiled from public package information, community data, and project usage.
A Dart library that enables access to Chrome extension APIs such as `chrome.runtime`, `chrome.storage`, and `chrome.tabs` within Flutter web applications. Designed specifically for developers building Chrome extensions using Flutter, it provides a type-safe interface to interact with browser-level functionality. The package bridges the gap between Flutter's web capabilities and native Chrome extension features, allowing seamless integration of extension-specific behaviors like background scripts, popup interactions, and storage management. It is maintained by xaha.dev and hosted on GitHub for transparency and community contributions.
Use cases
Building Chrome extensions with Flutter
Accessing browser storage in web apps
Managing tabs and runtime events
Creating popup interfaces
Implementing background services
Key features
Direct access to chrome.* APIs
Type-safe Dart wrappers
Web-only compatibility
GitHub-hosted source code
Simple pub add integration
Suitable for
Flutter web developers
Chrome extension creators
Browser automation projects
Cross-platform extension tools
Dart-focused web app builders
Considerations
Only works on web platform
Requires Chrome extension manifest setup
Limited to Chrome-specific features
Not compatible with non-Chrome browsers
Depends on JavaScript interop
Original README
Original README snapshot from the linked source repository. Visit the repository for the latest content.
chrome_extension.dart
A library for accessing the chrome.*APIs available in Chrome extensions.
This allows to build Chrome extension with Dart & Flutter and to interop with the native APIs easily with a high-level type-safe interface.
The JS interop is build on top of dart:js_interop (static interop) which make it ready for future WASM compilation.
See example folder for some examples of Flutter and Dart Chrome extensions
Tips to build Chrome extensions with Flutter
Here are some personal tips to build Chrome extension using the Flutter UI framework.
Develop the app using Flutter Desktop
In order to develop in a comfortable environment with hot-reload,
most of the app (the UI part) should be developed using Flutter desktop.
This requires an abstraction layer between the UI and the chrome_extension APIs.
In the Desktop entry point, a fake implementation of this abstraction layer is used, like this:
// lib/main_desktop.dartvoidmain() {
// Inject a fake service that doesn't use the real chrome_extension package.var service = FakeBookmarkService();
runApp(MyExtensionPopup(service));
}
abstractclassBookmarkService{
Future<List<Bookmark>> getBookmarks();
}
classFakeBookmarkServiceimplementsBookmarkService{
@overrideFuture<List<Bookmark>> getBookmarks() async => [Bookmark()];
}
Launch this entry point in desktop with flutter run -t lib/main_desktop.dart -d macos|windows|linux
And the real entry point (the one used in the actual compiled extension) looks like:
// lib/main.dartvoidmain() {
var service = ChromeBookmarkService();
runApp(MyExtensionPopup(service));
}
classChromeBookmarkServiceimplementsBookmarkService{
@overrideFuture<List<Bookmark>> getBookmarks() async {
// Real implementation using chrome.bookmarksreturn (await chrome.bookmarks.getTree()).map(Bookmark.new).toList();
}
}