Files
FlutterUnit/lib/views/widgets/StatefulWidget/PageView/node2_direction.dart
2020-05-03 23:05:53 +08:00

64 lines
1.6 KiB
Dart

import 'package:flutter/material.dart';
/// create by 张风捷特烈 on 2020-03-28
/// contact me by email 1981462002@qq.com
/// 说明:
// {
// "widgetId": 165,
// "name": 'PageView滑动方向',
// "priority": 2,
// "subtitle":
// "【scrollDirection】 : 滑动方向 【Axis】\n"
// "【reverse】 : 是否反向 【bool】",
// }
class DirectionPageView extends StatelessWidget {
final data = <Color>[
Colors.orange[50],
Colors.orange[100],
Colors.orange[200],
Colors.orange[300],
Colors.orange[400],
Colors.orange[500],
Colors.orange[600],
Colors.orange[700],
Colors.orange[800],
Colors.orange[900],
];
@override
Widget build(BuildContext context) {
return Container(
height: 150,
child: PageView(
scrollDirection: Axis.vertical,
reverse: true,
onPageChanged: (position) {
print(position);
},
children: data
.map((color) =>
Container(
alignment: Alignment.center,
width: 90,
color: color,
child: Text(
colorString(color),
style: TextStyle(color: Colors.white,
fontSize: 24, shadows: [
Shadow(
color: Colors.black,
offset: Offset(.5, .5),
blurRadius: 2)
]),
),
))
.toList(),
),
);
}
String colorString(Color color) =>
"#${color.value.toRadixString(16).padLeft(8, '0').toUpperCase()}";
}