common.dart (文件名)
import 'package:flutter/material.dart';
final Color sliverbgColor = Color.fromARGB(255, 90, 186, 205);
final Color vbgColor = Colors.white;
final Color deviderColor = Color.fromARGB(255, 183, 183, 183);
final TextStyle tsSectionTitle =
TextStyle(fontSize: 16, color: Colors.black, fontWeight: FontWeight.bold);
final TextStyle tsPlainext =
TextStyle(fontSize: 16, color: Colors.black);
final Color statusBtnBackGround = Color.fromARGB(255, 85, 179, 60);
final Color btnDoneBackGround = Color.fromARGB(255, 25, 23, 115);
final Color btnCancelBackGround = Color.fromARGB(255, 93, 99, 106);
Widget edgetInsetWdiget({
@required Widget childw,
Color backGround,
EdgeInsets edgeInsets}){
return Container(
color: backGround ?? Colors.white,
padding: edgeInsets ?? EdgeInsets.fromLTRB(15, 0, 15, 0),
child: childw,
);
}
Widget textPlainW(
{@required Color background,
@required String text,
@required TextStyle textStyle,
@required EdgeInsets edgeInsets}) {
return Container(
color: background,
padding: edgeInsets,
child: Text(
text,
style: textStyle,
),
);
}
Widget rowBottomDeviderLineTopChilernWidget({EdgeInsets edgeInsets, double height = 50, List<Widget>children, Color deviderColor, double deviderWidth = 2, double thickness = 2, double indent = 0,
double endIndent = 0}){
List<Widget> ws = [];
for(var i = 0; i< children.length; i++){
Widget w = children[i];
ws.add(w);
if(i != children.length - 1){
ws.add(VerticalDivider(
color: deviderColor ?? Color.fromARGB(255, 213, 213, 213),
width: deviderWidth,
thickness: thickness,
indent: indent,
endIndent: endIndent,));
}
}
return Container(
padding: edgeInsets ?? EdgeInsets.fromLTRB(15, 10, 15, 10),
height: height,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: ws,
)
);
}
// 底部两个按钮
// 底部两个按钮 BuildContext context,
Widget bottomMenusWidget(
{@required String confirmText,
String backText,
double minWidth = 45,
double btnHegiht = 45,
Function() backAction,
TextStyle tsBack,
Color backBtnGround,
Function confirmAction,
TextStyle tsConfrim,
Color confrimBtnground}) {
TextStyle defaultTextStyle = TextStyle(color: Colors.white, fontSize: 14);
List <Widget> wls = [];
if(backText != null){
wls.addAll([
Expanded(flex: 1, child: ButtonTheme(
minWidth: minWidth,
height: btnHegiht,
child: RaisedButton(
child: Text(backText,
style: tsBack ?? defaultTextStyle, maxLines: 1,),
shape: StadiumBorder(),
color: backBtnGround ?? btnCancelBackGround,
onPressed: (){
print("back------------");
backAction();
},
),
)),
SizedBox(width: 15,),
Expanded(flex: 1, child: ButtonTheme(
minWidth: minWidth,
height: btnHegiht,
child: RaisedButton(
child: Text(confirmText,
style: tsConfrim ?? defaultTextStyle, maxLines: 1),
shape: StadiumBorder(),
color: confrimBtnground ?? Colors.white,
onPressed: confirmAction,
),
)),
]);
} else {
wls.addAll([
Expanded(flex: 1, child: Container()),
Expanded(flex: 1, child: ButtonTheme(
minWidth: minWidth,
height: btnHegiht,
child: RaisedButton(
child: Text(confirmText,
style: tsConfrim ?? defaultTextStyle, maxLines: 1),
shape: StadiumBorder(),
color: confrimBtnground ?? Colors.white,
onPressed: confirmAction,
),
)),
Expanded(flex: 1, child: Container())
]);
}
return Container(
color: Colors.transparent,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: wls),
);
}
Widget revokeAppBar(
{@required BuildContext context,
@required String topTitle,
@required String text,
Color textColor = Colors.white,
int maxlines = 1,
TextAlign textAlign,
bool softWrap = false,
TextStyle style,
TextStyle subStyle,
List<Color> colors,
List<int> stops,
double expandedHeight = 130.0,
double fontsize = 18.0}) {
return SliverAppBar(
backgroundColor: (colors != null && colors.length > 0)
? colors[0]
: Color.fromARGB(255, 25, 27, 113),
expandedHeight: expandedHeight,
pinned: true,
flexibleSpace: FlexibleSpaceBar(
centerTitle: true,
title: Text(
text,
maxLines: maxlines,
textAlign: textAlign,
softWrap: softWrap,
style: subStyle ??
TextStyle(color: textColor ?? Colors.white, fontSize: fontsize),
),
titlePadding: EdgeInsets.only(bottom: 30),
background: Container(
padding: EdgeInsets.only(top: 40),
alignment: Alignment.topCenter,
child: Text(topTitle,style:style ??
TextStyle(color: textColor ?? Colors.white, fontSize: fontsize)),
decoration: BoxDecoration(
gradient: LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: colors != null
? colors
: [
Color.fromARGB(255, 25, 27, 113),
Color.fromARGB(255, 28, 75, 113),
Color.fromARGB(255, 94, 187, 203)
],
stops: stops != null ? stops : [0.0, 0.63, 1.0],
),
),
),
),
);
}
Widget rowDeviderLineWithChildenWidget({EdgeInsets edgeInsets, double height = 50, List<Widget>children, Color deviderColor, double deviderWidth = 2, double thickness = 2, double indent = 0,
double endIndent = 0}){
List<Widget> ws = [];
for(var i = 0; i< children.length; i++){
Widget w = children[i];
ws.add(w);
if(i != children.length - 1){
ws.add(vDevider(width: 10));
}
}
return Container(
padding: edgeInsets ?? EdgeInsets.fromLTRB(15, 10, 15, 10),
height: height,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.center,
children: ws,
)
);
}
Widget vDevider({Color color, double width = 1,double thickness = 1, double indent = 0, double endIndent = 0}){
return VerticalDivider(
color: color ?? Color.fromARGB(255, 213, 213, 213),
width: width,
thickness: thickness,
indent: indent,
endIndent: endIndent,
);
}
Widget hDevider({Color color, double width = 1,double thickness = 1, double indent = 0, double endIndent = 0}){
return Divider(
color: color ?? Color.fromARGB(255, 213, 213, 213),
width: width,
thickness: thickness,
indent: indent,
endIndent: endIndent,
);
}
Widget customExpandRowRaiseBtn({BuildContext context,String text,TextStyle ts,Function callAction,
double height = 45, EdgeInsets edgeInsets, double elevation = 3, double bwidth = 0,
Color bColor = Colors.transparent, Color textColor = Colors.black, Color background = Colors.transparent}){
return Expanded(
child: Container(
height : height,
padding: edgeInsets ?? EdgeInsets.fromLTRB(15, 0, 15, 0),
child: RaisedButton(
elevation: elevation,
child: Text(
text,
style: ts ?? TextStyle(
fontSize: 14
),
maxLines: 1,
),
shape: StadiumBorder(
side: BorderSide(
width: bwidth,
color: bColor,
)),
textColor: textColor,
color: background,
onPressed: () {
if (callAction != null){
callAction();
}
},
),
));
}
Widget customFlexibleRowRaiseBtn({BuildContext context,String text,TextStyle ts,Function callAction,
double height = 45, EdgeInsets edgeInsets, double elevation = 3, double bwidth = 0,
Color bColor = Colors.transparent, Color textColor = Colors.black, Color background = Colors.transparent}){
return Flexible(
child: Container(
height : height,
padding: edgeInsets ?? EdgeInsets.fromLTRB(15, 0, 15, 0),
child: RaisedButton(
elevation: elevation,
child: Text(
text,
style: ts ?? TextStyle(
fontSize: 14
),
maxLines: 1,
),
shape: StadiumBorder(
side: BorderSide(
width: bwidth,
color: bColor,
)),
textColor: textColor,
color: background,
onPressed: () {
if (callAction != null){
callAction();
}
},
),
));
}
Widget minColumnFlexible({@required Widget child}){
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children:<Widget>[
Flexible(
child: child,
),
]
);
}
Widget minColumnExpanded({@required Widget child}){
return Column(
mainAxisAlignment: MainAxisAlignment.start,
crossAxisAlignment: CrossAxisAlignment.center,
mainAxisSize: MainAxisSize.min,
children:<Widget>[
Expanded(
child: child,
),
]
);
}
浙公网安备 33010602011771号