Last active
April 22, 2018 09:29
-
-
Save ponnamkarthik/89cc837befcc0eccbb64219e9af28b79 to your computer and use it in GitHub Desktop.
flutter_native_log.dart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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