SafePrint constructor

SafePrint(
  1. Object? object, {
  2. String? prefix = "",
  3. String? suffix = "",
  4. bool? highlight = false,
  5. bool enableRelease = false,
})

Implementation

SafePrint(Object? object, {String? prefix = "", String? suffix = "", bool? highlight = false, bool enableRelease = false}) {

  if (kDebugMode || enableRelease) {

    if(highlight ?? false) {print("#####################################");}

    String printableValue = "--SafePrint: $prefix--\n$object\n--$suffix--";

    if(printableValue.length <= 800) {
      print(printableValue);
    } else {
      print("#### BIG PRINT ####");
      final pattern = RegExp('.{1,800}');
      pattern.allMatches(printableValue).forEach((match) => print(match.group(0)));
      print("#### BIG PRINT END ####");
    }

    if(highlight ?? false) {print("#####################################");}

  } else {
    print("Private Print");
  }

}