Last active
October 28, 2019 21:54
-
-
Save legalcodes/4207fea3975b2d329e81d9c9ba84d271 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_web/material.dart'; | |
import 'package:flutter_web_test/flutter_web_test.dart'; | |
import 'package:flutter_web_ui/ui.dart' as ui; | |
const owl_url = 'https://raw.githubusercontent.com/flutter/website/master/src/images/owl.jpg'; | |
class FadeInDemo extends StatefulWidget { | |
_FadeInDemoState createState() => _FadeInDemoState(); | |
} | |
class _FadeInDemoState extends State<FadeInDemo> { | |
double opacityLevel = 0.0; | |
@override | |
Widget build(BuildContext context) { | |
return Column(children: <Widget>[ | |
Image.network(owl_url), | |
MaterialButton( | |
child: Text( | |
'Show details', | |
style: TextStyle(color: Colors.blueAccent), | |
), | |
onPressed: () => setState(() { | |
opacityLevel = 1.0; | |
}), | |
), | |
AnimatedOpacity( | |
duration: Duration(seconds: 3), | |
opacity: opacityLevel, | |
child: Column( | |
children: <Widget>[ | |
Text('Type: Owl'), | |
Text('Age: 39'), | |
Text('Employment: None'), | |
], | |
), | |
) | |
]); | |
} | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
debugShowCheckedModeBanner: false, | |
home: Scaffold( | |
body: Center( | |
child: FadeInDemo(), | |
), | |
), | |
); | |
} | |
} | |
Future<void> main() async { | |
await ui.webOnlyInitializePlatform(); | |
runApp( | |
MyApp(), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment