Created
March 13, 2021 09:05
-
-
Save pingbird/110f34192ed1e1a1b68cee2f715146e8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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