Skip to content

Instantly share code, notes, and snippets.

@lbarqueira
Created February 8, 2021 10:58
Show Gist options
  • Save lbarqueira/e6de0c4d42b93fe3e41f584c9beab94e to your computer and use it in GitHub Desktop.
Save lbarqueira/e6de0c4d42b93fe3e41f584c9beab94e to your computer and use it in GitHub Desktop.
Handling gestures - https://flutter.dev/docs/development/ui/widgets-intro#handling-gestures - Most applications include some form of user interaction with the system. The first step in building an interactive application is to detect input gestures.
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Flutter Tutorial',
home: TutorialHome(),
),
);
}
class TutorialHome extends StatelessWidget {
@override
Widget build(BuildContext context) {
// Scaffold is a layout for the major Material Components.
return Scaffold(
// body is the majority of the screen.
body: MyButton(),
);
}
}
class MyButton extends StatelessWidget {
@override
Widget build(BuildContext context) {
return GestureDetector(
onTap: () {
print('MyButton was tapped!');
},
child: Center(
child: Container(
height: 36.0,
width: 100.0,
padding: const EdgeInsets.all(8.0),
margin: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Colors.lightGreen[500],
),
child: Center(
child: Text('Engage'),
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment