Farm Mate is a Flutter-based mobile app designed to connect farmers with businesses, enabling them to sell crops directly to buyers. Below is a breakdown of the various components and features used in the app:
Flutter is the primary framework used for building the app. It provides a fast and efficient way to develop natively compiled applications for mobile, web, and desktop from a single codebase.
- Why Flutter?
Flutter allows for cross-platform development, enabling the app to run on both Android and iOS with a single codebase.
Firebase is used for backend services in Farm Mate. It provides real-time databases, authentication, cloud storage, and other services that make it easier to develop the app.
- firebase_core: Initializes Firebase for use within the app.
- firebase_auth: Handles user authentication, allowing users (farmers and businesses) to sign up, log in, and manage accounts securely.
- cloud_firestore: Used for real-time cloud data storage, enabling farmers and buyers to interact with data that updates in real-time.
The app leverages location-based features to connect farmers and businesses based on proximity.
- geolocator: Used to get the current location of the device. This is essential for showing farmers' locations to businesses and vice versa.
- geocoding: Converts geographic coordinates (latitude, longitude) into human-readable addresses. This helps in displaying location information.
Farm Mate integrates real-time weather updates to help farmers check the weather conditions for their area.
- weather_animation: This package fetches weather data and provides animated weather effects, such as sunny or rainy weather. The animations enhance the user experience by visually representing the weather conditions, such as displaying clouds for sunny weather or rain animations for rainy weather.
The Farmer Dashboard provides farmers with a comprehensive interface to manage their crops. Farmers can:
- Add crops: Input information about their crops, including the type, quantity, and price.
- View crop availability: See their crops listed in a view that businesses can browse.
- Manage listings: Update or delete their crop listings as needed.
The Buyer Dashboard is designed for businesses (buyers) to browse available crops. Buyers can:
- View available crops: Browse a list of crops from different farmers.
- Make purchases: Contact the farmer or place orders for crops.
The app uses Firebase Authentication to securely manage user logins. Both farmers and businesses can:
- Create an account: Sign up using email and password.
- Login: Log in with their credentials to access their respective dashboards.
- Logout: Sign out from the app to protect their account.
The app uses the Geolocator and Geocoding packages to provide:
- Location-based services: Farmers can provide their location for business buyers to view, making it easier to connect based on geographical proximity.
- Location tracking: The app tracks user locations to show relevant crop listings nearby.
- Weather Animations: The app integrates weather updates with the weather_animation package. Users can see weather information and forecasts, which is helpful for farmers to know about conditions that might affect their crops.
- Backend: Firebase is used for user authentication, real-time data storage, and retrieval of crop listings. It also handles storing and managing user data for both farmers and businesses.
- Frontend: The app is built using Flutter, which provides a responsive and visually appealing interface that runs seamlessly on both iOS and Android devices.
- Real-Time Updates: Crop data is synchronized in real time across all devices using Firebase Firestore. Any updates made by farmers are immediately reflected in the buyerβs dashboard.
Ensure you have the following installed:
- Flutter (Version 3.5.4 or higher)
- Dart SDK
- Android Studio or Visual Studio Code
- Xcode (for iOS development on macOS)
- Git
- Firebase Account
git clone https://github.com/yourusername/farmmate.git
cd farmmateflutter pub get- Sign up for an API key at OpenWeatherMap.
- Navigate to
lib/ApiKey.dartand replace the placeholder:
const String apiKey = 'YOUR_API_KEY_HERE';The Farm Mate app uses Firebase for:
- User Authentication
- Firestore Database
- Go to the Firebase Console.
- Navigate to the Authentication tab.
- Enable Email/Password Authentication.
dependencies:
firebase_auth: ^3.3.4import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(MyApp());
}Future<User?> signUp(String email, String password) async {
try {
UserCredential userCredential = await FirebaseAuth.instance
.createUserWithEmailAndPassword(email: email, password: password);
return userCredential.user;
} catch (e) {
print("Error: $e");
return null;
}
}Future<User?> signIn(String email, String password) async {
try {
UserCredential userCredential = await FirebaseAuth.instance
.signInWithEmailAndPassword(email: email, password: password);
return userCredential.user;
} catch (e) {
print("Error: $e");
return null;
}
}- Go to Firestore Database in Firebase Console.
- Create collections:
farmers,buyers,crops.
dependencies:
cloud_firestore: ^3.1.5FirebaseFirestore firestore = FirebaseFirestore.instance;
Future<void> addUserData(String userId, String collection, Map<String, dynamic> data) async {
try {
await firestore.collection(collection).doc(userId).set(data);
} catch (e) {
print("Error: $e");
}
}Future<void> addCropData(String cropId, Map<String, dynamic> cropData) async {
try {
await firestore.collection('crops').doc(cropId).set(cropData);
} catch (e) {
print("Error: $e");
}
}Future<QuerySnapshot> getCrops() async {
return await firestore.collection('crops').get();
}- Fork the repository.
- Create a new branch (
git checkout -b feature-branch). - Commit your changes (
git commit -m 'Add new feature'). - Push to the branch (
git push origin feature-branch). - Open a pull request.
This project is licensed under the MIT License.
For queries or collaborations, contact amoghreddykb1@gmail.com.