google_vision_flutter 2.0.0+3 copy "google_vision_flutter: ^2.0.0+3" to clipboard
google_vision_flutter: ^2.0.0+3 copied to clipboard

Add Google Visions image labeling, face, logo, and landmark detection into your Flutter applications.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:google_vision_flutter/google_vision_flutter.dart'
    hide WebDetection;

import 'crop_hints_page.dart';
import 'document_text_detection_page.dart';
import 'document_text_detection_file_page.dart';
import 'face_detection_page.dart';
import 'image_properties_page.dart';
import 'label_detection_page.dart';
import 'landmark_detection_page.dart';
import 'logo_detection_page.dart';
import 'multiple_detections_page.dart';
import 'multiple_face_detections_page.dart';
import 'object_localization_page.dart';
import 'safe_search_detection_page.dart';
import 'text_detection_page.dart';
import 'web_detection_page.dart';

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  final googleVision =
      GoogleVision().withAsset('assets/service_credentials.json');

  MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      routes: {
        '/': (context) => const MenuScreen(),
        '/multiple': (context) => MultipleDetectionsPage(
              googleVision: googleVision,
              title: 'Multiple Detections',
            ),
        '/cropHints': (context) => CropHintsPage(
              googleVision: googleVision,
              title: 'Crop Hints',
            ),
        '/documentTextDetection': (context) => DocumentTextDetectionPage(
              googleVision: googleVision,
              title: 'Document Text Detection',
            ),
        '/documentTextDetectionFile': (context) =>
            DocumentTextDetectionFilePage(
              googleVision: googleVision,
              title: 'Document Text Detection',
            ),
        '/faceDetection': (context) => FaceDetectionPage(
              googleVision: googleVision,
              title: 'Face Detection',
            ),
        '/imageProperties': (context) => ImagePropertiesPage(
              googleVision: googleVision,
              title: 'Image Properties',
            ),
        '/labelDetection': (context) => LabelDetectionPage(
              googleVision: googleVision,
              title: 'Label Detection',
            ),
        '/landmarkDetection': (context) => LandmarkDetectionPage(
              googleVision: googleVision,
              title: 'Landmark Detection',
            ),
        '/logoDetection': (context) => LogoDetectionPage(
              googleVision: googleVision,
              title: 'Logo Detection',
            ),
        '/objectLocalization': (context) => ObjectLocalizationPage(
              googleVision: googleVision,
              title: 'Object Localization',
            ),
        '/safeSearchDetection': (context) => SafeSearchDetectionPage(
              googleVision: googleVision,
              title: 'Safe Search Detection',
            ),
        '/textDetection': (context) => TextDetectionPage(
              googleVision: googleVision,
              title: 'Text Detection',
            ),
        '/webDetection': (context) => WebDetectionPage(
              googleVision: googleVision,
              title: 'Web Detection',
            ),
        '/multipleFace': (context) => MultipleFaceDetectionPage(
              googleVision: googleVision,
              title: 'Multiple Image Face Detection',
            ),
      },
    );
  }
}

class MenuScreen extends StatelessWidget {
  const MenuScreen({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Menu'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.spaceEvenly,
          children: [
            const SizedBox(
              height: 30,
              child: Text('Image Functions'),
            ),
            ElevatedButton(
              child: const Text('Multiple Detections'),
              onPressed: () => Navigator.pushNamed(context, '/multiple'),
            ),
            ElevatedButton(
              child: const Text('Crop Hints'),
              onPressed: () => Navigator.pushNamed(context, '/cropHints'),
            ),
            ElevatedButton(
              child: const Text('Document Text Detection'),
              onPressed: () =>
                  Navigator.pushNamed(context, '/documentTextDetection'),
            ),
            ElevatedButton(
              child: const Text('Face Detection'),
              onPressed: () => Navigator.pushNamed(context, '/faceDetection'),
            ),
            ElevatedButton(
              child: const Text('Image Properties'),
              onPressed: () => Navigator.pushNamed(context, '/imageProperties'),
            ),
            ElevatedButton(
              child: const Text('Label Detection'),
              onPressed: () => Navigator.pushNamed(context, '/labelDetection'),
            ),
            ElevatedButton(
              child: const Text('Landmark Detection'),
              onPressed: () =>
                  Navigator.pushNamed(context, '/landmarkDetection'),
            ),
            ElevatedButton(
              child: const Text('Logo Detection'),
              onPressed: () => Navigator.pushNamed(context, '/logoDetection'),
            ),
            ElevatedButton(
              child: const Text('Object Localization'),
              onPressed: () =>
                  Navigator.pushNamed(context, '/objectLocalization'),
            ),
            ElevatedButton(
              child: const Text('Safe Search Detection'),
              onPressed: () =>
                  Navigator.pushNamed(context, '/safeSearchDetection'),
            ),
            ElevatedButton(
              child: const Text('Text Detection'),
              onPressed: () => Navigator.pushNamed(context, '/textDetection'),
            ),
            ElevatedButton(
              child: const Text('Web Detection'),
              onPressed: () => Navigator.pushNamed(context, '/webDetection'),
            ),
            ElevatedButton(
              child: const Text('Multiple Image Face Detection'),
              onPressed: () => Navigator.pushNamed(context, '/multipleFace'),
            ),
            const SizedBox(
              height: 30,
              child: Text('File Functions'),
            ),
            ElevatedButton(
              child: const Text('Document Text Detection from PDF'),
              onPressed: () =>
                  Navigator.pushNamed(context, '/documentTextDetectionFile'),
            ),
          ],
        ),
      ),
    );
  }
}
10
likes
160
pub points
71%
popularity

Publisher

verified publishermuayid.com

Add Google Visions image labeling, face, logo, and landmark detection into your Flutter applications.

Homepage
Repository (GitHub)
View/report issues

Topics

#api #widget #flutter #image #document

Documentation

API reference

Funding

Consider supporting this project:

www.buymeacoffee.com

License

MIT (license)

Dependencies

dio, flutter, flutter_image_converter, google_vision, image, loggy

More

Packages that depend on google_vision_flutter