import 'package:flutter/material.dart';
void main() {
// Entry point of the Flutter app
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget serves as the
// root of the application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Builder Demo',
// Hides the debug banner
debugShowCheckedModeBanner: false,
// Sets the primary theme color
theme: ThemeData(
primarySwatch: Colors.green,
),
// Sets the home screen of the app
home: Home(),
);
}
}
class Home extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
// AppBar with title and styling
appBar: AppBar(
title: Text('GeeksforGeeks'),
backgroundColor: Colors.green,
foregroundColor: Colors.white,
),
// Body with a centered button
// inside a GestureDetector
body: Center(
child: GestureDetector(
onTap: () {
// Displays a SnackBar when tapped
ScaffoldMessenger.of(context).showSnackBar(
SnackBar(
content: Text('GeeksforGeeks'),
),
);
},
// Styling for the clickable box
child: Container(
margin: EdgeInsets.all(18),
height: 40,
decoration: BoxDecoration(
color: Colors.blueGrey,
borderRadius: BorderRadius.circular(8),
),
child: Center(
child: Text(
'CLICK ME',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.white,
),
),
),
),
),
),
);
}
}