Skip to content

Instantly share code, notes, and snippets.

@FlutterZeroGit
Last active July 11, 2022 04:47
Show Gist options
  • Save FlutterZeroGit/82245658ca2fcb69f3b40888447432d6 to your computer and use it in GitHub Desktop.
Save FlutterZeroGit/82245658ca2fcb69f3b40888447432d6 to your computer and use it in GitHub Desktop.
AnimatedOpacity
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