├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── config.yml └── workflows │ ├── change-review.yml │ ├── package-publish.yml │ └── security-scan.yml ├── .gitignore ├── .metadata ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── example ├── .gitignore ├── .metadata ├── README.md ├── analysis_options.yaml ├── android │ ├── .gitignore │ ├── app │ │ ├── build.gradle.kts │ │ └── src │ │ │ ├── debug │ │ │ └── AndroidManifest.xml │ │ │ ├── main │ │ │ ├── AndroidManifest.xml │ │ │ ├── kotlin │ │ │ │ └── com │ │ │ │ │ └── example │ │ │ │ │ └── example │ │ │ │ │ └── MainActivity.kt │ │ │ └── res │ │ │ │ ├── drawable-v21 │ │ │ │ └── launch_background.xml │ │ │ │ ├── drawable │ │ │ │ └── launch_background.xml │ │ │ │ ├── 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 │ │ │ │ ├── values-night │ │ │ │ └── styles.xml │ │ │ │ └── values │ │ │ │ └── styles.xml │ │ │ └── profile │ │ │ └── AndroidManifest.xml │ ├── build.gradle.kts │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ └── settings.gradle.kts ├── ios │ ├── .gitignore │ ├── Flutter │ │ ├── AppFrameworkInfo.plist │ │ ├── Debug.xcconfig │ │ └── Release.xcconfig │ ├── Podfile │ ├── Podfile.lock │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ │ └── WorkspaceSettings.xcsettings │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── IDEWorkspaceChecks.plist │ │ │ └── WorkspaceSettings.xcsettings │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ ├── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── 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-83.5x83.5@2x.png │ │ │ └── LaunchImage.imageset │ │ │ │ ├── Contents.json │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ └── README.md │ │ ├── Base.lproj │ │ │ ├── LaunchScreen.storyboard │ │ │ └── Main.storyboard │ │ ├── Info.plist │ │ └── Runner-Bridging-Header.h │ └── RunnerTests │ │ └── RunnerTests.swift ├── lib │ └── main.dart ├── linux │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ │ ├── CMakeLists.txt │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ └── generated_plugins.cmake │ └── runner │ │ ├── CMakeLists.txt │ │ ├── main.cc │ │ ├── my_application.cc │ │ └── my_application.h ├── macos │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Podfile │ ├── Runner.xcodeproj │ │ ├── project.pbxproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner │ │ ├── AppDelegate.swift │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Contents.json │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── app_icon_64.png │ │ ├── Base.lproj │ │ │ └── MainMenu.xib │ │ ├── Configs │ │ │ ├── AppInfo.xcconfig │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ └── Warnings.xcconfig │ │ ├── DebugProfile.entitlements │ │ ├── Info.plist │ │ ├── MainFlutterWindow.swift │ │ └── Release.entitlements │ └── RunnerTests │ │ └── RunnerTests.swift ├── pubspec.lock ├── pubspec.yaml ├── test │ └── widget_test.dart ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── index.html │ └── manifest.json └── windows │ ├── .gitignore │ ├── CMakeLists.txt │ ├── flutter │ ├── CMakeLists.txt │ ├── generated_plugin_registrant.cc │ ├── generated_plugin_registrant.h │ └── generated_plugins.cmake │ └── runner │ ├── CMakeLists.txt │ ├── Runner.rc │ ├── flutter_window.cpp │ ├── flutter_window.h │ ├── main.cpp │ ├── resource.h │ ├── resources │ └── app_icon.ico │ ├── runner.exe.manifest │ ├── utils.cpp │ ├── utils.h │ ├── win32_window.cpp │ └── win32_window.h ├── lib ├── core │ ├── TransactionCallBack.dart │ ├── flutterwave.dart │ └── transaction_status.dart ├── flutterwave.dart ├── models │ ├── TransactionError.dart │ ├── requests │ │ ├── customer.dart │ │ ├── customizations.dart │ │ └── standard_request.dart │ ├── responses │ │ ├── charge_response.dart │ │ └── standard_response.dart │ └── subaccount.dart ├── utils.dart └── view │ ├── flutterwave_in_app_browser.dart │ ├── flutterwave_style.dart │ ├── standard_webview.dart │ ├── standard_widget.dart │ └── view_utils.dart ├── pubspec.lock ├── pubspec.yaml └── test └── customer_test.dart /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: bug 6 | assignees: '' 7 | 8 | --- 9 | 10 | Have you read our [Code of Conduct](https://github.com/Flutterwave/Flutter/blob/master/CONTRIBUTING.md)? By filing an Issue, you are expected to comply with it, including treating everyone with respect 11 | 12 | Do you want to ask a question? Are you looking for support? The developer slack is the best place for getting [support](https://bit.ly/34Vkzcg) 13 | 14 | ### Description 15 | 16 | 17 | 18 | ### Steps to Reproduce 19 | 20 | 1. 21 | 2. 22 | 3. 23 | 24 | **Expected behaviour:** 25 | 26 | 27 | 28 | **Actual behaviour:** 29 | 30 | 31 | 32 | **Reproduces how often:** 33 | 34 | 35 | 36 | ### Configuration 37 | 38 | - API Version: 39 | - Environment: 40 | - Browser: 41 | - Language: 42 | 43 | ### Additional Information 44 | 45 | 46 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: false 2 | contact_links: 3 | - name: Developer Support Forum 4 | url: https://forum.flutterwave.com 5 | about: If you're having general trouble with your integration, Kindly contact our support team. 6 | -------------------------------------------------------------------------------- /.github/workflows/change-review.yml: -------------------------------------------------------------------------------- 1 | name: Review changes on Dev (Commits/PRs) 2 | 3 | on: 4 | push: 5 | branches: ["dev"] 6 | pull_request: 7 | types: 8 | - opened 9 | 10 | jobs: 11 | version: 12 | name: code-check 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: checkout code 16 | uses: actions/checkout@v2 17 | 18 | - name: setup flutter environment 19 | uses: subosito/flutter-action@v2 20 | with: 21 | flutter-version: "3.29.2" 22 | 23 | - name: install flutter dependencies 24 | run: flutter pub get 25 | 26 | - name: run coverage tests 27 | run: flutter test --coverage 28 | 29 | - name: push build status to slack 30 | uses: 8398a7/action-slack@v3 31 | with: 32 | status: ${{ job.status }} 33 | fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest 34 | env: 35 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 36 | MATRIX_CONTEXT: ${{ toJson(matrix) }} 37 | if: always() 38 | -------------------------------------------------------------------------------- /.github/workflows/package-publish.yml: -------------------------------------------------------------------------------- 1 | name: Publish changes to Pub.dev 2 | 3 | on: 4 | release: 5 | types: [created] 6 | 7 | permissions: 8 | id-token: write 9 | contents: read 10 | 11 | jobs: 12 | check-readme-and-changelog: 13 | runs-on: ubuntu-latest 14 | steps: 15 | - name: checkout code 16 | uses: actions/checkout@v2 17 | 18 | - name: check for changes in readme and changelog files 19 | run: | 20 | if ! git diff --quiet HEAD~ HEAD -- README.md CHANGELOG.md; then 21 | echo "README and/or CHANGELOG have been modified. Proceeding with deployment." 22 | else 23 | echo "README and/or CHANGELOG have not been modified. Terminating deployment." 24 | exit 1 25 | fi 26 | 27 | - name: push build status to slack 28 | uses: 8398a7/action-slack@v3 29 | with: 30 | status: ${{ job.status }} 31 | fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest 32 | env: 33 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 34 | MATRIX_CONTEXT: ${{ toJson(matrix) }} 35 | if: always() 36 | 37 | publish: 38 | needs: check-readme-and-changelog 39 | runs-on: ubuntu-latest 40 | steps: 41 | - name: checkout code 42 | uses: actions/checkout@v2 43 | 44 | - name: setup flutter environment 45 | uses: subosito/flutter-action@v2 46 | with: 47 | flutter-version: "3.29.2" 48 | 49 | - name: install flutter dependencies 50 | run: flutter pub get 51 | 52 | - name: Publish to Pub.dev 53 | run: flutter pub publish --dry-run 54 | 55 | - name: push build status to Slack 56 | uses: 8398a7/action-slack@v3 57 | with: 58 | status: ${{ job.status }} 59 | fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest 60 | env: 61 | SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} 62 | MATRIX_CONTEXT: ${{ toJson(matrix) }} 63 | if: always() 64 | -------------------------------------------------------------------------------- /.github/workflows/security-scan.yml: -------------------------------------------------------------------------------- 1 | name: Security scan on all changes (Commits/PRs) 2 | on: 3 | push: 4 | branches: ["main", "master", "pilot", "dev"] 5 | pull_request: 6 | types: 7 | - opened 8 | jobs: 9 | code-check: 10 | runs-on: ubuntu-latest 11 | env: 12 | OS: ubuntu-latest 13 | steps: 14 | - name: Checkout code 15 | uses: actions/checkout@v2 16 | 17 | - name: Checkmarx One CLI Action 18 | uses: checkmarx/ast-github-action@main 19 | with: 20 | project_name: Flutter-v3 21 | cx_tenant: Flutterwave 22 | base_uri: https://eu.ast.checkmarx.net/ 23 | cx_client_id: ${{ secrets.CX_CLIENT_ID }} 24 | cx_client_secret: ${{ secrets.CX_CLIENT_SECRET }} 25 | additional_params: --scan-types sast,iac-security,api-security,sca,container-security 26 | -------------------------------------------------------------------------------- /.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 | 19 | # The .vscode folder contains launch configuration and tasks you configure in 20 | # VS Code which you may wish to be included in version control, so this line 21 | # is commented out by default. 22 | #.vscode/ 23 | 24 | # Flutter/Dart/Pub related 25 | **/doc/api/ 26 | .dart_tool/ 27 | .flutter-plugins 28 | .flutter-plugins-dependencies 29 | .packages 30 | .pub-cache/ 31 | .pub/ 32 | build/ 33 | coverage/ 34 | 35 | # Android related 36 | **/android/**/gradle-wrapper.jar 37 | **/android/.gradle 38 | **/android/captures/ 39 | **/android/gradlew 40 | **/android/gradlew.bat 41 | **/android/local.properties 42 | **/android/**/GeneratedPluginRegistrant.java 43 | 44 | # iOS/XCode related 45 | **/ios/**/*.mode1v3 46 | **/ios/**/*.mode2v3 47 | **/ios/**/*.moved-aside 48 | **/ios/**/*.pbxuser 49 | **/ios/**/*.perspectivev3 50 | **/ios/**/*sync/ 51 | **/ios/**/.sconsign.dblite 52 | **/ios/**/.tags* 53 | **/ios/**/.vagrant/ 54 | **/ios/**/DerivedData/ 55 | **/ios/**/Icon? 56 | **/ios/**/Pods/ 57 | **/ios/**/.symlinks/ 58 | **/ios/**/profile 59 | **/ios/**/xcuserdata 60 | **/ios/.generated/ 61 | **/ios/Flutter/App.framework 62 | **/ios/Flutter/Flutter.framework 63 | **/ios/Flutter/Flutter.podspec 64 | **/ios/Flutter/Generated.xcconfig 65 | **/ios/Flutter/app.flx 66 | **/ios/Flutter/app.zip 67 | **/ios/Flutter/flutter_assets/ 68 | **/ios/Flutter/flutter_export_environment.sh 69 | **/ios/ServiceDefinitions.json 70 | **/ios/Runner/GeneratedPluginRegistrant.* 71 | 72 | # Exceptions to above rules. 73 | !**/ios/**/default.mode1v3 74 | !**/ios/**/default.mode2v3 75 | !**/ios/**/default.pbxuser 76 | !**/ios/**/default.perspectivev3 77 | -------------------------------------------------------------------------------- /.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: c5a4b4029c0798f37c4a39b479d7cb75daa7b05c 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## [1.1.1] | April 24, 2025 2 | 3 | Changes include: 4 | 5 | - Added checkmarx security scan to the package build pipeline. 6 | 7 | ## [1.1.0] | April 11, 2025 8 | 9 | Changes include: 10 | 11 | - Modified `Flutterwave.charge()` method to accept a BuildContext parameter. 12 | - Added context.mounted checks to prevent setState calls after widget disposal. 13 | - Enhanced success status check logic to handle different status values ("success" and "completed"). 14 | - Improved error handling and state management. 15 | - Removed deprecated components: `flutterwave_style.dart` and `standard_webview.dart`. 16 | - Removed `flutterwave_style_test.dart`. 17 | - Updated the SDK requirements to `>=2.17.0`. 18 | - Upgraded dependencies to the latest versions. 19 | - Removed unused dependencies: webview_flutter, modal_bottom_sheet and uuid. 20 | - Update deployment workflow. 21 | 22 | ## [1.0.7] - February, 2023 23 | 24 | Changes include: 25 | 26 | - Fixed iOS bug where webview couldn't close when close buttons are clicked 27 | - Removed required `name` and `phone number` fields in `Customer` object 28 | 29 | ## [1.0.6] - October, 2022 30 | 31 | Changes include: 32 | 33 | - Fixed bug where transaction gets stuck after redirecting on webview 34 | - Fixed iOS build bug by removing inAppBrowser library 35 | 36 | ## [1.0.5] - October, 2022 37 | 38 | Changes include: 39 | 40 | - Fixed null when transaction is cancelled. 41 | - Removed modal pop up before launching web view. 42 | - Removed intermediate make payment screen before webview. 43 | - Deprecated FlutterwaveStyle. 44 | - Updated README file. 45 | 46 | ## [1.0.4] - July 4, 2022 47 | 48 | Changes include: 49 | 50 | - Renamed property `isDebug` to `isTestMode` 51 | - Made property `redirectUrl` required 52 | - Updated README file 53 | 54 | ## [1.0.3] - October 4, 2021. 55 | 56 | Changes include: 57 | 58 | - Fixed issue with webview 59 | 60 | ## [1.0.2] - September 23, 2021. 61 | 62 | Changes include: 63 | 64 | - Fixed bug where cancel payment buttons are not clickable on iOS devices. 65 | 66 | ## [1.0.1] - September 14, 2021. 67 | 68 | Changes include: 69 | 70 | - Fixed bug where response is not returned to initiating screen when user cancels transaction. 71 | 72 | ## [1.0.0] - September 9, 2021. 73 | 74 | Changes include: 75 | 76 | - Initial release 77 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Community contribution guide 2 | 3 | Thank you for taking the time to contribute to our library🙌🏾. 4 | 5 | In this section, we detail everything you need to know about contributing to this library. 6 | 7 | 8 | 9 | **[Code of Conduct](https://github.com/probot/template/blob/master/CODE_OF_CONDUCT.md)** 10 | 11 | ## **I don't want to contribute, I have a question** 12 | 13 | Please don't raise an issue to ask a question. You can ask questions on our [forum](http://forum.flutterwave.com) or developer [slack](https://bit.ly/34Vkzcg). We have an army of Engineers on hand to answer your questions there. 14 | 15 | ## How can I contribute? 16 | 17 | ### Reporting a bug 18 | 19 | Have you spotted a bug? Fantastic! Before raising an issue, here are some things to do: 20 | 21 | 1. Search to see if another user has reported the bug. For existing issues that are still open, add a comment instead of creating a new one. 22 | 2. Check our forum and developer slack to confirm that we did not address it there. 23 | 24 | When you report an issue, it is important to: 25 | 26 | 1. Explain the problem 27 | - Use a clear and descriptive title to help us to identify the problem. 28 | - Describe steps we can use to replicate the bug and be as precise as possible. 29 | - Include screenshots of the error messages. 30 | 2. Include details about your configuration and setup 31 | - What version of the library are you using? 32 | - Did you experience the bug on test mode or live? 33 | - Do you have the recommended versions of the library dependencies? 34 | 35 | 36 | > 💡 Please make use of the issue template when reporting bugs. 37 | 38 | 39 | ### Requesting a feature 40 | 41 | If you need an additional feature added to the library, kindly send us an email at developers@flutterwavego.com. Be sure to include the following in your request: 42 | 43 | 1. A clear title that helps us to identify the requested feature. 44 | 2. A brief description of the use case for that feature. 45 | 3. Explain how this feature would be helpful to your integration. 46 | 4. Library name and version. 47 | 48 | ### Submitting changes (PR) 49 | 50 | Generally, you can make any of the following changes to the library: 51 | 52 | 1. Bug fixes 53 | 2. Performance improvement 54 | 3. Documentation update 55 | 4. Functionality change (usually new features) 56 | 57 | > 💡 Changes that are cosmetic in nature and do not add anything substantial to the stability, functionality, or testability of the library will generally not be accepted. 58 | 59 | Follow these steps when making a pull request to the library: 60 | 61 | 1. Fork the repository and create your branch from master. 62 | 2. For all types of changes (excluding documentation updates), add tests for the changes. 63 | 3. If you are making a functionality change, update the docs to show how to use the new feature. 64 | 4. Ensure all your tests pass. 65 | 5. Make sure your code lints. 66 | 6. Write clear log messages for your commits. one-liners are fine for small changes, but bigger changes should have a more descriptive commit message (see sample below). 67 | 7. Use present tense for commit messages, "Add feature" not "Added feature”. 68 | 8. Ensure that you fill out all sections of the PR template. 69 | 9. Raise the PR against the `dev` branch. 70 | 10. After you submit the PR, verify that all [status checks](https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/collaborating-on-repositories-with-code-quality-features/about-status-checks) are passing 71 | 72 | ```markdown 73 | $ git commit -m "A brief summary of the commit 74 | > 75 | > A paragraph describing what changed and its impact." 76 | ``` 77 | 78 | > 💡 For your pull request to be reviewed, you need to meet the requirements above. We may ask you to complete additional tests, or other changes before your pull request can be ultimately accepted. 79 | 80 | We encourage you to contribute and help make the library better for the community. Got questions? send us a [message](https://bit.ly/34Vkzcg). 81 | 82 | Thank you. 83 | 84 | The Flutterwave team 🦋 85 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2021 Flutterwave 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

2 | 3 |

4 | 5 | # Flutterwave Flutter SDK (Standard) 6 | 7 | The Flutter library helps you create seamless payment experiences in your dart mobile app. By connecting to our modal, you can start collecting payment in no time. 8 | 9 | Available features include: 10 | 11 | - Collections: Card, Account, Mobile money, Bank Transfers, USSD. 12 | - Recurring payments: Tokenization and Subscriptions. 13 | - Split payments. 14 | 15 | ## Table of Contents 16 | 17 | 1. [Requirements](#requirements) 18 | 2. [Installation](#installation) 19 | 3. [Usage](#usage) 20 | 4. [Support](#support) 21 | 5. [Contribution guidelines](#contribution-guidelines) 22 | 6. [License](#license) 23 | 24 | ## Requirements 25 | 26 | 1. Flutterwave for business [API Keys](https://developer.flutterwave.com/docs/integration-guides/authentication) 27 | 2. Supported Flutter version >= 1.17.0 28 | 3. Dart SDK >= 2.17.0 29 | 4. For Android development, ensure the NDK version >= `27.0.12077973` on your project's `android/app/build.gradle.kts` file with android `{ ndkVersion = "27.0.12077973" }`. 30 | 31 | ## Installation 32 | 33 | 1. Add the dependency to your project. In your `pubspec.yaml` file add: `flutterwave_standard: 1.1.0` 34 | 2. Run `flutter pub get`. 35 | 36 | ## Usage 37 | 38 | ### Initializing a Flutterwave instance 39 | 40 | To create an instance, you should call the Flutterwave constructor. This constructor accepts a mandatory instance of the following: 41 | 42 | - `publicKey` 43 | - `Customer` 44 | - `amount` 45 | - `email` 46 | - `fullName` 47 | - `txRef` 48 | - `isTestMode` 49 | - `paymentOptions` 50 | - `redirectUrl` 51 | - `Customization` 52 | 53 | It returns an instance of Flutterwave which we then call the async method `.charge()` on. 54 | 55 | \_ 56 | 57 | handlePaymentInitialization() async { 58 | final Customer customer = Customer( 59 | name: "Flutterwave Developer", 60 | phoneNumber: "1234566677777", 61 | email: "customer@customer.com" 62 | ); 63 | final Flutterwave flutterwave = Flutterwave( 64 | publicKey: "Public Key-here", 65 | currency: "currency-here", 66 | redirectUrl: "add-your-redirect-url-here", 67 | txRef: "add-your-unique-reference-here", 68 | amount: "3000", 69 | customer: customer, 70 | paymentOptions: "ussd, card, bank transfer", 71 | customization: Customization(title: "My Payment"), 72 | isTestMode: true ); 73 | 74 | final ChargeResponse response = await flutterwave.charge(context); 75 | 76 | // Handle the response 77 | if (response.success == true) { 78 | // Payment was successful 79 | } else { 80 | // Payment failed or was cancelled 81 | } 82 | } 83 | 84 | ### Handling the response 85 | 86 | Calling the `.charge()` method returns a `Future` of `ChargeResponse` which we await for the actual response as seen above. 87 | 88 | final ChargeResponse response = await flutterwave.charge(context); 89 | 90 | Call the verify transaction [endpoint](https://developer.flutterwave.com/docs/transaction-verification) with the `transactionID` returned in `response.transactionId` or the `txRef` you provided to verify transaction before offering value to customer 91 | 92 | #### Note 93 | - `ChargeResponse` can be null, depending on if the user cancels the transaction by pressing back. 94 | - You need to confirm the transaction status is successful. Ensure that the txRef, amount, and status are correct and successful. Be sure to [verify the transaction details](https://developer.flutterwave.com/docs/transaction-verification) before providing value. 95 | - Some payment methods are not instant, such a `Pay with Bank Transfers, Pay with Bank`, and so you would need to rely on [webhooks](https://developer.flutterwave.com/docs/webhooks) or call the transaction verification service using the [`transactionId`](https://developer.flutterwave.com/reference/verify-transaction), or transaction reference you created(`txRef`) 96 | - For such long payments like the above, closing the payment page returns a `cancelled` status, so your final source of truth has to be calling the transaction verification service. 97 | 98 | 99 | ## Support 100 | For additional assistance using this library, contact the developer experience (DX) team via [email](mailto:developers@flutterwavego.com) or on [slack](https://bit.ly/34Vkzcg). 101 | 102 | You can also follow us [@FlutterwaveEng](https://twitter.com/FlutterwaveEng) and let us know what you think 😊. 103 | 104 | 105 | ## Contribution guidelines 106 | Read more about our community contribution guidelines [here](CONTRIBUTING.md). 107 | 108 | 109 | ## License 110 | By contributing to the Flutter library, you agree that your contributions will be licensed under its [MIT license](/LICENSE). 111 | 112 | Copyright (c) Flutterwave Inc. 113 | 114 | ## Built Using 115 | - [flutter](https://flutter.dev/) 116 | - [http](https://pub.dev/packages/http) 117 | - [flutter_inappwebview](https://pub.dev/packages/flutter_inappwebview) 118 | - [fluttertoast](https://pub.dev/packages/fluttertoast) 119 | 120 | 121 | 122 | ## Other Resources 123 | - [Flutterwave API Doc](https://developer.flutterwave.com) 124 | - [Flutterwave Inline Payment Doc](https://developer.flutterwave.com/docs/inline) 125 | - [Flutterwave Dashboard](https://dashboard.flutterwave.com/login) 126 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .build/ 9 | .buildlog/ 10 | .history 11 | .svn/ 12 | .swiftpm/ 13 | migrate_working_dir/ 14 | 15 | # IntelliJ related 16 | *.iml 17 | *.ipr 18 | *.iws 19 | .idea/ 20 | 21 | # The .vscode folder contains launch configuration and tasks you configure in 22 | # VS Code which you may wish to be included in version control, so this line 23 | # is commented out by default. 24 | #.vscode/ 25 | 26 | # Flutter/Dart/Pub related 27 | **/doc/api/ 28 | **/ios/Flutter/.last_build_id 29 | .dart_tool/ 30 | .flutter-plugins 31 | .flutter-plugins-dependencies 32 | .pub-cache/ 33 | .pub/ 34 | /build/ 35 | 36 | # Symbolication related 37 | app.*.symbols 38 | 39 | # Obfuscation related 40 | app.*.map.json 41 | 42 | # Android Studio will place build artifacts here 43 | /android/app/debug 44 | /android/app/profile 45 | /android/app/release 46 | -------------------------------------------------------------------------------- /example/.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: "c23637390482d4cf9598c3ce3f2be31aa7332daf" 8 | channel: "stable" 9 | 10 | project_type: app 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 17 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 18 | - platform: android 19 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 20 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 21 | - platform: ios 22 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 23 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 24 | - platform: linux 25 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 26 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 27 | - platform: macos 28 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 29 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 30 | - platform: web 31 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 32 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 33 | - platform: windows 34 | create_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 35 | base_revision: c23637390482d4cf9598c3ce3f2be31aa7332daf 36 | 37 | # User provided section 38 | 39 | # List of Local paths (relative to this file) that should be 40 | # ignored by the migrate tool. 41 | # 42 | # Files that are not part of the templates will be ignored by default. 43 | unmanaged_files: 44 | - 'lib/main.dart' 45 | - 'ios/Runner.xcodeproj/project.pbxproj' 46 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # example 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://docs.flutter.dev/get-started/codelab) 12 | - [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook) 13 | 14 | For help getting started with Flutter development, view the 15 | [online documentation](https://docs.flutter.dev/), which offers tutorials, 16 | samples, guidance on mobile development, and a full API reference. 17 | -------------------------------------------------------------------------------- /example/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 https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | .cxx/ 9 | 10 | # Remember to never publicly share your keystore. 11 | # See https://flutter.dev/to/reference-keystore 12 | key.properties 13 | **/*.keystore 14 | **/*.jks 15 | -------------------------------------------------------------------------------- /example/android/app/build.gradle.kts: -------------------------------------------------------------------------------- 1 | plugins { 2 | id("com.android.application") 3 | id("kotlin-android") 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id("dev.flutter.flutter-gradle-plugin") 6 | } 7 | 8 | android { 9 | namespace = "com.example.example" 10 | compileSdk = flutter.compileSdkVersion 11 | ndkVersion = "27.0.12077973" 12 | 13 | compileOptions { 14 | sourceCompatibility = JavaVersion.VERSION_11 15 | targetCompatibility = JavaVersion.VERSION_11 16 | } 17 | 18 | kotlinOptions { 19 | jvmTarget = JavaVersion.VERSION_11.toString() 20 | } 21 | 22 | defaultConfig { 23 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 24 | applicationId = "com.example.example" 25 | // You can update the following values to match your application needs. 26 | // For more information, see: https://flutter.dev/to/review-gradle-config. 27 | minSdk = flutter.minSdkVersion 28 | targetSdk = flutter.targetSdkVersion 29 | versionCode = flutter.versionCode 30 | versionName = flutter.versionName 31 | } 32 | 33 | buildTypes { 34 | release { 35 | // TODO: Add your own signing config for the release build. 36 | // Signing with the debug keys for now, so `flutter run --release` works. 37 | signingConfig = signingConfigs.getByName("debug") 38 | } 39 | } 40 | } 41 | 42 | flutter { 43 | source = "../.." 44 | } 45 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/android/app/src/main/kotlin/com/example/example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.example.example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity : FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/android/app/src/main/res/mipmap-mdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/build.gradle.kts: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | val newBuildDir: Directory = rootProject.layout.buildDirectory.dir("../../build").get() 9 | rootProject.layout.buildDirectory.value(newBuildDir) 10 | 11 | subprojects { 12 | val newSubprojectBuildDir: Directory = newBuildDir.dir(project.name) 13 | project.layout.buildDirectory.value(newSubprojectBuildDir) 14 | } 15 | subprojects { 16 | project.evaluationDependsOn(":app") 17 | } 18 | 19 | tasks.register("clean") { 20 | delete(rootProject.layout.buildDirectory) 21 | } 22 | -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx8G -XX:MaxMetaspaceSize=4G -XX:ReservedCodeCacheSize=512m -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | zipStoreBase=GRADLE_USER_HOME 4 | zipStorePath=wrapper/dists 5 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-all.zip 6 | -------------------------------------------------------------------------------- /example/android/settings.gradle.kts: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | val flutterSdkPath = run { 3 | val properties = java.util.Properties() 4 | file("local.properties").inputStream().use { properties.load(it) } 5 | val flutterSdkPath = properties.getProperty("flutter.sdk") 6 | require(flutterSdkPath != null) { "flutter.sdk not set in local.properties" } 7 | flutterSdkPath 8 | } 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id("dev.flutter.flutter-plugin-loader") version "1.0.0" 21 | id("com.android.application") version "8.7.0" apply false 22 | id("org.jetbrains.kotlin.android") version "1.8.22" apply false 23 | } 24 | 25 | include(":app") 26 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '12.0' 3 | 4 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 5 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 6 | 7 | project 'Runner', { 8 | 'Debug' => :debug, 9 | 'Profile' => :release, 10 | 'Release' => :release, 11 | } 12 | 13 | def flutter_root 14 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) 15 | unless File.exist?(generated_xcode_build_settings_path) 16 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" 17 | end 18 | 19 | File.foreach(generated_xcode_build_settings_path) do |line| 20 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 21 | return matches[1].strip if matches 22 | end 23 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" 24 | end 25 | 26 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 27 | 28 | flutter_ios_podfile_setup 29 | 30 | target 'Runner' do 31 | use_frameworks! 32 | 33 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 34 | target 'RunnerTests' do 35 | inherit! :search_paths 36 | end 37 | end 38 | 39 | post_install do |installer| 40 | installer.pods_project.targets.each do |target| 41 | flutter_additional_ios_build_settings(target) 42 | end 43 | end 44 | -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Flutter (1.0.0) 3 | - flutter_inappwebview_ios (0.0.1): 4 | - Flutter 5 | - flutter_inappwebview_ios/Core (= 0.0.1) 6 | - OrderedSet (~> 6.0.3) 7 | - flutter_inappwebview_ios/Core (0.0.1): 8 | - Flutter 9 | - OrderedSet (~> 6.0.3) 10 | - fluttertoast (0.0.2): 11 | - Flutter 12 | - OrderedSet (6.0.3) 13 | 14 | DEPENDENCIES: 15 | - Flutter (from `Flutter`) 16 | - flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`) 17 | - fluttertoast (from `.symlinks/plugins/fluttertoast/ios`) 18 | 19 | SPEC REPOS: 20 | trunk: 21 | - OrderedSet 22 | 23 | EXTERNAL SOURCES: 24 | Flutter: 25 | :path: Flutter 26 | flutter_inappwebview_ios: 27 | :path: ".symlinks/plugins/flutter_inappwebview_ios/ios" 28 | fluttertoast: 29 | :path: ".symlinks/plugins/fluttertoast/ios" 30 | 31 | SPEC CHECKSUMS: 32 | Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 33 | flutter_inappwebview_ios: b89ba3482b96fb25e00c967aae065701b66e9b99 34 | fluttertoast: 2c67e14dce98bbdb200df9e1acf610d7a6264ea1 35 | OrderedSet: e539b66b644ff081c73a262d24ad552a69be3a94 36 | 37 | PODFILE CHECKSUM: 4305caec6b40dde0ae97be1573c53de1882a07e5 38 | 39 | COCOAPODS: 1.16.2 40 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | 4 | @main 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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/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. -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Example 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterwave_standard/flutterwave.dart'; 3 | import 'package:uuid/uuid.dart'; 4 | 5 | void main() { 6 | runApp(MyApp()); 7 | } 8 | 9 | class MyApp extends StatelessWidget { 10 | const MyApp({super.key}); 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return MaterialApp( 15 | debugShowCheckedModeBanner: false, 16 | title: 'Flutter Standard Demo', 17 | home: const MyHomePage(), 18 | ); 19 | } 20 | } 21 | 22 | class MyHomePage extends StatefulWidget { 23 | const MyHomePage({super.key}); 24 | 25 | @override 26 | State createState() => _MyHomePageState(); 27 | } 28 | 29 | class _MyHomePageState extends State { 30 | final formKey = GlobalKey(); 31 | final amountController = TextEditingController(); 32 | final currencyController = TextEditingController(); 33 | final emailController = TextEditingController(); 34 | final phoneNumberController = TextEditingController(); 35 | 36 | String selectedCurrency = "NGN"; 37 | bool isLoading = false; 38 | bool isTestMode = true; 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | currencyController.text = selectedCurrency; 43 | 44 | return Scaffold( 45 | appBar: AppBar(title: Text('Flutterwave Payment Demo')), 46 | body: Container( 47 | width: double.infinity, 48 | margin: EdgeInsets.fromLTRB(20, 10, 20, 10), 49 | child: Form( 50 | key: formKey, 51 | child: ListView( 52 | children: [ 53 | Container( 54 | margin: EdgeInsets.fromLTRB(0, 20, 0, 10), 55 | child: TextFormField( 56 | controller: amountController, 57 | textInputAction: TextInputAction.next, 58 | keyboardType: TextInputType.number, 59 | style: TextStyle(color: Colors.black), 60 | decoration: InputDecoration(hintText: "Amount"), 61 | validator: (value) { 62 | if (value == null || value.isEmpty) { 63 | return 'Amount is required'; 64 | } 65 | return null; 66 | }, 67 | ), 68 | ), 69 | Container( 70 | margin: EdgeInsets.fromLTRB(0, 20, 0, 10), 71 | child: TextFormField( 72 | controller: currencyController, 73 | textInputAction: TextInputAction.next, 74 | style: TextStyle(color: Colors.black), 75 | readOnly: true, 76 | onTap: _openBottomSheet, 77 | decoration: InputDecoration(hintText: "Currency"), 78 | validator: (value) { 79 | if (value == null || value.isEmpty) { 80 | return 'Currency is required'; 81 | } 82 | return null; 83 | }, 84 | ), 85 | ), 86 | Container( 87 | margin: EdgeInsets.fromLTRB(0, 20, 0, 10), 88 | child: TextFormField( 89 | controller: emailController, 90 | textInputAction: TextInputAction.next, 91 | style: TextStyle(color: Colors.black), 92 | decoration: InputDecoration(hintText: "Email"), 93 | validator: (value) { 94 | if (value == null || value.isEmpty) { 95 | return 'Please enter an email'; 96 | } 97 | return null; 98 | }, 99 | ), 100 | ), 101 | Container( 102 | margin: EdgeInsets.fromLTRB(0, 20, 0, 10), 103 | child: TextFormField( 104 | controller: phoneNumberController, 105 | textInputAction: TextInputAction.next, 106 | style: TextStyle(color: Colors.black), 107 | decoration: InputDecoration( 108 | hintText: "Phone Number", 109 | ), 110 | ), 111 | ), 112 | Container( 113 | width: double.infinity, 114 | margin: EdgeInsets.fromLTRB(0, 20, 0, 10), 115 | child: Row( 116 | children: [ 117 | Text("Use Debug"), 118 | Switch( 119 | onChanged: 120 | (value) => { 121 | setState(() { 122 | isTestMode = value; 123 | }), 124 | }, 125 | value: isTestMode, 126 | ), 127 | ], 128 | ), 129 | ), 130 | Container( 131 | width: double.infinity, 132 | height: 50, 133 | margin: EdgeInsets.fromLTRB(0, 20, 0, 10), 134 | child: ElevatedButton( 135 | onPressed: isLoading ? null : makePayment, 136 | child: Text( 137 | "Make Payment", 138 | style: TextStyle(color: Colors.white), 139 | ), 140 | ), 141 | ), 142 | ], 143 | ), 144 | ), 145 | ), // This trailing comma makes auto-formatting nicer for build methods. 146 | ); 147 | } 148 | 149 | void makePayment() async { 150 | if (!formKey.currentState!.validate()) { 151 | return; 152 | } 153 | 154 | setState(() { 155 | isLoading = true; 156 | }); 157 | 158 | try { 159 | final Customer customer = Customer( 160 | email: emailController.text, 161 | phoneNumber: phoneNumberController.text, 162 | ); 163 | 164 | final Flutterwave flutterwave = Flutterwave( 165 | publicKey: "YOUR_PUBLIC_KEY", // Input your public key 166 | currency: selectedCurrency, 167 | amount: amountController.text.toString().trim(), 168 | customer: customer, 169 | txRef: Uuid().v4(), 170 | paymentOptions: "card, ussd, bank transfer", 171 | customization: Customization( 172 | title: "Payment for Product/Service", 173 | description: "Payment for items in cart", 174 | ), 175 | redirectUrl: "https://www.flutterwave.com", 176 | isTestMode: isTestMode, 177 | ); 178 | 179 | final ChargeResponse response = await flutterwave.charge( 180 | context, 181 | ); 182 | 183 | if (mounted) { 184 | if (response.success == true) { 185 | // Payment was successful 186 | showDialog( 187 | context: context, 188 | builder: (BuildContext context) { 189 | return AlertDialog( 190 | title: const Text('Payment Successful'), 191 | content: Text( 192 | 'Transaction Reference: ${response.txRef}', 193 | ), 194 | actions: [ 195 | TextButton( 196 | onPressed: () => Navigator.of(context).pop(), 197 | child: const Text('OK'), 198 | ), 199 | ], 200 | ); 201 | }, 202 | ); 203 | } else { 204 | // Payment failed 205 | showDialog( 206 | context: context, 207 | builder: (BuildContext context) { 208 | return AlertDialog( 209 | title: const Text('Payment Failed'), 210 | content: Text('Status: ${response.status}'), 211 | actions: [ 212 | TextButton( 213 | onPressed: () => Navigator.of(context).pop(), 214 | child: const Text('OK'), 215 | ), 216 | ], 217 | ); 218 | }, 219 | ); 220 | } 221 | } 222 | } catch (e) { 223 | if (mounted) { 224 | showDialog( 225 | context: context, 226 | builder: (BuildContext context) { 227 | return AlertDialog( 228 | title: const Text('Error'), 229 | content: Text(e.toString()), 230 | actions: [ 231 | TextButton( 232 | onPressed: () => Navigator.of(context).pop(), 233 | child: const Text('OK'), 234 | ), 235 | ], 236 | ); 237 | }, 238 | ); 239 | } 240 | } finally { 241 | if (mounted) { 242 | setState(() { 243 | isLoading = false; 244 | }); 245 | } 246 | } 247 | } 248 | 249 | void _openBottomSheet() { 250 | showModalBottomSheet( 251 | context: context, 252 | builder: (context) { 253 | return _getCurrency(); 254 | }, 255 | ); 256 | } 257 | 258 | Widget _getCurrency() { 259 | final currencies = [ 260 | "NGN", 261 | "RWF", 262 | "UGX", 263 | "KES", 264 | "ZAR", 265 | "USD", 266 | "GHS", 267 | "TZS", 268 | ]; 269 | return Container( 270 | height: 250, 271 | margin: EdgeInsets.fromLTRB(0, 10, 0, 0), 272 | color: Colors.white, 273 | child: ListView( 274 | children: 275 | currencies 276 | .map( 277 | (currency) => ListTile( 278 | onTap: () => {_handleCurrencyTap(currency)}, 279 | title: Column( 280 | children: [ 281 | Text( 282 | currency, 283 | textAlign: TextAlign.start, 284 | style: TextStyle(color: Colors.black), 285 | ), 286 | SizedBox(height: 4), 287 | Divider(height: 1), 288 | ], 289 | ), 290 | ), 291 | ) 292 | .toList(), 293 | ), 294 | ); 295 | } 296 | 297 | _handleCurrencyTap(String currency) { 298 | setState(() { 299 | selectedCurrency = currency; 300 | currencyController.text = currency; 301 | }); 302 | Navigator.pop(context); 303 | } 304 | 305 | @override 306 | void dispose() { 307 | amountController.dispose(); 308 | currencyController.dispose(); 309 | emailController.dispose(); 310 | phoneNumberController.dispose(); 311 | super.dispose(); 312 | } 313 | } 314 | -------------------------------------------------------------------------------- /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/linux/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.13) 3 | project(runner LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | # The unique GTK application identifier for this application. See: 9 | # https://wiki.gnome.org/HowDoI/ChooseApplicationID 10 | set(APPLICATION_ID "com.example.example") 11 | 12 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 13 | # versions of CMake. 14 | cmake_policy(SET CMP0063 NEW) 15 | 16 | # Load bundled libraries from the lib/ directory relative to the binary. 17 | set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") 18 | 19 | # Root filesystem for cross-building. 20 | if(FLUTTER_TARGET_PLATFORM_SYSROOT) 21 | set(CMAKE_SYSROOT ${FLUTTER_TARGET_PLATFORM_SYSROOT}) 22 | set(CMAKE_FIND_ROOT_PATH ${CMAKE_SYSROOT}) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 25 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 26 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 27 | endif() 28 | 29 | # Define build configuration options. 30 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 31 | set(CMAKE_BUILD_TYPE "Debug" CACHE 32 | STRING "Flutter build mode" FORCE) 33 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 34 | "Debug" "Profile" "Release") 35 | endif() 36 | 37 | # Compilation settings that should be applied to most targets. 38 | # 39 | # Be cautious about adding new options here, as plugins use this function by 40 | # default. In most cases, you should add new options to specific targets instead 41 | # of modifying this function. 42 | function(APPLY_STANDARD_SETTINGS TARGET) 43 | target_compile_features(${TARGET} PUBLIC cxx_std_14) 44 | target_compile_options(${TARGET} PRIVATE -Wall -Werror) 45 | target_compile_options(${TARGET} PRIVATE "$<$>:-O3>") 46 | target_compile_definitions(${TARGET} PRIVATE "$<$>:NDEBUG>") 47 | endfunction() 48 | 49 | # Flutter library and tool build rules. 50 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 51 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 52 | 53 | # System-level dependencies. 54 | find_package(PkgConfig REQUIRED) 55 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 56 | 57 | # Application build; see runner/CMakeLists.txt. 58 | add_subdirectory("runner") 59 | 60 | # Run the Flutter tool portions of the build. This must not be removed. 61 | add_dependencies(${BINARY_NAME} flutter_assemble) 62 | 63 | # Only the install-generated bundle's copy of the executable will launch 64 | # correctly, since the resources must in the right relative locations. To avoid 65 | # people trying to run the unbundled copy, put it in a subdirectory instead of 66 | # the default top-level location. 67 | set_target_properties(${BINARY_NAME} 68 | PROPERTIES 69 | RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/intermediates_do_not_run" 70 | ) 71 | 72 | 73 | # Generated plugin build rules, which manage building the plugins and adding 74 | # them to the application. 75 | include(flutter/generated_plugins.cmake) 76 | 77 | 78 | # === Installation === 79 | # By default, "installing" just makes a relocatable bundle in the build 80 | # directory. 81 | set(BUILD_BUNDLE_DIR "${PROJECT_BINARY_DIR}/bundle") 82 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 83 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 84 | endif() 85 | 86 | # Start with a clean build bundle directory every time. 87 | install(CODE " 88 | file(REMOVE_RECURSE \"${BUILD_BUNDLE_DIR}/\") 89 | " COMPONENT Runtime) 90 | 91 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 92 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib") 93 | 94 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 95 | COMPONENT Runtime) 96 | 97 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 98 | COMPONENT Runtime) 99 | 100 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 101 | COMPONENT Runtime) 102 | 103 | foreach(bundled_library ${PLUGIN_BUNDLED_LIBRARIES}) 104 | install(FILES "${bundled_library}" 105 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 106 | COMPONENT Runtime) 107 | endforeach(bundled_library) 108 | 109 | # Copy the native assets provided by the build.dart from all packages. 110 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/linux/") 111 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 112 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 113 | COMPONENT Runtime) 114 | 115 | # Fully re-copy the assets directory on each build to avoid having stale files 116 | # from a previous install. 117 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 118 | install(CODE " 119 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 120 | " COMPONENT Runtime) 121 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 122 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 123 | 124 | # Install the AOT library on non-Debug builds only. 125 | if(NOT CMAKE_BUILD_TYPE MATCHES "Debug") 126 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 127 | COMPONENT Runtime) 128 | endif() 129 | -------------------------------------------------------------------------------- /example/linux/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.10) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | 12 | # Serves the same purpose as list(TRANSFORM ... PREPEND ...), 13 | # which isn't available in 3.10. 14 | function(list_prepend LIST_NAME PREFIX) 15 | set(NEW_LIST "") 16 | foreach(element ${${LIST_NAME}}) 17 | list(APPEND NEW_LIST "${PREFIX}${element}") 18 | endforeach(element) 19 | set(${LIST_NAME} "${NEW_LIST}" PARENT_SCOPE) 20 | endfunction() 21 | 22 | # === Flutter Library === 23 | # System-level dependencies. 24 | find_package(PkgConfig REQUIRED) 25 | pkg_check_modules(GTK REQUIRED IMPORTED_TARGET gtk+-3.0) 26 | pkg_check_modules(GLIB REQUIRED IMPORTED_TARGET glib-2.0) 27 | pkg_check_modules(GIO REQUIRED IMPORTED_TARGET gio-2.0) 28 | 29 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/libflutter_linux_gtk.so") 30 | 31 | # Published to parent scope for install step. 32 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 33 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 34 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 35 | set(AOT_LIBRARY "${PROJECT_DIR}/build/lib/libapp.so" PARENT_SCOPE) 36 | 37 | list(APPEND FLUTTER_LIBRARY_HEADERS 38 | "fl_basic_message_channel.h" 39 | "fl_binary_codec.h" 40 | "fl_binary_messenger.h" 41 | "fl_dart_project.h" 42 | "fl_engine.h" 43 | "fl_json_message_codec.h" 44 | "fl_json_method_codec.h" 45 | "fl_message_codec.h" 46 | "fl_method_call.h" 47 | "fl_method_channel.h" 48 | "fl_method_codec.h" 49 | "fl_method_response.h" 50 | "fl_plugin_registrar.h" 51 | "fl_plugin_registry.h" 52 | "fl_standard_message_codec.h" 53 | "fl_standard_method_codec.h" 54 | "fl_string_codec.h" 55 | "fl_value.h" 56 | "fl_view.h" 57 | "flutter_linux.h" 58 | ) 59 | list_prepend(FLUTTER_LIBRARY_HEADERS "${EPHEMERAL_DIR}/flutter_linux/") 60 | add_library(flutter INTERFACE) 61 | target_include_directories(flutter INTERFACE 62 | "${EPHEMERAL_DIR}" 63 | ) 64 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}") 65 | target_link_libraries(flutter INTERFACE 66 | PkgConfig::GTK 67 | PkgConfig::GLIB 68 | PkgConfig::GIO 69 | ) 70 | add_dependencies(flutter flutter_assemble) 71 | 72 | # === Flutter tool backend === 73 | # _phony_ is a non-existent file to force this command to run every time, 74 | # since currently there's no way to get a full input/output list from the 75 | # flutter tool. 76 | add_custom_command( 77 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 78 | ${CMAKE_CURRENT_BINARY_DIR}/_phony_ 79 | COMMAND ${CMAKE_COMMAND} -E env 80 | ${FLUTTER_TOOL_ENVIRONMENT} 81 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.sh" 82 | ${FLUTTER_TARGET_PLATFORM} ${CMAKE_BUILD_TYPE} 83 | VERBATIM 84 | ) 85 | add_custom_target(flutter_assemble DEPENDS 86 | "${FLUTTER_LIBRARY}" 87 | ${FLUTTER_LIBRARY_HEADERS} 88 | ) 89 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void fl_register_plugins(FlPluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/linux/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.13) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} 10 | "main.cc" 11 | "my_application.cc" 12 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 13 | ) 14 | 15 | # Apply the standard set of build settings. This can be removed for applications 16 | # that need different build settings. 17 | apply_standard_settings(${BINARY_NAME}) 18 | 19 | # Add preprocessor definitions for the application ID. 20 | add_definitions(-DAPPLICATION_ID="${APPLICATION_ID}") 21 | 22 | # Add dependency libraries. Add any application-specific dependencies here. 23 | target_link_libraries(${BINARY_NAME} PRIVATE flutter) 24 | target_link_libraries(${BINARY_NAME} PRIVATE PkgConfig::GTK) 25 | 26 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 27 | -------------------------------------------------------------------------------- /example/linux/runner/main.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | int main(int argc, char** argv) { 4 | g_autoptr(MyApplication) app = my_application_new(); 5 | return g_application_run(G_APPLICATION(app), argc, argv); 6 | } 7 | -------------------------------------------------------------------------------- /example/linux/runner/my_application.cc: -------------------------------------------------------------------------------- 1 | #include "my_application.h" 2 | 3 | #include 4 | #ifdef GDK_WINDOWING_X11 5 | #include 6 | #endif 7 | 8 | #include "flutter/generated_plugin_registrant.h" 9 | 10 | struct _MyApplication { 11 | GtkApplication parent_instance; 12 | char** dart_entrypoint_arguments; 13 | }; 14 | 15 | G_DEFINE_TYPE(MyApplication, my_application, GTK_TYPE_APPLICATION) 16 | 17 | // Implements GApplication::activate. 18 | static void my_application_activate(GApplication* application) { 19 | MyApplication* self = MY_APPLICATION(application); 20 | GtkWindow* window = 21 | GTK_WINDOW(gtk_application_window_new(GTK_APPLICATION(application))); 22 | 23 | // Use a header bar when running in GNOME as this is the common style used 24 | // by applications and is the setup most users will be using (e.g. Ubuntu 25 | // desktop). 26 | // If running on X and not using GNOME then just use a traditional title bar 27 | // in case the window manager does more exotic layout, e.g. tiling. 28 | // If running on Wayland assume the header bar will work (may need changing 29 | // if future cases occur). 30 | gboolean use_header_bar = TRUE; 31 | #ifdef GDK_WINDOWING_X11 32 | GdkScreen* screen = gtk_window_get_screen(window); 33 | if (GDK_IS_X11_SCREEN(screen)) { 34 | const gchar* wm_name = gdk_x11_screen_get_window_manager_name(screen); 35 | if (g_strcmp0(wm_name, "GNOME Shell") != 0) { 36 | use_header_bar = FALSE; 37 | } 38 | } 39 | #endif 40 | if (use_header_bar) { 41 | GtkHeaderBar* header_bar = GTK_HEADER_BAR(gtk_header_bar_new()); 42 | gtk_widget_show(GTK_WIDGET(header_bar)); 43 | gtk_header_bar_set_title(header_bar, "example"); 44 | gtk_header_bar_set_show_close_button(header_bar, TRUE); 45 | gtk_window_set_titlebar(window, GTK_WIDGET(header_bar)); 46 | } else { 47 | gtk_window_set_title(window, "example"); 48 | } 49 | 50 | gtk_window_set_default_size(window, 1280, 720); 51 | gtk_widget_show(GTK_WIDGET(window)); 52 | 53 | g_autoptr(FlDartProject) project = fl_dart_project_new(); 54 | fl_dart_project_set_dart_entrypoint_arguments(project, self->dart_entrypoint_arguments); 55 | 56 | FlView* view = fl_view_new(project); 57 | gtk_widget_show(GTK_WIDGET(view)); 58 | gtk_container_add(GTK_CONTAINER(window), GTK_WIDGET(view)); 59 | 60 | fl_register_plugins(FL_PLUGIN_REGISTRY(view)); 61 | 62 | gtk_widget_grab_focus(GTK_WIDGET(view)); 63 | } 64 | 65 | // Implements GApplication::local_command_line. 66 | static gboolean my_application_local_command_line(GApplication* application, gchar*** arguments, int* exit_status) { 67 | MyApplication* self = MY_APPLICATION(application); 68 | // Strip out the first argument as it is the binary name. 69 | self->dart_entrypoint_arguments = g_strdupv(*arguments + 1); 70 | 71 | g_autoptr(GError) error = nullptr; 72 | if (!g_application_register(application, nullptr, &error)) { 73 | g_warning("Failed to register: %s", error->message); 74 | *exit_status = 1; 75 | return TRUE; 76 | } 77 | 78 | g_application_activate(application); 79 | *exit_status = 0; 80 | 81 | return TRUE; 82 | } 83 | 84 | // Implements GApplication::startup. 85 | static void my_application_startup(GApplication* application) { 86 | //MyApplication* self = MY_APPLICATION(object); 87 | 88 | // Perform any actions required at application startup. 89 | 90 | G_APPLICATION_CLASS(my_application_parent_class)->startup(application); 91 | } 92 | 93 | // Implements GApplication::shutdown. 94 | static void my_application_shutdown(GApplication* application) { 95 | //MyApplication* self = MY_APPLICATION(object); 96 | 97 | // Perform any actions required at application shutdown. 98 | 99 | G_APPLICATION_CLASS(my_application_parent_class)->shutdown(application); 100 | } 101 | 102 | // Implements GObject::dispose. 103 | static void my_application_dispose(GObject* object) { 104 | MyApplication* self = MY_APPLICATION(object); 105 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 106 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 107 | } 108 | 109 | static void my_application_class_init(MyApplicationClass* klass) { 110 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 111 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 112 | G_APPLICATION_CLASS(klass)->startup = my_application_startup; 113 | G_APPLICATION_CLASS(klass)->shutdown = my_application_shutdown; 114 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 115 | } 116 | 117 | static void my_application_init(MyApplication* self) {} 118 | 119 | MyApplication* my_application_new() { 120 | // Set the program name to the application ID, which helps various systems 121 | // like GTK and desktop environments map this running application to its 122 | // corresponding .desktop file. This ensures better integration by allowing 123 | // the application to be recognized beyond its binary name. 124 | g_set_prgname(APPLICATION_ID); 125 | 126 | return MY_APPLICATION(g_object_new(my_application_get_type(), 127 | "application-id", APPLICATION_ID, 128 | "flags", G_APPLICATION_NON_UNIQUE, 129 | nullptr)); 130 | } 131 | -------------------------------------------------------------------------------- /example/linux/runner/my_application.h: -------------------------------------------------------------------------------- 1 | #ifndef FLUTTER_MY_APPLICATION_H_ 2 | #define FLUTTER_MY_APPLICATION_H_ 3 | 4 | #include 5 | 6 | G_DECLARE_FINAL_TYPE(MyApplication, my_application, MY, APPLICATION, 7 | GtkApplication) 8 | 9 | /** 10 | * my_application_new: 11 | * 12 | * Creates a new Flutter-based application. 13 | * 14 | * Returns: a new #MyApplication. 15 | */ 16 | MyApplication* my_application_new(); 17 | 18 | #endif // FLUTTER_MY_APPLICATION_H_ 19 | -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" 2 | #include "ephemeral/Flutter-Generated.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import flutter_inappwebview_macos 9 | 10 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 11 | InAppWebViewFlutterPlugin.register(with: registry.registrar(forPlugin: "InAppWebViewFlutterPlugin")) 12 | } 13 | -------------------------------------------------------------------------------- /example/macos/Podfile: -------------------------------------------------------------------------------- 1 | platform :osx, '10.14' 2 | 3 | # CocoaPods analytics sends network stats synchronously affecting flutter build latency. 4 | ENV['COCOAPODS_DISABLE_STATS'] = 'true' 5 | 6 | project 'Runner', { 7 | 'Debug' => :debug, 8 | 'Profile' => :release, 9 | 'Release' => :release, 10 | } 11 | 12 | def flutter_root 13 | generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'ephemeral', 'Flutter-Generated.xcconfig'), __FILE__) 14 | unless File.exist?(generated_xcode_build_settings_path) 15 | raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure \"flutter pub get\" is executed first" 16 | end 17 | 18 | File.foreach(generated_xcode_build_settings_path) do |line| 19 | matches = line.match(/FLUTTER_ROOT\=(.*)/) 20 | return matches[1].strip if matches 21 | end 22 | raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Flutter-Generated.xcconfig, then run \"flutter pub get\"" 23 | end 24 | 25 | require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) 26 | 27 | flutter_macos_podfile_setup 28 | 29 | target 'Runner' do 30 | use_frameworks! 31 | 32 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 33 | target 'RunnerTests' do 34 | inherit! :search_paths 35 | end 36 | end 37 | 38 | post_install do |installer| 39 | installer.pods_project.targets.each do |target| 40 | flutter_additional_macos_build_settings(target) 41 | end 42 | end 43 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 64 | 66 | 72 | 73 | 74 | 75 | 81 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @main 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | 10 | override func applicationSupportsSecureRestorableState(_ app: NSApplication) -> Bool { 11 | return true 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/macos/Runner/Configs/AppInfo.xcconfig: -------------------------------------------------------------------------------- 1 | // Application-level settings for the Runner target. 2 | // 3 | // This may be replaced with something auto-generated from metadata (e.g., pubspec.yaml) in the 4 | // future. If not, the values below would default to using the project name when this becomes a 5 | // 'flutter create' template. 6 | 7 | // The application's name. By default this is also the title of the Flutter window. 8 | PRODUCT_NAME = example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.example.example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2025 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Debug.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "../../Flutter/Flutter-Release.xcconfig" 2 | #include "Warnings.xcconfig" 3 | -------------------------------------------------------------------------------- /example/macos/Runner/Configs/Warnings.xcconfig: -------------------------------------------------------------------------------- 1 | WARNING_CFLAGS = -Wall -Wconditional-uninitialized -Wnullable-to-nonnull-conversion -Wmissing-method-return-type -Woverlength-strings 2 | GCC_WARN_UNDECLARED_SELECTOR = YES 3 | CLANG_UNDEFINED_BEHAVIOR_SANITIZER_NULLABILITY = YES 4 | CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE 5 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES 6 | CLANG_WARN_PRAGMA_PACK = YES 7 | CLANG_WARN_STRICT_PROTOTYPES = YES 8 | CLANG_WARN_COMMA = YES 9 | GCC_WARN_STRICT_SELECTOR_MATCH = YES 10 | CLANG_WARN_OBJC_REPEATED_USE_OF_WEAK = YES 11 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES 12 | GCC_WARN_SHADOW = YES 13 | CLANG_WARN_UNREACHABLE_CODE = YES 14 | -------------------------------------------------------------------------------- /example/macos/Runner/DebugProfile.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | com.apple.security.cs.allow-jit 8 | 9 | com.apple.security.network.server 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /example/macos/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIconFile 10 | 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | $(PRODUCT_NAME) 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleVersion 22 | $(FLUTTER_BUILD_NUMBER) 23 | LSMinimumSystemVersion 24 | $(MACOSX_DEPLOYMENT_TARGET) 25 | NSHumanReadableCopyright 26 | $(PRODUCT_COPYRIGHT) 27 | NSMainNibFile 28 | MainMenu 29 | NSPrincipalClass 30 | NSApplication 31 | 32 | 33 | -------------------------------------------------------------------------------- /example/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | class RunnerTests: XCTestCase { 6 | 7 | func testExample() { 8 | // If you add code to the Runner application, consider adding tests here. 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: "A flutterwave example project." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: "none" # Remove this line if you wish to publish to pub.dev 6 | 7 | # The following defines the version and build number for your application. 8 | # A version number is three numbers separated by dots, like 1.2.43 9 | # followed by an optional build number separated by a +. 10 | # Both the version and the builder number may be overridden in flutter 11 | # build by specifying --build-name and --build-number, respectively. 12 | # In Android, build-name is used as versionName while build-number used as versionCode. 13 | # Read more about Android versioning at https://developer.android.com/studio/publish/versioning 14 | # In iOS, build-name is used as CFBundleShortVersionString while build-number is used as CFBundleVersion. 15 | # Read more about iOS versioning at 16 | # https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html 17 | # In Windows, build-name is used as the major, minor, and patch parts 18 | # of the product and file versions while build-number is used as the build suffix. 19 | version: 1.0.0+1 20 | 21 | environment: 22 | sdk: ^3.7.2 23 | 24 | # Dependencies specify other packages that your package needs in order to work. 25 | # To automatically upgrade your package dependencies to the latest versions 26 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 27 | # dependencies can be manually updated by changing the version numbers below to 28 | # the latest version available on pub.dev. To see which dependencies have newer 29 | # versions available, run `flutter pub outdated`. 30 | dependencies: 31 | flutter: 32 | sdk: flutter 33 | flutterwave_standard: 34 | path: "../" 35 | uuid: ^4.5.1 36 | 37 | # The following adds the Cupertino Icons font to your application. 38 | # Use with the CupertinoIcons class for iOS style icons. 39 | cupertino_icons: ^1.0.8 40 | 41 | dev_dependencies: 42 | flutter_test: 43 | sdk: flutter 44 | 45 | mockito: ^5.4.0 46 | 47 | # The "flutter_lints" package below contains a set of recommended lints to 48 | # encourage good coding practices. The lint set provided by the package is 49 | # activated in the `analysis_options.yaml` file located at the root of your 50 | # package. See that file for information about deactivating specific lint 51 | # rules and activating additional ones. 52 | flutter_lints: ^5.0.0 53 | 54 | # For information on the generic Dart part of this file, see the 55 | # following page: https://dart.dev/tools/pub/pubspec 56 | 57 | # The following section is specific to Flutter packages. 58 | flutter: 59 | # The following line ensures that the Material Icons font is 60 | # included with your application, so that you can use the icons in 61 | # the material Icons class. 62 | uses-material-design: true 63 | 64 | # To add assets to your application, add an assets section, like this: 65 | # assets: 66 | # - images/a_dot_burr.jpeg 67 | # - images/a_dot_ham.jpeg 68 | 69 | # An image asset can refer to one or more resolution-specific "variants", see 70 | # https://flutter.dev/to/resolution-aware-images 71 | 72 | # For details regarding adding assets from package dependencies, see 73 | # https://flutter.dev/to/asset-from-package 74 | 75 | # To add custom fonts to your application, add a fonts section here, 76 | # in this "flutter" section. Each entry in this list should have a 77 | # "family" key with the font family name, and a "fonts" key with a 78 | # list giving the asset and other descriptors for the font. For 79 | # example: 80 | # fonts: 81 | # - family: Schyler 82 | # fonts: 83 | # - asset: fonts/Schyler-Regular.ttf 84 | # - asset: fonts/Schyler-Italic.ttf 85 | # style: italic 86 | # - family: Trajan Pro 87 | # fonts: 88 | # - asset: fonts/TrajanPro.ttf 89 | # - asset: fonts/TrajanPro_Bold.ttf 90 | # weight: 700 91 | # 92 | # For details regarding fonts from package dependencies, 93 | # see https://flutter.dev/to/font-from-package 94 | -------------------------------------------------------------------------------- /example/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 in the flutter_test package. 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:example/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 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | example 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "example", 3 | "short_name": "example", 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 | -------------------------------------------------------------------------------- /example/windows/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral/ 2 | 3 | # Visual Studio user-specific files. 4 | *.suo 5 | *.user 6 | *.userosscache 7 | *.sln.docstates 8 | 9 | # Visual Studio build-related files. 10 | x64/ 11 | x86/ 12 | 13 | # Visual Studio cache files 14 | # files ending in .cache can be ignored 15 | *.[Cc]ache 16 | # but keep track of directories ending in .cache 17 | !*.[Cc]ache/ 18 | -------------------------------------------------------------------------------- /example/windows/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Project-level configuration. 2 | cmake_minimum_required(VERSION 3.14) 3 | project(example LANGUAGES CXX) 4 | 5 | # The name of the executable created for the application. Change this to change 6 | # the on-disk name of your application. 7 | set(BINARY_NAME "example") 8 | 9 | # Explicitly opt in to modern CMake behaviors to avoid warnings with recent 10 | # versions of CMake. 11 | cmake_policy(VERSION 3.14...3.25) 12 | 13 | # Define build configuration option. 14 | get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) 15 | if(IS_MULTICONFIG) 16 | set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" 17 | CACHE STRING "" FORCE) 18 | else() 19 | if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES) 20 | set(CMAKE_BUILD_TYPE "Debug" CACHE 21 | STRING "Flutter build mode" FORCE) 22 | set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS 23 | "Debug" "Profile" "Release") 24 | endif() 25 | endif() 26 | # Define settings for the Profile build mode. 27 | set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") 28 | set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") 29 | set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") 30 | set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") 31 | 32 | # Use Unicode for all projects. 33 | add_definitions(-DUNICODE -D_UNICODE) 34 | 35 | # Compilation settings that should be applied to most targets. 36 | # 37 | # Be cautious about adding new options here, as plugins use this function by 38 | # default. In most cases, you should add new options to specific targets instead 39 | # of modifying this function. 40 | function(APPLY_STANDARD_SETTINGS TARGET) 41 | target_compile_features(${TARGET} PUBLIC cxx_std_17) 42 | target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") 43 | target_compile_options(${TARGET} PRIVATE /EHsc) 44 | target_compile_definitions(${TARGET} PRIVATE "_HAS_EXCEPTIONS=0") 45 | target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") 46 | endfunction() 47 | 48 | # Flutter library and tool build rules. 49 | set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") 50 | add_subdirectory(${FLUTTER_MANAGED_DIR}) 51 | 52 | # Application build; see runner/CMakeLists.txt. 53 | add_subdirectory("runner") 54 | 55 | 56 | # Generated plugin build rules, which manage building the plugins and adding 57 | # them to the application. 58 | include(flutter/generated_plugins.cmake) 59 | 60 | 61 | # === Installation === 62 | # Support files are copied into place next to the executable, so that it can 63 | # run in place. This is done instead of making a separate bundle (as on Linux) 64 | # so that building and running from within Visual Studio will work. 65 | set(BUILD_BUNDLE_DIR "$") 66 | # Make the "install" step default, as it's required to run. 67 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 68 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 69 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 70 | endif() 71 | 72 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 73 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 74 | 75 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 76 | COMPONENT Runtime) 77 | 78 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 79 | COMPONENT Runtime) 80 | 81 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 82 | COMPONENT Runtime) 83 | 84 | if(PLUGIN_BUNDLED_LIBRARIES) 85 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 86 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 87 | COMPONENT Runtime) 88 | endif() 89 | 90 | # Copy the native assets provided by the build.dart from all packages. 91 | set(NATIVE_ASSETS_DIR "${PROJECT_BUILD_DIR}native_assets/windows/") 92 | install(DIRECTORY "${NATIVE_ASSETS_DIR}" 93 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 94 | COMPONENT Runtime) 95 | 96 | # Fully re-copy the assets directory on each build to avoid having stale files 97 | # from a previous install. 98 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 99 | install(CODE " 100 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 101 | " COMPONENT Runtime) 102 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 103 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 104 | 105 | # Install the AOT library on non-Debug builds only. 106 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 107 | CONFIGURATIONS Profile;Release 108 | COMPONENT Runtime) 109 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | #include 10 | 11 | void RegisterPlugins(flutter::PluginRegistry* registry) { 12 | FlutterInappwebviewWindowsPluginCApiRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("FlutterInappwebviewWindowsPluginCApi")); 14 | } 15 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugin_registrant.h: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #ifndef GENERATED_PLUGIN_REGISTRANT_ 8 | #define GENERATED_PLUGIN_REGISTRANT_ 9 | 10 | #include 11 | 12 | // Registers Flutter plugins. 13 | void RegisterPlugins(flutter::PluginRegistry* registry); 14 | 15 | #endif // GENERATED_PLUGIN_REGISTRANT_ 16 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | flutter_inappwebview_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | ) 11 | 12 | set(PLUGIN_BUNDLED_LIBRARIES) 13 | 14 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 15 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 16 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 19 | endforeach(plugin) 20 | 21 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 22 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/windows/runner/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.14) 2 | project(runner LANGUAGES CXX) 3 | 4 | # Define the application target. To change its name, change BINARY_NAME in the 5 | # top-level CMakeLists.txt, not the value here, or `flutter run` will no longer 6 | # work. 7 | # 8 | # Any new source files that you add to the application should be added here. 9 | add_executable(${BINARY_NAME} WIN32 10 | "flutter_window.cpp" 11 | "main.cpp" 12 | "utils.cpp" 13 | "win32_window.cpp" 14 | "${FLUTTER_MANAGED_DIR}/generated_plugin_registrant.cc" 15 | "Runner.rc" 16 | "runner.exe.manifest" 17 | ) 18 | 19 | # Apply the standard set of build settings. This can be removed for applications 20 | # that need different build settings. 21 | apply_standard_settings(${BINARY_NAME}) 22 | 23 | # Add preprocessor definitions for the build version. 24 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION=\"${FLUTTER_VERSION}\"") 25 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}") 26 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}") 27 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}") 28 | target_compile_definitions(${BINARY_NAME} PRIVATE "FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}") 29 | 30 | # Disable Windows macros that collide with C++ standard library functions. 31 | target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") 32 | 33 | # Add dependency libraries and include directories. Add any application-specific 34 | # dependencies here. 35 | target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) 36 | target_link_libraries(${BINARY_NAME} PRIVATE "dwmapi.lib") 37 | target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") 38 | 39 | # Run the Flutter tool portions of the build. This must not be removed. 40 | add_dependencies(${BINARY_NAME} flutter_assemble) 41 | -------------------------------------------------------------------------------- /example/windows/runner/Runner.rc: -------------------------------------------------------------------------------- 1 | // Microsoft Visual C++ generated resource script. 2 | // 3 | #pragma code_page(65001) 4 | #include "resource.h" 5 | 6 | #define APSTUDIO_READONLY_SYMBOLS 7 | ///////////////////////////////////////////////////////////////////////////// 8 | // 9 | // Generated from the TEXTINCLUDE 2 resource. 10 | // 11 | #include "winres.h" 12 | 13 | ///////////////////////////////////////////////////////////////////////////// 14 | #undef APSTUDIO_READONLY_SYMBOLS 15 | 16 | ///////////////////////////////////////////////////////////////////////////// 17 | // English (United States) resources 18 | 19 | #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) 20 | LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US 21 | 22 | #ifdef APSTUDIO_INVOKED 23 | ///////////////////////////////////////////////////////////////////////////// 24 | // 25 | // TEXTINCLUDE 26 | // 27 | 28 | 1 TEXTINCLUDE 29 | BEGIN 30 | "resource.h\0" 31 | END 32 | 33 | 2 TEXTINCLUDE 34 | BEGIN 35 | "#include ""winres.h""\r\n" 36 | "\0" 37 | END 38 | 39 | 3 TEXTINCLUDE 40 | BEGIN 41 | "\r\n" 42 | "\0" 43 | END 44 | 45 | #endif // APSTUDIO_INVOKED 46 | 47 | 48 | ///////////////////////////////////////////////////////////////////////////// 49 | // 50 | // Icon 51 | // 52 | 53 | // Icon with lowest ID value placed first to ensure application icon 54 | // remains consistent on all systems. 55 | IDI_APP_ICON ICON "resources\\app_icon.ico" 56 | 57 | 58 | ///////////////////////////////////////////////////////////////////////////// 59 | // 60 | // Version 61 | // 62 | 63 | #if defined(FLUTTER_VERSION_MAJOR) && defined(FLUTTER_VERSION_MINOR) && defined(FLUTTER_VERSION_PATCH) && defined(FLUTTER_VERSION_BUILD) 64 | #define VERSION_AS_NUMBER FLUTTER_VERSION_MAJOR,FLUTTER_VERSION_MINOR,FLUTTER_VERSION_PATCH,FLUTTER_VERSION_BUILD 65 | #else 66 | #define VERSION_AS_NUMBER 1,0,0,0 67 | #endif 68 | 69 | #if defined(FLUTTER_VERSION) 70 | #define VERSION_AS_STRING FLUTTER_VERSION 71 | #else 72 | #define VERSION_AS_STRING "1.0.0" 73 | #endif 74 | 75 | VS_VERSION_INFO VERSIONINFO 76 | FILEVERSION VERSION_AS_NUMBER 77 | PRODUCTVERSION VERSION_AS_NUMBER 78 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 79 | #ifdef _DEBUG 80 | FILEFLAGS VS_FF_DEBUG 81 | #else 82 | FILEFLAGS 0x0L 83 | #endif 84 | FILEOS VOS__WINDOWS32 85 | FILETYPE VFT_APP 86 | FILESUBTYPE 0x0L 87 | BEGIN 88 | BLOCK "StringFileInfo" 89 | BEGIN 90 | BLOCK "040904e4" 91 | BEGIN 92 | VALUE "CompanyName", "com.example" "\0" 93 | VALUE "FileDescription", "example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2025 com.example. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "example.exe" "\0" 98 | VALUE "ProductName", "example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_FLUTTER_WINDOW_H_ 2 | #define RUNNER_FLUTTER_WINDOW_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "win32_window.h" 10 | 11 | // A window that does nothing but host a Flutter view. 12 | class FlutterWindow : public Win32Window { 13 | public: 14 | // Creates a new FlutterWindow hosting a Flutter view running |project|. 15 | explicit FlutterWindow(const flutter::DartProject& project); 16 | virtual ~FlutterWindow(); 17 | 18 | protected: 19 | // Win32Window: 20 | bool OnCreate() override; 21 | void OnDestroy() override; 22 | LRESULT MessageHandler(HWND window, UINT const message, WPARAM const wparam, 23 | LPARAM const lparam) noexcept override; 24 | 25 | private: 26 | // The project to run. 27 | flutter::DartProject project_; 28 | 29 | // The Flutter instance hosted by this window. 30 | std::unique_ptr flutter_controller_; 31 | }; 32 | 33 | #endif // RUNNER_FLUTTER_WINDOW_H_ 34 | -------------------------------------------------------------------------------- /example/windows/runner/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #include "flutter_window.h" 6 | #include "utils.h" 7 | 8 | int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev, 9 | _In_ wchar_t *command_line, _In_ int show_command) { 10 | // Attach to console when present (e.g., 'flutter run') or create a 11 | // new console when running with a debugger. 12 | if (!::AttachConsole(ATTACH_PARENT_PROCESS) && ::IsDebuggerPresent()) { 13 | CreateAndAttachConsole(); 14 | } 15 | 16 | // Initialize COM, so that it is available for use in the library and/or 17 | // plugins. 18 | ::CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED); 19 | 20 | flutter::DartProject project(L"data"); 21 | 22 | std::vector command_line_arguments = 23 | GetCommandLineArguments(); 24 | 25 | project.set_dart_entrypoint_arguments(std::move(command_line_arguments)); 26 | 27 | FlutterWindow window(project); 28 | Win32Window::Point origin(10, 10); 29 | Win32Window::Size size(1280, 720); 30 | if (!window.Create(L"example", origin, size)) { 31 | return EXIT_FAILURE; 32 | } 33 | window.SetQuitOnClose(true); 34 | 35 | ::MSG msg; 36 | while (::GetMessage(&msg, nullptr, 0, 0)) { 37 | ::TranslateMessage(&msg); 38 | ::DispatchMessage(&msg); 39 | } 40 | 41 | ::CoUninitialize(); 42 | return EXIT_SUCCESS; 43 | } 44 | -------------------------------------------------------------------------------- /example/windows/runner/resource.h: -------------------------------------------------------------------------------- 1 | //{{NO_DEPENDENCIES}} 2 | // Microsoft Visual C++ generated include file. 3 | // Used by Runner.rc 4 | // 5 | #define IDI_APP_ICON 101 6 | 7 | // Next default values for new objects 8 | // 9 | #ifdef APSTUDIO_INVOKED 10 | #ifndef APSTUDIO_READONLY_SYMBOLS 11 | #define _APS_NEXT_RESOURCE_VALUE 102 12 | #define _APS_NEXT_COMMAND_VALUE 40001 13 | #define _APS_NEXT_CONTROL_VALUE 1001 14 | #define _APS_NEXT_SYMED_VALUE 101 15 | #endif 16 | #endif 17 | -------------------------------------------------------------------------------- /example/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Flutterwave/Flutter-v3/011ee39618d58351ec11612601d1fb9418eb1940/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.cpp: -------------------------------------------------------------------------------- 1 | #include "win32_window.h" 2 | 3 | #include 4 | #include 5 | 6 | #include "resource.h" 7 | 8 | namespace { 9 | 10 | /// Window attribute that enables dark mode window decorations. 11 | /// 12 | /// Redefined in case the developer's machine has a Windows SDK older than 13 | /// version 10.0.22000.0. 14 | /// See: https://docs.microsoft.com/windows/win32/api/dwmapi/ne-dwmapi-dwmwindowattribute 15 | #ifndef DWMWA_USE_IMMERSIVE_DARK_MODE 16 | #define DWMWA_USE_IMMERSIVE_DARK_MODE 20 17 | #endif 18 | 19 | constexpr const wchar_t kWindowClassName[] = L"FLUTTER_RUNNER_WIN32_WINDOW"; 20 | 21 | /// Registry key for app theme preference. 22 | /// 23 | /// A value of 0 indicates apps should use dark mode. A non-zero or missing 24 | /// value indicates apps should use light mode. 25 | constexpr const wchar_t kGetPreferredBrightnessRegKey[] = 26 | L"Software\\Microsoft\\Windows\\CurrentVersion\\Themes\\Personalize"; 27 | constexpr const wchar_t kGetPreferredBrightnessRegValue[] = L"AppsUseLightTheme"; 28 | 29 | // The number of Win32Window objects that currently exist. 30 | static int g_active_window_count = 0; 31 | 32 | using EnableNonClientDpiScaling = BOOL __stdcall(HWND hwnd); 33 | 34 | // Scale helper to convert logical scaler values to physical using passed in 35 | // scale factor 36 | int Scale(int source, double scale_factor) { 37 | return static_cast(source * scale_factor); 38 | } 39 | 40 | // Dynamically loads the |EnableNonClientDpiScaling| from the User32 module. 41 | // This API is only needed for PerMonitor V1 awareness mode. 42 | void EnableFullDpiSupportIfAvailable(HWND hwnd) { 43 | HMODULE user32_module = LoadLibraryA("User32.dll"); 44 | if (!user32_module) { 45 | return; 46 | } 47 | auto enable_non_client_dpi_scaling = 48 | reinterpret_cast( 49 | GetProcAddress(user32_module, "EnableNonClientDpiScaling")); 50 | if (enable_non_client_dpi_scaling != nullptr) { 51 | enable_non_client_dpi_scaling(hwnd); 52 | } 53 | FreeLibrary(user32_module); 54 | } 55 | 56 | } // namespace 57 | 58 | // Manages the Win32Window's window class registration. 59 | class WindowClassRegistrar { 60 | public: 61 | ~WindowClassRegistrar() = default; 62 | 63 | // Returns the singleton registrar instance. 64 | static WindowClassRegistrar* GetInstance() { 65 | if (!instance_) { 66 | instance_ = new WindowClassRegistrar(); 67 | } 68 | return instance_; 69 | } 70 | 71 | // Returns the name of the window class, registering the class if it hasn't 72 | // previously been registered. 73 | const wchar_t* GetWindowClass(); 74 | 75 | // Unregisters the window class. Should only be called if there are no 76 | // instances of the window. 77 | void UnregisterWindowClass(); 78 | 79 | private: 80 | WindowClassRegistrar() = default; 81 | 82 | static WindowClassRegistrar* instance_; 83 | 84 | bool class_registered_ = false; 85 | }; 86 | 87 | WindowClassRegistrar* WindowClassRegistrar::instance_ = nullptr; 88 | 89 | const wchar_t* WindowClassRegistrar::GetWindowClass() { 90 | if (!class_registered_) { 91 | WNDCLASS window_class{}; 92 | window_class.hCursor = LoadCursor(nullptr, IDC_ARROW); 93 | window_class.lpszClassName = kWindowClassName; 94 | window_class.style = CS_HREDRAW | CS_VREDRAW; 95 | window_class.cbClsExtra = 0; 96 | window_class.cbWndExtra = 0; 97 | window_class.hInstance = GetModuleHandle(nullptr); 98 | window_class.hIcon = 99 | LoadIcon(window_class.hInstance, MAKEINTRESOURCE(IDI_APP_ICON)); 100 | window_class.hbrBackground = 0; 101 | window_class.lpszMenuName = nullptr; 102 | window_class.lpfnWndProc = Win32Window::WndProc; 103 | RegisterClass(&window_class); 104 | class_registered_ = true; 105 | } 106 | return kWindowClassName; 107 | } 108 | 109 | void WindowClassRegistrar::UnregisterWindowClass() { 110 | UnregisterClass(kWindowClassName, nullptr); 111 | class_registered_ = false; 112 | } 113 | 114 | Win32Window::Win32Window() { 115 | ++g_active_window_count; 116 | } 117 | 118 | Win32Window::~Win32Window() { 119 | --g_active_window_count; 120 | Destroy(); 121 | } 122 | 123 | bool Win32Window::Create(const std::wstring& title, 124 | const Point& origin, 125 | const Size& size) { 126 | Destroy(); 127 | 128 | const wchar_t* window_class = 129 | WindowClassRegistrar::GetInstance()->GetWindowClass(); 130 | 131 | const POINT target_point = {static_cast(origin.x), 132 | static_cast(origin.y)}; 133 | HMONITOR monitor = MonitorFromPoint(target_point, MONITOR_DEFAULTTONEAREST); 134 | UINT dpi = FlutterDesktopGetDpiForMonitor(monitor); 135 | double scale_factor = dpi / 96.0; 136 | 137 | HWND window = CreateWindow( 138 | window_class, title.c_str(), WS_OVERLAPPEDWINDOW, 139 | Scale(origin.x, scale_factor), Scale(origin.y, scale_factor), 140 | Scale(size.width, scale_factor), Scale(size.height, scale_factor), 141 | nullptr, nullptr, GetModuleHandle(nullptr), this); 142 | 143 | if (!window) { 144 | return false; 145 | } 146 | 147 | UpdateTheme(window); 148 | 149 | return OnCreate(); 150 | } 151 | 152 | bool Win32Window::Show() { 153 | return ShowWindow(window_handle_, SW_SHOWNORMAL); 154 | } 155 | 156 | // static 157 | LRESULT CALLBACK Win32Window::WndProc(HWND const window, 158 | UINT const message, 159 | WPARAM const wparam, 160 | LPARAM const lparam) noexcept { 161 | if (message == WM_NCCREATE) { 162 | auto window_struct = reinterpret_cast(lparam); 163 | SetWindowLongPtr(window, GWLP_USERDATA, 164 | reinterpret_cast(window_struct->lpCreateParams)); 165 | 166 | auto that = static_cast(window_struct->lpCreateParams); 167 | EnableFullDpiSupportIfAvailable(window); 168 | that->window_handle_ = window; 169 | } else if (Win32Window* that = GetThisFromHandle(window)) { 170 | return that->MessageHandler(window, message, wparam, lparam); 171 | } 172 | 173 | return DefWindowProc(window, message, wparam, lparam); 174 | } 175 | 176 | LRESULT 177 | Win32Window::MessageHandler(HWND hwnd, 178 | UINT const message, 179 | WPARAM const wparam, 180 | LPARAM const lparam) noexcept { 181 | switch (message) { 182 | case WM_DESTROY: 183 | window_handle_ = nullptr; 184 | Destroy(); 185 | if (quit_on_close_) { 186 | PostQuitMessage(0); 187 | } 188 | return 0; 189 | 190 | case WM_DPICHANGED: { 191 | auto newRectSize = reinterpret_cast(lparam); 192 | LONG newWidth = newRectSize->right - newRectSize->left; 193 | LONG newHeight = newRectSize->bottom - newRectSize->top; 194 | 195 | SetWindowPos(hwnd, nullptr, newRectSize->left, newRectSize->top, newWidth, 196 | newHeight, SWP_NOZORDER | SWP_NOACTIVATE); 197 | 198 | return 0; 199 | } 200 | case WM_SIZE: { 201 | RECT rect = GetClientArea(); 202 | if (child_content_ != nullptr) { 203 | // Size and position the child window. 204 | MoveWindow(child_content_, rect.left, rect.top, rect.right - rect.left, 205 | rect.bottom - rect.top, TRUE); 206 | } 207 | return 0; 208 | } 209 | 210 | case WM_ACTIVATE: 211 | if (child_content_ != nullptr) { 212 | SetFocus(child_content_); 213 | } 214 | return 0; 215 | 216 | case WM_DWMCOLORIZATIONCOLORCHANGED: 217 | UpdateTheme(hwnd); 218 | return 0; 219 | } 220 | 221 | return DefWindowProc(window_handle_, message, wparam, lparam); 222 | } 223 | 224 | void Win32Window::Destroy() { 225 | OnDestroy(); 226 | 227 | if (window_handle_) { 228 | DestroyWindow(window_handle_); 229 | window_handle_ = nullptr; 230 | } 231 | if (g_active_window_count == 0) { 232 | WindowClassRegistrar::GetInstance()->UnregisterWindowClass(); 233 | } 234 | } 235 | 236 | Win32Window* Win32Window::GetThisFromHandle(HWND const window) noexcept { 237 | return reinterpret_cast( 238 | GetWindowLongPtr(window, GWLP_USERDATA)); 239 | } 240 | 241 | void Win32Window::SetChildContent(HWND content) { 242 | child_content_ = content; 243 | SetParent(content, window_handle_); 244 | RECT frame = GetClientArea(); 245 | 246 | MoveWindow(content, frame.left, frame.top, frame.right - frame.left, 247 | frame.bottom - frame.top, true); 248 | 249 | SetFocus(child_content_); 250 | } 251 | 252 | RECT Win32Window::GetClientArea() { 253 | RECT frame; 254 | GetClientRect(window_handle_, &frame); 255 | return frame; 256 | } 257 | 258 | HWND Win32Window::GetHandle() { 259 | return window_handle_; 260 | } 261 | 262 | void Win32Window::SetQuitOnClose(bool quit_on_close) { 263 | quit_on_close_ = quit_on_close; 264 | } 265 | 266 | bool Win32Window::OnCreate() { 267 | // No-op; provided for subclasses. 268 | return true; 269 | } 270 | 271 | void Win32Window::OnDestroy() { 272 | // No-op; provided for subclasses. 273 | } 274 | 275 | void Win32Window::UpdateTheme(HWND const window) { 276 | DWORD light_mode; 277 | DWORD light_mode_size = sizeof(light_mode); 278 | LSTATUS result = RegGetValue(HKEY_CURRENT_USER, kGetPreferredBrightnessRegKey, 279 | kGetPreferredBrightnessRegValue, 280 | RRF_RT_REG_DWORD, nullptr, &light_mode, 281 | &light_mode_size); 282 | 283 | if (result == ERROR_SUCCESS) { 284 | BOOL enable_dark_mode = light_mode == 0; 285 | DwmSetWindowAttribute(window, DWMWA_USE_IMMERSIVE_DARK_MODE, 286 | &enable_dark_mode, sizeof(enable_dark_mode)); 287 | } 288 | } 289 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /lib/core/TransactionCallBack.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterwave_standard/flutterwave.dart'; 2 | 3 | abstract class TransactionCallBack { 4 | onTransactionComplete(ChargeResponse? chargeResponse); 5 | } -------------------------------------------------------------------------------- /lib/core/flutterwave.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutterwave_standard/models/requests/customer.dart'; 3 | import 'package:flutterwave_standard/models/requests/customizations.dart'; 4 | import 'package:flutterwave_standard/models/requests/standard_request.dart'; 5 | import 'package:flutterwave_standard/models/responses/charge_response.dart'; 6 | import 'package:flutterwave_standard/models/responses/standard_response.dart'; 7 | import 'package:flutterwave_standard/models/subaccount.dart'; 8 | import 'package:flutterwave_standard/view/standard_widget.dart'; 9 | import 'package:flutterwave_standard/view/view_utils.dart'; 10 | import 'package:http/http.dart'; 11 | 12 | class Flutterwave { 13 | String txRef; 14 | String amount; 15 | Customization customization; 16 | Customer customer; 17 | bool isTestMode; 18 | String publicKey; 19 | String paymentOptions; 20 | String redirectUrl; 21 | String currency; 22 | String? paymentPlanId; 23 | List? subAccounts; 24 | Map? meta; 25 | 26 | Flutterwave( 27 | {required this.publicKey, 28 | required this.txRef, 29 | required this.amount, 30 | required this.customer, 31 | required this.paymentOptions, 32 | required this.customization, 33 | required this.redirectUrl, 34 | required this.isTestMode, 35 | required this.currency, 36 | this.paymentPlanId, 37 | this.subAccounts, 38 | this.meta}); 39 | 40 | /// Starts a transaction by calling the Standard service 41 | Future charge(BuildContext context) async { 42 | final request = StandardRequest( 43 | txRef: txRef, 44 | amount: amount, 45 | customer: customer, 46 | paymentOptions: paymentOptions, 47 | customization: customization, 48 | isTestMode: isTestMode, 49 | redirectUrl: redirectUrl, 50 | publicKey: publicKey, 51 | currency: currency, 52 | paymentPlanId: paymentPlanId, 53 | subAccounts: subAccounts, 54 | meta: meta); 55 | 56 | StandardResponse? standardResponse; 57 | 58 | try { 59 | standardResponse = await request.execute(Client()); 60 | 61 | if (!context.mounted) { 62 | return ChargeResponse( 63 | txRef: request.txRef, 64 | status: "error", 65 | success: false, 66 | ); 67 | } 68 | 69 | if ("error" == standardResponse.status) { 70 | FlutterwaveViewUtils.showToast( 71 | context, standardResponse.message!); 72 | return ChargeResponse( 73 | txRef: request.txRef, status: "error", success: false); 74 | } 75 | 76 | if (standardResponse.data?.link == null || 77 | standardResponse.data?.link?.isEmpty == true) { 78 | if (!context.mounted) { 79 | return ChargeResponse( 80 | txRef: request.txRef, 81 | status: "error", 82 | success: false, 83 | ); 84 | } 85 | 86 | FlutterwaveViewUtils.showToast( 87 | context, 88 | "Unable to process this transaction. " + 89 | "Please check that you generated a new tx_ref"); 90 | return ChargeResponse( 91 | txRef: request.txRef, status: "error", success: false); 92 | } 93 | } catch (error) { 94 | if (!context.mounted) { 95 | return ChargeResponse( 96 | txRef: request.txRef, 97 | status: "error", 98 | success: false, 99 | ); 100 | } 101 | 102 | FlutterwaveViewUtils.showToast(context, error.toString()); 103 | return ChargeResponse( 104 | txRef: request.txRef, status: "error", success: false); 105 | } 106 | 107 | if (!context.mounted) { 108 | return ChargeResponse( 109 | txRef: request.txRef, 110 | status: "error", 111 | success: false, 112 | ); 113 | } 114 | 115 | final response = await Navigator.push( 116 | context, 117 | MaterialPageRoute( 118 | builder: (context) => StandardPaymentWidget( 119 | webUrl: standardResponse!.data!.link!, 120 | ), 121 | ), 122 | ); 123 | 124 | if (response != null) return response!; 125 | return ChargeResponse( 126 | txRef: request.txRef, status: "cancelled", success: false); 127 | } 128 | } 129 | -------------------------------------------------------------------------------- /lib/core/transaction_status.dart: -------------------------------------------------------------------------------- 1 | class TransactionStatus { 2 | static const SUCCESSFUL = "successful"; 3 | static const CANCELLED = "cancelled"; 4 | static const ERROR = "error"; 5 | } 6 | -------------------------------------------------------------------------------- /lib/flutterwave.dart: -------------------------------------------------------------------------------- 1 | library flutterwave; 2 | 3 | export './core/flutterwave.dart'; 4 | export './view/flutterwave_style.dart'; 5 | export './models/requests/customer.dart'; 6 | export './models/requests/customizations.dart'; 7 | export './models/responses/charge_response.dart'; -------------------------------------------------------------------------------- /lib/models/TransactionError.dart: -------------------------------------------------------------------------------- 1 | class TransactionError implements Exception { 2 | String message; 3 | 4 | TransactionError(this.message); 5 | 6 | @override 7 | String toString() => message; 8 | 9 | static String formatError(dynamic error) { 10 | try { 11 | if (error["errors"] != null) { 12 | final errorList = error["errors"] as List; 13 | return "${errorList.first["message"]}"; 14 | } 15 | if (error["message"] != null) { 16 | return error["message"]; 17 | } 18 | return "An unexpected error occurred. Please try again."; 19 | } catch (error) { 20 | return "An unexpected error occurred. Please try again."; 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /lib/models/requests/customer.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterwave_standard/utils.dart'; 2 | 3 | class Customer { 4 | String email; 5 | String? phoneNumber; 6 | String? name; 7 | 8 | Customer({required this.email, this.name, this.phoneNumber}); 9 | 10 | /// Converts instance of Customer to json 11 | Map toJson() { 12 | final customer = { 13 | "email": email, 14 | "phonenumber": phoneNumber ?? "", 15 | "name": name ?? "" 16 | }; 17 | return Utils.removeKeysWithEmptyValues(customer); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/models/requests/customizations.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterwave_standard/utils.dart'; 2 | 3 | class Customization { 4 | String? title; 5 | String? description; 6 | String? logo; 7 | 8 | Customization({this.title, this.description, this.logo}); 9 | 10 | /// Converts instance of Customization to json 11 | Map toJson() { 12 | final customization = { 13 | "title": title ?? "", 14 | "description": description ?? "", 15 | "logo": logo ?? "", 16 | }; 17 | return Utils.removeKeysWithEmptyValues(customization); 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/models/requests/standard_request.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | import 'dart:io'; 3 | 4 | import 'package:flutterwave_standard/models/TransactionError.dart'; 5 | import 'package:flutterwave_standard/models/requests/customer.dart'; 6 | import 'package:flutterwave_standard/models/requests/customizations.dart'; 7 | import 'package:flutterwave_standard/models/responses/standard_response.dart'; 8 | import 'package:flutterwave_standard/models/subaccount.dart'; 9 | import 'package:flutterwave_standard/utils.dart'; 10 | import 'package:http/http.dart'; 11 | 12 | class StandardRequest { 13 | String txRef; 14 | String amount; 15 | Customization customization; 16 | Customer customer; 17 | bool isTestMode; 18 | String publicKey; 19 | String paymentOptions; 20 | String redirectUrl; 21 | String? currency; 22 | String? paymentPlanId; 23 | List? subAccounts; 24 | Map? meta; 25 | 26 | StandardRequest( 27 | {required this.txRef, 28 | required this.amount, 29 | required this.customer, 30 | required this.paymentOptions, 31 | required this.customization, 32 | required this.isTestMode, 33 | required this.publicKey, 34 | required this.redirectUrl, 35 | this.currency, 36 | this.paymentPlanId, 37 | this.subAccounts, 38 | this.meta}); 39 | 40 | @override 41 | String toString() => jsonEncode(this._toJson()); 42 | 43 | /// Converts this instance to json 44 | Map _toJson() { 45 | final request = { 46 | "tx_ref": this.txRef, 47 | "publicKey": this.publicKey, 48 | "amount": this.amount, 49 | "currency": this.currency, 50 | "payment_options": this.paymentOptions, 51 | "payment_plan": this.paymentPlanId, 52 | "redirect_url": this.redirectUrl, 53 | "customer": this.customer.toJson(), 54 | "subaccounts": 55 | this.subAccounts?.map((e) => e.toJson()).toList(), 56 | "meta": this.meta, 57 | "customizations": customization.toJson() 58 | }; 59 | return Utils.removeKeysWithEmptyValues(request); 60 | } 61 | 62 | /// Executes network call to initiate transactions 63 | Future execute(Client client) async { 64 | final url = Utils.getBaseUrl(isTestMode) + Utils.STANDARD_PAYMENT; 65 | final uri = Uri.parse(url); 66 | try { 67 | final response = await client.post(uri, 68 | headers: { 69 | HttpHeaders.authorizationHeader: publicKey, 70 | HttpHeaders.contentTypeHeader: 'application/json' 71 | }, 72 | body: json.encode(_toJson())); 73 | 74 | final responseBody = json.decode(response.body); 75 | if (responseBody["status"] == "error") { 76 | throw TransactionError( 77 | TransactionError.formatError(responseBody)); 78 | } 79 | return StandardResponse.fromJson(responseBody); 80 | } catch (error) { 81 | throw (error); 82 | } 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /lib/models/responses/charge_response.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutterwave_standard/core/transaction_status.dart'; 2 | 3 | class ChargeResponse { 4 | String? status; 5 | bool? success; 6 | String? transactionId; 7 | String? txRef; 8 | 9 | ChargeResponse( 10 | {this.status, this.success, this.transactionId, this.txRef}); 11 | 12 | ChargeResponse.fromJson(Map json) { 13 | status = json['status'] ?? TransactionStatus.ERROR; 14 | success = json['success'] ?? false; 15 | transactionId = json['transaction_id']; 16 | txRef = json['tx_ref']; 17 | } 18 | 19 | /// Converts this instance to json 20 | Map toJson() { 21 | final Map data = Map(); 22 | data['status'] = status; 23 | data['success'] = success; 24 | data['transaction_id'] = transactionId; 25 | data['tx_ref'] = txRef; 26 | return data; 27 | } 28 | 29 | @override 30 | String toString() => toJson().toString(); 31 | } 32 | -------------------------------------------------------------------------------- /lib/models/responses/standard_response.dart: -------------------------------------------------------------------------------- 1 | class StandardResponse { 2 | String? status; 3 | String? message; 4 | StandardResponseData? data; 5 | 6 | StandardResponse({this.status, this.data, this.message}); 7 | 8 | StandardResponse.fromJson(Map json) { 9 | status = json["status"]; 10 | message = json["message"]; 11 | data = StandardResponseData.fromJson(json["data"]); 12 | } 13 | 14 | /// Converts this instance to json 15 | Map toJson() { 16 | return { 17 | "status": status, 18 | "message": message, 19 | "data": data?.toJson() 20 | }; 21 | } 22 | } 23 | 24 | class StandardResponseData { 25 | String? link; 26 | 27 | StandardResponseData([this.link = ""]); 28 | 29 | StandardResponseData.fromJson(Map json) { 30 | link = json["link"]; 31 | } 32 | 33 | /// Converts this instance to json 34 | Map toJson() { 35 | return {"link": link}; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /lib/models/subaccount.dart: -------------------------------------------------------------------------------- 1 | class SubAccount { 2 | String id; 3 | int? transactionSplitRatio; 4 | String? transactionChargeType; 5 | double? transactionPercentage; 6 | 7 | SubAccount( 8 | {required this.id, 9 | this.transactionSplitRatio, 10 | this.transactionChargeType, 11 | this.transactionPercentage}); 12 | 13 | /// Converts this instance to json 14 | Map toJson() { 15 | return { 16 | "id": id, 17 | "transaction_split_ratio": transactionSplitRatio, 18 | "transaction_charge_type": transactionChargeType, 19 | "transaction_charge": transactionPercentage 20 | }; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/utils.dart: -------------------------------------------------------------------------------- 1 | class Utils { 2 | static const _PROD_BASE_URL = "https://api.ravepay.co/v3/sdkcheckout/"; 3 | static const String STANDARD_PAYMENT = "payments"; 4 | static const _DEBUG_BASE_URL = 5 | "https://ravesandboxapi.flutterwave.com/v3/sdkcheckout/"; 6 | static const DEFAULT_CURRENCY = "NGN"; 7 | 8 | /// Returns base url depending on test mode 9 | static String getBaseUrl(final bool isTestMode) { 10 | return isTestMode ? _DEBUG_BASE_URL : _PROD_BASE_URL; 11 | } 12 | 13 | static Map removeKeysWithEmptyValues(final Map map) { 14 | final Map copied = Map.from(map); 15 | map.forEach((key, value) { 16 | if (map[key] == null || map[key] == "") copied 17 | .remove(key); 18 | }); 19 | return copied; 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /lib/view/flutterwave_in_app_browser.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:flutter_inappwebview/flutter_inappwebview.dart'; 4 | import 'package:flutterwave_standard/core/TransactionCallBack.dart'; 5 | 6 | import 'package:flutterwave_standard/models/responses/charge_response.dart'; 7 | 8 | class FlutterwaveInAppBrowser extends InAppBrowser { 9 | final TransactionCallBack callBack; 10 | 11 | FlutterwaveInAppBrowser({required this.callBack}); 12 | 13 | ChargeResponse? _chargeResponse; 14 | 15 | @override 16 | Future onLoadStart(url) async { 17 | if (url != null) _processUrl(url); 18 | } 19 | 20 | @override 21 | void onExit() { 22 | callBack.onTransactionComplete(_chargeResponse); 23 | } 24 | 25 | _processUrl(Uri uri) { 26 | if (_checkHasAppendedWithResponse(uri)) { 27 | _finishWithAppendedResponse(uri); 28 | } else { 29 | _checkHasCompletedProcessing(uri); 30 | } 31 | } 32 | 33 | _checkHasCompletedProcessing(final Uri uri) { 34 | final status = uri.queryParameters["status"]; 35 | final txRef = uri.queryParameters["tx_ref"]; 36 | if (status != null && txRef != null) { 37 | _finish(uri); 38 | } 39 | } 40 | 41 | bool _checkHasAppendedWithResponse(final Uri uri) { 42 | final response = uri.queryParameters["response"]; 43 | if (response != null) { 44 | final json = jsonDecode(response); 45 | final status = json["status"]; 46 | final txRef = json["txRef"]; 47 | return status != null && txRef != null; 48 | } 49 | return false; 50 | } 51 | 52 | _finishWithAppendedResponse(Uri uri) { 53 | final response = uri.queryParameters["response"]; 54 | final decoded = Uri.decodeFull(response!); 55 | final json = jsonDecode(decoded); 56 | final status = json["status"]; 57 | final txRef = json["txRef"]; 58 | final id = json["id"]; 59 | 60 | final ChargeResponse chargeResponse = ChargeResponse( 61 | status: status, 62 | transactionId: "$id", 63 | txRef: txRef, 64 | success: status?.toString().toLowerCase() == "success" || 65 | status?.toString().toLowerCase() == "completed"); 66 | _closeTransactionScreen(chargeResponse); 67 | // callBack.onTransactionComplete(chargeResponse); 68 | // close(); 69 | } 70 | 71 | _finish(final Uri uri) { 72 | final status = uri.queryParameters["status"]; 73 | final txRef = uri.queryParameters["tx_ref"]; 74 | final id = uri.queryParameters["transaction_id"]; 75 | final ChargeResponse chargeResponse = ChargeResponse( 76 | status: status, 77 | transactionId: id, 78 | txRef: txRef, 79 | success: status?.toLowerCase() == "success" || 80 | status?.toLowerCase() == "completed"); 81 | _closeTransactionScreen(chargeResponse); 82 | // callBack.onTransactionComplete(chargeResponse); 83 | // close(); 84 | } 85 | 86 | _closeTransactionScreen(final ChargeResponse chargeResponse) { 87 | _chargeResponse = chargeResponse; 88 | close(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /lib/view/flutterwave_style.dart: -------------------------------------------------------------------------------- 1 | // import 'package:flutter/material.dart'; 2 | 3 | // @deprecated 4 | // /// No longer needed since the intermediate screen was removed. 5 | // /// Will be removed in further releases. 6 | // class FlutterwaveStyle { 7 | // final String? appBarText; 8 | // final Color? buttonColor; 9 | // final TextStyle? buttonTextStyle; 10 | // final Color? appBarColor; 11 | // final TextStyle? appBarTitleTextStyle; 12 | // final Icon? appBarIcon; 13 | // final Color? mainBackgroundColor; 14 | // final TextStyle? mainTextStyle; 15 | // final Color? dialogBackgroundColor; 16 | // final TextStyle? dialogCancelTextStyle; 17 | // final TextStyle? dialogContinueTextStyle; 18 | // final String? buttonText; 19 | 20 | // FlutterwaveStyle( 21 | // {this.buttonColor, 22 | // this.buttonTextStyle, 23 | // this.appBarText, 24 | // this.appBarTitleTextStyle, 25 | // this.appBarColor, 26 | // this.appBarIcon, 27 | // this.mainBackgroundColor, 28 | // this.mainTextStyle, 29 | // this.dialogBackgroundColor, 30 | // this.dialogCancelTextStyle, 31 | // this.dialogContinueTextStyle, 32 | // this.buttonText}); 33 | 34 | // /// Returns app bar text text or default 35 | // String getAppBarText() { 36 | // return appBarText ?? "Flutterwave"; 37 | // } 38 | 39 | // /// Returns button color or default 40 | // Color getButtonColor() { 41 | // return buttonColor ?? Color(0xFFfff1d0); 42 | // } 43 | 44 | // /// Returns button text style or default 45 | // TextStyle getButtonTextStyle() { 46 | // return buttonTextStyle ?? 47 | // TextStyle( 48 | // color: Colors.black, fontSize: 18, fontWeight: FontWeight.bold); 49 | // } 50 | 51 | // /// Returns app bar color or default 52 | // Color getAppBarColor() { 53 | // return appBarColor ?? Color(0xFFfff1d0); 54 | // } 55 | 56 | // /// Returns app bar text style or default 57 | // TextStyle getAppBarTextStyle() { 58 | // return appBarTitleTextStyle ?? 59 | // TextStyle( 60 | // fontSize: 20, color: Colors.black, fontWeight: FontWeight.bold); 61 | // } 62 | 63 | // /// Returns app bar icon or default 64 | // Icon getAppBarIcon() { 65 | // return appBarIcon ?? Icon(Icons.arrow_back, color: Colors.black); 66 | // } 67 | 68 | // /// Returns background color or default 69 | // Color getMainBackgroundColor() { 70 | // return mainBackgroundColor ?? Colors.white; 71 | // } 72 | 73 | // /// Returns dialog text style or default 74 | // TextStyle getMainTextStyle() { 75 | // return mainTextStyle ?? 76 | // TextStyle(color: Colors.black, fontSize: 18, letterSpacing: 1.2); 77 | // } 78 | 79 | // /// Returns dialog background color or default 80 | // Color getDialogBackgroundColor() { 81 | // return dialogBackgroundColor ?? Colors.white; 82 | // } 83 | 84 | // /// Returns dialog's cancel text style or default 85 | // TextStyle getDialogCancelTextStyle() { 86 | // return dialogCancelTextStyle ?? TextStyle(fontSize: 18, color: Colors.red); 87 | // } 88 | 89 | // /// Returns dialog's continue text style or default 90 | // TextStyle getDialogContinueTextStyle() { 91 | // return dialogContinueTextStyle ?? TextStyle(fontSize: 18, color: Colors.blue); 92 | // } 93 | 94 | // /// Returns button text or default 95 | // String getButtonText() { 96 | // return buttonText ?? "Make Payment"; 97 | // } 98 | // } 99 | -------------------------------------------------------------------------------- /lib/view/standard_webview.dart: -------------------------------------------------------------------------------- 1 | 2 | // import 'dart:convert'; 3 | // import 'dart:io'; 4 | 5 | // import 'package:flutter/foundation.dart'; 6 | // import 'package:flutter/gestures.dart'; 7 | // import 'package:flutter/material.dart'; 8 | // import 'package:flutterwave_standard/models/responses/charge_response.dart'; 9 | // import 'package:webview_flutter/webview_flutter.dart'; 10 | 11 | // import 'flutterwave_style.dart'; 12 | 13 | // @deprecated 14 | // class StandardWebView extends StatefulWidget { 15 | // final String url; 16 | // final FlutterwaveStyle? style; 17 | // const StandardWebView({required this.url, this.style}); 18 | 19 | // @override 20 | // State createState() => _StandardWebViewAppState(); 21 | // } 22 | 23 | // class _StandardWebViewAppState extends State { 24 | 25 | // @override 26 | // void initState() { 27 | // if (Platform.isAndroid) { 28 | // WebView.platform = SurfaceAndroidWebView(); 29 | // } 30 | // super.initState(); 31 | // } 32 | 33 | // @override 34 | // Widget build(BuildContext context) { 35 | 36 | // final Set> gestureRecognizers = { 37 | // Factory(() => EagerGestureRecognizer()) 38 | // }; 39 | 40 | // UniqueKey _key = UniqueKey(); 41 | 42 | // AppBar? appBar; 43 | // if (widget.style != null) { 44 | // appBar = AppBar( 45 | // title: Text( 46 | // widget.style!.getAppBarText(), 47 | // style: widget.style!.getAppBarTextStyle(), 48 | // ), 49 | // ); 50 | // } 51 | 52 | // return SafeArea( 53 | // child: Scaffold( 54 | // key: _key, 55 | // appBar: appBar, 56 | // body: WebView( 57 | // initialUrl: widget.url, 58 | // javascriptMode: JavascriptMode.unrestricted, 59 | // gestureRecognizers: gestureRecognizers, 60 | // onPageStarted: (webUrl) { 61 | // final url = Uri.parse(webUrl); 62 | // _processUrl(url); 63 | // }, 64 | // ), 65 | // ) 66 | // ); 67 | // } 68 | 69 | // _processUrl(Uri uri) { 70 | // if (_checkHasAppendedWithResponse(uri)) { 71 | // _finishWithAppendedResponse(uri); 72 | // } else { 73 | // _checkHasCompletedProcessing(uri); 74 | // } 75 | // } 76 | 77 | // _checkHasCompletedProcessing(final Uri uri) { 78 | // final status = uri.queryParameters["status"]; 79 | // final txRef = uri.queryParameters["tx_ref"]; 80 | // final id = uri.queryParameters["transaction_id"]; 81 | // if (status != null && txRef != null) { 82 | // _finish(uri); 83 | // } 84 | // } 85 | 86 | // bool _checkHasAppendedWithResponse(final Uri uri) { 87 | // final response = uri.queryParameters["response"]; 88 | // if (response != null) { 89 | // final json = jsonDecode(response); 90 | // final status = json["status"]; 91 | // final txRef = json["txRef"]; 92 | // return status != null && txRef != null; 93 | // } 94 | // return false; 95 | // } 96 | 97 | // _finishWithAppendedResponse(Uri uri) { 98 | // final response = uri.queryParameters["response"]; 99 | // final decoded = Uri.decodeFull(response!); 100 | // final json = jsonDecode(decoded); 101 | // final status = json["status"]; 102 | // final txRef = json["txRef"]; 103 | // final id = json["id"]; 104 | 105 | // final ChargeResponse chargeResponse = ChargeResponse( 106 | // status: status, 107 | // transactionId: "$id", 108 | // txRef: txRef, 109 | // success: status?.contains("success") == true 110 | // ); 111 | // Navigator.pop(context, chargeResponse); 112 | // } 113 | 114 | // _finish(final Uri uri) { 115 | // final status = uri.queryParameters["status"]; 116 | // final txRef = uri.queryParameters["tx_ref"]; 117 | // final id = uri.queryParameters["transaction_id"]; 118 | // final ChargeResponse chargeResponse = ChargeResponse( 119 | // status: status, 120 | // transactionId: id, 121 | // txRef: txRef, 122 | // success: status?.contains("success") == true 123 | // ); 124 | // Navigator.pop(context, chargeResponse); 125 | // } 126 | // } -------------------------------------------------------------------------------- /lib/view/standard_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:flutter_inappwebview/flutter_inappwebview.dart'; 3 | import 'package:flutterwave_standard/core/TransactionCallBack.dart'; 4 | import 'package:flutterwave_standard/models/responses/charge_response.dart'; 5 | 6 | import 'package:flutterwave_standard/view/flutterwave_in_app_browser.dart'; 7 | 8 | class StandardPaymentWidget extends StatefulWidget { 9 | final String webUrl; 10 | 11 | StandardPaymentWidget({required this.webUrl}); 12 | 13 | @override 14 | State createState() => 15 | new _StandardPaymentWidgetAppState(); 16 | } 17 | 18 | class _StandardPaymentWidgetAppState 19 | extends State 20 | implements TransactionCallBack { 21 | InAppBrowserClassSettings settings = InAppBrowserClassSettings( 22 | browserSettings: InAppBrowserSettings(hideUrlBar: true), 23 | webViewSettings: InAppWebViewSettings(javaScriptEnabled: true), 24 | ); 25 | 26 | @override 27 | void initState() { 28 | super.initState(); 29 | final browser = FlutterwaveInAppBrowser(callBack: this); 30 | browser.openUrlRequest( 31 | urlRequest: URLRequest(url: WebUri(widget.webUrl)), 32 | settings: settings); 33 | } 34 | 35 | @override 36 | onTransactionComplete(ChargeResponse? chargeResponse) { 37 | Navigator.pop(context, chargeResponse); 38 | } 39 | 40 | @override 41 | Widget build(BuildContext context) { 42 | return Scaffold( 43 | body: Container(), 44 | backgroundColor: Colors.white, 45 | ); 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /lib/view/view_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | import 'package:fluttertoast/fluttertoast.dart'; 3 | 4 | class FlutterwaveViewUtils { 5 | /// Displays a modal to confirm payment 6 | // static Future showConfirmPaymentModal( 7 | // final BuildContext context, 8 | // final String? currency, 9 | // final String amount, 10 | // final TextStyle textStyle, 11 | // final Color? dialogBackgroundColor, 12 | // final TextStyle modalCancelTextStyle, 13 | // final TextStyle modalContinueTextStyle, 14 | // final Function onContinuePressed, 15 | // ) async { 16 | 17 | // return showDialog( 18 | // context: context, 19 | // barrierDismissible: false, 20 | // builder: (BuildContext buildContext) { 21 | // final transactionCurrency = currency ?? "NGN"; 22 | // return AlertDialog( 23 | // backgroundColor: dialogBackgroundColor, 24 | // content: Container( 25 | // margin: EdgeInsets.fromLTRB(20, 5, 20, 5), 26 | // child: Text( 27 | // "You will be charged a total of $transactionCurrency " 28 | // "$amount. Do you wish to continue? ", 29 | // textAlign: TextAlign.center, 30 | // style: textStyle, 31 | // // style: TextStyle( 32 | // // color: Colors.black, 33 | // // fontSize: 18, 34 | // // letterSpacing: 1.2, 35 | // // ), 36 | // ), 37 | // ), 38 | // actions: [ 39 | // TextButton( 40 | // onPressed: () => {Navigator.of(context).pop()}, 41 | // child: Text( 42 | // "CANCEL", 43 | // style: modalCancelTextStyle, 44 | // ), 45 | // ), 46 | // TextButton( 47 | // onPressed: () => onContinuePressed(), 48 | // child: Text( 49 | // "CONTINUE", 50 | // style: modalContinueTextStyle, 51 | // ), 52 | // ), 53 | // ], 54 | // ); 55 | // }, 56 | // ); 57 | // } 58 | 59 | // /// Shows progress dialog 60 | // Future showProgressDialog( 61 | // final String message, 62 | // final BuildContext context, 63 | // final bool dismissible, 64 | // final Widget? progressIndicator, 65 | // final TextStyle? textStyle, 66 | // final Color? dialogBackgroundColor) { 67 | // final Widget indicator = progressIndicator != null 68 | // ? progressIndicator 69 | // : CircularProgressIndicator(backgroundColor: Colors.orangeAccent); 70 | 71 | // final style = 72 | // textStyle != null ? textStyle : TextStyle(color: Colors.black); 73 | 74 | // return showDialog( 75 | // context: context, 76 | // barrierDismissible: dismissible, 77 | // builder: (BuildContext context) { 78 | // return AlertDialog( 79 | // backgroundColor: dialogBackgroundColor, 80 | // content: Row( 81 | // mainAxisAlignment: MainAxisAlignment.spaceEvenly, 82 | // children: [ 83 | // indicator, 84 | // Text( 85 | // message, 86 | // textAlign: TextAlign.center, 87 | // style: style, 88 | // ) 89 | // ], 90 | // ), 91 | // ); 92 | // }, 93 | // ); 94 | // } 95 | 96 | // static void _goBackToPaymentScreen(final BuildContext context) { 97 | // Navigator.of(context).pop(); 98 | // } 99 | 100 | // /// Cretaes a customised Appbar 101 | // static AppBar appBar( 102 | // final BuildContext context, 103 | // final String title, 104 | // final TextStyle appBarTitleTextStyle, 105 | // final Icon appBarIcon, 106 | // final Color appBarColor, 107 | // [final Function? handleBackPress]) { 108 | 109 | // return AppBar( 110 | // backgroundColor: appBarColor, 111 | // titleTextStyle: appBarTitleTextStyle, 112 | // leading: IconButton( 113 | // icon: appBarIcon, 114 | // onPressed: () => handleBackPress == null 115 | // ? _goBackToPaymentScreen(context) 116 | // : handleBackPress(), 117 | // ), 118 | // title: Text(title, style: appBarTitleTextStyle), 119 | // ); 120 | // } 121 | 122 | // /// Displays a Snackbar 123 | // static showSnackBar(BuildContext context, String text) { 124 | // final snackBar = SnackBar(content: Text(text)); 125 | // ScaffoldMessenger.of(context).showSnackBar(snackBar); 126 | // } 127 | 128 | /// Displays a toast notification 129 | static void showToast(BuildContext context, String text) { 130 | Fluttertoast.showToast( 131 | msg: text, 132 | timeInSecForIosWeb: 1, 133 | backgroundColor: Color(0xAA383737), 134 | textColor: Colors.white, 135 | ); 136 | } 137 | } 138 | -------------------------------------------------------------------------------- /pubspec.lock: -------------------------------------------------------------------------------- 1 | # Generated by pub 2 | # See https://dart.dev/tools/pub/glossary#lockfile 3 | packages: 4 | _fe_analyzer_shared: 5 | dependency: transitive 6 | description: 7 | name: _fe_analyzer_shared 8 | sha256: "16e298750b6d0af7ce8a3ba7c18c69c3785d11b15ec83f6dcd0ad2a0009b3cab" 9 | url: "https://pub.dev" 10 | source: hosted 11 | version: "76.0.0" 12 | _macros: 13 | dependency: transitive 14 | description: dart 15 | source: sdk 16 | version: "0.3.3" 17 | analyzer: 18 | dependency: transitive 19 | description: 20 | name: analyzer 21 | sha256: "1f14db053a8c23e260789e9b0980fa27f2680dd640932cae5e1137cce0e46e1e" 22 | url: "https://pub.dev" 23 | source: hosted 24 | version: "6.11.0" 25 | args: 26 | dependency: transitive 27 | description: 28 | name: args 29 | sha256: "3d82ff8620ec576fd38f6cec0df45a7c088b8704eb1c63d4c336392e5efca6ca" 30 | url: "https://pub.dev" 31 | source: hosted 32 | version: "2.2.0" 33 | async: 34 | dependency: transitive 35 | description: 36 | name: async 37 | sha256: d2872f9c19731c2e5f10444b14686eb7cc85c76274bd6c16e1816bff9a3bab63 38 | url: "https://pub.dev" 39 | source: hosted 40 | version: "2.12.0" 41 | boolean_selector: 42 | dependency: transitive 43 | description: 44 | name: boolean_selector 45 | sha256: "8aab1771e1243a5063b8b0ff68042d67334e3feab9e95b9490f9a6ebf73b42ea" 46 | url: "https://pub.dev" 47 | source: hosted 48 | version: "2.1.2" 49 | build: 50 | dependency: transitive 51 | description: 52 | name: build 53 | sha256: cef23f1eda9b57566c81e2133d196f8e3df48f244b317368d65c5943d91148f0 54 | url: "https://pub.dev" 55 | source: hosted 56 | version: "2.4.2" 57 | built_collection: 58 | dependency: transitive 59 | description: 60 | name: built_collection 61 | sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100" 62 | url: "https://pub.dev" 63 | source: hosted 64 | version: "5.1.1" 65 | built_value: 66 | dependency: transitive 67 | description: 68 | name: built_value 69 | sha256: ce70206f4116029cec77802dd5b5987e32c30ab491af6e3e49410b7457ebfc64 70 | url: "https://pub.dev" 71 | source: hosted 72 | version: "8.1.2" 73 | characters: 74 | dependency: transitive 75 | description: 76 | name: characters 77 | sha256: f71061c654a3380576a52b451dd5532377954cf9dbd272a78fc8479606670803 78 | url: "https://pub.dev" 79 | source: hosted 80 | version: "1.4.0" 81 | charcode: 82 | dependency: transitive 83 | description: 84 | name: charcode 85 | sha256: fb98c0f6d12c920a02ee2d998da788bca066ca5f148492b7085ee23372b12306 86 | url: "https://pub.dev" 87 | source: hosted 88 | version: "1.3.1" 89 | clock: 90 | dependency: transitive 91 | description: 92 | name: clock 93 | sha256: fddb70d9b5277016c77a80201021d40a2247104d9f4aa7bab7157b7e3f05b84b 94 | url: "https://pub.dev" 95 | source: hosted 96 | version: "1.1.2" 97 | code_builder: 98 | dependency: transitive 99 | description: 100 | name: code_builder 101 | sha256: "0ec10bf4a89e4c613960bf1e8b42c64127021740fb21640c29c909826a5eea3e" 102 | url: "https://pub.dev" 103 | source: hosted 104 | version: "4.10.1" 105 | collection: 106 | dependency: transitive 107 | description: 108 | name: collection 109 | sha256: "2f5709ae4d3d59dd8f7cd309b4e023046b57d8a6c82130785d2b0e5868084e76" 110 | url: "https://pub.dev" 111 | source: hosted 112 | version: "1.19.1" 113 | convert: 114 | dependency: transitive 115 | description: 116 | name: convert 117 | sha256: f08428ad63615f96a27e34221c65e1a451439b5f26030f78d790f461c686d65d 118 | url: "https://pub.dev" 119 | source: hosted 120 | version: "3.0.1" 121 | crypto: 122 | dependency: transitive 123 | description: 124 | name: crypto 125 | sha256: cf75650c66c0316274e21d7c43d3dea246273af5955bd94e8184837cd577575c 126 | url: "https://pub.dev" 127 | source: hosted 128 | version: "3.0.1" 129 | dart_style: 130 | dependency: transitive 131 | description: 132 | name: dart_style 133 | sha256: "7306ab8a2359a48d22310ad823521d723acfed60ee1f7e37388e8986853b6820" 134 | url: "https://pub.dev" 135 | source: hosted 136 | version: "2.3.8" 137 | fake_async: 138 | dependency: transitive 139 | description: 140 | name: fake_async 141 | sha256: "6a95e56b2449df2273fd8c45a662d6947ce1ebb7aafe80e550a3f68297f3cacc" 142 | url: "https://pub.dev" 143 | source: hosted 144 | version: "1.3.2" 145 | file: 146 | dependency: transitive 147 | description: 148 | name: file 149 | sha256: b69516f2c26a5bcac4eee2e32512e1a5205ab312b3536c1c1227b2b942b5f9ad 150 | url: "https://pub.dev" 151 | source: hosted 152 | version: "6.1.2" 153 | fixnum: 154 | dependency: transitive 155 | description: 156 | name: fixnum 157 | sha256: "6a2ef17156f4dc49684f9d99aaf4a93aba8ac49f5eac861755f5730ddf6e2e4e" 158 | url: "https://pub.dev" 159 | source: hosted 160 | version: "1.0.0" 161 | flutter: 162 | dependency: "direct main" 163 | description: flutter 164 | source: sdk 165 | version: "0.0.0" 166 | flutter_inappwebview: 167 | dependency: "direct main" 168 | description: 169 | name: flutter_inappwebview 170 | sha256: "80092d13d3e29b6227e25b67973c67c7210bd5e35c4b747ca908e31eb71a46d5" 171 | url: "https://pub.dev" 172 | source: hosted 173 | version: "6.1.5" 174 | flutter_inappwebview_android: 175 | dependency: transitive 176 | description: 177 | name: flutter_inappwebview_android 178 | sha256: "62557c15a5c2db5d195cb3892aab74fcaec266d7b86d59a6f0027abd672cddba" 179 | url: "https://pub.dev" 180 | source: hosted 181 | version: "1.1.3" 182 | flutter_inappwebview_internal_annotations: 183 | dependency: transitive 184 | description: 185 | name: flutter_inappwebview_internal_annotations 186 | sha256: "787171d43f8af67864740b6f04166c13190aa74a1468a1f1f1e9ee5b90c359cd" 187 | url: "https://pub.dev" 188 | source: hosted 189 | version: "1.2.0" 190 | flutter_inappwebview_ios: 191 | dependency: transitive 192 | description: 193 | name: flutter_inappwebview_ios 194 | sha256: "5818cf9b26cf0cbb0f62ff50772217d41ea8d3d9cc00279c45f8aabaa1b4025d" 195 | url: "https://pub.dev" 196 | source: hosted 197 | version: "1.1.2" 198 | flutter_inappwebview_macos: 199 | dependency: transitive 200 | description: 201 | name: flutter_inappwebview_macos 202 | sha256: c1fbb86af1a3738e3541364d7d1866315ffb0468a1a77e34198c9be571287da1 203 | url: "https://pub.dev" 204 | source: hosted 205 | version: "1.1.2" 206 | flutter_inappwebview_platform_interface: 207 | dependency: transitive 208 | description: 209 | name: flutter_inappwebview_platform_interface 210 | sha256: cf5323e194096b6ede7a1ca808c3e0a078e4b33cc3f6338977d75b4024ba2500 211 | url: "https://pub.dev" 212 | source: hosted 213 | version: "1.3.0+1" 214 | flutter_inappwebview_web: 215 | dependency: transitive 216 | description: 217 | name: flutter_inappwebview_web 218 | sha256: "55f89c83b0a0d3b7893306b3bb545ba4770a4df018204917148ebb42dc14a598" 219 | url: "https://pub.dev" 220 | source: hosted 221 | version: "1.1.2" 222 | flutter_inappwebview_windows: 223 | dependency: transitive 224 | description: 225 | name: flutter_inappwebview_windows 226 | sha256: "8b4d3a46078a2cdc636c4a3d10d10f2a16882f6be607962dbfff8874d1642055" 227 | url: "https://pub.dev" 228 | source: hosted 229 | version: "0.6.0" 230 | flutter_test: 231 | dependency: "direct dev" 232 | description: flutter 233 | source: sdk 234 | version: "0.0.0" 235 | flutter_web_plugins: 236 | dependency: transitive 237 | description: flutter 238 | source: sdk 239 | version: "0.0.0" 240 | fluttertoast: 241 | dependency: "direct main" 242 | description: 243 | name: fluttertoast 244 | sha256: "25e51620424d92d3db3832464774a6143b5053f15e382d8ffbfd40b6e795dcf1" 245 | url: "https://pub.dev" 246 | source: hosted 247 | version: "8.2.12" 248 | glob: 249 | dependency: transitive 250 | description: 251 | name: glob 252 | sha256: dda85ce2aefce16f7e75586acbcb1e8320bf176f69fd94082e31945d6de67f3e 253 | url: "https://pub.dev" 254 | source: hosted 255 | version: "2.0.1" 256 | http: 257 | dependency: "direct main" 258 | description: 259 | name: http 260 | sha256: fe7ab022b76f3034adc518fb6ea04a82387620e19977665ea18d30a1cf43442f 261 | url: "https://pub.dev" 262 | source: hosted 263 | version: "1.3.0" 264 | http_parser: 265 | dependency: transitive 266 | description: 267 | name: http_parser 268 | sha256: e362d639ba3bc07d5a71faebb98cde68c05bfbcfbbb444b60b6f60bb67719185 269 | url: "https://pub.dev" 270 | source: hosted 271 | version: "4.0.0" 272 | leak_tracker: 273 | dependency: transitive 274 | description: 275 | name: leak_tracker 276 | sha256: c35baad643ba394b40aac41080300150a4f08fd0fd6a10378f8f7c6bc161acec 277 | url: "https://pub.dev" 278 | source: hosted 279 | version: "10.0.8" 280 | leak_tracker_flutter_testing: 281 | dependency: transitive 282 | description: 283 | name: leak_tracker_flutter_testing 284 | sha256: f8b613e7e6a13ec79cfdc0e97638fddb3ab848452eff057653abd3edba760573 285 | url: "https://pub.dev" 286 | source: hosted 287 | version: "3.0.9" 288 | leak_tracker_testing: 289 | dependency: transitive 290 | description: 291 | name: leak_tracker_testing 292 | sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3" 293 | url: "https://pub.dev" 294 | source: hosted 295 | version: "3.0.1" 296 | logging: 297 | dependency: transitive 298 | description: 299 | name: logging 300 | sha256: "0520a4826042a8a5d09ddd4755623a50d37ee536d79a70452aff8c8ad7bb6c27" 301 | url: "https://pub.dev" 302 | source: hosted 303 | version: "1.0.1" 304 | macros: 305 | dependency: transitive 306 | description: 307 | name: macros 308 | sha256: "1d9e801cd66f7ea3663c45fc708450db1fa57f988142c64289142c9b7ee80656" 309 | url: "https://pub.dev" 310 | source: hosted 311 | version: "0.1.3-main.0" 312 | matcher: 313 | dependency: transitive 314 | description: 315 | name: matcher 316 | sha256: dc58c723c3c24bf8d3e2d3ad3f2f9d7bd9cf43ec6feaa64181775e60190153f2 317 | url: "https://pub.dev" 318 | source: hosted 319 | version: "0.12.17" 320 | material_color_utilities: 321 | dependency: transitive 322 | description: 323 | name: material_color_utilities 324 | sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec 325 | url: "https://pub.dev" 326 | source: hosted 327 | version: "0.11.1" 328 | meta: 329 | dependency: transitive 330 | description: 331 | name: meta 332 | sha256: e3641ec5d63ebf0d9b41bd43201a66e3fc79a65db5f61fc181f04cd27aab950c 333 | url: "https://pub.dev" 334 | source: hosted 335 | version: "1.16.0" 336 | mockito: 337 | dependency: "direct dev" 338 | description: 339 | name: mockito 340 | sha256: f99d8d072e249f719a5531735d146d8cf04c580d93920b04de75bef6dfb2daf6 341 | url: "https://pub.dev" 342 | source: hosted 343 | version: "5.4.5" 344 | package_config: 345 | dependency: transitive 346 | description: 347 | name: package_config 348 | sha256: f096c55ebb7deb7e384101542bfba8c52696c1b56fca2eb62827989ef2353bbc 349 | url: "https://pub.dev" 350 | source: hosted 351 | version: "2.2.0" 352 | path: 353 | dependency: transitive 354 | description: 355 | name: path 356 | sha256: "75cca69d1490965be98c73ceaea117e8a04dd21217b37b292c9ddbec0d955bc5" 357 | url: "https://pub.dev" 358 | source: hosted 359 | version: "1.9.1" 360 | pedantic: 361 | dependency: transitive 362 | description: 363 | name: pedantic 364 | sha256: "67fc27ed9639506c856c840ccce7594d0bdcd91bc8d53d6e52359449a1d50602" 365 | url: "https://pub.dev" 366 | source: hosted 367 | version: "1.11.1" 368 | plugin_platform_interface: 369 | dependency: transitive 370 | description: 371 | name: plugin_platform_interface 372 | sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02" 373 | url: "https://pub.dev" 374 | source: hosted 375 | version: "2.1.8" 376 | pub_semver: 377 | dependency: transitive 378 | description: 379 | name: pub_semver 380 | sha256: "5bfcf68ca79ef689f8990d1160781b4bad40a3bd5e5218ad4076ddb7f4081585" 381 | url: "https://pub.dev" 382 | source: hosted 383 | version: "2.2.0" 384 | sky_engine: 385 | dependency: transitive 386 | description: flutter 387 | source: sdk 388 | version: "0.0.0" 389 | source_gen: 390 | dependency: transitive 391 | description: 392 | name: source_gen 393 | sha256: "35c8150ece9e8c8d263337a265153c3329667640850b9304861faea59fc98f6b" 394 | url: "https://pub.dev" 395 | source: hosted 396 | version: "2.0.0" 397 | source_span: 398 | dependency: transitive 399 | description: 400 | name: source_span 401 | sha256: "254ee5351d6cb365c859e20ee823c3bb479bf4a293c22d17a9f1bf144ce86f7c" 402 | url: "https://pub.dev" 403 | source: hosted 404 | version: "1.10.1" 405 | stack_trace: 406 | dependency: transitive 407 | description: 408 | name: stack_trace 409 | sha256: "8b27215b45d22309b5cddda1aa2b19bdfec9df0e765f2de506401c071d38d1b1" 410 | url: "https://pub.dev" 411 | source: hosted 412 | version: "1.12.1" 413 | stream_channel: 414 | dependency: transitive 415 | description: 416 | name: stream_channel 417 | sha256: "969e04c80b8bcdf826f8f16579c7b14d780458bd97f56d107d3950fdbeef059d" 418 | url: "https://pub.dev" 419 | source: hosted 420 | version: "2.1.4" 421 | string_scanner: 422 | dependency: transitive 423 | description: 424 | name: string_scanner 425 | sha256: "921cd31725b72fe181906c6a94d987c78e3b98c2e205b397ea399d4054872b43" 426 | url: "https://pub.dev" 427 | source: hosted 428 | version: "1.4.1" 429 | term_glyph: 430 | dependency: transitive 431 | description: 432 | name: term_glyph 433 | sha256: "7f554798625ea768a7518313e58f83891c7f5024f88e46e7182a4558850a4b8e" 434 | url: "https://pub.dev" 435 | source: hosted 436 | version: "1.2.2" 437 | test_api: 438 | dependency: transitive 439 | description: 440 | name: test_api 441 | sha256: fb31f383e2ee25fbbfe06b40fe21e1e458d14080e3c67e7ba0acfde4df4e0bbd 442 | url: "https://pub.dev" 443 | source: hosted 444 | version: "0.7.4" 445 | typed_data: 446 | dependency: transitive 447 | description: 448 | name: typed_data 449 | sha256: "53bdf7e979cfbf3e28987552fd72f637e63f3c8724c9e56d9246942dc2fa36ee" 450 | url: "https://pub.dev" 451 | source: hosted 452 | version: "1.3.0" 453 | vector_math: 454 | dependency: transitive 455 | description: 456 | name: vector_math 457 | sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803" 458 | url: "https://pub.dev" 459 | source: hosted 460 | version: "2.1.4" 461 | vm_service: 462 | dependency: transitive 463 | description: 464 | name: vm_service 465 | sha256: "0968250880a6c5fe7edc067ed0a13d4bae1577fe2771dcf3010d52c4a9d3ca14" 466 | url: "https://pub.dev" 467 | source: hosted 468 | version: "14.3.1" 469 | watcher: 470 | dependency: transitive 471 | description: 472 | name: watcher 473 | sha256: "69da27e49efa56a15f8afe8f4438c4ec02eff0a117df1b22ea4aad194fe1c104" 474 | url: "https://pub.dev" 475 | source: hosted 476 | version: "1.1.1" 477 | web: 478 | dependency: transitive 479 | description: 480 | name: web 481 | sha256: "868d88a33d8a87b18ffc05f9f030ba328ffefba92d6c127917a2ba740f9cfe4a" 482 | url: "https://pub.dev" 483 | source: hosted 484 | version: "1.1.1" 485 | yaml: 486 | dependency: transitive 487 | description: 488 | name: yaml 489 | sha256: "3cee79b1715110341012d27756d9bae38e650588acd38d3f3c610822e1337ace" 490 | url: "https://pub.dev" 491 | source: hosted 492 | version: "3.1.0" 493 | sdks: 494 | dart: ">=3.7.0-0 <4.0.0" 495 | flutter: ">=3.24.0" 496 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: flutterwave_standard 2 | description: Flutterwave's official library that wraps the standard implementation. 3 | version: 1.1.0 4 | homepage: https://github.com/Flutterwave/flutter_standard 5 | environment: 6 | sdk: ">=2.17.0 <4.0.0" 7 | flutter: ">=1.17.0" 8 | 9 | dependencies: 10 | flutter: 11 | sdk: flutter 12 | 13 | http: ^1.3.0 14 | fluttertoast: ^8.2.12 15 | flutter_inappwebview: ^6.1.5 16 | 17 | dev_dependencies: 18 | flutter_test: 19 | sdk: flutter 20 | 21 | mockito: ^5.0.15 22 | 23 | # For information on the generic Dart part of this file, see the 24 | # following page: https://dart.dev/tools/pub/pubspec 25 | 26 | # The following section is specific to Flutter. 27 | flutter: 28 | 29 | # To add assets to your package, add an assets section, like this: 30 | # assets: 31 | # - images/a_dot_burr.jpeg 32 | # - images/a_dot_ham.jpeg 33 | # 34 | # For details regarding assets in packages, see 35 | # https://flutter.dev/assets-and-images/#from-packages 36 | # 37 | # An image asset can refer to one or more resolution-specific "variants", see 38 | # https://flutter.dev/assets-and-images/#resolution-aware. 39 | 40 | # To add custom fonts to your package, add a fonts section here, 41 | # in this "flutter" section. Each entry in this list should have a 42 | # "family" key with the font family name, and a "fonts" key with a 43 | # list giving the asset and other descriptors for the font. For 44 | # example: 45 | # fonts: 46 | # - family: Schyler 47 | # fonts: 48 | # - asset: fonts/Schyler-Regular.ttf 49 | # - asset: fonts/Schyler-Italic.ttf 50 | # style: italic 51 | # - family: Trajan Pro 52 | # fonts: 53 | # - asset: fonts/TrajanPro.ttf 54 | # - asset: fonts/TrajanPro_Bold.ttf 55 | # weight: 700 56 | # 57 | # For details regarding fonts in packages, see 58 | # https://flutter.dev/custom-fonts/#from-packages 59 | -------------------------------------------------------------------------------- /test/customer_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:flutterwave_standard/flutterwave.dart'; 3 | 4 | main() { 5 | group("Customer object", () { 6 | test("should initialize correctly when values are set", () { 7 | final email = "testEmail"; 8 | final phoneNumber = "123456789"; 9 | final name = "Random Name"; 10 | final customer = Customer(email: email, name: name, phoneNumber: phoneNumber); 11 | 12 | expect(email, customer.email); 13 | expect(phoneNumber, customer.phoneNumber); 14 | expect(name, customer.name); 15 | 16 | final customerHashmap = { 17 | "email": email, 18 | "phonenumber": phoneNumber, 19 | "name": name 20 | }; 21 | expect(customerHashmap.toString(), customer.toJson().toString()); 22 | 23 | }); 24 | 25 | test("should initialize correctly when required value is set", () { 26 | final email = "testEmail"; 27 | final customer = Customer(email: email); 28 | 29 | expect(email, customer.email); 30 | expect(true, customer.phoneNumber == null); 31 | expect(true, customer.name == null); 32 | 33 | final customerHashmap = { "email": email }; 34 | expect(customerHashmap.toString(), customer.toJson().toString()); 35 | }); 36 | 37 | }); 38 | } --------------------------------------------------------------------------------