An open API service indexing awesome lists of open source software.

https://github.com/paishanmadusha/firebase-ml-text-recognition-app

Text Recognition is a Flutter application that uses Firebase ML Kit to recognize and extract text from images. Users can capture or upload images to extract text using machine learning. Additionally, a premium feature enabled via Stripe-powered subscription payments allows users to view their previous text captures.
https://github.com/paishanmadusha/firebase-ml-text-recognition-app

anonymous dart firebase firebase-storage firestore flutter flutter-dotenv http image-picker machine-learning payment-gateway premium provider stripe stripe-api stripe-payments

Last synced: about 1 month ago
JSON representation

Text Recognition is a Flutter application that uses Firebase ML Kit to recognize and extract text from images. Users can capture or upload images to extract text using machine learning. Additionally, a premium feature enabled via Stripe-powered subscription payments allows users to view their previous text captures.

Awesome Lists containing this project

README

          

# ๐Ÿค– Firebase ML Text Recognition App

A Flutter application that uses **Firebase Machine Learning Kit** for **text recognition** from images. Users can capture or upload images through the app to extract text using Firebase ML Kit. Additionally, a **premium feature** allows users to view their previously captured text, enabled via **Stripe-powered subscription payments**.

---

## โœจ Features:

### ๐Ÿ“ธ Text Recognition:
- Select an image from the gallery or take a new photo.
- Detect and extract text using Google Machine Learning Kit's Text Recognition.
- Copy captured text to the clipboard easily.

### ๐Ÿ“ Captured History (Premium):
- Premium users can view previously captured text alongside images.
- Each user's data is stored privately using Firebase.

### ๐Ÿ’ณ Stripe Integration:
- Monthly recurring subscriptions using the **Stripe API**.
- Users can upgrade to premium and unlock additional features.

### ๐Ÿ‘ค Anonymous Authentication:
- Firebase Auth is used to generate a unique anonymous user ID.
- User data (including captures) are stored per user in Firestore.

### ๐Ÿ” Secure Storage:
- Images stored in **Firebase Storage**.
- Captured text stored in **Cloud Firestore** linked to user IDs.

### ๐ŸŽจ UI Enhancements:
- Splash screen animation using **Lottie**.
- Clean UI design with **Google Fonts** and **SVG assets**.

### ๐Ÿ“ก Stripe API Endpoints Used:

The following [Stripe API](https://docs.stripe.com/api) endpoints were used to implement subscription-based payments:

| Purpose | Endpoint |
|----------------------------------------------------|---------------------------------------------------------------------|
| โœ… Create a new customer on Stripe | `https://api.stripe.com/v1/customers` |
| โœ… Prepare to collect payment details | `https://api.stripe.com/v1/setup_intents` |
| โœ… Attach a payment method to a specific customer | `https://api.stripe.com/v1/customers/[customerId]/payment_methods` |
| โœ… Create a subscription for a customer | `https://api.stripe.com/v1/subscriptions` |

---

## ๐Ÿ› ๏ธ Technologies Used:
The following core technologies are used in this project:

- **Flutter** : UI toolkit for building natively compiled applications for mobile.
- **Dart** : Programming language used with Flutter.
- **Firebase ML Kit** : For on-device text recognition (Optical Character Recognition (OCR)).
- **Firebase Authentication** : Anonymous authentication to track user data securely.
- **Cloud Firestore** : NoSQL cloud database to store captured text and metadata.
- **Firebase Storage** : To store captured images securely.
- **Stripe API** : Handles payment processing and subscriptions.

---

## ๐Ÿ›  Dependencies:
The following technologies are used in this project:

| Package | Description |
|--------------------------------|--------------------------------------------------|
| firebase_core | Firebase core initialization |
| firebase_auth | Anonymous authentication |
| firebase_storage | Store captured images |
| cloud_firestore | Store captured text and metadata |
| image_picker | Pick images from gallery or camera |
| google_mlkit_text_recognition | ML text recognition from images |
| google_fonts | Custom fonts integration |
| flutter_stripe | Stripe API integration for subscription handling |
| flutter_dotenv | Load environment variables (e.g., API keys) |
| http | HTTP client for Stripe API requests |
| provider | State management (e.g., premium status) |
| flutter_svg | SVG image rendering |
| lottie | Splash screen animation |

---

## ๐Ÿš€ How to Run the Project:
1. Clone the repository:

```sh
https://github.com/PAIshanMadusha/firebase-ml-text-recognition-app.git
```
2. Navigate to the project directory:

```sh
cd firebase-ml-text-recognition-app
```
3. Install dependencies:

```sh
flutter pub get
```
## ๐Ÿ“ฅ Set up Firebase:

### ๐Ÿ“ To use Firebase services in this project, follow these steps:

- Create a Firebase project at [Firebase Console](https://console.firebase.google.com/).
- After creating your Firebase project, you need to configure the following services, Go to the **Build** section in Firebase and:
- Enable [**Authentication**](https://github.com/PAIshanMadusha/basic-firebase-authentication.git) โ†’ **Sign-in method** โ†’ **Anonymous**.
- Enable **Cloud Firestore** (start in **test mode** for development).
- Enable **Firebase Storage** (also start in **test mode**).
- Enable **Machine Learning** โ†’ **Text Recognition**.
- Then, connect your Flutter project to Firebase.
- For this project, I used the FlutterFire CLI to do that. You should follow the same process to avoid errors.

### โš ๏ธ Not familiar with the FlutterFire CLI?

- Iโ€™ve written a detailed [Medium](https://medium.com/@ishanmadusha) article explaining the step-by-step process to connect Firebase to Flutter using the CLI with screenshots to guide
you through it. **๐Ÿ“– Read my article on Medium here:** [Link](https://medium.com/@ishanmadusha/using-firebase-cli-to-easily-connect-firebase-with-your-flutter-app-927e0021bc44)
- So, follow the above steps and add Firebase to your Flutter project using the FlutterFire CLI.

## ๐Ÿ’ณ Configure Stripe:

To enable premium features in the app, Stripe is used to handle subscription payments. Follow these steps to configure Stripe:

### ๐Ÿ”ง Create a Stripe Account:
- Go to [Stripe](https://stripe.com/) and create an account if you don't have one, and select test mode.

### ๐Ÿ” Get Your Stripe API Keys:
- Navigate to your Stripe Dashboard โ†’ **Developers โ†’ API Keys**
- Copy your **Publishable key** and **Secret key**

### โš™๏ธ Set Up Environment Variables:
- Create a `.env` file in the root directory of your Flutter project.
- Add your Stripe keys:
```env
SECRET_KEY = "[Your-Secret-Key]"
PUBLISHABLE_KEY ="[Your-Publishable-Key]"
```
- Replace `[Your-...-Keys]` with your actual API keys from Stripe.

### โš ๏ธ Important:

- The `priceId` used in this project (`price_1REmVySHefmHhg9lhKnukC5O`) is specific to the original developerโ€™s Stripe account.
- It appears in the following file and lines:
- `\lib\services\stripe\stripe_service.dart` โ†’ **Line 58** and **Line 136**
- If you're cloning or reusing this project, **you must create your own Stripe product and price**, and **replace this ID** with your own.

### ๐Ÿ› ๏ธ How to Create Your Own Stripe Price ID:

- Go to your Stripe Dashboard.
- On the left sidebar, click **Product Catalog**.
- Click **+ Add product**.
- Fill in the **required product details** (name, description, etc.).
- Under **Pricing**, choose **Recurring** and set your amount and interval (e.g., monthly).
- Click **Add product** to save.
- After the product is created, click on it to view the **Price ID**.
- Copy the Price ID and replace the hardcoded one at **Line 58** and **Line 136** in `stripe_service.dart`.

### โœ… Now you can run the app. Make sure there are no errors:
```bash
flutter run
```

## ๐Ÿ“ธ System Screenshots:

---


Screenshot 1ย ย ย ย ย ย 
Screenshot 2ย ย ย ย ย ย 
Screenshot 3ย ย ย ย ย ย 





Screenshot 1ย ย ย 
Screenshot 2ย ย ย 
Screenshot 3ย ย ย 
Screenshot 4ย ย ย 

---

## ๐Ÿ‘ค About This Project:

A Flutter app that uses Firebase ML Kit to extract text from images, with a premium feature (via Stripe subscription) to view captured history, built to enhance my Flutter and Firebase skills.

### ๐Ÿ‘จโ€๐Ÿ’ป Created by:
**Ishan Madhusha**
GitHub: [PAIshanMadusha](https://github.com/PAIshanMadusha)

Feel free to explore my work and get in touch if you'd like to collaborate! ๐Ÿš€

---

## ๐Ÿ“ License:
This project is open-source and available under the MIT License.