flutter添加自定义appbar顶部tabar

		import 'package:flutter/material.dart';
		
		class ProductInfor extends StatefulWidget {
		  Map arguments;
		  ProductInfor({Key key,this.arguments}): super(key:key);
		
		  @override
		  _ProductInforState createState() => _ProductInforState(arguments:this.arguments);
		}
		
		class _ProductInforState extends State {
		  Map arguments;
		  _ProductInforState({this.arguments});
		  @override
		  Widget build(BuildContext context) {
		    return Scaffold(
		      appBar: AppBar(
		        title: Text("商品详情"),
		        centerTitle: true,
		//        backgroundColor: Colors.red,
		          leading: IconButton(
		              icon:Icon(Icons.menu),
		              onPressed: (){
		                print(1);
		              },
		          ),
		          actions: [
		            IconButton(
		              icon:Icon(Icons.menu),
		              onPressed: (){
		                print(1);
		              },
		            ),
		          ],
		      ),
		      body: Text('商品详情页面${arguments["id"]}'),
		    );
		  }
		}
import 'package:flutter/material.dart';
import './FromPage.dart';
class CatePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return DefaultTabController(
      length: 4,
      child: Scaffold(
        appBar: AppBar(
          title: Row(
            children: [
              Expanded(
                child: TabBar(
                  tabs: [
                    Tab(text: '211221'),
                    Tab(text: '2333'),
                    Tab(text: '2333'),
                    Tab(text: '2333'),
                  ],
                ),
              )
            ],
          ),
//          bottom:
        ),
        body: TabBarView(
            children: [
              ListView(
                children: [
                  ListTile(
                    title: Text('23123'),
                  )
                ],
              ),
              ListView(
                children: [
                  ListTile(
                    title: Text('23123'),
                  )
                ],
              ),
              ListView(
                children: [
                  ListTile(
                    title: Text('23123'),
                  )
                ],
              ),
              ListView(
                children: [
                  ListTile(
                    title: Text('23123'),
                  )
                ],
              )
            ],

        ),
      ),
    );
  }
}

你可能感兴趣的:(笔记)