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

패키지 상세v1.1.0

flutter_tags_x

선택 가능하고 입력 가능한 태그(TextField)를 만드는 것이 결코 쉬운 일이 아니었다.

AndroidiOSWebmacOSWindowsLinux
30일 다운로드
2천
좋아요
30
Pub 점수
140

패키지 설치

flutter pub add flutter_tags_x

패키지 개요

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

flutter_tags_x는 선택 가능하고 입력 기반의 태그 생성을 간소화하는 Flutter 패키지로, 사전 정의된 태그와 사용자 입력 태그 모두를 위한 기능을 통합합니다. 텍스트 필드, 선택 상태 및 동적 태그 관리를 내장한 직관적인 인터페이스를 제공합니다. 양식, 필터 또는 태깅 시스템에 적합하며, 여러 플랫폼에서 깔끔하고 사용자 정의 가능한 칩 컴포넌트를 통해 사용자 상호작용을 향상시킵니다.

사용 사례

  • 태그 제안이 있는 폼 입력
  • 사용자 생성 콘텐츠 태깅
  • 선택 가능한 칩을 갖춘 필터 인터페이스
  • 태그 기반 검색 기능
  • 양식 내 동적 태그 관리
  • 선택 가능한 항목의 인터랙티브 목록

주요 기능

  • 사전 정의된 태그와 입력 태그 모두를 지원합니다
  • 새 태그를 추가하기 위한 내장 텍스트 필드
  • 선택 및 제거 가능한 태그 칩
  • 사용자 지정 스타일 및 테마
  • 크로스 플랫폼 호환성
  • 기존 폼 로직과의 간편한 통합

적합한 대상

  • 인터랙티브 폼을 개발하는 개발자
  • 태그 기반 필터링이 필요한 앱
  • 사용자 생성 콘텐츠를 포함한 프로젝트
  • 깔끔한 태그 UI를 원하는 디자이너
  • 다중 플랫폼을 대상으로 하는 팀

고려 사항

  • 태그 중복 처리에 주의가 필요합니다
  • 입력 제약 조건에 맞는 사용자 지정 검증이 필요할 수 있습니다
  • 스타일 맞춤화는 Flutter 위젯에 대한 이해가 필요합니다
  • 큰 태그 목록을 사용할 경우 성능 최적화가 필요할 수 있습니다
  • 기본 입력 검사 외에 제한된 내장 검증

원본 README

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

flutter_tags_x

Create beautiful tags quickly and easily.

Forked from Dn-a/flutter_tags (Not supported)

Installing

Add this to your package's pubspec.yaml file: Null-safety version MORE INFO

dependencies:
  flutter_tags_x: ... # last version

DEMO

Simple usage


import 'package:flutter_tags/flutter_tags.dart';
.
.
.
List _items;
double _fontSize = 14;

@override
void initState(){
    super.initState();
    // if you store data on a local database (sqflite), then you could do something like this
    Model().getItems().then((items){
            _items = items;
        });
}

@override
Widget build(BuildContext context) {
    return Tags(
      key:_tagStateKey,
      textField: TagsTextField(
        textStyle: TextStyle(fontSize: _fontSize),
        constraintSuggestion: true, suggestions: [],
        //width: double.infinity, padding: EdgeInsets.symmetric(horizontal: 10),
        onSubmitted: (String str) {
          // Add item to the data source.
          setState(() {             
             // required             
            _items.add(Item(
                title: str,
                active: true,
                index: 1,                
              ));
          });
        },
      ),
      itemCount: _items.length, // required
      itemBuilder: (int index){          
            final item = _items[index];
    
            return ItemTags(
                  // Each ItemTags must contain a Key. Keys allow Flutter to
                  // uniquely identify widgets.
                  key: Key(index.toString()),
                  index: index, // required
                  title: item.title,
                  active: item.active,
                  customData: item.customData,
                  textStyle: TextStyle( fontSize: _fontSize, ),
                  combine: ItemTagsCombine.withTextBefore,
                  image: ItemTagsImage(
                    image: AssetImage("img.jpg") // OR NetworkImage("https://...image.png")
                  ), // OR null,
                  icon: ItemTagsIcon(
                    icon: Icons.add,
                  ), // OR null,
                  removeButton: ItemTagsRemoveButton(
                    onRemoved: (){
                        // Remove the item from the data source.
                        setState(() {
                            // required
                            _items.removeAt(index);
                        });
                        //required
                        return true;
                    },
                  ), // OR null,
                  onPressed: (item) => print(item),
                  onLongPressed: (item) => print(item),
            );
    
      },
    );    
}

final GlobalKey<TagsState> _tagStateKey = GlobalKey<TagsState>();
// Allows you to get a list of all the ItemTags
_getAllItem(){
    List<Item> lst = _tagStateKey.currentState?.getAllItem;
    if(lst!=null)
        lst.where((a) => a.active==true).forEach( ( a) => print(a.title));        
}

Wrapped widget example

You are free to wrap ItemTags () inside another widget

Tags(  
      itemCount: items.length, 
      itemBuilder: (int index){ 
          return Tooltip(
          message: item.title,
          child:ItemTags(
            title:item.title,
          )
          );
      },
    );    
Tags() parameters
PropName Description default value
columns Possibility to set number of columns when necessary null
itemCount Tag number to display required
symmetry Ability to view and scroll tags horizontally false
horizontalScroll Offset drawer width 0.4
heightHorizontalScroll height for HorizontalScroll to set to display tags correctly 60
spacing Horizontal space between the tags 6
runSpacing Vertical space between the tags 14
alignment Horizontal WrapAlignment WrapAlignment.center
runAlignment Vertical WrapAlignment WrapAlignment.center
direction Direction of the ItemTags Axis.horizontal
verticalDirection Iterate Item from the lower to the upper direction or vice versa VerticalDirection.down
textDirection Text direction of the ItemTags TextDirection.ltr
itemBuilder tag generator
textField add textField TagsTextFiled()
ItemTags() parameters
  • index - required
  • title - required
  • textScaleFactor - custom textScaleFactor
  • active - bool value (default true)
  • pressEnabled - active onPress tag ( default true)
  • customData - Possibility to add any custom value in customData field, you can retrieve this later. A good example: store an id from Firestore document.
  • textStyle - textStyle()
  • alignment - MainAxisAlignment ( default MainAxisAlignment.center)
  • combine - * ability to combine text, icons, images in different ways ( default ItemTagsCombine.imageOrIconOrText)*
  • icon - ItemTagsIcon()
  • image - ItemTagsImage()
  • removeButton - ItemTagsRemoveButton()
  • borderRadius - BorderRadius
  • border - custom border-side
  • padding - default EdgeInsets.symmetric(horizontal: 7, vertical: 5)
  • elevation - default 5
  • singleItem - default false
  • textOverflow - default TextOverflow.fade
  • textColor - default Colors.black
  • textActiveColor - default Colors.white
  • color - default Colors.white
  • activeColor - default Colors.blueGrey
  • highlightColor -
  • splashColor -
  • colorShowDuplicate - default Colors.red
  • onPressed - callback
  • onLongPressed - callback
  • onRemoved - callback

Issues

If you encounter problems, open an issue. Pull request are also welcome.

카테고리

소스 저장소

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

아직 데이터가 없습니다.