CallBack Function
import "package:flutter/material.dart";
void main()
{
runApp(const MyApp());
}
class MyApp extends StatelessWidget
{
const MyApp({super.key});
@override
Widget build(BuildContext context)
{
return MaterialApp(
title: "Hello",
debugShowCheckedModeBanner: false,
theme: ThemeData(
primarySwatch: Colors.red,
),
home: const FlutterApp(),
);
}
}
class FlutterApp extends StatefulWidget
{
const FlutterApp({super.key});
@override
State<StatefulWidget> createState()
{
return FlutterState();
}
}
class FlutterState extends State<FlutterApp>
{
callBack(){
print("Clicked button");
}
@override
Widget build(BuildContext context)
{
return Scaffold(
drawer: const Drawer(),
appBar: AppBar(
title: const Text("Hello Flutter CallBack",
style: TextStyle(fontWeight: FontWeight.bold),
),
centerTitle: true,
backgroundColor: Colors.grey,
),
body: Center(
child: ElevatedButton(
onPressed: callBack, /*To manage Data passing or Data flow throughout the flutter application, callBack
function is used.*/
style: ElevatedButton.styleFrom(
backgroundColor: Colors.blue,
fixedSize: const Size(350.0,50.0),
),
child: const Text("Clicked me!!",
style: TextStyle(fontWeight: FontWeight.bold, color: Colors.white, fontSize: 20.0),
),
),
),
);
}
}
Comments
Post a Comment