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

choice 표지
패키지 상세v2.3.2

choice

smart_select 및 chips_choice의 후속 제품으로, 단일 또는 다중 선택을 지원하는 인라인 또는 프롬프트 형식의 선택 위젯을 만들기 위한 더 깔끔하고 유연하며 조합 가능한 API를 제공합니다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
1.4만
좋아요
143
Pub 점수
150

패키지 설치

flutter pub add choice

패키지 개요

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

Choice는 단일 및 다중 선택을 지원하는 유연하고 조합 가능한 선택 위젯을 구축하기 위해 설계된 현대적인 Flutter 패키지입니다. 기존의 smart_select 및 chips_choice와 같은 패키지를 대체하며, 인라인 또는 프롬프트 형식의 선택 인터페이스를 위한 더 깔끔한 API를 제공합니다. 폼, 필터, 태그 기반 입력에 적합하며, 플랫폼 간 일관성 있고 사용자 정의 가능한 경험을 제공합니다. 개발자 편의성과 UI의 유연성을 중시하여 다양한 앱 디자인에 쉽게 통합할 수 있습니다.

사용 사례

  • 선택 가능한 옵션을 가진 폼 입력
  • 필터링 인터페이스
  • 태그 기반의 데이터 입력
  • 동적 선택 목록
  • 사용자 선호도 선택
  • 다중 선택 드롭다운

주요 기능

  • 깔끔하고 직관적인 API
  • 단일 및 다중 선택 지원
  • 유연한 인라인 또는 프롬프트 레이아웃
  • 높은 사용자 정의 가능한 외관
  • 크로스 플랫폼 호환성
  • 조합 가능한 위젯 디자인

적합한 대상

  • 기존 선택 패키지의 현대적 대안을 찾는 개발자
  • 동적이고 재사용 가능한 선택 컴포넌트가 필요한 앱
  • UI 일관성과 유지보수를 강조하는 프로젝트
  • 개발자 경험과 코드 명확성을 우선시하는 팀
  • 복잡한 필터링 또는 태그 요구 사항이 있는 응용 프로그램

고려 사항

  • Flutter 위젯 조합에 대한 이해가 필요합니다
  • 복잡한 테마를 위해 추가 스타일링이 필요할 수 있습니다
  • 성숙한 패키지에 비해 문서가 제한적
  • 자주 사용자 선택이 필요한 앱에 적합
  • 상호작용이 없는 간단한 정적 선택에는 적합하지 않음

원본 README

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

Pub Version GitHub GitHub GitHub

The successor to smart_select and chips_choice with cleaner, more flexible, and composable API for creating inline or prompted choice widgets with single or multiple selection.

Features

  • Cleaner, flexible, and composable API
  • Inline or prompted choice widget
  • Single or multiple choice widget
  • Searchable choice items with highlighted result
  • Specifies whether the choice selection needs to be confirmed
  • Use any type of choice data and load it easily, either synchronously or asynchronously
  • Build your own choice item that fits your needs
  • Groupable choice items that can be sorted
  • Supports leading and trailing choice items, as well as divider choice items
  • Use a predefined wrapped, scrollable, virtualized choice list, or build one that fits your needs
  • Use a predefined popup dialog, bottom sheet, new page prompt, or build one that fits your needs
  • Use a predefined modal header, footer, and separator, or build one that fits your needs
  • Use a predefined group list, group item, and group header, or build one that fits your needs
  • Use a predefined anchor widget or build one that fits your needs
  • Use a predefined widget on loading, on error, and placeholder when empty, or build one that fits your needs

Usage

For a complete usage, please see the example.

To read more about classes and other references used by choice, see the API Reference.

Single Choice

Preview

There are a few constructors to create a single selection choice widget:

By default, the choice controller maintains the selection state within a List. Any constructors other than those dedicated to single choice will have a List<T> for their value and onChanged prop. If we want to use a single value of T, we can use ChoiceSingle.value adapter to fill the value prop and ChoiceSingle.onChanged adapter to fill the onChanged prop.

Here is an example of how to use the ChoiceSingle.value and ChoiceSingle.onChanged adapters

import 'package:flutter/material.dart';
import 'package:choice/choice.dart';

class InlineScrollableX extends StatefulWidget {
  const InlineScrollableX({super.key});

  @override
  State<InlineScrollableX> createState() => _InlineScrollableXState();
}

class _InlineScrollableXState extends State<InlineScrollableX> {
  List<String> choices = [
    'News',
    'Entertainment',
    'Politics',
    'Automotive',
    'Sports',
    'Education',
    'Fashion',
    'Travel',
    'Food',
    'Tech',
    'Science',
    'Arts'
  ];

  String? selectedValue;

  void setSelectedValue(String? value) {
    setState(() => selectedValue = value);
  }

  @override
  Widget build(BuildContext context) {
    return Column(
      children: [
        Choice<String>.inline(
          clearable: true,
          value: ChoiceSingle.value(selectedValue),
          onChanged: ChoiceSingle.onChanged(setSelectedValue),
          itemCount: choices.length,
          itemBuilder: (state, i) {
            return ChoiceChip(
              selected: state.selected(choices[i]),
              onSelected: state.onSelected(choices[i]),
              label: Text(choices[i]),
            );
          },
          listBuilder: ChoiceList.createScrollable(
            spacing: 10,
            padding: const EdgeInsets.symmetric(
              horizontal: 20,
              vertical: 25,
            ),
          ),
        ),
        InlineChoice<String>.single(
          clearable: true,
          value: selectedValue,
          onChanged: setSelectedValue,
          itemCount: choices.length,
          itemBuilder: (state, i) {
            return ChoiceChip(
              selected: state.selected(choices[i]),
              onSelected: state.onSelected(choices[i]),
              label: Text(choices[i]),
            );
          },
          listBuilder: ChoiceList.createWrapped(
            spacing: 10,
            runSpacing: 10,
            padding: const EdgeInsets.symmetric(
              horizontal: 20,
              vertical: 25,
            ),
          ),
        ),
      ],
    );
  }
}
Multiple Choice

Preview

There are a few constructors to create an multiple selection choice widget:

Inline Choice

Preview

There are a few constructors to create an inline choice widget:

Prompted Choice

Preview

There are a few constructors to create a prompted choice widget:

Choice Data

Preview

Choice Item

Preview

With Future Builder

Preview

With Form and FormField

Preview

TODO

  • :white_check_mark: Grouped choice items
  • :x: Sortable choice items better to do this outside
  • :black_square_button: Add scroll wheel list
  • :black_square_button: Add dropdown choice widget
  • :black_square_button: Add chainable choice widget

Sponsoring

Buy Me A Coffee Ko-Fi

If this package or any other package I created is helping you, please consider to sponsor me so that I can take time to read the issues, fix bugs, merge pull requests and add features to these packages.

카테고리

소스 저장소

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