{"id":575,"date":"2023-02-18T18:33:57","date_gmt":"2023-02-18T10:33:57","guid":{"rendered":"http:\/\/gjweb.top\/?p=575"},"modified":"2023-02-18T18:33:58","modified_gmt":"2023-02-18T10:33:58","slug":"10-appber-tabber-tabberview","status":"publish","type":"post","link":"https:\/\/gjweb.top\/?p=575","title":{"rendered":"10. APPBer &#038; TabBer &#038; TabBerView"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\" id=\"appber-\u81ea\u5b9a\u4e49\u9876\u90e8\u6309\u94ae\u56fe\u6807-\u989c\u8272\">AppBer \u81ea\u5b9a\u4e49\u9876\u90e8\u6309\u94ae\u56fe\u6807\u3001\u989c\u8272<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5c5e\u6027<\/th><th>\u4f5c\u7528<\/th><th>\u7c7b\u578b<\/th><\/tr><\/thead><tbody><tr><td>leading<\/td><td>\u6807\u9898\u524d\u9762\u663e\u793a\u7684\u4e00\u4e2a\u63a7\u4ef6,\u9996\u9875\u4e00\u822c\u653elogo,\u5176\u4ed6\u9875\u9762\u4e00\u822c\u653e\u8fd4\u56de\u6309\u94ae<\/td><td><\/td><\/tr><tr><td>title<\/td><td>\u6807\u9898<\/td><td><\/td><\/tr><tr><td>actions<\/td><td>\u901a\u5e38\u4f7f\u7528IconButton\u8868\u793a,\u53ef\u4ee5\u653e\u6309\u94ae\u7ec4<\/td><td><\/td><\/tr><tr><td>bottom<\/td><td>\u901a\u5e38\u653etabBar,\u6807\u9898\u4e0b\u9762\u7684\u4e00\u4e2a\u5bfc\u822a\u680f,\u7c7b\u4f3c\u4e8e\u5934\u6761\u7684tab<\/td><td><\/td><\/tr><tr><td>backgroundColor<\/td><td>\u5bfc\u822a\u80cc\u666f\u989c\u8272<\/td><td><\/td><\/tr><tr><td>iconTheme<\/td><td>\u56fe\u6807\u6837\u5f0f<\/td><td><\/td><\/tr><tr><td>centerTitle<\/td><td>\u6807\u9898\u662f\u5426\u5c45\u4e2d<\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>Scaffold(<br>    appBar:AppBar(<br> &nbsp;      backgroundColor:Colors.red,<br> &nbsp; &nbsp; &nbsp; &nbsp;title:Text(\"\u6807\u9898\"),<br> &nbsp; &nbsp; &nbsp; &nbsp;leading:IconButton( \/\/ \u5de6\u4fa7<br> &nbsp; &nbsp; &nbsp;      onPressed(){},<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;icon:Icon(Icons.flutter)<br> &nbsp; &nbsp; &nbsp;  ),<br> &nbsp; &nbsp; &nbsp; &nbsp;actions:&#91; \/\/ \u53f3\u4fa7<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IconButton(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      icon:const Icon(Icons.add),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onPressed:(){}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;IconButton(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      icon:const Icon(Icons.search),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;onPressed:(){}<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ),<br> &nbsp; &nbsp; &nbsp;  ]<br> &nbsp;  )<br>)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"tabber-\u7ec4\u4ef6-\u9876\u90e8\u7684\u5bfc\u822a\u680f\">TabBer \u7ec4\u4ef6 \u9876\u90e8\u7684\u5bfc\u822a\u680f<\/h2>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>\u5c5e\u6027<\/th><th>\u4f5c\u7528<\/th><th>\u7c7b\u578b<\/th><\/tr><\/thead><tbody><tr><td>tabs<\/td><td>\u663e\u793a\u6807\u7b7e\u5185\u5bb9,\u901a\u5e38\u60c5\u51b5\u4e0b\u662f Tab \u4e5f\u53ef\u4ee5\u662f Widget<\/td><td><\/td><\/tr><tr><td>controller<\/td><td>tabController\u5bf9\u8c61<\/td><td><\/td><\/tr><tr><td>isScrollable<\/td><td>\u662f\u5426\u53ef\u6eda\u52a8<\/td><td>bool<\/td><\/tr><tr><td>indicatorColor<\/td><td>\u6307\u793a\u5668\u989c\u8272<\/td><td>Color<\/td><\/tr><tr><td>indicatorWeight<\/td><td>\u6307\u793a\u5668\u9ad8\u5ea6<\/td><td>Color<\/td><\/tr><tr><td>indicatorPadding<\/td><td>\u5e95\u90e8\u6307\u793a\u5668\u7684Padding<\/td><td><\/td><\/tr><tr><td>indicator<\/td><td>\u6307\u793a\u5668 Decoration<\/td><td><\/td><\/tr><tr><td>indicatorSize<\/td><td>\u6307\u793a\u5668\u5927\u5c0f,TabbarIndicatorSize.label \u6587\u5b57\u7b49\u5bbd; .tab tab\u7b49\u5bbd<\/td><td><\/td><\/tr><tr><td>labelColor<\/td><td>\u9009\u4e2d\u7684 label \u989c\u8272<\/td><td>Color<\/td><\/tr><tr><td>labelStyle<\/td><td>\u9009\u4e2d\u7684 label \u7684\u6837\u5f0f<\/td><td><\/td><\/tr><tr><td>labelPadding<\/td><td>\u6bcf\u4e2a label \u7684\u5185\u8fb9\u8ddd<\/td><td><\/td><\/tr><tr><td>unselectedLabelColor<\/td><td>\u672a\u9009\u4e2d label \u7684\u989c\u8272<\/td><td>Color<\/td><\/tr><tr><td>unselectedLabelStyle<\/td><td>\u672a\u9009\u4e2d\u7684 label \u7684 style<\/td><td><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528\u9700\u8981\u6df7\u5165\u76f8\u5173\u7c7b<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>class xxx extends state&lt;xxx&gt; with SingleTickerProviderStateMixin{<br> &nbsp; &nbsp;\/\/ \u5b9a\u4e49 tabController<br> &nbsp; &nbsp;late TabController _xxx;<br> &nbsp; &nbsp;void initState(){<br> &nbsp; &nbsp; &nbsp; &nbsp;super.initState();<br> &nbsp; &nbsp; &nbsp; &nbsp;_xxx = TabController(length:8,vsync:this);<br> &nbsp; &nbsp; &nbsp; &nbsp;_xxx.addListener(){<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;if (_xxx.animation!.value == _xxx.index) {<br>                print(_xxx.index); \/\/\u83b7\u53d6\u70b9\u51fb\u6216\u6ed1\u52a8\u9875\u9762\u7684\u7d22\u5f15\u503c<br>            }<br> &nbsp; &nbsp; &nbsp;  }<br> &nbsp;  }<br> &nbsp; &nbsp;\/\/ \u914d\u7f6e Tabbar \u548c TabBerView<br> &nbsp; &nbsp;Widget build(BuildContext context){<br> &nbsp; &nbsp; &nbsp; &nbsp;return Scaffold(<br> &nbsp; &nbsp; &nbsp;      appBar:AppBar(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      title:const Text(\"Flutter App\"),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;bottom:tabBar(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      controller:_xxx,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;tabs:const &#91;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tab(child:Text(\"\u70ed\u95e8\")),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tab(child:Text(\"\u70ed\u95e81\")),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Tab(child:Text(\"\u70ed\u95e82\")),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ]<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;body:TabBarView(<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;      controller:_xxx,<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;children:&#91;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Text(\"\u70ed\u95e8\"),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Text(\"\u70ed\u95e81\"),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Text(\"\u70ed\u95e82\"),<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  ]<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  )<br> &nbsp; &nbsp; &nbsp;  )<br> &nbsp;  }<br>}<br>\u200b<br>\u200b<\/code><\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"\u6539\u53d8-appbar-\u7684\u9ad8\u5ea6\">\u6539\u53d8 appBar \u7684\u9ad8\u5ea6<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f7f\u7528 preferredSize \u53ef\u4ee5\u6539\u53d8 appBar \u7684\u9ad8\u5ea6<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>Scaffold(<br>    appBar:PreferredSize(<br> &nbsp;      preferredSize:Size\u3002fromHeight(50),<br> &nbsp; &nbsp; &nbsp; &nbsp;child:AppBar()<br> &nbsp;  )<br>)<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>AppBer \u81ea\u5b9a\u4e49\u9876\u90e8\u6309\u94ae\u56fe\u6807\u3001\u989c\u8272 \u5c5e\u6027 \u4f5c\u7528 \u7c7b\u578b leading \u6807\u9898\u524d\u9762\u663e\u793a\u7684\u4e00\u4e2a\u63a7\u4ef6,\u9996\u9875\u4e00\u822c\u653el [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[31],"tags":[],"class_list":["post-575","post","type-post","status-publish","format-standard","hentry","category-flutter"],"_links":{"self":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/575","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=575"}],"version-history":[{"count":2,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/575\/revisions"}],"predecessor-version":[{"id":577,"href":"https:\/\/gjweb.top\/index.php?rest_route=\/wp\/v2\/posts\/575\/revisions\/577"}],"wp:attachment":[{"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=575"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=575"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gjweb.top\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=575"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}