Skip to content

Instantly share code, notes, and snippets.

@ponnamkarthik
Last active April 22, 2018 09:29
Show Gist options
  • Save ponnamkarthik/89cc837befcc0eccbb64219e9af28b79 to your computer and use it in GitHub Desktop.
Save ponnamkarthik/89cc837befcc0eccbb64219e9af28b79 to your computer and use it in GitHub Desktop.
flutter_native_log.dart
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:meta/meta.dart';
enum Log {
DEBUG,
WARNING,
ERROR
}
class FlutterNativeLog {
static const MethodChannel _channel =
const MethodChannel('flutter_native_log');
static Future<String> printLog({Log logType,@required String tag, @required String msg}) async {
String log = "debug";
if(logType == Log.WARNING) {
log = "warning";
} else if(logType == Log.ERROR) {
log = "error";
} else {
log = "debug";
}
final Map<String, dynamic> params = <String, dynamic> {
'tag': tag,
'msg': msg,
'logType': log
};
final String result = await _channel.invokeMethod('printLog', params);
return result;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment