패키지, 저장소 및 앱 카테고리 검색

input_quantity 표지
패키지 상세v2.6.0

input_quantity

수량 입력을 위한 위젯입니다. TextFormField로 구현되었습니다. 수동으로 입력하거나 버튼을 사용하여 값을 증가 또는 감소시킬 수 있습니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
3.9천
좋아요
76
Pub 점수
160

패키지 설치

flutter pub add input_quantity

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

수량 입력을 위한 플러터 위젯으로, 텍스트 필드와 증가 및 감소 버튼을 결합했습니다. 사용자는 수동으로 값을 입력하거나 제공된 버튼을 사용하여 조정할 수 있으며, 직관적이고 접근성 있는 숫자 입력을 보장합니다. TextFormField를 기반으로 하여 표준 텍스트 입력 동작을 지원하면서도 수량 선택의 사용성을 향상시킵니다. 쇼핑카트나 설정과 같은 숫자 입력이 필요한 양식에 적합합니다.

사용 사례

  • 전자상거래 제품 수량 선택
  • 숫자 값을 요구하는 폼 입력
  • 재고 관리 인터페이스
  • 사용자 선호 설정
  • 주문 입력 시스템

주요 기능

  • 내장된 증가/감소 버튼
  • 수동 텍스트 입력 지원
  • 사용자 정의 가능한 단계 크기
  • 다중 플랫폼에 걸친 반응형 디자인
  • TextFormField와의 통합

적합한 대상

  • 간단한 수량 입력
  • 모바일 및 웹 애플리케이션
  • 숫자 필드를 포함한 폼
  • 경량 스파인 박스를 찾는 개발자
  • 최소 설정이 필요한 앱

고려 사항

  • 기본 숫자 입력에 제한됨
  • 텍스트 입력 외에는 내장 검증 없음
  • 최소/최대 제약 조건을 수동으로 처리해야 합니다
  • 복소수 형식 지정에 적합하지 않습니다
  • 외부 스타일링에 따라 외관이 달라집니다

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

Input Quantity

Get it on Google Play

pub pkg likes Popularity Pub points Publisher Star on Github License: MIT

Flutter widget for quantity input. Increase or decrease the input value by pressing the button. It's built with text fields, so InputQty also supports manually typing quantities. Very flexible for large quantities. For example, if the user wants to enter the value 19243, it will be very difficult to only rely on buttons.

Set input limits so that input values automatically return to predefined maximum/minimum values.

Demo Preview

Features

  • Simple and easy to use
  • Customizable
  • Output: int, double, or num
  • Style options: classic, button on the left or button on the right
  • Tap once to update the value, longpress for update the value continuously, or type the value manually.
  • Add validator form, or use custom message builder

Installation

To use this package, add input_quantity as a dependency in your pubspec.yaml file.

dependencies:
  input_quantity: ^2.5.0

Then, run flutter pub get to install the package.

Usage

Basic Usage
import 'package:input_quantity/input_quantity.dart';

InputQty(
  maxVal: 100,
  initVal: 0,
  minVal: -100,
  steps: 10,
  onQtyChanged: (val) {
    print(val);
  },
)
Typing Manually

If you want to prevent typing manually, you can disable it from enableTyping.

InputQty(
  qtyFormProps: QtyFormProps(enableTyping: false),
  ...
)
Output Types

By default, the output will be as a num.

InputQty(
  onQtyChanged: (val) {
    print(val.runtimeType); // num
  },
)

To specify the output type as int:

InputQty.int(
  onQtyChanged: (val) {
    print(val.runtimeType); // int
  },
)

To specify the output type as double:

InputQty.double(
  onQtyChanged: (val) {
    print(val.runtimeType); // double
  },
)
Customizing Appearance and Behavior
Using QtyFormProps

You can customize the appearance and behavior of the input field using QtyFormProps.

InputQty(
  qtyFormProps: QtyFormProps(
    textAlign: TextAlign.center,
    style: TextStyle(fontWeight: FontWeight.bold),
    cursorColor: Colors.red,
    enableTyping: true,
  ),
)
Using QtyDecorationProps

You can customize the decoration of the input field using QtyDecorationProps.

InputQty(
  decoration: QtyDecorationProps(
    borderShape: BorderShapeBtn.circle,
    btnColor: Colors.blue,
    fillColor: Colors.grey[200],
    isBordered: true,+
  ),
)
Validation

You can use the validator property to validate the input value.

InputQty(
  validator: (value) {
    if (value == null) {
      return "Required field";
    } else if (value >= 200) {
      return "More than available quantity";
    }
    return null;
  },
)
Custom Messages

You can use the messageBuilder property to display custom messages based on the input value.

InputQty(
  messageBuilder: (minVal, maxVal, value) {
    if (value == null) return null;
    if (value < -20) {
      return Text(
        "Reach my limit",
        style: TextStyle(color: Colors.red),
        textAlign: TextAlign.center,
      );
    } else if (value > 20) {
      return Text(
        "Reach my limit",
        style: TextStyle(color: Colors.red),
        textAlign: TextAlign.center,
      );
    } else {
      return Text("Value : $value", textAlign: TextAlign.center);
    }
  },
)
Controlling Input Value Programmatically

You can use TextEditingController to control the input value programmatically.

final TextEditingController _controller = TextEditingController();

InputQty(
  qtyFormProps: QtyFormProps(
    controller: _controller,
  ),
)
Button Orientation

You can change the orientation of the buttons using ButtonOrientation.

InputQty(
  decoration: QtyDecorationProps(
    orientation: ButtonOrientation.horizontal,
  ),
)
Button Position

You can change the position of the buttons using QtyStyle.

InputQty(
  decoration: QtyDecorationProps(
    qtyStyle: QtyStyle.btnOnRight,
  ),
)

Examples

For more examples, check the example directory.

Image Preview

Contributons

To contribute to this project, please follow the guidelines in the CONTRIBUTING.md file.

Thank you to all contributors for their valuable contributions!

@pmatatias @tonypioneer @fixiply @sirfaman @daniel-pimenta-cc @5amfung

Additional Information

  • Want to thank me? You can buy me a coffee.

카테고리

의존성

의존성 목록 1 개

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.