make running snippet more convenient

This commit is contained in:
lollipopkit
2023-01-27 23:06:47 +08:00
parent b6ab4b7fde
commit 913ce312de
11 changed files with 148 additions and 63 deletions

View File

@@ -0,0 +1,36 @@
import 'package:flutter/material.dart';
Widget buildPicker(List<Widget> items, Function(int idx) onSelected) {
return SizedBox(
height: 111,
child: Stack(
children: [
Positioned(
top: 36,
bottom: 36,
left: 0,
right: 0,
child: Container(
height: 37,
decoration: const BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(7)),
color: Colors.black12,
),
),
),
ListWheelScrollView.useDelegate(
itemExtent: 37,
diameterRatio: 1.2,
controller: FixedExtentScrollController(initialItem: 0),
onSelectedItemChanged: (idx) => onSelected(idx),
physics: const FixedExtentScrollPhysics(),
childDelegate: ListWheelChildBuilderDelegate(
builder: (context, index) => Center(
child: items[index],
),
childCount: items.length),
)
],
),
);
}