Print Console Log Message in Flutter App for Testing Purpose Example

In flutter mobile app development language there are 2 inbuilt application debugging methods available print() and debugPrint(). They both are used to print debug messages on Terminal command prompt window.  The print() method can only print a Object String to Terminal window whenever developer wants to. The debugPrint() method can print large size strings outputs on debugging terminal window. debugPrint() method can also print Flutter tools log on Terminal screen. So in this tutorial we would Print Console Log Message in Flutter App for Testing Purpose in Android iOS Example Tutorial.

Contents in this project Print Console Log Message in Flutter App for Testing Purpose in Android iOS Example Tutorial:

1. Import material.dart package in your project’s main.dart file.

2. Create void main runApp() method and here we would call our main MyApp() class.

3. Create our main Root View class named as MyApp extends StatelessWidget.

4. Create a function named as showConsoleUsingPrint(). Inside the function we would call the print() method and prints a sample log message on terminal screen.

5. Create a function named as showConsoleUsingDebugPrint(). Inside this function we would call the debugPrint() method and prints a text string message on terminal window.

6. Create 2 Raised Buttons in Widget build area of MyApp class. We would call each above function on Button onPress event.

7. Complete source code for main.dart file:

Screenshots:

Print Console Log Message in Flutter App for Testing Purpose Example

Leave a Reply

Your email address will not be published.