我试图DefaultTabController在一些小部件中间使用。所以我TabBar不能进入AppBar并且必须关闭一些小部件。所以我的问题是当我使用TabBarView它时崩溃......
所以这是一个 Flutter 示例的例子,但没有找到如何在没有Scaffold.
final List<Tab> myTabs = <Tab>[
Tab(text: 'LEFT'),
Tab(text: 'RIGHT')];
Run Code Online (Sandbox Code Playgroud)
代码
DefaultTabController(
length: myTabs.length,
child: Scaffold(
appBar: TabBar(
tabs: myTabs,
),
body: TabBarView(
children: myTabs.map((Tab tab) {
final String label = tab.text.toLowerCase();
return Center(
child: Text(
'This is the $label tab',
style: const TextStyle(fontSize: 36),
),
);
}).toList(),
),
),
);
Run Code Online (Sandbox Code Playgroud)
这是我应该做的 TabBar 的另一个示例图像
实码
class ProfileTabBarNavigation extends StatelessWidget {
final List<Tab> myTabs = <Tab>[
const …Run Code Online (Sandbox Code Playgroud) 我试图在 TabBar 中实现边距,但没有找到任何东西。所以我的想法是对参数中的BoxDecorationof做一个裕度。TabBarindicator
这就是我要的:

这就是我所拥有的:

我的实现代码:
DefaultTabController(
length: 2,
initialIndex: 0,
child: Padding(
padding: kPaddingTabBar,
child: Container(
decoration: BoxDecoration(
color: kLightGrey,
borderRadius: BorderRadius.all(
Radius.circular(50),
),
),
child: TabBar(
tabs: <Tab>[
Tab(text: kArtwork),
Tab(text: kPastJobs)
],
unselectedLabelColor: Colors.black54,
labelColor: Colors.black,
unselectedLabelStyle: TextStyle(
fontWeight: FontWeight.bold,
fontFamily: kRobotoBold,
),
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
fontFamily: kRobotoBold,
),
indicatorSize: TabBarIndicatorSize.tab,
indicator: BoxDecoration(
shape: BoxShape.rectangle,
borderRadius: BorderRadius.circular(50),
color: Colors.white,
),
),
),
),
)
Run Code Online (Sandbox Code Playgroud) 我试图删除底部的多余空间SliverAppBar。
我的代码是:
class Home extends StatefulWidget {
@override
_HomeState createState() => _HomeState();
}
class _HomeState extends State<Home> with TickerProviderStateMixin {
ScrollController _scrollViewController;
TabController _tabController;
double scrollPosition;
@override
void initState() {
_scrollViewController = ScrollController();
_tabController = TabController(vsync: this, length: 2, initialIndex: 0)
..addListener(() => _scrollViewController.animateTo(
0.0,
curve: Curves.easeIn,
duration: const Duration(milliseconds: 300),
));
super.initState();
}
@override
void dispose() {
_tabController.dispose();
_scrollViewController.dispose();
super.dispose();
}
@override
Widget build(BuildContext context) {
return Container(
color: Colors.white,
child: DefaultTabController(
length: 2,
initialIndex: 0,
child: …Run Code Online (Sandbox Code Playgroud)我是 Haskell 的新手,我迷路了。我试图解析一个数学表达式,但真的不知道 Haskell 编程如何运作良好。所以我要写的是一个程序来解决一个简单的数学表达式。我正在寻找有关如何通过提出论据来解决问题的想法。
命令行可能如下所示:./math "3 + 2"或./math "5 * 8"
我的代码如下所示:
import System.Environment (getArgs)
import Text.Printf
main :: IO ()
main = do
args <- getArgs
printf "%.2f" args[1] + args[2]
Run Code Online (Sandbox Code Playgroud)