write static method

void write(
  1. String data, {
  2. PenType type = PenType.info,
  3. bool log = false,
})

Implementation

static void write(final String data,
    {final PenType type = PenType.info, final bool log = false}) {
  late final AnsiPen color;
  if (type == PenType.info) {
    color = PenColors.blue;
  } else if (type == PenType.debug || type == PenType.warning) {
    color = PenColors.yellowBold;
  } else if (type == PenType.print) {
    color = PenColors.white;
  } else if (type == PenType.success) {
    color = PenColors.greenBold;
  } else if (type == PenType.error) {
    color = PenColors.redBold;
  } else {
    color = PenColors.whiteBold;
  }

  final String formattedData = "${DateTime.now().toIso8601String()} [${type.name.padRight(7)}] : $data\n";

  if (kDebugMode) {
    debugPrint(color(formattedData));
  }

  if (!kDebugMode || log || FlutterIgnite.logToFile) {
    saveLog(formattedData);
    // _writeLogFile(
    //     "${DateFormat('dd-MM-yyyy - kk:mm-ss').format(DateTime.now())} : $data");
  }
}