Print Console Log Message Using Flutter Android App

admin_img Posted By Bajarangi soft , Posted On 05-11-2020

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.

Print Console Log Message Using Flutter Android App

Console Log Message
Complete Code For Console Log Message In Flutter
main.dart

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      home: MyHomePage(),
    );
  }
}
class MyHomePage extends StatefulWidget {
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> with SingleTickerProviderStateMixin {
  void showConsoleUsingPrint() {
    print('Console Message Using Print');
  }

  void showConsoleUsingDebugPrint() {
    debugPrint('Console Message Using Debug Print');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
        backgroundColor: Colors.black,
        appBar: AppBar(
          backgroundColor: Colors.pink[600],
          title: Text('Console Log Message'),
        ),
        body: Center(
            child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  Container(
                      margin: const EdgeInsets.fromLTRB(10, 10, 10, 10),
                      child:
                      RaisedButton(
                        onPressed: () => showConsoleUsingPrint(),
                        child: Text(' Console Message using Print '),
                        textColor: Colors.white,
                        color: Colors.green,
                        padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
                      )
                  ),
                  Container(
                      margin: const EdgeInsets.fromLTRB(10, 10, 10, 10),
                      child:
                      RaisedButton(
                        onPressed: () => showConsoleUsingDebugPrint(),
                        child: Text(' Console Message using Debug Print '),
                        textColor: Colors.white,
                        color: Colors.green,
                        padding: EdgeInsets.fromLTRB(12, 12, 12, 12),
                      )
                  ),
                ])
        )
    );
  }
}

 

Related Post