flutter_file_logger_android 0.0.1
flutter_file_logger_android: ^0.0.1 copied to clipboard
Android implementation of the flutter_file_logger plugin.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter_file_logger_android/flutter_file_logger_android.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _plugin = FlutterFileLoggerAndroid();
final _logTimes = 10000;
Duration? cost;
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(title: const Text('Plugin example app')),
body: SizedBox.expand(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
spacing: 16,
children: [
Text(
'$_logTimes times log cost: ${cost?.inMilliseconds ?? '-'} ms',
),
ElevatedButton(
onPressed: () {
_plugin.open();
},
child: Text('open'),
),
ElevatedButton(
onPressed: () {
_plugin.close();
},
child: Text('close'),
),
ElevatedButton(
onPressed: () {
final begin = DateTime.now();
for (var i = 0; i < _logTimes; i++) {
_plugin.log(
LogLevel.info,
'FlutterFileLoggerAndroid',
'Test log.',
);
}
final end = DateTime.now();
final cost = end.difference(begin);
setState(() {
this.cost = cost;
});
},
child: Text('log'),
),
ElevatedButton(
onPressed: () {
_plugin.flush();
},
child: Text('flush'),
),
],
),
),
),
);
}
}