├── example ├── linux │ ├── .gitignore │ ├── main.cc │ ├── flutter │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ ├── my_application.h │ └── my_application.cc ├── ios │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── .gitignore │ ├── Podfile.lock │ └── Podfile ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── manifest.json │ └── index.html ├── android │ ├── gradle.properties │ ├── app │ │ ├── src │ │ │ ├── main │ │ │ │ ├── res │ │ │ │ │ ├── mipmap-hdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-mdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── mipmap-xxxhdpi │ │ │ │ │ │ └── ic_launcher.png │ │ │ │ │ ├── drawable │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── drawable-v21 │ │ │ │ │ │ └── launch_background.xml │ │ │ │ │ ├── values │ │ │ │ │ │ └── styles.xml │ │ │ │ │ └── values-night │ │ │ │ │ │ └── styles.xml │ │ │ │ ├── kotlin │ │ │ │ │ └── com │ │ │ │ │ │ └── example │ │ │ │ │ │ └── example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── gradle │ │ └── wrapper │ │ │ └── gradle-wrapper.properties │ ├── .gitignore │ ├── settings.gradle │ └── build.gradle ├── macos │ ├── Runner │ │ ├── Configs │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── Warnings.xcconfig │ │ │ └── AppInfo.xcconfig │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_64.png │ │ │ │ ├── app_icon_1024.png │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_512.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Release.entitlements │ │ ├── DebugProfile.entitlements │ │ ├── MainFlutterWindow.swift │ │ └── Info.plist │ ├── .gitignore │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ └── Podfile ├── windows │ ├── runner │ │ ├── resources │ │ │ └── app_icon.ico │ │ ├── resource.h │ │ ├── utils.h │ │ ├── runner.exe.manifest │ │ ├── flutter_window.h │ │ ├── main.cpp │ │ ├── CMakeLists.txt │ │ ├── utils.cpp │ │ ├── flutter_window.cpp │ │ ├── Runner.rc │ │ └── win32_window.h │ ├── .gitignore │ ├── flutter │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ └── CMakeLists.txt ├── lib │ ├── models │ │ ├── my_store_model.dart │ │ ├── custom_error_message.dart │ │ ├── my_version_response_model.dart │ │ └── custom_info_message.dart │ └── services │ │ └── my_version_convert_manager.dart ├── pubspec.yaml ├── README.md ├── .gitignore ├── test │ └── widget_test.dart ├── analysis_options.yaml └── .metadata ├── lib ├── src │ ├── utils │ │ ├── enums │ │ │ ├── check_version_loading_type.dart │ │ │ └── app_platform.dart │ │ ├── mixins │ │ │ ├── platform │ │ │ │ ├── platform_decider_mixin.dart │ │ │ │ ├── platform_decider_mixin_web.dart │ │ │ │ └── platform_decider_mixin_io.dart │ │ │ ├── http_header_key_value_mixin.dart │ │ │ ├── launch_url_mixin.dart │ │ │ ├── version_dialog_mixin.dart │ │ │ ├── version_result_validator_mixin.dart │ │ │ ├── package_info_mixin.dart │ │ │ ├── bundle_id_controller_mixin.dart │ │ │ ├── version_compare_mixin.dart │ │ │ └── custom_version_comparator_view_state_mixin.dart │ │ ├── extensions │ │ │ ├── string_extension.dart │ │ │ └── iterable_extension.dart │ │ ├── messages │ │ │ ├── default_comparator_info_message.dart │ │ │ ├── default_comparator_error_message.dart │ │ │ ├── comparator_info_message.dart │ │ │ └── comparator_error_message.dart │ │ ├── index.dart │ │ ├── helpers │ │ │ ├── regexp_helper.dart │ │ │ └── version_compare_service_factory.dart │ │ ├── constants │ │ │ ├── endpoint_constants.dart │ │ │ └── constants.dart │ │ └── results │ │ │ ├── result.dart │ │ │ └── data_result.dart │ ├── models │ │ ├── entities │ │ │ ├── store │ │ │ │ ├── base_store_model.dart │ │ │ │ ├── ios_store_model.dart │ │ │ │ ├── android_store_model.dart │ │ │ │ ├── huawei_store_model.dart │ │ │ │ └── custom_store_model.dart │ │ │ ├── entity_model.dart │ │ │ ├── huawei │ │ │ │ ├── huawei_app_data_model.g.dart │ │ │ │ ├── huawei_layout_data_model.g.dart │ │ │ │ ├── huawei_version_entity_model.g.dart │ │ │ │ ├── huawei_app_data_model.dart │ │ │ │ ├── huawei_layout_data_model.dart │ │ │ │ └── huawei_version_entity_model.dart │ │ │ ├── empty_entity_model.dart │ │ │ ├── ios_version_entity_model.g.dart │ │ │ └── ios_version_entity_model.dart │ │ ├── parameters │ │ │ ├── get_data_service_parameter_model.dart │ │ │ ├── service_parameter_model.dart │ │ │ ├── send_data_service_parameter_model.dart │ │ │ └── custom_version_compare_parameter_model.dart │ │ ├── index.dart │ │ └── version_response_model.dart │ ├── widgets │ │ ├── index.dart │ │ ├── version_result_error_dialog_content.dart │ │ ├── column_by_space.dart │ │ ├── default_check_version_progress.dart │ │ ├── check_version_progress_dialog.dart │ │ └── platform_specific_version_comparator_view.dart │ └── services │ │ ├── abstracts │ │ ├── version_convert_service.dart │ │ ├── remote_data_service.dart │ │ ├── version_comparator_state.dart │ │ ├── version_dialog_service.dart │ │ ├── huawei_version_compare_service.dart │ │ └── version_compare_service.dart │ │ ├── concretes │ │ ├── ios │ │ │ ├── ios_version_convert_manager.dart │ │ │ └── ios_version_compare_manager.dart │ │ ├── huawei │ │ │ ├── huawei_version_convert_manager.dart │ │ │ └── huawei_version_compare_manager.dart │ │ ├── android │ │ │ ├── android_version_convert_manager.dart │ │ │ └── android_version_compare_manager.dart │ │ ├── custom │ │ │ └── custom_version_compare_manager.dart │ │ └── http_remote_data_manager.dart │ │ └── index.dart └── version_comparator.dart ├── analysis_options.yaml ├── .metadata ├── .flutter-plugins ├── pubspec.yaml ├── CHANGELOG.md ├── LICENSE ├── .gitignore ├── test ├── version_comparator_test.dart └── utils │ └── mixins │ └── version_compare_mixin_test.dart └── .flutter-plugins-dependencies /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/web/favicon.png -------------------------------------------------------------------------------- /lib/src/utils/enums/check_version_loading_type.dart: -------------------------------------------------------------------------------- 1 | enum CheckVersionLoadingType { alertDialog, widget } 2 | -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx1536M 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /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/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/web/icons/Icon-maskable-512.png -------------------------------------------------------------------------------- /example/macos/.gitignore: -------------------------------------------------------------------------------- 1 | # Flutter-related 2 | **/Flutter/ephemeral/ 3 | **/Pods/ 4 | 5 | # Xcode-related 6 | **/dgph 7 | **/xcuserdata/ 8 | -------------------------------------------------------------------------------- /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/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /lib/src/utils/mixins/platform/platform_decider_mixin.dart: -------------------------------------------------------------------------------- 1 | export 'platform_decider_mixin_io.dart' 2 | if (dart.library.html) 'platform_decider_mixin_web.dart'; 3 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/models/entities/store/base_store_model.dart: -------------------------------------------------------------------------------- 1 | abstract class BaseStoreModel { 2 | String get storeUrl; 3 | String get appId; 4 | String get versionQuery; 5 | } 6 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /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/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | 3 | # Additional information about this file can be found at 4 | # https://dart.dev/guides/language/analysis-options 5 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@3x.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /lib/src/models/entities/entity_model.dart: -------------------------------------------------------------------------------- 1 | abstract class EntityModel { 2 | String get responseBody; 3 | TModel fromJson(Map json); 4 | Map toJson(); 5 | } 6 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/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/E-MRE/version_comparator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/E-MRE/version_comparator/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /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 | } 7 | -------------------------------------------------------------------------------- /example/linux/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/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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-7.5-all.zip 6 | -------------------------------------------------------------------------------- /lib/src/utils/extensions/string_extension.dart: -------------------------------------------------------------------------------- 1 | extension StringExtension on String? { 2 | bool get isNullOrEmpty { 3 | if (this == null) return true; 4 | 5 | return this!.isEmpty; 6 | } 7 | 8 | bool get isNotNullAndNotEmpty => !isNullOrEmpty; 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/widgets/index.dart: -------------------------------------------------------------------------------- 1 | export 'version_compare_wrapper.dart'; 2 | export 'check_version_progress_dialog.dart'; 3 | export 'default_check_version_progress.dart'; 4 | export 'custom_version_comparator_view.dart'; 5 | export 'platform_specific_version_comparator_view.dart'; 6 | -------------------------------------------------------------------------------- /example/macos/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | @NSApplicationMain 5 | class AppDelegate: FlutterAppDelegate { 6 | override func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool { 7 | return true 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /lib/src/services/abstracts/version_convert_service.dart: -------------------------------------------------------------------------------- 1 | import '../../models/entities/entity_model.dart'; 2 | import '../../utils/results/data_result.dart'; 3 | 4 | abstract class VersionConvertService> { 5 | DataResult convert(TData entity); 6 | } 7 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.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/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.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: b8f7f1f9869bb2d116aa6a70dbeac61000b52849 8 | channel: stable 9 | 10 | project_type: package 11 | -------------------------------------------------------------------------------- /lib/src/utils/extensions/iterable_extension.dart: -------------------------------------------------------------------------------- 1 | extension IterableExtension on Iterable { 2 | /// The first element satisfying [test], or `null` if there are none. 3 | T? firstWhereOrNull(bool Function(T element) test) { 4 | for (var element in this) { 5 | if (test(element)) return element; 6 | } 7 | return null; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | gradle-wrapper.jar 2 | /.gradle 3 | /captures/ 4 | /gradlew 5 | /gradlew.bat 6 | /local.properties 7 | GeneratedPluginRegistrant.java 8 | 9 | # Remember to never publicly share your keystore. 10 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 11 | key.properties 12 | **/*.keystore 13 | **/*.jks 14 | -------------------------------------------------------------------------------- /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/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/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/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/lib/models/my_store_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:version_comparator/version_comparator.dart'; 2 | 3 | class MyStoreModel extends BaseStoreModel { 4 | @override 5 | final String appId; 6 | 7 | MyStoreModel({required this.appId}); 8 | 9 | @override 10 | String get storeUrl => 'https://itunes.apple.com/lookup'; 11 | 12 | @override 13 | String get versionQuery => 'bundleId=com.mars.FocusId'; 14 | } 15 | -------------------------------------------------------------------------------- /example/lib/models/custom_error_message.dart: -------------------------------------------------------------------------------- 1 | import 'package:version_comparator/version_comparator.dart'; 2 | 3 | class CustomErrorMessage extends ComparatorErrorMessage { 4 | @override 5 | String get appNotFound => 'App not found in the store.'; 6 | 7 | @override 8 | String get appVersionFetchError => 'Fetch error'; 9 | 10 | @override 11 | String get appBundleIdFetchError => 'App bundle id could\'t fetch.'; 12 | } 13 | -------------------------------------------------------------------------------- /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 | UrlLauncherWindowsRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("UrlLauncherWindows")); 14 | } 15 | -------------------------------------------------------------------------------- /lib/src/utils/messages/default_comparator_info_message.dart: -------------------------------------------------------------------------------- 1 | import 'comparator_info_message.dart'; 2 | 3 | class DefaultComparatorInfoMessage extends ComparatorInfoMessage { 4 | static DefaultComparatorInfoMessage? _instance; 5 | static DefaultComparatorInfoMessage get instance { 6 | _instance ??= DefaultComparatorInfoMessage._init(); 7 | return _instance!; 8 | } 9 | 10 | DefaultComparatorInfoMessage._init(); 11 | } 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/utils/messages/default_comparator_error_message.dart: -------------------------------------------------------------------------------- 1 | import 'comparator_error_message.dart'; 2 | 3 | class DefaultComparatorErrorMessage extends ComparatorErrorMessage { 4 | static DefaultComparatorErrorMessage? _instance; 5 | static DefaultComparatorErrorMessage get instance { 6 | _instance ??= DefaultComparatorErrorMessage._init(); 7 | return _instance!; 8 | } 9 | 10 | DefaultComparatorErrorMessage._init(); 11 | } 12 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/models/parameters/get_data_service_parameter_model.dart: -------------------------------------------------------------------------------- 1 | import 'service_parameter_model.dart'; 2 | 3 | class GetDataServiceParameterModel extends ServiceParameterModel { 4 | final String? query; 5 | 6 | GetDataServiceParameterModel({ 7 | required super.url, 8 | this.query, 9 | super.timeout, 10 | super.header, 11 | }); 12 | 13 | @override 14 | String getUrl() { 15 | return query?.isEmpty ?? true ? url : '$url?$query'; 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /lib/src/models/index.dart: -------------------------------------------------------------------------------- 1 | export 'version_response_model.dart'; 2 | export 'entities/entity_model.dart'; 3 | export 'entities/empty_entity_model.dart'; 4 | export 'entities/store/base_store_model.dart'; 5 | export 'entities/store/android_store_model.dart'; 6 | export 'entities/store/ios_store_model.dart'; 7 | export 'entities/store/huawei_store_model.dart'; 8 | export 'parameters/custom_version_compare_parameter_model.dart'; 9 | export 'parameters/service_parameter_model.dart'; 10 | -------------------------------------------------------------------------------- /lib/src/utils/index.dart: -------------------------------------------------------------------------------- 1 | export 'results/result.dart'; 2 | export 'results/data_result.dart'; 3 | export 'enums/app_platform.dart'; 4 | export 'enums/check_version_loading_type.dart'; 5 | export 'helpers/regexp_helper.dart'; 6 | export 'messages/comparator_error_message.dart'; 7 | export 'messages/comparator_info_message.dart'; 8 | export 'mixins/platform/platform_decider_mixin.dart'; 9 | export 'mixins/version_compare_mixin.dart'; 10 | export 'mixins/version_dialog_mixin.dart'; 11 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import UIKit 2 | import Flutter 3 | 4 | @UIApplicationMain 5 | @objc class AppDelegate: FlutterAppDelegate { 6 | override func application( 7 | _ application: UIApplication, 8 | didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? 9 | ) -> Bool { 10 | GeneratedPluginRegistrant.register(with: self) 11 | return super.application(application, didFinishLaunchingWithOptions: launchOptions) 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /example/linux/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/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController.init() 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/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: example 2 | description: A new Flutter project. 3 | publish_to: 'none' 4 | 5 | version: 1.0.0+1 6 | 7 | environment: 8 | sdk: '>=3.0.0 <4.0.0' 9 | 10 | dependencies: 11 | flutter: 12 | sdk: flutter 13 | 14 | version_comparator: 15 | path: ../ 16 | 17 | cupertino_icons: ^1.0.2 18 | 19 | dev_dependencies: 20 | flutter_test: 21 | sdk: flutter 22 | 23 | flutter_lints: ^2.0.0 24 | 25 | 26 | flutter: 27 | 28 | uses-material-design: true 29 | -------------------------------------------------------------------------------- /lib/src/models/parameters/service_parameter_model.dart: -------------------------------------------------------------------------------- 1 | import '../../utils/constants/constants.dart'; 2 | 3 | abstract class ServiceParameterModel { 4 | final String url; 5 | final int timeout; 6 | final Map? header; 7 | 8 | String getUrl(); 9 | 10 | Duration get timeoutDuration => Duration(milliseconds: timeout.toInt()); 11 | 12 | ServiceParameterModel({ 13 | required this.url, 14 | this.timeout = kDefaultTimeout, 15 | this.header, 16 | }); 17 | } 18 | -------------------------------------------------------------------------------- /lib/src/models/parameters/send_data_service_parameter_model.dart: -------------------------------------------------------------------------------- 1 | import '../entities/entity_model.dart'; 2 | import 'service_parameter_model.dart'; 3 | 4 | class SendDataServiceParameterModel> 5 | extends ServiceParameterModel { 6 | final TData body; 7 | 8 | SendDataServiceParameterModel({ 9 | required super.url, 10 | required this.body, 11 | super.timeout, 12 | super.header, 13 | }); 14 | 15 | @override 16 | String getUrl() => url; 17 | } 18 | -------------------------------------------------------------------------------- /lib/src/utils/helpers/regexp_helper.dart: -------------------------------------------------------------------------------- 1 | class RegExpHelper { 2 | static RegExp get androidVersionRegExp => RegExp(r',\[\[\["([0-9,\.]*)"]],'); 3 | static RegExp get androidVersionWithAlphabetRegExp => 4 | RegExp(r'
[0-9.a-zA-Z]+<\/div>'); 5 | static RegExp get onlyNumericVersionRegExp => RegExp(r'[0-9.]'); 6 | 7 | static bool isVersionOnlyNumeric(String version) { 8 | return onlyNumericVersionRegExp.allMatches(version).length == 9 | version.length; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /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/android/settings.gradle: -------------------------------------------------------------------------------- 1 | include ':app' 2 | 3 | def localPropertiesFile = new File(rootProject.projectDir, "local.properties") 4 | def properties = new Properties() 5 | 6 | assert localPropertiesFile.exists() 7 | localPropertiesFile.withReader("UTF-8") { reader -> properties.load(reader) } 8 | 9 | def flutterSdkPath = properties.getProperty("flutter.sdk") 10 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 11 | apply from: "$flutterSdkPath/packages/flutter_tools/gradle/app_plugin_loader.gradle" 12 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /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 | #include 10 | 11 | void fl_register_plugins(FlPluginRegistry* registry) { 12 | g_autoptr(FlPluginRegistrar) url_launcher_linux_registrar = 13 | fl_plugin_registry_get_registrar_for_plugin(registry, "UrlLauncherPlugin"); 14 | url_launcher_plugin_register_with_registrar(url_launcher_linux_registrar); 15 | } 16 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/http_header_key_value_mixin.dart: -------------------------------------------------------------------------------- 1 | mixin HttpHeaderKeyValueMixin { 2 | static const contentTypeKey = 'content-type'; 3 | static const interfaceCodeKey = 'interface-code'; 4 | static const applicationJsonValue = 'application/json'; 5 | 6 | MapEntry getApplicationJsonContentTypeEntry() => 7 | const MapEntry(contentTypeKey, applicationJsonValue); 8 | 9 | MapEntry getInterfaceCodeEntry(String code) => 10 | MapEntry(interfaceCodeKey, code); 11 | } 12 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/utils/constants/endpoint_constants.dart: -------------------------------------------------------------------------------- 1 | class EndpointConstants { 2 | static const String androidStoreUrl = 3 | 'https://play.google.com/store/apps/details'; 4 | static const String iosStoreUrl = 'https://itunes.apple.com/lookup'; 5 | static const String huaweiStoreUrl = 'https://appgallery.huawei.com/app'; 6 | static const String huaweiVersionControlUrl = 7 | 'https://web-dre.hispace.dbankcloud.cn/uowap/index'; 8 | static const String huaweiInterfaceCodeUrl = 9 | 'https://web-dre.hispace.dbankcloud.cn/webedge/getInterfaceCode'; 10 | } 11 | -------------------------------------------------------------------------------- /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/macos/Flutter/GeneratedPluginRegistrant.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | import FlutterMacOS 6 | import Foundation 7 | 8 | import device_info_plus 9 | import package_info_plus 10 | import url_launcher_macos 11 | 12 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 13 | DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) 14 | FLTPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FLTPackageInfoPlusPlugin")) 15 | UrlLauncherPlugin.register(with: registry.registrar(forPlugin: "UrlLauncherPlugin")) 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/utils/enums/app_platform.dart: -------------------------------------------------------------------------------- 1 | /// Enum representing different application platforms. 2 | /// 3 | /// The available platforms are: 4 | /// - `android`: Represents the Android platform. 5 | /// - `ios`: Represents the iOS platform. 6 | /// - `huawei`: Represents the Huawei platform. 7 | /// - `web`: Represents web applications. 8 | /// - `windows`: Represents the Windows platform. 9 | /// - `linux`: Represents the Linux platform. 10 | /// - `macOs`: Represents the macOS platform. 11 | /// - `invalid`: Represents an invalid or unsupported platform. 12 | enum AppPlatform { android, ios, huawei, web, windows, linux, macOs, invalid } 13 | -------------------------------------------------------------------------------- /lib/src/models/entities/store/ios_store_model.dart: -------------------------------------------------------------------------------- 1 | import '../../../utils/constants/endpoint_constants.dart'; 2 | import 'base_store_model.dart'; 3 | 4 | class IosStoreModel extends BaseStoreModel { 5 | @override 6 | final String storeUrl; 7 | @override 8 | final String appId; 9 | @override 10 | final String versionQuery; 11 | 12 | IosStoreModel.custom( 13 | {required this.storeUrl, 14 | required this.appId, 15 | required this.versionQuery}); 16 | 17 | IosStoreModel(String bundleId) 18 | : appId = bundleId, 19 | versionQuery = 'bundleId=$bundleId', 20 | storeUrl = EndpointConstants.iosStoreUrl; 21 | } 22 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/models/entities/store/android_store_model.dart: -------------------------------------------------------------------------------- 1 | import '../../../utils/constants/endpoint_constants.dart'; 2 | import 'base_store_model.dart'; 3 | 4 | class AndroidStoreModel extends BaseStoreModel { 5 | @override 6 | final String storeUrl; 7 | @override 8 | final String appId; 9 | @override 10 | final String versionQuery; 11 | 12 | AndroidStoreModel.custom( 13 | {required this.storeUrl, 14 | required this.appId, 15 | required this.versionQuery}); 16 | 17 | AndroidStoreModel(String bundleId) 18 | : appId = bundleId, 19 | versionQuery = 'id=$bundleId', 20 | storeUrl = EndpointConstants.androidStoreUrl; 21 | } 22 | -------------------------------------------------------------------------------- /lib/src/models/entities/store/huawei_store_model.dart: -------------------------------------------------------------------------------- 1 | import '../../../utils/constants/endpoint_constants.dart'; 2 | import 'base_store_model.dart'; 3 | 4 | class HuaweiStoreModel extends BaseStoreModel { 5 | @override 6 | final String storeUrl; 7 | @override 8 | final String appId; 9 | @override 10 | final String versionQuery; 11 | 12 | HuaweiStoreModel.custom( 13 | {required this.storeUrl, 14 | required this.appId, 15 | required this.versionQuery}); 16 | 17 | HuaweiStoreModel(this.appId) 18 | : versionQuery = 'method=internal.getTabDetail&uri=app%7C$appId', 19 | storeUrl = EndpointConstants.huaweiVersionControlUrl; 20 | } 21 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/launch_url_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:url_launcher/url_launcher.dart'; 2 | 3 | import '../constants/constants.dart'; 4 | import '../results/result.dart'; 5 | 6 | mixin LaunchUrlMixin { 7 | Future launchStoreLink(String storeLink) async { 8 | if (await canLaunchUrl(Uri.parse(storeLink))) { 9 | final isLaunched = await launchUrl(Uri.parse(storeLink), 10 | mode: LaunchMode.externalApplication); 11 | return isLaunched 12 | ? Result.success() 13 | : Result.error(message: kErrorMessage.notLaunchUrl); 14 | } else { 15 | return Result.error(message: kErrorMessage.notLaunchUrl); 16 | } 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /lib/src/services/concretes/ios/ios_version_convert_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/ios_version_entity_model.dart'; 2 | import '../../../utils/constants/constants.dart'; 3 | import '../../../utils/results/data_result.dart'; 4 | import '../../abstracts/version_convert_service.dart'; 5 | 6 | class IosVersionConvertManager 7 | extends VersionConvertService { 8 | @override 9 | DataResult convert(IosVersionEntityModel entity) { 10 | if (entity.storeVersion.isEmpty) { 11 | return DataResult.error(message: kErrorMessage.versionNotMatch); 12 | } 13 | 14 | return DataResult.success(data: entity.storeVersion); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/services/index.dart: -------------------------------------------------------------------------------- 1 | export 'abstracts/base_version_comparator.dart'; 2 | export 'abstracts/remote_data_service.dart'; 3 | export 'abstracts/version_compare_service.dart'; 4 | export 'abstracts/version_convert_service.dart'; 5 | export 'abstracts/version_dialog_service.dart'; 6 | export 'abstracts/version_comparator_view.dart'; 7 | export 'abstracts/version_comparator_state.dart'; 8 | export 'concretes/custom/custom_version_compare_manager.dart'; 9 | export 'concretes/version_dialog_manager.dart'; 10 | export 'concretes/android/android_version_convert_manager.dart'; 11 | export 'concretes/ios/ios_version_convert_manager.dart'; 12 | export 'concretes/http_remote_data_manager.dart'; 13 | -------------------------------------------------------------------------------- /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 © 2023 com.example. All rights reserved. 15 | -------------------------------------------------------------------------------- /lib/src/services/abstracts/remote_data_service.dart: -------------------------------------------------------------------------------- 1 | import '../../models/entities/entity_model.dart'; 2 | import '../../models/parameters/get_data_service_parameter_model.dart'; 3 | import '../../models/parameters/send_data_service_parameter_model.dart'; 4 | import '../../utils/results/data_result.dart'; 5 | import '../../utils/results/result.dart'; 6 | 7 | abstract class RemoteDataService { 8 | Map get baseHeader => {'content-type': 'application/json'}; 9 | 10 | Future> getData( 11 | GetDataServiceParameterModel parameterModel); 12 | 13 | Future sendData>( 14 | SendDataServiceParameterModel parameterModel); 15 | } 16 | -------------------------------------------------------------------------------- /lib/src/services/concretes/huawei/huawei_version_convert_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/huawei/huawei_version_entity_model.dart'; 2 | import '../../../utils/constants/constants.dart'; 3 | import '../../../utils/results/data_result.dart'; 4 | import '../../abstracts/version_convert_service.dart'; 5 | 6 | class HuaweiVersionConvertManager 7 | extends VersionConvertService { 8 | @override 9 | DataResult convert(HuaweiVersionEntityModel entity) { 10 | final version = entity.storeVersion; 11 | 12 | return version.isEmpty 13 | ? DataResult.error(message: kErrorMessage.versionNotMatch) 14 | : DataResult.success(data: version); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/platform/platform_decider_mixin_web.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/foundation.dart'; 2 | import 'package:version_comparator/version_comparator.dart'; 3 | 4 | /// This mixin decides which platform runs app. 5 | mixin PlatformDeciderMixin { 6 | /// Determines the platform on which the app is running. 7 | /// 8 | /// If the app is running on the web, it returns [AppPlatform.web]. 9 | /// Otherwise, it returns [AppPlatform.invalid]. 10 | /// 11 | /// Returns a [Future] that completes with the determined [AppPlatform]. 12 | Future getPlatform() async { 13 | if (kIsWeb) { 14 | return AppPlatform.web; 15 | } 16 | 17 | return AppPlatform.invalid; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/version_dialog_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../models/version_response_model.dart'; 4 | import '../../services/abstracts/version_dialog_service.dart'; 5 | 6 | mixin VersionDialogMixin { 7 | VersionDialogService get dialogService; 8 | 9 | Future showSimpleVersionDialog( 10 | BuildContext context, 11 | VersionResponseModel versionModel, { 12 | T? result, 13 | bool isUpdateRequired = false, 14 | }) async { 15 | return await dialogService.showVersionDialog( 16 | context: context, 17 | popResult: result, 18 | versionModel: versionModel, 19 | isUpdateRequired: isUpdateRequired, 20 | ); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /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/android/build.gradle: -------------------------------------------------------------------------------- 1 | buildscript { 2 | ext.kotlin_version = '1.7.10' 3 | repositories { 4 | google() 5 | mavenCentral() 6 | } 7 | 8 | dependencies { 9 | classpath 'com.android.tools.build:gradle:7.2.0' 10 | classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" 11 | } 12 | } 13 | 14 | allprojects { 15 | repositories { 16 | google() 17 | mavenCentral() 18 | } 19 | } 20 | 21 | rootProject.buildDir = '../build' 22 | subprojects { 23 | project.buildDir = "${rootProject.buildDir}/${project.name}" 24 | } 25 | subprojects { 26 | project.evaluationDependsOn(':app') 27 | } 28 | 29 | tasks.register("clean", Delete) { 30 | delete rootProject.buildDir 31 | } 32 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/models/parameters/custom_version_compare_parameter_model.dart: -------------------------------------------------------------------------------- 1 | import '../../services/abstracts/version_convert_service.dart'; 2 | import '../entities/entity_model.dart'; 3 | import '../entities/store/base_store_model.dart'; 4 | 5 | class CustomVersionCompareParameterModel> { 6 | final TData parseModel; 7 | final String currentAppVersion; 8 | final VersionConvertService versionConvertService; 9 | final BaseStoreModel store; 10 | final String? Function(TData parseModel)? updateLinkGetter; 11 | 12 | CustomVersionCompareParameterModel({ 13 | required this.parseModel, 14 | required this.currentAppVersion, 15 | required this.versionConvertService, 16 | required this.store, 17 | this.updateLinkGetter, 18 | }); 19 | } 20 | -------------------------------------------------------------------------------- /lib/src/models/entities/huawei/huawei_app_data_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'huawei_app_data_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | HuaweiAppDataModel _$HuaweiAppDataModelFromJson(Map json) => 10 | HuaweiAppDataModel( 11 | package: json['package'] as String?, 12 | versionName: json['versionName'] as String?, 13 | ); 14 | 15 | Map _$HuaweiAppDataModelToJson(HuaweiAppDataModel instance) => 16 | { 17 | 'versionName': instance.versionName, 18 | 'package': instance.package, 19 | }; 20 | -------------------------------------------------------------------------------- /lib/src/widgets/version_result_error_dialog_content.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../utils/constants/constants.dart'; 4 | 5 | class VersionResultErrorDialogContent extends StatelessWidget { 6 | const VersionResultErrorDialogContent( 7 | {super.key, required this.content, required this.onPressed}); 8 | 9 | final String content; 10 | final VoidCallback onPressed; 11 | 12 | @override 13 | Widget build(BuildContext context) { 14 | return AlertDialog( 15 | title: Text(kInfoMessage.checkVersionErrorDialogTitle), 16 | content: Text(content), 17 | actions: [ 18 | TextButton( 19 | onPressed: onPressed, 20 | child: Text(kInfoMessage.checkVersionOkAction)) 21 | ], 22 | ); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/models/entities/empty_entity_model.dart: -------------------------------------------------------------------------------- 1 | import 'entity_model.dart'; 2 | 3 | class EmptyEntityModel extends EntityModel { 4 | @override 5 | final String responseBody; 6 | 7 | final Map jsonData; 8 | 9 | EmptyEntityModel({required this.jsonData, required this.responseBody}); 10 | 11 | EmptyEntityModel.empty() 12 | : jsonData = {}, 13 | responseBody = ''; 14 | 15 | factory EmptyEntityModel.fromResponse(String body) { 16 | return EmptyEntityModel(jsonData: {'data': body}, responseBody: body); 17 | } 18 | 19 | @override 20 | EmptyEntityModel fromJson(Map json) { 21 | return EmptyEntityModel(jsonData: json, responseBody: responseBody); 22 | } 23 | 24 | @override 25 | Map toJson() => jsonData; 26 | } 27 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/version_result_validator_mixin.dart: -------------------------------------------------------------------------------- 1 | import '../../models/version_response_model.dart'; 2 | import '../constants/constants.dart'; 3 | import '../results/data_result.dart'; 4 | import '../results/result.dart'; 5 | 6 | mixin VersionResultValidatorMixin { 7 | Result isVersionResultValid(DataResult result) { 8 | if (result.isNotSuccess) { 9 | return Result.error( 10 | message: result.message.isEmpty 11 | ? kErrorMessage.appNotFound 12 | : result.message); 13 | } else if (result.data == null) { 14 | return Result.error( 15 | message: result.message.isEmpty 16 | ? kErrorMessage.versionResponseNull 17 | : result.message); 18 | } 19 | 20 | return Result.success(); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /lib/src/models/entities/huawei/huawei_layout_data_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'huawei_layout_data_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | HuaweiLayoutDataModel _$HuaweiLayoutDataModelFromJson( 10 | Map json) => 11 | HuaweiLayoutDataModel( 12 | dataList: (json['dataList'] as List?) 13 | ?.map((e) => HuaweiAppDataModel.fromJson(e as Map)) 14 | .toList(), 15 | ); 16 | 17 | Map _$HuaweiLayoutDataModelToJson( 18 | HuaweiLayoutDataModel instance) => 19 | { 20 | 'dataList': instance.dataList, 21 | }; 22 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_linux 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}/linux 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}/linux plugins/${ffi_plugin}) 23 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 24 | endforeach(ffi_plugin) 25 | -------------------------------------------------------------------------------- /example/lib/models/my_version_response_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:version_comparator/version_comparator.dart'; 2 | 3 | class MyVersionResponseModel extends EntityModel { 4 | @override 5 | final String responseBody; 6 | 7 | final Map jsonData; 8 | 9 | MyVersionResponseModel({required this.jsonData, required this.responseBody}); 10 | 11 | MyVersionResponseModel.empty() 12 | : jsonData = {}, 13 | responseBody = ''; 14 | 15 | factory MyVersionResponseModel.fromResponse(String body) { 16 | return MyVersionResponseModel(jsonData: {'data': body}, responseBody: body); 17 | } 18 | 19 | @override 20 | MyVersionResponseModel fromJson(Map json) { 21 | return MyVersionResponseModel(jsonData: json, responseBody: responseBody); 22 | } 23 | 24 | @override 25 | Map toJson() => jsonData; 26 | } 27 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | url_launcher_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 | -------------------------------------------------------------------------------- /lib/src/models/entities/huawei/huawei_version_entity_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'huawei_version_entity_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | HuaweiVersionEntityModel _$HuaweiVersionEntityModelFromJson( 10 | Map json) => 11 | HuaweiVersionEntityModel( 12 | layoutData: (json['layoutData'] as List?) 13 | ?.map( 14 | (e) => HuaweiLayoutDataModel.fromJson(e as Map)) 15 | .toList(), 16 | ); 17 | 18 | Map _$HuaweiVersionEntityModelToJson( 19 | HuaweiVersionEntityModel instance) => 20 | { 21 | 'layoutData': instance.layoutData, 22 | }; 23 | -------------------------------------------------------------------------------- /.flutter-plugins: -------------------------------------------------------------------------------- 1 | # This is a generated file; do not edit or check into version control. 2 | device_info_plus=/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/ 3 | package_info_plus=/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/ 4 | url_launcher=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher-6.3.1/ 5 | url_launcher_android=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_android-6.3.3/ 6 | url_launcher_ios=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.0/ 7 | url_launcher_linux=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.1/ 8 | url_launcher_macos=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_macos-3.2.0/ 9 | url_launcher_web=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_web-2.3.3/ 10 | url_launcher_windows=/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.1/ 11 | -------------------------------------------------------------------------------- /example/.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | migrate_working_dir/ 12 | 13 | # IntelliJ related 14 | *.iml 15 | *.ipr 16 | *.iws 17 | .idea/ 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 | **/ios/Flutter/.last_build_id 27 | .dart_tool/ 28 | .flutter-plugins 29 | .flutter-plugins-dependencies 30 | .packages 31 | .pub-cache/ 32 | .pub/ 33 | /build/ 34 | 35 | # Symbolication related 36 | app.*.symbols 37 | 38 | # Obfuscation related 39 | app.*.map.json 40 | 41 | # Android Studio will place build artifacts here 42 | /android/app/debug 43 | /android/app/profile 44 | /android/app/release 45 | -------------------------------------------------------------------------------- /lib/src/models/entities/ios_version_entity_model.g.dart: -------------------------------------------------------------------------------- 1 | // GENERATED CODE - DO NOT MODIFY BY HAND 2 | 3 | part of 'ios_version_entity_model.dart'; 4 | 5 | // ************************************************************************** 6 | // JsonSerializableGenerator 7 | // ************************************************************************** 8 | 9 | IosVersionEntityModel _$IosVersionEntityModelFromJson( 10 | Map json) => 11 | IosVersionEntityModel( 12 | resultCount: json['resultCount'] as int?, 13 | results: (json['results'] as List?) 14 | ?.map((e) => e as Map) 15 | .toList(), 16 | ); 17 | 18 | Map _$IosVersionEntityModelToJson( 19 | IosVersionEntityModel instance) => 20 | { 21 | 'resultCount': instance.resultCount, 22 | 'results': instance.results, 23 | }; 24 | -------------------------------------------------------------------------------- /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 | 11.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /lib/src/utils/results/result.dart: -------------------------------------------------------------------------------- 1 | import '../constants/constants.dart'; 2 | 3 | ///This class returns operation results with message. 4 | class Result { 5 | ///Operation result. 6 | final bool isSuccess; 7 | 8 | bool get isNotSuccess => !isSuccess; 9 | 10 | ///Operation message. Also it can use for error message. 11 | final String message; 12 | 13 | ///Customizable constructor 14 | Result({required this.isSuccess, required this.message}); 15 | 16 | ///Operation result is successful. Also you can add success message to [message] 17 | Result.success({this.message = kEmpty}) : isSuccess = true; 18 | 19 | ///Operation result is unsuccessful. You must add error message to [message] 20 | Result.error({required this.message}) : isSuccess = false; 21 | 22 | ///Operation result is unsuccessful. Error message is optional. 23 | Result.errorByEmptyMessage({this.message = kEmpty}) : isSuccess = false; 24 | } 25 | -------------------------------------------------------------------------------- /lib/src/services/abstracts/version_comparator_state.dart: -------------------------------------------------------------------------------- 1 | import '../../models/version_response_model.dart'; 2 | 3 | abstract class VersionComparatorState { 4 | const VersionComparatorState(); 5 | } 6 | 7 | class VersionComparatorInitialState extends VersionComparatorState { 8 | const VersionComparatorInitialState(); 9 | } 10 | 11 | class VersionComparatorLoadingState extends VersionComparatorState { 12 | const VersionComparatorLoadingState(); 13 | } 14 | 15 | class VersionComparatorSuccessState extends VersionComparatorState { 16 | const VersionComparatorSuccessState(this.data); 17 | 18 | final VersionResponseModel data; 19 | } 20 | 21 | class VersionComparatorErrorState extends VersionComparatorState { 22 | const VersionComparatorErrorState( 23 | {required this.message, this.data, required this.isOldVersionError}); 24 | 25 | final String message; 26 | final bool isOldVersionError; 27 | final VersionResponseModel? data; 28 | } 29 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: version_comparator 2 | description: An app version comparator between app stores and local version. It support Android, iOS and Huawei platforms. 3 | Also custom version compare is possible. 4 | repository: https://github.com/E-MRE/version_comparator/ 5 | issue_tracker: https://github.com/E-MRE/version_comparator/issues?q=is%3Aopen 6 | version: 1.0.23 7 | 8 | environment: 9 | sdk: '>=3.4.1 <4.0.0' 10 | flutter: ">=1.17.0" 11 | 12 | dependencies: 13 | flutter: 14 | sdk: flutter 15 | 16 | #Json Operations 17 | json_annotation: ^4.9.0 18 | 19 | #Networking 20 | http: ^1.3.0 21 | 22 | #Package & Device Info 23 | package_info_plus: ^8.2.0 24 | device_info_plus: ^11.2.2 25 | 26 | #Launch URL 27 | url_launcher: ^6.3.1 28 | 29 | dev_dependencies: 30 | flutter_test: 31 | sdk: flutter 32 | flutter_lints: ^4.0.0 33 | 34 | build_runner: ^2.4.11 35 | #Json Operation 36 | json_serializable: ^6.8.0 37 | 38 | flutter: 39 | -------------------------------------------------------------------------------- /example/lib/services/my_version_convert_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:version_comparator/version_comparator.dart'; 2 | 3 | import '../models/my_version_response_model.dart'; 4 | 5 | class MyVersionConvertManager 6 | extends VersionConvertService { 7 | @override 8 | DataResult convert(EntityModel entity) { 9 | final firstMatch = 10 | RegExpHelper.androidVersionRegExp.firstMatch(entity.responseBody); 11 | 12 | return _checkRegExpVersion(firstMatch); 13 | } 14 | 15 | DataResult _checkRegExpVersion(RegExpMatch? regExpMatch) { 16 | if (regExpMatch == null || regExpMatch.groupCount < 1) { 17 | return DataResult.error(message: 'Version not matched'); 18 | } 19 | 20 | final version = regExpMatch.group(1); 21 | return version == null || version.isEmpty 22 | ? DataResult.error(message: 'Version not matched') 23 | : DataResult.success(data: version); 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /example/windows/runner/runner.exe.manifest: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PerMonitorV2 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /lib/src/models/entities/huawei/huawei_app_data_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import '../../../utils/constants/constants.dart'; 4 | import '../entity_model.dart'; 5 | 6 | part 'huawei_app_data_model.g.dart'; 7 | 8 | @JsonSerializable() 9 | class HuaweiAppDataModel extends EntityModel { 10 | HuaweiAppDataModel({this.package, this.versionName, String? responseBody}) 11 | : responseBody = responseBody ?? kEmpty; 12 | 13 | final String? versionName; 14 | final String? package; 15 | 16 | @override 17 | @JsonKey(includeFromJson: false) 18 | final String responseBody; 19 | 20 | factory HuaweiAppDataModel.fromJson(Map json) => 21 | _$HuaweiAppDataModelFromJson(json); 22 | 23 | @override 24 | HuaweiAppDataModel fromJson(Map json) => 25 | _$HuaweiAppDataModelFromJson(json); 26 | 27 | @override 28 | Map toJson() => _$HuaweiAppDataModelToJson(this); 29 | } 30 | -------------------------------------------------------------------------------- /lib/src/models/entities/huawei/huawei_layout_data_model.dart: -------------------------------------------------------------------------------- 1 | import 'package:json_annotation/json_annotation.dart'; 2 | 3 | import '../../../utils/constants/constants.dart'; 4 | import '../entity_model.dart'; 5 | import 'huawei_app_data_model.dart'; 6 | 7 | part 'huawei_layout_data_model.g.dart'; 8 | 9 | @JsonSerializable() 10 | class HuaweiLayoutDataModel extends EntityModel { 11 | final List? dataList; 12 | 13 | @override 14 | @JsonKey(includeFromJson: false) 15 | final String responseBody; 16 | 17 | HuaweiLayoutDataModel({this.dataList, String? responseBody}) 18 | : responseBody = responseBody ?? kEmpty; 19 | 20 | factory HuaweiLayoutDataModel.fromJson(Map json) => 21 | _$HuaweiLayoutDataModelFromJson(json); 22 | 23 | @override 24 | HuaweiLayoutDataModel fromJson(Map json) => 25 | _$HuaweiLayoutDataModelFromJson(json); 26 | 27 | @override 28 | Map toJson() => _$HuaweiLayoutDataModelToJson(this); 29 | } 30 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/models/version_response_model.dart: -------------------------------------------------------------------------------- 1 | import '../utils/mixins/version_compare_mixin.dart'; 2 | 3 | class VersionResponseModel with VersionCompareMixin { 4 | /// The current version of the app. 5 | final String localVersion; 6 | 7 | /// The most recent version of the app in the store. 8 | final String storeVersion; 9 | 10 | /// A link to the app store page where the app can be updated. 11 | final String updateLink; 12 | 13 | ///result of compared versions between [localVersion] and [storeVersion] 14 | bool get isAppVersionOld => isCurrentVersionOld( 15 | currentVersion: localVersion, storeVersion: storeVersion); 16 | 17 | VersionResponseModel({ 18 | required this.localVersion, 19 | required this.storeVersion, 20 | required this.updateLink, 21 | }); 22 | 23 | Map toJson() { 24 | return { 25 | localVersion.toString(): localVersion, 26 | storeVersion.toString(): storeVersion, 27 | updateLink.toString(): updateLink, 28 | isAppVersionOld.toString(): isAppVersionOld, 29 | }; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /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/android/app/src/main/res/values/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | ## 1.0.23 (02/04/2025) 2 | 3 | * Reorganized platform decision logic 4 | * Added web support 5 | * Updated constants and error messages 6 | 7 | ## 1.0.22 (02/04/2025) 8 | 9 | * Depended packages upgraded. 10 | 11 | ## 1.0.21 (07/06/2024) 12 | 13 | * Flutter version upgraded to last version. 14 | * Depended packages version upgraded. 15 | 16 | ## 1.0.2 (10/07/2023) 17 | 18 | * [Interface Code] error fixed for Huawei version compare. 19 | * Wrong version comparator url fixed for Huawei. 20 | 21 | ## 1.0.1 (11/06/2023) 22 | 23 | * Flutter version upgraded to 3.10 24 | * Package versions upgraded to latest. 25 | 26 | ## 1.0.0 (28/02/2023) 27 | 28 | * Readme file upgraded. 29 | * Optional app id added. 30 | * Some functions names are changed. 31 | * Added a lot of example to the main.dart 32 | 33 | ## 0.0.1 (24/02/2023) 34 | 35 | * Initial open source release. 36 | * Platform specific (Android, iOS, Huawei) version comparator feature added. 37 | * Custom version comparator feature added. 38 | * PlatformSpecificVersionComparatorView widget added. 39 | * CustomVersionComparatorView widget added. -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /lib/src/services/concretes/android/android_version_convert_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/empty_entity_model.dart'; 2 | import '../../../utils/constants/constants.dart'; 3 | import '../../../utils/helpers/regexp_helper.dart'; 4 | import '../../../utils/results/data_result.dart'; 5 | import '../../abstracts/version_convert_service.dart'; 6 | 7 | class AndroidVersionConvertManager 8 | extends VersionConvertService { 9 | @override 10 | DataResult convert(EmptyEntityModel entity) { 11 | final firstMatch = 12 | RegExpHelper.androidVersionRegExp.firstMatch(entity.responseBody); 13 | 14 | return _checkRegExpVersion(firstMatch); 15 | } 16 | } 17 | 18 | DataResult _checkRegExpVersion(RegExpMatch? regExpMatch) { 19 | if (regExpMatch == null || regExpMatch.groupCount < 1) { 20 | return DataResult.error(message: kErrorMessage.versionNotMatch); 21 | } 22 | 23 | final version = regExpMatch.group(1); 24 | return version == null || version.isEmpty 25 | ? DataResult.error(message: kErrorMessage.versionNotMatch) 26 | : DataResult.success(data: version); 27 | } 28 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/package_info_mixin.dart: -------------------------------------------------------------------------------- 1 | import 'package:package_info_plus/package_info_plus.dart'; 2 | import 'package:version_comparator/src/utils/constants/constants.dart'; 3 | 4 | import '../results/data_result.dart'; 5 | 6 | mixin PackageInfoMixin { 7 | Future> getCurrentAppVersion() async { 8 | try { 9 | final info = await PackageInfo.fromPlatform(); 10 | return info.version.isEmpty 11 | ? DataResult.error(message: kErrorMessage.appVersionFetchError) 12 | : DataResult.success(data: info.version); 13 | } catch (exception) { 14 | return DataResult.error(message: kErrorMessage.appVersionFetchError); 15 | } 16 | } 17 | 18 | Future> getBundleId() async { 19 | try { 20 | final info = await PackageInfo.fromPlatform(); 21 | return info.packageName.isEmpty 22 | ? DataResult.error(message: kErrorMessage.appBundleIdFetchError) 23 | : DataResult.success(data: info.packageName); 24 | } catch (exception) { 25 | return DataResult.error(message: kErrorMessage.appBundleIdFetchError); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /lib/src/services/abstracts/version_dialog_service.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../../../version_comparator.dart'; 4 | import '../../utils/mixins/launch_url_mixin.dart'; 5 | 6 | abstract class VersionDialogService with LaunchUrlMixin { 7 | Future showVersionDialog({ 8 | required BuildContext context, 9 | required VersionResponseModel versionModel, 10 | T? popResult, 11 | bool isUpdateRequired = false, 12 | bool isCancelActionVisible = true, 13 | VoidCallback? onAfterPopDialog, 14 | Widget? title, 15 | Widget? content, 16 | List? actions, 17 | }); 18 | 19 | Future showCustomContentVersionDialog({ 20 | required BuildContext context, 21 | required VersionResponseModel versionModel, 22 | required Widget content, 23 | T? popResult, 24 | bool isUpdateRequired = false, 25 | bool isCancelActionVisible = true, 26 | VoidCallback? onAfterPopDialog, 27 | }); 28 | 29 | Future showCustomVersionDialog({ 30 | required BuildContext context, 31 | required Widget dialog, 32 | bool isDismissible = true, 33 | }); 34 | } 35 | -------------------------------------------------------------------------------- /lib/src/utils/results/data_result.dart: -------------------------------------------------------------------------------- 1 | import '../constants/constants.dart'; 2 | import 'result.dart'; 3 | 4 | ///This class returns operation results with message and data. [TData] must be defined. 5 | class DataResult extends Result { 6 | ///Operation data. 7 | final TData? data; 8 | 9 | ///Operation code. 10 | final int code; 11 | 12 | ///Customizable constructor 13 | DataResult( 14 | {required super.isSuccess, 15 | required super.message, 16 | this.data, 17 | this.code = kZero}); 18 | 19 | ///Operation result is successful. Also you can add success message to [message]. [data] is required. 20 | DataResult.success({super.message, required this.data, this.code = kZero}) 21 | : super.success(); 22 | 23 | ///Operation result is unsuccessful. You must add error message to [message] 24 | DataResult.error({required super.message, this.data, this.code = kZero}) 25 | : super.error(); 26 | 27 | ///Operation result is unsuccessful. Error message is optional. 28 | DataResult.errorByEmptyMessage({super.message, this.data, this.code = kZero}) 29 | : super.errorByEmptyMessage(); 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 Pagar.me Pagamentos S/A 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. -------------------------------------------------------------------------------- /example/ios/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - device_info_plus (0.0.1): 3 | - Flutter 4 | - Flutter (1.0.0) 5 | - package_info_plus (0.4.5): 6 | - Flutter 7 | - url_launcher_ios (0.0.1): 8 | - Flutter 9 | 10 | DEPENDENCIES: 11 | - device_info_plus (from `.symlinks/plugins/device_info_plus/ios`) 12 | - Flutter (from `Flutter`) 13 | - package_info_plus (from `.symlinks/plugins/package_info_plus/ios`) 14 | - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) 15 | 16 | EXTERNAL SOURCES: 17 | device_info_plus: 18 | :path: ".symlinks/plugins/device_info_plus/ios" 19 | Flutter: 20 | :path: Flutter 21 | package_info_plus: 22 | :path: ".symlinks/plugins/package_info_plus/ios" 23 | url_launcher_ios: 24 | :path: ".symlinks/plugins/url_launcher_ios/ios" 25 | 26 | SPEC CHECKSUMS: 27 | device_info_plus: e5c5da33f982a436e103237c0c85f9031142abed 28 | Flutter: f04841e97a9d0b0a8025694d0796dd46242b2854 29 | package_info_plus: 6c92f08e1f853dc01228d6f553146438dafcd14e 30 | url_launcher_ios: fb12c43172927bb5cf75aeebd073f883801f1993 31 | 32 | PODFILE CHECKSUM: ef19549a9bc3046e7bb7d2fab4d021637c0c58a3 33 | 34 | COCOAPODS: 1.11.3 35 | -------------------------------------------------------------------------------- /lib/src/widgets/column_by_space.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class ColumnBySpace extends StatelessWidget { 4 | const ColumnBySpace({ 5 | super.key, 6 | required this.children, 7 | required this.space, 8 | this.mainAxisAlignment = MainAxisAlignment.center, 9 | this.crossAxisAlignment = CrossAxisAlignment.center, 10 | this.mainAxisSize = MainAxisSize.min, 11 | }); 12 | 13 | final List children; 14 | final Widget space; 15 | 16 | final MainAxisAlignment mainAxisAlignment; 17 | final CrossAxisAlignment crossAxisAlignment; 18 | final MainAxisSize mainAxisSize; 19 | 20 | @override 21 | Widget build(BuildContext context) { 22 | return Column( 23 | mainAxisAlignment: mainAxisAlignment, 24 | crossAxisAlignment: crossAxisAlignment, 25 | mainAxisSize: mainAxisSize, 26 | children: _buildChildren(), 27 | ); 28 | } 29 | 30 | List _buildChildren() { 31 | if (children.isEmpty) return []; 32 | final list = [space]; 33 | 34 | for (var item in children) { 35 | list.add(item); 36 | list.add(space); 37 | } 38 | 39 | return list; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /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/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/lib/models/custom_info_message.dart: -------------------------------------------------------------------------------- 1 | import 'package:version_comparator/version_comparator.dart'; 2 | 3 | class CustomInfoMessage implements ComparatorInfoMessage { 4 | @override 5 | String get checkVersionErrorDialogTitle => ''; 6 | 7 | @override 8 | String get checkVersionLoadingMessage => ''; 9 | 10 | @override 11 | String get checkVersionOkAction => ''; 12 | 13 | @override 14 | String get getDataError => ''; 15 | 16 | @override 17 | String get getDataSuccess => ''; 18 | 19 | @override 20 | String requiredVersionDialogContent(String oldVersion, String latestVersion) { 21 | return ''; 22 | } 23 | 24 | @override 25 | String get requiredVersionDialogTitle => ''; 26 | 27 | @override 28 | String get sendDataError => ''; 29 | 30 | @override 31 | String get sendDataSuccess => ''; 32 | 33 | @override 34 | String get unExpectedError => ''; 35 | 36 | @override 37 | String get versionDialogCancelAction => ''; 38 | 39 | @override 40 | String versionDialogContent(String oldVersion, String latestVersion) { 41 | return ''; 42 | } 43 | 44 | @override 45 | String get versionDialogTitle => ''; 46 | 47 | @override 48 | String get versionDialogUpdateAction => ''; 49 | } 50 | -------------------------------------------------------------------------------- /lib/src/widgets/default_check_version_progress.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../utils/constants/constants.dart'; 4 | import 'column_by_space.dart'; 5 | 6 | class DefaultCheckVersionProgress extends StatelessWidget { 7 | const DefaultCheckVersionProgress({ 8 | super.key, 9 | this.loadingWidget, 10 | required this.isLoadingTextVisible, 11 | required this.loadingWidgetSize, 12 | required this.spaceAroundChild, 13 | this.loadingText, 14 | }); 15 | 16 | final Widget? loadingWidget; 17 | final bool isLoadingTextVisible; 18 | final double loadingWidgetSize; 19 | final double spaceAroundChild; 20 | final String? loadingText; 21 | 22 | @override 23 | Widget build(BuildContext context) { 24 | return Center( 25 | child: ColumnBySpace( 26 | mainAxisSize: MainAxisSize.min, 27 | mainAxisAlignment: MainAxisAlignment.center, 28 | space: SizedBox(height: spaceAroundChild), 29 | children: [ 30 | SizedBox( 31 | height: loadingWidgetSize, 32 | width: loadingWidgetSize, 33 | child: loadingWidget ?? const CircularProgressIndicator(), 34 | ), 35 | if (isLoadingTextVisible) 36 | Text(loadingText ?? kInfoMessage.checkVersionLoadingMessage) 37 | ], 38 | ), 39 | ); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /lib/src/utils/constants/constants.dart: -------------------------------------------------------------------------------- 1 | import '../messages/comparator_error_message.dart'; 2 | import '../messages/comparator_info_message.dart'; 3 | import '../messages/default_comparator_error_message.dart'; 4 | import '../messages/default_comparator_info_message.dart'; 5 | 6 | const String kEmpty = ''; 7 | const String kSpace = ' '; 8 | const String kVersionSplitter = '.'; 9 | const String kAndroidManufacturer = 'GOOGLE'; 10 | const String kHuaweiManufacturer = 'HUAWEI'; 11 | 12 | const int kDefaultTimeout = 16000; 13 | const int kZero = 0; 14 | const int kHttpStatusOK = 200; 15 | 16 | const double kLoadingWidgetSize = 40; 17 | const double kMediumSpace = 16; 18 | const double kTransparentBlack = 0.25; 19 | 20 | ComparatorInfoMessage get kInfoMessage => 21 | AppConstants.comparatorInfoMessage ?? DefaultComparatorInfoMessage.instance; 22 | 23 | ComparatorErrorMessage get kErrorMessage => 24 | AppConstants.comparatorErrorMessage ?? 25 | DefaultComparatorErrorMessage.instance; 26 | 27 | class AppConstants { 28 | static ComparatorInfoMessage? comparatorInfoMessage; 29 | static ComparatorErrorMessage? comparatorErrorMessage; 30 | 31 | static void setInfoMessage(ComparatorInfoMessage infoMessage) { 32 | comparatorInfoMessage = infoMessage; 33 | } 34 | 35 | static void setErrorMessage(ComparatorErrorMessage errorMessage) { 36 | comparatorErrorMessage = errorMessage; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /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/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 | use_modular_headers! 32 | 33 | flutter_install_all_macos_pods File.dirname(File.realpath(__FILE__)) 34 | end 35 | 36 | post_install do |installer| 37 | installer.pods_project.targets.each do |target| 38 | flutter_additional_macos_build_settings(target) 39 | end 40 | end 41 | -------------------------------------------------------------------------------- /example/ios/Podfile: -------------------------------------------------------------------------------- 1 | # Uncomment this line to define a global platform for your project 2 | # platform :ios, '11.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 | use_modular_headers! 33 | 34 | flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) 35 | end 36 | 37 | post_install do |installer| 38 | installer.pods_project.targets.each do |target| 39 | flutter_additional_ios_build_settings(target) 40 | end 41 | end 42 | -------------------------------------------------------------------------------- /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 17 | # https://dart-lang.github.io/linter/lints/index.html. 18 | # 19 | # Instead of disabling a lint rule for the entire project in the 20 | # section below, it can also be suppressed for a single line of code 21 | # or a specific dart file by using the `// ignore: name_of_lint` and 22 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 23 | # producing the lint. 24 | rules: 25 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 26 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 27 | 28 | # Additional information about this file can be found at 29 | # https://dart.dev/guides/language/analysis-options 30 | -------------------------------------------------------------------------------- /lib/src/services/concretes/custom/custom_version_compare_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/store/base_store_model.dart'; 2 | import '../../../models/version_response_model.dart'; 3 | import '../../../utils/results/data_result.dart'; 4 | import '../../abstracts/remote_data_service.dart'; 5 | import '../../abstracts/version_compare_service.dart'; 6 | import '../http_remote_data_manager.dart'; 7 | 8 | class CustomVersionCompareManager extends VersionCompareByQueryService { 9 | CustomVersionCompareManager({ 10 | required this.dataService, 11 | required this.localVersion, 12 | required this.onConvertVersion, 13 | required this.store, 14 | this.customUpdateLink, 15 | }); 16 | 17 | CustomVersionCompareManager.httpService({ 18 | required this.localVersion, 19 | required this.onConvertVersion, 20 | required this.store, 21 | this.customUpdateLink, 22 | }) : dataService = HttpRemoteDataManager(); 23 | 24 | @override 25 | final BaseStoreModel store; 26 | 27 | @override 28 | final RemoteDataService dataService; 29 | 30 | final String localVersion; 31 | final String? Function(String responseBody) onConvertVersion; 32 | final String? Function(String responseBody)? customUpdateLink; 33 | 34 | @override 35 | Future> getVersion( 36 | {Map? customHeader}) async { 37 | return getStoreVersionByQuery( 38 | localVersion: localVersion, 39 | customHeader: customHeader, 40 | onConvertVersion: onConvertVersion, 41 | customUpdateLink: customUpdateLink, 42 | ); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /lib/src/models/entities/store/custom_store_model.dart: -------------------------------------------------------------------------------- 1 | import 'base_store_model.dart'; 2 | 3 | ///This class includes store information of app. 4 | ///[appId] it's app bundle id or specific id for access to the app. 5 | /// 6 | ///[versionQuery] it will be use for access to the app in the store. 7 | ///If your app link doesn't have query just fill with empty character. 8 | /// 9 | ///[storeUrl] is includes custom app store link (base url + endpoint) 10 | /// 11 | ///Example: 12 | /// 13 | ///``` 14 | ///CustomStoreModel( 15 | /// //!(Base url and endpoint) 16 | /// storeUrl: 'https://play.google.com/store/apps/details', 17 | /// //!Sometimes query can be different 18 | /// versionQuery: 'id=com.example.bundle', 19 | /// //!bundleId or app id in the app store. 20 | /// appId: 'com.example.bundle', 21 | ///); 22 | ///``` 23 | class CustomStoreModel extends BaseStoreModel { 24 | @override 25 | 26 | ///Store url without query. Base url and endpoint. 27 | ///For example (https://play.google.com/store/apps/details) 28 | final String storeUrl; 29 | 30 | @override 31 | 32 | ///App bundle id or specific id for store. 33 | ///For example: com.example.bundleId 34 | ///If you don't need to the appId just pass with empty character 35 | final String appId; 36 | 37 | @override 38 | 39 | ///It will using to get version of your app in the store. 40 | ///For example: id=com.example.id 41 | ///If you don't need to the appId just pass with empty character 42 | final String versionQuery; 43 | 44 | CustomStoreModel({ 45 | required this.storeUrl, 46 | required this.appId, 47 | required this.versionQuery, 48 | }); 49 | } 50 | -------------------------------------------------------------------------------- /lib/src/utils/helpers/version_compare_service_factory.dart: -------------------------------------------------------------------------------- 1 | import 'package:version_comparator/src/services/concretes/android/android_version_compare_manager.dart'; 2 | import 'package:version_comparator/src/services/concretes/huawei/huawei_version_compare_manager.dart'; 3 | import 'package:version_comparator/src/services/concretes/ios/ios_version_compare_manager.dart'; 4 | import 'package:version_comparator/src/utils/constants/constants.dart'; 5 | import 'package:version_comparator/version_comparator.dart'; 6 | 7 | class VersionCompareServiceFactory { 8 | final AppPlatform platform; 9 | 10 | VersionCompareServiceFactory({required this.platform}); 11 | 12 | VersionCompareService getCompareService({ 13 | required RemoteDataService dataService, 14 | required String bundleId, 15 | }) { 16 | switch (platform) { 17 | case AppPlatform.android: 18 | return AndroidVersionCompareManager( 19 | versionConvertService: AndroidVersionConvertManager(), 20 | dataService: dataService, 21 | bundleId: bundleId, 22 | ); 23 | 24 | case AppPlatform.ios: 25 | return IosVersionCompareManager( 26 | dataService: dataService, bundleId: bundleId); 27 | 28 | case AppPlatform.huawei: 29 | return HuaweiVersionCompareManager( 30 | dataService: dataService, appId: bundleId); 31 | 32 | case AppPlatform.web: 33 | case AppPlatform.linux: 34 | case AppPlatform.macOs: 35 | case AppPlatform.windows: 36 | case AppPlatform.invalid: 37 | throw Exception(kErrorMessage.unHandledAppPlatformException); 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/bundle_id_controller_mixin.dart: -------------------------------------------------------------------------------- 1 | import '../../services/abstracts/base_version_comparator.dart'; 2 | import '../constants/constants.dart'; 3 | import '../enums/app_platform.dart'; 4 | import '../extensions/string_extension.dart'; 5 | import '../results/data_result.dart'; 6 | 7 | mixin BundleIdControllerMixin on BaseVersionComparator { 8 | ///It returns platform specific app bundle id. 9 | ///Don't forget AppGallery (Huawei) not uses bundle id for comparing. 10 | ///You have to set huaweiId parameter if you want to compare app on AppGallery. 11 | Future> getBundleByOptionalId({ 12 | String? androidId, 13 | String? iosId, 14 | String? huaweiId, 15 | required AppPlatform platform, 16 | }) async { 17 | if (platform == AppPlatform.android && androidId.isNotNullAndNotEmpty) { 18 | return DataResult.success(data: androidId); 19 | } else if (platform == AppPlatform.ios && iosId.isNotNullAndNotEmpty) { 20 | return DataResult.success(data: iosId); 21 | } else if (platform == AppPlatform.huawei) { 22 | return huaweiId.isNotNullAndNotEmpty 23 | ? DataResult.success(data: huaweiId) 24 | : DataResult.error(message: kErrorMessage.huaweiAppIdNullOrEmpty); 25 | } 26 | 27 | final bundleResult = await getBundleId(); 28 | 29 | bool isBundleNotValid = bundleResult.isNotSuccess || 30 | bundleResult.data == null || 31 | (bundleResult.data?.isEmpty ?? true); 32 | 33 | if (isBundleNotValid) { 34 | return DataResult.error( 35 | message: kErrorMessage.bundleIdAndCustomIdNotValid); 36 | } 37 | 38 | return bundleResult; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /lib/src/services/concretes/huawei/huawei_version_compare_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/huawei/huawei_version_entity_model.dart'; 2 | import '../../../models/entities/store/base_store_model.dart'; 3 | import '../../../models/entities/store/huawei_store_model.dart'; 4 | import '../../../models/version_response_model.dart'; 5 | import '../../../utils/results/data_result.dart'; 6 | import '../../abstracts/huawei_version_compare_service.dart'; 7 | import '../../abstracts/remote_data_service.dart'; 8 | import '../../abstracts/version_convert_service.dart'; 9 | import '../http_remote_data_manager.dart'; 10 | 11 | class HuaweiVersionCompareManager extends HuaweiVersionCompareService { 12 | HuaweiVersionCompareManager( 13 | {required this.dataService, required String appId}) 14 | : store = HuaweiStoreModel(appId); 15 | 16 | HuaweiVersionCompareManager.httpService( 17 | {VersionConvertService? versionConvertService, required String appId}) 18 | : store = HuaweiStoreModel(appId), 19 | dataService = HttpRemoteDataManager(); 20 | 21 | @override 22 | final BaseStoreModel store; 23 | 24 | @override 25 | final RemoteDataService dataService; 26 | 27 | @override 28 | Future> getVersion( 29 | {Map? customHeader}) async { 30 | return await getVersionByQuery( 31 | customUpdateLink: (body) => 32 | HuaweiVersionEntityModel.fromResponse(body).storeUrl(store.appId), 33 | onConvertVersion: (body) => 34 | HuaweiVersionEntityModel.fromResponse(body).storeVersion, 35 | customHeader: customHeader ?? await generateHeaderByInterfaceCode(), 36 | ); 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /lib/src/services/concretes/ios/ios_version_compare_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/ios_version_entity_model.dart'; 2 | import '../../../models/entities/store/base_store_model.dart'; 3 | import '../../../models/entities/store/ios_store_model.dart'; 4 | import '../../../models/version_response_model.dart'; 5 | import '../../../utils/results/data_result.dart'; 6 | import '../../abstracts/remote_data_service.dart'; 7 | import '../../abstracts/version_compare_service.dart'; 8 | import '../../abstracts/version_convert_service.dart'; 9 | import '../http_remote_data_manager.dart'; 10 | 11 | class IosVersionCompareManager extends VersionCompareByQueryService { 12 | IosVersionCompareManager({required this.dataService, required String bundleId}) : store = IosStoreModel(bundleId); 13 | 14 | IosVersionCompareManager.httpService({VersionConvertService? versionConvertService, required String bundleId}) 15 | : store = IosStoreModel(bundleId), 16 | dataService = HttpRemoteDataManager(); 17 | 18 | @override 19 | final BaseStoreModel store; 20 | 21 | @override 22 | final RemoteDataService dataService; 23 | 24 | @override 25 | Future> getVersion({Map? customHeader}) async { 26 | final bundleIdResult = await getBundleId(); 27 | if (bundleIdResult.isNotSuccess) { 28 | return DataResult.error(message: bundleIdResult.message); 29 | } 30 | 31 | return getVersionByQuery( 32 | customHeader: customHeader, 33 | customUpdateLink: (body) => IosVersionEntityModel.fromResponse(body).storeUrl, 34 | onConvertVersion: (responseBody) => IosVersionEntityModel.fromResponse(responseBody).storeVersion, 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 | -------------------------------------------------------------------------------- /lib/src/widgets/check_version_progress_dialog.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | import '../utils/constants/constants.dart'; 4 | import 'column_by_space.dart'; 5 | 6 | class CheckVersionProgressDialog extends StatelessWidget { 7 | const CheckVersionProgressDialog({ 8 | super.key, 9 | this.backgroundColor, 10 | this.customLoading, 11 | this.loadingText, 12 | this.isTextVisible = true, 13 | this.loadingWidgetSize = kLoadingWidgetSize, 14 | this.spaceAroundChildren = kMediumSpace, 15 | }); 16 | 17 | final Color? backgroundColor; 18 | final Widget? customLoading; 19 | 20 | final String? loadingText; 21 | final bool isTextVisible; 22 | final double loadingWidgetSize; 23 | final double spaceAroundChildren; 24 | 25 | @override 26 | Widget build(BuildContext context) { 27 | return Container( 28 | height: double.infinity, 29 | width: double.infinity, 30 | padding: EdgeInsets.zero, 31 | color: backgroundColor ?? Colors.black.withOpacity(kTransparentBlack), 32 | child: AlertDialog( 33 | alignment: Alignment.center, 34 | content: ColumnBySpace( 35 | mainAxisSize: MainAxisSize.min, 36 | mainAxisAlignment: MainAxisAlignment.center, 37 | space: SizedBox(height: spaceAroundChildren), 38 | children: [ 39 | SizedBox( 40 | height: loadingWidgetSize, 41 | width: loadingWidgetSize, 42 | child: customLoading ?? const CircularProgressIndicator(), 43 | ), 44 | if (isTextVisible) 45 | Text(loadingText ?? kInfoMessage.checkVersionLoadingMessage) 46 | ], 47 | ), 48 | ), 49 | ); 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /lib/src/services/abstracts/huawei_version_compare_service.dart: -------------------------------------------------------------------------------- 1 | import '../../models/parameters/get_data_service_parameter_model.dart'; 2 | import '../../utils/constants/constants.dart'; 3 | import '../../utils/constants/endpoint_constants.dart'; 4 | import '../../utils/extensions/string_extension.dart'; 5 | import '../../utils/mixins/http_header_key_value_mixin.dart'; 6 | import '../../utils/results/data_result.dart'; 7 | import 'version_compare_service.dart'; 8 | 9 | abstract class HuaweiVersionCompareService extends VersionCompareByQueryService 10 | with HttpHeaderKeyValueMixin { 11 | Future> getInterfaceCode() async { 12 | final result = await dataService.getData( 13 | GetDataServiceParameterModel( 14 | url: EndpointConstants.huaweiInterfaceCodeUrl), 15 | ); 16 | 17 | return result; 18 | } 19 | 20 | Future> generateHeaderByInterfaceCode() async { 21 | final interfaceCodeResult = await getInterfaceCode(); 22 | 23 | if (interfaceCodeResult.isNotSuccess || 24 | (interfaceCodeResult.data?.isNullOrEmpty ?? true)) { 25 | return dataService.baseHeader; 26 | } 27 | 28 | return createInterfaceCodeHeader(interfaceCodeResult.data); 29 | } 30 | 31 | String getInterfaceCodeByTimestamp(String? code) { 32 | String interfaceCode = code?.replaceAll('"', kEmpty) ?? kEmpty; 33 | interfaceCode += '_${DateTime.now().millisecondsSinceEpoch}'; 34 | return interfaceCode; 35 | } 36 | 37 | Map createInterfaceCodeHeader(String? interfaceCode) { 38 | return Map.fromEntries([ 39 | getApplicationJsonContentTypeEntry(), 40 | getInterfaceCodeEntry(getInterfaceCodeByTimestamp(interfaceCode)), 41 | ]); 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .history 10 | .svn/ 11 | 12 | # IntelliJ related 13 | *.iml 14 | *.ipr 15 | *.iws 16 | .idea/ 17 | 18 | # The .vscode folder contains launch configuration and tasks you configure in 19 | # VS Code which you may wish to be included in version control, so this line 20 | # is commented out by default. 21 | #.vscode/ 22 | 23 | # Flutter/Dart/Pub related 24 | **/doc/api/ 25 | .dart_tool/ 26 | .packages 27 | .pub-cache/ 28 | .pub/ 29 | build/ 30 | 31 | # Android related 32 | **/android/**/gradle-wrapper.jar 33 | **/android/.gradle 34 | **/android/captures/ 35 | **/android/gradlew 36 | **/android/gradlew.bat 37 | **/android/local.properties 38 | **/android/**/GeneratedPluginRegistrant.java 39 | 40 | # iOS/XCode related 41 | **/ios/**/*.mode1v3 42 | **/ios/**/*.mode2v3 43 | **/ios/**/*.moved-aside 44 | **/ios/**/*.pbxuser 45 | **/ios/**/*.perspectivev3 46 | **/ios/**/*sync/ 47 | **/ios/**/.sconsign.dblite 48 | **/ios/**/.tags* 49 | **/ios/**/.vagrant/ 50 | **/ios/**/DerivedData/ 51 | **/ios/**/Icon? 52 | **/ios/**/Pods/ 53 | **/ios/**/.symlinks/ 54 | **/ios/**/profile 55 | **/ios/**/xcuserdata 56 | **/ios/.generated/ 57 | **/ios/Flutter/App.framework 58 | **/ios/Flutter/Flutter.framework 59 | **/ios/Flutter/Flutter.podspec 60 | **/ios/Flutter/Generated.xcconfig 61 | **/ios/Flutter/app.flx 62 | **/ios/Flutter/app.zip 63 | **/ios/Flutter/flutter_assets/ 64 | **/ios/Flutter/flutter_export_environment.sh 65 | **/ios/ServiceDefinitions.json 66 | **/ios/Runner/GeneratedPluginRegistrant.* 67 | 68 | # Exceptions to above rules. 69 | !**/ios/**/default.mode1v3 70 | !**/ios/**/default.mode2v3 71 | !**/ios/**/default.pbxuser 72 | !**/ios/**/default.perspectivev3 73 | !/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 3 | 7 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /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. 5 | 6 | version: 7 | revision: 9944297138845a94256f1cf37beb88ff9a8e811a 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: 9944297138845a94256f1cf37beb88ff9a8e811a 17 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 18 | - platform: android 19 | create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 20 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 21 | - platform: ios 22 | create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 23 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 24 | - platform: linux 25 | create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 26 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 27 | - platform: macos 28 | create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 29 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 30 | - platform: web 31 | create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 32 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 33 | - platform: windows 34 | create_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 35 | base_revision: 9944297138845a94256f1cf37beb88ff9a8e811a 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/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 | UIViewControllerBasedStatusBarAppearance 45 | 46 | CADisableMinimumFrameDurationOnPhone 47 | 48 | UIApplicationSupportsIndirectInputEvents 49 | 50 | 51 | 52 | -------------------------------------------------------------------------------- /lib/src/models/entities/ios_version_entity_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | import 'package:version_comparator/src/utils/extensions/iterable_extension.dart'; 5 | 6 | import '../../utils/constants/constants.dart'; 7 | import 'entity_model.dart'; 8 | 9 | part 'ios_version_entity_model.g.dart'; 10 | 11 | @JsonSerializable() 12 | class IosVersionEntityModel extends EntityModel { 13 | IosVersionEntityModel({this.resultCount, this.results, String? responseBody}) 14 | : responseBody = responseBody ?? kEmpty; 15 | 16 | @override 17 | @JsonKey(includeFromJson: false) 18 | final String responseBody; 19 | 20 | final int? resultCount; 21 | final List>? results; 22 | 23 | String get storeUrl { 24 | if (results == null || (results?.isEmpty ?? true)) return kEmpty; 25 | 26 | final item = results! 27 | .firstWhereOrNull((element) => element.containsKey('trackViewUrl')); 28 | if (item == null) return kEmpty; 29 | 30 | final url = item['trackViewUrl']; 31 | return url is String ? url : kEmpty; 32 | } 33 | 34 | String get storeVersion { 35 | if (results == null || (results?.isEmpty ?? true)) return kEmpty; 36 | 37 | final item = 38 | results!.firstWhereOrNull((element) => element.containsKey('version')); 39 | if (item == null) return kEmpty; 40 | 41 | final version = item['version']; 42 | return version is String ? version : kEmpty; 43 | } 44 | 45 | factory IosVersionEntityModel.fromResponse(String body) { 46 | final trimBody = body.replaceAll(kSpace, kEmpty); 47 | return _$IosVersionEntityModelFromJson(jsonDecode(trimBody)); 48 | } 49 | 50 | @override 51 | IosVersionEntityModel fromJson(Map json) => 52 | _$IosVersionEntityModelFromJson(json); 53 | 54 | @override 55 | Map toJson() => _$IosVersionEntityModelToJson(this); 56 | } 57 | -------------------------------------------------------------------------------- /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/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 | int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr); 51 | std::string utf8_string; 52 | if (target_length == 0 || target_length > utf8_string.max_size()) { 53 | return utf8_string; 54 | } 55 | utf8_string.resize(target_length); 56 | int converted_length = ::WideCharToMultiByte( 57 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 58 | -1, utf8_string.data(), 59 | target_length, nullptr, nullptr); 60 | if (converted_length == 0) { 61 | return std::string(); 62 | } 63 | return utf8_string; 64 | } 65 | -------------------------------------------------------------------------------- /lib/src/models/entities/huawei/huawei_version_entity_model.dart: -------------------------------------------------------------------------------- 1 | import 'dart:convert'; 2 | 3 | import 'package:json_annotation/json_annotation.dart'; 4 | 5 | import '../../../utils/constants/constants.dart'; 6 | import '../../../utils/constants/endpoint_constants.dart'; 7 | import '../entity_model.dart'; 8 | import 'huawei_layout_data_model.dart'; 9 | 10 | part 'huawei_version_entity_model.g.dart'; 11 | 12 | @JsonSerializable() 13 | class HuaweiVersionEntityModel extends EntityModel { 14 | HuaweiVersionEntityModel({String? responseBody, this.layoutData}) 15 | : responseBody = responseBody ?? kEmpty; 16 | 17 | HuaweiVersionEntityModel.empty() 18 | : responseBody = '', 19 | layoutData = null; 20 | 21 | @override 22 | @JsonKey(includeFromJson: false) 23 | final String responseBody; 24 | 25 | final List? layoutData; 26 | 27 | String storeUrl(String appId) { 28 | return '${EndpointConstants.huaweiStoreUrl}/$appId'; 29 | } 30 | 31 | String get storeVersion { 32 | if (layoutData == null || (layoutData?.isEmpty ?? true)) { 33 | return kEmpty; 34 | } 35 | 36 | bool isDataNullOrEmpty = layoutData!.first.dataList == null || 37 | (layoutData!.first.dataList?.isEmpty ?? true); 38 | if (isDataNullOrEmpty) { 39 | return kEmpty; 40 | } 41 | 42 | return layoutData!.first.dataList!.first.versionName ?? kEmpty; 43 | } 44 | 45 | factory HuaweiVersionEntityModel.fromJson(Map json) => 46 | _$HuaweiVersionEntityModelFromJson(json); 47 | 48 | factory HuaweiVersionEntityModel.fromResponse(String body) { 49 | final json = jsonDecode(body); 50 | return _$HuaweiVersionEntityModelFromJson(json); 51 | } 52 | 53 | @override 54 | HuaweiVersionEntityModel fromJson(Map json) => 55 | _$HuaweiVersionEntityModelFromJson(json); 56 | 57 | @override 58 | Map toJson() => _$HuaweiVersionEntityModelToJson(this); 59 | } 60 | -------------------------------------------------------------------------------- /lib/src/services/concretes/android/android_version_compare_manager.dart: -------------------------------------------------------------------------------- 1 | import '../../../models/entities/empty_entity_model.dart'; 2 | import '../../../models/entities/store/android_store_model.dart'; 3 | import '../../../models/entities/store/base_store_model.dart'; 4 | import '../../../models/version_response_model.dart'; 5 | import '../../../utils/results/data_result.dart'; 6 | import '../../abstracts/remote_data_service.dart'; 7 | import '../../abstracts/version_compare_service.dart'; 8 | import '../../abstracts/version_convert_service.dart'; 9 | import '../http_remote_data_manager.dart'; 10 | import 'android_version_convert_manager.dart'; 11 | 12 | class AndroidVersionCompareManager extends VersionCompareByQueryService { 13 | AndroidVersionCompareManager({ 14 | required this.dataService, 15 | required this.versionConvertService, 16 | required String bundleId, 17 | }) : store = AndroidStoreModel(bundleId); 18 | 19 | AndroidVersionCompareManager.httpService({ 20 | VersionConvertService? versionConvertService, 21 | required String bundleId, 22 | }) : store = AndroidStoreModel(bundleId), 23 | dataService = HttpRemoteDataManager(), 24 | versionConvertService = versionConvertService ?? AndroidVersionConvertManager(); 25 | 26 | @override 27 | final BaseStoreModel store; 28 | 29 | @override 30 | final RemoteDataService dataService; 31 | 32 | final VersionConvertService versionConvertService; 33 | 34 | @override 35 | Future> getVersion({Map? customHeader}) async { 36 | final bundleIdResult = await getBundleId(); 37 | if (bundleIdResult.isNotSuccess) { 38 | return DataResult.error(message: bundleIdResult.message); 39 | } 40 | 41 | return getVersionByQuery( 42 | customHeader: customHeader, 43 | onConvertVersion: (responseBody) { 44 | final versionResult = versionConvertService.convert(EmptyEntityModel.fromResponse(responseBody)); 45 | return versionResult.data; 46 | }, 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /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 | 39 | 40 | 41 | 42 | 43 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /lib/src/utils/messages/comparator_info_message.dart: -------------------------------------------------------------------------------- 1 | ///Version Comparator info messages. 2 | abstract class ComparatorInfoMessage { 3 | ///It is used to retrieve an error message when there is an issue with data retrieval. 4 | String get getDataError => 'Get Data Error'; 5 | 6 | ///It is used to retrieve an error message when there is an issue with data sending. 7 | String get getDataSuccess => 'Get Data Success'; 8 | 9 | ///It is used to retrieve an success message when data retrieval is success. 10 | String get sendDataError => 'Send Data Error'; 11 | 12 | ///It is used to retrieve an success message when data sending is success. 13 | String get sendDataSuccess => 'Send Data Success'; 14 | 15 | ///It is used to retrieve an error message when unexpected error happens. 16 | String get unExpectedError => 'Unexpected Error'; 17 | 18 | ///Version update AlertDialog title text. 19 | String get versionDialogTitle => 'Update Available'; 20 | 21 | ///Required update AlertDialog title text. 22 | String get requiredVersionDialogTitle => 'Update Required'; 23 | 24 | ///Cancel dialog action 25 | String get versionDialogCancelAction => 'Cancel'; 26 | 27 | ///Update version dialog action 28 | String get versionDialogUpdateAction => 'Update Now!'; 29 | 30 | ///New version is available message text. 31 | String versionDialogContent(String oldVersion, String latestVersion) => 32 | 'App version ($oldVersion) out of date. New version is available ($latestVersion). Would you like to update?'; 33 | 34 | ///Required version message text. 35 | String requiredVersionDialogContent( 36 | String oldVersion, String latestVersion) => 37 | 'App version ($oldVersion) out of date. Please update app to latest version ($latestVersion).'; 38 | 39 | ///When checks app version this message will display 40 | String get checkVersionLoadingMessage => 'App version checking...'; 41 | 42 | ///If any error occur dialog title will be display with this text. 43 | String get checkVersionErrorDialogTitle => 'Error'; 44 | 45 | ///OK action text 46 | String get checkVersionOkAction => 'OK'; 47 | } 48 | -------------------------------------------------------------------------------- /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 | return true; 35 | } 36 | 37 | void FlutterWindow::OnDestroy() { 38 | if (flutter_controller_) { 39 | flutter_controller_ = nullptr; 40 | } 41 | 42 | Win32Window::OnDestroy(); 43 | } 44 | 45 | LRESULT 46 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 47 | WPARAM const wparam, 48 | LPARAM const lparam) noexcept { 49 | // Give Flutter, including plugins, an opportunity to handle window messages. 50 | if (flutter_controller_) { 51 | std::optional result = 52 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 53 | lparam); 54 | if (result) { 55 | return *result; 56 | } 57 | } 58 | 59 | switch (message) { 60 | case WM_FONTCHANGE: 61 | flutter_controller_->engine()->ReloadSystemFonts(); 62 | break; 63 | } 64 | 65 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 66 | } 67 | -------------------------------------------------------------------------------- /lib/src/services/concretes/http_remote_data_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:http/http.dart' as http; 2 | 3 | import '../../models/entities/entity_model.dart'; 4 | import '../../models/parameters/get_data_service_parameter_model.dart'; 5 | import '../../models/parameters/send_data_service_parameter_model.dart'; 6 | import '../../models/parameters/service_parameter_model.dart'; 7 | import '../../utils/constants/constants.dart'; 8 | import '../../utils/results/data_result.dart'; 9 | import '../../utils/results/result.dart'; 10 | import '../abstracts/remote_data_service.dart'; 11 | 12 | class HttpRemoteDataManager extends RemoteDataService { 13 | HttpRemoteDataManager() : _client = http.Client(); 14 | 15 | Uri getUri(ServiceParameterModel parameterModel) => 16 | Uri.parse(parameterModel.getUrl()); 17 | 18 | final http.Client _client; 19 | 20 | @override 21 | Future> getData( 22 | GetDataServiceParameterModel parameterModel) async { 23 | try { 24 | final response = await _client 25 | .get(getUri(parameterModel), 26 | headers: parameterModel.header ?? baseHeader) 27 | .timeout(parameterModel.timeoutDuration); 28 | 29 | return response.statusCode == kHttpStatusOK 30 | ? DataResult.success(data: response.body) 31 | : DataResult.error(message: kInfoMessage.getDataError); 32 | } catch (exception) { 33 | return DataResult.error(message: exception.toString()); 34 | } 35 | } 36 | 37 | @override 38 | Future sendData>( 39 | SendDataServiceParameterModel parameterModel) async { 40 | try { 41 | final response = await _client 42 | .post(getUri(parameterModel), 43 | headers: parameterModel.header ?? baseHeader) 44 | .timeout(parameterModel.timeoutDuration); 45 | 46 | return response.statusCode == kHttpStatusOK 47 | ? Result.success(message: kInfoMessage.sendDataSuccess) 48 | : DataResult.error(message: kInfoMessage.sendDataError); 49 | } catch (exception) { 50 | return DataResult.error(message: exception.toString()); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /lib/src/utils/messages/comparator_error_message.dart: -------------------------------------------------------------------------------- 1 | ///Version Comparator error messages. 2 | abstract class ComparatorErrorMessage { 3 | /// 'App isn\'t found in the store. Please check your bundle and try again.' 4 | String get appNotFound => 5 | 'App isn\'t found in the store. Please check your bundle and try again.'; 6 | 7 | /// 'Downloaded app version can\'t fetch.' 8 | String get appVersionFetchError => 'Downloaded app version can\'t fetch.'; 9 | 10 | /// 'Downloaded app bundle id can\'t fetch.' 11 | String get appBundleIdFetchError => 'Downloaded app bundle id can\'t fetch.'; 12 | 13 | /// 'Version information is not found in the response' 14 | String get versionNotMatch => 15 | 'Version information is not found in the response'; 16 | 17 | /// 'Url can\'t launch' 18 | String get notLaunchUrl => 'Url can\'t launch'; 19 | 20 | /// 'Version comparator service is not set. You must set it!' 21 | String get versionComparatorNotSet => 22 | 'Version comparator service is not set. You must set it!'; 23 | 24 | /// 'Others platforms are not supported' 25 | String get otherPlatformsNotSupported => 'Others platforms are not supported'; 26 | 27 | /// 'You must add Huawei Store App Id for compare versions' 28 | String get huaweiAppIdNullOrEmpty => 29 | 'You must add Huawei Store App Id for compare versions'; 30 | 31 | /// 'App bundle Id and custom app Id are not valid. Version compare is not possible' 32 | String get bundleIdAndCustomIdNotValid => 33 | 'App bundle Id and custom app Id are not valid. Version compare is not possible'; 34 | 35 | /// 'This app platform is not handled' 36 | String get unHandledAppPlatformException => 37 | 'This app platform is not handled'; 38 | 39 | ///If data is null than this message displays. 40 | String get versionResponseNull => 'Data is null. App version can\'t compare'; 41 | 42 | /// Returns an error message indicating that the current platform is not supported 43 | /// for automatic version comparison. 44 | String get platformNotSupportedForThis => 45 | 'Current platform is not supported to the automatic version compare. Please use custom comparator in this platform'; 46 | } 47 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/platform/platform_decider_mixin_io.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:device_info_plus/device_info_plus.dart'; 4 | import 'package:version_comparator/src/utils/constants/constants.dart'; 5 | import 'package:version_comparator/version_comparator.dart'; 6 | 7 | /// This mixin decides which platform runs app. 8 | mixin PlatformDeciderMixin { 9 | /// Determines the platform on which the app is running. 10 | /// 11 | /// This method checks the current platform and returns the corresponding 12 | /// [AppPlatform] enum value. It supports Android, iOS, Linux, macOS, and 13 | /// Windows platforms. For Android, it further checks if the device 14 | /// manufacturer is Huawei and returns [AppPlatform.huawei] if true. 15 | /// 16 | /// Returns: 17 | /// - [AppPlatform.android] if the platform is Android and the manufacturer 18 | /// is not Huawei. 19 | /// - [AppPlatform.huawei] if the platform is Android and the manufacturer 20 | /// is Huawei. 21 | /// - [AppPlatform.ios] if the platform is iOS. 22 | /// - [AppPlatform.linux] if the platform is Linux. 23 | /// - [AppPlatform.macOs] if the platform is macOS. 24 | /// - [AppPlatform.windows] if the platform is Windows. 25 | /// - [AppPlatform.invalid] if the platform is none of the above. 26 | /// 27 | /// Throws: 28 | /// - Any exceptions thrown by the underlying platform detection or device 29 | /// info retrieval mechanisms. 30 | Future getPlatform() async { 31 | if (Platform.isAndroid) { 32 | final deviceInfo = DeviceInfoPlugin(); 33 | final info = await deviceInfo.androidInfo; 34 | 35 | return info.manufacturer.toUpperCase() == 36 | kHuaweiManufacturer.toUpperCase() 37 | ? AppPlatform.huawei 38 | : AppPlatform.android; 39 | } 40 | 41 | if (Platform.isIOS) { 42 | return AppPlatform.ios; 43 | } 44 | 45 | if (Platform.isLinux) { 46 | return AppPlatform.linux; 47 | } 48 | 49 | if (Platform.isMacOS) { 50 | return AppPlatform.macOs; 51 | } 52 | 53 | if (Platform.isWindows) { 54 | return AppPlatform.windows; 55 | } 56 | 57 | return AppPlatform.invalid; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | def localProperties = new Properties() 2 | def localPropertiesFile = rootProject.file('local.properties') 3 | if (localPropertiesFile.exists()) { 4 | localPropertiesFile.withReader('UTF-8') { reader -> 5 | localProperties.load(reader) 6 | } 7 | } 8 | 9 | def flutterRoot = localProperties.getProperty('flutter.sdk') 10 | if (flutterRoot == null) { 11 | throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") 12 | } 13 | 14 | def flutterVersionCode = localProperties.getProperty('flutter.versionCode') 15 | if (flutterVersionCode == null) { 16 | flutterVersionCode = '1' 17 | } 18 | 19 | def flutterVersionName = localProperties.getProperty('flutter.versionName') 20 | if (flutterVersionName == null) { 21 | flutterVersionName = '1.0' 22 | } 23 | 24 | apply plugin: 'com.android.application' 25 | apply plugin: 'kotlin-android' 26 | apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" 27 | 28 | android { 29 | compileSdkVersion flutter.compileSdkVersion 30 | ndkVersion flutter.ndkVersion 31 | 32 | compileOptions { 33 | sourceCompatibility JavaVersion.VERSION_1_8 34 | targetCompatibility JavaVersion.VERSION_1_8 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = '1.8' 39 | } 40 | 41 | sourceSets { 42 | main.java.srcDirs += 'src/main/kotlin' 43 | } 44 | 45 | defaultConfig { 46 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 47 | applicationId "com.example.example" 48 | // You can update the following values to match your application needs. 49 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 50 | minSdkVersion flutter.minSdkVersion 51 | targetSdkVersion flutter.targetSdkVersion 52 | versionCode flutterVersionCode.toInteger() 53 | versionName flutterVersionName 54 | } 55 | 56 | buildTypes { 57 | release { 58 | // TODO: Add your own signing config for the release build. 59 | // Signing with the debug keys for now, so `flutter run --release` works. 60 | signingConfig signingConfigs.debug 61 | } 62 | } 63 | } 64 | 65 | flutter { 66 | source '../..' 67 | } 68 | 69 | dependencies { 70 | implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" 71 | } 72 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /test/version_comparator_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:version_comparator/version_comparator.dart'; 3 | 4 | void main() { 5 | test( 6 | 'Compare equality of Android app version and store version with customVersionCompare test', 7 | () async { 8 | final result = await VersionComparator.instance.customCompare( 9 | localVersion: 'ADD_YOUR_APP_LOCAL_VERSION', 10 | store: AndroidStoreModel('ADD_YOUR_BUNDLE_ID'), 11 | customUpdateLink: (responseBody) => 'Custom app update link. (Optional)', 12 | onConvertVersion: (responseBody) => 13 | 'Convert store version from response.body', 14 | ); 15 | 16 | expect(result.isSuccess, true); 17 | expect(result.data == null, false); 18 | expect(result.data?.isAppVersionOld ?? true, false); 19 | }); 20 | 21 | test( 22 | 'Compare equality of iOS app version and store version with customVersionCompare test', 23 | () async { 24 | final result = await VersionComparator.instance.customCompare( 25 | localVersion: 'ADD_YOUR_APP_LOCAL_VERSION', 26 | store: IosStoreModel('ADD_YOUR_BUNDLE_ID'), 27 | customUpdateLink: (responseBody) => 'Custom app update link. (Optional)', 28 | onConvertVersion: (responseBody) => 29 | 'Convert store version from response.body', 30 | ); 31 | 32 | expect(result.isSuccess, true); 33 | expect(result.data == null, false); 34 | expect(result.data?.isAppVersionOld ?? true, false); 35 | }); 36 | 37 | test( 38 | 'Compare equality of Huawei app version and store version with customVersionCompare test', 39 | () async { 40 | final result = await VersionComparator.instance.customCompare( 41 | localVersion: 'ADD_YOUR_APP_LOCAL_VERSION', 42 | store: HuaweiStoreModel('ADD_YOUR_HUAWEI_APP_ID_FROM_APP_GALLERY'), 43 | customUpdateLink: (responseBody) => 'Custom app update link. (Optional)', 44 | 45 | ///convert response body for app version. You can convert response body using HuaweiVersionConverter for Huawei 46 | onConvertVersion: (responseBody) => 47 | 'Convert store version from response.body', 48 | 49 | ///get interface code from HuaweiVersionComparatorManager. 50 | ///interface code format --> '$interfaceCode_${DateTime.now().millisecondsSinceEpoch}' 51 | customHeader: Map.fromEntries([ 52 | const MapEntry('Interface-Code', 'ADD_INTERFACE_CODE_WITH_TIMESTAMP') 53 | ]), 54 | ); 55 | 56 | expect(result.isSuccess, true); 57 | expect(result.data == null, false); 58 | expect(result.data?.isAppVersionOld ?? true, false); 59 | }); 60 | } 61 | -------------------------------------------------------------------------------- /test/utils/mixins/version_compare_mixin_test.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter_test/flutter_test.dart'; 2 | import 'package:version_comparator/src/utils/mixins/version_compare_mixin.dart'; 3 | 4 | void main() { 5 | test( 6 | 'old app version (1.0.0) and up to date store version (1.0.20) compare test', 7 | () { 8 | final mockCompareMixin = MockComparator(); 9 | const currentVersion = '1.0.0'; 10 | const storeVersion = '1.0.20'; 11 | 12 | expect( 13 | mockCompareMixin.isCurrentVersionOld( 14 | currentVersion: currentVersion, storeVersion: storeVersion), 15 | true); 16 | }, 17 | ); 18 | 19 | test( 20 | 'equals app version and store version (1.0.0) compare test', 21 | () { 22 | final mockCompareMixin = MockComparator(); 23 | const currentVersion = '1.0.0'; 24 | const storeVersion = '1.0.0'; 25 | 26 | expect( 27 | mockCompareMixin.isCurrentVersionOld( 28 | currentVersion: currentVersion, storeVersion: storeVersion), 29 | false); 30 | }, 31 | ); 32 | 33 | test( 34 | 'higher app version (1.0.20) and old store version (1.0.0) compare test', 35 | () { 36 | final mockCompareMixin = MockComparator(); 37 | const currentVersion = '1.0.20'; 38 | const storeVersion = '1.0.0'; 39 | 40 | expect( 41 | mockCompareMixin.isCurrentVersionOld( 42 | currentVersion: currentVersion, storeVersion: storeVersion), 43 | false); 44 | }, 45 | ); 46 | 47 | test( 48 | 'old app version (1.0.0-abc) and up to date store version (1.0.20-abc) compare test', 49 | () { 50 | final mockCompareMixin = MockComparator(); 51 | const currentVersion = '1.0.0-abc'; 52 | const storeVersion = '1.0.20-abc'; 53 | 54 | expect( 55 | mockCompareMixin.isCurrentVersionOld( 56 | currentVersion: currentVersion, storeVersion: storeVersion), 57 | true); 58 | }, 59 | ); 60 | 61 | test( 62 | 'equals app version and store version (1.0.0-abc) compare test', 63 | () { 64 | final mockCompareMixin = MockComparator(); 65 | const currentVersion = '1.0.0-abc'; 66 | const storeVersion = '1.0.0-abc'; 67 | 68 | expect( 69 | mockCompareMixin.isCurrentVersionOld( 70 | currentVersion: currentVersion, storeVersion: storeVersion), 71 | false); 72 | }, 73 | ); 74 | 75 | test( 76 | 'higher app version (1.0.20-abc) and old store version (1.0.0-abc) compare test. Its expected version is old because string parameters is not equals', 77 | () { 78 | final mockCompareMixin = MockComparator(); 79 | const currentVersion = '1.0.20-abc'; 80 | const storeVersion = '1.0.0-abc'; 81 | 82 | expect( 83 | mockCompareMixin.isCurrentVersionOld( 84 | currentVersion: currentVersion, storeVersion: storeVersion), 85 | true); 86 | }, 87 | ); 88 | } 89 | 90 | class MockComparator with VersionCompareMixin {} 91 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/version_compare_mixin.dart: -------------------------------------------------------------------------------- 1 | import '../constants/constants.dart'; 2 | import '../helpers/regexp_helper.dart'; 3 | 4 | mixin VersionCompareMixin { 5 | bool isCurrentVersionOld({required String currentVersion, required String storeVersion, int defaultValue = kZero}) { 6 | if (currentVersion.isEmpty || storeVersion.isEmpty) return true; 7 | 8 | final convertedCurrentVersion = _convertVersion(currentVersion, defaultValue); 9 | final convertedStoreVersion = _convertVersion(storeVersion, defaultValue); 10 | 11 | if (convertedCurrentVersion is int && convertedStoreVersion is int) { 12 | return _isIntVersionOld(convertedCurrentVersion, convertedStoreVersion); 13 | } else if (convertedCurrentVersion is List && convertedStoreVersion is List) { 14 | return _isListVersionOld(convertedCurrentVersion, convertedStoreVersion); 15 | } else { 16 | return true; 17 | } 18 | } 19 | 20 | bool _isIntVersionOld(int currentVersion, int storeVersion) { 21 | return storeVersion > currentVersion; 22 | } 23 | 24 | bool _isListVersionOld(List currentVersion, List storeVersion) { 25 | if (currentVersion.length != storeVersion.length) return true; 26 | 27 | for (var index = 0; index < currentVersion.length; index++) { 28 | final currentVersionNumber = int.tryParse(currentVersion[index]); 29 | final storeVersionNumber = int.tryParse(storeVersion[index]); 30 | 31 | if (currentVersionNumber != null && storeVersionNumber != null) { 32 | if (_isIntVersionOld(currentVersionNumber, storeVersionNumber)) { 33 | return true; 34 | } 35 | } else { 36 | if (currentVersion[index].toLowerCase() != storeVersion[index].toLowerCase()) return true; 37 | } 38 | } 39 | 40 | return false; 41 | } 42 | 43 | Object _convertVersion(String version, int defaultValue) { 44 | final isVersionNumeric = RegExpHelper.isVersionOnlyNumeric(version); 45 | 46 | return isVersionNumeric 47 | ? _convertToInt(version, defaultValue: defaultValue) 48 | : _convertToList(version, defaultValue: defaultValue.toString()); 49 | } 50 | 51 | int _convertToInt(String version, {int defaultValue = kZero}) { 52 | final versionList = _convertToList(version, defaultValue: defaultValue.toString()); 53 | int convertedVersion = kZero; 54 | 55 | int multiplier = 1; 56 | int digitValue = 10; 57 | 58 | for (var element in versionList) { 59 | final value = int.tryParse(element); 60 | if (value == null) continue; 61 | 62 | convertedVersion += (value * multiplier); 63 | multiplier *= digitValue; 64 | } 65 | 66 | return convertedVersion; 67 | } 68 | 69 | List _convertToList(String version, {String defaultValue = kEmpty}) { 70 | // in this dart version, trim() is not working. Alternative solution is replacing 71 | final trimVersion = version.replaceAll(kSpace, kEmpty); 72 | 73 | final list = trimVersion.split(kVersionSplitter); 74 | return list.isEmpty ? [defaultValue] : list.reversed.toList(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /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/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 | -------------------------------------------------------------------------------- /.flutter-plugins-dependencies: -------------------------------------------------------------------------------- 1 | {"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"device_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_ios","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_ios-6.3.0/","native_build":true,"dependencies":[]}],"android":[{"name":"device_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_android","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_android-6.3.3/","native_build":true,"dependencies":[]}],"macos":[{"name":"device_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/","native_build":true,"dependencies":[]},{"name":"package_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/","native_build":true,"dependencies":[]},{"name":"url_launcher_macos","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_macos-3.2.0/","native_build":true,"dependencies":[]}],"linux":[{"name":"device_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/","native_build":false,"dependencies":[]},{"name":"url_launcher_linux","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_linux-3.1.1/","native_build":true,"dependencies":[]}],"windows":[{"name":"device_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/","native_build":false,"dependencies":[]},{"name":"package_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/","native_build":false,"dependencies":[]},{"name":"url_launcher_windows","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_windows-3.1.1/","native_build":true,"dependencies":[]}],"web":[{"name":"device_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/device_info_plus-11.2.2/","dependencies":[]},{"name":"package_info_plus","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/package_info_plus-8.2.0/","dependencies":[]},{"name":"url_launcher_web","path":"/Users/emregultekir/.pub-cache/hosted/pub.dev/url_launcher_web-2.3.3/","dependencies":[]}]},"dependencyGraph":[{"name":"device_info_plus","dependencies":[]},{"name":"package_info_plus","dependencies":[]},{"name":"url_launcher","dependencies":["url_launcher_android","url_launcher_ios","url_launcher_linux","url_launcher_macos","url_launcher_web","url_launcher_windows"]},{"name":"url_launcher_android","dependencies":[]},{"name":"url_launcher_ios","dependencies":[]},{"name":"url_launcher_linux","dependencies":[]},{"name":"url_launcher_macos","dependencies":[]},{"name":"url_launcher_web","dependencies":[]},{"name":"url_launcher_windows","dependencies":[]}],"date_created":"2025-02-04 14:20:23.115749","version":"3.22.1"} -------------------------------------------------------------------------------- /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 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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 | 41 | 42 | 52 | 54 | 60 | 61 | 62 | 63 | 69 | 71 | 77 | 78 | 79 | 80 | 82 | 83 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /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) 2023 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 | -------------------------------------------------------------------------------- /lib/src/utils/mixins/custom_version_comparator_view_state_mixin.dart: -------------------------------------------------------------------------------- 1 | part of '../../widgets/custom_version_comparator_view.dart'; 2 | 3 | mixin _CustomVersionComparatorViewStateMixin on State> 4 | implements VersionResultValidatorMixin { 5 | late VersionComparatorState _state; 6 | 7 | @override 8 | void initState() { 9 | super.initState(); 10 | _state = const VersionComparatorInitialState(); 11 | Future.microtask(() async => await _startVersionComparator()); 12 | } 13 | 14 | Future _startVersionComparator() async { 15 | final result = await _getVersionByValidation(); 16 | 17 | if (result.isNotSuccess || result.data == null) { 18 | _setState(VersionComparatorErrorState(message: result.message, isOldVersionError: false)); 19 | if (widget.errorPageBuilder == null) { 20 | await _showInvalidVersionAlert(result); 21 | } 22 | widget.onCompareError?.call(result.message); 23 | } else if (result.data?.isAppVersionOld ?? false) { 24 | if (!mounted) return; 25 | _setState(VersionComparatorErrorState( 26 | message: _getOutOfDateMessage(result.data!), 27 | data: result.data, 28 | isOldVersionError: true, 29 | )); 30 | widget.onOutOfDateVersionError?.call(_getOutOfDateMessage(result.data!), result.data!); 31 | await _showOldVersionAlert(result); 32 | } else { 33 | widget.onCompareSuccess?.call(result.data!); 34 | _setState(VersionComparatorSuccessState(result.data!)); 35 | } 36 | } 37 | 38 | Future> _getVersionByValidation() async { 39 | _setState(const VersionComparatorLoadingState()); 40 | final result = await widget.onVersionCompareCallback.call(); 41 | final versionValidationResult = isVersionResultValid(result); 42 | 43 | return DataResult( 44 | isSuccess: versionValidationResult.isSuccess, 45 | message: versionValidationResult.message, 46 | data: result.data, 47 | ); 48 | } 49 | 50 | Future _showInvalidVersionAlert(DataResult result) async { 51 | if (!mounted) return; 52 | final alertResult = await widget.dialogService?.showCustomVersionDialog( 53 | context: context, 54 | isDismissible: false, 55 | dialog: widget.invalidVersionDialogContentBuilder?.call(context, result.message) ?? 56 | VersionResultErrorDialogContent( 57 | content: result.message, 58 | onPressed: () { 59 | widget.onCompareError?.call(result.message); 60 | Navigator.of(context).pop(widget.popVersionDialogResult); 61 | }, 62 | ), 63 | ); 64 | 65 | widget.onAfterPopDialog?.call(alertResult); 66 | } 67 | 68 | Future _showOldVersionAlert(DataResult result) async { 69 | if (!mounted) return; 70 | final alertResult = await widget.dialogService?.showVersionDialog( 71 | context: context, 72 | versionModel: result.data!, 73 | isUpdateRequired: widget.isUpdateRequired, 74 | isCancelActionVisible: widget.isCancelActionVisible, 75 | popResult: widget.popVersionDialogResult, 76 | ); 77 | 78 | widget.onAfterPopDialog?.call(alertResult); 79 | } 80 | 81 | void _setState(VersionComparatorState state) { 82 | setState(() { 83 | _state = state; 84 | }); 85 | 86 | widget.onStateChanged?.call(state); 87 | } 88 | 89 | String _getOutOfDateMessage(VersionResponseModel versionModel) => widget.isUpdateRequired 90 | ? kInfoMessage.requiredVersionDialogContent(versionModel.localVersion, versionModel.storeVersion) 91 | : kInfoMessage.versionDialogContent(versionModel.localVersion, versionModel.storeVersion); 92 | } 93 | -------------------------------------------------------------------------------- /lib/version_comparator.dart: -------------------------------------------------------------------------------- 1 | library version_comparator; 2 | 3 | import 'src/models/index.dart'; 4 | import 'src/services/concretes/http_remote_data_manager.dart'; 5 | import 'src/services/index.dart'; 6 | import 'src/utils/constants/constants.dart'; 7 | import 'src/utils/helpers/version_compare_service_factory.dart'; 8 | import 'src/utils/index.dart'; 9 | import 'src/utils/mixins/bundle_id_controller_mixin.dart'; 10 | 11 | export 'src/models/index.dart'; 12 | export 'src/services/index.dart'; 13 | export 'src/utils/index.dart'; 14 | export 'src/widgets/index.dart'; 15 | 16 | ///The mission of the VersionComparator class is to compare different versions of an app. 17 | ///It has three methods: versionCompare, versionCompareWithHuawei and customCompare. 18 | ///The versionCompare methods are used to compare platform-specific versions, such as Android, iOS, and Huawei. 19 | ///The customCompare method is used to compare versions with custom settings. 20 | ///This method can be used when the project platform is different from Android, 21 | ///iOS or Huawei, or when comparing versions from other stores. 22 | class VersionComparator extends BaseVersionComparator 23 | with BundleIdControllerMixin, VersionDialogMixin { 24 | static VersionComparator? _instance; 25 | static VersionComparator get instance => getInstanceByDialogService(); 26 | 27 | ///Create a `VersionComparator` instance using with custom `VersionDialogService` (optional) 28 | static VersionComparator getInstanceByDialogService( 29 | {VersionDialogService? dialogService}) { 30 | _instance ??= VersionComparator._init( 31 | dialogService: dialogService ?? VersionDialogManager()); 32 | 33 | if (dialogService != null && 34 | (_instance!.dialogService.runtimeType != dialogService.runtimeType)) { 35 | _instance = VersionComparator._init(dialogService: dialogService); 36 | } 37 | return _instance!; 38 | } 39 | 40 | VersionComparator._init({required this.dialogService}); 41 | 42 | @override 43 | 44 | ///Version Dialog Service 45 | final VersionDialogService dialogService; 46 | 47 | @override 48 | 49 | ///Compare app version between current version and store version. 50 | ///If your app available on AppGallery, this method recommended for you. 51 | ///It compares app version automatically on Popular App Stores [`PlayStore`,`AppStore`,`AppGallery`] 52 | Future> versionCompareWithHuawei({ 53 | ///Network Request Manager 54 | RemoteDataService? dataService, 55 | 56 | ///App's id on AppGallery. It's required for retrieve version from Huawei store. 57 | required String huaweiId, 58 | 59 | ///Custom android bundle id. If you want to compare different app, set this parameter. 60 | ///Default value is app bundle id 61 | String? androidId, 62 | 63 | ///Custom ios bundle id. If you want to compare different app, set this parameter. 64 | ///Default value is app bundle id 65 | String? iosId, 66 | }) async { 67 | final platform = await getPlatform(); 68 | final bundleResult = await getBundleByOptionalId( 69 | platform: platform, 70 | androidId: androidId, 71 | iosId: iosId, 72 | huaweiId: huaweiId, 73 | ); 74 | 75 | if (bundleResult.isNotSuccess) { 76 | return DataResult.error(message: bundleResult.message); 77 | } 78 | 79 | final remoteService = dataService ?? HttpRemoteDataManager(); 80 | 81 | try { 82 | final versionComparatorService = 83 | VersionCompareServiceFactory(platform: platform).getCompareService( 84 | dataService: remoteService, 85 | bundleId: bundleResult.data ?? kEmpty, 86 | ); 87 | 88 | setVersionComparator(versionComparatorService); 89 | } catch (_) { 90 | return DataResult.error( 91 | message: kErrorMessage.platformNotSupportedForThis, 92 | ); 93 | } 94 | 95 | return await versionComparator?.getVersion() ?? 96 | DataResult.error(message: kErrorMessage.versionComparatorNotSet); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /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 | // responsponds 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/src/widgets/platform_specific_version_comparator_view.dart: -------------------------------------------------------------------------------- 1 | import '../../version_comparator.dart'; 2 | import '../utils/constants/constants.dart'; 3 | 4 | class AppVersionComparatorView 5 | extends CustomVersionComparatorView { 6 | AppVersionComparatorView({ 7 | super.key, 8 | required super.child, 9 | super.onStateChanged, 10 | String? androidId, 11 | String? iosId, 12 | String? huaweiId, 13 | RemoteDataService? dataService, 14 | super.onOutOfDateVersionError, 15 | super.versionDialogService, 16 | super.errorPageBuilder, 17 | super.outOfDateVersionPageBuilder, 18 | super.onAfterPopDialog, 19 | super.popVersionDialogResult, 20 | super.onCompareSuccess, 21 | super.onCompareError, 22 | super.invalidVersionDialogContentBuilder, 23 | super.outOfDateVersionDialogContentBuilder, 24 | super.loadingType = CheckVersionLoadingType.widget, 25 | super.loadingWidgetSize = kLoadingWidgetSize, 26 | super.isLoadingTextVisible = true, 27 | super.isChildExpandedInStack = false, 28 | super.isDismissibleWhenGetDataError = false, 29 | super.isUpdateRequired = false, 30 | super.isCancelActionVisible = true, 31 | super.spaceAroundChild = kMediumSpace, 32 | super.loadingWidget, 33 | super.loadingText, 34 | }) : super( 35 | onVersionCompareCallback: () async { 36 | return await VersionComparator.instance.versionCompare( 37 | iosId: iosId, 38 | huaweiId: huaweiId, 39 | androidId: androidId, 40 | dataService: dataService, 41 | ); 42 | }, 43 | ); 44 | 45 | AppVersionComparatorView.alertDialog({ 46 | super.key, 47 | required super.child, 48 | super.versionDialogService, 49 | super.onStateChanged, 50 | String? androidId, 51 | String? iosId, 52 | String? huaweiId, 53 | RemoteDataService? dataService, 54 | super.onOutOfDateVersionError, 55 | super.onAfterPopDialog, 56 | super.popVersionDialogResult, 57 | super.onCompareSuccess, 58 | super.onCompareError, 59 | super.invalidVersionDialogContentBuilder, 60 | super.loadingWidgetSize = kLoadingWidgetSize, 61 | super.isLoadingTextVisible = true, 62 | super.isChildExpandedInStack = false, 63 | super.isDismissibleWhenGetDataError = false, 64 | super.isUpdateRequired = false, 65 | super.isCancelActionVisible = true, 66 | super.spaceAroundChild = kMediumSpace, 67 | super.loadingWidget, 68 | super.loadingText, 69 | }) : super.alertDialog( 70 | onVersionCompareCallback: () async { 71 | return await VersionComparator.instance.versionCompare( 72 | iosId: iosId, 73 | huaweiId: huaweiId, 74 | androidId: androidId, 75 | dataService: dataService, 76 | ); 77 | }, 78 | ); 79 | 80 | AppVersionComparatorView.widget({ 81 | super.key, 82 | required super.errorPageBuilder, 83 | required super.outOfDateVersionPageBuilder, 84 | required super.child, 85 | super.onStateChanged, 86 | String? androidId, 87 | String? iosId, 88 | String? huaweiId, 89 | RemoteDataService? dataService, 90 | super.onOutOfDateVersionError, 91 | super.onCompareSuccess, 92 | super.onCompareError, 93 | super.loadingWidgetSize = kLoadingWidgetSize, 94 | super.isLoadingTextVisible = true, 95 | super.isChildExpandedInStack = false, 96 | super.isUpdateRequired = false, 97 | super.spaceAroundChild = kMediumSpace, 98 | super.loadingWidget, 99 | super.loadingText, 100 | }) : super.widget( 101 | onVersionCompareCallback: () async { 102 | return await VersionComparator.instance.versionCompare( 103 | iosId: iosId, 104 | huaweiId: huaweiId, 105 | androidId: androidId, 106 | dataService: dataService, 107 | ); 108 | }, 109 | ); 110 | } 111 | -------------------------------------------------------------------------------- /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 | # === Flutter Library === 14 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 15 | 16 | # Published to parent scope for install step. 17 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 18 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 19 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 20 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 21 | 22 | list(APPEND FLUTTER_LIBRARY_HEADERS 23 | "flutter_export.h" 24 | "flutter_windows.h" 25 | "flutter_messenger.h" 26 | "flutter_plugin_registrar.h" 27 | "flutter_texture_registrar.h" 28 | ) 29 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 30 | add_library(flutter INTERFACE) 31 | target_include_directories(flutter INTERFACE 32 | "${EPHEMERAL_DIR}" 33 | ) 34 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 35 | add_dependencies(flutter flutter_assemble) 36 | 37 | # === Wrapper === 38 | list(APPEND CPP_WRAPPER_SOURCES_CORE 39 | "core_implementations.cc" 40 | "standard_codec.cc" 41 | ) 42 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 43 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 44 | "plugin_registrar.cc" 45 | ) 46 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 47 | list(APPEND CPP_WRAPPER_SOURCES_APP 48 | "flutter_engine.cc" 49 | "flutter_view_controller.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 52 | 53 | # Wrapper sources needed for a plugin. 54 | add_library(flutter_wrapper_plugin STATIC 55 | ${CPP_WRAPPER_SOURCES_CORE} 56 | ${CPP_WRAPPER_SOURCES_PLUGIN} 57 | ) 58 | apply_standard_settings(flutter_wrapper_plugin) 59 | set_target_properties(flutter_wrapper_plugin PROPERTIES 60 | POSITION_INDEPENDENT_CODE ON) 61 | set_target_properties(flutter_wrapper_plugin PROPERTIES 62 | CXX_VISIBILITY_PRESET hidden) 63 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 64 | target_include_directories(flutter_wrapper_plugin PUBLIC 65 | "${WRAPPER_ROOT}/include" 66 | ) 67 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 68 | 69 | # Wrapper sources needed for the runner. 70 | add_library(flutter_wrapper_app STATIC 71 | ${CPP_WRAPPER_SOURCES_CORE} 72 | ${CPP_WRAPPER_SOURCES_APP} 73 | ) 74 | apply_standard_settings(flutter_wrapper_app) 75 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 76 | target_include_directories(flutter_wrapper_app PUBLIC 77 | "${WRAPPER_ROOT}/include" 78 | ) 79 | add_dependencies(flutter_wrapper_app flutter_assemble) 80 | 81 | # === Flutter tool backend === 82 | # _phony_ is a non-existent file to force this command to run every time, 83 | # since currently there's no way to get a full input/output list from the 84 | # flutter tool. 85 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 86 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 87 | add_custom_command( 88 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 89 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 90 | ${CPP_WRAPPER_SOURCES_APP} 91 | ${PHONY_OUTPUT} 92 | COMMAND ${CMAKE_COMMAND} -E env 93 | ${FLUTTER_TOOL_ENVIRONMENT} 94 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 95 | windows-x64 $ 96 | VERBATIM 97 | ) 98 | add_custom_target(flutter_assemble DEPENDS 99 | "${FLUTTER_LIBRARY}" 100 | ${FLUTTER_LIBRARY_HEADERS} 101 | ${CPP_WRAPPER_SOURCES_CORE} 102 | ${CPP_WRAPPER_SOURCES_PLUGIN} 103 | ${CPP_WRAPPER_SOURCES_APP} 104 | ) 105 | -------------------------------------------------------------------------------- /example/linux/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 GObject::dispose. 85 | static void my_application_dispose(GObject* object) { 86 | MyApplication* self = MY_APPLICATION(object); 87 | g_clear_pointer(&self->dart_entrypoint_arguments, g_strfreev); 88 | G_OBJECT_CLASS(my_application_parent_class)->dispose(object); 89 | } 90 | 91 | static void my_application_class_init(MyApplicationClass* klass) { 92 | G_APPLICATION_CLASS(klass)->activate = my_application_activate; 93 | G_APPLICATION_CLASS(klass)->local_command_line = my_application_local_command_line; 94 | G_OBJECT_CLASS(klass)->dispose = my_application_dispose; 95 | } 96 | 97 | static void my_application_init(MyApplication* self) {} 98 | 99 | MyApplication* my_application_new() { 100 | return MY_APPLICATION(g_object_new(my_application_get_type(), 101 | "application-id", APPLICATION_ID, 102 | "flags", G_APPLICATION_NON_UNIQUE, 103 | nullptr)); 104 | } 105 | -------------------------------------------------------------------------------- /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(SET CMP0063 NEW) 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 | # Generated plugin build rules, which manage building the plugins and adding 56 | # them to the application. 57 | include(flutter/generated_plugins.cmake) 58 | 59 | 60 | # === Installation === 61 | # Support files are copied into place next to the executable, so that it can 62 | # run in place. This is done instead of making a separate bundle (as on Linux) 63 | # so that building and running from within Visual Studio will work. 64 | set(BUILD_BUNDLE_DIR "$") 65 | # Make the "install" step default, as it's required to run. 66 | set(CMAKE_VS_INCLUDE_INSTALL_TO_DEFAULT_BUILD 1) 67 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 68 | set(CMAKE_INSTALL_PREFIX "${BUILD_BUNDLE_DIR}" CACHE PATH "..." FORCE) 69 | endif() 70 | 71 | set(INSTALL_BUNDLE_DATA_DIR "${CMAKE_INSTALL_PREFIX}/data") 72 | set(INSTALL_BUNDLE_LIB_DIR "${CMAKE_INSTALL_PREFIX}") 73 | 74 | install(TARGETS ${BINARY_NAME} RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}" 75 | COMPONENT Runtime) 76 | 77 | install(FILES "${FLUTTER_ICU_DATA_FILE}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 78 | COMPONENT Runtime) 79 | 80 | install(FILES "${FLUTTER_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 81 | COMPONENT Runtime) 82 | 83 | if(PLUGIN_BUNDLED_LIBRARIES) 84 | install(FILES "${PLUGIN_BUNDLED_LIBRARIES}" 85 | DESTINATION "${INSTALL_BUNDLE_LIB_DIR}" 86 | COMPONENT Runtime) 87 | endif() 88 | 89 | # Fully re-copy the assets directory on each build to avoid having stale files 90 | # from a previous install. 91 | set(FLUTTER_ASSET_DIR_NAME "flutter_assets") 92 | install(CODE " 93 | file(REMOVE_RECURSE \"${INSTALL_BUNDLE_DATA_DIR}/${FLUTTER_ASSET_DIR_NAME}\") 94 | " COMPONENT Runtime) 95 | install(DIRECTORY "${PROJECT_BUILD_DIR}/${FLUTTER_ASSET_DIR_NAME}" 96 | DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" COMPONENT Runtime) 97 | 98 | # Install the AOT library on non-Debug builds only. 99 | install(FILES "${AOT_LIBRARY}" DESTINATION "${INSTALL_BUNDLE_DATA_DIR}" 100 | CONFIGURATIONS Profile;Release 101 | COMPONENT Runtime) 102 | -------------------------------------------------------------------------------- /lib/src/services/abstracts/version_compare_service.dart: -------------------------------------------------------------------------------- 1 | import '../../models/entities/store/base_store_model.dart'; 2 | import '../../models/parameters/get_data_service_parameter_model.dart'; 3 | import '../../models/version_response_model.dart'; 4 | import '../../utils/constants/constants.dart'; 5 | import '../../utils/mixins/launch_url_mixin.dart'; 6 | import '../../utils/mixins/package_info_mixin.dart'; 7 | import '../../utils/results/data_result.dart'; 8 | import 'remote_data_service.dart'; 9 | 10 | abstract class VersionCompareService with PackageInfoMixin, LaunchUrlMixin { 11 | BaseStoreModel get store; 12 | RemoteDataService get dataService; 13 | 14 | Future> getVersion({Map? customHeader}); 15 | } 16 | 17 | abstract class VersionCompareByQueryService extends VersionCompareService { 18 | /// This function retrieves the store version by querying using custom parameters. 19 | /// It returns a Future that resolves to a DataResult containing the store version. 20 | /// Overall, this code asynchronously retrieves the current app version and 21 | /// then uses it as a parameter to query the store version with custom parameters. 22 | Future> getVersionByQuery({ 23 | required String? Function(String responseBody) onConvertVersion, 24 | String? Function(String responseBody)? customUpdateLink, 25 | Map? customHeader, 26 | }) async { 27 | // Retrieve the current app version. 28 | final appVersionResult = await getCurrentAppVersion(); 29 | // If the retrieval of the app version is not successful, 30 | // return a DataResult with an error message. 31 | if (appVersionResult.isNotSuccess) { 32 | return DataResult.error(message: appVersionResult.message); 33 | } 34 | 35 | // Call the getStoreVersionByQuery function with the following parameters: 36 | // - customHeader: The custom headers provided. 37 | // - onConvertVersion: The function to convert the response body to a version string. 38 | // - customUpdateLink: The optional function to provide a custom update link. 39 | // - localVersion: The app's current version, retrieved from appVersionResult.data. 40 | // If appVersionResult.data is null, use the value of kEmpty. 41 | return getStoreVersionByQuery( 42 | customHeader: customHeader, 43 | onConvertVersion: onConvertVersion, 44 | customUpdateLink: customUpdateLink, 45 | localVersion: appVersionResult.data ?? kEmpty, 46 | ); 47 | } 48 | 49 | /// This function retrieves the store version by querying using custom parameters. 50 | /// It returns a Future that resolves to a DataResult containing the store version. 51 | /// Overall, this code performs the query to retrieve the store version using the provided parameters, 52 | /// handles error conditions, and returns a DataResult with the version information. 53 | Future> getStoreVersionByQuery({ 54 | required String? Function(String responseBody) onConvertVersion, 55 | required String localVersion, 56 | String? Function(String responseBody)? customUpdateLink, 57 | Map? customHeader, 58 | }) async { 59 | // Create a GetDataServiceParameterModel object with the following parameters: 60 | // - url: The store's URL. 61 | // - query: The version query for the store. 62 | // - header: The custom headers provided. 63 | final parameter = GetDataServiceParameterModel( 64 | url: store.storeUrl, 65 | query: store.versionQuery, 66 | header: customHeader, 67 | ); 68 | 69 | // Call the getData() method of the dataService with the parameter object. 70 | // The response is stored in the 'response' variable. 71 | final response = await dataService.getData(parameter); 72 | 73 | // If the response is not successful or the data is null, 74 | // return a DataResult with an error message. 75 | if (response.isNotSuccess || response.data == null) { 76 | return DataResult.error(message: response.message); 77 | } 78 | 79 | // Call the onConvertVersion function with the response data. 80 | // The result is stored in the 'version' variable. 81 | final version = onConvertVersion.call(response.data!); 82 | 83 | // If the version is null or empty, return a DataResult with an error message. 84 | if (version == null || version.isEmpty) { 85 | return DataResult.error(message: kErrorMessage.versionResponseNull); 86 | } 87 | 88 | // Create a VersionResponseModel object with the following parameters: 89 | // - localVersion: The app's current version. 90 | // - storeVersion: The converted version obtained from the response. 91 | // - updateLink: The custom update link if available, otherwise the URL from the parameter object. 92 | return DataResult.success( 93 | data: VersionResponseModel( 94 | localVersion: localVersion, 95 | storeVersion: version, 96 | updateLink: customUpdateLink?.call(response.data!) ?? parameter.getUrl(), 97 | ), 98 | ); 99 | } 100 | } 101 | --------------------------------------------------------------------------------