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

flutter_tags 표지
패키지 상세v0.4.9+1

flutter_tags

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

30일 다운로드
789
좋아요
297
Pub 점수
40

패키지 설치

flutter pub add flutter_tags

패키지 개요

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

flutter_tags는 선택 가능하고 입력 기반의 태그를 생성하는 것을 간소화하는 Flutter 패키지로, 미리 정의된 태그와 사용자가 입력한 태그 모두에 대한 기능을 결합합니다. 태그 추가, 삭제 및 선택 기능을 내장한 직관적인 인터페이스를 제공하여 양식, 필터 또는 태깅 시스템에 이상적입니다. 동적 입력을 위해 TextField와 원활하게 통합되며, 스타일과 콜백을 통해 맞춤 설정이 가능합니다. 복잡한 설정 없이도 가볍고 쉽게 사용할 수 있도록 설계되었습니다.

사용 사례

  • 태그 선택이 있는 폼 입력
  • 사용자 생성 콘텐츠 태깅
  • 동적 태그를 사용한 인터페이스 필터링
  • 태그 기반 검색 기능
  • 실시간 피드백을 제공하는 인터랙티브 폼 요소

주요 기능

  • 선택 및 편집 가능한 태그
  • 내장된 TextField 통합
  • 사용자 정의 가능한 외관 및 동작
  • 간편한 태그 추가/제거 작업
  • 사전 정의 및 동적 태그 둘 다 지원

적합한 대상

  • 인터랙티브 폼을 개발하는 개발자
  • 태그 기반 필터링이 필요한 앱
  • 동적 태그 관리를 필요로 하는 UI 컴포넌트
  • 깔끔하고 미니멀한 태그 인터페이스에 집중하는 프로젝트
  • 태그가 많은 기능의 빠른 프로토타이핑

고려 사항

  • 제한된 플랫폼별 사용자 지정
  • 입력 태그에 내장된 검증이 없습니다
  • 복잡한 레이아웃을 위해 추가 스타일링이 필요할 수 있습니다
  • 매우 큰 태그 목록에 최적화되지 않음
  • 고급 기능을 위해 외부 종속성에 의존합니다

원본 README

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

flutter_tags

pub package Awesome Flutter Donate

Create beautiful tags quickly and easily.

Installing

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

dependencies:
  flutter_tags: "^0.4.9+1"

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(str);
          });
        },
      ),
      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

Donate

It takes time to carry on this project. If you found it useful or learned something from the source code please consider the idea of donating 5, 20, 50 € or whatever you can to support the project.

  • Donate

Issues

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

카테고리

소스 저장소

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