log_and_shake 1.0.2
log_and_shake: ^1.0.2 copied to clipboard
A developer-friendly package for logging and debugging via shake gestures. Great for debugging in dev builds.
log_and_shake #
log_and_shake
is a lightweight Flutter package that helps developers log messages and view them
via a shake gesture, ideal for debugging during development. It captures print()
statements,
uncaught exceptions, and shows them in a simple in-app log viewer — triggered by shaking the device.
very helpful to show logs while QC team do his work, to easy find the cause of error
.
log_and_shake
is a lightweight Flutter package that helps developers and QA teams capture and view logs in real time by simply shaking the device.
It automatically records print() or debugPrint()
statements and uncaught exceptions, and displays them in an in-app log viewer — making it ideal for debugging during development and QA testing.
🛠 Perfect for use by your QA or QC team to identify issues quickly and gather context before reporting bugs.
✨ Features #
- ✅ Shake the device to show a debug log viewer
- ✅ Captures
print()
and uncaught errors automatically - ✅ Simple integration with
LogAndShake.run(...)
- ✅ Shake gesture shows a bottom sheet confirmation before opening logs
- ✅ Logging is enabled only in dev mode by default
- ✅ Custom log support:
LogAndShake.log("message")
- ✅ Works with any state management or localization (GetX, EasyLocalization, Bloc, etc.)
🚀 Getting Started #
1. Add the package #
dependencies:
log_and_shake: ^1.0.0
2. 🛠️ Usage ✅ Basic Setup #
In your main.dart:
import 'package:log_and_shake/log_and_shake.dart';
void main() {
LogAndShake.run(
appInitializer: () async {
WidgetsFlutterBinding.ensureInitialized();
// Optional: await Firebase.initializeApp();
},
runAppWidget: const MyApp(),
);
}
3.✅ Add shake detection and start listening on your app #
Add the navigator key inside your MaterialApp (or GetMaterialApp, etc.):
final GlobalKey<NavigatorState> navigatorKey = GlobalKey<NavigatorState>();
class MyApp extends StatefulWidget {
const MyApp({super.key});
@override
State<MyApp> createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
super.initState();
LogAndShake.init(navigatorKey: navigatorKey);
}
@override
void dispose() {
LogAndShake.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
navigatorKey: navigatorKey,
home: const HomePage(),
);
}
}
📌 Developer Logs #
You can manually log messages anywhere:
LogAndShake.log("Fetching data..."); // auto detect log type
LogAndShake.logI("Fetching data..."); // log info
LogAndShake.logW("Fetching data..."); // log warning
LogAndShake.logE("Fetching data..."); // log error
🔐 Production Safety #
By default, log_and_shake only runs in dev or profile builds.
To disable explicitly:
LogAndShake.run(
...,
enableLogAndShake: false, // disables logs and shake even in dev
);
📦 Example #
A working example is available in the example/ folder. It demonstrates: Logging a message Triggering an exception Shake-to-open log screen
📮 Feedback & Contributions #
Found a bug or want a new feature? Find an issue, Pull requests are welcome!
📄 License #
MIT License © [MOHAMED EZZELDEEN]