Skip to content

Instantly share code, notes, and snippets.

@Piinks
Last active August 2, 2019 17:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Piinks/955c449d2764e4591b574859c7a0395f to your computer and use it in GitHub Desktop.
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
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