Skip to content

Instantly share code, notes, and snippets.

@pingbird
Created March 13, 2021 09:05
Show Gist options
  • Save pingbird/110f34192ed1e1a1b68cee2f715146e8 to your computer and use it in GitHub Desktop.
Save pingbird/110f34192ed1e1a1b68cee2f715146e8 to your computer and use it in GitHub Desktop.
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(),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key}) : super(key: key);
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
Offset tapOffset;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Tap example"),
),
body: GestureDetector(
behavior: HitTestBehavior.opaque,
onTapDown: (details) {
setState(() {
print("offset: ${details.localPosition}");
tapOffset = details.localPosition;
});
},
child: Stack(
children: [
if (tapOffset != null) AnimatedPositioned.fromRect(
rect: Rect.fromCircle(
center: tapOffset,
radius: 40.0,
),
child: Container(color: Colors.teal),
duration: Duration(milliseconds: 400),
curve: Curves.easeOutCubic,
),
]
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment