Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Avoid `print` calls in production code while using flutter [duplicate]

My code keeps giving me a warning... Avoid print calls in production code.

How do I resolve it?

like image 273
dekerthesamurai Avatar asked Jun 03 '26 19:06

dekerthesamurai


2 Answers

Use debugPrint instead. Just know that debugPrint can only take a String? so you might need to use toString() or correctly format the data you are trying to display.

import 'package:flutter/foundation.dart';

debugPrint('This is a debugPrint');
like image 150
Guillaume Roux Avatar answered Jun 07 '26 23:06

Guillaume Roux


You can use print statement in only debug mode when app run in release mode print statement avoid. Write print using below both method:-

import 'package:flutter/foundation.dart';

if (kDebugMode) {
      print("Hello");
    }

OR

debugPrint('This is a debugPrint');
like image 24
Ravi Limbani Avatar answered Jun 07 '26 22:06

Ravi Limbani



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!