offline_logger 0.0.1 copy "offline_logger: ^0.0.1" to clipboard
offline_logger: ^0.0.1 copied to clipboard

Offline-first logging and crash reporting SDK for Flutter apps

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:offline_logger/offline_logger.dart'; // ✅ ADD THIS

void main() async {
  WidgetsFlutterBinding.ensureInitialized();

  await OfflineLogger.init(
    LoggerConfig(
      apiEndpoint: "https://api.example.com/logs",
      enableDebugLogs: true,
    ),
  );

  OfflineLogger.runAppWithLogger(() {
    runApp(const MyApp());
  });
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(title: 'Offline Logger Example', home: const HomePage());
  }
}

class HomePage extends StatelessWidget {
  const HomePage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text("Offline Logger Example")),
      body: Padding(
        padding: const EdgeInsets.all(16),
        child: Column(
          children: [
            ElevatedButton(
              onPressed: () {
                OfflineLogger.log("Button clicked");
              },
              child: const Text("Log Info"),
            ),
            ElevatedButton(
              onPressed: () {
                OfflineLogger.error("Sample error");
              },
              child: const Text("Log Error"),
            ),
            ElevatedButton(
              onPressed: () {
                try {
                  throw Exception("Test crash");
                } catch (e, stack) {
                  OfflineLogger.crash(e, stack);
                }
              },
              child: const Text("Trigger Crash"),
            ),
            ElevatedButton(
              onPressed: () async {
                await OfflineLogger.flush();
              },
              child: const Text("Flush Logs"),
            ),
          ],
        ),
      ),
    );
  }
}
2
likes
130
points
90
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Offline-first logging and crash reporting SDK for Flutter apps

Homepage
Repository (GitHub)

License

MIT (license)

Dependencies

archive, connectivity_plus, device_info_plus, dio, flutter, hive, hive_flutter, package_info_plus, uuid

More

Packages that depend on offline_logger