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.
- Host: GitHub
- URL: https://github.com/paishanmadusha/firebase-ml-text-recognition-app
- Owner: PAIshanMadusha
- License: mit
- Created: 2025-04-11T15:53:20.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-04-20T09:32:26.000Z (about 1 year ago)
- Last Synced: 2025-04-24T01:18:12.401Z (about 1 year ago)
- Topics: anonymous, dart, firebase, firebase-storage, firestore, flutter, flutter-dotenv, http, image-picker, machine-learning, payment-gateway, premium, provider, stripe, stripe-api, stripe-payments
- Language: Dart
- Homepage:
- Size: 329 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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:
---
ย ย ย ย ย ย
ย ย ย ย ย ย
ย ย ย ย ย ย
ย ย ย
ย ย ย
ย ย ย
ย ย ย
---
## ๐ค 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.