題記 —— 執劍天涯,從你的點滴積累開始,所及之處,必精益求精,便是折騰每一天。前端
重要消息java
EDU配套 教程github
flutter_tag_layout: ^0.0.3
複製代碼
github源碼在這裏 pub.flutter-io.cn最新版在這裏ide
在使用到文本標籤的地方佈局
import 'package:flutter_tag_layout/flutter_tag_layout.dart';
複製代碼
class TextTagPage extends StatefulWidget {
@override
_FirstPageState createState() => _FirstPageState();
}
class _FirstPageState extends State<TextTagPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("文本標籤"),
),
body: Container(
margin: EdgeInsets.all(30.0),
child: Row(children: [
TextTagWidget("文本標籤"),
TextTagWidget("測試"),
]),
));
}
}
複製代碼
運行效果以下: 測試
class TextWarpTagPage extends StatefulWidget {
@override
_FirstPageState createState() => _FirstPageState();
}
class _FirstPageState extends State<TextWarpTagPage> {
///文本標籤集合
List<String> tagList = ["文本標籤", "測試", "這是什麼", "早上好","吃飯", "再來一次"];
@override
Widget build(BuildContext context) {
List<Widget> itemWidgetList = [];
for (var i = 0; i < tagList.length; i++) {
var str = tagList[i];
itemWidgetList.add(TextTagWidget("$str"));
}
return Scaffold(
appBar: AppBar(
title: Text("文本標籤"),
),
body: Container(
margin: EdgeInsets.only(top: 30.0, left: 10, right: 10),
///流式佈局
child: Wrap(
spacing: 8.0,
runSpacing: 8.0,
///子標籤
children: itemWidgetList),
));
}
}
複製代碼
運行效果以下: ui
完畢 spa