-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathanimatedpadding.dart
44 lines (40 loc) · 1.36 KB
/
animatedpadding.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 AnimatedPaddingWidget extends StatefulWidget {
const AnimatedPaddingWidget({super.key});
@override
State<AnimatedPaddingWidget> createState() => _AnimatedPaddingWidgetState();
}
class _AnimatedPaddingWidgetState extends State<AnimatedPaddingWidget> {
double padValue = 0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("AnimatedPadding"),
),
body: Center(
child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [
ElevatedButton(
onPressed: () {
setState(() {
padValue = padValue == 0.0 ? 100.0 : 0.0;
});
},
style: ElevatedButton.styleFrom(backgroundColor: Colors.orange),
child: const Text('Change Padding'),
),
Text('Padding = $padValue'),
AnimatedPadding(
duration: const Duration(seconds: 2),
padding: EdgeInsets.all(padValue),
curve: Curves.easeInOut,
child: Container(
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.height / 4,
color: Colors.orangeAccent,
),
)
]),
));
}
}