SHARE
TWEET

Untitled

a guest Sep 18th, 2019 70 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import 'package:flutter/material.dart';
  2. import 'package:firebase_crashlytics/firebase_crashlytics.dart';
  3. class CrashTest extends StatefulWidget {
  4.   CrashTest({Key key}) : super(key: key);
  5.  
  6.   _CrashTestState createState() => _CrashTestState();
  7. }
  8.  
  9. class _CrashTestState extends State<CrashTest> {
  10.   @override
  11.   Widget build(BuildContext context) {
  12.     return Scaffold(
  13.       appBar: AppBar(
  14.         title: Text('Crash Test'),
  15.       ),
  16.       body: Center(
  17.           child: Column(
  18.             children: <Widget>[
  19.               FlatButton(
  20.                   child: const Text('Key'),
  21.                   onPressed: () {
  22.                     Crashlytics.instance.setString('foo', 'bar');
  23.                   }),
  24.               FlatButton(
  25.                   child: const Text('Log'),
  26.                   onPressed: () {
  27.                     Crashlytics.instance.log('baz');
  28.                   }),
  29.               FlatButton(
  30.                   child: const Text('Crash'),
  31.                   onPressed: () {
  32.                     // Use Crashlytics to throw an error. Use this for
  33.                     // confirmation that errors are being correctly reported.
  34.                     Crashlytics.instance.crash();
  35.                   }),
  36.               FlatButton(
  37.                   child: const Text('Throw Error'),
  38.                   onPressed: () {
  39.                     // Example of thrown error, it will be caught and sent to
  40.                     // Crashlytics.
  41.                     throw StateError('Uncaught error thrown by app.');
  42.                   }),
  43.               FlatButton(
  44.                   child: const Text('Async out of bounds'),
  45.                   onPressed: () {
  46.                     // Example of an exception that does not get caught
  47.                     // by `FlutterError.onError` but is caught by the `onError` handler of
  48.                     // `runZoned`.
  49.                     Future<void>.delayed(Duration(seconds: 2), () {
  50.                       final List<int> list = <int>[];
  51.                       print(list[100]);
  52.                     });
  53.                   }),
  54.             ],
  55.           ),
  56.         ),
  57.     );
  58.   }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top