diff --git a/.flutter-plugins b/.flutter-plugins
deleted file mode 100644
index 57b74a8..0000000
--- a/.flutter-plugins
+++ /dev/null
@@ -1,8 +0,0 @@
-# This is a generated file; do not edit or check into version control.
-connectivity_plus=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/
-connectivity_plus_linux=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
-connectivity_plus_macos=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
-connectivity_plus_web=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.3/
-connectivity_plus_windows=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
-flutter_inappwebview=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/
-fluttertoast=/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/fluttertoast-8.0.9/
diff --git a/.flutter-plugins-dependencies b/.flutter-plugins-dependencies
deleted file mode 100644
index 5afb255..0000000
--- a/.flutter-plugins-dependencies
+++ /dev/null
@@ -1 +0,0 @@
-{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/","native_build":true,"dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/","native_build":true,"dependencies":[]},{"name":"fluttertoast","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/fluttertoast-8.0.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.6+1/","native_build":true,"dependencies":[]},{"name":"flutter_inappwebview","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_inappwebview-5.4.3+7/","native_build":true,"dependencies":[]},{"name":"fluttertoast","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/fluttertoast-8.0.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.3/","dependencies":[]},{"name":"fluttertoast","path":"/Users/habeshageeks/flutter/.pub-cache/hosted/pub.dartlang.org/fluttertoast-8.0.9/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]},{"name":"flutter_inappwebview","dependencies":[]},{"name":"fluttertoast","dependencies":[]}],"date_created":"2023-05-22 08:43:34.602972","version":"3.3.6"}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 6528aa8..9b333b1 100644
--- a/.gitignore
+++ b/.gitignore
@@ -31,3 +31,5 @@ build/
.gradle
/example/ios/Podfile.lock
/coverage/
+.flutter-plugins
+.flutter-plugins-dependencies
diff --git a/README.md b/README.md
index d7e4473..63cc168 100644
--- a/README.md
+++ b/README.md
@@ -1,78 +1,171 @@
-
# Chapa Flutter SDK
-Chapa Flutter sdk for Chapa payment API. It is not official and is not supported by Chapa. It is provided as-is. The main features of this library is it supports connectivity tests, auto reroutes, parameter checks for payment options.
+The official **Chapa Flutter SDK** enables Flutter developers to integrate Chapa's Payment API seamlessly into their applications. It supports both native and web checkout, providing a robust and flexible solution for initiating and validating payments.
+---
+## **Features**
-## API Reference
+- š **Initiate Payment:** Easily facilitate transactions via four supported wallets telebirr,cbebirr,mpesa and ebirr.
+- ā
**Validate Payment Status:** Confirm payment completion and notify users instantly.
+- š **Web Checkout Support:** Enable users to use the web checkout for additional payment options.
-#### Create new transaction from mobile end point
+---
+## **Preview**
-Base end point
-https://api.chapa.co/v1
+
+
+
Payment Methods in Grid View
+

+
+
+
Payment Methods in List View with Customized Button Color
+

+
+
+
Error
+

+
+
+
Successful Payment Receipt
+

+
+
-```http
- POST /transaction/mobile-initialize
-```
-| Parameter | Type | Description |
-| :-------- | :------- | :------------------------- |
-| `key` | `string` | **Required**. This will be your public key from Chapa. When on test mode use the test key, and when on live mode use the live key. |
-| `email` | `string` | A customerās email address. |
-| `amount` | `string` | **Required**. The amount you will be charging your customer. |
-| `first_name` | `string` | A customerās first name. |
-| `last_name` | `string` | A customer's last name. |
-| `tx_ref` | `string` | **Required**. A unique reference given to each transaction. |
-| `currency` | `string` | **Required**. The currency in which all the charges are made. i.e ETB, USD |
-| `phone` | `digit` | A customerās phone number. |
-| `callback_url`| `string` | The URL to redirect the customer to after payment is done.|
-| `customization[title]`| `string` | The customizations field (optional) allows you to customize the look and feel of the payment modal.|
-#### SDK requires additional parameter for fallBack page which is named route which will help you reroute webview after payment completed, on internet disconnected and many more
+## **Getting Started**
+### **Installation**
+Add the following dependency to your `pubspec.yaml` file:
-| Parameter | Type | Description |
-| :-------- | :------- | :-------------------------------- |
-| `namedRouteFallBack` | `string` | **Required by the sdk**. This will accepted route name in String, After successful transaction the app will direct to this page with necessary information for flutter developers to update the backend or to regenerate new transaction reference. |
+```yaml
+dependencies:
+ chapasdk: ^latest_version
+```
+Then, run the command:
+```bash
+flutter pub get
+```
+---
+
+## **Parameters**
+
+| Parameter | Type | Required | Description |
+|----------------------------|-------------------|-----------|---------------------------------------------------------------------------------------------------------------|
+| `context` | `BuildContext` | **Yes** | Context of the current widget. |
+| `publicKey` | `String` | **Yes** | Your Chapa public key (use test key for testing and live key for production). |
+| `currency` | `String` | **Yes** | Transaction currency (ETB for native checkout, ETB or USD for web checkout NB=> You can not use USD for Naive checkout is it is only available for Web checkout.). |
+| `amount` | `String` | **Yes** | The amount to be charged. |
+| `email` | `String` | **Yes** | Customerās email address. |
+| `phone` | `String` | **Yes** | Customerās phone number. |
+| `firstName` | `String` | **Yes** | Customerās first name. |
+| `lastName` | `String` | **Yes** | Customerās last name. |
+| `txRef` | `String` | **Yes** | Unique reference for the transaction. |
+| `title` | `String` | **Yes** | Title of the payment modal. |
+| `desc` | `String` | **Yes** | Description of the payment. |
+| `namedRouteFallBack` | `String` | **Yes** | Named route to redirect users to after payment events (success, failure, or cancellation). |
+| `nativeCheckout` | `bool` | No | Whether to use native checkout (`true`) or web checkout (`false`). Default is `true`. |
+| `showPaymentMethodsOnGridView` | `bool` | No | Display payment methods in grid (`true`) or horizontal view (`false`). Default is `true`. |
+| `availablePaymentMethods` | `List` | No | List of allowed payment methods (`mpesa`, `cbebirr`, `telebirr`, `ebirr`). Defaults to all methods. |
+| `buttonColor` | `Color` | No | Button color for native checkout. Defaults to the appās primary theme color. |
+
+---
+
+## **Usage**
+
+```dart
+import 'package:chapasdk/chapasdk.dart';
-## Installation
+Chapa.paymentParameters(
+ context: context,
+ publicKey: 'CHAPUBK-@@@@',
+ currency: 'ETB',
+ amount: '1',
+ email: 'fetanchapa.co',
+ phone: '0911223344',
+ firstName: 'Israel',
+ lastName: 'Goytom',
+ txRef: 'txn_12345',
+ title: 'Order Payment',
+ desc: 'Payment for order #12345',
+ nativeCheckout: true,
+ namedRouteFallBack: '/',
+ showPaymentMethodsOnGridView: true,
+ availablePaymentMethods: ['mpesa', 'cbebirr', 'telebirr', 'ebirr'],
+);
+```
-Installation instructions coming soon its better if you install it from pub dev
+---
+## **Payment Responses from**
+### For Native Checkout:
-## Usage/Example
+Transaction Reference Number in Native Checkout context is Chapa's Reference number for the Payment.
+```json
+{
+ "message": "Any Descriptive message regarding the payment status",
+ "transactionReference": "CHHhvtn7xLEkZ",
+ "paidAmount": "1.00"
+}
+```
-```flutter
-import 'package:chapasdk/chapasdk.dart';
+### For Web Checkout:
+Transaction Reference Number in Web Checkout context is The transaction reference number you generated for the payment.
-Chapa.paymentParameters(
- context: context, // context
- publicKey: 'CHASECK_TEST--------------',
- currency: 'ETB',
- amount: '200',
- email: 'xyz@gmail.com',
- phone: '911223344',
- firstName: 'fullName',
- lastName: 'lastName',
- txRef: '34TXTHHgb',
- title: 'title',
- desc:'desc',
- namedRouteFallBack: '/second', // fall back route name
- );
+Important Note:
+If the web checkout is initiated from the native checkout page, the Transaction Reference for the web checkout will be generated by the app itself. This is because a single transaction reference cannot be used for both native and web checkout processes. Therefore, the app will generate a separate transaction reference for the web checkout.
+
+#### Payment Canceled:
+```json
+{
+ "message": "paymentCancelled",
+ "transactionReference": "txn_12345",
+ "paidAmount": "1.00"
+}
+```
+#### Payment Successful:
+```json
+{
+ "message": "paymentSuccessful",
+ "transactionReference": "txn_12345" ,
+ "paidAmount": "1.00"
+}
```
+#### Payment Failed:
+```json
+{
+ "message": "paymentFailed",
+ "transactionReference": "txn_12345",
+ "paidAmount": "0.00"
+}
+```
+
+---
+
+## **FAQ**
+### **1. Is the fallback route mandatory?**
+Yes, `namedRouteFallBack` is required to handle post-payment events such as success, failure, or cancellation.
-## FAQ
+### **2. What currencies are supported?**
+- Native Checkout: ONLY **ETB**
+- Web Checkout: **ETB**, **USD**
-#### Should my fallBack route should be named route?
+---
-Answer Yes, the fallBackRoute comes with an information such as payment is successful, user cancelled payment and connectivity issue messages. Those information will help you to update your backend, to generate new transaction reference.
+## **Support**
+For any questions or issues:
+- **Email:** [info@chapa.co](mailto:infot@chapa.co)
+- **Call Center:** [+251960724272](tel:+251960724272)
+- **Short Code:** [8911](tel:8911)
+- **Documentation:** [Chapa Developer Docs](https://developer.chapa.co/)
+Start building seamless payment experiences today with the **Chapa Flutter SDK**! š
diff --git a/assets/images/cbebirr.png b/assets/images/cbebirr.png
new file mode 100644
index 0000000..a25c528
Binary files /dev/null and b/assets/images/cbebirr.png differ
diff --git a/assets/images/chapa-logo.png b/assets/images/chapa-logo.png
new file mode 100644
index 0000000..533ee24
Binary files /dev/null and b/assets/images/chapa-logo.png differ
diff --git a/assets/images/ebirr.png b/assets/images/ebirr.png
new file mode 100644
index 0000000..ceaa5de
Binary files /dev/null and b/assets/images/ebirr.png differ
diff --git a/assets/images/ethiopia-flag.png b/assets/images/ethiopia-flag.png
new file mode 100644
index 0000000..d6d6e07
Binary files /dev/null and b/assets/images/ethiopia-flag.png differ
diff --git a/assets/images/mpesa.png b/assets/images/mpesa.png
new file mode 100644
index 0000000..d6a9221
Binary files /dev/null and b/assets/images/mpesa.png differ
diff --git a/assets/images/success-icon.png b/assets/images/success-icon.png
new file mode 100644
index 0000000..1d36615
Binary files /dev/null and b/assets/images/success-icon.png differ
diff --git a/assets/images/telebirr.png b/assets/images/telebirr.png
new file mode 100644
index 0000000..183110b
Binary files /dev/null and b/assets/images/telebirr.png differ
diff --git a/doc/error.png b/doc/error.png
new file mode 100644
index 0000000..c79f829
Binary files /dev/null and b/doc/error.png differ
diff --git a/doc/gridview.png b/doc/gridview.png
new file mode 100644
index 0000000..1678263
Binary files /dev/null and b/doc/gridview.png differ
diff --git a/doc/listview.png b/doc/listview.png
new file mode 100644
index 0000000..fd36ef3
Binary files /dev/null and b/doc/listview.png differ
diff --git a/doc/success.png b/doc/success.png
new file mode 100644
index 0000000..db9ac79
Binary files /dev/null and b/doc/success.png differ
diff --git a/example/.metadata b/example/.metadata
index 5a02328..732ba6d 100644
--- a/example/.metadata
+++ b/example/.metadata
@@ -1,10 +1,30 @@
# This file tracks properties of this Flutter project.
# Used by Flutter tool to assess capabilities and perform upgrades etc.
#
-# This file should be version controlled and should not be manually edited.
+# This file should be version controlled.
version:
- revision: 7e9793dee1b85a243edd0e06cb1658e98b077561
+ revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
channel: stable
project_type: app
+
+# Tracks metadata for the flutter migrate command
+migration:
+ platforms:
+ - platform: root
+ create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
+ base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
+ - platform: android
+ create_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
+ base_revision: f468f3366c26a5092eb964a230ce7892fda8f2f8
+
+ # User provided section
+
+ # List of Local paths (relative to this file) that should be
+ # ignored by the migrate tool.
+ #
+ # Files that are not part of the templates will be ignored by default.
+ unmanaged_files:
+ - 'lib/main.dart'
+ - 'ios/Runner.xcodeproj/project.pbxproj'
diff --git a/example/android/build.gradle b/example/android/build.gradle
index 4256f91..4d649ab 100644
--- a/example/android/build.gradle
+++ b/example/android/build.gradle
@@ -6,7 +6,7 @@ buildscript {
}
dependencies {
- classpath 'com.android.tools.build:gradle:4.1.0'
+ classpath 'com.android.tools.build:gradle:8.4.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
@@ -26,6 +26,6 @@ subprojects {
project.evaluationDependsOn(':app')
}
-task clean(type: Delete) {
+tasks.register("clean", Delete) {
delete rootProject.buildDir
}
diff --git a/example/android/gradle/wrapper/gradle-wrapper.properties b/example/android/gradle/wrapper/gradle-wrapper.properties
index bc6a58a..1f45544 100644
--- a/example/android/gradle/wrapper/gradle-wrapper.properties
+++ b/example/android/gradle/wrapper/gradle-wrapper.properties
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.7-all.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.8.0-all.zip
diff --git a/example/ios/Flutter/AppFrameworkInfo.plist b/example/ios/Flutter/AppFrameworkInfo.plist
index 8d4492f..7c56964 100644
--- a/example/ios/Flutter/AppFrameworkInfo.plist
+++ b/example/ios/Flutter/AppFrameworkInfo.plist
@@ -21,6 +21,6 @@
CFBundleVersion
1.0
MinimumOSVersion
- 9.0
+ 12.0
diff --git a/example/ios/Podfile b/example/ios/Podfile
index 1e8c3c9..2c068c4 100644
--- a/example/ios/Podfile
+++ b/example/ios/Podfile
@@ -1,5 +1,5 @@
# Uncomment this line to define a global platform for your project
-# platform :ios, '9.0'
+platform :ios, '12.0'
# CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'
diff --git a/example/ios/Runner.xcodeproj/project.pbxproj b/example/ios/Runner.xcodeproj/project.pbxproj
index 7cdf2aa..99b6483 100644
--- a/example/ios/Runner.xcodeproj/project.pbxproj
+++ b/example/ios/Runner.xcodeproj/project.pbxproj
@@ -3,12 +3,13 @@
archiveVersion = 1;
classes = {
};
- objectVersion = 50;
+ objectVersion = 54;
objects = {
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
+ 6ABE65F751942FCF67014A78 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 367D95931BDBBD94D4483798 /* Pods_Runner.framework */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
@@ -31,10 +32,14 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = ""; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = ""; };
+ 367D95931BDBBD94D4483798 /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = ""; };
+ 7259F65F242427A551ABCB1C /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = ""; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = ""; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = ""; };
+ 7E289552D56EF4AE86813DEA /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; };
+ 826D7A2CF170DE860AAB9389 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = ""; };
9740EEB21CF90195004384FC /* Debug.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Debug.xcconfig; path = Flutter/Debug.xcconfig; sourceTree = ""; };
9740EEB31CF90195004384FC /* Generated.xcconfig */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xcconfig; name = Generated.xcconfig; path = Flutter/Generated.xcconfig; sourceTree = ""; };
97C146EE1CF9000F007C117D /* Runner.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = Runner.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -49,12 +54,24 @@
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
+ 6ABE65F751942FCF67014A78 /* Pods_Runner.framework in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXFrameworksBuildPhase section */
/* Begin PBXGroup section */
+ 937E302E8D077A6705BB5022 /* Pods */ = {
+ isa = PBXGroup;
+ children = (
+ 7E289552D56EF4AE86813DEA /* Pods-Runner.debug.xcconfig */,
+ 826D7A2CF170DE860AAB9389 /* Pods-Runner.release.xcconfig */,
+ 7259F65F242427A551ABCB1C /* Pods-Runner.profile.xcconfig */,
+ );
+ name = Pods;
+ path = Pods;
+ sourceTree = "";
+ };
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
@@ -72,6 +89,8 @@
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
+ 937E302E8D077A6705BB5022 /* Pods */,
+ C4C1FCD9E3CA04DF32FD7E6F /* Frameworks */,
);
sourceTree = "";
};
@@ -98,6 +117,14 @@
path = Runner;
sourceTree = "";
};
+ C4C1FCD9E3CA04DF32FD7E6F /* Frameworks */ = {
+ isa = PBXGroup;
+ children = (
+ 367D95931BDBBD94D4483798 /* Pods_Runner.framework */,
+ );
+ name = Frameworks;
+ sourceTree = "";
+ };
/* End PBXGroup section */
/* Begin PBXNativeTarget section */
@@ -105,12 +132,14 @@
isa = PBXNativeTarget;
buildConfigurationList = 97C147051CF9000F007C117D /* Build configuration list for PBXNativeTarget "Runner" */;
buildPhases = (
+ AC96978B6AAFA251E53C8BD8 /* [CP] Check Pods Manifest.lock */,
9740EEB61CF901F6004384FC /* Run Script */,
97C146EA1CF9000F007C117D /* Sources */,
97C146EB1CF9000F007C117D /* Frameworks */,
97C146EC1CF9000F007C117D /* Resources */,
9705A1C41CF9048500538489 /* Embed Frameworks */,
3B06AD1E1E4923F5004D2608 /* Thin Binary */,
+ CBB6A21FE89A520C71A60ED6 /* [CP] Embed Pods Frameworks */,
);
buildRules = (
);
@@ -127,7 +156,7 @@
97C146E61CF9000F007C117D /* Project object */ = {
isa = PBXProject;
attributes = {
- LastUpgradeCheck = 1300;
+ LastUpgradeCheck = 1510;
ORGANIZATIONNAME = "";
TargetAttributes = {
97C146ED1CF9000F007C117D = {
@@ -171,10 +200,12 @@
/* Begin PBXShellScriptBuildPhase section */
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
+ "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}",
);
name = "Thin Binary";
outputPaths = (
@@ -185,6 +216,7 @@
};
9740EEB61CF901F6004384FC /* Run Script */ = {
isa = PBXShellScriptBuildPhase;
+ alwaysOutOfDate = 1;
buildActionMask = 2147483647;
files = (
);
@@ -197,6 +229,45 @@
shellPath = /bin/sh;
shellScript = "/bin/sh \"$FLUTTER_ROOT/packages/flutter_tools/bin/xcode_backend.sh\" build";
};
+ AC96978B6AAFA251E53C8BD8 /* [CP] Check Pods Manifest.lock */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ );
+ inputPaths = (
+ "${PODS_PODFILE_DIR_PATH}/Podfile.lock",
+ "${PODS_ROOT}/Manifest.lock",
+ );
+ name = "[CP] Check Pods Manifest.lock";
+ outputFileListPaths = (
+ );
+ outputPaths = (
+ "$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
+ showEnvVarsInLog = 0;
+ };
+ CBB6A21FE89A520C71A60ED6 /* [CP] Embed Pods Frameworks */ = {
+ isa = PBXShellScriptBuildPhase;
+ buildActionMask = 2147483647;
+ files = (
+ );
+ inputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-input-files.xcfilelist",
+ );
+ name = "[CP] Embed Pods Frameworks";
+ outputFileListPaths = (
+ "${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks-${CONFIGURATION}-output-files.xcfilelist",
+ );
+ runOnlyForDeploymentPostprocessing = 0;
+ shellPath = /bin/sh;
+ shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
+ showEnvVarsInLog = 0;
+ };
/* End PBXShellScriptBuildPhase section */
/* Begin PBXSourcesBuildPhase section */
@@ -272,7 +343,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
@@ -350,7 +421,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
@@ -399,7 +470,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
- IPHONEOS_DEPLOYMENT_TARGET = 9.0;
+ IPHONEOS_DEPLOYMENT_TARGET = 12.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SUPPORTED_PLATFORMS = iphoneos;
diff --git a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
index c87d15a..5e31d3d 100644
--- a/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
+++ b/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
@@ -1,6 +1,6 @@
+
+
diff --git a/example/ios/Runner/AppDelegate.swift b/example/ios/Runner/AppDelegate.swift
index 70693e4..b636303 100644
--- a/example/ios/Runner/AppDelegate.swift
+++ b/example/ios/Runner/AppDelegate.swift
@@ -1,7 +1,7 @@
import UIKit
import Flutter
-@UIApplicationMain
+@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(
_ application: UIApplication,
diff --git a/example/ios/Runner/Info.plist b/example/ios/Runner/Info.plist
index b369190..b218a27 100644
--- a/example/ios/Runner/Info.plist
+++ b/example/ios/Runner/Info.plist
@@ -43,5 +43,9 @@
UIViewControllerBasedStatusBarAppearance
+ CADisableMinimumFrameDurationOnPhone
+
+ UIApplicationSupportsIndirectInputEvents
+
diff --git a/example/lib/database/db_helper.dart b/example/lib/database/db_helper.dart
index 15bcd9a..581a115 100644
--- a/example/lib/database/db_helper.dart
+++ b/example/lib/database/db_helper.dart
@@ -1,60 +1,132 @@
+import 'dart:developer';
+import 'dart:io' as io;
+import 'package:shopping_cart_app/model/cart_model.dart';
import 'package:sqflite/sqflite.dart';
import 'package:path_provider/path_provider.dart';
import 'package:path/path.dart';
-import 'dart:io' as io;
-import 'package:shopping_cart_app/model/cart_model.dart';
class DBHelper {
static Database? _database;
- Future get database async {
+ Future get database async {
if (_database != null) {
return _database!;
}
_database = await initDatabase();
- return null;
+ return _database!;
}
- initDatabase() async {
+ Future initDatabase() async {
io.Directory directory = await getApplicationDocumentsDirectory();
String path = join(directory.path, 'cart.db');
- var db = await openDatabase(path, version: 1, onCreate: _onCreate);
- return db;
+ return await openDatabase(
+ path,
+ version: 2,
+ onCreate: _onCreate,
+ );
}
- _onCreate(Database db, int version) async {
+ Future _onCreate(Database db, int version) async {
await db.execute(
- 'CREATE TABLE cart(id INTEGER PRIMARY KEY, productId VARCHAR UNIQUE, productName TEXT, initialPrice INTEGER, productPrice INTEGER, quantity INTEGER, unitTag TEXT, image TEXT)');
+ 'CREATE TABLE cart('
+ 'id INTEGER PRIMARY KEY AUTOINCREMENT, '
+ 'productId VARCHAR UNIQUE, '
+ 'productName TEXT, '
+ 'initialPrice INTEGER, '
+ 'productPrice INTEGER, '
+ 'quantity INTEGER, '
+ 'unitTag TEXT, '
+ 'image TEXT)',
+ );
}
Future insert(Cart cart) async {
- var dbClient = await database;
- await dbClient!.insert('cart', cart.toMap());
+ final dbClient = await database;
+ try {
+ await dbClient.insert(
+ 'cart',
+ cart.toMap(),
+ conflictAlgorithm: ConflictAlgorithm.ignore,
+ );
+ } catch (e) {
+ log('Error inserting cart: $e');
+ }
+ return cart;
+ }
+
+ Future addToCart(Cart cart) async {
+ final dbClient = await database;
+ try {
+ List