crashlytics_test.dart 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Automatic FlutterFlow imports
  2. import '/backend/schema/structs/index.dart';
  3. import '/flutter_flow/flutter_flow_theme.dart';
  4. import '/flutter_flow/flutter_flow_util.dart';
  5. import 'index.dart'; // Imports other custom actions
  6. import '/flutter_flow/custom_functions.dart'; // Imports custom functions
  7. import 'package:flutter/material.dart';
  8. // Begin custom action code
  9. // DO NOT REMOVE OR MODIFY THE CODE ABOVE!
  10. import 'index.dart'; // Imports other custom actions
  11. import 'package:firebase_crashlytics/firebase_crashlytics.dart';
  12. /// TIJDELIJK — testknop voor taak 66 (P1-60). Weghalen zodra Crashlytics
  13. /// bewezen is.
  14. ///
  15. /// modus laten staan op Unset -> echte crash (Google's eigen testmethode).
  16. /// 'melding' -> niet-fatale melding, app blijft gewoon draaien.
  17. /// 'flutter' -> Flutter-framework-fout, loopt via de
  18. /// FlutterError.onError-koppeling in main.dart.
  19. Future crashlyticsTest(String? modus) async {
  20. final keuze = (modus ?? '').trim().toLowerCase();
  21. if (keuze == 'melding') {
  22. // Verschijnt in Crashlytics onder "Non-fatals". Wordt meteen verstuurd,
  23. // geen herstart nodig.
  24. await FirebaseCrashlytics.instance.recordError(
  25. Exception('Uitgaanskrant testmelding (niet-fataal) ${DateTime.now()}'),
  26. StackTrace.current,
  27. reason: 'Handmatige test taak 66',
  28. fatal: false,
  29. );
  30. print('CRASHLYTICS: niet-fatale melding verstuurd');
  31. return;
  32. }
  33. if (keuze == 'flutter') {
  34. // Gaat door FlutterError.onError -> recordFlutterFatalError, precies het
  35. // pad dat main.dart instelt.
  36. FlutterError.reportError(FlutterErrorDetails(
  37. exception: Exception('Uitgaanskrant testfout via FlutterError'),
  38. stack: StackTrace.current,
  39. library: 'crashlyticsTest',
  40. context: ErrorDescription('Handmatige test taak 66'),
  41. ));
  42. print('CRASHLYTICS: FlutterError gerapporteerd');
  43. return;
  44. }
  45. // Standaard: echte crash. Het rapport gaat pas mee bij de VOLGENDE start
  46. // van de app, dus na het tikken de app opnieuw openen.
  47. print('CRASHLYTICS: nu crashen...');
  48. FirebaseCrashlytics.instance.crash();
  49. }
  50. // Set your action name, define your arguments and return parameter,
  51. // and then add the boilerplate code using the `</>` button on the right!