我想知道如何构建一个搜索栏,将用户搜索输入过滤到组或选项卡中,例如人员、标签、地点,就像 instagram 一样,但我不知道该怎么做!
问问题
3624 次
1 回答
1
它可能看起来像这样:
import 'package:flutter/material.dart';
main() => runApp(
MaterialApp(
// home: Scaffold(
// body: Container(child: SearchButton()),
home: Body()),
);
class Body extends StatefulWidget {
@override
_BodyState createState() => _BodyState();
}
class _BodyState extends State<Body> {
TextEditingController controller;
@override
void initState() {
super.initState();
controller = TextEditingController();
}
@override
Widget build(BuildContext context) {
return DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
leading: Icon(Icons.search),
title: TextField(
controller: controller,
cursorColor: Colors.white,
style: TextStyle(color: Colors.white),
),
bottom: TabBar(tabs: [
Tab(icon: Icon(Icons.people)),
Tab(icon: Icon(Icons.location_city)),
]),
),
body: TabBarView(children: [Container(), Container()]),
),
);
}
}
于 2019-04-17T20:48:28.203 回答