error_overlay 1.0.4 error_overlay: ^1.0.4 copied to clipboard
Error Overlay is a Flutter package that allows you to display real-time error logs as an overlay on all pages of your app.
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:error_overlay/error_overlay.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: ErrorOverlay(child: MyHomePage()),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: const Text("Error Overlay"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
TextButton(
child: const Text("Throw Exception"),
onPressed: () {
Random random = Random();
int randomInt = random.nextInt(100);
throw Exception("Test Exception $randomInt");
},
),
],
),
),
// This trailing comma makes auto-formatting nicer for build methods.
);
}
}