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

PlatformiOS

iOS implementation of the flutter_file_logger plugin.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:flutter_file_logger_ios/flutter_file_logger_ios.dart';

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

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

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _plugin = FlutterFileLoggerIOS();

  final _logTimes = 10000;

  Duration? cost;

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('Plugin example app')),
        body: SizedBox.expand(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            crossAxisAlignment: CrossAxisAlignment.center,
            spacing: 16,
            children: [
              Text(
                '$_logTimes times log cost: ${cost?.inMilliseconds ?? '-'} ms',
              ),
              ElevatedButton(
                onPressed: () {
                  _plugin.open();
                },
                child: Text('open'),
              ),
              ElevatedButton(
                onPressed: () {
                  _plugin.close();
                },
                child: Text('close'),
              ),
              ElevatedButton(
                onPressed: () {
                  final begin = DateTime.now();
                  for (var i = 0; i < _logTimes; i++) {
                    _plugin.log(
                      LogLevel.info,
                      'FlutterFileLoggerIOS',
                      'Test log.',
                    );
                  }
                  final end = DateTime.now();
                  final cost = end.difference(begin);
                  setState(() {
                    this.cost = cost;
                  });
                },
                child: Text('log'),
              ),
              ElevatedButton(
                onPressed: () {
                  _plugin.flush();
                },
                child: Text('flush'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}