devPrint function

void devPrint(
  1. Object? object, {
  2. int limit = 800,
})

Custom print function for development use only. Uses assert to ensure the print statement only executes in debug mode. In release mode, this function does nothing.

Implementation

void devPrint(Object? object, {int limit = 800}) {
  assert(() {
    if (limit <= 0) {
      print('Error: limit must be greater than 0');
      return false;
    }

    ansiColorDisabled = false;
    final pattern =
        RegExp('.{1,$limit}'); // Membagi teks ke dalam chunk sesuai limit

    pattern.allMatches(object.toString()).forEach((match) {
      final matchedString = match.group(0);
      if (matchedString != null) {
        print(matchedString);
      }
    });

    return true;
  }());
}