├── flutter
├── ios
│ ├── Flutter
│ │ ├── Debug.xcconfig
│ │ ├── Release.xcconfig
│ │ └── AppFrameworkInfo.plist
│ ├── Runner
│ │ ├── Runner-Bridging-Header.h
│ │ ├── Assets.xcassets
│ │ │ ├── LaunchImage.imageset
│ │ │ │ ├── LaunchImage.png
│ │ │ │ ├── LaunchImage@2x.png
│ │ │ │ ├── LaunchImage@3x.png
│ │ │ │ ├── README.md
│ │ │ │ └── Contents.json
│ │ │ └── AppIcon.appiconset
│ │ │ │ ├── Icon-App-20x20@1x.png
│ │ │ │ ├── Icon-App-20x20@2x.png
│ │ │ │ ├── Icon-App-20x20@3x.png
│ │ │ │ ├── Icon-App-29x29@1x.png
│ │ │ │ ├── Icon-App-29x29@2x.png
│ │ │ │ ├── Icon-App-29x29@3x.png
│ │ │ │ ├── Icon-App-40x40@1x.png
│ │ │ │ ├── Icon-App-40x40@2x.png
│ │ │ │ ├── Icon-App-40x40@3x.png
│ │ │ │ ├── Icon-App-60x60@2x.png
│ │ │ │ ├── Icon-App-60x60@3x.png
│ │ │ │ ├── Icon-App-76x76@1x.png
│ │ │ │ ├── Icon-App-76x76@2x.png
│ │ │ │ ├── Icon-App-1024x1024@1x.png
│ │ │ │ ├── Icon-App-83.5x83.5@2x.png
│ │ │ │ └── Contents.json
│ │ ├── AppDelegate.swift
│ │ ├── Base.lproj
│ │ │ ├── Main.storyboard
│ │ │ └── LaunchScreen.storyboard
│ │ └── Info.plist
│ ├── Runner.xcodeproj
│ │ ├── project.xcworkspace
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata
│ │ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ ├── xcshareddata
│ │ │ └── xcschemes
│ │ │ │ └── Runner.xcscheme
│ │ └── project.pbxproj
│ ├── Runner.xcworkspace
│ │ ├── contents.xcworkspacedata
│ │ └── xcshareddata
│ │ │ ├── WorkspaceSettings.xcsettings
│ │ │ └── IDEWorkspaceChecks.plist
│ └── .gitignore
├── web
│ ├── favicon.png
│ ├── icons
│ │ ├── Icon-192.png
│ │ ├── Icon-512.png
│ │ ├── Icon-maskable-192.png
│ │ └── Icon-maskable-512.png
│ ├── manifest.json
│ └── index.html
├── android
│ ├── gradle.properties
│ ├── app
│ │ ├── src
│ │ │ ├── main
│ │ │ │ ├── res
│ │ │ │ │ ├── mipmap-hdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-mdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── mipmap-xxxhdpi
│ │ │ │ │ │ └── ic_launcher.png
│ │ │ │ │ ├── drawable
│ │ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── drawable-v21
│ │ │ │ │ │ └── launch_background.xml
│ │ │ │ │ ├── values
│ │ │ │ │ │ └── styles.xml
│ │ │ │ │ └── values-night
│ │ │ │ │ │ └── styles.xml
│ │ │ │ ├── kotlin
│ │ │ │ │ └── com
│ │ │ │ │ │ └── example
│ │ │ │ │ │ └── flutter_nodejs_crud_app
│ │ │ │ │ │ └── MainActivity.kt
│ │ │ │ └── AndroidManifest.xml
│ │ │ ├── debug
│ │ │ │ └── AndroidManifest.xml
│ │ │ └── profile
│ │ │ │ └── AndroidManifest.xml
│ │ └── build.gradle
│ ├── gradle
│ │ └── wrapper
│ │ │ └── gradle-wrapper.properties
│ ├── .gitignore
│ ├── settings.gradle
│ └── build.gradle
├── lib
│ ├── config.dart
│ ├── main.dart
│ ├── model
│ │ └── product_model.dart
│ ├── services
│ │ └── api_service.dart
│ └── pages
│ │ ├── product_item.dart
│ │ ├── product_list.dart
│ │ └── product_add_edit.dart
├── .metadata
├── README.md
├── .gitignore
├── test
│ └── widget_test.dart
├── analysis_options.yaml
├── pubspec.yaml
└── pubspec.lock
├── api
├── .gitignore
├── config
│ └── app.config.js
├── models
│ └── products.model.js
├── package.json
├── middleware
│ ├── errors.js
│ └── upload.js
├── routes
│ └── app.routes.js
├── index.js
├── services
│ └── products.services.js
├── controllers
│ └── products.controller.js
└── swagger.json
└── README.md
/flutter/ios/Flutter/Debug.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/flutter/ios/Flutter/Release.xcconfig:
--------------------------------------------------------------------------------
1 | #include "Generated.xcconfig"
2 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Runner-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | #import "GeneratedPluginRegistrant.h"
2 |
--------------------------------------------------------------------------------
/flutter/web/favicon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/web/favicon.png
--------------------------------------------------------------------------------
/flutter/android/gradle.properties:
--------------------------------------------------------------------------------
1 | org.gradle.jvmargs=-Xmx1536M
2 | android.useAndroidX=true
3 | android.enableJetifier=true
4 |
--------------------------------------------------------------------------------
/api/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 |
3 | # compiled output
4 | /node_modules
--------------------------------------------------------------------------------
/flutter/web/icons/Icon-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/web/icons/Icon-192.png
--------------------------------------------------------------------------------
/flutter/web/icons/Icon-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/web/icons/Icon-512.png
--------------------------------------------------------------------------------
/flutter/web/icons/Icon-maskable-192.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/web/icons/Icon-maskable-192.png
--------------------------------------------------------------------------------
/flutter/web/icons/Icon-maskable-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/web/icons/Icon-maskable-512.png
--------------------------------------------------------------------------------
/api/config/app.config.js:
--------------------------------------------------------------------------------
1 | const MONGO_DB_CONFIG = {
2 | DB: "mongodb://localhost/ecommerce-app"
3 | };
4 |
5 | module.exports = {
6 | MONGO_DB_CONFIG,
7 | };
8 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/android/app/src/main/res/mipmap-hdpi/ic_launcher.png
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/android/app/src/main/res/mipmap-mdpi/ic_launcher.png
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png
--------------------------------------------------------------------------------
/flutter/lib/config.dart:
--------------------------------------------------------------------------------
1 | class Config {
2 | static const String appName = "Shopping App";
3 | static const String apiURL = '10.0.0.3:5000'; //PROD_URL
4 | static const productsAPI = "api/products";
5 | }
6 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SnippetCoders/flutter_nodejs_crud/HEAD/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/kotlin/com/example/flutter_nodejs_crud_app/MainActivity.kt:
--------------------------------------------------------------------------------
1 | package com.example.flutter_nodejs_crud_app
2 |
3 | import io.flutter.embedding.android.FlutterActivity
4 |
5 | class MainActivity: FlutterActivity() {
6 | }
7 |
--------------------------------------------------------------------------------
/flutter/android/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | #Fri Jun 23 08:50:38 CEST 2017
2 | distributionBase=GRADLE_USER_HOME
3 | distributionPath=wrapper/dists
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 | distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
7 |
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | PreviewsEnabled
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | IDEDidComputeMac32BitWarning
6 |
7 |
8 |
9 |
--------------------------------------------------------------------------------
/flutter/.metadata:
--------------------------------------------------------------------------------
1 | # This file tracks properties of this Flutter project.
2 | # Used by Flutter tool to assess capabilities and perform upgrades etc.
3 | #
4 | # This file should be version controlled and should not be manually edited.
5 |
6 | version:
7 | revision: 18116933e77adc82f80866c928266a5b4f1ed645
8 | channel: stable
9 |
10 | project_type: app
11 |
--------------------------------------------------------------------------------
/flutter/android/.gitignore:
--------------------------------------------------------------------------------
1 | gradle-wrapper.jar
2 | /.gradle
3 | /captures/
4 | /gradlew
5 | /gradlew.bat
6 | /local.properties
7 | GeneratedPluginRegistrant.java
8 |
9 | # Remember to never publicly share your keystore.
10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app
11 | key.properties
12 | **/*.keystore
13 | **/*.jks
14 |
--------------------------------------------------------------------------------
/api/models/products.model.js:
--------------------------------------------------------------------------------
1 | const mongoose = require("mongoose");
2 |
3 | const product = mongoose.model(
4 | "products",
5 | mongoose.Schema(
6 | {
7 | productName: String,
8 | productDescription: String,
9 | productPrice: Number,
10 | productImage: String
11 | },
12 | { timestamps: true }
13 | )
14 | );
15 |
16 | module.exports = {
17 | product,
18 | };
19 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/README.md:
--------------------------------------------------------------------------------
1 | # Launch Screen Assets
2 |
3 | You can customize the launch screen with your own desired assets by replacing the image files in this directory.
4 |
5 | You can also do it by opening your Flutter project's Xcode project with `open ios/Runner.xcworkspace`, selecting `Runner/Assets.xcassets` in the Project Navigator and dropping in the desired images.
--------------------------------------------------------------------------------
/flutter/android/app/src/debug/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/flutter/android/app/src/profile/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/api/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nodejs_push_notification_api",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "index.js",
6 | "scripts": {
7 | "test": "echo \"Error: no test specified\" && exit 1"
8 | },
9 | "author": "",
10 | "license": "ISC",
11 | "dependencies": {
12 | "express": "^4.17.1",
13 | "mongoose": "^6.1.1",
14 | "multer": "^1.4.4",
15 | "nodemon": "^2.0.15",
16 | "swagger-ui-express": "^4.3.0"
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 | import Flutter
3 |
4 | @UIApplicationMain
5 | @objc class AppDelegate: FlutterAppDelegate {
6 | override func application(
7 | _ application: UIApplication,
8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
9 | ) -> Bool {
10 | GeneratedPluginRegistrant.register(with: self)
11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions)
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/flutter/android/settings.gradle:
--------------------------------------------------------------------------------
1 | include ':app'
2 |
3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties")
4 | def properties = new Properties()
5 |
6 | assert localPropertiesFile.exists()
7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) }
8 |
9 | def flutterSdkPath = properties.getProperty("flutter.sdk")
10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties"
11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle"
12 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/drawable/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/drawable-v21/launch_background.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
12 |
13 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "LaunchImage.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "filename" : "LaunchImage@2x.png",
11 | "scale" : "2x"
12 | },
13 | {
14 | "idiom" : "universal",
15 | "filename" : "LaunchImage@3x.png",
16 | "scale" : "3x"
17 | }
18 | ],
19 | "info" : {
20 | "version" : 1,
21 | "author" : "xcode"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/flutter/README.md:
--------------------------------------------------------------------------------
1 | # flutter_nodejs_crud_app
2 |
3 | A new Flutter project.
4 |
5 | ## Getting Started
6 |
7 | This project is a starting point for a Flutter application.
8 |
9 | A few resources to get you started if this is your first Flutter project:
10 |
11 | - [Lab: Write your first Flutter app](https://flutter.dev/docs/get-started/codelab)
12 | - [Cookbook: Useful Flutter samples](https://flutter.dev/docs/cookbook)
13 |
14 | For help getting started with Flutter, view our
15 | [online documentation](https://flutter.dev/docs), which offers tutorials,
16 | samples, guidance on mobile development, and a full API reference.
17 |
--------------------------------------------------------------------------------
/api/middleware/errors.js:
--------------------------------------------------------------------------------
1 | function errorHandler(err, req, res, next) {
2 | if (typeof err === "string") {
3 | // custom application error
4 | return res.status(400).json({ message: err });
5 | }
6 |
7 | if (err.name === "ValidationError") {
8 | // mongoose validation error
9 | return res.status(400).json({ message: err.message });
10 | }
11 |
12 | if (err.name === "UnauthorizedError") {
13 | // jwt authentication error
14 | return res.status(401).json({ message: "Token not valid" });
15 | }
16 |
17 | return res.status(500).json({ message: err.message });
18 | }
19 |
20 | module.exports = {
21 | errorHandler,
22 | };
23 |
--------------------------------------------------------------------------------
/api/routes/app.routes.js:
--------------------------------------------------------------------------------
1 | const productsController = require("../controllers/products.controller");
2 | const express = require("express");
3 | const router = express.Router();
4 |
5 | // Create a new Product
6 | router.post("/products", productsController.create);
7 |
8 | // Retrieve all Products
9 | router.get("/products", productsController.findAll);
10 |
11 | // Retrieve a single Product with id
12 | router.get("/products/:id", productsController.findOne);
13 |
14 | // Update a Product with id
15 | router.put("/products/:id", productsController.update);
16 |
17 | // // Delete a Product with id
18 | router.delete("/products/:id", productsController.delete);
19 |
20 | module.exports = router;
21 |
--------------------------------------------------------------------------------
/flutter/android/build.gradle:
--------------------------------------------------------------------------------
1 | buildscript {
2 | ext.kotlin_version = '1.3.50'
3 | repositories {
4 | google()
5 | mavenCentral()
6 | }
7 |
8 | dependencies {
9 | classpath 'com.android.tools.build:gradle:4.1.0'
10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
11 | }
12 | }
13 |
14 | allprojects {
15 | repositories {
16 | google()
17 | mavenCentral()
18 | }
19 | }
20 |
21 | rootProject.buildDir = '../build'
22 | subprojects {
23 | project.buildDir = "${rootProject.buildDir}/${project.name}"
24 | project.evaluationDependsOn(':app')
25 | }
26 |
27 | task clean(type: Delete) {
28 | delete rootProject.buildDir
29 | }
30 |
--------------------------------------------------------------------------------
/flutter/ios/.gitignore:
--------------------------------------------------------------------------------
1 | **/dgph
2 | *.mode1v3
3 | *.mode2v3
4 | *.moved-aside
5 | *.pbxuser
6 | *.perspectivev3
7 | **/*sync/
8 | .sconsign.dblite
9 | .tags*
10 | **/.vagrant/
11 | **/DerivedData/
12 | Icon?
13 | **/Pods/
14 | **/.symlinks/
15 | profile
16 | xcuserdata
17 | **/.generated/
18 | Flutter/App.framework
19 | Flutter/Flutter.framework
20 | Flutter/Flutter.podspec
21 | Flutter/Generated.xcconfig
22 | Flutter/ephemeral/
23 | Flutter/app.flx
24 | Flutter/app.zip
25 | Flutter/flutter_assets/
26 | Flutter/flutter_export_environment.sh
27 | ServiceDefinitions.json
28 | Runner/GeneratedPluginRegistrant.*
29 |
30 | # Exceptions to above rules.
31 | !default.mode1v3
32 | !default.mode2v3
33 | !default.pbxuser
34 | !default.perspectivev3
35 |
--------------------------------------------------------------------------------
/flutter/lib/main.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_nodejs_crud_app/pages/product_add_edit.dart';
3 | import 'package:flutter_nodejs_crud_app/pages/product_list.dart';
4 |
5 | void main() {
6 | runApp(const MyApp());
7 | }
8 |
9 | class MyApp extends StatelessWidget {
10 | const MyApp({Key? key}) : super(key: key);
11 |
12 | @override
13 | Widget build(BuildContext context) {
14 | return MaterialApp(
15 | title: 'Flutter Demo',
16 | theme: ThemeData(
17 | primarySwatch: Colors.blue,
18 | ),
19 | routes: {
20 | '/': (context) => const ProductsList(),
21 | '/add-product': (context) => const ProductAddEdit(),
22 | '/edit-product': (context) => const ProductAddEdit(),
23 | },
24 | );
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/flutter/ios/Flutter/AppFrameworkInfo.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | App
9 | CFBundleIdentifier
10 | io.flutter.flutter.app
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | App
15 | CFBundlePackageType
16 | FMWK
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1.0
23 | MinimumOSVersion
24 | 9.0
25 |
26 |
27 |
--------------------------------------------------------------------------------
/flutter/.gitignore:
--------------------------------------------------------------------------------
1 | # Miscellaneous
2 | *.class
3 | *.log
4 | *.pyc
5 | *.swp
6 | .DS_Store
7 | .atom/
8 | .buildlog/
9 | .history
10 | .svn/
11 |
12 | # IntelliJ related
13 | *.iml
14 | *.ipr
15 | *.iws
16 | .idea/
17 |
18 | # The .vscode folder contains launch configuration and tasks you configure in
19 | # VS Code which you may wish to be included in version control, so this line
20 | # is commented out by default.
21 | #.vscode/
22 |
23 | # Flutter/Dart/Pub related
24 | **/doc/api/
25 | **/ios/Flutter/.last_build_id
26 | .dart_tool/
27 | .flutter-plugins
28 | .flutter-plugins-dependencies
29 | .packages
30 | .pub-cache/
31 | .pub/
32 | /build/
33 |
34 | # Web related
35 | lib/generated_plugin_registrant.dart
36 |
37 | # Symbolication related
38 | app.*.symbols
39 |
40 | # Obfuscation related
41 | app.*.map.json
42 |
43 | # Android Studio will place build artifacts here
44 | /android/app/debug
45 | /android/app/profile
46 | /android/app/release
47 |
--------------------------------------------------------------------------------
/api/middleware/upload.js:
--------------------------------------------------------------------------------
1 | const multer = require("multer");
2 | const Path = require('path');
3 |
4 | const storage = multer.diskStorage({
5 | destination: function (req, file, cb) {
6 | cb(null, "./uploads");
7 | },
8 | filename: function (req, file, cb) {
9 | cb(null, Date.now() + "--" + file.originalname);
10 | },
11 | });
12 |
13 | const fileFilter = (req, file, callback) => {
14 | const acceptableExtensions = [".png", ".jpg", ".mp4"];
15 | if (!acceptableExtensions.includes(Path.extname(file.originalname))) {
16 | return callback(new Error("Only .png, .jpg and .jpeg format allowed!"));
17 | }
18 |
19 | const fileSize = parseInt(req.headers["content-length"]);
20 | if (fileSize > 1048576) {
21 | return callback(new Error("File Size Big"));
22 | }
23 |
24 | callback(null, true);
25 | };
26 |
27 | let upload = multer({
28 | storage: storage,
29 | fileFilter: fileFilter,
30 | fileSize: 1048576, // 10 Mb
31 | });
32 |
33 | module.exports = upload.single("productImage");
34 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/values/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/res/values-night/styles.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
9 |
15 |
18 |
19 |
--------------------------------------------------------------------------------
/flutter/web/manifest.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "flutter_nodejs_crud_app",
3 | "short_name": "flutter_nodejs_crud_app",
4 | "start_url": ".",
5 | "display": "standalone",
6 | "background_color": "#0175C2",
7 | "theme_color": "#0175C2",
8 | "description": "A new Flutter project.",
9 | "orientation": "portrait-primary",
10 | "prefer_related_applications": false,
11 | "icons": [
12 | {
13 | "src": "icons/Icon-192.png",
14 | "sizes": "192x192",
15 | "type": "image/png"
16 | },
17 | {
18 | "src": "icons/Icon-512.png",
19 | "sizes": "512x512",
20 | "type": "image/png"
21 | },
22 | {
23 | "src": "icons/Icon-maskable-192.png",
24 | "sizes": "192x192",
25 | "type": "image/png",
26 | "purpose": "maskable"
27 | },
28 | {
29 | "src": "icons/Icon-maskable-512.png",
30 | "sizes": "512x512",
31 | "type": "image/png",
32 | "purpose": "maskable"
33 | }
34 | ]
35 | }
36 |
--------------------------------------------------------------------------------
/flutter/lib/model/product_model.dart:
--------------------------------------------------------------------------------
1 | List productsFromJson(dynamic str) =>
2 | List.from((str).map((x) => ProductModel.fromJson(x)));
3 |
4 | class ProductModel {
5 | late String? id;
6 | late String? productName;
7 | late String? productDescription;
8 | late int? productPrice;
9 | late String? productImage;
10 |
11 | ProductModel({
12 | this.id,
13 | this.productName,
14 | this.productDescription,
15 | this.productPrice,
16 | this.productImage,
17 | });
18 |
19 | ProductModel.fromJson(Map json) {
20 | id = json['_id'];
21 | productName = json['productName'];
22 | productDescription = json['productDescription'];
23 | productPrice = json['productPrice'];
24 | productImage = json['productImage'];
25 | }
26 |
27 | Map toJson() {
28 | final _data = {};
29 | _data['_id'] = id;
30 | _data['productName'] = productName;
31 | _data['productDescription'] = productDescription;
32 | _data['productPrice'] = productPrice;
33 | _data['productImage'] = productImage;
34 | return _data;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/flutter/test/widget_test.dart:
--------------------------------------------------------------------------------
1 | // This is a basic Flutter widget test.
2 | //
3 | // To perform an interaction with a widget in your test, use the WidgetTester
4 | // utility that Flutter provides. For example, you can send tap and scroll
5 | // gestures. You can also use WidgetTester to find child widgets in the widget
6 | // tree, read text, and verify that the values of widget properties are correct.
7 |
8 | import 'package:flutter/material.dart';
9 | import 'package:flutter_test/flutter_test.dart';
10 |
11 | import 'package:flutter_nodejs_crud_app/main.dart';
12 |
13 | void main() {
14 | testWidgets('Counter increments smoke test', (WidgetTester tester) async {
15 | // Build our app and trigger a frame.
16 | await tester.pumpWidget(const MyApp());
17 |
18 | // Verify that our counter starts at 0.
19 | expect(find.text('0'), findsOneWidget);
20 | expect(find.text('1'), findsNothing);
21 |
22 | // Tap the '+' icon and trigger a frame.
23 | await tester.tap(find.byIcon(Icons.add));
24 | await tester.pump();
25 |
26 | // Verify that our counter has incremented.
27 | expect(find.text('0'), findsNothing);
28 | expect(find.text('1'), findsOneWidget);
29 | });
30 | }
31 |
--------------------------------------------------------------------------------
/flutter/analysis_options.yaml:
--------------------------------------------------------------------------------
1 | # This file configures the analyzer, which statically analyzes Dart code to
2 | # check for errors, warnings, and lints.
3 | #
4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled
5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
6 | # invoked from the command line by running `flutter analyze`.
7 |
8 | # The following line activates a set of recommended lints for Flutter apps,
9 | # packages, and plugins designed to encourage good coding practices.
10 | include: package:flutter_lints/flutter.yaml
11 |
12 | linter:
13 | # The lint rules applied to this project can be customized in the
14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml`
15 | # included above or to enable additional rules. A list of all available lints
16 | # and their documentation is published at
17 | # https://dart-lang.github.io/linter/lints/index.html.
18 | #
19 | # Instead of disabling a lint rule for the entire project in the
20 | # section below, it can also be suppressed for a single line of code
21 | # or a specific dart file by using the `// ignore: name_of_lint` and
22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file
23 | # producing the lint.
24 | rules:
25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule
26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule
27 |
28 | # Additional information about this file can be found at
29 | # https://dart.dev/guides/language/analysis-options
30 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | $(DEVELOPMENT_LANGUAGE)
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | flutter_nodejs_crud_app
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | $(FLUTTER_BUILD_NAME)
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | $(FLUTTER_BUILD_NUMBER)
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UISupportedInterfaceOrientations
30 |
31 | UIInterfaceOrientationPortrait
32 | UIInterfaceOrientationLandscapeLeft
33 | UIInterfaceOrientationLandscapeRight
34 |
35 | UISupportedInterfaceOrientations~ipad
36 |
37 | UIInterfaceOrientationPortrait
38 | UIInterfaceOrientationPortraitUpsideDown
39 | UIInterfaceOrientationLandscapeLeft
40 | UIInterfaceOrientationLandscapeRight
41 |
42 | UIViewControllerBasedStatusBarAppearance
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/api/index.js:
--------------------------------------------------------------------------------
1 | const express = require("express");
2 | const app = express();
3 | const mongoose = require("mongoose");
4 | const { MONGO_DB_CONFIG } = require("./config/app.config");
5 | const errors = require("./middleware/errors.js");
6 | const swaggerUi = require("swagger-ui-express"), swaggerDocument = require("./swagger.json");
7 |
8 | // connect to mongodb
9 |
10 | /**
11 | * With useNewUrlParser: The underlying MongoDB driver has deprecated their current connection string parser.
12 | * Because this is a major change, they added the useNewUrlParser flag to allow users to fall back to the old parser if they find a bug in the new parser.
13 | * You should set useNewUrlParser: true unless that prevents you from connecting.
14 | *
15 | * With useUnifiedTopology, the MongoDB driver sends a heartbeat every heartbeatFrequencyMS to check on the status of the connection.
16 | * A heartbeat is subject to serverSelectionTimeoutMS , so the MongoDB driver will retry failed heartbeats for up to 30 seconds by default.
17 | */
18 | mongoose.Promise = global.Promise;
19 | mongoose
20 | .connect(MONGO_DB_CONFIG.DB, {
21 | useNewUrlParser: true,
22 | useUnifiedTopology: true,
23 | })
24 | .then(
25 | () => {
26 | console.log("Database connected");
27 | },
28 | (error) => {
29 | console.log("Database can't be connected: " + error);
30 | }
31 | );
32 |
33 | app.use(express.json());
34 |
35 | app.use("/uploads", express.static("uploads"));
36 |
37 | // initialize routes
38 | app.use("/api", require("./routes/app.routes"));
39 |
40 | app.use(errors.errorHandler);
41 |
42 | app.use("/api-docs", swaggerUi.serve, swaggerUi.setup(swaggerDocument));
43 |
44 | // listen for requests
45 | app.listen(process.env.port || 5000, function () {
46 | console.log("Ready to Go!");
47 | });
48 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Flutter CRUD Using NodeJS API
2 |
3 | In this video we will learn how to Create CRUD Rest API for our Flutter application using NODEJS API.
4 |
5 | [](https://www.youtube.com/watch?v=Euq_-_Xmi9U)
6 |
7 | [](https://www.youtube.com/watch?v=_QTuK4PH1hs)
8 |
9 | [](https://www.youtube.com/watch?v=z45p7_sizJk)
10 |
11 |
12 |
13 | ##### 📎Packages Used
14 | ##### https://pub.dev/packages/snippet_coder_utils
15 | ##### https://pub.dev/packages/api_cache_manager
16 | ##### https://pub.dev/packages/image_picker
17 | ##### https://www.npmjs.com/package/swagger-ui-express
18 | ##### https://swagger.io/docs/specification/basic-structure/
19 |
20 |
21 |
22 | ##### 📎Json to Dart ConverterJson to Dart Converter
23 | ##### https://www.dripcoding.com/json-to-dart/
24 |
25 |
26 |
27 | ### 🤝Stay Connected with me !
28 | ##### ✔ Instagram : https://www.instagram.com/SnippetCoder
29 | ##### ✔ Facebook : https://www.facebook.com/SnippetCoder
30 | ##### ✔ Twitter : https://www.twitter.com/SnippetCoder
31 | ##### ✔ Telegram : https://t.me/SnippetCoder
32 | ##### ✔ Github : https://github.com/SnippetCoders/
33 |
34 |
35 |
36 | ### ⛄If you like my work , you can support me
37 | #### ☑️Patreon : https://www.patreon.com/SnippetCoder
38 | #### ☑️PayPal : http://www.paypal.me/iSharpeners
39 | #### ☑️DM For UPI Number
40 |
41 |
42 |
43 | PLEASE SUBSCRIBE AND SHARE THIS VIDEO!!!!😳
44 | THANKS FOR WATCHING!!!
45 |
46 | 🔥NODEJS API for Flutter Developers🔥
47 | https://youtu.be/_hv-4knConI
48 |
49 | 🔥 Node JS Register and Login API using JWT & MongoDB 🔥
50 | https://youtu.be/ZEg03f1o_vQ
51 |
52 | 🔥 Flutter OTP Login Using NodeJS API 🔥
53 | https://youtu.be/KbF6uVMGDxg
54 |
55 | 🔥 NodeJS Login & Register Rest API with MySQL 🔥
56 | https://youtu.be/YINNyvMS35k
57 |
58 | 🔥 Flutter Push Notification Using NodeJS API 🔥
59 | https://youtu.be/3C5pfo7Bc3E
60 |
61 |
62 | Tags and SEO Stuff :
63 | #flutter #NodeJS #SnippetCoder
64 |
--------------------------------------------------------------------------------
/flutter/android/app/build.gradle:
--------------------------------------------------------------------------------
1 | def localProperties = new Properties()
2 | def localPropertiesFile = rootProject.file('local.properties')
3 | if (localPropertiesFile.exists()) {
4 | localPropertiesFile.withReader('UTF-8') { reader ->
5 | localProperties.load(reader)
6 | }
7 | }
8 |
9 | def flutterRoot = localProperties.getProperty('flutter.sdk')
10 | if (flutterRoot == null) {
11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
12 | }
13 |
14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
15 | if (flutterVersionCode == null) {
16 | flutterVersionCode = '1'
17 | }
18 |
19 | def flutterVersionName = localProperties.getProperty('flutter.versionName')
20 | if (flutterVersionName == null) {
21 | flutterVersionName = '1.0'
22 | }
23 |
24 | apply plugin: 'com.android.application'
25 | apply plugin: 'kotlin-android'
26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
27 |
28 | android {
29 | compileSdkVersion 30
30 |
31 | compileOptions {
32 | sourceCompatibility JavaVersion.VERSION_1_8
33 | targetCompatibility JavaVersion.VERSION_1_8
34 | }
35 |
36 | kotlinOptions {
37 | jvmTarget = '1.8'
38 | }
39 |
40 | sourceSets {
41 | main.java.srcDirs += 'src/main/kotlin'
42 | }
43 |
44 | defaultConfig {
45 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
46 | applicationId "com.example.flutter_nodejs_crud_app"
47 | minSdkVersion 16
48 | targetSdkVersion 30
49 | versionCode flutterVersionCode.toInteger()
50 | versionName flutterVersionName
51 | }
52 |
53 | buildTypes {
54 | release {
55 | // TODO: Add your own signing config for the release build.
56 | // Signing with the debug keys for now, so `flutter run --release` works.
57 | signingConfig signingConfigs.debug
58 | }
59 | }
60 | }
61 |
62 | flutter {
63 | source '../..'
64 | }
65 |
66 | dependencies {
67 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
68 | }
69 |
--------------------------------------------------------------------------------
/flutter/android/app/src/main/AndroidManifest.xml:
--------------------------------------------------------------------------------
1 |
3 |
6 |
13 |
17 |
21 |
26 |
30 |
31 |
32 |
33 |
34 |
35 |
37 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/api/services/products.services.js:
--------------------------------------------------------------------------------
1 | const { product } = require("../models/products.model");
2 |
3 | async function createProduct(params, callback) {
4 | if (!params.productName) {
5 | return callback(
6 | {
7 | message: "Product Name Required",
8 | },
9 | ""
10 | );
11 | }
12 |
13 | const productModel = new product(params);
14 | productModel
15 | .save()
16 | .then((response) => {
17 | return callback(null, response);
18 | })
19 | .catch((error) => {
20 | return callback(error);
21 | });
22 | }
23 |
24 | async function getProducts(params, callback) {
25 | const productName = params.productName;
26 | var condition = productName
27 | ? { productName: { $regex: new RegExp(productName), $options: "i" } }
28 | : {};
29 |
30 | product
31 | .find(condition)
32 | .then((response) => {
33 | return callback(null, response);
34 | })
35 | .catch((error) => {
36 | return callback(error);
37 | });
38 | }
39 |
40 | async function getProductById(params, callback) {
41 | const productId = params.productId;
42 |
43 | product
44 | .findById(productId)
45 | .then((response) => {
46 | if (!response) callback("Not found Product with id " + productId);
47 | else callback(null, response);
48 | })
49 | .catch((error) => {
50 | return callback(error);
51 | });
52 | }
53 |
54 | async function updateProduct(params, callback) {
55 | const productId = params.productId;
56 |
57 | product
58 | .findByIdAndUpdate(productId, params, { useFindAndModify: false })
59 | .then((response) => {
60 | if (!response) callback(`Cannot update Tutorial with id=${productId}. Maybe Tutorial was not found!`);
61 | else callback(null, response);
62 | })
63 | .catch((error) => {
64 | return callback(error);
65 | });
66 | }
67 |
68 | async function deleteProduct(params, callback) {
69 | const productId = params.productId;
70 |
71 | product
72 | .findByIdAndRemove(productId)
73 | .then((response) => {
74 | if (!response) callback(`Cannot delete Product with id=${productId}. Maybe Product was not found!`);
75 | else callback(null, response);
76 | })
77 | .catch((error) => {
78 | return callback(error);
79 | });
80 | }
81 |
82 | module.exports = {
83 | createProduct,
84 | getProducts,
85 | getProductById,
86 | updateProduct,
87 | deleteProduct
88 | };
89 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/flutter/lib/services/api_service.dart:
--------------------------------------------------------------------------------
1 | import 'dart:convert';
2 | import 'dart:io';
3 |
4 | import 'package:flutter_nodejs_crud_app/model/product_model.dart';
5 | import 'package:http/http.dart' as http;
6 |
7 | import '../../config.dart';
8 |
9 | class APIService {
10 | static var client = http.Client();
11 |
12 | static Future?> getProducts() async {
13 | Map requestHeaders = {
14 | 'Content-Type': 'application/json',
15 | };
16 |
17 | var url = Uri.http(
18 | Config.apiURL,
19 | Config.productsAPI,
20 | );
21 |
22 | var response = await client.get(
23 | url,
24 | headers: requestHeaders,
25 | );
26 |
27 | if (response.statusCode == 200) {
28 | var data = jsonDecode(response.body);
29 |
30 | return productsFromJson(data["data"]);
31 |
32 | //return true;
33 | } else {
34 | return null;
35 | }
36 | }
37 |
38 | static Future saveProduct(
39 | ProductModel model,
40 | bool isEditMode,
41 | bool isFileSelected,
42 | ) async {
43 | var productURL = Config.productsAPI;
44 |
45 | if (isEditMode) {
46 | productURL = productURL + "/" + model.id.toString();
47 | }
48 |
49 | var url = Uri.http(Config.apiURL, productURL);
50 |
51 | var requestMethod = isEditMode ? "PUT" : "POST";
52 |
53 | var request = http.MultipartRequest(requestMethod, url);
54 | request.fields["productName"] = model.productName!;
55 | request.fields["productPrice"] = model.productPrice!.toString();
56 |
57 | if (model.productImage != null && isFileSelected) {
58 | http.MultipartFile multipartFile = await http.MultipartFile.fromPath(
59 | 'productImage',
60 | model.productImage!,
61 | );
62 |
63 | request.files.add(multipartFile);
64 | }
65 |
66 | var response = await request.send();
67 |
68 | if (response.statusCode == 200) {
69 | return true;
70 | } else {
71 | return false;
72 | }
73 | }
74 |
75 | static Future deleteProduct(productId) async {
76 | Map requestHeaders = {
77 | 'Content-Type': 'application/json',
78 | };
79 |
80 | var url = Uri.http(
81 | Config.apiURL,
82 | Config.productsAPI + "/" + productId,
83 | );
84 |
85 | var response = await client.delete(
86 | url,
87 | headers: requestHeaders,
88 | );
89 |
90 | if (response.statusCode == 200) {
91 | return true;
92 | } else {
93 | return false;
94 | }
95 | }
96 | }
97 |
--------------------------------------------------------------------------------
/flutter/ios/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "20x20",
5 | "idiom" : "iphone",
6 | "filename" : "Icon-App-20x20@2x.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "20x20",
11 | "idiom" : "iphone",
12 | "filename" : "Icon-App-20x20@3x.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "29x29",
17 | "idiom" : "iphone",
18 | "filename" : "Icon-App-29x29@1x.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "29x29",
23 | "idiom" : "iphone",
24 | "filename" : "Icon-App-29x29@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "29x29",
29 | "idiom" : "iphone",
30 | "filename" : "Icon-App-29x29@3x.png",
31 | "scale" : "3x"
32 | },
33 | {
34 | "size" : "40x40",
35 | "idiom" : "iphone",
36 | "filename" : "Icon-App-40x40@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "40x40",
41 | "idiom" : "iphone",
42 | "filename" : "Icon-App-40x40@3x.png",
43 | "scale" : "3x"
44 | },
45 | {
46 | "size" : "60x60",
47 | "idiom" : "iphone",
48 | "filename" : "Icon-App-60x60@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "60x60",
53 | "idiom" : "iphone",
54 | "filename" : "Icon-App-60x60@3x.png",
55 | "scale" : "3x"
56 | },
57 | {
58 | "size" : "20x20",
59 | "idiom" : "ipad",
60 | "filename" : "Icon-App-20x20@1x.png",
61 | "scale" : "1x"
62 | },
63 | {
64 | "size" : "20x20",
65 | "idiom" : "ipad",
66 | "filename" : "Icon-App-20x20@2x.png",
67 | "scale" : "2x"
68 | },
69 | {
70 | "size" : "29x29",
71 | "idiom" : "ipad",
72 | "filename" : "Icon-App-29x29@1x.png",
73 | "scale" : "1x"
74 | },
75 | {
76 | "size" : "29x29",
77 | "idiom" : "ipad",
78 | "filename" : "Icon-App-29x29@2x.png",
79 | "scale" : "2x"
80 | },
81 | {
82 | "size" : "40x40",
83 | "idiom" : "ipad",
84 | "filename" : "Icon-App-40x40@1x.png",
85 | "scale" : "1x"
86 | },
87 | {
88 | "size" : "40x40",
89 | "idiom" : "ipad",
90 | "filename" : "Icon-App-40x40@2x.png",
91 | "scale" : "2x"
92 | },
93 | {
94 | "size" : "76x76",
95 | "idiom" : "ipad",
96 | "filename" : "Icon-App-76x76@1x.png",
97 | "scale" : "1x"
98 | },
99 | {
100 | "size" : "76x76",
101 | "idiom" : "ipad",
102 | "filename" : "Icon-App-76x76@2x.png",
103 | "scale" : "2x"
104 | },
105 | {
106 | "size" : "83.5x83.5",
107 | "idiom" : "ipad",
108 | "filename" : "Icon-App-83.5x83.5@2x.png",
109 | "scale" : "2x"
110 | },
111 | {
112 | "size" : "1024x1024",
113 | "idiom" : "ios-marketing",
114 | "filename" : "Icon-App-1024x1024@1x.png",
115 | "scale" : "1x"
116 | }
117 | ],
118 | "info" : {
119 | "version" : 1,
120 | "author" : "xcode"
121 | }
122 | }
123 |
--------------------------------------------------------------------------------
/api/controllers/products.controller.js:
--------------------------------------------------------------------------------
1 | const productsServices = require("../services/products.services");
2 | const upload = require("../middleware/upload.js");
3 |
4 | // Create and Save a new Product
5 | exports.create = (req, res, next) => {
6 | upload(req, res, function (err) {
7 | if (err) {
8 | next(err);
9 | } else {
10 | const url = req.protocol + "://" + req.get("host");
11 |
12 | const path =
13 | req.file != undefined ? req.file.path.replace(/\\/g, "/") : "";
14 |
15 | var model = {
16 | productName: req.body.productName,
17 | productDescription: req.body.productDescription,
18 | productPrice: req.body.productPrice,
19 | productImage: path != "" ? url + "/" + path : "",
20 | };
21 |
22 | productsServices.createProduct(model, (error, results) => {
23 | if (error) {
24 | return next(error);
25 | }
26 | return res.status(200).send({
27 | message: "Success",
28 | data: results,
29 | });
30 | });
31 | }
32 | });
33 | };
34 |
35 | // Retrieve all Products from the database.
36 | exports.findAll = (req, res, next) => {
37 | var model = {
38 | productName: req.query.productName,
39 | };
40 |
41 | productsServices.getProducts(model, (error, results) => {
42 | if (error) {
43 | return next(error);
44 | }
45 | return res.status(200).send({
46 | message: "Success",
47 | data: results,
48 | });
49 | });
50 | };
51 |
52 | // Find a single Tutorial with an id
53 | exports.findOne = (req, res, next) => {
54 | var model = {
55 | productId: req.params.id,
56 | };
57 |
58 | productsServices.getProductById(model, (error, results) => {
59 | if (error) {
60 | return next(error);
61 | }
62 | return res.status(200).send({
63 | message: "Success",
64 | data: results,
65 | });
66 | });
67 | };
68 |
69 | // Update a Product by the id in the request
70 | exports.update = (req, res, next) => {
71 | upload(req, res, function (err) {
72 | if (err) {
73 | next(err);
74 | } else {
75 | const url = req.protocol + "://" + req.get("host");
76 |
77 | const path =
78 | req.file != undefined ? req.file.path.replace(/\\/g, "/") : "";
79 |
80 | var model = {
81 | productId: req.params.id,
82 | productName: req.body.productName,
83 | productDescription: req.body.productDescription,
84 | productPrice: req.body.productPrice,
85 | productImage: path != "" ? url + "/" + path : "",
86 | };
87 |
88 | console.log(model);
89 |
90 | productsServices.updateProduct(model, (error, results) => {
91 | if (error) {
92 | return next(error);
93 | }
94 | return res.status(200).send({
95 | message: "Success",
96 | data: results,
97 | });
98 | });
99 | }
100 | });
101 | };
102 |
103 | // Delete a Product with the specified id in the request
104 | exports.delete = (req, res, next) => {
105 | var model = {
106 | productId: req.params.id,
107 | };
108 |
109 | productsServices.deleteProduct(model, (error, results) => {
110 | if (error) {
111 | return next(error);
112 | }
113 | return res.status(200).send({
114 | message: "Success",
115 | data: results,
116 | });
117 | });
118 | };
119 |
--------------------------------------------------------------------------------
/flutter/lib/pages/product_item.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:snippet_coder_utils/FormHelper.dart';
3 | import '../model/product_model.dart';
4 |
5 | class ProductItem extends StatelessWidget {
6 | final ProductModel? model;
7 | final Function? onDelete;
8 |
9 | ProductItem({
10 | Key? key,
11 | this.model,
12 | this.onDelete,
13 | }) : super(key: key);
14 |
15 | @override
16 | Widget build(BuildContext context) {
17 | return Card(
18 | elevation: 0,
19 | margin: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 5.0),
20 | child: Container(
21 | width: 200,
22 | decoration: BoxDecoration(
23 | color: Colors.white,
24 | borderRadius: BorderRadius.circular(50),
25 | ),
26 | child: cartItem(context),
27 | ),
28 | );
29 | }
30 |
31 | Widget cartItem(context) {
32 | return Row(
33 | mainAxisAlignment: MainAxisAlignment.start,
34 | crossAxisAlignment: CrossAxisAlignment.start,
35 | children: [
36 | Container(
37 | width: 120,
38 | alignment: Alignment.center,
39 | margin: EdgeInsets.all(10),
40 | child: Image.network(
41 | (model!.productImage == null || model!.productImage == "")
42 | ? "https://upload.wikimedia.org/wikipedia/commons/thumb/6/65/No-Image-Placeholder.svg/1665px-No-Image-Placeholder.svg.png"
43 | : model!.productImage!,
44 | height: 70,
45 | fit: BoxFit.scaleDown,
46 | ),
47 | ),
48 | Padding(
49 | padding: const EdgeInsets.all(8.0),
50 | child: Column(
51 | mainAxisAlignment: MainAxisAlignment.start,
52 | crossAxisAlignment: CrossAxisAlignment.start,
53 | children: [
54 | Text(
55 | model!.productName!,
56 | style: const TextStyle(
57 | color: Colors.black,
58 | fontWeight: FontWeight.bold,
59 | ),
60 | ),
61 | const SizedBox(
62 | height: 10,
63 | ),
64 | Text(
65 | "₹${model!.productPrice}",
66 | style: const TextStyle(color: Colors.black),
67 | ),
68 | const SizedBox(
69 | height: 10,
70 | ),
71 | Container(
72 | width: MediaQuery.of(context).size.width - 180,
73 | child: Row(
74 | mainAxisAlignment: MainAxisAlignment.end,
75 | children: [
76 | GestureDetector(
77 | child: const Icon(Icons.edit),
78 | onTap: () {
79 | Navigator.of(context).pushNamed(
80 | '/edit-product',
81 | arguments: {
82 | 'model': model,
83 | },
84 | );
85 | },
86 | ),
87 | GestureDetector(
88 | child: const Icon(
89 | Icons.delete,
90 | color: Colors.red,
91 | ),
92 | onTap: () {
93 | onDelete!(model);
94 | },
95 | ),
96 | ],
97 | ),
98 | )
99 | ],
100 | ),
101 | ),
102 | ],
103 | );
104 | }
105 | }
106 |
--------------------------------------------------------------------------------
/flutter/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme:
--------------------------------------------------------------------------------
1 |
2 |
5 |
8 |
9 |
15 |
21 |
22 |
23 |
24 |
25 |
30 |
31 |
32 |
33 |
39 |
40 |
41 |
42 |
43 |
44 |
54 |
56 |
62 |
63 |
64 |
65 |
66 |
67 |
73 |
75 |
81 |
82 |
83 |
84 |
86 |
87 |
90 |
91 |
92 |
--------------------------------------------------------------------------------
/flutter/pubspec.yaml:
--------------------------------------------------------------------------------
1 | name: flutter_nodejs_crud_app
2 | description: A new Flutter project.
3 |
4 | # The following line prevents the package from being accidentally published to
5 | # pub.dev using `flutter pub publish`. This is preferred for private packages.
6 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev
7 |
8 | # The following defines the version and build number for your application.
9 | # A version number is three numbers separated by dots, like 1.2.43
10 | # followed by an optional build number separated by a +.
11 | # Both the version and the builder number may be overridden in flutter
12 | # build by specifying --build-name and --build-number, respectively.
13 | # In Android, build-name is used as versionName while build-number used as versionCode.
14 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning
15 | # In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
16 | # Read more about iOS versioning at
17 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
18 | version: 1.0.0+1
19 |
20 | environment:
21 | sdk: ">=2.12.0 <3.0.0"
22 |
23 | # Dependencies specify other packages that your package needs in order to work.
24 | # To automatically upgrade your package dependencies to the latest versions
25 | # consider running `flutter pub upgrade --major-versions`. Alternatively,
26 | # dependencies can be manually updated by changing the version numbers below to
27 | # the latest version available on pub.dev. To see which dependencies have newer
28 | # versions available, run `flutter pub outdated`.
29 | dependencies:
30 | flutter:
31 | sdk: flutter
32 | snippet_coder_utils: ^1.0.9
33 | image_picker: ^0.8.4+4
34 |
35 |
36 | # The following adds the Cupertino Icons font to your application.
37 | # Use with the CupertinoIcons class for iOS style icons.
38 | cupertino_icons: ^1.0.2
39 |
40 | dev_dependencies:
41 | flutter_test:
42 | sdk: flutter
43 |
44 | # The "flutter_lints" package below contains a set of recommended lints to
45 | # encourage good coding practices. The lint set provided by the package is
46 | # activated in the `analysis_options.yaml` file located at the root of your
47 | # package. See that file for information about deactivating specific lint
48 | # rules and activating additional ones.
49 | flutter_lints: ^1.0.0
50 |
51 | # For information on the generic Dart part of this file, see the
52 | # following page: https://dart.dev/tools/pub/pubspec
53 |
54 | # The following section is specific to Flutter.
55 | flutter:
56 |
57 | # The following line ensures that the Material Icons font is
58 | # included with your application, so that you can use the icons in
59 | # the material Icons class.
60 | uses-material-design: true
61 |
62 | # To add assets to your application, add an assets section, like this:
63 | # assets:
64 | # - images/a_dot_burr.jpeg
65 | # - images/a_dot_ham.jpeg
66 |
67 | # An image asset can refer to one or more resolution-specific "variants", see
68 | # https://flutter.dev/assets-and-images/#resolution-aware.
69 |
70 | # For details regarding adding assets from package dependencies, see
71 | # https://flutter.dev/assets-and-images/#from-packages
72 |
73 | # To add custom fonts to your application, add a fonts section here,
74 | # in this "flutter" section. Each entry in this list should have a
75 | # "family" key with the font family name, and a "fonts" key with a
76 | # list giving the asset and other descriptors for the font. For
77 | # example:
78 | # fonts:
79 | # - family: Schyler
80 | # fonts:
81 | # - asset: fonts/Schyler-Regular.ttf
82 | # - asset: fonts/Schyler-Italic.ttf
83 | # style: italic
84 | # - family: Trajan Pro
85 | # fonts:
86 | # - asset: fonts/TrajanPro.ttf
87 | # - asset: fonts/TrajanPro_Bold.ttf
88 | # weight: 700
89 | #
90 | # For details regarding fonts from package dependencies,
91 | # see https://flutter.dev/custom-fonts/#from-packages
92 |
--------------------------------------------------------------------------------
/flutter/web/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | flutter_nodejs_crud_app
30 |
31 |
32 |
33 |
36 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/flutter/lib/pages/product_list.dart:
--------------------------------------------------------------------------------
1 | import 'package:flutter/material.dart';
2 | import 'package:flutter_nodejs_crud_app/model/product_model.dart';
3 | import 'package:flutter_nodejs_crud_app/pages/product_item.dart';
4 | import 'package:flutter_nodejs_crud_app/services/api_service.dart';
5 | import 'package:snippet_coder_utils/ProgressHUD.dart';
6 |
7 | class ProductsList extends StatefulWidget {
8 | const ProductsList({Key? key}) : super(key: key);
9 |
10 | @override
11 | _ProductsListState createState() => _ProductsListState();
12 | }
13 |
14 | class _ProductsListState extends State {
15 | // List products = List.empty(growable: true);
16 | bool isApiCallProcess = false;
17 | @override
18 | void initState() {
19 | super.initState();
20 |
21 | // products.add(
22 | // ProductModel(
23 | // id: "1",
24 | // productName: "Haldiram",
25 | // productImage:
26 | // "https://cdn.grofers.com/cdn-cgi/image/f=auto,fit=scale-down,q=85,metadata=none,w=400,h=400/app/images/products/full_screen/pro_86973.jpg",
27 | // productDescription: "Haldiram Foods",
28 | // productPrice: 500,
29 | // ),
30 | // );
31 |
32 | // products.add(
33 | // ProductModel(
34 | // id: "1",
35 | // productName: "Haldiram",
36 | // productImage:
37 | // "https://cdn.grofers.com/cdn-cgi/image/f=auto,fit=scale-down,q=85,metadata=none,w=400,h=400/app/images/products/full_screen/pro_86973.jpg",
38 | // productDescription: "Haldiram Foods",
39 | // productPrice: 500,
40 | // ),
41 | // );
42 | }
43 |
44 | @override
45 | Widget build(BuildContext context) {
46 | return Scaffold(
47 | appBar: AppBar(
48 | title: const Text('NodeJS - CRUD'),
49 | elevation: 0,
50 | ),
51 | backgroundColor: Colors.grey[200],
52 | body: ProgressHUD(
53 | child: loadProducts(),
54 | inAsyncCall: isApiCallProcess,
55 | opacity: 0.3,
56 | key: UniqueKey(),
57 | ),
58 | );
59 | }
60 |
61 | Widget loadProducts() {
62 | return FutureBuilder(
63 | future: APIService.getProducts(),
64 | builder: (
65 | BuildContext context,
66 | AsyncSnapshot?> model,
67 | ) {
68 | if (model.hasData) {
69 | return productList(model.data);
70 | }
71 |
72 | return const Center(
73 | child: CircularProgressIndicator(),
74 | );
75 | },
76 | );
77 | }
78 |
79 | Widget productList(products) {
80 | return SingleChildScrollView(
81 | child: Column(
82 | mainAxisAlignment: MainAxisAlignment.spaceAround,
83 | crossAxisAlignment: CrossAxisAlignment.center,
84 | children: [
85 | Column(
86 | mainAxisAlignment: MainAxisAlignment.start,
87 | children: [
88 | ElevatedButton(
89 | style: ElevatedButton.styleFrom(
90 | onPrimary: Colors.white,
91 | primary: Colors.green,
92 | minimumSize: const Size(88, 36),
93 | padding: const EdgeInsets.symmetric(horizontal: 16),
94 | shape: const RoundedRectangleBorder(
95 | borderRadius: BorderRadius.all(
96 | Radius.circular(10),
97 | ),
98 | ),
99 | ),
100 | onPressed: () {
101 | Navigator.pushNamed(
102 | context,
103 | '/add-product',
104 | );
105 | },
106 | child: const Text('Add Product'),
107 | ),
108 | ListView.builder(
109 | shrinkWrap: true,
110 | physics: const ClampingScrollPhysics(),
111 | scrollDirection: Axis.vertical,
112 | itemCount: products.length,
113 | itemBuilder: (context, index) {
114 | return ProductItem(
115 | model: products[index],
116 | onDelete: (ProductModel model) {
117 | setState(() {
118 | isApiCallProcess = true;
119 | });
120 |
121 | APIService.deleteProduct(model.id).then(
122 | (response) {
123 | setState(() {
124 | isApiCallProcess = false;
125 | });
126 | },
127 | );
128 | },
129 | );
130 | },
131 | ),
132 | ],
133 | )
134 | ],
135 | ),
136 | );
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/api/swagger.json:
--------------------------------------------------------------------------------
1 | {
2 | "swagger": "2.0",
3 | "info": {
4 | "version": "1.0.0",
5 | "title": "Shopping App - CRUD",
6 | "description": "My Shopping App Project Application API",
7 | "license": {
8 | "name": "MIT",
9 | "url": "https://opensource.org/licenses/MIT"
10 | }
11 | },
12 | "host": "localhost:5000",
13 | "basePath": "/",
14 | "tags": [
15 | {
16 | "name": "Products",
17 | "description": "Products API"
18 | }
19 | ],
20 | "schemes": ["http"],
21 | "consumes": ["application/json"],
22 | "produces": ["application/json"],
23 | "paths": {
24 | "/api/products": {
25 | "get": {
26 | "tags": ["Products"],
27 | "summary": "Get all products",
28 | "parameters": [
29 | {
30 | "name": "productName",
31 | "in": "query",
32 | "required": false,
33 | "description": "Product Name",
34 | "type": "string"
35 | }
36 | ],
37 | "responses": {
38 | "200": {
39 | "description": "OK",
40 | "schema": {
41 | "$ref": "#/definitions/ServiceResponse"
42 | }
43 | }
44 | }
45 | },
46 | "post": {
47 | "tags": ["Products"],
48 | "summary": "Create Product API",
49 | "parameters": [
50 | {
51 | "name": "productName",
52 | "in": "formData",
53 | "description": "Product Name",
54 | "required": true,
55 | "type": "string"
56 | },
57 | {
58 | "name": "productDescription",
59 | "in": "formData",
60 | "description": "Product Description",
61 | "type": "string"
62 | },
63 | {
64 | "name": "productPrice",
65 | "in": "formData",
66 | "description": "Product Price",
67 | "required": true,
68 | "type": "integer"
69 | },
70 | {
71 | "name": "productImage",
72 | "in": "formData",
73 | "description": "Product Image",
74 | "type": "file"
75 | }
76 | ],
77 | "responses": {
78 | "200": {
79 | "description": "OK",
80 | "schema": {
81 | "$ref": "#/definitions/ServiceResponse"
82 | }
83 | }
84 | }
85 | }
86 | },
87 | "/api/products/{id}": {
88 | "parameters": [
89 | {
90 | "name": "id",
91 | "in": "path",
92 | "required": true,
93 | "description": "Product Id",
94 | "type": "string"
95 | }
96 | ],
97 | "get": {
98 | "tags": ["Products"],
99 | "summary": "Product Details based on Product Id",
100 | "responses": {
101 | "200": {
102 | "description": "OK",
103 | "schema": {
104 | "$ref": "#/definitions/ServiceResponse"
105 | }
106 | }
107 | }
108 | },
109 | "put": {
110 | "tags": ["Products"],
111 | "summary": "Update Product API",
112 | "parameters": [
113 | {
114 | "name": "productName",
115 | "in": "formData",
116 | "description": "Product Name",
117 | "required": true,
118 | "type": "string"
119 | },
120 | {
121 | "name": "productDescription",
122 | "in": "formData",
123 | "description": "Product Description",
124 | "type": "string"
125 | },
126 | {
127 | "name": "productPrice",
128 | "in": "formData",
129 | "description": "Product Price",
130 | "required": true,
131 | "type": "integer"
132 | },
133 | {
134 | "name": "productImage",
135 | "in": "formData",
136 | "description": "Product Image",
137 | "type": "file"
138 | }
139 | ],
140 | "responses": {
141 | "200": {
142 | "description": "OK",
143 | "schema": {
144 | "$ref": "#/definitions/ServiceResponse"
145 | }
146 | }
147 | }
148 | },
149 | "delete": {
150 | "tags": ["Products"],
151 | "summary": "Delete Product API",
152 | "responses": {
153 | "200": {
154 | "description": "OK",
155 | "schema": {
156 | "$ref": "#/definitions/ServiceResponse"
157 | }
158 | }
159 | }
160 | }
161 | }
162 | },
163 | "definitions": {
164 | "Product": {
165 | "required": ["productName", "_id", "productPrice"],
166 | "properties": {
167 | "_id": {
168 | "type": "integer",
169 | "uniqueItems": true
170 | },
171 | "productName": {
172 | "type": "string"
173 | },
174 | "productDescription": {
175 | "type": "string"
176 | },
177 | "productPrice": {
178 | "type": "number"
179 | },
180 | "productImage": {
181 | "type": "string"
182 | }
183 | }
184 | },
185 | "ServiceResponse": {
186 | "properties": {
187 | "message": {
188 | "type": "string"
189 | },
190 | "data": {
191 | "type": "array",
192 | "items": {
193 | "$ref": "#/definitions/Product"
194 | }
195 | }
196 | }
197 | }
198 | }
199 | }
200 |
--------------------------------------------------------------------------------
/flutter/pubspec.lock:
--------------------------------------------------------------------------------
1 | # Generated by pub
2 | # See https://dart.dev/tools/pub/glossary#lockfile
3 | packages:
4 | async:
5 | dependency: transitive
6 | description:
7 | name: async
8 | url: "https://pub.dartlang.org"
9 | source: hosted
10 | version: "2.8.2"
11 | boolean_selector:
12 | dependency: transitive
13 | description:
14 | name: boolean_selector
15 | url: "https://pub.dartlang.org"
16 | source: hosted
17 | version: "2.1.0"
18 | characters:
19 | dependency: transitive
20 | description:
21 | name: characters
22 | url: "https://pub.dartlang.org"
23 | source: hosted
24 | version: "1.2.0"
25 | charcode:
26 | dependency: transitive
27 | description:
28 | name: charcode
29 | url: "https://pub.dartlang.org"
30 | source: hosted
31 | version: "1.3.1"
32 | clock:
33 | dependency: transitive
34 | description:
35 | name: clock
36 | url: "https://pub.dartlang.org"
37 | source: hosted
38 | version: "1.1.0"
39 | collection:
40 | dependency: transitive
41 | description:
42 | name: collection
43 | url: "https://pub.dartlang.org"
44 | source: hosted
45 | version: "1.15.0"
46 | cross_file:
47 | dependency: transitive
48 | description:
49 | name: cross_file
50 | url: "https://pub.dartlang.org"
51 | source: hosted
52 | version: "0.3.2"
53 | cupertino_icons:
54 | dependency: "direct main"
55 | description:
56 | name: cupertino_icons
57 | url: "https://pub.dartlang.org"
58 | source: hosted
59 | version: "1.0.4"
60 | fake_async:
61 | dependency: transitive
62 | description:
63 | name: fake_async
64 | url: "https://pub.dartlang.org"
65 | source: hosted
66 | version: "1.2.0"
67 | flutter:
68 | dependency: "direct main"
69 | description: flutter
70 | source: sdk
71 | version: "0.0.0"
72 | flutter_lints:
73 | dependency: "direct dev"
74 | description:
75 | name: flutter_lints
76 | url: "https://pub.dartlang.org"
77 | source: hosted
78 | version: "1.0.4"
79 | flutter_plugin_android_lifecycle:
80 | dependency: transitive
81 | description:
82 | name: flutter_plugin_android_lifecycle
83 | url: "https://pub.dartlang.org"
84 | source: hosted
85 | version: "2.0.5"
86 | flutter_test:
87 | dependency: "direct dev"
88 | description: flutter
89 | source: sdk
90 | version: "0.0.0"
91 | flutter_web_plugins:
92 | dependency: transitive
93 | description: flutter
94 | source: sdk
95 | version: "0.0.0"
96 | http:
97 | dependency: transitive
98 | description:
99 | name: http
100 | url: "https://pub.dartlang.org"
101 | source: hosted
102 | version: "0.13.4"
103 | http_parser:
104 | dependency: transitive
105 | description:
106 | name: http_parser
107 | url: "https://pub.dartlang.org"
108 | source: hosted
109 | version: "4.0.0"
110 | image_picker:
111 | dependency: "direct main"
112 | description:
113 | name: image_picker
114 | url: "https://pub.dartlang.org"
115 | source: hosted
116 | version: "0.8.4+4"
117 | image_picker_for_web:
118 | dependency: transitive
119 | description:
120 | name: image_picker_for_web
121 | url: "https://pub.dartlang.org"
122 | source: hosted
123 | version: "2.1.4"
124 | image_picker_platform_interface:
125 | dependency: transitive
126 | description:
127 | name: image_picker_platform_interface
128 | url: "https://pub.dartlang.org"
129 | source: hosted
130 | version: "2.4.1"
131 | js:
132 | dependency: transitive
133 | description:
134 | name: js
135 | url: "https://pub.dartlang.org"
136 | source: hosted
137 | version: "0.6.3"
138 | lints:
139 | dependency: transitive
140 | description:
141 | name: lints
142 | url: "https://pub.dartlang.org"
143 | source: hosted
144 | version: "1.0.1"
145 | matcher:
146 | dependency: transitive
147 | description:
148 | name: matcher
149 | url: "https://pub.dartlang.org"
150 | source: hosted
151 | version: "0.12.11"
152 | meta:
153 | dependency: transitive
154 | description:
155 | name: meta
156 | url: "https://pub.dartlang.org"
157 | source: hosted
158 | version: "1.7.0"
159 | path:
160 | dependency: transitive
161 | description:
162 | name: path
163 | url: "https://pub.dartlang.org"
164 | source: hosted
165 | version: "1.8.0"
166 | plugin_platform_interface:
167 | dependency: transitive
168 | description:
169 | name: plugin_platform_interface
170 | url: "https://pub.dartlang.org"
171 | source: hosted
172 | version: "2.0.2"
173 | sky_engine:
174 | dependency: transitive
175 | description: flutter
176 | source: sdk
177 | version: "0.0.99"
178 | snippet_coder_utils:
179 | dependency: "direct main"
180 | description:
181 | name: snippet_coder_utils
182 | url: "https://pub.dartlang.org"
183 | source: hosted
184 | version: "1.0.9"
185 | source_span:
186 | dependency: transitive
187 | description:
188 | name: source_span
189 | url: "https://pub.dartlang.org"
190 | source: hosted
191 | version: "1.8.1"
192 | stack_trace:
193 | dependency: transitive
194 | description:
195 | name: stack_trace
196 | url: "https://pub.dartlang.org"
197 | source: hosted
198 | version: "1.10.0"
199 | stream_channel:
200 | dependency: transitive
201 | description:
202 | name: stream_channel
203 | url: "https://pub.dartlang.org"
204 | source: hosted
205 | version: "2.1.0"
206 | string_scanner:
207 | dependency: transitive
208 | description:
209 | name: string_scanner
210 | url: "https://pub.dartlang.org"
211 | source: hosted
212 | version: "1.1.0"
213 | term_glyph:
214 | dependency: transitive
215 | description:
216 | name: term_glyph
217 | url: "https://pub.dartlang.org"
218 | source: hosted
219 | version: "1.2.0"
220 | test_api:
221 | dependency: transitive
222 | description:
223 | name: test_api
224 | url: "https://pub.dartlang.org"
225 | source: hosted
226 | version: "0.4.3"
227 | typed_data:
228 | dependency: transitive
229 | description:
230 | name: typed_data
231 | url: "https://pub.dartlang.org"
232 | source: hosted
233 | version: "1.3.0"
234 | vector_math:
235 | dependency: transitive
236 | description:
237 | name: vector_math
238 | url: "https://pub.dartlang.org"
239 | source: hosted
240 | version: "2.1.1"
241 | sdks:
242 | dart: ">=2.14.0 <3.0.0"
243 | flutter: ">=2.5.0"
244 |
--------------------------------------------------------------------------------
/flutter/lib/pages/product_add_edit.dart:
--------------------------------------------------------------------------------
1 | import 'dart:io';
2 |
3 | import 'package:flutter/material.dart';
4 | import 'package:flutter_nodejs_crud_app/model/product_model.dart';
5 | import 'package:flutter_nodejs_crud_app/services/api_service.dart';
6 | import 'package:image_picker/image_picker.dart';
7 | import 'package:snippet_coder_utils/FormHelper.dart';
8 | import 'package:snippet_coder_utils/ProgressHUD.dart';
9 | import 'package:snippet_coder_utils/hex_color.dart';
10 |
11 | import '../config.dart';
12 |
13 | class ProductAddEdit extends StatefulWidget {
14 | const ProductAddEdit({Key? key}) : super(key: key);
15 |
16 | @override
17 | _ProductAddEditState createState() => _ProductAddEditState();
18 | }
19 |
20 | class _ProductAddEditState extends State {
21 | ProductModel? productModel;
22 | static final GlobalKey globalFormKey = GlobalKey();
23 | bool isApiCallProcess = false;
24 | List