You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

55 lines
1.2 KiB

import 'package:flutter/material.dart';
3 years ago
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';
class BeeTabBar extends StatefulWidget with PreferredSizeWidget {
4 years ago
final TabController? controller;
final List<String> tabs;
4 years ago
final Function(int index)? onTap;
final bool scrollable;
3 years ago
BeeTabBar({
4 years ago
Key? key,
required this.controller,
required this.tabs,
this.onTap,
this.scrollable = false,
}) : super(key: key);
@override
_BeeTabBarState createState() => _BeeTabBarState();
@override
Size get preferredSize => Size.fromHeight(96.w);
}
class _BeeTabBarState extends State<BeeTabBar> {
update() {
4 years ago
if (widget.onTap != null) widget.onTap!(widget.controller!.index);
}
@override
void initState() {
super.initState();
4 years ago
widget.controller!.addListener(update);
}
@override
void dispose() {
4 years ago
widget.controller!.removeListener(update);
super.dispose();
}
@override
Widget build(BuildContext context) {
return TabBar(
controller: widget.controller,
indicatorColor: Color(0xffffc40c),
tabs: widget.tabs.map((e) => Tab(text: e)).toList(),
onTap: widget.onTap,
isScrollable: widget.scrollable,
);
}
}