SelectTags(tags: _form),
Divider(height: 1.0, indent: 0.0),
SelectTags(tags: _type),
Divider(height: 1.0, indent: 0.0),
import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_tags/flutter_tags.dart';
class SelectTags extends StatefulWidget {
final Map<String, String> tags;
const SelectTags({Key key, this.tags}) : super(key: key);
@override
_SelectTagsState createState() => _SelectTagsState(tags);
}
class _SelectTagsState extends State<SelectTags> {
final Map<String, String> tags;
_SelectTagsState(this.tags);
bool _symmetry = false;
bool _startDirection = false;
bool _horizontalScroll = true;
int _column = 0;
double _fontSize = 16;
ItemTags _buildTagItem(Map<String,String> tags, index) {
final item = tags.keys.elementAt(index);
return ItemTags(
key: Key(index.toString()),
index: index,
elevation: 0,
title: item,
active: false,
singleItem: true,
textColor: Colors.grey,
textActiveColor: Colors.white,
customData: item,
color: Colors.white,
activeColor: Colors.green[400],
textScaleFactor: utf8.encode(item.substring(0, 1)).length > 2 ? 0.8 : 1,
textStyle: TextStyle(fontSize: _fontSize),
pressEnabled: true,
onPressed: (_item) {
},
);
}
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(5),
child: Tags(
symmetry: _symmetry,
columns: _column,
horizontalScroll: _horizontalScroll,
verticalDirection: _startDirection
? VerticalDirection.up
: VerticalDirection.down,
textDirection:
_startDirection ? TextDirection.rtl : TextDirection.ltr,
heightHorizontalScroll: 35 * (_fontSize / 14),
itemCount: tags.entries.length,
alignment: WrapAlignment.start,
itemBuilder: (index) => _buildTagItem(tags, index)));
}
}