ทำเว็บนี้ขึ้นมา เอาไว้บันทึกโค้ด การแก้ไขปัญหาต่างๆ ที่พบเจอ

Flutter ปิด Log บน Production

หน้าหลัก » Dev » Flutter ปิด Log บน Production

จะต้องใช้ debugPrint() แทน print() ในการดู log

นำโค้ดนี้ไปไว้ main() บรรทัดแรก ไฟล์ main.dart

debugPrint = (String message, {int wrapWidth}) {};

ตัวอย่าง

void main() {
  debugPrint = (String? message, {int? wrapWidth}) {};

  runApp(const MyApp());
}

หากไม่ต้องการปิด log ก็ comment โค้ดนั้นไว้

x91 Channel นักพัฒนา