vesti_logger 1.0.0+2 vesti_logger: ^1.0.0+2 copied to clipboard
Projeto de Logger da Vesti para ajudar no troubleshotting
example/lib/main.dart
import 'dart:math';
import 'package:flutter/material.dart';
import 'package:vesti_logger/logger/vlog.dart';
import 'package:vesti_logger/logger/vlogger.dart';
import 'package:vesti_logger/logger/vlogger_list.dart';
import 'package:vesti_logger/logger/vlogger_store.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Vesti Logger',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Vesti Logger'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, this.title}) : super(key: key);
final String? title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
late VLogger _logger;
late VLoggerStore _store;
_MyHomePageState() {
_store = VLoggerStore();
_store.toggle();
_logger = VLogger(_store);
}
@override
Widget build(BuildContext context) {
return Stack(
children: [
Scaffold(
appBar: AppBar(
title: Text(widget.title ?? ""),
),
body: Padding(
padding: EdgeInsets.all(32),
child: Column(
crossAxisAlignment: CrossAxisAlignment.stretch,
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
RippleCard(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 16, horizontal: 8),
child: Row(
children: [
VLogType.Debug.icon,
SizedBox(width: 8),
Text("Add Random Debug Example"),
],
),
),
onTap: () {
_logger.debug(
title: "Debug Log", message: getRandomString(1000));
}),
RippleCard(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 16, horizontal: 8),
child: Row(
children: [
VLogType.Error.icon,
SizedBox(width: 8),
Text("Add Random Error Example"),
],
),
),
onTap: () {
_logger.error(
title: "Error Log", message: getRandomString(1000));
}),
RippleCard(
child: Padding(
padding: const EdgeInsets.symmetric(
vertical: 16, horizontal: 8),
child: Row(
children: [
VLogType.Info.icon,
SizedBox(width: 8),
Text("Add Random Info Example"),
],
),
),
onTap: () {
_logger.info(
title: "Info Log", message: getRandomString(1000));
})
],
),
)),
VLogger.logButton(_store)
],
);
}
}
const _chars = 'AaBbCcDdEeFfGgHhIiJjKkLlMmNnOoPpQqRrSsTtUuVvWwXxYyZz1234567890';
Random _rnd = Random();
String getRandomString(int length) => String.fromCharCodes(Iterable.generate(
length, (_) => _chars.codeUnitAt(_rnd.nextInt(_chars.length))));