├── example ├── linux │ ├── .gitignore │ ├── main.cc │ ├── flutter │ │ ├── generated_plugin_registrant.cc │ │ ├── generated_plugin_registrant.h │ │ ├── generated_plugins.cmake │ │ └── CMakeLists.txt │ └── my_application.h ├── ios │ ├── Flutter │ │ ├── Debug.xcconfig │ │ ├── Release.xcconfig │ │ └── AppFrameworkInfo.plist │ ├── Runner │ │ ├── Runner-Bridging-Header.h │ │ ├── Assets.xcassets │ │ │ ├── LaunchImage.imageset │ │ │ │ ├── LaunchImage.png │ │ │ │ ├── LaunchImage@2x.png │ │ │ │ ├── LaunchImage@3x.png │ │ │ │ ├── README.md │ │ │ │ └── Contents.json │ │ │ └── AppIcon.appiconset │ │ │ │ ├── Icon-App-20x20@1x.png │ │ │ │ ├── Icon-App-20x20@2x.png │ │ │ │ ├── Icon-App-20x20@3x.png │ │ │ │ ├── Icon-App-29x29@1x.png │ │ │ │ ├── Icon-App-29x29@2x.png │ │ │ │ ├── Icon-App-29x29@3x.png │ │ │ │ ├── Icon-App-40x40@1x.png │ │ │ │ ├── Icon-App-40x40@2x.png │ │ │ │ ├── Icon-App-40x40@3x.png │ │ │ │ ├── Icon-App-60x60@2x.png │ │ │ │ ├── Icon-App-60x60@3x.png │ │ │ │ ├── Icon-App-76x76@1x.png │ │ │ │ ├── Icon-App-76x76@2x.png │ │ │ │ ├── Icon-App-1024x1024@1x.png │ │ │ │ ├── Icon-App-83.5x83.5@2x.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Base.lproj │ │ │ ├── Main.storyboard │ │ │ └── LaunchScreen.storyboard │ │ └── Info.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ ├── contents.xcworkspacedata │ │ │ └── xcshareddata │ │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ ├── WorkspaceSettings.xcsettings │ │ │ └── IDEWorkspaceChecks.plist │ ├── .gitignore │ └── RunnerTests │ │ └── RunnerTests.swift ├── macos │ ├── Flutter │ │ ├── Flutter-Debug.xcconfig │ │ ├── Flutter-Release.xcconfig │ │ └── GeneratedPluginRegistrant.swift │ ├── Runner │ │ ├── Configs │ │ │ ├── Debug.xcconfig │ │ │ ├── Release.xcconfig │ │ │ ├── Warnings.xcconfig │ │ │ └── AppInfo.xcconfig │ │ ├── Assets.xcassets │ │ │ └── AppIcon.appiconset │ │ │ │ ├── app_icon_128.png │ │ │ │ ├── app_icon_16.png │ │ │ │ ├── app_icon_256.png │ │ │ │ ├── app_icon_32.png │ │ │ │ ├── app_icon_512.png │ │ │ │ ├── app_icon_64.png │ │ │ │ ├── app_icon_1024.png │ │ │ │ └── Contents.json │ │ ├── AppDelegate.swift │ │ ├── Release.entitlements │ │ ├── DebugProfile.entitlements │ │ ├── MainFlutterWindow.swift │ │ └── Info.plist │ ├── .gitignore │ ├── Runner.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ ├── Runner.xcodeproj │ │ ├── project.xcworkspace │ │ │ └── xcshareddata │ │ │ │ └── IDEWorkspaceChecks.plist │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── Runner.xcscheme │ └── RunnerTests │ │ └── RunnerTests.swift ├── web │ ├── favicon.png │ ├── icons │ │ ├── Icon-192.png │ │ ├── Icon-512.png │ │ ├── Icon-maskable-192.png │ │ └── Icon-maskable-512.png │ ├── manifest.json │ └── index.html ├── 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 ├── android │ ├── gradle.properties │ ├── gradle │ │ └── wrapper │ │ │ ├── gradle-wrapper.jar │ │ │ └── gradle-wrapper.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 │ │ │ │ │ │ └── jhomlala │ │ │ │ │ │ └── catcher_2_example │ │ │ │ │ │ └── MainActivity.kt │ │ │ │ └── AndroidManifest.xml │ │ │ ├── debug │ │ │ │ └── AndroidManifest.xml │ │ │ └── profile │ │ │ │ └── AndroidManifest.xml │ │ └── build.gradle │ ├── .gitignore │ ├── build.gradle │ ├── settings.gradle │ └── gradlew.bat ├── README.md ├── .gitignore ├── analysis_options.yaml ├── lib │ ├── basic_example.dart │ ├── sentry_example.dart │ ├── occurences_timeout_example.dart │ ├── discord_handler_example.dart │ ├── custom_navigator_key_example.dart │ ├── report_modes_example.dart │ ├── explicit_error_report_handler_map_example.dart │ ├── slack_handler_example.dart │ ├── email_manual_handler_example.dart │ ├── cupertino_example.dart │ ├── excluded_parameters_example.dart │ ├── filter_example.dart │ ├── http_handler_update_headers_example.dart │ ├── error_widget_example.dart │ ├── update_config_example.dart │ ├── change_custom_parameters_example.dart │ ├── explicit_error_report_mode_map_example.dart │ ├── custom_logger_example.dart │ ├── snackbar_handler_example.dart │ ├── screenshot_example.dart │ ├── main.dart │ ├── file_example.dart │ ├── custom_report_mode_example.dart │ └── localization_example.dart └── pubspec.yaml ├── backend ├── src │ ├── main │ │ ├── resources │ │ │ ├── application.properties │ │ │ └── templates │ │ │ │ └── reports.html │ │ └── java │ │ │ └── com │ │ │ └── jhomlala │ │ │ └── catcher_2 │ │ │ └── backend │ │ │ ├── BackendApplication.java │ │ │ ├── ReportLogService.java │ │ │ ├── ReportLogController.java │ │ │ └── ReportLog.java │ └── test │ │ └── java │ │ └── com │ │ └── jhomlala │ │ └── catcher_2 │ │ └── backend │ │ └── BackendApplicationTests.java ├── .mvn │ └── wrapper │ │ ├── maven-wrapper.jar │ │ └── maven-wrapper.properties ├── .gitignore └── pom.xml ├── lib ├── model │ ├── http_request_type.dart │ ├── toast_handler_length.dart │ ├── toast_handler_gravity.dart │ ├── platform_type.dart │ ├── application_profile.dart │ ├── report_handler.dart │ ├── report_mode.dart │ └── report.dart ├── mode │ ├── report_mode_action_confirmed.dart │ ├── silent_report_mode.dart │ └── dialog_report_mode.dart ├── core │ ├── catcher_2_screenshot.dart │ ├── application_profile_manager.dart │ └── catcher_2_screenshot_manager.dart ├── utils │ ├── catcher_2_logger.dart │ ├── catcher_2_utils.dart │ └── catcher_2_error_widget.dart ├── catcher_2.dart └── handlers │ ├── email_manual_handler.dart │ ├── console_handler.dart │ ├── email_auto_handler.dart │ └── http_handler.dart ├── analysis_options.yaml ├── screenshots ├── 1.png ├── 3.png ├── 4.png ├── 5.png ├── 6.png ├── 7.png ├── 8.png ├── 9.png └── logo.png ├── SECURITY.md ├── .github ├── ISSUE_TEMPLATE │ ├── feature_request.md │ ├── compatibility-issue.md │ └── bug_report.yaml ├── workflows │ └── ci.yml └── FUNDING.yml ├── .gitignore ├── pubspec.yaml ├── .metadata └── platform_support.md /example/linux/.gitignore: -------------------------------------------------------------------------------- 1 | flutter/ephemeral 2 | -------------------------------------------------------------------------------- /backend/src/main/resources/application.properties: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /example/ios/Flutter/Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /lib/model/http_request_type.dart: -------------------------------------------------------------------------------- 1 | enum HttpRequestType { post } 2 | -------------------------------------------------------------------------------- /analysis_options.yaml: -------------------------------------------------------------------------------- 1 | include: package:flutter_lints/flutter.yaml 2 | -------------------------------------------------------------------------------- /example/ios/Flutter/Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /lib/model/toast_handler_length.dart: -------------------------------------------------------------------------------- 1 | enum ToastHandlerLength { short, long } 2 | -------------------------------------------------------------------------------- /example/ios/Runner/Runner-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | #import "GeneratedPluginRegistrant.h" 2 | -------------------------------------------------------------------------------- /lib/model/toast_handler_gravity.dart: -------------------------------------------------------------------------------- 1 | enum ToastHandlerGravity { bottom, center, top } 2 | -------------------------------------------------------------------------------- /screenshots/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/1.png -------------------------------------------------------------------------------- /screenshots/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/3.png -------------------------------------------------------------------------------- /screenshots/4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/4.png -------------------------------------------------------------------------------- /screenshots/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/5.png -------------------------------------------------------------------------------- /screenshots/6.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/6.png -------------------------------------------------------------------------------- /screenshots/7.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/7.png -------------------------------------------------------------------------------- /screenshots/8.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/8.png -------------------------------------------------------------------------------- /screenshots/9.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/9.png -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Debug.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /example/macos/Flutter/Flutter-Release.xcconfig: -------------------------------------------------------------------------------- 1 | #include "ephemeral/Flutter-Generated.xcconfig" 2 | -------------------------------------------------------------------------------- /screenshots/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/screenshots/logo.png -------------------------------------------------------------------------------- /example/web/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/web/favicon.png -------------------------------------------------------------------------------- /example/web/icons/Icon-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/web/icons/Icon-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/web/icons/Icon-512.png -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /backend/.mvn/wrapper/maven-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/backend/.mvn/wrapper/maven-wrapper.jar -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-192.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/web/icons/Icon-maskable-192.png -------------------------------------------------------------------------------- /example/web/icons/Icon-maskable-512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/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/windows/runner/resources/app_icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/windows/runner/resources/app_icon.ico -------------------------------------------------------------------------------- /example/android/gradle.properties: -------------------------------------------------------------------------------- 1 | org.gradle.jvmargs=-Xmx4G -XX:+HeapDumpOnOutOfMemoryError 2 | android.useAndroidX=true 3 | android.enableJetifier=true 4 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/android/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /lib/model/platform_type.dart: -------------------------------------------------------------------------------- 1 | enum PlatformType { 2 | android, 3 | iOS, 4 | web, 5 | macOS, 6 | linux, 7 | windows, 8 | unknown, 9 | } 10 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-hdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/HEAD/example/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/HEAD/example/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_128.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_16.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_256.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_32.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_512.png -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_64.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/LaunchImage@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/HEAD/example/macos/Runner/Assets.xcassets/AppIcon.appiconset/app_icon_1024.png -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ThexXTURBOXx/catcher_2/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/ThexXTURBOXx/catcher_2/HEAD/example/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png -------------------------------------------------------------------------------- /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/android/app/src/main/kotlin/com/jhomlala/catcher_2_example/MainActivity.kt: -------------------------------------------------------------------------------- 1 | package com.jhomlala.catcher_2_example 2 | 3 | import io.flutter.embedding.android.FlutterActivity 4 | 5 | class MainActivity: FlutterActivity() 6 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/macos/Runner.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /lib/model/application_profile.dart: -------------------------------------------------------------------------------- 1 | /// Available application run modes. 2 | enum ApplicationProfile { 3 | /// Debug mode 4 | debug, 5 | 6 | /// Release mode 7 | release, 8 | 9 | /// Profile mode 10 | profile, 11 | } 12 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugin_registrant.cc: -------------------------------------------------------------------------------- 1 | // 2 | // Generated file. Do not edit. 3 | // 4 | 5 | // clang-format off 6 | 7 | #include "generated_plugin_registrant.h" 8 | 9 | 10 | void fl_register_plugins(FlPluginRegistry* registry) { 11 | } 12 | -------------------------------------------------------------------------------- /example/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 | -------------------------------------------------------------------------------- /example/macos/Runner/Release.entitlements: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | com.apple.security.app-sandbox 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/.gitignore: -------------------------------------------------------------------------------- 1 | /.gradle 2 | /captures/ 3 | /local.properties 4 | GeneratedPluginRegistrant.java 5 | 6 | # Remember to never publicly share your keystore. 7 | # See https://flutter.dev/docs/deployment/android#reference-the-keystore-from-the-app 8 | key.properties 9 | **/*.keystore 10 | **/*.jks 11 | -------------------------------------------------------------------------------- /example/ios/Runner.xcworkspace/xcshareddata/WorkspaceSettings.xcsettings: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreviewsEnabled 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /example/android/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip 4 | networkTimeout=10000 5 | validateDistributionUrl=true 6 | zipStoreBase=GRADLE_USER_HOME 7 | zipStorePath=wrapper/dists 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/mode/report_mode_action_confirmed.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/report.dart'; 2 | 3 | abstract class ReportModeAction { 4 | /// Code which should be triggered if report mode has been confirmed 5 | void onActionConfirmed(Report report); 6 | 7 | /// Code which should be triggered if report mode has been rejected 8 | void onActionRejected(Report report); 9 | } 10 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Only the newest version, as indicated [here](https://pub.dev/packages/catcher_2/versions) is supported. 6 | 7 | ## Reporting a Vulnerability 8 | 9 | You can report a vulnerability using my contact information from [here](https://nmexis.me/). 10 | 11 | If you have reported a vulnerability, I should usually respond within a day. 12 | -------------------------------------------------------------------------------- /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/android/build.gradle: -------------------------------------------------------------------------------- 1 | allprojects { 2 | repositories { 3 | google() 4 | mavenCentral() 5 | } 6 | } 7 | 8 | rootProject.buildDir = "../build" 9 | subprojects { 10 | project.buildDir = "${rootProject.buildDir}/${project.name}" 11 | } 12 | subprojects { 13 | project.evaluationDependsOn(":app") 14 | } 15 | 16 | tasks.register("clean", Delete) { 17 | delete rootProject.buildDir 18 | } 19 | -------------------------------------------------------------------------------- /example/android/app/src/debug/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /example/android/app/src/profile/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /backend/src/main/java/com/jhomlala/catcher_2/backend/BackendApplication.java: -------------------------------------------------------------------------------- 1 | package com.jhomlala.catcher_2.backend; 2 | 3 | import org.springframework.boot.SpringApplication; 4 | import org.springframework.boot.autoconfigure.SpringBootApplication; 5 | 6 | @SpringBootApplication 7 | public class BackendApplication { 8 | 9 | public static void main(String[] args) { 10 | SpringApplication.run(BackendApplication.class, args); 11 | } 12 | 13 | } 14 | 15 | -------------------------------------------------------------------------------- /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 | PermissionHandlerWindowsPluginRegisterWithRegistrar( 13 | registry->GetRegistrarForPlugin("PermissionHandlerWindowsPlugin")); 14 | } 15 | -------------------------------------------------------------------------------- /example/ios/Runner/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 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/macos/Runner/MainFlutterWindow.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | 4 | class MainFlutterWindow: NSWindow { 5 | override func awakeFromNib() { 6 | let flutterViewController = FlutterViewController() 7 | let windowFrame = self.frame 8 | self.contentViewController = flutterViewController 9 | self.setFrame(windowFrame, display: true) 10 | 11 | RegisterGeneratedPlugins(registry: flutterViewController) 12 | 13 | super.awakeFromNib() 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /example/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/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/app/src/main/res/drawable/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /backend/src/test/java/com/jhomlala/catcher_2/backend/BackendApplicationTests.java: -------------------------------------------------------------------------------- 1 | package com.jhomlala.catcher_2.backend; 2 | 3 | import org.junit.jupiter.api.Test; 4 | import org.junit.jupiter.api.extension.ExtendWith; 5 | import org.springframework.boot.test.context.SpringBootTest; 6 | import org.springframework.test.context.junit.jupiter.SpringExtension; 7 | 8 | @ExtendWith(SpringExtension.class) 9 | @SpringBootTest 10 | public class BackendApplicationTests { 11 | 12 | @Test 13 | public void contextLoads() { 14 | } 15 | 16 | } 17 | 18 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/drawable-v21/launch_background.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 12 | 13 | -------------------------------------------------------------------------------- /backend/src/main/java/com/jhomlala/catcher_2/backend/ReportLogService.java: -------------------------------------------------------------------------------- 1 | package com.jhomlala.catcher_2.backend; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import org.springframework.stereotype.Service; 7 | 8 | @Service 9 | public class ReportLogService { 10 | 11 | private List reportLogs = new ArrayList(); 12 | 13 | public void addReportLog(ReportLog log) { 14 | reportLogs.add(log); 15 | } 16 | 17 | public List getReportLogs(){ 18 | return reportLogs; 19 | } 20 | 21 | } 22 | -------------------------------------------------------------------------------- /example/ios/Runner/Assets.xcassets/LaunchImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "LaunchImage.png", 6 | "scale" : "1x" 7 | }, 8 | { 9 | "idiom" : "universal", 10 | "filename" : "LaunchImage@2x.png", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "universal", 15 | "filename" : "LaunchImage@3x.png", 16 | "scale" : "3x" 17 | } 18 | ], 19 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /example/README.md: -------------------------------------------------------------------------------- 1 | # catcher_2_example 2 | 3 | Demonstrates how to use the catcher_2 plugin. 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/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 | -------------------------------------------------------------------------------- /backend/.gitignore: -------------------------------------------------------------------------------- 1 | *.java.hsp 2 | *.sonarj 3 | *.sw* 4 | .DS_Store 5 | .settings 6 | .springBeans 7 | bin 8 | build.sh 9 | integration-repo 10 | ivy-cache 11 | jxl.log 12 | jmx.log 13 | derby.log 14 | spring-test/test-output/ 15 | .gradle 16 | argfile* 17 | activemq-data/ 18 | 19 | classes/ 20 | /build 21 | buildSrc/build 22 | /spring-*/build 23 | /src/asciidoc/build 24 | target/ 25 | 26 | # Eclipse artifacts, including WTP generated manifests 27 | .classpath 28 | .project 29 | spring-*/src/main/java/META-INF/MANIFEST.MF 30 | 31 | # IDEA artifacts and output dirs 32 | *.iml 33 | *.ipr 34 | *.iws 35 | .idea 36 | out 37 | test-output 38 | atlassian-ide-plugin.xml 39 | .gradletasknamecache -------------------------------------------------------------------------------- /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 = catcher_2_example 9 | 10 | // The application's bundle identifier 11 | PRODUCT_BUNDLE_IDENTIFIER = com.jhomlala.catcher2Example 12 | 13 | // The copyright displayed in application information 14 | PRODUCT_COPYRIGHT = Copyright © 2024 com.jhomlala. All rights reserved. 15 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: '' 5 | labels: enhancement 6 | assignees: ThexXTURBOXx 7 | 8 | --- 9 | 10 | ## Is your feature request related to a problem? Please describe. 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | ## Describe the solution you'd like 14 | A clear and concise description of what you want to happen. 15 | 16 | ## Describe alternatives you've considered 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | ## Additional context 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/mode/silent_report_mode.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/platform_type.dart'; 2 | import 'package:catcher_2/model/report.dart'; 3 | import 'package:catcher_2/model/report_mode.dart'; 4 | import 'package:flutter/widgets.dart'; 5 | 6 | class SilentReportMode extends ReportMode { 7 | @override 8 | void requestAction(Report report, BuildContext? context) { 9 | // no action needed, request is automatically accepted 10 | super.onActionConfirmed(report); 11 | } 12 | 13 | @override 14 | List getSupportedPlatforms() => [ 15 | PlatformType.android, 16 | PlatformType.iOS, 17 | PlatformType.web, 18 | PlatformType.linux, 19 | PlatformType.macOS, 20 | PlatformType.windows, 21 | ]; 22 | } 23 | -------------------------------------------------------------------------------- /.github/workflows/ci.yml: -------------------------------------------------------------------------------- 1 | name: CI 2 | 3 | on: 4 | push: 5 | pull_request: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | lint: 10 | name: Lint 11 | runs-on: ubuntu-latest 12 | steps: 13 | - name: Checkout code 14 | uses: actions/checkout@v5 15 | 16 | - name: Install Flutter 17 | uses: subosito/flutter-action@v2 18 | with: 19 | channel: 'stable' 20 | 21 | - name: Setup Pana 22 | run: flutter pub global activate pana 23 | 24 | - name: Get dependencies 25 | run: flutter pub get 26 | 27 | - name: Lint 28 | run: dart format -o none --set-exit-if-changed . 29 | 30 | - name: Analyze 31 | run: dart analyze 32 | 33 | - name: Pana 34 | run: pana 35 | -------------------------------------------------------------------------------- /example/windows/runner/utils.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_UTILS_H_ 2 | #define RUNNER_UTILS_H_ 3 | 4 | #include 5 | #include 6 | 7 | // Creates a console for the process, and redirects stdout and stderr to 8 | // it for both the runner and the Flutter library. 9 | void CreateAndAttachConsole(); 10 | 11 | // Takes a null-terminated wchar_t* encoded in UTF-16 and returns a std::string 12 | // encoded in UTF-8. Returns an empty std::string on failure. 13 | std::string Utf8FromUtf16(const wchar_t* utf16_string); 14 | 15 | // Gets the command line arguments passed in as a std::vector, 16 | // encoded in UTF-8. Returns an empty std::vector on failure. 17 | std::vector GetCommandLineArguments(); 18 | 19 | #endif // RUNNER_UTILS_H_ 20 | -------------------------------------------------------------------------------- /example/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 flutter_local_notifications 10 | import package_info_plus 11 | import path_provider_foundation 12 | 13 | func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { 14 | DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) 15 | FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) 16 | FPPPackageInfoPlusPlugin.register(with: registry.registrar(forPlugin: "FPPPackageInfoPlusPlugin")) 17 | PathProviderPlugin.register(with: registry.registrar(forPlugin: "PathProviderPlugin")) 18 | } 19 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | # These are supported funding model platforms 2 | 3 | github: ThexXTURBOXx 4 | patreon: # Replace with a single Patreon username 5 | open_collective: # Replace with a single Open Collective username 6 | ko_fi: # Replace with a single Ko-fi username 7 | tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel 8 | community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry 9 | liberapay: # Replace with a single Liberapay username 10 | issuehunt: # Replace with a single IssueHunt username 11 | otechie: # Replace with a single Otechie username 12 | lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry 13 | custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] 14 | -------------------------------------------------------------------------------- /example/android/settings.gradle: -------------------------------------------------------------------------------- 1 | pluginManagement { 2 | def flutterSdkPath = { 3 | def properties = new Properties() 4 | file("local.properties").withInputStream { properties.load(it) } 5 | def flutterSdkPath = properties.getProperty("flutter.sdk") 6 | assert flutterSdkPath != null, "flutter.sdk not set in local.properties" 7 | return flutterSdkPath 8 | }() 9 | 10 | includeBuild("$flutterSdkPath/packages/flutter_tools/gradle") 11 | 12 | repositories { 13 | google() 14 | mavenCentral() 15 | gradlePluginPortal() 16 | } 17 | } 18 | 19 | plugins { 20 | id "dev.flutter.flutter-plugin-loader" version "1.0.0" 21 | id "com.android.application" version "8.2.1" apply false 22 | id "org.jetbrains.kotlin.android" version "1.7.10" apply false 23 | } 24 | 25 | include ":app" 26 | -------------------------------------------------------------------------------- /example/linux/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | ) 7 | 8 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 9 | ) 10 | 11 | set(PLUGIN_BUNDLED_LIBRARIES) 12 | 13 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 14 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/linux plugins/${plugin}) 15 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 16 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 17 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 18 | endforeach(plugin) 19 | 20 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 21 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) 22 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 23 | endforeach(ffi_plugin) 24 | -------------------------------------------------------------------------------- /example/ios/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Flutter 2 | import UIKit 3 | import XCTest 4 | 5 | @testable import catcher_2 6 | 7 | // This demonstrates a simple unit test of the Swift portion of this plugin's implementation. 8 | // 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | 11 | class RunnerTests: XCTestCase { 12 | 13 | func testGetPlatformVersion() { 14 | let plugin = Catcher_2Plugin() 15 | 16 | let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: []) 17 | 18 | let resultExpectation = expectation(description: "result block must be called.") 19 | plugin.handle(call) { result in 20 | XCTAssertEqual(result as! String, "iOS " + UIDevice.current.systemVersion) 21 | resultExpectation.fulfill() 22 | } 23 | waitForExpectations(timeout: 1) 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /lib/core/catcher_2_screenshot.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/core/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | /// Screenshot widget used to create screenshot of all child widgets. 5 | class Catcher2Screenshot extends StatefulWidget { 6 | const Catcher2Screenshot({ 7 | super.key, 8 | required this.child, 9 | required this.catcher2, 10 | }); 11 | 12 | final Widget child; 13 | final Catcher2 catcher2; 14 | 15 | @override 16 | State createState() => Catcher2ScreenshotState(); 17 | } 18 | 19 | /// State of screenshot widget. 20 | class Catcher2ScreenshotState extends State 21 | with TickerProviderStateMixin { 22 | @override 23 | Widget build(BuildContext context) => RepaintBoundary( 24 | key: widget.catcher2.screenshotManager.containerKey, 25 | child: widget.child, 26 | ); 27 | } 28 | -------------------------------------------------------------------------------- /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 | .pub-cache/ 31 | .pub/ 32 | /build/ 33 | 34 | # Symbolication related 35 | app.*.symbols 36 | 37 | # Obfuscation related 38 | app.*.map.json 39 | 40 | # Android Studio will place build artifacts here 41 | /android/app/debug 42 | /android/app/profile 43 | /android/app/release 44 | -------------------------------------------------------------------------------- /example/ios/Flutter/AppFrameworkInfo.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | App 9 | CFBundleIdentifier 10 | io.flutter.flutter.app 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | App 15 | CFBundlePackageType 16 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1.0 23 | MinimumOSVersion 24 | 12.0 25 | 26 | 27 | -------------------------------------------------------------------------------- /example/macos/RunnerTests/RunnerTests.swift: -------------------------------------------------------------------------------- 1 | import Cocoa 2 | import FlutterMacOS 3 | import XCTest 4 | 5 | @testable import catcher_2 6 | 7 | // This demonstrates a simple unit test of the Swift portion of this plugin's implementation. 8 | // 9 | // See https://developer.apple.com/documentation/xctest for more information about using XCTest. 10 | 11 | class RunnerTests: XCTestCase { 12 | 13 | func testGetPlatformVersion() { 14 | let plugin = Catcher_2Plugin() 15 | 16 | let call = FlutterMethodCall(methodName: "getPlatformVersion", arguments: []) 17 | 18 | let resultExpectation = expectation(description: "result block must be called.") 19 | plugin.handle(call) { result in 20 | XCTAssertEqual(result as! String, 21 | "macOS " + ProcessInfo.processInfo.operatingSystemVersionString) 22 | resultExpectation.fulfill() 23 | } 24 | waitForExpectations(timeout: 1) 25 | } 26 | 27 | } 28 | -------------------------------------------------------------------------------- /example/windows/flutter/generated_plugins.cmake: -------------------------------------------------------------------------------- 1 | # 2 | # Generated file, do not edit. 3 | # 4 | 5 | list(APPEND FLUTTER_PLUGIN_LIST 6 | permission_handler_windows 7 | ) 8 | 9 | list(APPEND FLUTTER_FFI_PLUGIN_LIST 10 | flutter_local_notifications_windows 11 | ) 12 | 13 | set(PLUGIN_BUNDLED_LIBRARIES) 14 | 15 | foreach(plugin ${FLUTTER_PLUGIN_LIST}) 16 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${plugin}/windows plugins/${plugin}) 17 | target_link_libraries(${BINARY_NAME} PRIVATE ${plugin}_plugin) 18 | list(APPEND PLUGIN_BUNDLED_LIBRARIES $) 19 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) 20 | endforeach(plugin) 21 | 22 | foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) 23 | add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) 24 | list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) 25 | endforeach(ffi_plugin) 26 | -------------------------------------------------------------------------------- /lib/utils/catcher_2_logger.dart: -------------------------------------------------------------------------------- 1 | import 'package:logging/logging.dart'; 2 | 3 | /// Class used to provide logger for Catcher 2. 4 | class Catcher2Logger { 5 | final Logger _logger = Logger('Catcher 2'); 6 | 7 | /// Setup logger configuration. 8 | void setup() { 9 | Logger.root.level = Level.ALL; 10 | Logger.root.onRecord.listen( 11 | (rec) { 12 | // ignore: avoid_print 13 | print( 14 | '[${rec.time} | ${rec.loggerName} | ${rec.level.name}] ' 15 | '${rec.message}', 16 | ); 17 | }, 18 | ); 19 | } 20 | 21 | /// Log info message. 22 | void info(String message) => _logger.info(message); 23 | 24 | /// Log fine message. 25 | void fine(String message) => _logger.fine(message); 26 | 27 | /// Log warning message. 28 | void warning(String message) => _logger.warning(message); 29 | 30 | /// Log severe message. 31 | void severe(String message) => _logger.severe(message); 32 | } 33 | -------------------------------------------------------------------------------- /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/utils/catcher_2_utils.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/core/application_profile_manager.dart'; 2 | import 'package:dio/dio.dart'; 3 | import 'package:flutter/cupertino.dart'; 4 | import 'package:universal_io/io.dart'; 5 | 6 | class Catcher2Utils { 7 | /// From https://stackoverflow.com/a/56959146/5894824 8 | static Future isInternetConnectionAvailable() async { 9 | if (ApplicationProfileManager.isWeb()) { 10 | return true; // TODO(HyperSpeeed): We could in theory handle this maybe? 11 | } else { 12 | try { 13 | final result = await InternetAddress.lookup('google.com'); 14 | return result.isNotEmpty && result[0].rawAddress.isNotEmpty; 15 | } catch (_) {} 16 | } 17 | return false; 18 | } 19 | 20 | static bool isCupertinoAppAncestor(BuildContext context) => 21 | context.findAncestorWidgetOfExactType() != null; 22 | } 23 | 24 | /// From https://stackoverflow.com/a/70282800/5894824 25 | extension IsOk on Response { 26 | bool get ok => statusCode != null && (statusCode! ~/ 100) == 2; 27 | } 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Miscellaneous 2 | *.class 3 | *.log 4 | *.pyc 5 | *.swp 6 | .DS_Store 7 | .atom/ 8 | .buildlog/ 9 | .gradle/ 10 | .history 11 | .svn/ 12 | migrate_working_dir/ 13 | 14 | # IntelliJ related 15 | *.iml 16 | *.ipr 17 | *.iws 18 | .idea/ 19 | 20 | # The .vscode folder contains launch configuration and tasks you configure in 21 | # VS Code which you may wish to be included in version control, so this line 22 | # is commented out by default. 23 | #.vscode/ 24 | 25 | # Flutter/Dart/Pub related 26 | # Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock. 27 | pubspec.lock 28 | pubspec_overrides.yaml 29 | **/doc/api/ 30 | **/ios/Flutter/.last_build_id 31 | .dart_tool/ 32 | .flutter-plugins 33 | .flutter-plugins-dependencies 34 | .packages 35 | .pub-cache/ 36 | .pub/ 37 | /build/ 38 | local.properties 39 | 40 | # Symbolication related 41 | app.*.symbols 42 | 43 | # Obfuscation related 44 | app.*.map.json 45 | 46 | # Android Studio will place build artifacts here 47 | /android/app/debug 48 | /android/app/profile 49 | /android/app/release 50 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/android/app/src/main/res/values-night/styles.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 9 | 15 | 18 | 19 | -------------------------------------------------------------------------------- /backend/.mvn/wrapper/maven-wrapper.properties: -------------------------------------------------------------------------------- 1 | # Licensed to the Apache Software Foundation (ASF) under one 2 | # or more contributor license agreements. See the NOTICE file 3 | # distributed with this work for additional information 4 | # regarding copyright ownership. The ASF licenses this file 5 | # to you under the Apache License, Version 2.0 (the 6 | # "License"); you may not use this file except in compliance 7 | # with the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, 12 | # software distributed under the License is distributed on an 13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 | # KIND, either express or implied. See the License for the 15 | # specific language governing permissions and limitations 16 | # under the License. 17 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.4/apache-maven-3.9.4-bin.zip 18 | wrapperUrl=https://repo.maven.apache.org/maven2/org/apache/maven/wrapper/maven-wrapper/3.2.0/maven-wrapper-3.2.0.jar 19 | -------------------------------------------------------------------------------- /example/web/manifest.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "catcher_2_example", 3 | "short_name": "catcher_2_example", 4 | "start_url": ".", 5 | "display": "standalone", 6 | "background_color": "#0175C2", 7 | "theme_color": "#0175C2", 8 | "description": "Demonstrates how to use the catcher_2 plugin.", 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 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/compatibility-issue.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Compatibility issue 3 | about: Something is not compatible with the original catcher plugin? 4 | title: '' 5 | labels: compatibility 6 | assignees: ThexXTURBOXx 7 | 8 | --- 9 | 10 | ## Description 11 | A clear and concise description of what the issue is. 12 | 13 | ## To Reproduce 14 | ```dart 15 | Code to reproduce the behavior 16 | ``` 17 | 18 | ## Expected behavior 19 | A clear and concise description of what you expected to happen. 20 | 21 | ## Screenshots 22 | If applicable, add screenshots to help explain your problem. 23 | 24 | ## Device (please complete the following information!) 25 | - Device: [e.g. iPhone 6, Desktop Computer] 26 | - OS: [e.g. iOS 8.1, Windows 10 21H2] 27 | - Browser: [e.g. Stock, Chrome, Safari, Firefox] 28 | - `catcher_2` version: [e.g. 1.0.0] 29 | 30 | ## Additional context 31 | Add any other context about the problem here. 32 | 33 | ## Checklist 34 | - [ ] I have read and followed the **entire** [README](https://github.com/ThexXTURBOXx/catcher_2) and it has not provided the solution I need. 35 | - [ ] I have provided all the information I can (incl. auth URL etc.) 36 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /lib/core/application_profile_manager.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/application_profile.dart'; 2 | import 'package:flutter/foundation.dart'; 3 | import 'package:universal_io/io.dart'; 4 | 5 | class ApplicationProfileManager { 6 | /// Get current application profile (release, debug or profile). 7 | static ApplicationProfile getApplicationProfile() { 8 | if (kReleaseMode) { 9 | return ApplicationProfile.release; 10 | } 11 | if (kDebugMode) { 12 | return ApplicationProfile.debug; 13 | } 14 | if (kProfileMode) { 15 | return ApplicationProfile.profile; 16 | } 17 | 18 | /// Fallback 19 | return ApplicationProfile.debug; 20 | } 21 | 22 | /// Check if current platform is Web 23 | static bool isWeb() => kIsWeb; 24 | 25 | /// Check if current platform is Android 26 | static bool isAndroid() => !kIsWeb && Platform.isAndroid; 27 | 28 | /// Check if current platform is iOS 29 | static bool isIos() => !kIsWeb && Platform.isIOS; 30 | 31 | /// Check if current platform is Linux 32 | static bool isLinux() => !kIsWeb && Platform.isLinux; 33 | 34 | /// Check if current platform is Windows 35 | static bool isWindows() => !kIsWeb && Platform.isWindows; 36 | 37 | /// Check if current platform is macOS 38 | static bool isMacOS() => !kIsWeb && Platform.isMacOS; 39 | } 40 | -------------------------------------------------------------------------------- /backend/src/main/resources/templates/reports.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 10 | 11 | Reports 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 31 | 32 | 33 | 34 | 35 | 36 |
DateApplicationErrorStack traceDevice data
37 |
38 | 39 | -------------------------------------------------------------------------------- /backend/src/main/java/com/jhomlala/catcher_2/backend/ReportLogController.java: -------------------------------------------------------------------------------- 1 | package com.jhomlala.catcher_2.backend; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collections; 5 | import java.util.List; 6 | 7 | import org.springframework.beans.factory.annotation.Autowired; 8 | import org.springframework.http.HttpStatus; 9 | import org.springframework.stereotype.Controller; 10 | import org.springframework.ui.Model; 11 | import org.springframework.web.bind.annotation.RequestBody; 12 | import org.springframework.web.bind.annotation.RequestMapping; 13 | import org.springframework.web.bind.annotation.RequestMethod; 14 | import org.springframework.web.bind.annotation.ResponseStatus; 15 | 16 | @Controller 17 | public class ReportLogController { 18 | 19 | @Autowired 20 | private ReportLogService reportLogService; 21 | 22 | @RequestMapping(value = "/report", method = RequestMethod.POST) 23 | @ResponseStatus(value = HttpStatus.OK) 24 | public void handleReportLog(@RequestBody ReportLog reportLog) { 25 | reportLogService.addReportLog(reportLog); 26 | } 27 | 28 | @RequestMapping(value = "/reports", method = RequestMethod.GET) 29 | public String reportsPage(Model model) { 30 | List reportsCopied = new ArrayList(reportLogService.getReportLogs()); 31 | Collections.reverse(reportsCopied); 32 | model.addAttribute("reportLogs",reportsCopied); 33 | return "reports"; 34 | } 35 | 36 | } 37 | -------------------------------------------------------------------------------- /example/web/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | catcher_2_example 33 | 34 | 35 | 36 | 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"catcher_2_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 | -------------------------------------------------------------------------------- /pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: catcher_2 2 | description: Plugin for error catching which provides multiple handlers for dealing with errors when they are not caught by the developer. 3 | version: 2.1.5 4 | homepage: https://github.com/ThexXTURBOXx/catcher_2 5 | repository: https://github.com/ThexXTURBOXx/catcher_2 6 | issue_tracker: https://github.com/ThexXTURBOXx/catcher_2/issues 7 | 8 | funding: 9 | - https://github.com/sponsors/ThexXTURBOXx 10 | 11 | screenshots: 12 | - description: 'The catcher_2 logo' 13 | path: screenshots/logo.png 14 | - description: 'catcher_2 in action with notifications' 15 | path: screenshots/1.png 16 | - description: 'catcher_2 in action with emails' 17 | path: screenshots/3.png 18 | - description: 'catcher_2 in action with dialogs' 19 | path: screenshots/6.png 20 | 21 | topics: 22 | - analysis 23 | - errors 24 | - flutter 25 | - logging 26 | - tool 27 | 28 | environment: 29 | sdk: '>=3.0.0 <4.0.0' 30 | flutter: ">=3.0.0" 31 | 32 | dependencies: 33 | cross_file: ^0.3.0 34 | device_info_plus: '>=9.0.0 <13.0.0' 35 | dio: ^5.0.1 36 | flutter: 37 | sdk: flutter 38 | flutter_mailer: ^3.0.0 39 | fluttertoast: '>=8.2.6 <10.0.0' 40 | logging: ^1.0.2 41 | mailer: ^6.0.0 42 | package_info_plus: '>=4.0.0 <10.0.0' 43 | sentry: '>=7.2.0 <10.0.0' 44 | universal_io: ^2.0.4 45 | 46 | dev_dependencies: 47 | flutter_lints: ^6.0.0 48 | 49 | platforms: 50 | android: 51 | ios: 52 | linux: 53 | macos: 54 | web: 55 | windows: 56 | -------------------------------------------------------------------------------- /lib/model/report_handler.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/localization_options.dart'; 2 | import 'package:catcher_2/model/platform_type.dart'; 3 | import 'package:catcher_2/model/report.dart'; 4 | import 'package:catcher_2/utils/catcher_2_logger.dart'; 5 | import 'package:flutter/material.dart'; 6 | 7 | abstract class ReportHandler { 8 | /// Logger instance 9 | late Catcher2Logger logger; 10 | 11 | /// Localization settings 12 | LocalizationOptions? _localizationOptions; 13 | 14 | /// Method called when report has been accepted by user 15 | Future handle(Report report, BuildContext? context); 16 | 17 | /// Get list of supported platforms 18 | List getSupportedPlatforms(); 19 | 20 | /// Get currently used localization options 21 | LocalizationOptions get localizationOptions => 22 | _localizationOptions ?? LocalizationOptions.buildDefaultEnglishOptions(); 23 | 24 | /// Set localization options (translations) to this report mode 25 | set localizationOptions(LocalizationOptions? localizationOptions) { 26 | _localizationOptions = localizationOptions; 27 | } 28 | 29 | /// Check if given report mode requires context to run 30 | bool isContextRequired() => false; 31 | 32 | /// Check whether report mode should auto confirm without user confirmation. 33 | bool shouldHandleWhenRejected() => false; 34 | 35 | /// Can be overridden to provide more information about this handler. 36 | @override 37 | String toString() => runtimeType.toString(); 38 | } 39 | -------------------------------------------------------------------------------- /lib/catcher_2.dart: -------------------------------------------------------------------------------- 1 | export 'package:catcher_2/core/catcher_2.dart'; 2 | export 'package:catcher_2/core/catcher_2_screenshot.dart'; 3 | export 'package:catcher_2/handlers/console_handler.dart'; 4 | export 'package:catcher_2/handlers/discord_handler.dart'; 5 | export 'package:catcher_2/handlers/email_auto_handler.dart'; 6 | export 'package:catcher_2/handlers/email_manual_handler.dart'; 7 | export 'package:catcher_2/handlers/file_handler.dart'; 8 | export 'package:catcher_2/handlers/http_handler.dart'; 9 | export 'package:catcher_2/handlers/sentry_handler.dart'; 10 | export 'package:catcher_2/handlers/slack_handler.dart'; 11 | export 'package:catcher_2/handlers/snackbar_handler.dart'; 12 | export 'package:catcher_2/handlers/toast_handler.dart'; 13 | export 'package:catcher_2/mode/dialog_report_mode.dart'; 14 | export 'package:catcher_2/mode/page_report_mode.dart'; 15 | export 'package:catcher_2/mode/report_mode_action_confirmed.dart'; 16 | export 'package:catcher_2/mode/silent_report_mode.dart'; 17 | export 'package:catcher_2/model/catcher_2_options.dart'; 18 | export 'package:catcher_2/model/http_request_type.dart'; 19 | export 'package:catcher_2/model/localization_options.dart'; 20 | export 'package:catcher_2/model/report.dart'; 21 | export 'package:catcher_2/model/report_handler.dart'; 22 | export 'package:catcher_2/model/report_mode.dart'; 23 | export 'package:catcher_2/model/toast_handler_gravity.dart'; 24 | export 'package:catcher_2/model/toast_handler_length.dart'; 25 | export 'package:catcher_2/utils/catcher_2_logger.dart'; 26 | -------------------------------------------------------------------------------- /example/analysis_options.yaml: -------------------------------------------------------------------------------- 1 | # This file configures the analyzer, which statically analyzes Dart code to 2 | # check for errors, warnings, and lints. 3 | # 4 | # The issues identified by the analyzer are surfaced in the UI of Dart-enabled 5 | # IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be 6 | # invoked from the command line by running `flutter analyze`. 7 | 8 | # The following line activates a set of recommended lints for Flutter apps, 9 | # packages, and plugins designed to encourage good coding practices. 10 | include: package:flutter_lints/flutter.yaml 11 | 12 | linter: 13 | # The lint rules applied to this project can be customized in the 14 | # section below to disable rules from the `package:flutter_lints/flutter.yaml` 15 | # included above or to enable additional rules. A list of all available lints 16 | # and their documentation is published at https://dart.dev/lints. 17 | # 18 | # Instead of disabling a lint rule for the entire project in the 19 | # section below, it can also be suppressed for a single line of code 20 | # or a specific dart file by using the `// ignore: name_of_lint` and 21 | # `// ignore_for_file: name_of_lint` syntax on the line or in the file 22 | # producing the lint. 23 | rules: 24 | # avoid_print: false # Uncomment to disable the `avoid_print` rule 25 | # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule 26 | 27 | # Additional information about this file can be found at 28 | # https://dart.dev/guides/language/analysis-options 29 | -------------------------------------------------------------------------------- /example/lib/basic_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options(DialogReportMode(), [ 6 | ConsoleHandler(), 7 | ]); 8 | final releaseOptions = Catcher2Options(PageReportMode(), [ 9 | EmailManualHandler(['recipient@email.com']), 10 | ]); 11 | 12 | Catcher2( 13 | runAppFunction: () { 14 | runApp(const MyApp()); 15 | }, 16 | debugConfig: debugOptions, 17 | releaseConfig: releaseOptions, 18 | ); 19 | } 20 | 21 | class MyApp extends StatefulWidget { 22 | const MyApp({super.key}); 23 | 24 | @override 25 | State createState() => _MyAppState(); 26 | } 27 | 28 | class _MyAppState extends State { 29 | @override 30 | void initState() { 31 | super.initState(); 32 | } 33 | 34 | @override 35 | Widget build(BuildContext context) => MaterialApp( 36 | navigatorKey: Catcher2.navigatorKey, 37 | home: Scaffold( 38 | appBar: AppBar( 39 | title: const Text('Plugin example app'), 40 | ), 41 | body: const ChildWidget(), 42 | ), 43 | ); 44 | } 45 | 46 | class ChildWidget extends StatelessWidget { 47 | const ChildWidget({super.key}); 48 | 49 | @override 50 | Widget build(BuildContext context) => TextButton( 51 | onPressed: generateError, 52 | child: const Text('Generate error'), 53 | ); 54 | 55 | Future generateError() async { 56 | Catcher2.sendTestException(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /backend/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 4.0.0 6 | 7 | org.springframework.boot 8 | spring-boot-starter-parent 9 | 3.1.4 10 | 11 | 12 | com.jhomlala.catcher_2 13 | backend 14 | 0.0.1-SNAPSHOT 15 | backend 16 | Backend for Catcher 2 plugin 17 | 18 | 19 | 8 20 | 21 | 22 | 23 | 24 | org.springframework.boot 25 | spring-boot-starter-web 26 | 27 | 28 | org.springframework.boot 29 | spring-boot-starter-thymeleaf 30 | 31 | 32 | org.springframework.boot 33 | spring-boot-starter-test 34 | test 35 | 36 | 37 | 38 | 39 | 40 | 41 | org.springframework.boot 42 | spring-boot-maven-plugin 43 | 44 | 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /example/lib/sentry_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:sentry/sentry.dart'; 4 | 5 | void main() { 6 | final debugOptions = Catcher2Options(DialogReportMode(), [ 7 | SentryHandler( 8 | SentryClient(SentryOptions(dsn: 'YOUR DSN HERE')), 9 | printLogs: true, 10 | ), 11 | ]); 12 | final releaseOptions = Catcher2Options(PageReportMode(), [ 13 | EmailManualHandler(['recipient@email.com']), 14 | ]); 15 | 16 | Catcher2( 17 | rootWidget: const MyApp(), 18 | debugConfig: debugOptions, 19 | releaseConfig: releaseOptions, 20 | ); 21 | } 22 | 23 | class MyApp extends StatefulWidget { 24 | const MyApp({super.key}); 25 | 26 | @override 27 | State createState() => _MyAppState(); 28 | } 29 | 30 | class _MyAppState extends State { 31 | @override 32 | void initState() { 33 | super.initState(); 34 | } 35 | 36 | @override 37 | Widget build(BuildContext context) => MaterialApp( 38 | navigatorKey: Catcher2.navigatorKey, 39 | home: Scaffold( 40 | appBar: AppBar( 41 | title: const Text('Plugin example app'), 42 | ), 43 | body: const ChildWidget(), 44 | ), 45 | ); 46 | } 47 | 48 | class ChildWidget extends StatelessWidget { 49 | const ChildWidget({super.key}); 50 | 51 | @override 52 | Widget build(BuildContext context) => 53 | TextButton(onPressed: generateError, child: const Text('Generate error')); 54 | 55 | Future generateError() async { 56 | Catcher2.sendTestException(); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /example/macos/Runner/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "16x16", 5 | "idiom" : "mac", 6 | "filename" : "app_icon_16.png", 7 | "scale" : "1x" 8 | }, 9 | { 10 | "size" : "16x16", 11 | "idiom" : "mac", 12 | "filename" : "app_icon_32.png", 13 | "scale" : "2x" 14 | }, 15 | { 16 | "size" : "32x32", 17 | "idiom" : "mac", 18 | "filename" : "app_icon_32.png", 19 | "scale" : "1x" 20 | }, 21 | { 22 | "size" : "32x32", 23 | "idiom" : "mac", 24 | "filename" : "app_icon_64.png", 25 | "scale" : "2x" 26 | }, 27 | { 28 | "size" : "128x128", 29 | "idiom" : "mac", 30 | "filename" : "app_icon_128.png", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "size" : "128x128", 35 | "idiom" : "mac", 36 | "filename" : "app_icon_256.png", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "size" : "256x256", 41 | "idiom" : "mac", 42 | "filename" : "app_icon_256.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "256x256", 47 | "idiom" : "mac", 48 | "filename" : "app_icon_512.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "512x512", 53 | "idiom" : "mac", 54 | "filename" : "app_icon_512.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "512x512", 59 | "idiom" : "mac", 60 | "filename" : "app_icon_1024.png", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /example/lib/occurences_timeout_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options( 6 | SilentReportMode(), 7 | [ 8 | ConsoleHandler(), 9 | ToastHandler(), 10 | ], 11 | reportOccurrenceTimeout: 30000, 12 | ); 13 | final releaseOptions = Catcher2Options(PageReportMode(), [ 14 | EmailManualHandler(['recipient@email.com']), 15 | ]); 16 | 17 | Catcher2( 18 | runAppFunction: () { 19 | runApp(const MyApp()); 20 | }, 21 | debugConfig: debugOptions, 22 | releaseConfig: releaseOptions, 23 | ); 24 | } 25 | 26 | class MyApp extends StatefulWidget { 27 | const MyApp({super.key}); 28 | 29 | @override 30 | State createState() => _MyAppState(); 31 | } 32 | 33 | class _MyAppState extends State { 34 | @override 35 | void initState() { 36 | super.initState(); 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) => MaterialApp( 41 | navigatorKey: Catcher2.navigatorKey, 42 | home: Scaffold( 43 | appBar: AppBar( 44 | title: const Text('Plugin example app'), 45 | ), 46 | body: const ChildWidget(), 47 | ), 48 | ); 49 | } 50 | 51 | class ChildWidget extends StatelessWidget { 52 | const ChildWidget({super.key}); 53 | 54 | @override 55 | Widget build(BuildContext context) => TextButton( 56 | onPressed: generateError, 57 | child: const Text('Generate error'), 58 | ); 59 | 60 | Future generateError() async { 61 | Catcher2.sendTestException(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /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/model/report_mode.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/mode/report_mode_action_confirmed.dart'; 2 | import 'package:catcher_2/model/localization_options.dart'; 3 | import 'package:catcher_2/model/platform_type.dart'; 4 | import 'package:catcher_2/model/report.dart'; 5 | import 'package:flutter/widgets.dart'; 6 | 7 | abstract class ReportMode { 8 | late ReportModeAction _reportModeAction; 9 | LocalizationOptions? _localizationOptions; 10 | 11 | /// Set report mode action. 12 | // ignore: avoid_setters_without_getters 13 | set reportModeAction(ReportModeAction reportModeAction) { 14 | _reportModeAction = reportModeAction; 15 | } 16 | 17 | /// Set localization options (translations) to this report mode 18 | set localizationOptions(LocalizationOptions? localizationOptions) { 19 | _localizationOptions = localizationOptions; 20 | } 21 | 22 | /// Code which should be triggered if new error has been caught and core 23 | /// creates report about this. 24 | void requestAction(Report report, BuildContext? context); 25 | 26 | /// On user has accepted report 27 | void onActionConfirmed(Report report) { 28 | _reportModeAction.onActionConfirmed(report); 29 | } 30 | 31 | /// On user has rejected report 32 | void onActionRejected(Report report) { 33 | _reportModeAction.onActionRejected(report); 34 | } 35 | 36 | /// Check if given report mode requires context to run 37 | bool isContextRequired() => false; 38 | 39 | /// Get currently used localization options 40 | LocalizationOptions get localizationOptions => 41 | _localizationOptions ?? LocalizationOptions.buildDefaultEnglishOptions(); 42 | 43 | /// Get supported platform list 44 | List getSupportedPlatforms(); 45 | } 46 | -------------------------------------------------------------------------------- /example/lib/discord_handler_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options(SilentReportMode(), [ 6 | DiscordHandler( 7 | '', 8 | enableDeviceParameters: true, 9 | enableApplicationParameters: true, 10 | enableCustomParameters: true, 11 | enableStackTrace: true, 12 | printLogs: true, 13 | ), 14 | ]); 15 | final releaseOptions = Catcher2Options(PageReportMode(), [ 16 | EmailManualHandler(['recipient@email.com']), 17 | ]); 18 | 19 | Catcher2( 20 | rootWidget: const MyApp(), 21 | debugConfig: debugOptions, 22 | releaseConfig: releaseOptions, 23 | ); 24 | } 25 | 26 | class MyApp extends StatefulWidget { 27 | const MyApp({super.key}); 28 | 29 | @override 30 | State createState() => _MyAppState(); 31 | } 32 | 33 | class _MyAppState extends State { 34 | @override 35 | void initState() { 36 | super.initState(); 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) => MaterialApp( 41 | navigatorKey: Catcher2.navigatorKey, 42 | home: Scaffold( 43 | appBar: AppBar( 44 | title: const Text('Plugin example app'), 45 | ), 46 | body: const ChildWidget(), 47 | ), 48 | ); 49 | } 50 | 51 | class ChildWidget extends StatelessWidget { 52 | const ChildWidget({super.key}); 53 | 54 | @override 55 | Widget build(BuildContext context) => TextButton( 56 | onPressed: generateError, 57 | child: const Text('Generate error'), 58 | ); 59 | 60 | Future generateError() async { 61 | Catcher2.sendTestException(); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /example/lib/custom_navigator_key_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options(DialogReportMode(), [ 6 | EmailManualHandler(['recipient@email.com']), 7 | ConsoleHandler(), 8 | ]); 9 | final releaseOptions = Catcher2Options(PageReportMode(), [ 10 | EmailManualHandler(['recipient@email.com']), 11 | ]); 12 | 13 | final navigatorKey = GlobalKey(); 14 | Catcher2( 15 | rootWidget: MyApp(navigatorKey), 16 | debugConfig: debugOptions, 17 | releaseConfig: releaseOptions, 18 | navigatorKey: navigatorKey, 19 | ); 20 | } 21 | 22 | class MyApp extends StatefulWidget { 23 | const MyApp(this.navigatorKey, {super.key}); 24 | 25 | final GlobalKey navigatorKey; 26 | 27 | @override 28 | State createState() => _MyAppState(); 29 | } 30 | 31 | class _MyAppState extends State { 32 | @override 33 | void initState() { 34 | super.initState(); 35 | } 36 | 37 | @override 38 | Widget build(BuildContext context) => MaterialApp( 39 | navigatorKey: widget.navigatorKey, 40 | home: Scaffold( 41 | appBar: AppBar( 42 | title: const Text('Plugin example app'), 43 | ), 44 | body: const ChildWidget(), 45 | ), 46 | ); 47 | } 48 | 49 | class ChildWidget extends StatelessWidget { 50 | const ChildWidget({super.key}); 51 | 52 | @override 53 | Widget build(BuildContext context) => TextButton( 54 | onPressed: generateError, 55 | child: const Text('Generate error'), 56 | ); 57 | 58 | Future generateError() async { 59 | Catcher2.sendTestException(); 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /example/lib/report_modes_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | //silent: 6 | //ReportMode reportMode = SilentReportMode(); 7 | 8 | //notification: 9 | //ReportMode reportMode = NotificationReportMode(); 10 | 11 | //dialog: 12 | /*ReportMode reportMode = DialogReportMode( 13 | titleText: "Crash", 14 | descriptionText: "My description", 15 | acceptText: "OK", 16 | cancelText: "Back");*/ 17 | 18 | //page: 19 | final ReportMode reportMode = PageReportMode(showStackTrace: false); 20 | 21 | final debugOptions = Catcher2Options(reportMode, [ConsoleHandler()]); 22 | 23 | Catcher2(rootWidget: const MyApp(), debugConfig: debugOptions); 24 | } 25 | 26 | class MyApp extends StatefulWidget { 27 | const MyApp({super.key}); 28 | 29 | @override 30 | State createState() => _MyAppState(); 31 | } 32 | 33 | class _MyAppState extends State { 34 | @override 35 | void initState() { 36 | super.initState(); 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) => MaterialApp( 41 | navigatorKey: Catcher2.navigatorKey, 42 | home: Scaffold( 43 | appBar: AppBar( 44 | title: const Text('Plugin example app'), 45 | ), 46 | body: const ChildWidget(), 47 | ), 48 | ); 49 | } 50 | 51 | class ChildWidget extends StatelessWidget { 52 | const ChildWidget({super.key}); 53 | 54 | @override 55 | Widget build(BuildContext context) => TextButton( 56 | onPressed: generateError, 57 | child: const Text('Generate error'), 58 | ); 59 | 60 | Future generateError() async { 61 | throw Exception('Test exception'); 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /example/lib/explicit_error_report_handler_map_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final explicitMap = {'FormatException': ConsoleHandler()}; 6 | final debugOptions = Catcher2Options( 7 | DialogReportMode(), 8 | [ 9 | ConsoleHandler(), 10 | HttpHandler( 11 | HttpRequestType.post, 12 | Uri.parse('https://httpstat.us/200'), 13 | printLogs: true, 14 | ), 15 | ], 16 | explicitExceptionHandlersMap: explicitMap, 17 | ); 18 | final releaseOptions = Catcher2Options(PageReportMode(), [ 19 | EmailManualHandler(['recipient@email.com']), 20 | ]); 21 | 22 | Catcher2( 23 | rootWidget: const MyApp(), 24 | debugConfig: debugOptions, 25 | releaseConfig: releaseOptions, 26 | ); 27 | } 28 | 29 | class MyApp extends StatefulWidget { 30 | const MyApp({super.key}); 31 | 32 | @override 33 | State createState() => _MyAppState(); 34 | } 35 | 36 | class _MyAppState extends State { 37 | @override 38 | void initState() { 39 | super.initState(); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) => MaterialApp( 44 | navigatorKey: Catcher2.navigatorKey, 45 | home: Scaffold( 46 | appBar: AppBar( 47 | title: const Text('Plugin example app'), 48 | ), 49 | body: const ChildWidget(), 50 | ), 51 | ); 52 | } 53 | 54 | class ChildWidget extends StatelessWidget { 55 | const ChildWidget({super.key}); 56 | 57 | @override 58 | Widget build(BuildContext context) => TextButton( 59 | onPressed: generateError, 60 | child: const Text('Generate error'), 61 | ); 62 | 63 | Future generateError() async { 64 | throw const FormatException('Example Error'); 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /example/lib/slack_handler_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options(SilentReportMode(), [ 6 | SlackHandler( 7 | '', 8 | '#catcher', 9 | username: 'CatcherTest', 10 | iconEmoji: ':thinking_face:', 11 | enableDeviceParameters: true, 12 | enableApplicationParameters: true, 13 | enableCustomParameters: true, 14 | enableStackTrace: true, 15 | printLogs: true, 16 | ), 17 | //ConsoleHandler() 18 | ]); 19 | final releaseOptions = Catcher2Options(PageReportMode(), [ 20 | EmailManualHandler(['recipient@email.com']), 21 | ]); 22 | 23 | Catcher2( 24 | rootWidget: const MyApp(), 25 | debugConfig: debugOptions, 26 | releaseConfig: releaseOptions, 27 | ); 28 | } 29 | 30 | class MyApp extends StatefulWidget { 31 | const MyApp({super.key}); 32 | 33 | @override 34 | State createState() => _MyAppState(); 35 | } 36 | 37 | class _MyAppState extends State { 38 | @override 39 | void initState() { 40 | super.initState(); 41 | } 42 | 43 | @override 44 | Widget build(BuildContext context) => MaterialApp( 45 | navigatorKey: Catcher2.navigatorKey, 46 | home: Scaffold( 47 | appBar: AppBar( 48 | title: const Text('Plugin example app'), 49 | ), 50 | body: const ChildWidget(), 51 | ), 52 | ); 53 | } 54 | 55 | class ChildWidget extends StatelessWidget { 56 | const ChildWidget({super.key}); 57 | 58 | @override 59 | Widget build(BuildContext context) => TextButton( 60 | onPressed: generateError, 61 | child: const Text('Generate error'), 62 | ); 63 | 64 | Future generateError() async { 65 | Catcher2.sendTestException(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /example/ios/Runner/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | $(DEVELOPMENT_LANGUAGE) 7 | CFBundleDisplayName 8 | Catcher 2 9 | CFBundleExecutable 10 | $(EXECUTABLE_NAME) 11 | CFBundleIdentifier 12 | $(PRODUCT_BUNDLE_IDENTIFIER) 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | catcher_2_example 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | $(FLUTTER_BUILD_NAME) 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | $(FLUTTER_BUILD_NUMBER) 25 | LSRequiresIPhoneOS 26 | 27 | UILaunchStoryboardName 28 | LaunchScreen 29 | UIMainStoryboardFile 30 | Main 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | CADisableMinimumFrameDurationOnPhone 45 | 46 | UIApplicationSupportsIndirectInputEvents 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /.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: "b0850beeb25f6d5b10426284f506557f66181b36" 8 | channel: "stable" 9 | 10 | project_type: plugin 11 | 12 | # Tracks metadata for the flutter migrate command 13 | migration: 14 | platforms: 15 | - platform: root 16 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 17 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 18 | - platform: android 19 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 20 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 21 | - platform: ios 22 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 23 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 24 | - platform: linux 25 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 26 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 27 | - platform: macos 28 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 29 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 30 | - platform: web 31 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 32 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 33 | - platform: windows 34 | create_revision: b0850beeb25f6d5b10426284f506557f66181b36 35 | base_revision: b0850beeb25f6d5b10426284f506557f66181b36 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/lib/email_manual_handler_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options( 6 | DialogReportMode(), 7 | [ 8 | EmailManualHandler( 9 | ['email1@email.com', 'email2@email.com'], 10 | enableDeviceParameters: true, 11 | enableStackTrace: true, 12 | enableCustomParameters: true, 13 | enableApplicationParameters: true, 14 | sendHtml: true, 15 | emailTitle: 'Sample Title', 16 | emailHeader: 'Sample Header', 17 | printLogs: true, 18 | ), 19 | ], 20 | customParameters: { 21 | 'Test': 'Test12345', 22 | 'Test2': 'Test54321', 23 | }, 24 | ); 25 | 26 | Catcher2( 27 | rootWidget: const MyApp(), 28 | debugConfig: debugOptions, 29 | ); 30 | } 31 | 32 | class MyApp extends StatefulWidget { 33 | const MyApp({super.key}); 34 | 35 | @override 36 | State createState() => _MyAppState(); 37 | } 38 | 39 | class _MyAppState extends State { 40 | @override 41 | void initState() { 42 | super.initState(); 43 | } 44 | 45 | @override 46 | Widget build(BuildContext context) => MaterialApp( 47 | navigatorKey: Catcher2.navigatorKey, 48 | home: Scaffold( 49 | appBar: AppBar( 50 | title: const Text('Plugin example app'), 51 | ), 52 | body: const ChildWidget(), 53 | ), 54 | ); 55 | } 56 | 57 | class ChildWidget extends StatelessWidget { 58 | const ChildWidget({super.key}); 59 | 60 | @override 61 | Widget build(BuildContext context) => TextButton( 62 | onPressed: generateError, 63 | child: const Text('Generate error'), 64 | ); 65 | 66 | Future generateError() async { 67 | throw Exception('Test exception'); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /example/lib/cupertino_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/cupertino.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | void main() { 6 | final debugOptions = Catcher2Options(DialogReportMode(), [ 7 | //EmailManualHandler(["recipient@email.com"]), 8 | HttpHandler( 9 | HttpRequestType.post, 10 | Uri.parse('https://jsonplaceholder.typicode.com/posts'), 11 | printLogs: true, 12 | ), 13 | ConsoleHandler(), 14 | ]); 15 | final releaseOptions = Catcher2Options(PageReportMode(), [ 16 | EmailManualHandler(['recipient@email.com']), 17 | ]); 18 | 19 | Catcher2( 20 | rootWidget: const MyApp(), 21 | debugConfig: debugOptions, 22 | releaseConfig: releaseOptions, 23 | ); 24 | } 25 | 26 | class MyApp extends StatefulWidget { 27 | const MyApp({super.key}); 28 | 29 | @override 30 | State createState() => _MyAppState(); 31 | } 32 | 33 | class _MyAppState extends State { 34 | @override 35 | void initState() { 36 | super.initState(); 37 | } 38 | 39 | @override 40 | Widget build(BuildContext context) => CupertinoApp( 41 | navigatorKey: Catcher2.navigatorKey, 42 | home: const CupertinoPageScaffold( 43 | navigationBar: CupertinoNavigationBar( 44 | middle: Text('Cupertino example'), 45 | ), 46 | child: SafeArea( 47 | child: ChildWidget(), 48 | ), 49 | ), 50 | ); 51 | } 52 | 53 | class ChildWidget extends StatelessWidget { 54 | const ChildWidget({super.key}); 55 | 56 | @override 57 | Widget build(BuildContext context) => ColoredBox( 58 | color: Colors.orange, 59 | child: TextButton( 60 | onPressed: generateError, 61 | child: const Text('Generate error'), 62 | ), 63 | ); 64 | 65 | Future generateError() async { 66 | Catcher2.sendTestException(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /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/lib/excluded_parameters_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options( 6 | DialogReportMode(), 7 | [ 8 | //EmailManualHandler(["recipient@email.com"]), 9 | ToastHandler(), 10 | HttpHandler( 11 | HttpRequestType.post, 12 | Uri.parse('https://jsonplaceholder.typicode.com/posts'), 13 | printLogs: true, 14 | ), 15 | ConsoleHandler(), 16 | ], 17 | 18 | //Exclude these parameters from report. These params are device info params. 19 | excludedParameters: ['androidId', 'model'], 20 | ); 21 | final releaseOptions = Catcher2Options(PageReportMode(), [ 22 | EmailManualHandler(['recipient@email.com']), 23 | ]); 24 | 25 | Catcher2( 26 | runAppFunction: () { 27 | runApp(const MyApp()); 28 | }, 29 | debugConfig: debugOptions, 30 | releaseConfig: releaseOptions, 31 | ); 32 | } 33 | 34 | class MyApp extends StatefulWidget { 35 | const MyApp({super.key}); 36 | 37 | @override 38 | State createState() => _MyAppState(); 39 | } 40 | 41 | class _MyAppState extends State { 42 | @override 43 | void initState() { 44 | super.initState(); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) => MaterialApp( 49 | navigatorKey: Catcher2.navigatorKey, 50 | home: Scaffold( 51 | appBar: AppBar( 52 | title: const Text('Plugin example app'), 53 | ), 54 | body: const ChildWidget(), 55 | ), 56 | ); 57 | } 58 | 59 | class ChildWidget extends StatelessWidget { 60 | const ChildWidget({super.key}); 61 | 62 | @override 63 | Widget build(BuildContext context) => TextButton( 64 | onPressed: generateError, 65 | child: const Text('Generate error'), 66 | ); 67 | 68 | Future generateError() async { 69 | Catcher2.sendTestException(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /example/lib/filter_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options( 6 | DialogReportMode(), 7 | [ 8 | ConsoleHandler(), 9 | ToastHandler(), 10 | ], 11 | filterFunction: (report) { 12 | if (report.error is ArgumentError) { 13 | return false; 14 | } else { 15 | return true; 16 | } 17 | }, 18 | ); 19 | final releaseOptions = Catcher2Options(PageReportMode(), [ 20 | EmailManualHandler(['recipient@email.com']), 21 | ]); 22 | 23 | Catcher2( 24 | runAppFunction: () { 25 | runApp(const MyApp()); 26 | }, 27 | debugConfig: debugOptions, 28 | releaseConfig: releaseOptions, 29 | ); 30 | } 31 | 32 | class MyApp extends StatefulWidget { 33 | const MyApp({super.key}); 34 | 35 | @override 36 | State createState() => _MyAppState(); 37 | } 38 | 39 | class _MyAppState extends State { 40 | @override 41 | void initState() { 42 | super.initState(); 43 | } 44 | 45 | @override 46 | Widget build(BuildContext context) => MaterialApp( 47 | navigatorKey: Catcher2.navigatorKey, 48 | home: Scaffold( 49 | appBar: AppBar( 50 | title: const Text('Filter example'), 51 | ), 52 | body: Column( 53 | children: [ 54 | TextButton( 55 | onPressed: generateNormalError, 56 | child: const Text('Generate normal error'), 57 | ), 58 | TextButton( 59 | onPressed: generateFilteredError, 60 | child: const Text('Generate filtered error'), 61 | ), 62 | ], 63 | ), 64 | ), 65 | ); 66 | 67 | Future generateNormalError() async { 68 | throw StateError('Example error'); 69 | } 70 | 71 | Future generateFilteredError() async { 72 | throw ArgumentError('Example error'); 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /example/lib/http_handler_update_headers_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | ///Http handler instance 6 | final httpHandler = HttpHandler( 7 | HttpRequestType.post, 8 | Uri.parse('https://jsonplaceholder.typicode.com/posts'), 9 | printLogs: true, 10 | enableStackTrace: false, 11 | enableApplicationParameters: false, 12 | enableDeviceParameters: false, 13 | ); 14 | 15 | ///Init catcher 16 | final debugOptions = 17 | Catcher2Options(DialogReportMode(), [httpHandler, ConsoleHandler()]); 18 | final releaseOptions = Catcher2Options(PageReportMode(), [ 19 | EmailManualHandler(['recipient@email.com']), 20 | ]); 21 | 22 | Catcher2( 23 | rootWidget: const MyApp(), 24 | debugConfig: debugOptions, 25 | releaseConfig: releaseOptions, 26 | ); 27 | 28 | ///At some point of time, you're updating headers: 29 | 30 | httpHandler.headers.clear(); 31 | httpHandler.headers['my_header'] = 'Test'; 32 | } 33 | 34 | class MyApp extends StatefulWidget { 35 | const MyApp({super.key}); 36 | 37 | @override 38 | State createState() => _MyAppState(); 39 | } 40 | 41 | class _MyAppState extends State { 42 | @override 43 | void initState() { 44 | super.initState(); 45 | } 46 | 47 | @override 48 | Widget build(BuildContext context) => MaterialApp( 49 | navigatorKey: Catcher2.navigatorKey, 50 | home: Scaffold( 51 | appBar: AppBar( 52 | title: const Text('Plugin example app'), 53 | ), 54 | body: const ChildWidget(), 55 | ), 56 | ); 57 | } 58 | 59 | class ChildWidget extends StatelessWidget { 60 | const ChildWidget({super.key}); 61 | 62 | @override 63 | Widget build(BuildContext context) => TextButton( 64 | onPressed: generateError, 65 | child: const Text('Generate error'), 66 | ); 67 | 68 | Future generateError() async { 69 | Catcher2.sendTestException(); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /example/windows/runner/utils.cpp: -------------------------------------------------------------------------------- 1 | #include "utils.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | void CreateAndAttachConsole() { 11 | if (::AllocConsole()) { 12 | FILE *unused; 13 | if (freopen_s(&unused, "CONOUT$", "w", stdout)) { 14 | _dup2(_fileno(stdout), 1); 15 | } 16 | if (freopen_s(&unused, "CONOUT$", "w", stderr)) { 17 | _dup2(_fileno(stdout), 2); 18 | } 19 | std::ios::sync_with_stdio(); 20 | FlutterDesktopResyncOutputStreams(); 21 | } 22 | } 23 | 24 | std::vector GetCommandLineArguments() { 25 | // Convert the UTF-16 command line arguments to UTF-8 for the Engine to use. 26 | int argc; 27 | wchar_t** argv = ::CommandLineToArgvW(::GetCommandLineW(), &argc); 28 | if (argv == nullptr) { 29 | return std::vector(); 30 | } 31 | 32 | std::vector command_line_arguments; 33 | 34 | // Skip the first argument as it's the binary name. 35 | for (int i = 1; i < argc; i++) { 36 | command_line_arguments.push_back(Utf8FromUtf16(argv[i])); 37 | } 38 | 39 | ::LocalFree(argv); 40 | 41 | return command_line_arguments; 42 | } 43 | 44 | std::string Utf8FromUtf16(const wchar_t* utf16_string) { 45 | if (utf16_string == nullptr) { 46 | return std::string(); 47 | } 48 | unsigned int target_length = ::WideCharToMultiByte( 49 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 50 | -1, nullptr, 0, nullptr, nullptr) 51 | -1; // remove the trailing null character 52 | int input_length = (int)wcslen(utf16_string); 53 | std::string utf8_string; 54 | if (target_length == 0 || target_length > utf8_string.max_size()) { 55 | return utf8_string; 56 | } 57 | utf8_string.resize(target_length); 58 | int converted_length = ::WideCharToMultiByte( 59 | CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, 60 | input_length, utf8_string.data(), target_length, nullptr, nullptr); 61 | if (converted_length == 0) { 62 | return std::string(); 63 | } 64 | return utf8_string; 65 | } 66 | -------------------------------------------------------------------------------- /platform_support.md: -------------------------------------------------------------------------------- 1 | ## Platform support 2 | Catcher 2 supports all platforms available in Flutter: 3 | * Mobile: Android, iOS 4 | * Web 5 | * Desktop: Linux, Windows, MacOS 6 | 7 | Some features available in Android/iOS won't be available in other platforms due to no support of dependencies used by Catcher 2. This may change in the future, but right now some features are disabled in Web/Desktop platforms. 8 | 9 | Check table below to see which features are enabled in Platforms: 10 | | Feature | Android | iOS | Web | Linux | Windows | MacOS | 11 | |:---------------------------:|:-------:|:---:|:---:|:-----:|:-------:|:-----:| 12 | | Application data in report | ✔ | ✔ | ❌ | ❌ | ❌ | ❌ | 13 | | Console handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 14 | | Discord handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 15 | | Email auto handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 16 | | File handler | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | 17 | | Http handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 18 | | Sentry handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 19 | | Slack handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 20 | | Toast handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 21 | | Custom handler | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 22 | | Dialog report mode | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 23 | | Page report mode | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 24 | | Silent report mode | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 25 | | Custom report mode | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 26 | | Explicit report mode map | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 27 | | Explicit report handler map | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 28 | | Error widget | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | 29 | | Screenshots | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | 30 | -------------------------------------------------------------------------------- /lib/handlers/email_manual_handler.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/handlers/base_email_handler.dart'; 2 | import 'package:catcher_2/model/platform_type.dart'; 3 | import 'package:catcher_2/model/report.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:flutter_mailer/flutter_mailer.dart'; 6 | 7 | class EmailManualHandler extends BaseEmailHandler { 8 | EmailManualHandler( 9 | this.recipients, { 10 | this.sendHtml = true, 11 | this.printLogs = false, 12 | super.emailTitle, 13 | super.emailHeader, 14 | super.enableDeviceParameters = true, 15 | super.enableApplicationParameters = true, 16 | super.enableStackTrace = true, 17 | super.enableCustomParameters = true, 18 | }) : assert(recipients.isNotEmpty, "Recipients can't be empty"); 19 | final List recipients; 20 | final bool sendHtml; 21 | final bool printLogs; 22 | 23 | @override 24 | Future handle(Report report, BuildContext? context) async => 25 | _sendEmail(report); 26 | 27 | Future _sendEmail(Report report) async { 28 | try { 29 | final mailOptions = MailOptions( 30 | body: _getEmailBody(report), 31 | subject: getEmailTitle(report), 32 | recipients: recipients, 33 | isHTML: sendHtml, 34 | attachments: [ 35 | report.screenshot?.path ?? '', 36 | ], 37 | ); 38 | _printLog('Creating mail request'); 39 | await FlutterMailer.send(mailOptions); 40 | _printLog('Creating mail request success'); 41 | return true; 42 | } catch (exc, stackTrace) { 43 | _printLog('Exception occurred: $exc stack: $stackTrace'); 44 | return false; 45 | } 46 | } 47 | 48 | String _getEmailBody(Report report) { 49 | if (sendHtml) { 50 | return setupHtmlMessageText(report); 51 | } else { 52 | return setupRawMessageText(report); 53 | } 54 | } 55 | 56 | void _printLog(String log) { 57 | if (printLogs) { 58 | logger.info(log); 59 | } 60 | } 61 | 62 | @override 63 | List getSupportedPlatforms() => [ 64 | PlatformType.android, 65 | PlatformType.iOS, 66 | ]; 67 | } 68 | -------------------------------------------------------------------------------- /example/lib/error_widget_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options(SilentReportMode(), [ 6 | ConsoleHandler(), 7 | ]); 8 | final releaseOptions = Catcher2Options(PageReportMode(), [ 9 | EmailManualHandler(['recipient@email.com']), 10 | ]); 11 | 12 | Catcher2( 13 | rootWidget: const MyApp(), 14 | debugConfig: debugOptions, 15 | releaseConfig: releaseOptions, 16 | ); 17 | } 18 | 19 | class MyApp extends StatefulWidget { 20 | const MyApp({super.key}); 21 | 22 | @override 23 | State createState() => _MyAppState(); 24 | } 25 | 26 | class _MyAppState extends State { 27 | @override 28 | void initState() { 29 | super.initState(); 30 | } 31 | 32 | @override 33 | Widget build(BuildContext context) => MaterialApp( 34 | navigatorKey: Catcher2.navigatorKey, 35 | builder: (context, widget) { 36 | Catcher2.addDefaultErrorWidget( 37 | showStacktrace: true, 38 | title: 'Custom title', 39 | description: 'Custom description', 40 | maxWidthForSmallMode: 150, 41 | ); 42 | return widget!; 43 | }, 44 | home: Scaffold( 45 | appBar: AppBar( 46 | title: const Text('Plugin example app'), 47 | ), 48 | body: _buildSmallErrorWidget(), 49 | ), 50 | ); 51 | 52 | ///Trigger "normal" mode 53 | /*Widget _buildNormalErrorWidget() { 54 | return ChildWidget(); 55 | }*/ 56 | 57 | ///Trigger "small" mode 58 | Widget _buildSmallErrorWidget() => GridView.count( 59 | crossAxisCount: 3, 60 | children: const [ 61 | ChildWidget(), 62 | ChildWidget(), 63 | ChildWidget(), 64 | ], 65 | ); 66 | } 67 | 68 | class ChildWidget extends StatelessWidget { 69 | const ChildWidget({super.key}); 70 | 71 | @override 72 | Widget build(BuildContext context) => 73 | TextButton(onPressed: generateError, child: const Text('Test')); 74 | 75 | Future generateError() async { 76 | Catcher2.sendTestException(); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /example/lib/update_config_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | late Catcher2 catcher2; 5 | 6 | void main() { 7 | final debugOptions = Catcher2Options(DialogReportMode(), [ 8 | //EmailManualHandler(["recipient@email.com"]), 9 | HttpHandler( 10 | HttpRequestType.post, 11 | Uri.parse('https://jsonplaceholder.typicode.com/posts'), 12 | printLogs: true, 13 | ), 14 | ConsoleHandler(), 15 | ]); 16 | final releaseOptions = Catcher2Options(PageReportMode(), [ 17 | EmailManualHandler(['recipient@email.com']), 18 | ]); 19 | 20 | catcher2 = Catcher2( 21 | rootWidget: const MyApp(), 22 | debugConfig: debugOptions, 23 | releaseConfig: releaseOptions, 24 | ); 25 | } 26 | 27 | class MyApp extends StatefulWidget { 28 | const MyApp({super.key}); 29 | 30 | @override 31 | State createState() => _MyAppState(); 32 | } 33 | 34 | class _MyAppState extends State { 35 | @override 36 | void initState() { 37 | super.initState(); 38 | } 39 | 40 | @override 41 | Widget build(BuildContext context) => MaterialApp( 42 | navigatorKey: Catcher2.navigatorKey, 43 | home: Scaffold( 44 | appBar: AppBar( 45 | title: const Text('Plugin example app'), 46 | ), 47 | body: const ChildWidget(), 48 | ), 49 | ); 50 | } 51 | 52 | class ChildWidget extends StatelessWidget { 53 | const ChildWidget({super.key}); 54 | 55 | @override 56 | Widget build(BuildContext context) => Row( 57 | children: [ 58 | TextButton( 59 | onPressed: changeConfig, 60 | child: const Text('Change config'), 61 | ), 62 | TextButton( 63 | onPressed: generateError, 64 | child: const Text('Generate error'), 65 | ), 66 | ], 67 | ); 68 | 69 | Future generateError() async { 70 | Catcher2.sendTestException(); 71 | } 72 | 73 | void changeConfig() { 74 | catcher2.updateConfig( 75 | debugConfig: Catcher2Options( 76 | PageReportMode(), 77 | [ConsoleHandler()], 78 | ), 79 | ); 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /example/lib/change_custom_parameters_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | late Catcher2 catcher2; 5 | 6 | void main() { 7 | final customParameters = {}; 8 | customParameters['First'] = 'First parameter'; 9 | final debugOptions = Catcher2Options( 10 | PageReportMode(), 11 | [ 12 | ConsoleHandler(enableCustomParameters: true), 13 | ], 14 | customParameters: customParameters, 15 | ); 16 | final releaseOptions = Catcher2Options(PageReportMode(), [ 17 | EmailManualHandler(['recipient@email.com']), 18 | ]); 19 | 20 | catcher2 = Catcher2( 21 | rootWidget: const MyApp(), 22 | debugConfig: debugOptions, 23 | releaseConfig: releaseOptions, 24 | ); 25 | } 26 | 27 | class MyApp extends StatefulWidget { 28 | const MyApp({super.key}); 29 | 30 | @override 31 | State createState() => _MyAppState(); 32 | } 33 | 34 | class _MyAppState extends State { 35 | @override 36 | void initState() { 37 | super.initState(); 38 | } 39 | 40 | @override 41 | Widget build(BuildContext context) => MaterialApp( 42 | navigatorKey: Catcher2.navigatorKey, 43 | home: Scaffold( 44 | appBar: AppBar( 45 | title: const Text('Plugin example app'), 46 | ), 47 | body: const ChildWidget(), 48 | ), 49 | ); 50 | } 51 | 52 | class ChildWidget extends StatelessWidget { 53 | const ChildWidget({super.key}); 54 | 55 | @override 56 | Widget build(BuildContext context) => Column( 57 | children: [ 58 | ElevatedButton( 59 | onPressed: _changeCustomParameters, 60 | child: const Text('Change custom parameters'), 61 | ), 62 | ElevatedButton( 63 | onPressed: generateError, 64 | child: const Text('Generate error'), 65 | ), 66 | ], 67 | ); 68 | 69 | Future generateError() async { 70 | Catcher2.sendTestException(); 71 | } 72 | 73 | void _changeCustomParameters() { 74 | final options = catcher2.getCurrentConfig()!; 75 | options.customParameters['Second'] = 'Second parameter'; 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /example/lib/explicit_error_report_mode_map_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final explicitReportModesMap = {'FormatException': PageReportMode()}; 6 | final debugOptions = Catcher2Options( 7 | DialogReportMode(), 8 | [ 9 | ConsoleHandler(), 10 | HttpHandler( 11 | HttpRequestType.post, 12 | Uri.parse('https://httpstat.us/200'), 13 | printLogs: true, 14 | ), 15 | ], 16 | explicitExceptionReportModesMap: explicitReportModesMap, 17 | ); 18 | final releaseOptions = Catcher2Options(PageReportMode(), [ 19 | EmailManualHandler(['recipient@email.com']), 20 | ]); 21 | 22 | Catcher2( 23 | rootWidget: const MyApp(), 24 | debugConfig: debugOptions, 25 | releaseConfig: releaseOptions, 26 | ); 27 | } 28 | 29 | class MyApp extends StatefulWidget { 30 | const MyApp({super.key}); 31 | 32 | @override 33 | State createState() => _MyAppState(); 34 | } 35 | 36 | class _MyAppState extends State { 37 | @override 38 | void initState() { 39 | super.initState(); 40 | } 41 | 42 | @override 43 | Widget build(BuildContext context) => MaterialApp( 44 | navigatorKey: Catcher2.navigatorKey, 45 | home: Scaffold( 46 | appBar: AppBar( 47 | title: const Text('Plugin example app'), 48 | ), 49 | body: const ChildWidget(), 50 | ), 51 | ); 52 | } 53 | 54 | class ChildWidget extends StatelessWidget { 55 | const ChildWidget({super.key}); 56 | 57 | @override 58 | Widget build(BuildContext context) => Column( 59 | children: [ 60 | TextButton( 61 | onPressed: generateFirstError, 62 | child: const Text('Generate first error'), 63 | ), 64 | TextButton( 65 | onPressed: generateSecondError, 66 | child: const Text('Generate second error'), 67 | ), 68 | ], 69 | ); 70 | 71 | Future generateFirstError() async { 72 | throw const FormatException('Example Error'); 73 | } 74 | 75 | Future generateSecondError() async { 76 | throw ArgumentError('Normal error'); 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /lib/model/report.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/platform_type.dart'; 2 | import 'package:cross_file/cross_file.dart'; 3 | import 'package:flutter/foundation.dart'; 4 | 5 | class Report { 6 | /// Creates report instance 7 | Report( 8 | this.error, 9 | this.stackTrace, 10 | this.dateTime, 11 | this.deviceParameters, 12 | this.applicationParameters, 13 | this.customParameters, 14 | this.errorDetails, 15 | this.platformType, 16 | this.screenshot, 17 | ); 18 | 19 | /// Error that has been caught 20 | final dynamic error; 21 | 22 | /// Stack trace of error 23 | final dynamic stackTrace; 24 | 25 | /// Time when it was caught 26 | final DateTime dateTime; 27 | 28 | /// Device info 29 | final Map deviceParameters; 30 | 31 | /// Application info 32 | final Map applicationParameters; 33 | 34 | /// Custom parameters passed to report 35 | final Map customParameters; 36 | 37 | /// FlutterErrorDetails data if present 38 | final FlutterErrorDetails? errorDetails; 39 | 40 | /// Type of platform used 41 | final PlatformType platformType; 42 | 43 | /// Screenshot of screen where error happens. Screenshot won't work everywhere 44 | /// (i.e. web platform), so this may be `null` 45 | final XFile? screenshot; 46 | 47 | /// Creates json from current instance 48 | Map toJson({ 49 | bool enableDeviceParameters = true, 50 | bool enableApplicationParameters = true, 51 | bool enableStackTrace = true, 52 | bool enableCustomParameters = false, 53 | }) { 54 | final json = { 55 | 'error': error.toString(), 56 | 'customParameters': customParameters, 57 | 'dateTime': dateTime.toIso8601String(), 58 | 'platformType': platformType.name, 59 | }; 60 | if (enableDeviceParameters) { 61 | json['deviceParameters'] = deviceParameters; 62 | } 63 | if (enableApplicationParameters) { 64 | json['applicationParameters'] = applicationParameters; 65 | } 66 | if (enableStackTrace) { 67 | json['stackTrace'] = stackTrace.toString(); 68 | } 69 | if (enableCustomParameters) { 70 | json['customParameters'] = customParameters; 71 | } 72 | return json; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /example/lib/custom_logger_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options( 6 | DialogReportMode(), 7 | [ 8 | ConsoleHandler(), 9 | ], 10 | logger: CustomCatcher2Logger(), 11 | ); 12 | final releaseOptions = Catcher2Options(PageReportMode(), [ 13 | EmailManualHandler(['recipient@email.com']), 14 | ]); 15 | 16 | Catcher2( 17 | runAppFunction: () { 18 | runApp(const MyApp()); 19 | }, 20 | debugConfig: debugOptions, 21 | releaseConfig: releaseOptions, 22 | ); 23 | } 24 | 25 | class MyApp extends StatefulWidget { 26 | const MyApp({super.key}); 27 | 28 | @override 29 | State createState() => _MyAppState(); 30 | } 31 | 32 | class _MyAppState extends State { 33 | @override 34 | void initState() { 35 | super.initState(); 36 | } 37 | 38 | @override 39 | Widget build(BuildContext context) => MaterialApp( 40 | navigatorKey: Catcher2.navigatorKey, 41 | home: Scaffold( 42 | appBar: AppBar( 43 | title: const Text('Plugin example app'), 44 | ), 45 | body: const ChildWidget(), 46 | ), 47 | ); 48 | } 49 | 50 | class ChildWidget extends StatelessWidget { 51 | const ChildWidget({super.key}); 52 | 53 | @override 54 | Widget build(BuildContext context) => TextButton( 55 | onPressed: generateError, 56 | child: const Text('Generate error'), 57 | ); 58 | 59 | Future generateError() async { 60 | Catcher2.sendTestException(); 61 | } 62 | } 63 | 64 | class CustomCatcher2Logger extends Catcher2Logger { 65 | @override 66 | void info(String message) { 67 | // ignore: avoid_print 68 | print('Custom Catcher Logger | Info | $message'); 69 | } 70 | 71 | @override 72 | void fine(String message) { 73 | // ignore: avoid_print 74 | print('Custom Catcher Logger | Fine | $message'); 75 | } 76 | 77 | @override 78 | void warning(String message) { 79 | // ignore: avoid_print 80 | print('Custom Catcher Logger | Warning | $message'); 81 | } 82 | 83 | @override 84 | void severe(String message) { 85 | // ignore: avoid_print 86 | print('Custom Catcher Logger | Severe | $message'); 87 | } 88 | } 89 | -------------------------------------------------------------------------------- /backend/src/main/java/com/jhomlala/catcher_2/backend/ReportLog.java: -------------------------------------------------------------------------------- 1 | package com.jhomlala.catcher_2.backend; 2 | 3 | import java.sql.Timestamp; 4 | import java.util.Map; 5 | import java.util.Map.Entry; 6 | 7 | public class ReportLog { 8 | private String error; 9 | private String stackTrace; 10 | private Map deviceParameters; 11 | private Map applicationParameters; 12 | private Map customParameters; 13 | private Timestamp dateTime; 14 | public String getError() { 15 | return error; 16 | } 17 | public void setError(String error) { 18 | this.error = error; 19 | } 20 | public String getStackTrace() { 21 | return stackTrace; 22 | } 23 | public void setStackTrace(String stackTrace) { 24 | this.stackTrace = stackTrace; 25 | } 26 | public Map getDeviceParameters() { 27 | return deviceParameters; 28 | } 29 | public void setDeviceParameters(Map deviceParameters) { 30 | this.deviceParameters = deviceParameters; 31 | } 32 | public Map getApplicationParameters() { 33 | return applicationParameters; 34 | } 35 | public void setApplicationParameters(Map applicationParameters) { 36 | this.applicationParameters = applicationParameters; 37 | } 38 | public Map getCustomParameters() { 39 | return customParameters; 40 | } 41 | public void setCustomParameters(Map customParameters) { 42 | this.customParameters = customParameters; 43 | } 44 | 45 | public Timestamp getDateTime() { 46 | return dateTime; 47 | } 48 | public void setDateTime(Timestamp dateTime) { 49 | this.dateTime = dateTime; 50 | } 51 | @Override 52 | public String toString() { 53 | return "ReportLog [error=" + error + ", stackTrace=" + stackTrace + ", deviceParameters=" + deviceParameters 54 | + ", applicationParameters=" + applicationParameters + ", customParameters=" + customParameters 55 | + ", dateTime=" + dateTime + "]"; 56 | } 57 | 58 | public String getStackTraceFormatted() { 59 | return ""+stackTrace.replace("\n", "
")+"
"; 60 | } 61 | 62 | public String getDeviceDataFormatted() { 63 | String text = ""; 64 | for (Entry entry: deviceParameters.entrySet()) { 65 | text += ""+entry.getKey()+":"+entry.getValue() +"
"; 66 | } 67 | text += "
"; 68 | return text; 69 | } 70 | 71 | 72 | } 73 | -------------------------------------------------------------------------------- /example/android/app/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id "com.android.application" 3 | id "kotlin-android" 4 | // The Flutter Gradle Plugin must be applied after the Android and Kotlin Gradle plugins. 5 | id "dev.flutter.flutter-gradle-plugin" 6 | } 7 | 8 | def localProperties = new Properties() 9 | def localPropertiesFile = rootProject.file("local.properties") 10 | if (localPropertiesFile.exists()) { 11 | localPropertiesFile.withReader("UTF-8") { reader -> 12 | localProperties.load(reader) 13 | } 14 | } 15 | 16 | def flutterVersionCode = localProperties.getProperty("flutter.versionCode") 17 | if (flutterVersionCode == null) { 18 | flutterVersionCode = "1" 19 | } 20 | 21 | def flutterVersionName = localProperties.getProperty("flutter.versionName") 22 | if (flutterVersionName == null) { 23 | flutterVersionName = "1.0" 24 | } 25 | 26 | android { 27 | namespace = "com.jhomlala.catcher_2_example" 28 | compileSdk = flutter.compileSdkVersion 29 | ndkVersion = "25.1.8937393" // flutter.ndkVersion 30 | 31 | compileOptions { 32 | sourceCompatibility = JavaVersion.VERSION_11 33 | targetCompatibility = JavaVersion.VERSION_11 34 | coreLibraryDesugaringEnabled true 35 | } 36 | 37 | kotlinOptions { 38 | jvmTarget = JavaVersion.VERSION_11 39 | } 40 | 41 | defaultConfig { 42 | // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). 43 | applicationId = "com.jhomlala.catcher_2_example" 44 | // You can update the following values to match your application needs. 45 | // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. 46 | minSdk = flutter.minSdkVersion 47 | targetSdk = flutter.targetSdkVersion 48 | versionCode = flutterVersionCode.toInteger() 49 | versionName = flutterVersionName 50 | } 51 | 52 | buildTypes { 53 | release { 54 | // TODO: Add your own signing config for the release build. 55 | // Signing with the debug keys for now, so `flutter run --release` works. 56 | signingConfig = signingConfigs.debug 57 | } 58 | } 59 | } 60 | 61 | flutter { 62 | source = "../.." 63 | } 64 | 65 | dependencies { 66 | coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.2' 67 | } 68 | -------------------------------------------------------------------------------- /example/android/app/src/main/AndroidManifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 15 | 19 | 23 | 24 | 25 | 26 | 27 | 28 | 30 | 33 | 34 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /example/lib/snackbar_handler_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | 4 | void main() { 5 | final debugOptions = Catcher2Options(DialogReportMode(), [ 6 | SnackbarHandler( 7 | const Duration(seconds: 5), 8 | backgroundColor: Colors.green, 9 | elevation: 2, 10 | margin: const EdgeInsets.all(16), 11 | padding: const EdgeInsets.all(16), 12 | shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(16)), 13 | behavior: SnackBarBehavior.floating, 14 | action: SnackBarAction( 15 | label: 'Button', 16 | onPressed: () { 17 | // ignore: avoid_print 18 | print('Click!'); 19 | }, 20 | ), 21 | textStyle: const TextStyle( 22 | color: Colors.white, 23 | fontSize: 16, 24 | ), 25 | ), 26 | ]); 27 | final releaseOptions = Catcher2Options(DialogReportMode(), [ 28 | SnackbarHandler( 29 | const Duration(seconds: 5), 30 | backgroundColor: Colors.green, 31 | elevation: 2, 32 | padding: const EdgeInsets.all(16), 33 | textStyle: const TextStyle( 34 | color: Colors.white, 35 | fontSize: 16, 36 | ), 37 | ), 38 | ]); 39 | 40 | Catcher2( 41 | runAppFunction: () { 42 | runApp(const MyApp()); 43 | }, 44 | debugConfig: debugOptions, 45 | releaseConfig: releaseOptions, 46 | ); 47 | } 48 | 49 | class MyApp extends StatefulWidget { 50 | const MyApp({super.key}); 51 | 52 | @override 53 | State createState() => _MyAppState(); 54 | } 55 | 56 | class _MyAppState extends State { 57 | @override 58 | void initState() { 59 | super.initState(); 60 | } 61 | 62 | @override 63 | Widget build(BuildContext context) => MaterialApp( 64 | navigatorKey: Catcher2.navigatorKey, 65 | home: Scaffold( 66 | appBar: AppBar( 67 | title: const Text('Snackbar handler example'), 68 | ), 69 | body: const ChildWidget(), 70 | ), 71 | ); 72 | } 73 | 74 | class ChildWidget extends StatelessWidget { 75 | const ChildWidget({super.key}); 76 | 77 | @override 78 | Widget build(BuildContext context) => TextButton( 79 | onPressed: generateError, 80 | child: const Text('Generate error'), 81 | ); 82 | 83 | Future generateError() async { 84 | Catcher2.sendTestException(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /example/windows/runner/flutter_window.cpp: -------------------------------------------------------------------------------- 1 | #include "flutter_window.h" 2 | 3 | #include 4 | 5 | #include "flutter/generated_plugin_registrant.h" 6 | 7 | FlutterWindow::FlutterWindow(const flutter::DartProject& project) 8 | : project_(project) {} 9 | 10 | FlutterWindow::~FlutterWindow() {} 11 | 12 | bool FlutterWindow::OnCreate() { 13 | if (!Win32Window::OnCreate()) { 14 | return false; 15 | } 16 | 17 | RECT frame = GetClientArea(); 18 | 19 | // The size here must match the window dimensions to avoid unnecessary surface 20 | // creation / destruction in the startup path. 21 | flutter_controller_ = std::make_unique( 22 | frame.right - frame.left, frame.bottom - frame.top, project_); 23 | // Ensure that basic setup of the controller was successful. 24 | if (!flutter_controller_->engine() || !flutter_controller_->view()) { 25 | return false; 26 | } 27 | RegisterPlugins(flutter_controller_->engine()); 28 | SetChildContent(flutter_controller_->view()->GetNativeWindow()); 29 | 30 | flutter_controller_->engine()->SetNextFrameCallback([&]() { 31 | this->Show(); 32 | }); 33 | 34 | // Flutter can complete the first frame before the "show window" callback is 35 | // registered. The following call ensures a frame is pending to ensure the 36 | // window is shown. It is a no-op if the first frame hasn't completed yet. 37 | flutter_controller_->ForceRedraw(); 38 | 39 | return true; 40 | } 41 | 42 | void FlutterWindow::OnDestroy() { 43 | if (flutter_controller_) { 44 | flutter_controller_ = nullptr; 45 | } 46 | 47 | Win32Window::OnDestroy(); 48 | } 49 | 50 | LRESULT 51 | FlutterWindow::MessageHandler(HWND hwnd, UINT const message, 52 | WPARAM const wparam, 53 | LPARAM const lparam) noexcept { 54 | // Give Flutter, including plugins, an opportunity to handle window messages. 55 | if (flutter_controller_) { 56 | std::optional result = 57 | flutter_controller_->HandleTopLevelWindowProc(hwnd, message, wparam, 58 | lparam); 59 | if (result) { 60 | return *result; 61 | } 62 | } 63 | 64 | switch (message) { 65 | case WM_FONTCHANGE: 66 | flutter_controller_->engine()->ReloadSystemFonts(); 67 | break; 68 | } 69 | 70 | return Win32Window::MessageHandler(hwnd, message, wparam, lparam); 71 | } 72 | -------------------------------------------------------------------------------- /example/lib/screenshot_example.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:catcher_2/catcher_2.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:path_provider/path_provider.dart'; 6 | 7 | void main() async { 8 | final catcher2 = Catcher2(rootWidget: const MyApp(), ensureInitialized: true); 9 | Directory? externalDir; 10 | if (Platform.isAndroid) { 11 | externalDir = await getExternalStorageDirectory(); 12 | } 13 | if (Platform.isIOS || Platform.isMacOS) { 14 | externalDir = await getApplicationDocumentsDirectory(); 15 | } 16 | var path = ''; 17 | if (externalDir != null) { 18 | path = externalDir.path; 19 | } 20 | 21 | final debugOptions = Catcher2Options( 22 | DialogReportMode(), 23 | [ 24 | EmailManualHandler( 25 | ['email1@email.com', 'email2@email.com'], 26 | enableDeviceParameters: true, 27 | enableStackTrace: true, 28 | enableCustomParameters: true, 29 | enableApplicationParameters: true, 30 | sendHtml: true, 31 | emailTitle: 'Sample Title', 32 | emailHeader: 'Sample Header', 33 | printLogs: true, 34 | ), 35 | ], 36 | customParameters: { 37 | 'Test': 'Test12345', 38 | 'Test2': 'Test54321', 39 | }, 40 | screenshotsPath: path, 41 | ); 42 | 43 | catcher2.updateConfig(debugConfig: debugOptions); 44 | } 45 | 46 | class MyApp extends StatefulWidget { 47 | const MyApp({super.key}); 48 | 49 | @override 50 | State createState() => _MyAppState(); 51 | } 52 | 53 | class _MyAppState extends State { 54 | @override 55 | void initState() { 56 | super.initState(); 57 | } 58 | 59 | @override 60 | Widget build(BuildContext context) => MaterialApp( 61 | navigatorKey: Catcher2.navigatorKey, 62 | home: Catcher2Screenshot( 63 | catcher2: Catcher2.getInstance(), 64 | child: Scaffold( 65 | appBar: AppBar( 66 | title: const Text('Plugin example app'), 67 | ), 68 | body: const ChildWidget(), 69 | ), 70 | ), 71 | ); 72 | } 73 | 74 | class ChildWidget extends StatelessWidget { 75 | const ChildWidget({super.key}); 76 | 77 | @override 78 | Widget build(BuildContext context) => TextButton( 79 | onPressed: generateError, 80 | child: const Text('Generate error'), 81 | ); 82 | 83 | Future generateError() async { 84 | Catcher2.sendTestException(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /example/ios/Runner/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /example/lib/main.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:sentry/sentry.dart'; 4 | 5 | void main() { 6 | ///Configure your debug options (settings used in development mode) 7 | final debugOptions = Catcher2Options( 8 | ///Show information about caught error in dialog 9 | DialogReportMode(), 10 | [ 11 | ///Send logs to HTTP server 12 | HttpHandler( 13 | HttpRequestType.post, 14 | Uri.parse('https://jsonplaceholder.typicode.com/posts'), 15 | printLogs: true, 16 | ), 17 | 18 | ///Print logs in console 19 | ConsoleHandler(), 20 | ], 21 | ); 22 | 23 | ///Configure your production options (settings used in release mode) 24 | final releaseOptions = Catcher2Options( 25 | ///Show new page with information about caught error 26 | PageReportMode(), 27 | [ 28 | ///Send logs to Sentry 29 | SentryHandler( 30 | SentryClient( 31 | SentryOptions(dsn: ''), 32 | ), 33 | ), 34 | 35 | ///Print logs in console 36 | ConsoleHandler(), 37 | ], 38 | ); 39 | 40 | ///Start Catcher and then start App. Now Catcher will guard and report any 41 | ///error to your configured services! 42 | Catcher2( 43 | runAppFunction: () { 44 | runApp(const MyApp()); 45 | }, 46 | ensureInitialized: true, 47 | debugConfig: debugOptions, 48 | releaseConfig: releaseOptions, 49 | ); 50 | } 51 | 52 | class MyApp extends StatefulWidget { 53 | const MyApp({super.key}); 54 | 55 | @override 56 | State createState() => _MyAppState(); 57 | } 58 | 59 | class _MyAppState extends State { 60 | @override 61 | void initState() { 62 | super.initState(); 63 | } 64 | 65 | @override 66 | Widget build(BuildContext context) => MaterialApp( 67 | ///Last step: add navigator key of Catcher here, so Catcher can show 68 | ///page and dialog! 69 | navigatorKey: Catcher2.navigatorKey, 70 | home: Scaffold( 71 | appBar: AppBar( 72 | title: const Text('Catcher example'), 73 | ), 74 | body: const ChildWidget(), 75 | ), 76 | ); 77 | } 78 | 79 | class ChildWidget extends StatelessWidget { 80 | const ChildWidget({super.key}); 81 | 82 | @override 83 | Widget build(BuildContext context) => TextButton( 84 | onPressed: generateError, 85 | child: const Text('Generate error'), 86 | ); 87 | 88 | ///Simply just trigger some error. 89 | Future generateError() async { 90 | Catcher2.sendTestException(); 91 | } 92 | } 93 | -------------------------------------------------------------------------------- /example/lib/file_example.dart: -------------------------------------------------------------------------------- 1 | import 'dart:io'; 2 | 3 | import 'package:catcher_2/catcher_2.dart'; 4 | import 'package:flutter/material.dart'; 5 | import 'package:path_provider/path_provider.dart'; 6 | import 'package:permission_handler/permission_handler.dart'; 7 | 8 | void main() async { 9 | final catcher2 = Catcher2(rootWidget: const MyApp(), ensureInitialized: true); 10 | Directory? externalDir; 11 | if (Platform.isAndroid || Platform.isIOS) { 12 | externalDir = await getExternalStorageDirectory(); 13 | } 14 | if (Platform.isMacOS) { 15 | externalDir = await getApplicationDocumentsDirectory(); 16 | } 17 | var path = ''; 18 | if (externalDir != null) { 19 | path = '${externalDir.path}/log.txt'; 20 | } 21 | // ignore: avoid_print 22 | print('PATH: $path'); 23 | 24 | final debugOptions = Catcher2Options( 25 | DialogReportMode(), 26 | [FileHandler(File(path), printLogs: true)], 27 | ); 28 | final releaseOptions = 29 | Catcher2Options(DialogReportMode(), [FileHandler(File(path))]); 30 | catcher2.updateConfig( 31 | debugConfig: debugOptions, 32 | releaseConfig: releaseOptions, 33 | ); 34 | } 35 | 36 | class MyApp extends StatefulWidget { 37 | const MyApp({super.key}); 38 | 39 | @override 40 | State createState() => _MyAppState(); 41 | } 42 | 43 | class _MyAppState extends State { 44 | @override 45 | void initState() { 46 | super.initState(); 47 | } 48 | 49 | @override 50 | Widget build(BuildContext context) => MaterialApp( 51 | navigatorKey: Catcher2.navigatorKey, 52 | home: Scaffold( 53 | appBar: AppBar( 54 | title: const Text('Plugin example app'), 55 | ), 56 | body: const ChildWidget(), 57 | ), 58 | ); 59 | } 60 | 61 | class ChildWidget extends StatelessWidget { 62 | const ChildWidget({super.key}); 63 | 64 | @override 65 | Widget build(BuildContext context) => Column( 66 | children: [ 67 | TextButton( 68 | onPressed: checkPermissions, 69 | child: const Text('Check permission'), 70 | ), 71 | TextButton( 72 | onPressed: generateError, 73 | child: const Text('Generate error'), 74 | ), 75 | ], 76 | ); 77 | 78 | Future checkPermissions() async { 79 | final status = await Permission.storage.status; 80 | // ignore: avoid_print 81 | print('Status: $status'); 82 | if (!status.isGranted) { 83 | // ignore: avoid_print 84 | print('Requested'); 85 | } 86 | } 87 | 88 | Future generateError() async { 89 | throw Exception('Test exception'); 90 | } 91 | } 92 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.yaml: -------------------------------------------------------------------------------- 1 | name: Bug report 2 | description: Create a bug report to help us improve 3 | title: '[Bug]: ' 4 | labels: 5 | - bug 6 | assignees: 7 | - ThexXTURBOXx 8 | body: 9 | - type: textarea 10 | attributes: 11 | label: Description 12 | description: A clear and concise description of the problem 13 | placeholder: Currently, I am trying to [...] 14 | validations: 15 | required: true 16 | - type: textarea 17 | attributes: 18 | label: Minimal Reproduction 19 | description: Provide steps to reproduce the problem 20 | placeholder: 'Steps to reproduce the behaviour: [...]' 21 | value: |- 22 | Steps to reproduce the behaviour: 23 | 24 | 1. Use the following code: 25 | ```dart 26 | 27 | ``` 28 | 2. [...] 29 | validations: 30 | required: true 31 | - type: textarea 32 | attributes: 33 | label: Exception or Error 34 | description: Provide error logs 35 | placeholder: Copy paste from the log/console 36 | validations: 37 | required: true 38 | - type: textarea 39 | attributes: 40 | label: Expected Behaviour 41 | description: A clear and concise description of what you expected to happen 42 | placeholder: The package should [...] 43 | validations: 44 | required: true 45 | - type: textarea 46 | attributes: 47 | label: Screenshots 48 | description: If applicable, add screenshots to help explain your problem 49 | placeholder: You can upload screenshots by drag’n’drop 50 | - type: textarea 51 | attributes: 52 | label: Additional context 53 | description: Add any other context about the problem here 54 | - type: markdown 55 | attributes: 56 | value: '# Environment' 57 | - type: input 58 | attributes: 59 | label: Device 60 | placeholder: e.g. iPhone 6, Desktop Computer 61 | validations: 62 | required: true 63 | - type: input 64 | attributes: 65 | label: OS 66 | placeholder: e.g. iOS 8.1, Windows 10 21H2 67 | validations: 68 | required: true 69 | - type: input 70 | attributes: 71 | label: Flutter version 72 | placeholder: e.g. 3.13.9 73 | validations: 74 | required: true 75 | - type: input 76 | attributes: 77 | label: catcher_2 version 78 | placeholder: e.g. 1.0.0 79 | validations: 80 | required: true 81 | - type: checkboxes 82 | attributes: 83 | label: Checklist 84 | options: 85 | - label: >- 86 | I have read and followed the **entire** 87 | [README](https://github.com/ThexXTURBOXx/catcher_2/blob/master/README.md) 88 | and it has not provided the solution I need. 89 | required: true 90 | - label: I have provided all the information I can. 91 | required: true 92 | -------------------------------------------------------------------------------- /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 | -------------------------------------------------------------------------------- /example/android/gradlew.bat: -------------------------------------------------------------------------------- 1 | @rem 2 | @rem Copyright 2015 the original author or authors. 3 | @rem 4 | @rem Licensed under the Apache License, Version 2.0 (the "License"); 5 | @rem you may not use this file except in compliance with the License. 6 | @rem You may obtain a copy of the License at 7 | @rem 8 | @rem https://www.apache.org/licenses/LICENSE-2.0 9 | @rem 10 | @rem Unless required by applicable law or agreed to in writing, software 11 | @rem distributed under the License is distributed on an "AS IS" BASIS, 12 | @rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | @rem See the License for the specific language governing permissions and 14 | @rem limitations under the License. 15 | @rem 16 | @rem SPDX-License-Identifier: Apache-2.0 17 | @rem 18 | 19 | @if "%DEBUG%"=="" @echo off 20 | @rem ########################################################################## 21 | @rem 22 | @rem Gradle startup script for Windows 23 | @rem 24 | @rem ########################################################################## 25 | 26 | @rem Set local scope for the variables with windows NT shell 27 | if "%OS%"=="Windows_NT" setlocal 28 | 29 | set DIRNAME=%~dp0 30 | if "%DIRNAME%"=="" set DIRNAME=. 31 | @rem This is normally unused 32 | set APP_BASE_NAME=%~n0 33 | set APP_HOME=%DIRNAME% 34 | 35 | @rem Resolve any "." and ".." in APP_HOME to make it shorter. 36 | for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi 37 | 38 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. 39 | set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m" 40 | 41 | @rem Find java.exe 42 | if defined JAVA_HOME goto findJavaFromJavaHome 43 | 44 | set JAVA_EXE=java.exe 45 | %JAVA_EXE% -version >NUL 2>&1 46 | if %ERRORLEVEL% equ 0 goto execute 47 | 48 | echo. 1>&2 49 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2 50 | echo. 1>&2 51 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 52 | echo location of your Java installation. 1>&2 53 | 54 | goto fail 55 | 56 | :findJavaFromJavaHome 57 | set JAVA_HOME=%JAVA_HOME:"=% 58 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe 59 | 60 | if exist "%JAVA_EXE%" goto execute 61 | 62 | echo. 1>&2 63 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2 64 | echo. 1>&2 65 | echo Please set the JAVA_HOME variable in your environment to match the 1>&2 66 | echo location of your Java installation. 1>&2 67 | 68 | goto fail 69 | 70 | :execute 71 | @rem Setup the command line 72 | 73 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar 74 | 75 | 76 | @rem Execute Gradle 77 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %* 78 | 79 | :end 80 | @rem End local scope for the variables with windows NT shell 81 | if %ERRORLEVEL% equ 0 goto mainEnd 82 | 83 | :fail 84 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of 85 | rem the _cmd.exe /c_ return code! 86 | set EXIT_CODE=%ERRORLEVEL% 87 | if %EXIT_CODE% equ 0 set EXIT_CODE=1 88 | if not ""=="%GRADLE_EXIT_CONSOLE%" exit %EXIT_CODE% 89 | exit /b %EXIT_CODE% 90 | 91 | :mainEnd 92 | if "%OS%"=="Windows_NT" endlocal 93 | 94 | :omega 95 | -------------------------------------------------------------------------------- /lib/handlers/console_handler.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/platform_type.dart'; 2 | import 'package:catcher_2/model/report.dart'; 3 | import 'package:catcher_2/model/report_handler.dart'; 4 | import 'package:flutter/material.dart'; 5 | 6 | class ConsoleHandler extends ReportHandler { 7 | ConsoleHandler({ 8 | this.enableDeviceParameters = true, 9 | this.enableApplicationParameters = true, 10 | this.enableStackTrace = true, 11 | this.enableCustomParameters = false, 12 | this.handleWhenRejected = false, 13 | }); 14 | 15 | final bool enableDeviceParameters; 16 | final bool enableApplicationParameters; 17 | final bool enableStackTrace; 18 | final bool enableCustomParameters; 19 | final bool handleWhenRejected; 20 | 21 | @override 22 | Future handle(Report report, BuildContext? context) { 23 | logger 24 | ..info( 25 | '============================== ' 26 | 'CATCHER 2 LOG ' 27 | '==============================', 28 | ) 29 | ..info('Crash occurred on ${report.dateTime}') 30 | ..info(''); 31 | if (enableDeviceParameters) { 32 | _printDeviceParametersFormatted(report.deviceParameters); 33 | logger.info(''); 34 | } 35 | if (enableApplicationParameters) { 36 | _printApplicationParametersFormatted(report.applicationParameters); 37 | logger.info(''); 38 | } 39 | logger 40 | ..info('---------- ERROR ----------') 41 | ..info('${report.error}') 42 | ..info(''); 43 | if (enableStackTrace) { 44 | _printStackTraceFormatted(report.stackTrace); 45 | } 46 | if (enableCustomParameters) { 47 | _printCustomParametersFormatted(report.customParameters); 48 | } 49 | logger.info( 50 | '======================================================================', 51 | ); 52 | return Future.value(true); 53 | } 54 | 55 | void _printDeviceParametersFormatted(Map deviceParameters) { 56 | logger.info('------- DEVICE INFO -------'); 57 | for (final entry in deviceParameters.entries) { 58 | logger.info('${entry.key}: ${entry.value}'); 59 | } 60 | } 61 | 62 | void _printApplicationParametersFormatted( 63 | Map applicationParameters, 64 | ) { 65 | logger.info('------- APP INFO -------'); 66 | for (final entry in applicationParameters.entries) { 67 | logger.info('${entry.key}: ${entry.value}'); 68 | } 69 | } 70 | 71 | void _printCustomParametersFormatted(Map customParameters) { 72 | logger.info('------- CUSTOM INFO -------'); 73 | for (final entry in customParameters.entries) { 74 | logger.info('${entry.key}: ${entry.value}'); 75 | } 76 | } 77 | 78 | void _printStackTraceFormatted(dynamic stackTrace) { 79 | logger.info('------- STACK TRACE -------'); 80 | stackTrace?.toString().split('\n').forEach((entry) => logger.info(entry)); 81 | } 82 | 83 | @override 84 | List getSupportedPlatforms() => [ 85 | PlatformType.android, 86 | PlatformType.iOS, 87 | PlatformType.web, 88 | PlatformType.linux, 89 | PlatformType.macOS, 90 | PlatformType.windows, 91 | ]; 92 | 93 | @override 94 | bool shouldHandleWhenRejected() => handleWhenRejected; 95 | } 96 | -------------------------------------------------------------------------------- /lib/utils/catcher_2_error_widget.dart: -------------------------------------------------------------------------------- 1 | import 'package:flutter/material.dart'; 2 | 3 | class Catcher2ErrorWidget extends StatelessWidget { 4 | const Catcher2ErrorWidget({ 5 | super.key, 6 | this.details, 7 | required this.showStacktrace, 8 | required this.title, 9 | required this.description, 10 | required this.maxWidthForSmallMode, 11 | }) : assert( 12 | maxWidthForSmallMode > 0, 13 | 'maxWidthForSmallMode must be positive', 14 | ); 15 | final FlutterErrorDetails? details; 16 | final bool showStacktrace; 17 | final String title; 18 | final String description; 19 | final double maxWidthForSmallMode; 20 | 21 | @override 22 | Widget build(BuildContext context) => LayoutBuilder( 23 | builder: (context, constraint) => 24 | constraint.maxWidth < maxWidthForSmallMode 25 | ? _buildSmallErrorWidget(context) 26 | : _buildNormalErrorWidget(context), 27 | ); 28 | 29 | Widget _buildSmallErrorWidget(BuildContext context) => Center( 30 | child: Icon( 31 | Icons.error_outline, 32 | color: Theme.of(context).colorScheme.error, 33 | size: 40, 34 | ), 35 | ); 36 | 37 | Widget _buildNormalErrorWidget(BuildContext context) => Container( 38 | margin: const EdgeInsets.all(20), 39 | child: Center( 40 | child: ListView( 41 | children: [ 42 | _buildIcon(context), 43 | Text( 44 | title, 45 | style: Theme.of(context) 46 | .textTheme 47 | .titleMedium 48 | ?.copyWith(fontSize: 25) ?? 49 | const TextStyle(fontSize: 25), 50 | textAlign: TextAlign.center, 51 | ), 52 | const SizedBox(height: 10), 53 | Text( 54 | _getDescription(), 55 | textAlign: TextAlign.center, 56 | ), 57 | const SizedBox(height: 10), 58 | _buildStackTraceWidget(), 59 | ], 60 | ), 61 | ), 62 | ); 63 | 64 | Widget _buildIcon(BuildContext context) => Icon( 65 | Icons.announcement, 66 | color: Theme.of(context).colorScheme.error, 67 | size: 40, 68 | ); 69 | 70 | Widget _buildStackTraceWidget() { 71 | if (showStacktrace) { 72 | final items = []; 73 | if (details != null) { 74 | items 75 | ..add(details!.exception.toString()) 76 | ..addAll(details!.stack.toString().split('\n')); 77 | } 78 | return ListView.builder( 79 | padding: const EdgeInsets.all(8), 80 | shrinkWrap: true, 81 | physics: const ClampingScrollPhysics(), 82 | itemCount: items.length, 83 | itemBuilder: (context, index) { 84 | final line = items[index]; 85 | return line.isNotEmpty ? Text(line) : const SizedBox(); 86 | }, 87 | ); 88 | } else { 89 | return const SizedBox(); 90 | } 91 | } 92 | 93 | String _getDescription() { 94 | var descriptionText = description; 95 | if (showStacktrace) { 96 | descriptionText += ' See details below.'; 97 | } 98 | return descriptionText; 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /example/lib/custom_report_mode_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:catcher_2/model/platform_type.dart'; 3 | import 'package:flutter/material.dart'; 4 | 5 | void main() { 6 | final debugOptions = Catcher2Options(CustomPageReportMode(), [ 7 | EmailManualHandler(['recipient@email.com']), 8 | ConsoleHandler(), 9 | ]); 10 | final releaseOptions = Catcher2Options(PageReportMode(), [ 11 | EmailManualHandler(['recipient@email.com']), 12 | ]); 13 | 14 | Catcher2( 15 | rootWidget: const MyApp(), 16 | debugConfig: debugOptions, 17 | releaseConfig: releaseOptions, 18 | ); 19 | } 20 | 21 | class MyApp extends StatefulWidget { 22 | const MyApp({super.key}); 23 | 24 | @override 25 | State createState() => _MyAppState(); 26 | } 27 | 28 | class _MyAppState extends State { 29 | @override 30 | void initState() { 31 | super.initState(); 32 | } 33 | 34 | @override 35 | Widget build(BuildContext context) => MaterialApp( 36 | navigatorKey: Catcher2.navigatorKey, 37 | home: Scaffold( 38 | appBar: AppBar( 39 | title: const Text('Plugin example app'), 40 | ), 41 | body: const ChildWidget(), 42 | ), 43 | ); 44 | } 45 | 46 | class ChildWidget extends StatelessWidget { 47 | const ChildWidget({super.key}); 48 | 49 | @override 50 | Widget build(BuildContext context) => TextButton( 51 | onPressed: generateError, 52 | child: const Text('Generate error'), 53 | ); 54 | 55 | Future generateError() async { 56 | Catcher2.sendTestException(); 57 | } 58 | } 59 | 60 | class CustomPageReportMode extends ReportMode { 61 | @override 62 | void requestAction(Report report, BuildContext? context) { 63 | if (context != null) { 64 | _navigateToPageWidget(report, context); 65 | } 66 | } 67 | 68 | Future _navigateToPageWidget( 69 | Report report, 70 | BuildContext context, 71 | ) async { 72 | await Future.delayed(Duration.zero); 73 | if (!context.mounted) { 74 | return; 75 | } 76 | await Navigator.push( 77 | context, 78 | MaterialPageRoute(builder: (context) => CustomPage(this, report)), 79 | ); 80 | } 81 | 82 | @override 83 | bool isContextRequired() => true; 84 | 85 | @override 86 | List getSupportedPlatforms() => 87 | [PlatformType.web, PlatformType.android, PlatformType.iOS]; 88 | } 89 | 90 | class CustomPage extends StatelessWidget { 91 | const CustomPage(this.reportMode, this.report, {super.key}); 92 | final ReportMode reportMode; 93 | final Report report; 94 | 95 | @override 96 | Widget build(BuildContext context) => Scaffold( 97 | appBar: AppBar( 98 | title: const Text('Test'), 99 | ), 100 | body: Row( 101 | children: [ 102 | ElevatedButton( 103 | child: const Text('Send report'), 104 | onPressed: () { 105 | reportMode.onActionConfirmed(report); 106 | }, 107 | ), 108 | ElevatedButton( 109 | child: const Text('Cancel report'), 110 | onPressed: () { 111 | reportMode.onActionRejected(report); 112 | Navigator.pop(context); 113 | }, 114 | ), 115 | ], 116 | ), 117 | ); 118 | } 119 | -------------------------------------------------------------------------------- /example/lib/localization_example.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/catcher_2.dart'; 2 | import 'package:flutter/material.dart'; 3 | import 'package:flutter_localizations/flutter_localizations.dart'; 4 | 5 | void main() { 6 | final debugOptions = Catcher2Options( 7 | DialogReportMode(), 8 | [ 9 | ConsoleHandler(), 10 | HttpHandler( 11 | HttpRequestType.post, 12 | Uri.parse('https://httpstat.us/200'), 13 | printLogs: true, 14 | ), 15 | ], 16 | localizationOptions: [ 17 | LocalizationOptions( 18 | 'en', 19 | dialogReportModeTitle: 'Custom message', 20 | dialogReportModeDescription: 'Custom message', 21 | dialogReportModeAccept: 'YES', 22 | dialogReportModeCancel: 'NO', 23 | ), 24 | LocalizationOptions( 25 | 'pl', 26 | notificationReportModeTitle: 'Wystąpił błąd aplikacji', 27 | notificationReportModeContent: 28 | 'Naciśnij tutaj aby wysłać raport do zespołu wpsarcia', 29 | dialogReportModeTitle: 'Błąd aplikacji', 30 | dialogReportModeDescription: 31 | 'Wystąpił niespodziewany błąd aplikacji. Raport z błędem jest ' 32 | 'gotowy do wysłania do zespołu wsparcia. Naciśnij akceptuj aby ' 33 | 'wysłać raport lub odrzuć aby odrzucić raport.', 34 | dialogReportModeAccept: 'Akceptuj', 35 | dialogReportModeCancel: 'Odrzuć', 36 | pageReportModeTitle: 'Błąd aplikacji', 37 | pageReportModeDescription: 38 | 'Wystąpił niespodziewany błąd aplikacji. Raport z błędem jest ' 39 | 'gotowy do wysłania do zespołu wsparcia. Naciśnij akceptuj aby ' 40 | 'wysłać raport lub odrzuć aby odrzucić raport.', 41 | pageReportModeAccept: 'Akceptuj', 42 | pageReportModeCancel: 'Odrzuć', 43 | ), 44 | ], 45 | ); 46 | final releaseOptions = Catcher2Options(PageReportMode(), [ 47 | EmailManualHandler(['recipient@email.com']), 48 | ]); 49 | 50 | Catcher2( 51 | rootWidget: const MyApp(), 52 | debugConfig: debugOptions, 53 | releaseConfig: releaseOptions, 54 | ); 55 | } 56 | 57 | class MyApp extends StatefulWidget { 58 | const MyApp({super.key}); 59 | 60 | @override 61 | State createState() => _MyAppState(); 62 | } 63 | 64 | class _MyAppState extends State { 65 | @override 66 | void initState() { 67 | super.initState(); 68 | } 69 | 70 | @override 71 | Widget build(BuildContext context) => MaterialApp( 72 | navigatorKey: Catcher2.navigatorKey, 73 | localizationsDelegates: const [ 74 | GlobalMaterialLocalizations.delegate, 75 | GlobalWidgetsLocalizations.delegate, 76 | ], 77 | supportedLocales: const [ 78 | Locale('en', 'US'), 79 | Locale('pl', 'PL'), 80 | ], 81 | home: Scaffold( 82 | appBar: AppBar( 83 | title: const Text('Plugin example app'), 84 | ), 85 | body: const ChildWidget(), 86 | ), 87 | ); 88 | } 89 | 90 | class ChildWidget extends StatelessWidget { 91 | const ChildWidget({super.key}); 92 | 93 | @override 94 | Widget build(BuildContext context) => TextButton( 95 | onPressed: generateError, 96 | child: const Text('Generate error'), 97 | ); 98 | 99 | Future generateError() async { 100 | throw Exception('Test exception'); 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /lib/handlers/email_auto_handler.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | 3 | import 'package:catcher_2/catcher_2.dart'; 4 | import 'package:catcher_2/handlers/base_email_handler.dart'; 5 | import 'package:catcher_2/model/platform_type.dart'; 6 | import 'package:catcher_2/model/report.dart'; 7 | import 'package:cross_file/cross_file.dart'; 8 | import 'package:flutter/material.dart'; 9 | import 'package:mailer/mailer.dart'; 10 | import 'package:mailer/smtp_server.dart'; 11 | 12 | class EmailAutoHandler extends BaseEmailHandler { 13 | EmailAutoHandler( 14 | this.smtpHost, 15 | this.smtpPort, 16 | this.senderEmail, 17 | this.senderName, 18 | this.senderPassword, 19 | this.recipients, { 20 | this.senderUsername, 21 | this.enableSsl = false, 22 | this.sendHtml = true, 23 | this.printLogs = false, 24 | super.emailTitle, 25 | super.emailHeader, 26 | super.enableDeviceParameters = true, 27 | super.enableApplicationParameters = true, 28 | super.enableStackTrace = true, 29 | super.enableCustomParameters = true, 30 | }) : assert(recipients.isNotEmpty, "Recipients can't be null or empty"); 31 | final String smtpHost; 32 | final int smtpPort; 33 | final String senderEmail; 34 | final String senderName; 35 | final String senderPassword; 36 | final String? senderUsername; 37 | final bool enableSsl; 38 | final List recipients; 39 | final bool sendHtml; 40 | final bool printLogs; 41 | 42 | @override 43 | Future handle(Report report, BuildContext? context) => 44 | _sendMail(report); 45 | 46 | Future _sendMail(Report report) async { 47 | try { 48 | final message = Message() 49 | ..from = Address(senderEmail, senderName) 50 | ..recipients.addAll(recipients) 51 | ..subject = getEmailTitle(report) 52 | ..text = setupRawMessageText(report); 53 | 54 | if (report.screenshot != null) { 55 | message.attachments = [XFilePngAttachment(report.screenshot!)]; 56 | } 57 | 58 | if (sendHtml) { 59 | message.html = setupHtmlMessageText(report); 60 | } 61 | _printLog('Sending email...'); 62 | 63 | final result = await send(message, _setupSmtpServer()); 64 | 65 | _printLog( 66 | 'Email result: mail: ${result.mail} ' 67 | 'sending start time: ${result.messageSendingStart} ' 68 | 'sending end time: ${result.messageSendingEnd}', 69 | ); 70 | 71 | return true; 72 | } catch (stacktrace, exception) { 73 | _printLog(stacktrace.toString()); 74 | _printLog(exception.toString()); 75 | return false; 76 | } 77 | } 78 | 79 | SmtpServer _setupSmtpServer() => SmtpServer( 80 | smtpHost, 81 | port: smtpPort, 82 | ssl: enableSsl, 83 | username: senderUsername ?? senderEmail, 84 | password: senderPassword, 85 | ); 86 | 87 | void _printLog(String log) { 88 | if (printLogs) { 89 | logger.info(log); 90 | } 91 | } 92 | 93 | @override 94 | List getSupportedPlatforms() => [ 95 | PlatformType.android, 96 | PlatformType.iOS, 97 | PlatformType.web, 98 | PlatformType.linux, 99 | PlatformType.macOS, 100 | PlatformType.windows, 101 | ]; 102 | } 103 | 104 | class XFilePngAttachment extends Attachment { 105 | XFilePngAttachment(this._xFile) { 106 | contentType = 'image/png'; 107 | } 108 | 109 | final XFile _xFile; 110 | 111 | @override 112 | Stream> asStream() => _xFile.openRead(); 113 | } 114 | -------------------------------------------------------------------------------- /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.jhomlala" "\0" 93 | VALUE "FileDescription", "catcher_2_example" "\0" 94 | VALUE "FileVersion", VERSION_AS_STRING "\0" 95 | VALUE "InternalName", "catcher_2_example" "\0" 96 | VALUE "LegalCopyright", "Copyright (C) 2024 com.jhomlala. All rights reserved." "\0" 97 | VALUE "OriginalFilename", "catcher_2_example.exe" "\0" 98 | VALUE "ProductName", "catcher_2_example" "\0" 99 | VALUE "ProductVersion", VERSION_AS_STRING "\0" 100 | END 101 | END 102 | BLOCK "VarFileInfo" 103 | BEGIN 104 | VALUE "Translation", 0x409, 1252 105 | END 106 | END 107 | 108 | #endif // English (United States) resources 109 | ///////////////////////////////////////////////////////////////////////////// 110 | 111 | 112 | 113 | #ifndef APSTUDIO_INVOKED 114 | ///////////////////////////////////////////////////////////////////////////// 115 | // 116 | // Generated from the TEXTINCLUDE 3 resource. 117 | // 118 | 119 | 120 | ///////////////////////////////////////////////////////////////////////////// 121 | #endif // not APSTUDIO_INVOKED 122 | -------------------------------------------------------------------------------- /example/pubspec.yaml: -------------------------------------------------------------------------------- 1 | name: catcher_2_example 2 | description: "Demonstrates how to use the catcher_2 package." 3 | # The following line prevents the package from being accidentally published to 4 | # pub.dev using `flutter pub publish`. This is preferred for private packages. 5 | publish_to: 'none' # Remove this line if you wish to publish to pub.dev 6 | 7 | environment: 8 | sdk: '>=3.4.4 <4.0.0' 9 | 10 | # Dependencies specify other packages that your package needs in order to work. 11 | # To automatically upgrade your package dependencies to the latest versions 12 | # consider running `flutter pub upgrade --major-versions`. Alternatively, 13 | # dependencies can be manually updated by changing the version numbers below to 14 | # the latest version available on pub.dev. To see which dependencies have newer 15 | # versions available, run `flutter pub outdated`. 16 | dependencies: 17 | flutter: 18 | sdk: flutter 19 | 20 | catcher_2: 21 | # When depending on this package from a real application you should use: 22 | # catcher_2: ^x.y.z 23 | # See https://dart.dev/tools/pub/dependencies#version-constraints 24 | # The example app is bundled with the plugin so we use a path dependency on 25 | # the parent directory to use the current plugin's version. 26 | path: ../ 27 | 28 | # The following adds the Cupertino Icons font to your application. 29 | # Use with the CupertinoIcons class for iOS style icons. 30 | cupertino_icons: ^1.0.6 31 | 32 | dio: ^5.0.1 33 | flutter_local_notifications: ^19.0.0 34 | flutter_localizations: 35 | sdk: flutter 36 | path_provider: ^2.0.1 37 | permission_handler: ^12.0.0 38 | sentry: ^9.0.0 39 | 40 | dev_dependencies: 41 | integration_test: 42 | sdk: flutter 43 | flutter_test: 44 | sdk: flutter 45 | 46 | # The "flutter_lints" package below contains a set of recommended lints to 47 | # encourage good coding practices. The lint set provided by the package is 48 | # activated in the `analysis_options.yaml` file located at the root of your 49 | # package. See that file for information about deactivating specific lint 50 | # rules and activating additional ones. 51 | flutter_lints: ^6.0.0 52 | 53 | # For information on the generic Dart part of this file, see the 54 | # following page: https://dart.dev/tools/pub/pubspec 55 | 56 | # The following section is specific to Flutter packages. 57 | flutter: 58 | 59 | # The following line ensures that the Material Icons font is 60 | # included with your application, so that you can use the icons in 61 | # the material Icons class. 62 | uses-material-design: true 63 | 64 | # To add assets to your application, add an assets section, like this: 65 | # assets: 66 | # - images/a_dot_burr.jpeg 67 | # - images/a_dot_ham.jpeg 68 | 69 | # An image asset can refer to one or more resolution-specific "variants", see 70 | # https://flutter.dev/assets-and-images/#resolution-aware 71 | 72 | # For details regarding adding assets from package dependencies, see 73 | # https://flutter.dev/assets-and-images/#from-packages 74 | 75 | # To add custom fonts to your application, add a fonts section here, 76 | # in this "flutter" section. Each entry in this list should have a 77 | # "family" key with the font family name, and a "fonts" key with a 78 | # list giving the asset and other descriptors for the font. For 79 | # example: 80 | # fonts: 81 | # - family: Schyler 82 | # fonts: 83 | # - asset: fonts/Schyler-Regular.ttf 84 | # - asset: fonts/Schyler-Italic.ttf 85 | # style: italic 86 | # - family: Trajan Pro 87 | # fonts: 88 | # - asset: fonts/TrajanPro.ttf 89 | # - asset: fonts/TrajanPro_Bold.ttf 90 | # weight: 700 91 | # 92 | # For details regarding fonts from package dependencies, 93 | # see https://flutter.dev/custom-fonts/#from-packages 94 | -------------------------------------------------------------------------------- /lib/mode/dialog_report_mode.dart: -------------------------------------------------------------------------------- 1 | import 'package:catcher_2/model/platform_type.dart'; 2 | import 'package:catcher_2/model/report.dart'; 3 | import 'package:catcher_2/model/report_mode.dart'; 4 | import 'package:catcher_2/utils/catcher_2_utils.dart'; 5 | import 'package:flutter/cupertino.dart'; 6 | import 'package:flutter/material.dart'; 7 | 8 | class DialogReportMode extends ReportMode { 9 | @override 10 | void requestAction(Report report, BuildContext? context) { 11 | _showDialog(report, context); 12 | } 13 | 14 | Future _showDialog(Report report, BuildContext? context) async { 15 | await Future.delayed(Duration.zero); 16 | if (context != null) { 17 | if (!context.mounted) { 18 | return; 19 | } 20 | if (Catcher2Utils.isCupertinoAppAncestor(context)) { 21 | return showCupertinoDialog( 22 | context: context, 23 | builder: (context) => _buildCupertinoDialog(report, context), 24 | ); 25 | } else { 26 | return showDialog( 27 | context: context, 28 | barrierDismissible: false, 29 | builder: (context) => _buildMaterialDialog(report, context), 30 | ); 31 | } 32 | } 33 | } 34 | 35 | Widget _buildCupertinoDialog(Report report, BuildContext context) => 36 | // ignore: deprecated_member_use 37 | WillPopScope( 38 | onWillPop: () async { 39 | super.onActionRejected(report); 40 | return true; 41 | }, 42 | child: CupertinoAlertDialog( 43 | title: Text(localizationOptions.dialogReportModeTitle), 44 | content: Text(localizationOptions.dialogReportModeDescription), 45 | actions: [ 46 | CupertinoDialogAction( 47 | onPressed: () => _onAcceptReportClicked(context, report), 48 | child: Text(localizationOptions.dialogReportModeAccept), 49 | ), 50 | CupertinoDialogAction( 51 | onPressed: () => _onCancelReportClicked(context, report), 52 | child: Text(localizationOptions.dialogReportModeCancel), 53 | ), 54 | ], 55 | ), 56 | ); 57 | 58 | Widget _buildMaterialDialog(Report report, BuildContext context) => 59 | // ignore: deprecated_member_use 60 | WillPopScope( 61 | onWillPop: () async { 62 | super.onActionRejected(report); 63 | return true; 64 | }, 65 | child: AlertDialog( 66 | title: Text(localizationOptions.dialogReportModeTitle), 67 | content: Text(localizationOptions.dialogReportModeDescription), 68 | actions: [ 69 | TextButton( 70 | onPressed: () => _onAcceptReportClicked(context, report), 71 | child: Text(localizationOptions.dialogReportModeAccept), 72 | ), 73 | TextButton( 74 | onPressed: () => _onCancelReportClicked(context, report), 75 | child: Text(localizationOptions.dialogReportModeCancel), 76 | ), 77 | ], 78 | ), 79 | ); 80 | 81 | void _onAcceptReportClicked(BuildContext context, Report report) { 82 | super.onActionConfirmed(report); 83 | Navigator.pop(context); 84 | } 85 | 86 | void _onCancelReportClicked(BuildContext context, Report report) { 87 | super.onActionRejected(report); 88 | Navigator.pop(context); 89 | } 90 | 91 | @override 92 | bool isContextRequired() => true; 93 | 94 | @override 95 | List getSupportedPlatforms() => [ 96 | PlatformType.android, 97 | PlatformType.iOS, 98 | PlatformType.web, 99 | PlatformType.linux, 100 | PlatformType.macOS, 101 | PlatformType.windows, 102 | ]; 103 | } 104 | -------------------------------------------------------------------------------- /lib/core/catcher_2_screenshot_manager.dart: -------------------------------------------------------------------------------- 1 | import 'dart:async'; 2 | import 'dart:typed_data'; 3 | import 'dart:ui' as ui; 4 | 5 | import 'package:catcher_2/utils/catcher_2_logger.dart'; 6 | import 'package:cross_file/cross_file.dart'; 7 | import 'package:flutter/material.dart'; 8 | import 'package:flutter/rendering.dart'; 9 | import 'package:flutter/widgets.dart'; 10 | 11 | /// Manager which takes screenshot of configured widget. Screenshot will be 12 | /// saved to file which can be reused later. 13 | class Catcher2ScreenshotManager { 14 | Catcher2ScreenshotManager(this._logger) : _containerKey = GlobalKey(); 15 | final Catcher2Logger _logger; 16 | final GlobalKey _containerKey; 17 | String? _path; 18 | 19 | /// Unique global key used to create screenshot 20 | GlobalKey get containerKey => _containerKey; 21 | 22 | /// Create screenshot and save it in file. File will be created in directory 23 | /// specified in `Catcher2Options`. 24 | Future captureAndSave({ 25 | double? pixelRatio, 26 | Duration delay = const Duration(milliseconds: 20), 27 | }) async { 28 | try { 29 | final content = await _capture( 30 | pixelRatio: pixelRatio, 31 | delay: delay, 32 | ); 33 | 34 | if (content != null) { 35 | return saveFile(content); 36 | } 37 | } catch (exception) { 38 | _logger.warning('Failed to create screenshot file: $exception'); 39 | } 40 | return null; 41 | } 42 | 43 | Future saveFile(Uint8List fileContent) async { 44 | final name = 'catcher_2_${DateTime.now().microsecondsSinceEpoch}.png'; 45 | final path = (_path?.isEmpty ?? true) ? name : '$_path/$name'; 46 | final file = XFile.fromData(fileContent, path: path, name: name); 47 | if (_path != null && _path!.isNotEmpty) { 48 | await file.saveTo(path); 49 | } 50 | return file; 51 | } 52 | 53 | Future _capture({ 54 | double? pixelRatio, 55 | Duration delay = const Duration(milliseconds: 20), 56 | }) => 57 | //Delay is required. See Issue https://github.com/flutter/flutter/issues/22308 58 | Future.delayed(delay, () async { 59 | try { 60 | final image = await captureAsUiImage( 61 | delay: Duration.zero, 62 | pixelRatio: pixelRatio, 63 | ); 64 | final byteData = 65 | await image?.toByteData(format: ui.ImageByteFormat.png); 66 | image?.dispose(); 67 | return byteData?.buffer.asUint8List(); 68 | } catch (exception) { 69 | _logger.severe('Failed to capture screenshot: $exception'); 70 | } 71 | return null; 72 | }); 73 | 74 | Future captureAsUiImage({ 75 | double? pixelRatio, 76 | Duration delay = const Duration(milliseconds: 20), 77 | }) => 78 | //Delay is required. See Issue https://github.com/flutter/flutter/issues/22308 79 | Future.delayed(delay, () async { 80 | try { 81 | final findRenderObject = 82 | _containerKey.currentContext?.findRenderObject(); 83 | 84 | if (findRenderObject == null) { 85 | return null; 86 | } 87 | 88 | final boundary = findRenderObject as RenderRepaintBoundary; 89 | final context = _containerKey.currentContext; 90 | var pixelRatioValue = pixelRatio; 91 | if (pixelRatioValue == null && context != null && context.mounted) { 92 | pixelRatioValue = MediaQuery.of(context).devicePixelRatio; 93 | } 94 | return await boundary.toImage(pixelRatio: pixelRatioValue ?? 1); 95 | } catch (exception) { 96 | _logger.severe('Failed to capture screenshot: $exception'); 97 | } 98 | return null; 99 | }); 100 | 101 | /// Update screenshots directory path. 102 | // ignore: avoid_setters_without_getters 103 | set path(String path) { 104 | _path = path; 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /example/windows/runner/win32_window.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNNER_WIN32_WINDOW_H_ 2 | #define RUNNER_WIN32_WINDOW_H_ 3 | 4 | #include 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | // A class abstraction for a high DPI-aware Win32 Window. Intended to be 11 | // inherited from by classes that wish to specialize with custom 12 | // rendering and input handling 13 | class Win32Window { 14 | public: 15 | struct Point { 16 | unsigned int x; 17 | unsigned int y; 18 | Point(unsigned int x, unsigned int y) : x(x), y(y) {} 19 | }; 20 | 21 | struct Size { 22 | unsigned int width; 23 | unsigned int height; 24 | Size(unsigned int width, unsigned int height) 25 | : width(width), height(height) {} 26 | }; 27 | 28 | Win32Window(); 29 | virtual ~Win32Window(); 30 | 31 | // Creates a win32 window with |title| that is positioned and sized using 32 | // |origin| and |size|. New windows are created on the default monitor. Window 33 | // sizes are specified to the OS in physical pixels, hence to ensure a 34 | // consistent size this function will scale the inputted width and height as 35 | // as appropriate for the default monitor. The window is invisible until 36 | // |Show| is called. Returns true if the window was created successfully. 37 | bool Create(const std::wstring& title, const Point& origin, const Size& size); 38 | 39 | // Show the current window. Returns true if the window was successfully shown. 40 | bool Show(); 41 | 42 | // Release OS resources associated with window. 43 | void Destroy(); 44 | 45 | // Inserts |content| into the window tree. 46 | void SetChildContent(HWND content); 47 | 48 | // Returns the backing Window handle to enable clients to set icon and other 49 | // window properties. Returns nullptr if the window has been destroyed. 50 | HWND GetHandle(); 51 | 52 | // If true, closing this window will quit the application. 53 | void SetQuitOnClose(bool quit_on_close); 54 | 55 | // Return a RECT representing the bounds of the current client area. 56 | RECT GetClientArea(); 57 | 58 | protected: 59 | // Processes and route salient window messages for mouse handling, 60 | // size change and DPI. Delegates handling of these to member overloads that 61 | // inheriting classes can handle. 62 | virtual LRESULT MessageHandler(HWND window, 63 | UINT const message, 64 | WPARAM const wparam, 65 | LPARAM const lparam) noexcept; 66 | 67 | // Called when CreateAndShow is called, allowing subclass window-related 68 | // setup. Subclasses should return false if setup fails. 69 | virtual bool OnCreate(); 70 | 71 | // Called when Destroy is called. 72 | virtual void OnDestroy(); 73 | 74 | private: 75 | friend class WindowClassRegistrar; 76 | 77 | // OS callback called by message pump. Handles the WM_NCCREATE message which 78 | // is passed when the non-client area is being created and enables automatic 79 | // non-client DPI scaling so that the non-client area automatically 80 | // responds to changes in DPI. All other messages are handled by 81 | // MessageHandler. 82 | static LRESULT CALLBACK WndProc(HWND const window, 83 | UINT const message, 84 | WPARAM const wparam, 85 | LPARAM const lparam) noexcept; 86 | 87 | // Retrieves a class instance pointer for |window| 88 | static Win32Window* GetThisFromHandle(HWND const window) noexcept; 89 | 90 | // Update the window frame's theme to match the system theme. 91 | static void UpdateTheme(HWND const window); 92 | 93 | bool quit_on_close_ = false; 94 | 95 | // window handle for top level window. 96 | HWND window_handle_ = nullptr; 97 | 98 | // window handle for hosted content. 99 | HWND child_content_ = nullptr; 100 | }; 101 | 102 | #endif // RUNNER_WIN32_WINDOW_H_ 103 | -------------------------------------------------------------------------------- /example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /example/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 37 | 38 | 39 | 40 | 43 | 49 | 50 | 51 | 52 | 53 | 63 | 65 | 71 | 72 | 73 | 74 | 80 | 82 | 88 | 89 | 90 | 91 | 93 | 94 | 97 | 98 | 99 | -------------------------------------------------------------------------------- /lib/handlers/http_handler.dart: -------------------------------------------------------------------------------- 1 | import 'dart:collection'; 2 | 3 | import 'package:catcher_2/model/http_request_type.dart'; 4 | import 'package:catcher_2/model/platform_type.dart'; 5 | import 'package:catcher_2/model/report.dart'; 6 | import 'package:catcher_2/model/report_handler.dart'; 7 | import 'package:catcher_2/utils/catcher_2_utils.dart'; 8 | import 'package:dio/dio.dart'; 9 | import 'package:flutter/material.dart'; 10 | 11 | class HttpHandler extends ReportHandler { 12 | HttpHandler( 13 | this.requestType, 14 | this.endpointUri, { 15 | Map? headers, 16 | this.requestTimeout = const Duration(seconds: 5), 17 | this.responseTimeout = const Duration(seconds: 5), 18 | this.printLogs = false, 19 | this.enableDeviceParameters = true, 20 | this.enableApplicationParameters = true, 21 | this.enableStackTrace = true, 22 | this.enableCustomParameters = false, 23 | }) : headers = headers ?? {}; 24 | final Dio _dio = Dio(); 25 | 26 | final HttpRequestType requestType; 27 | final Uri endpointUri; 28 | final Map headers; 29 | final Duration requestTimeout; 30 | final Duration responseTimeout; 31 | final bool printLogs; 32 | final bool enableDeviceParameters; 33 | final bool enableApplicationParameters; 34 | final bool enableStackTrace; 35 | final bool enableCustomParameters; 36 | 37 | @override 38 | Future handle(Report report, BuildContext? context) async { 39 | if (report.platformType != PlatformType.web && 40 | !(await Catcher2Utils.isInternetConnectionAvailable())) { 41 | _printLog('No internet connection available'); 42 | return false; 43 | } 44 | 45 | if (requestType == HttpRequestType.post) { 46 | return _sendPost(report); 47 | } 48 | return true; 49 | } 50 | 51 | Future _sendPost(Report report) async { 52 | try { 53 | final json = report.toJson( 54 | enableDeviceParameters: enableDeviceParameters, 55 | enableApplicationParameters: enableApplicationParameters, 56 | enableStackTrace: enableStackTrace, 57 | enableCustomParameters: enableCustomParameters, 58 | ); 59 | final mutableHeaders = HashMap(); 60 | if (headers.isNotEmpty) { 61 | mutableHeaders.addAll(headers); 62 | } 63 | 64 | final options = Options( 65 | sendTimeout: requestTimeout, 66 | receiveTimeout: responseTimeout, 67 | headers: mutableHeaders, 68 | ); 69 | 70 | Response? response; 71 | _printLog('Calling: $endpointUri'); 72 | if (report.screenshot != null) { 73 | final formData = FormData.fromMap({ 74 | 'payload_json': json, 75 | 'file': MultipartFile.fromBytes( 76 | await report.screenshot!.readAsBytes(), 77 | filename: report.screenshot!.name, 78 | ), 79 | }); 80 | response = await _dio.post( 81 | endpointUri.toString(), 82 | data: formData, 83 | options: options, 84 | ); 85 | } else { 86 | response = await _dio.post( 87 | endpointUri.toString(), 88 | data: json, 89 | options: options, 90 | ); 91 | } 92 | _printLog( 93 | 'HttpHandler response status: ${response.statusCode!} ' 94 | 'body: ${response.data!}', 95 | ); 96 | return true; 97 | } catch (error, stackTrace) { 98 | _printLog('HttpHandler error: $error, stackTrace: $stackTrace'); 99 | return false; 100 | } 101 | } 102 | 103 | void _printLog(String log) { 104 | if (printLogs) { 105 | logger.info(log); 106 | } 107 | } 108 | 109 | @override 110 | String toString() => 'HttpHandler'; 111 | 112 | @override 113 | List getSupportedPlatforms() => [ 114 | PlatformType.android, 115 | PlatformType.iOS, 116 | PlatformType.web, 117 | PlatformType.linux, 118 | PlatformType.macOS, 119 | PlatformType.windows, 120 | ]; 121 | } 122 | -------------------------------------------------------------------------------- /example/windows/flutter/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This file controls Flutter-level build steps. It should not be edited. 2 | cmake_minimum_required(VERSION 3.14) 3 | 4 | set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") 5 | 6 | # Configuration provided via flutter tool. 7 | include(${EPHEMERAL_DIR}/generated_config.cmake) 8 | 9 | # TODO: Move the rest of this into files in ephemeral. See 10 | # https://github.com/flutter/flutter/issues/57146. 11 | set(WRAPPER_ROOT "${EPHEMERAL_DIR}/cpp_client_wrapper") 12 | 13 | # Set fallback configurations for older versions of the flutter tool. 14 | if (NOT DEFINED FLUTTER_TARGET_PLATFORM) 15 | set(FLUTTER_TARGET_PLATFORM "windows-x64") 16 | endif() 17 | 18 | # === Flutter Library === 19 | set(FLUTTER_LIBRARY "${EPHEMERAL_DIR}/flutter_windows.dll") 20 | 21 | # Published to parent scope for install step. 22 | set(FLUTTER_LIBRARY ${FLUTTER_LIBRARY} PARENT_SCOPE) 23 | set(FLUTTER_ICU_DATA_FILE "${EPHEMERAL_DIR}/icudtl.dat" PARENT_SCOPE) 24 | set(PROJECT_BUILD_DIR "${PROJECT_DIR}/build/" PARENT_SCOPE) 25 | set(AOT_LIBRARY "${PROJECT_DIR}/build/windows/app.so" PARENT_SCOPE) 26 | 27 | list(APPEND FLUTTER_LIBRARY_HEADERS 28 | "flutter_export.h" 29 | "flutter_windows.h" 30 | "flutter_messenger.h" 31 | "flutter_plugin_registrar.h" 32 | "flutter_texture_registrar.h" 33 | ) 34 | list(TRANSFORM FLUTTER_LIBRARY_HEADERS PREPEND "${EPHEMERAL_DIR}/") 35 | add_library(flutter INTERFACE) 36 | target_include_directories(flutter INTERFACE 37 | "${EPHEMERAL_DIR}" 38 | ) 39 | target_link_libraries(flutter INTERFACE "${FLUTTER_LIBRARY}.lib") 40 | add_dependencies(flutter flutter_assemble) 41 | 42 | # === Wrapper === 43 | list(APPEND CPP_WRAPPER_SOURCES_CORE 44 | "core_implementations.cc" 45 | "standard_codec.cc" 46 | ) 47 | list(TRANSFORM CPP_WRAPPER_SOURCES_CORE PREPEND "${WRAPPER_ROOT}/") 48 | list(APPEND CPP_WRAPPER_SOURCES_PLUGIN 49 | "plugin_registrar.cc" 50 | ) 51 | list(TRANSFORM CPP_WRAPPER_SOURCES_PLUGIN PREPEND "${WRAPPER_ROOT}/") 52 | list(APPEND CPP_WRAPPER_SOURCES_APP 53 | "flutter_engine.cc" 54 | "flutter_view_controller.cc" 55 | ) 56 | list(TRANSFORM CPP_WRAPPER_SOURCES_APP PREPEND "${WRAPPER_ROOT}/") 57 | 58 | # Wrapper sources needed for a plugin. 59 | add_library(flutter_wrapper_plugin STATIC 60 | ${CPP_WRAPPER_SOURCES_CORE} 61 | ${CPP_WRAPPER_SOURCES_PLUGIN} 62 | ) 63 | apply_standard_settings(flutter_wrapper_plugin) 64 | set_target_properties(flutter_wrapper_plugin PROPERTIES 65 | POSITION_INDEPENDENT_CODE ON) 66 | set_target_properties(flutter_wrapper_plugin PROPERTIES 67 | CXX_VISIBILITY_PRESET hidden) 68 | target_link_libraries(flutter_wrapper_plugin PUBLIC flutter) 69 | target_include_directories(flutter_wrapper_plugin PUBLIC 70 | "${WRAPPER_ROOT}/include" 71 | ) 72 | add_dependencies(flutter_wrapper_plugin flutter_assemble) 73 | 74 | # Wrapper sources needed for the runner. 75 | add_library(flutter_wrapper_app STATIC 76 | ${CPP_WRAPPER_SOURCES_CORE} 77 | ${CPP_WRAPPER_SOURCES_APP} 78 | ) 79 | apply_standard_settings(flutter_wrapper_app) 80 | target_link_libraries(flutter_wrapper_app PUBLIC flutter) 81 | target_include_directories(flutter_wrapper_app PUBLIC 82 | "${WRAPPER_ROOT}/include" 83 | ) 84 | add_dependencies(flutter_wrapper_app flutter_assemble) 85 | 86 | # === Flutter tool backend === 87 | # _phony_ is a non-existent file to force this command to run every time, 88 | # since currently there's no way to get a full input/output list from the 89 | # flutter tool. 90 | set(PHONY_OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/_phony_") 91 | set_source_files_properties("${PHONY_OUTPUT}" PROPERTIES SYMBOLIC TRUE) 92 | add_custom_command( 93 | OUTPUT ${FLUTTER_LIBRARY} ${FLUTTER_LIBRARY_HEADERS} 94 | ${CPP_WRAPPER_SOURCES_CORE} ${CPP_WRAPPER_SOURCES_PLUGIN} 95 | ${CPP_WRAPPER_SOURCES_APP} 96 | ${PHONY_OUTPUT} 97 | COMMAND ${CMAKE_COMMAND} -E env 98 | ${FLUTTER_TOOL_ENVIRONMENT} 99 | "${FLUTTER_ROOT}/packages/flutter_tools/bin/tool_backend.bat" 100 | ${FLUTTER_TARGET_PLATFORM} $ 101 | VERBATIM 102 | ) 103 | add_custom_target(flutter_assemble DEPENDS 104 | "${FLUTTER_LIBRARY}" 105 | ${FLUTTER_LIBRARY_HEADERS} 106 | ${CPP_WRAPPER_SOURCES_CORE} 107 | ${CPP_WRAPPER_SOURCES_PLUGIN} 108 | ${CPP_WRAPPER_SOURCES_APP} 109 | ) 110 | --------------------------------------------------------------------------------