Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import 'package:flutter/material.dart';
- import 'package:firebase_crashlytics/firebase_crashlytics.dart';
- class CrashTest extends StatefulWidget {
- CrashTest({Key key}) : super(key: key);
- _CrashTestState createState() => _CrashTestState();
- }
- class _CrashTestState extends State<CrashTest> {
- @override
- Widget build(BuildContext context) {
- return Scaffold(
- appBar: AppBar(
- title: Text('Crash Test'),
- ),
- body: Center(
- child: Column(
- children: <Widget>[
- FlatButton(
- child: const Text('Key'),
- onPressed: () {
- Crashlytics.instance.setString('foo', 'bar');
- }),
- FlatButton(
- child: const Text('Log'),
- onPressed: () {
- Crashlytics.instance.log('baz');
- }),
- FlatButton(
- child: const Text('Crash'),
- onPressed: () {
- // Use Crashlytics to throw an error. Use this for
- // confirmation that errors are being correctly reported.
- Crashlytics.instance.crash();
- }),
- FlatButton(
- child: const Text('Throw Error'),
- onPressed: () {
- // Example of thrown error, it will be caught and sent to
- // Crashlytics.
- throw StateError('Uncaught error thrown by app.');
- }),
- FlatButton(
- child: const Text('Async out of bounds'),
- onPressed: () {
- // Example of an exception that does not get caught
- // by `FlutterError.onError` but is caught by the `onError` handler of
- // `runZoned`.
- Future<void>.delayed(Duration(seconds: 2), () {
- final List<int> list = <int>[];
- print(list[100]);
- });
- }),
- ],
- ),
- ),
- );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement