string - 参数类型“TabBar”不能分配给参数类型“String”
问题描述
您好朋友,我在将 tabbar 放入 customappbar 时遇到了错误,
它说“参数类型'TabBar'不能分配给参数类型'String'。”
// ignore_for_file: import_of_legacy_library_into_null_safe, unused_import, non_constant_identifier_names
import 'package:date_time_picker/date_time_picker.dart';
import 'package:dropdown_search/dropdown_search.dart';
import 'package:e_digital_nepal/widgets/custom_appBar.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'student_leave_card.dart';
import 'student_leave_apply.dart';
import 'datepicker.dart';
void main() {
runApp(MaterialApp(
debugShowCheckedModeBanner: false,
home: StudentLeaveHistory(),
title: 'Leaves',
));
}
class StudentLeaveHistory extends StatefulWidget {
@override
_StudentLeaveHistoryState createState() => _StudentLeaveHistoryState();
}
class _StudentLeaveHistoryState extends State<StudentLeaveHistory>
with SingleTickerProviderStateMixin {
late Animation animation, delayedAnimation, muchDelayedAnimation, LeftCurve;
late AnimationController animationController;
@override
void initState() {
// ignore: todo
// TODO: implement initState
super.initState();
//SystemChrome.setEnabledSystemUIOverlays([]);
animationController =
AnimationController(duration: Duration(seconds: 3), vsync: this);
animation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation(
parent: animationController, curve: Curves.fastOutSlowIn));
delayedAnimation = Tween(begin: 1.0, end: 0.0).animate(CurvedAnimation(
parent: animationController,
curve: Interval(0.2, 0.5, curve: Curves.fastOutSlowIn)));
muchDelayedAnimation = Tween(begin: -1.0, end: 0.0).animate(CurvedAnimation(
parent: animationController,
curve: Interval(0.3, 0.5, curve: Curves.fastOutSlowIn)));
}
@override
Widget build(BuildContext context) {
animationController.forward();
final double width = MediaQuery.of(context).size.width;
return AnimatedBuilder(
animation: animationController,
builder: (BuildContext context, Widget? child) {
现在,问题来了,
return DefaultTabController(长度: 4, child: Scaffold(appBar: CoustomAppBar(title: 'Leaves', bottom:TabBar( tabs: [ Tab(icon: Icon(Icons.cake)), Tab(icon: Icon(Icons.android) ), Tab(icon: Icon(Icons.phone_android)), ],), ),
return DefaultTabController(
length: 4,
child: Scaffold(
appBar: CoustomAppBar(
title: 'Leaves',
bottom:TabBar(
tabs: <Widget>[
Tab(icon: Icon(Icons.cake)),
Tab(icon: Icon(Icons.android)),
Tab(icon: Icon(Icons.phone_android)),
],),
),
body: SingleChildScrollView(
child: Column(children: [
Transform(
transform: Matrix4.translationValues(
delayedAnimation.value * width, 0, 0),
child: StudentLeaveHistoryCard(
leavetype: 'Cultural & Ritual Ceremony',
description:
"It is respectfully submitted that, I Subidha Shrestha from class 10 having roll no 15 is suffering from fever since last night. It seems as if that fever is not going away at all, soy father want to rush me to hospital.Therefore I, am unable to attend my school classes for next three days. I hope you will understand my situation will grant me leave for next 03 days.",
status: 'Pending',
requesteddate: '2078-05-08',
verifieddate: '2078-05-09',
),
),
SizedBox(
height: 10,
),
Transform(
transform: Matrix4.translationValues(
delayedAnimation.value * width, 0, 0),
child: StudentLeaveHistoryCard(
leavetype: 'Cultural & Ritual Ceremony',
description:
"It is respectfully submitted that, I Subidha Shrestha from class 10 having roll no 15 is suffering from fever since last night. It seems as if that fever is not going away at all, soy father want to rush me to hospital.Therefore I, am unable to attend my school classes for next three days. I hope you will understand my situation will grant me leave for next 03 days.",
status: 'Pending',
requesteddate: '2078-05-08',
verifieddate: '2078-05-09',
),
),
SizedBox(
height: 10,
),
Transform(
transform: Matrix4.translationValues(
delayedAnimation.value * width, 0, 0),
child: StudentLeaveHistoryCard(
leavetype: 'Cultural & Ritual Ceremony',
description:
"It is respectfully submitted that, I Subidha Shrestha from class 10 having roll no 15 is suffering from fever since last night. It seems as if that fever is not going away at all, soy father want to rush me to hospital.Therefore I, am unable to attend my school classes for next three days. I hope you will understand my situation will grant me leave for next 03 days.",
status: 'Pending',
requesteddate: '2078-05-08',
verifieddate: '2078-05-09',
),
),
SizedBox(
height: 10,
),
Transform(
transform: Matrix4.translationValues(
delayedAnimation.value * width, 0, 0),
child: StudentLeaveHistoryCard(
leavetype: 'Cultural & Ritual Ceremony',
description:
"It is respectfully submitted that, I Subidha Shrestha from class 10 having roll no 15 is suffering from fever since last night. It seems as if that fever is not going away at all, soy father want to rush me to hospital.Therefore I, am unable to attend my school classes for next three days. I hope you will understand my situation will grant me leave for next 03 days.",
status: 'Pending',
requesteddate: '2078-05-08',
verifieddate: '2078-05-09',
),
),
SizedBox(
height: 10,
),
]),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(builder: (context) => StudentLeaveApply()),
);
},
child: Icon(
Icons.add,
color: Colors.white,
size: 20,
),
),
),
);
},
);
}
}
解决方案
我已经做到了,@Why_So_Ezz
class CoustomAppBar extends StatelessWidget with PreferredSizeWidget {
@override
final Size preferredSize;
Color? backgroundColor;
String bottom;
String title;
bool containTabBar;
TabController? tabController;
bool isCenterTitle;
double? elevation;
CoustomAppBar(
{Key? key,
this.backgroundColor,
this.bottom = '',
this.title = '',
this.containTabBar = false,
this.tabController,
this.isCenterTitle = false,
this.elevation})
: preferredSize = Size.fromHeight(containTabBar ? 100.0 : 50.0),
super(key: key);
推荐阅读
- swiftui - SwiftUI 不更新第二个 NavigationLink 目的地
- python - 当 Tkinter 窗口不在顶层时,如何制作它的截图?
- python - Python 类方法钩子和派生
- swift - Swift 有条件的向下转型什么都不做
- javascript - 使用本机文件系统 API 在 Windows 资源管理器中打开文件夹
- sql - 哪些资源使用 GCP VM 实例对 GCP SQL 实例执行任何操作?
- vba - 在 AutoCAD vba 中出现数组错误。下标超出范围
- html - 如何使 2 个表格单元格的长度相同但文本数量不同?
- javascript - 带有 HTML5 视频的 WebView 中的内存泄漏
- c# - 数据库集
将 EF Core 从 2.2.6 升级到 3.1.3 时出现 .Local.Any() 性能问题