import 'package:flutter/material.dart';
import 'package:flutter_shop/config/font.dart';
import 'package:provide/provide.dart';
import '../../provide/details_info.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class DetailTabBarextends StatelessWidget {
@override
Widget build(BuildContext context) {
return Provide(
builder: (context,child,val){
var isLeft=Provide.value(context).isLeft;
var isRight=Provide.value(context).isRight;
return Container(
child:Row(
children: [
_myTabBarLeft(context,isLeft),
_myTabBarRight(context,isRight),
],
),
);
}
);
}
Widget _myTabBarLeft(BuildContext context,bool isLeft){
return InkWell(
onTap: (){
Provide.value(context).changeLeftAndRight('left');
},
child:Container(
padding:EdgeInsets.all(10),
alignment: Alignment.center,
width:ScreenUtil().setWidth(375),
decoration:BoxDecoration(
color: Colors.white,
border:Border(
bottom:BorderSide(
width:1.0,
color: isLeft?Colors.pink:Colors.black12
)
)
),
child:Text("详情",style:TextStyle(
color: isLeft?Colors.pink:Colors.black12
),),
),
);
}
Widget _myTabBarRight(BuildContext context,bool isRight){
return InkWell(
onTap: (){
Provide.value(context).changeLeftAndRight('right');
},
child:Container(
padding:EdgeInsets.all(10),
alignment: Alignment.center,
width:ScreenUtil().setWidth(375),
decoration:BoxDecoration(
color: Colors.white,
border:Border(
bottom:BorderSide(
width:1.0,
color: isRight?Colors.pink:Colors.black12
)
)
),
child:Text("评论",style:TextStyle(
color: isRight?Colors.pink:Colors.black87
),),
),
);
}
}
provide中写
boolisLeft=true;
boolisRight=false;
// tabbar的切换方法
changeLeftAndRight(String changeState){
if(changeState=='left'){
isLeft=true;
isRight=false;
}else{
isLeft=false;
isRight=true;
}
// 通知监听者
notifyListeners();
}
![](https://img.haomeiwen.com/i20331012/e7db31ed2067881f.png)
网友评论