搜索插件、代码仓与 APP 分类

cupertino_height_picker 封面
插件详情v1.0.1

cupertino_height_picker

该包提供了一种无缝的 Cupertino 风格高度选择器,支持厘米(公制)和英尺/英寸(英制),为用户提供灵活性和精确性。

AndroidiOSWebmacOSWindowsLinux
近 30 天下载
189
喜欢数
8
Pub 分数
160

安装插件

flutter pub add cupertino_height_picker

插件介绍

基于插件公开信息、社区数据与项目使用情况整理的选型参考。

cupertino_height_picker 包为 Flutter 应用提供了一种类似原生的 Cupertino 风格身高选择器,支持公制(厘米)和英制(英尺/英寸)单位。它提供了一个流畅、交互性强的界面,无缝集成 iOS 设计规范,同时在 Android、Web、macOS、Windows 和 Linux 上也保持功能完整。该组件设计注重精度与易用性,让用户通过直观的滚动操作和清晰的视觉反馈来选择身高。该选择器高度可定制,适用于需要精确输入身高的表单。

适合场景

  • 用户资料设置
  • 健康与健身应用
  • 医疗数据收集
  • 基于年龄/身高形式输入
  • 应用中可自定义高度选择

主要特点

  • Cupertino 风格的 UI
  • 支持公制和英制单位
  • 跨平台兼容性
  • 平滑滚动界面
  • 可自定义外观
  • 精确高度选择

适合对象

  • 面向iOS的Flutter应用
  • 跨平台健康应用
  • 表单密集型应用
  • 设计一致的用户界面
  • 寻求原生样式的选择器的开发者

使用建议

  • 需要 Flutter 3.0 或更高版本
  • 对内部布局的自定义有限
  • 在非 Cupertino 主题下可能需要额外的样式
  • 未针对非常大的数据集进行优化
  • 依赖于平台特定的渲染行为

原始 README

以下为关联源码仓库的 README 原文快照,最新内容请访问源码仓库。

🎚️ Cupertino Height Picker Plugin

pub package

A seamless Cupertino-style height picker widget for Flutter. Supports height selection in both centimeters (metric) and feet/inches (imperial), providing versatility and precision for users.

Imperial System Metric System Automatic Unit Conversion
Imperial System Demo Metric System Demo Unit Conversion Demo

Features

  • Automatic Unit Conversion: Effortlessly switch between centimeters and feet/inches with automatic conversions.
  • Decimal Value Precision: Allows for precise height measurements.
  • Cupertino Styled Number Picker: A clean, intuitive interface consistent with iOS design.
  • Light & Dark Themes: Built-in support for both light and dark themes, adapting to the user's theme settings.

Getting started

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
  cupertino_height_picker: ^1.0.1
2. Install it

You can install packages from the command line:

$ flutter pub get
3. Import it

Now in your Dart code, you can use:

import 'package:cupertino_height_picker/cupertino_height_picker.dart';

Usage

Call the default showCupertinoHeightPicker Function which always returns the height in centimeters and has automatic unit conversion enabled by default

screenshot_1
await showCupertinoHeightPicker(
  context: context,
  onHeightChanged: (val) {
    setState(() {
      heightInCm = val;
      });
  },
);




Allow Height to be input only from metric system

screenshot_2
await showCupertinoHeightPicker(
  context: context,
  initialSelectedHeightUnit:HeightUnit.cm,
  canConvertUnit: false,
  onHeightChanged: (val) {
    print(val);
  },
);




Start from a custom initial height and don't show the separation text between feet and inches

screenshot_3
await showCupertinoHeightPicker(
  context: context,
  initialHeight: 185.5,
  showSeparationText: false,
  onHeightChanged: (val) {
    print(val);
  },
);




Customize the Look of the Modal to your liking!

screenshot_4
await showCupertinoHeightPicker(
  context: context,
  modalHeight: 300,
  maxModalWidth: 500,
  modalBackgroundColor: CupertinoColors.systemTeal,
  barrierColor: CupertinoColors.systemGreen.withOpacity(0.5),
  onHeightChanged: (val) {
    print(val);
  },
);


Parameters
  • context: (Required) The BuildContext object, which is necessary for rendering the height picker within the widget tree.

  • onHeightChanged: (Required) A callback function that handles height changes when the user scrolls through different height values. The selected height is returned in centimeters.

  • initialHeight: Sets the default initial height value when the picker is opened. The default is 150.0 cm.

  • initialSelectedHeightUnit: Specifies the default height unit (either HeightUnit.inches or HeightUnit.cm) when the picker is opened. The default is HeightUnit.inches.

  • canConvertUnit: A boolean that determines whether the height picker allows conversion between imperial and metric systems. The default is true.

  • showSeparationText: A boolean that controls whether a separation text (e.g., 'feet') or a decimal point text is shown between the two sliders. The default is true.

  • modalHeight: Specifies the height of the modal sheet. The default value is 216.0.

  • maxModalWidth: Defines the maximum width of the modal sheet. This is useful for responsiveness on larger screens, such as tablets and laptops. If null, the modal takes up the full device width. The default is null.

  • modalBackgroundColor: Defines the background color of the modal sheet. The default is null.

  • barrierColor: Sets the color of the screen behind the modal, allowing for a custom background color with reduced opacity. The default is kCupertinoModalBarrierColor.

Maintainers

Aditya R

所属分类

源码仓库

使用此插件的项目

暂无相关数据。