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),
)
),
])
)
);
}
}