Last active
August 2, 2019 17:34
-
-
Save Piinks/955c449d2764e4591b574859c7a0395f to your computer and use it in GitHub Desktop.
Scroll Animation on timed delay - Experiment for https://github.com/flutter/flutter/pull/37267
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'package:flutter/rendering.dart'; | |
void main() => runApp(new MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return new MaterialApp( | |
home: new MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
final _controller = new ScrollController(); | |
Future<void> awaitAndAnimate() async { | |
print('Waiting'); | |
await Future.delayed(Duration(seconds: 5)); | |
_controller.animateTo(10000.0, duration: const Duration(seconds: 2), curve: Curves.elasticOut); | |
} | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar(title: Text('Timed Scroll Animation')), | |
body: ListView.builder( | |
padding: EdgeInsets.all(8.0), | |
controller: _controller, | |
itemExtent: 60.0, | |
itemBuilder: (BuildContext context, int index) { | |
return FlatButton( | |
child: Text('Item No. $index'), | |
// After pressing the button, tap and hold, do not drag. | |
onPressed: awaitAndAnimate, | |
); | |
}, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment