chromeapi 0.0.8 copy "chromeapi: ^0.0.8" to clipboard
chromeapi: ^0.0.8 copied to clipboard

discontinuedreplaced by: chrome_extension
Platformweb

Chrome Extension API wrapper

example/lib/main.dart

import 'package:chromeapi/tabs.dart';
import 'package:flutter/material.dart' hide Tab;

import 'qr_view.dart';

void main() => runApp(const MyApp());

Future<Tab> getActiveTab() async {
  QueryInfo queryInfo = QueryInfo(active: true, lastFocusedWindow: true);
  // Chrome library, not like JS namespaces
  // `chrome.tabs.query` just `query` in this case
  List<Tab> tabs = await query(queryInfo);
  return tabs.singleWhere((tab) => tab.url != null && tab.url!.isNotEmpty);
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Chrome Extension',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(primarySwatch: Colors.blue),
      home: FutureBuilder<Tab>(
        future: getActiveTab(),
        builder: (context, snapshot) {
          if (snapshot.hasData) {
            return QRView(qrText: snapshot.data!.url!);
          } else {
            return const Center(child: CircularProgressIndicator());
          }
        },
      ),
    );
  }
}
4
likes
110
pub points
0%
popularity

Publisher

unverified uploader

Chrome Extension API wrapper

Repository (GitHub)
View/report issues

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

js

More

Packages that depend on chromeapi