parent
050d008c5d
commit
3db402547a
@ -0,0 +1,24 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:power_logger/src/view/flutter_error_view.dart';
|
||||
|
||||
class FlutterErrorBuilder extends StatelessWidget {
|
||||
final FlutterErrorDetails details;
|
||||
FlutterErrorBuilder({Key? key, required this.details}) : super(key: key);
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ListTile(
|
||||
tileColor: Colors.red.withOpacity(0.4),
|
||||
title: Text(details.exception.toString()),
|
||||
trailing: Chip(label: Text('EXCEPTION'), backgroundColor: Colors.red),
|
||||
onTap: () {
|
||||
Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => FlutterErrorView(details: details),
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
class FlutterErrorView extends StatefulWidget {
|
||||
final FlutterErrorDetails details;
|
||||
FlutterErrorView({Key? key, required this.details}) : super(key: key);
|
||||
|
||||
@override
|
||||
_FlutterErrorViewState createState() => _FlutterErrorViewState();
|
||||
}
|
||||
|
||||
class _FlutterErrorViewState extends State<FlutterErrorView> {
|
||||
String get exceptionValue {
|
||||
if (widget.details.exception is AssertionError) {
|
||||
return (widget.details.exception as AssertionError).message.toString();
|
||||
} else
|
||||
return widget.details.exception.toString();
|
||||
}
|
||||
|
||||
List<String> get _stringList {
|
||||
return widget.details.stack.toString().split('\n');
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
title: Text('Flutter Error'),
|
||||
),
|
||||
body: Column(
|
||||
children: [
|
||||
Card(
|
||||
margin: EdgeInsets.all(10),
|
||||
child: Padding(
|
||||
padding: EdgeInsets.all(10),
|
||||
child: SelectableText(
|
||||
exceptionValue,
|
||||
style: TextStyle(
|
||||
fontSize: 22,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
Expanded(
|
||||
child: ListView.separated(
|
||||
padding: EdgeInsets.all(10),
|
||||
itemBuilder: (context, index) {
|
||||
return Text(_stringList[index]);
|
||||
},
|
||||
separatorBuilder: (context, index) => SizedBox(height: 5),
|
||||
itemCount: _stringList.length,
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in new issue