Skip to content

Commit

Permalink
singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
faithoflifedev committed Sep 3, 2024
1 parent 4ac90a6 commit 0eae6a5
Show file tree
Hide file tree
Showing 38 changed files with 1,193 additions and 1,198 deletions.
8 changes: 8 additions & 0 deletions packages/google_vision/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@

* switch to Singleton

## 1.4.0

* switch to Singleton

## 1.4.0

* switch to Singleton

## 1.3.0+4

* switch to Singleton
Expand Down
19 changes: 19 additions & 0 deletions packages/google_vision_flutter/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
# Changelog

## 1.4.0

* singleton

## 1.4.0

* updated example
* simplified FutureBuilder

## 1.3.0+4

* updated example
* simplified FutureBuilder

## 1.3.0+4

* updated example
* simplified FutureBuilder

## 1.3.0+4

* updated example
Expand Down
23 changes: 19 additions & 4 deletions packages/google_vision_flutter/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,19 @@ Please feel free to submit PRs for any additional helper methods, or report an [

[![Buy me a coffee](https://www.buymeacoffee.com/assets/img/guidelines/download-assets-1.svg)](https://www.buymeacoffee.com/faithoflif2)

## Recent Changes

### New for v1.4.0
- A **breaking change** from the previous version is that the `GoogleVision` class now follows the Singleton design pattern. Now the object is instantiated as follows:
```dart
// Old method from v1.3.x and earlier
// final googleVision = await GoogleVision.withJwtFile('service_credentials.json');
// New
final googleVision = await GoogleVision().withJwtFile('service_credentials.json');
```

## Getting Started

### pubspec.yaml
Expand All @@ -28,7 +41,7 @@ To use this package, add the dependency to your `pubspec.yaml` file:
```yaml
dependencies:
...
google_vision_flutter: ^1.3.0+4
google_vision_flutter: ^1.4.0
```
Expand All @@ -54,8 +67,10 @@ class LabelDetection extends StatefulWidget {
}

class _MyHomePageState extends State<LabelDetection> {
final imageAsset = 'assets/setagaya_small.jpg';

final _processImage = Image.asset(
'assets/setagaya_small.jpg',
imageAsset,
fit: BoxFit.fitWidth,
);

Expand All @@ -76,7 +91,7 @@ class _MyHomePageState extends State<LabelDetection> {
children: <Widget>[
const Padding(
padding: EdgeInsets.all(8.0),
child: Text('assets/setagaya_small.jpg'),
child: Text(imageAsset),
),
Padding(
padding: const EdgeInsets.all(8.0),
Expand All @@ -91,7 +106,7 @@ class _MyHomePageState extends State<LabelDetection> {
Padding(
padding: const EdgeInsets.all(8.0),
child: GoogleVisionBuilder.labelDetection(
googleVision: GoogleVision.withAsset(
googleVision: GoogleVision().withAsset(
'assets/service_credentials.json'),
imageProvider: _processImage.image,
builder: (
Expand Down
12 changes: 6 additions & 6 deletions packages/google_vision_flutter/example/.metadata
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# This file should be version controlled and should not be manually edited.

version:
revision: "b0850beeb25f6d5b10426284f506557f66181b36"
revision: "5874a72aa4c779a02553007c47dacbefba2374dc"
channel: "stable"

project_type: app
Expand All @@ -13,11 +13,11 @@ project_type: app
migration:
platforms:
- platform: root
create_revision: b0850beeb25f6d5b10426284f506557f66181b36
base_revision: b0850beeb25f6d5b10426284f506557f66181b36
- platform: web
create_revision: b0850beeb25f6d5b10426284f506557f66181b36
base_revision: b0850beeb25f6d5b10426284f506557f66181b36
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
- platform: ios
create_revision: 5874a72aa4c779a02553007c47dacbefba2374dc
base_revision: 5874a72aa4c779a02553007c47dacbefba2374dc

# User provided section

Expand Down
16 changes: 16 additions & 0 deletions packages/google_vision_flutter/example/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# example

A new Flutter project.

## Getting Started

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)

For help getting started with Flutter development, view the
[online documentation](https://docs.flutter.dev/), which offers tutorials,
samples, guidance on mobile development, and a full API reference.
75 changes: 0 additions & 75 deletions packages/google_vision_flutter/example/lib/crop_hints.dart

This file was deleted.

45 changes: 45 additions & 0 deletions packages/google_vision_flutter/example/lib/crop_hints_page.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import 'package:flutter/material.dart';
import 'package:google_vision_flutter/google_vision_flutter.dart';
import 'example_base.dart';

class CropHintsPage extends ExampleBase {
static const assetName = 'assets/young-man-smiling.jpg';

final _processImage = Image.asset(
assetName,
fit: BoxFit.fitWidth,
);

CropHintsPage({
super.key,
required super.googleVision,
required super.title,
});

@override
Widget build(BuildContext context) => SafeArea(
child: Scaffold(
appBar: getAppBar(context),
body: simpleColumn(
assetName: assetName,
sampleImage: _processImage,
result: GoogleVisionBuilder.cropHints(
googleVision: googleVision,
imageProvider: _processImage.image,
builder: (
BuildContext context,
CropHintsAnnotation? cropHintsAnnotation,
) =>
Padding(
padding: const EdgeInsets.all(8.0),
child: Column(
children: cropHintsAnnotation!.cropHints
.map((cropHint) => Center(
child: Text('$cropHint'),
))
.toList()),
),
)),
),
);
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,29 +1,21 @@
import 'package:flutter/material.dart';
import 'package:google_vision_flutter/google_vision_flutter.dart';
import 'package:vision_demo/show_pdf.dart';
import 'example_base.dart';
import 'show_pdf.dart';

class DocumentTextDetectionFile extends StatefulWidget {
const DocumentTextDetectionFile({super.key, required this.title});

final String title;

@override
State<DocumentTextDetectionFile> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<DocumentTextDetectionFile> {
class DocumentTextDetectionFilePage extends ExampleBase {
static const assetName = 'assets/allswell.pdf';

const DocumentTextDetectionFilePage({
super.key,
required super.googleVision,
required super.title,
});

@override
Widget build(BuildContext context) => SafeArea(
child: Scaffold(
appBar: AppBar(
leading: IconButton(
icon: const Icon(Icons.arrow_back, color: Colors.black),
onPressed: () => Navigator.of(context).pop(),
),
title: Text(widget.title),
),
appBar: getAppBar(context),
body: SingleChildScrollView(
child: Center(
child: Column(
Expand Down Expand Up @@ -52,8 +44,7 @@ class _MyHomePageState extends State<DocumentTextDetectionFile> {
Padding(
padding: const EdgeInsets.all(8.0),
child: GoogleVisionFileBuilder.documentTextDetection(
googleVision: GoogleVision.withAsset(
'assets/service_credentials.json'),
googleVision: googleVision,
inputConfig: InputConfig.fromAsset('assets/allswell.pdf'),
builder: (
BuildContext context,
Expand Down
Loading

0 comments on commit 0eae6a5

Please sign in to comment.