Add dartpad sample for AnimatedPadding (#71050)

This commit is contained in:
Juyeong Lee
2020-11-26 06:43:05 +09:00
committed by GitHub
parent 508c4b4d29
commit 9806865b49

View File

@@ -813,6 +813,47 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState<AnimatedContainer>
/// of [Curves.fastOutSlowIn].
/// {@animation 250 266 https://flutter.github.io/assets-for-api-docs/assets/widgets/animated_padding.mp4}
///
/// {@tool dartpad --template=stateful_widget_scaffold}
///
/// The following code implements the [AnimatedPadding] widget, using a [curve] of
/// [Curves.easeInOut].
///
/// ```dart
/// double padValue = 0.0;
/// _updatePadding(double value) {
/// setState(() {
/// padValue = value;
/// });
/// }
///
/// @override
/// Widget build(BuildContext context) {
/// return Column(
/// mainAxisAlignment: MainAxisAlignment.center,
/// children: [
/// AnimatedPadding(
/// padding: EdgeInsets.all(padValue),
/// duration: const Duration(seconds: 2),
/// curve: Curves.easeInOut,
/// child: Container(
/// width: MediaQuery.of(context).size.width,
/// height: MediaQuery.of(context).size.height / 5,
/// color: Colors.blue,
/// ),
/// ),
/// Text('Padding: $padValue'),
/// ElevatedButton(
/// child: Text('Change padding'),
/// onPressed: () {
/// _updatePadding(padValue == 0.0 ? 100.0 : 0.0);
/// }
/// ),
/// ],
/// );
/// }
/// ```
/// {@end-tool}
///
/// See also:
///
/// * [AnimatedContainer], which can transition more values at once.