flutter_basics 0.0.4
flutter_basics: ^0.0.4 copied to clipboard
A lightweight Flutter package providing production-safe logging and in-app update utilities.
Here is a complete README.md for your package flutter_basics, including logging, file write, and upload logs. You can copy-paste this directly into your repository.
flutter_basics
A lightweight, production-safe utility package for Flutter applications providing structured logging, file-based log storage, and manual log upload support.
Designed and maintained by Mobigic Technology.
โจ Features
โ Production-safe logger (MobigicLogger)
๐งพ Supports log levels: trace, debug, info, warning, error, fatal
๐ซ Automatically disables console logs in release mode
๐พ Persistent file-based logging using LogService
โ๏ธ Manual log upload support
๐งน Clear logs after successful upload
๐ฑ Works with Flutter mobile apps (Android & iOS)
๐ Useful for crash tracking & in-app update debugging
๐ฆ Installation
Add the dependency in pubspec.yaml:
dependencies: flutter_basics: ^latest
Run:
flutter pub get
๐ฅ Import import 'package:flutter_basics/flutter_basics.dart';
๐ Usage Console Logging (MobigicLogger) MobigicLogger.debug("Debug message"); MobigicLogger.info("Info message"); MobigicLogger.warning("Warning message"); MobigicLogger.error("Error message");
Log objects easily:
MobigicLogger.info({ "status": "success", "version": 1, });
๐งฑ Log Levels MobigicLogger.trace("Trace log"); MobigicLogger.debug("Debug log"); MobigicLogger.info("Info log"); MobigicLogger.warning("Warning log"); MobigicLogger.error("Error log"); MobigicLogger.fatal( "Fatal error", error: error, stackTrace: stackTrace, );
๐ Production Safety
โ Logs print only in debug/profile
๐ซ No console logs in release builds
โ๏ธ No manual flags required
๐พ File-Based Logging (LogService)
LogService allows you to persist logs into a local file for later upload or debugging.
Write Logs to File await LogService.writeLog("Home screen opened"); await LogService.writeLog("User clicked submit button"); await LogService.writeLog("CRASH ERROR: API failed");
Each entry is saved with a timestamp:
2025-12-16T10:30:15.432 -> Home screen opened
โ๏ธ Upload Logs
Useful for Report Issue, Support, or Crash Recovery flows.
Future
try { await LogService.writeLog("Manual log upload initiated by user");
await MobigicHelper.uploadFile(file);
// Clear logs after successful upload
await file.writeAsString("");
MobigicLogger.info("Logs uploaded & cleared successfully");
} catch (e) { await LogService.writeLog("Upload failed: $e"); MobigicLogger.error("Log upload failed", error: e); } }
๐ Log File Location
This file can be:
Uploaded to backend
Shared with support teams
Attached to crash reports
โ Recommended Usage Purpose Tool Debug / Development logs MobigicLogger Production persistent logs LogService Manual issue reporting Log upload Crash diagnostics File logs ๐งฉ Configuration (Advanced)
You can customize logger behavior if needed:
var logger = Logger( printer: PrettyPrinter( methodCount: 2, lineLength: 120, colors: true, printEmojis: true, ), );
๐ค Contributing
Contributions are welcome!
Open issues for bugs or suggestions
Submit pull requests for improvements
๐ Acknowledgments
This package was originally created and enhanced by Tejeshvi Jagtap, focusing on real-world production debugging needs and scalable Flutter architecture.
๐ License
MIT License ยฉ Mobigic Technology