Skip to content

Instantly share code, notes, and snippets.

@mihalycsaba
Created April 27, 2021 11:08
Show Gist options
  • Save mihalycsaba/2cd7d19d74b2287c9fc4ced4e344943b to your computer and use it in GitHub Desktop.
Save mihalycsaba/2cd7d19d74b2287c9fc4ced4e344943b to your computer and use it in GitHub Desktop.
tap
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: InkWell(
onTap: _incrementCounter,
child: Container(
color: Colors.deepPurple,
constraints: BoxConstraints.expand(),
alignment: Alignment.center,
child: Text('Count: $_counter',
style: TextStyle(color: Colors.amber)),
)),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment