ecommerce
export PATH="$PATH:/Users/mac/Documents/flutter/bin"
shopping use total price count
num get totalPrice => items.fold(0, (total, current) => total + current.price);
Image select camera
final _picker = ImagePicker(); File? image; PickedFile? image = await _picker.getImage( source: ImageSource.camera, maxHeight: 675, maxWidth: 960, ); File selectedImage = File(image!.path);
setState(() { this.image = selectedImage; }); }
STRIPE PAYMENT GETWAY
static String getStripePrice(double price) { final returnedPrice = (price * 100).toInt(); return returnedPrice.toString(); }
Container( height: double.infinity, child: Align( widthFactor: 0.7, child: AspectRatio( aspectRatio: 1 / 1, child: ProfileAvatar(colorBg: color1, currentSociety: currentSociety, colorLight: color2))))
FractionallySizedBox( widthFactor: 1, child: Card( elevation: 0, margin: margin, clipBehavior: Clip.antiAlias, color: Colors.transparent, shape: RoundedRectangleBorder( borderRadius: BorderRadius.circular(radius) ), child: Container( height: height, color: color )))
List<> dataList = List<>.empty(growable: true);
const EdgeInsets.symmetric(horizontal: 30),
networkImage( {String image, Widget loaderImage, double height, double width, BoxFit boxFit = BoxFit.fitHeight}) => CachedNetworkImage( imageUrl: image, placeholder: (context, url) => loaderBeforeImage(width: width, height: height), //largeImageShimmer(context), errorWidget: (context, url, error) => loaderBeforeImage(width: width, height: height), height: height, width: width, fit: boxFit, );
Image loaderBeforeImage( {double height = 135, double width = 162.5, String image = 'assets/images/no_image.jpg', BoxFit boxFit = BoxFit.contain}) => Image.asset( image, height: height, width: width, fit: boxFit, );
//SEARCH
Container(
height: 140.h,
child: TextField(
textAlignVertical: TextAlignVertical.center,
textAlign: TextAlign.left,
decoration: InputDecoration(
hintText: '输入商品名或者宝贝标题搜索',
border: OutlineInputBorder(borderRadius: BorderRadius.circular(20.0), borderSide: BorderSide.none),
alignLabelWithHint: true,
filled: true,
fillColor: Colors.white,
suffixIcon: Icon(
Icons.search,
color: Colors.grey,
),
hintStyle: TextStyle(height: 1.5),
contentPadding: EdgeInsets.only(top: 30.h, left: 40.w)),
style: TextStyle(height: 1, color: Colors.black),
),
),
Container(
width: ScreenUtil().setWidth(900),
height: ScreenUtil().setHeight(120),
child: Stack(
children: <Widget>[
Container(
padding: EdgeInsets.only(left: 10),
decoration: BoxDecoration(
color: Color.fromRGBO(255, 238, 230, 1.0),
borderRadius: BorderRadius.only(
topRight: Radius.circular(100.0),
bottomRight: Radius.circular(100.0))),
alignment: Alignment.centerLeft,
child: RichText(
text: TextSpan(children: [
TextSpan(
text: "已售",
style: TextStyle(
fontSize: ScreenUtil().setSp(45),
color: Color.fromRGBO(137, 60, 17, 1.0)),
),
TextSpan(
text: " ${goodsItem.monthSales} ",
style: TextStyle(
fontSize: ScreenUtil().setSp(65),
color: Color.fromRGBO(255, 91, 0, 1.0)),
),
TextSpan(
text: "件",
style: TextStyle(
fontSize: ScreenUtil().setSp(45),
color: Color.fromRGBO(137, 60, 17, 1.0)),
)
]),
),
),
Positioned(
right: -3.3,
top: 0,
child: Image.asset(
"assets/images/lijigoumai.png",
width: ScreenUtil().setWidth(350),
height: ScreenUtil().setHeight(140),
fit: BoxFit.cover,
),
),
Positioned(
right: 0,
top: 0,
child: Container(
alignment: Alignment.center,
width: ScreenUtil().setWidth(280),
height: ScreenUtil().setHeight(120),
child: Text(
"立即购买",
style: TextStyle(
fontSize: ScreenUtil().setSp(40),
color: Colors.white),
),
)
)
],
),
)
{'Content-Type': 'application/json'} body: jsonEncode(data),