【发布时间】:2021-08-08 13:03:30
【问题描述】:
假设我想创建一个应用栏,在开始和结束时有两个操作按钮,同时在中间有一个标签栏,都在同一行。这是我为使标签栏工作而编写的代码:
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(
highlightColor: Colors.transparent,
splashColor: Colors.transparent,
hoverColor: Colors.transparent,
),
title: 'Flutter Demo',
home: DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
leading: Icon(
Icons.menu,
),
automaticallyImplyLeading: false,
backgroundColor: Colors.white,
flexibleSpace: new Column(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TabBar(
indicatorColor: Colors.pink[100],
tabs: [
Tab(text: 'Dogs'),
Tab(text: 'Cats'),
],
labelColor: Colors.black,
), //tabbar
], //chilren on Tabbar
), //new Column
), //appbar
body: TabBarView(
children: [
Center(child: Text('DOGS')),
Center(child: Text('CATS')),
],
),
),
),
);
}
}
但是如何在不让标签栏覆盖它们的情况下添加两个操作按钮?可以使用网格吗?
【问题讨论】:
-
你能添加一个IMG吗?当前的 IMG 和预期是什么?
-
是的! IMG 已添加 :)
标签: flutter material-design tabbar appbar