如何强制TabBarView
采用最小高度以适应其内容?
import 'package:flutter/material.dart';
void main() {
runApp(TabBarDemo());
}
class TabBarDemo extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: DefaultTabController(
length: 3,
child: Scaffold(
appBar: AppBar(
bottom: TabBar(
tabs: [
Tab(icon: Icon(Icons.directions_car)),
Tab(icon: Icon(Icons.directions_transit)),
Tab(icon: Icon(Icons.directions_bike)),
],
),
title: Text('Tabs Demo'),
),
body: Column(children: [
Text('Header Widget'),
Expanded(
child: TabBarView(
children: [
Column(
mainAxisSize: MainAxisSize.min,
children: [
Icon(Icons.directions_car),
Icon(Icons.directions_car),
],
),
Icon(Icons.directions_transit),
Icon(Icons.directions_bike),
],
),
),
Text('Footer Widget')
]),
),
),
);
}
}
1条答案
按热度按时间1l5u6lss1#
使用BoxConstraint限制TabBarView的高度
输出: