You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
458 lines
12 KiB
Dart
458 lines
12 KiB
Dart
import 'dart:io';
|
|
import 'dart:math';
|
|
import 'dart:ui';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
Decoration appGradient = BoxDecoration(
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xFFFDCA46F),
|
|
Color(0xFFFA47E5D),
|
|
],
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
),
|
|
);
|
|
|
|
Color getColorFromHex(String hexColor) {
|
|
hexColor = hexColor.toUpperCase().replaceAll('#', '');
|
|
|
|
if (hexColor.length == 6) {
|
|
hexColor = 'FF' + hexColor;
|
|
}
|
|
|
|
return Color(int.parse(hexColor, radix: 16));
|
|
}
|
|
|
|
spacerVertical(double v) {
|
|
return Container(
|
|
height: v,
|
|
width: double.infinity,
|
|
);
|
|
}
|
|
|
|
spacerHorizontal(double v) {
|
|
return Container(
|
|
height: v,
|
|
width: v,
|
|
);
|
|
}
|
|
|
|
spacer() {
|
|
return SizedBox(
|
|
height: 8,
|
|
);
|
|
}
|
|
|
|
Future navigateTo(context, page) async {
|
|
return await Navigator.push(context, MaterialPageRoute(builder: (context) => page));
|
|
}
|
|
|
|
// Future navigateToReplace(context, page) async {
|
|
// Navigator.pushReplacement(context, FadeRouteBuilder(page: page));
|
|
// }
|
|
|
|
InputDecoration txtField(String label) {
|
|
return new InputDecoration(
|
|
border: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
errorBorder: InputBorder.none,
|
|
hintText: label,
|
|
hintStyle: TextStyle(color: Colors.grey),
|
|
disabledBorder: InputBorder.none,
|
|
contentPadding: EdgeInsets.only(left: 15, right: 15),
|
|
);
|
|
}
|
|
|
|
InputDecoration txtField3(String label) {
|
|
return new InputDecoration(
|
|
border: InputBorder.none,
|
|
focusedBorder: InputBorder.none,
|
|
enabledBorder: InputBorder.none,
|
|
errorBorder: InputBorder.none,
|
|
hintText: label,
|
|
disabledBorder: InputBorder.none,
|
|
counterText: "",
|
|
contentPadding: EdgeInsets.only(left: 5, right: 5),
|
|
);
|
|
}
|
|
|
|
InputDecoration txtFieldSearch(String label) {
|
|
return new InputDecoration(
|
|
border: InputBorder.none,
|
|
suffixIcon: Icon(Icons.clear),
|
|
disabledBorder: InputBorder.none,
|
|
contentPadding: EdgeInsets.only(left: 15, right: 15),
|
|
);
|
|
}
|
|
|
|
Widget circularAviator(double s, {Color bcColor, Color brColor, Color iconColor, int borderWidth, IconData icon}) {
|
|
return Card(
|
|
shape: cardRadius(2000),
|
|
color: Colors.transparent,
|
|
elevation: 4,
|
|
child: Container(
|
|
width: s,
|
|
height: s,
|
|
decoration: containerColorRadiusBorderWidth(bcColor == null ? Colors.grey[200] : bcColor, 2000, brColor == null ? Colors.blueGrey[800] : brColor, borderWidth == null ? 2 : borderWidth),
|
|
child: Icon(
|
|
icon == null ? Icons.person : icon,
|
|
size: s / 1.7,
|
|
color: iconColor == null ? Colors.grey[800] : iconColor,
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget circularImage(String im, double width, double height) {
|
|
return new Container(
|
|
width: 190.0,
|
|
height: 190.0,
|
|
decoration: new BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
image: new DecorationImage(
|
|
fit: BoxFit.fill,
|
|
image: new AssetImage(im),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
circularImage2(String im, double width, double height) {
|
|
return new Container(
|
|
width: width,
|
|
height: height,
|
|
decoration: new BoxDecoration(
|
|
shape: BoxShape.circle,
|
|
image: new DecorationImage(
|
|
fit: BoxFit.fill,
|
|
image: new AssetImage(im),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget mDivider(Color color) {
|
|
return Divider(
|
|
// width: double.infinity,
|
|
height: 1,
|
|
color: color,
|
|
);
|
|
}
|
|
|
|
Widget mFlex(int f) {
|
|
return Flexible(
|
|
flex: f,
|
|
child: Container(),
|
|
);
|
|
}
|
|
|
|
mOverlay(double op) {
|
|
return Opacity(
|
|
opacity: op,
|
|
child: Container(
|
|
color: Colors.black,
|
|
width: double.infinity,
|
|
height: double.infinity,
|
|
),
|
|
);
|
|
}
|
|
|
|
Widget mHeight(double h) {
|
|
return Container(
|
|
height: h,
|
|
);
|
|
}
|
|
|
|
Widget mWidth(double w) {
|
|
return Container(
|
|
width: w,
|
|
);
|
|
}
|
|
|
|
RoundedRectangleBorder buttonShape() {
|
|
return RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.circular(14.0),
|
|
);
|
|
}
|
|
|
|
Decoration containerRadiusWithGradient(double radius) {
|
|
return BoxDecoration(
|
|
borderRadius: BorderRadius.circular(radius),
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
Color(0xFFF71787E),
|
|
Color(0xFFF2B353E),
|
|
],
|
|
begin: Alignment.centerLeft,
|
|
end: Alignment.centerRight,
|
|
),
|
|
);
|
|
}
|
|
|
|
Decoration containerBottomRightRadiusWithGradient(double radius, {Color darkColor, Color lightColor}) {
|
|
return BoxDecoration(
|
|
borderRadius: BorderRadius.only(bottomRight: Radius.circular(radius)),
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
darkColor == null ? Color(0xFFF2B353E) : darkColor,
|
|
lightColor == null ? Color(0xFFF71787E) : lightColor,
|
|
],
|
|
begin: Alignment.topCenter,
|
|
end: Alignment.bottomRight,
|
|
),
|
|
);
|
|
}
|
|
|
|
Decoration containerRadiusWithGradientServices(double radius, {Color darkColor, Color lightColor}) {
|
|
return BoxDecoration(
|
|
borderRadius: BorderRadius.all(Radius.circular(radius)),
|
|
gradient: LinearGradient(
|
|
colors: [
|
|
darkColor == null ? Color(0xFFF2B353E) : darkColor,
|
|
lightColor == null ? Color(0xFFF71787E) : lightColor,
|
|
],
|
|
begin: Alignment.centerRight,
|
|
end: Alignment.topLeft,
|
|
),
|
|
);
|
|
}
|
|
|
|
Decoration containerRadius(Color background, double radius) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
border: Border.all(
|
|
width: 1, //
|
|
color: background // <--- border width here
|
|
),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusBorder(Color background, double radius, Color color) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
border: Border.all(
|
|
width: 1, //
|
|
color: color // <--- border width here
|
|
),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusBorderWidth(Color background, double radius, Color color, double w) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
border: Border.all(
|
|
width: w, //
|
|
color: color // <--- border width here
|
|
),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusRight(Color background, double radius) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
borderRadius: BorderRadius.only(topRight: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusRightBorder(Color background, double radius, double w) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
border: Border.all(
|
|
width: w, //
|
|
color: Colors.white // <--- border width here
|
|
),
|
|
borderRadius: BorderRadius.only(topRight: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusRightBorderc(Color background, double radius, double w, Color borderColor) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
border: Border.all(
|
|
width: w, //
|
|
color: borderColor // <--- border width here
|
|
),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusTop(Color color, double radius) {
|
|
return BoxDecoration(
|
|
color: color,
|
|
borderRadius: BorderRadius.only(
|
|
topLeft: Radius.circular(radius),
|
|
topRight: Radius.circular(radius),
|
|
),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusBottom(Color color, double radius) {
|
|
return BoxDecoration(
|
|
color: color,
|
|
borderRadius: BorderRadius.only(
|
|
bottomLeft: Radius.circular(radius),
|
|
bottomRight: Radius.circular(radius),
|
|
),
|
|
);
|
|
}
|
|
|
|
Decoration containerColorRadiusLeftBorder(Color background, double radius, double w) {
|
|
return BoxDecoration(
|
|
color: background,
|
|
border: Border.all(
|
|
width: w, //
|
|
color: Colors.white // <--- border width here
|
|
),
|
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), bottomLeft: Radius.circular(radius)),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadius(double radius) {
|
|
return RoundedRectangleBorder(
|
|
side: BorderSide(color: Colors.transparent, width: 1),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadiusTop(double radius) {
|
|
return RoundedRectangleBorder(
|
|
side: BorderSide(color: Colors.transparent, width: 0),
|
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadiusTop2(double radius) {
|
|
return RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.only(topLeft: Radius.circular(radius), topRight: Radius.circular(radius)),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadiusBottom(double radius) {
|
|
return RoundedRectangleBorder(
|
|
borderRadius: BorderRadius.only(bottomLeft: Radius.circular(radius), bottomRight: Radius.circular(radius)),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadiusWithoutBorder(double radius) {
|
|
return RoundedRectangleBorder(
|
|
side: BorderSide(color: Colors.transparent, width: 1),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadiusWithBorder(double radius) {
|
|
return RoundedRectangleBorder(
|
|
side: BorderSide(color: Colors.grey, width: 1),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
ShapeBorder cardRadiusBorder(double radius, double w) {
|
|
return RoundedRectangleBorder(
|
|
side: BorderSide(color: Colors.transparent, width: w),
|
|
borderRadius: BorderRadius.circular(radius),
|
|
);
|
|
}
|
|
|
|
// String properRound(double val, int places) {
|
|
// double mod = pow(10.0, places);
|
|
// double result = ((val * mod).round().toDouble() / mod);
|
|
// return result.toString();
|
|
// }
|
|
//
|
|
// double properRoundDouble(double val, int places) {
|
|
// double mod = pow(10.0, places);
|
|
// double result = ((val * mod).round().toDouble() / mod);
|
|
// return result;
|
|
// }
|
|
//var cardShape = RoundedRectangleBorder(
|
|
// side: BorderSide(color: Colors.white70, width: 1),
|
|
// borderRadius: BorderRadius.circular(10),
|
|
//);
|
|
|
|
//await Navigator.of(context).push(new MaterialPageRoute<dynamic>(
|
|
//builder: (BuildContext context) {
|
|
//return AdminTeamAvaluatePage(widget.competitionID, data);
|
|
//},
|
|
//));
|
|
//setState(() {});
|
|
|
|
Color getColor(String selectedColor) {
|
|
try {
|
|
if ("black" == selectedColor) {
|
|
return Colors.black;
|
|
} else if ("red" == selectedColor) {
|
|
return Colors.red;
|
|
} else if ("blueAccent" == selectedColor) {
|
|
return Colors.blueAccent;
|
|
} else if ("blue" == selectedColor) {
|
|
return Colors.blue;
|
|
} else if ("blueGrey" == selectedColor) {
|
|
return Colors.blueGrey;
|
|
} else if ("yellow" == selectedColor) {
|
|
return Colors.yellow;
|
|
} else if ("black54" == selectedColor) {
|
|
return Colors.black54;
|
|
} else if ("green" == selectedColor) {
|
|
return Colors.green;
|
|
} else if ("orange" == selectedColor) {
|
|
return Colors.orange;
|
|
} else if ("deepOrange" == selectedColor) {
|
|
return Colors.deepOrange;
|
|
} else {
|
|
return Colors.black;
|
|
}
|
|
} catch (e) {
|
|
return Colors.black;
|
|
}
|
|
}
|
|
|
|
TextAlign getTextAlign(String textAlign) {
|
|
try {
|
|
if (textAlign == "left") {
|
|
return TextAlign.left;
|
|
} else if (textAlign == "right") {
|
|
return TextAlign.right;
|
|
} else if (textAlign == "center") {
|
|
return TextAlign.center;
|
|
} else if (textAlign == "justify") {
|
|
return TextAlign.justify;
|
|
} else {
|
|
return TextAlign.left;
|
|
}
|
|
} catch (e) {
|
|
print("fffff " + e.toString());
|
|
return TextAlign.left;
|
|
}
|
|
}
|
|
|
|
FontWeight getFontWeight(String fontWeight) {
|
|
if (fontWeight == null) {
|
|
return FontWeight.normal;
|
|
} else if (fontWeight == "bold") {
|
|
return FontWeight.bold;
|
|
} else {
|
|
return FontWeight.normal;
|
|
}
|
|
}
|
|
|
|
FontStyle getFontStyle(String fontStyle) {
|
|
try {
|
|
if (fontStyle == null) {
|
|
return FontStyle.normal;
|
|
} else if (fontStyle == "italian") {
|
|
return FontStyle.italic;
|
|
} else {
|
|
return FontStyle.normal;
|
|
}
|
|
} catch (e) {
|
|
return FontStyle.normal;
|
|
}
|
|
}
|