flutter_logan_pro 1.0.3
flutter_logan_pro: ^1.0.3 copied to clipboard
A high-performance, robust log plugin for Flutter based on Meituan Logan. Fixed truncation and decryption issues.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_logan_pro/flutter_logan_pro.dart';
import 'config.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
}
Future<void> _initLogan() async {
try {
await FlutterLoganPro.init(
secretKey: LoganConfig.secretKey,
secretIV: LoganConfig.secretIV,
maxFileLen: 1024 * 1024 * 10,
isDebug: true,
maxReversedDate: 7);
_showSnackBar('Logan init success');
} on PlatformException catch (e) {
_showSnackBar('Logan init failed: ${e.message}');
}
}
Future<void> _addLog() async {
try {
await FlutterLoganPro.log(
'This is a test log from flutter_logan plugin 啊打算离开打瞌睡打瞌睡打卡打卡时打卡打卡双卡双待卡开始打卡打卡扩大开始打卡打卡上课打卡打卡深刻的卡上的卡都是卡点卡上打卡上看到卡是短裤 at ${DateTime.now()}');
_showSnackBar('Log added');
} on PlatformException catch (e) {
_showSnackBar('Add log failed: ${e.message}');
}
}
void _showSnackBar(String message) {
if (!mounted) return;
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text(message)));
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Flutter Logan Plugin'),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
ElevatedButton(
onPressed: _initLogan,
child: const Text('Init Logan'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: _addLog,
child: const Text('Add Log'),
),
const SizedBox(height: 20),
ElevatedButton(
onPressed: () async {
var res = await FlutterLoganPro.send(
url: LoganConfig.uploadUrl, appId: "123131");
debugPrint('Send status: ${res.statusCode}');
},
child: const Text('Send Log'),
),
],
),
),
),
);
}
}