-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimatedopacity.dart
44 lines (41 loc) · 1.18 KB
/
animatedopacity.dart
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import 'package:flutter/material.dart';
class AnimatedOpacityWidget extends StatefulWidget {
const AnimatedOpacityWidget({super.key});
@override
State<AnimatedOpacityWidget> createState() => _AnimatedOpacityWidgetState();
}
class _AnimatedOpacityWidgetState extends State<AnimatedOpacityWidget> {
double opacity = 1.0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("Widget Name"),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
AnimatedOpacity(
opacity: opacity,
duration: const Duration(seconds: 2),
child: const FlutterLogo(size: 59),
),
ElevatedButton(
onPressed: (() {
setState(() {
opacity = opacity == 0 ? 1.0 : 0.0;
});
}),
child: const Text(
'Fade Logo',
style: TextStyle(color: Colors.black),
),
)
],
),
),
);
}
}