import
'package:flutter/material.dart'
;
void
main() => runApp(
const
MyApp());
class
MyApp extends StatelessWidget {
const
MyApp({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
const
title =
'Gestures'
;
return
const
MaterialApp(
title: title,
home: MyHomePage(title: title),
);
}
}
class
MyHomePage extends StatelessWidget {
final String title;
const
MyHomePage({Key? key, required
this
.title}) : super(key: key);
@override
Widget build(BuildContext context) {
return
Scaffold(
appBar: AppBar(
title:
const
Text(
'GeeksForGeeks'
),
backgroundColor: Colors.green,
),
body:
const
Center(child: MyButton()),
);
}
}
class
MyButton extends StatelessWidget {
const
MyButton({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return
GestureDetector(
onTap: () {
const
snackBar =
SnackBar(content: Text(
" You just Tapped on the Button"
));
Scaffold.of(context).showSnackBar(snackBar);
},
child: Container(
padding:
const
EdgeInsets.all(12.0),
decoration: BoxDecoration(
color: Theme.of(context).buttonColor,
borderRadius: BorderRadius.circular(8.0),
),
child:
const
Text(
'Tap Button'
),
),
);
}
}