Skip to content

Instantly share code, notes, and snippets.

@claireliu14
Created February 23, 2020 04:35
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save claireliu14/2c8873f53d0c9c827e60da4b6f8029a8 to your computer and use it in GitHub Desktop.
Save claireliu14/2c8873f53d0c9c827e60da4b6f8029a8 to your computer and use it in GitHub Desktop.
Horizontal ListWheelScrollView Sample
import 'package:flutter/material.dart';
const String kTitle = 'Horizontal ListWheelScrollView Sample';
void main() => runApp(new ListWheelScrollViewSample());
class ListWheelScrollViewSample extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new MaterialApp(
title: kTitle,
theme: new ThemeData(
primarySwatch: Colors.blue,
),
home: new HomePage(),
);
}
}
class HomePage extends StatelessWidget {
HomePage({
Key key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
final _style = Theme.of(context).textTheme.headline2;
return new Scaffold(
appBar: new AppBar(
title: new Text(kTitle),
),
body: new RotatedBox(
quarterTurns: 3,
child: new ListWheelScrollView(
itemExtent: 100,
physics: FixedExtentScrollPhysics(),
children: List<Widget>.generate(
20,
(index) => Container(
height: 100,
width: 100,
color: Colors.grey,
child: RotatedBox(
quarterTurns: 1,
child: Text('${index + 1}',
textAlign: TextAlign.center,
style: _style),
),
)),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment