File size: 3,255 Bytes
b91a53d a8c1fba b91a53d | 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 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | // Copyright 2014 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import 'package:flutter/material.dart';
/// Flutter code sample for [AnimatedSlide].
void main() => runApp(const AnimatedSlideApp());
class AnimatedSlideApp extends StatelessWidget {
const AnimatedSlideApp({super.key});
@override
Widget build(BuildContext context) {
return const MaterialApp(home: AnimatedSlideExample());
}
}
class AnimatedSlideExample extends StatefulWidget {
const AnimatedSlideExample({super.key});
@override
State<AnimatedSlideExample> createState() => _AnimatedSlideExampleState();
}
class _AnimatedSlideExampleState extends State<AnimatedSlideExample> {
Offset offset = Offset.zero;
@override
Widget build(BuildContext context) {
final TextTheme textTheme = Theme.of(context).textTheme;
return Scaffold(
appBar: AppBar(title: const Text('AnimatedSlide Sample')),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
Expanded(
child: Row(
children: <Widget>[
Expanded(
child: Container(
alignment: Alignment.center,
padding: const EdgeInsets.all(50.0),
child: AnimatedSlide(
offset: offset,
duration: const Duration(milliseconds: 500),
curve: Curves.easeInOut,
child: const FlutterLogo(size: 50.0),
),
),
),
Column(
children: <Widget>[
Text('Y', style: textTheme.bodyMedium),
Expanded(
child: RotatedBox(
quarterTurns: 1,
child: Slider(
min: -5.0,
max: 5.0,
value: offset.dy,
onChanged: (double value) {
setState(() {
offset = Offset(offset.dx, value);
});
},
),
),
),
],
),
],
),
),
Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: <Widget>[
Text('X', style: textTheme.bodyMedium),
Expanded(
child: Slider(
min: -5.0,
max: 5.0,
value: offset.dx,
onChanged: (double value) {
setState(() {
offset = Offset(value, offset.dy);
});
},
),
),
const SizedBox(width: 48.0),
],
),
],
),
),
);
}
}
|