flutter_native_crash_log 0.0.2 copy "flutter_native_crash_log: ^0.0.2" to clipboard
flutter_native_crash_log: ^0.0.2 copied to clipboard

A Flutter plugin to capture native Android crashes, log non-fatal errors, and share crash logs as JSON.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_native_crash_log/flutter_native_crash_log.dart';

void main() {
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: HomeScreen(),
    );
  }
}

class HomeScreen extends StatefulWidget {
  const HomeScreen({super.key});

  @override
  State<HomeScreen> createState() => _HomeScreenState();
}

class _HomeScreenState extends State<HomeScreen> {
  @override
  void initState() {
    super.initState();
    // Initialize the crash logger after the first frame
    WidgetsBinding.instance.addPostFrameCallback((_) {
      FlutterNativeCrashLog.initialize(context, trackLog: true);
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Native Crash Log Example'),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            const Text('Tap the button below to force a native crash.'),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                FlutterNativeCrashLog.forceCrash();
              },
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.red,
                foregroundColor: Colors.white,
              ),
              child: const Text('FORCE BASIC NATIVE CRASH'),
            ),
            const SizedBox(height: 20),
            ElevatedButton(
              onPressed: () {
                FlutterNativeCrashLog.logNonFatalError(
                    'This is a non-fatal error');
              },
              style: ElevatedButton.styleFrom(
                backgroundColor: Colors.orange,
                foregroundColor: Colors.white,
              ),
              child: const Text('LOG NON-FATAL ERROR'),
            ),
            const SizedBox(height: 20),
            const Text(
                'After crashing, re-open the app to see logs via the floating button.'),
          ],
        ),
      ),
    );
  }
}
0
likes
150
points
199
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin to capture native Android crashes, log non-fatal errors, and share crash logs as JSON.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, path_provider, plugin_platform_interface, share_plus

More

Packages that depend on flutter_native_crash_log

Packages that implement flutter_native_crash_log