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

https://github.com/hamidhosen42/buynjoy


https://github.com/hamidhosen42/buynjoy

cloude dart firbase firebase-auth flutter payment-gateway

Last synced: about 1 month ago
JSON representation

Awesome Lists containing this project

README

          

Here is a Flutter MVC folder structure for an e-commerce app using GetX, Firebase, push notifications, Google Maps, dark and light theme, Google Ads, animations, and a payment method with order by product functionality, along with example code for each major component:

```
lib/
├── controllers/
│ ├── auth_controller.dart // Handles authentication (Firebase Auth)
│ ├── cart_controller.dart // Manages shopping cart
│ ├── product_controller.dart // Handles product logic and ordering
│ ├── order_controller.dart // Manages orders, tracking, payments
│ ├── user_controller.dart // Handles user profile, address data
│ ├── map_controller.dart // Google Maps for user location and delivery
│ ├── notification_controller.dart // Firebase push notifications
│ ├── theme_controller.dart // Light/Dark theme management
│ ├── payment_controller.dart // Manages payment methods (e.g., Stripe)
│ └── ad_controller.dart // Google Ads integration
├── models/
│ ├── user_model.dart // User data model
│ ├── product_model.dart // Product data model
│ ├── cart_model.dart // Cart data model
│ ├── order_model.dart // Order data model
│ ├── address_model.dart // Address model for Google Maps
│ └── notification_model.dart // Push notification model
├── views/
│ ├── auth/
│ │ ├── login_view.dart // Login page UI
│ │ └── signup_view.dart // Signup page UI
│ ├── home/
│ │ ├── home_view.dart // Home page for product listings
│ │ └── product_detail_view.dart // Product details and purchase
│ ├── cart/
│ │ ├── cart_view.dart // Shopping cart view
│ │ └── checkout_view.dart // Checkout and payment
│ ├── orders/
│ │ ├── order_list_view.dart // View for user's orders
│ │ └── order_detail_view.dart // Detailed order tracking
│ ├── user/
│ │ ├── profile_view.dart // User profile page
│ │ └── address_view.dart // Address management with Google Maps
│ ├── ads/
│ │ └── google_ads_view.dart // Google Ads banner and interstitials
│ ├── notifications/
│ │ └── notifications_view.dart // Notification center
│ └── theme/
│ └── theme_toggle_view.dart // Toggle between dark and light themes
├── bindings/
│ ├── initial_bindings.dart // Initial bindings (e.g., AuthController)
│ ├── home_bindings.dart // Bindings for home, cart, product pages
│ ├── order_bindings.dart // Bindings for order pages
│ └── map_bindings.dart // Google Maps-related bindings
├── services/
│ ├── firebase_service.dart // Firebase integration (Auth, Firestore, etc.)
│ ├── push_notification_service.dart // Firebase Cloud Messaging for push notifications
│ ├── map_service.dart // Google Maps API integration
│ ├── payment_service.dart // Stripe or other payment provider integration
│ └── ad_service.dart // Google Ads service
├── utils/
│ ├── constants.dart // Constant values, API keys, endpoints, etc.
│ ├── routes.dart // Route management for the app
│ ├── theme.dart // Dark and light theme definitions
│ └── animations.dart // Animation helpers and presets
├── widgets/
│ ├── custom_button.dart // Reusable button widget
│ ├── product_card.dart // Product card widget for list views
│ ├── order_card.dart // Order summary card
│ ├── theme_toggle.dart // Widget to toggle dark/light theme
│ └── google_ad_widget.dart // Google Ad widget
├── main.dart // App entry point
└── app_pages.dart // App routes and page bindings
```

auth_controller.dart

```
import 'package:get/get.dart';
import 'package:firebase_auth/firebase_auth.dart';

class AuthController extends GetxController {
FirebaseAuth _auth = FirebaseAuth.instance;
Rx firebaseUser = Rx(null);

@override
void onReady() {
firebaseUser.bindStream(_auth.authStateChanges());
super.onReady();
}

void signIn(String email, String password) async {
try {
await _auth.signInWithEmailAndPassword(email: email, password: password);
} catch (e) {
Get.snackbar("Error", e.toString());
}
}

void signOut() async {
await _auth.signOut();
}
}
```

product_controller.dart

```
import 'package:get/get.dart';
import '../models/product_model.dart';

class ProductController extends GetxController {
var products = List.empty().obs;
var isLoading = true.obs;

@override
void onInit() {
fetchProducts();
super.onInit();
}

void fetchProducts() async {
// Fetch products from Firebase Firestore or API
try {
isLoading(true);
var productResult = await FirebaseService().getProducts();
products.value = productResult;
} finally {
isLoading(false);
}
}

void orderByPriceAsc() {
products.sort((a, b) => a.price.compareTo(b.price));
}
}
```

theme_controller.dart

```
import 'package:get/get.dart';
import 'package:flutter/material.dart';
import '../utils/theme.dart';

class ThemeController extends GetxController {
var isDarkMode = false.obs;

ThemeData get theme => isDarkMode.value ? darkTheme : lightTheme;

void toggleTheme() {
isDarkMode.value = !isDarkMode.value;
Get.changeTheme(theme);
}
}

```

push_notification_service.dart

```
import 'package:firebase_messaging/firebase_messaging.dart';

class PushNotificationService {
final FirebaseMessaging _fcm = FirebaseMessaging.instance;

Future init() async {
_fcm.requestPermission();
String? token = await _fcm.getToken();
print("FCM Token: $token");

FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print("Message received: ${message.notification!.title}");
});
}
}
```

map_controller.dart

```
import 'package:get/get.dart';
import 'package:google_maps_flutter/google_maps_flutter.dart';

class MapController extends GetxController {
GoogleMapController? mapController;
Rx currentLocation = LatLng(0, 0).obs;

void setMapController(GoogleMapController controller) {
mapController = controller;
}

void updateLocation(LatLng newLocation) {
currentLocation.value = newLocation;
mapController?.moveCamera(CameraUpdate.newLatLng(newLocation));
}
}

```

ad_controller.dart

```
import 'package:get/get.dart';
import 'package:google_mobile_ads/google_mobile_ads.dart';

class AdController extends GetxController {
BannerAd? bannerAd;

@override
void onInit() {
bannerAd = BannerAd(
size: AdSize.banner,
adUnitId: '',
listener: BannerAdListener(),
request: AdRequest(),
)..load();
super.onInit();
}
}
```

payment_controller.dart

```
import 'package:get/get.dart';
import '../services/payment_service.dart';

class PaymentController extends GetxController {
var isPaymentSuccessful = false.obs;

void makePayment(double amount) async {
try {
isPaymentSuccessful.value = await PaymentService().processPayment(amount);
} catch (e) {
Get.snackbar("Payment Error", e.toString());
}
}
}

```

animations.dart

```
import 'package:flutter/material.dart';

class Animations {
static SlideTransition slideFromLeft(Animation animation, Widget child) {
return SlideTransition(
position: Tween(begin: const Offset(-1, 0), end: Offset.zero).animate(animation),
child: child,
);
}

static FadeTransition fadeIn(Animation animation, Widget child) {
return FadeTransition(
opacity: Tween(begin: 0, end: 1).animate(animation),
child: child,
);
}
}

```

theme.dart

```
import 'package:flutter/material.dart';

final ThemeData darkTheme = ThemeData(
brightness: Brightness.dark,
primaryColor: Colors.black,
accentColor: Colors.blueAccent,
);

final ThemeData lightTheme = ThemeData(
brightness: Brightness.light,
primaryColor: Colors.white,
accentColor: Colors.blueAccent,
);

```

main.dart

```
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'controllers/theme_controller.dart';
import 'utils/routes.dart';
import 'app_pages.dart';

void main() {
runApp(MyApp());
}

class MyApp extends StatelessWidget {
final ThemeController themeController = Get.put(ThemeController());

@override
Widget build(BuildContext context) {
return Obx(() => GetMaterialApp(
debugShowCheckedModeBanner: false,
theme: themeController.theme,
initialRoute: Routes.HOME,
getPages: AppPages.pages,
));
}
}
```

Conclusion:
This folder structure and code provides a clean and modular architecture for a Flutter e-commerce app with all the requested features. The use of GetX for state management, Firebase for backend services, push notifications, Google Maps, Google Ads, dark/light theme, animations, and payment integration is demonstrated in this structure.

[//]: # (--------------------------------------------------------------------------)





ShopSavvy


## Development Setup
Clone the repository and run the following commands:
```
git clone https://github.com/hamidhosen42/Flutter-ShopSavvy-App.git
flutter pub get
flutter run
```
### [Firebase](https://console.firebase.google.com/u/5/project/shopsavvy-fb9e3/firestore/data/~2Fbanners~2FP9MUfp45wj6wTTmkXruZ)
### [APK](https://github.com/hamidhosen42/Flutter-ShopSavvy-App/blob/main/ShopSavvy.apk)

### flutter packages:
```
- cupertino_icons: ^1.0.2
- carousel_slider: ^4.2.1
- firebase_core: ^2.20.0
- firebase_auth: ^4.12.0
- cloud_firestore: ^4.12.1
- cached_network_image: ^3.3.0
- top_snackbar_flutter: ^3.1.0
- flutter_screenutil: ^5.9.0
- lottie: ^2.7.0
- dropdown_button2: ^2.3.9
- velocity_x: ^4.1.1
- flutter_stripe: any
- http: any
- flutter_bkash:
- flutter_paystack:
- image_picker: ^1.0.4
- firebase_storage: ^11.4.1
- toggle_switch: ^2.1.0
```

### The main features of our app are:
```
- Login: Allows existing users to access their accounts by providing valid credentials.
- Register: Enables new users to create an account to utilize the app's features.
- Product catalog browsing - Users can browse and search for products by category, view product details, reviews, add items to cart.
- Cart and checkout - Users can add/remove products and quantities to cart, apply promo codes during checkout and make payments.
- User account management - Users can register, login to their account, view order history, manage profile, addresses etc.
- Order tracking - Users can track the status of their orders from account section.
- Category management - Admins can add, edit, delete product categories.
- Product management - Admins can add, modify and manage catalog products.
- Order management - Admins can view and manage orders placed by users.
- Admin dashboard - Provides insights like sales reports, revenue metrics, user activity to admins.
- Payments - Likely integrates payment gateways like Stripe for accepting online payments.
- Search/filter - Users can search for products and filter by price, ratings, etc.
- Deals/coupons - Special discounted deals and coupon codes for users.
- Upload Packages (Admin review): Allows authorized personnel (like travel agencies) to upload new packages, which can be reviewed and approved by the app's admin.
- Logout: Ensures users can securely exit their accounts.
- Internet Checker: Monitors and notifies users of their internet connection status.
- Support: Provides assistance and solutions for any technical issues or queries users may encounter.
- Privacy: Outlines the app's data collection, storage, and usage policies to ensure users' personal information is protected.
- FAQ: Offers answers to frequently asked questions about the app and its features.
- Edit Profile Information: Allows users to update and modify their personal account details.
```

### App UI :
![image](https://github.com/hamidhosen42/Flutter-ShopSavvy-App/blob/main/assets/images/img.png)