-1

I am creating my first Flutter app for web. I need using Chrome api. For example I need to use it:

chrome.runtime.onInstalled.addListener

   or

   chrome.tabs...

but unfortunately I did not find any information about it.

Is it possible?

FetFrumos
  • 4,828
  • 4
  • 46
  • 77

1 Answers1

1

Yes, the chrome.* APIs are JavaScript just like all the other web APIs, so you can use Dart's JS support.

That means using Dart's js library.

For example, you could bind a function something like this (untested, without any type annotation, just an example)

@JS('chrome.runtime.onInstalled.addListener')
external void addInstalledListener(Function callback);

Edit: If you'd rather pull in a dependency than roll your own, you can use something like chrome.dart.

import 'package:chrome/chrome_app.dart' as chrome;

void main() {
  chrome.runtime.getPlatformInfo().then((Map m) {
    print(m.toString());
  });
}
AlexApps99
  • 1,632
  • 6
  • 11