google_api_headers 4.2.6 copy "google_api_headers: ^4.2.6" to clipboard
google_api_headers: ^4.2.6 copied to clipboard

A Flutter plugin for getting the headers required to call Google APIs with an app restricted API key

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:google_api_headers/google_api_headers.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends State<MyApp> {
  Map<String, String>? _headers;

  @override
  void initState() {
    super.initState();
    getHeaders();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Text(
            'Google API headers: ${_headers.toString()}',
            textAlign: TextAlign.center,
          ),
        ),
      ),
    );
  }

  Future<void> getHeaders() async {
    final headers = await const GoogleApiHeaders().getHeaders();
    setState(() => _headers = headers);
  }
}
27
likes
160
pub points
98%
popularity

Publisher

unverified uploader

A Flutter plugin for getting the headers required to call Google APIs with an app restricted API key

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, package_info_plus

More

Packages that depend on google_api_headers