Last active
July 11, 2022 04:47
-
-
Save FlutterZeroGit/82245658ca2fcb69f3b40888447432d6 to your computer and use it in GitHub Desktop.
AnimatedOpacity
This file contains 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 StatefulWidget { | |
@override | |
State<MyApp> createState() => _MyAppState(); | |
} | |
class _MyAppState extends State<MyApp> { | |
var opacityLevel = 0.1; | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: Scaffold( | |
appBar: AppBar( | |
title: Text('FlutterZero'), | |
), | |
body: Center( | |
child: GestureDetector( | |
child: AnimatedOpacity( | |
child: FlutterLogo(size: 150), | |
duration: Duration(seconds: 2), | |
opacity: opacityLevel, | |
), | |
onTap: () => setState( | |
() => opacityLevel = opacityLevel == 0.1 ? 1 : 0.1, | |
), | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment