-
Notifications
You must be signed in to change notification settings - Fork 3
/
animated_padding.dart
33 lines (28 loc) · 981 Bytes
/
animated_padding.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
import 'package:flutter/material.dart';
class AnimatedPaddingScreen extends StatefulWidget {
@override
_AnimatedPaddingState createState() => _AnimatedPaddingState();
}
class _AnimatedPaddingState extends State<AnimatedPaddingScreen> {
var _changed = false;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('AnimatedPadding Example'),
),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.play_arrow), onPressed: _changePadding),
body: AnimatedPadding(
padding: _padding(),
duration: Duration(milliseconds: 1200),
curve: Curves.fastOutSlowIn,
child: Container(color: Colors.purple),
),
);
}
EdgeInsetsGeometry _padding() => _changed
? EdgeInsets.symmetric(vertical: 30, horizontal: 80)
: EdgeInsets.symmetric(vertical: 100, horizontal: 50);
void _changePadding() => setState(() => _changed = !_changed);
}