flutter 长日志打印 并只在debug模式才打印

669 阅读1分钟

image.png

import 'dart:developer';

/// todo:完整日志打印
logger(dynamic msg,{String? tag}){
  const bool inProduction = const bool.fromEnvironment("dart.vm.product");
  /// todo:只在debug模式执行
  if(!inProduction){
    log(msg,name: tag ?? 'flutter log');
  }
}