《Flutter实战·第二版》- Preview
ShapeBorder shape,对应子类如下:
shape: BorderDirectional(
top: BorderSide(color: Colors.white),
start: BorderSide(color: Colors.black,width: 15)
),
1.2. Border --通过【top】【bottom】【left】【right】
shape: Border(
top: BorderSide(width: 5.0, color: Colors.grey),
left: BorderSide(width: 5.0, color: Colors.grey),
),
shape: RoundedRectangleBorder(
side: BorderSide(width: 1.0, color: Colors.black),
borderRadius: BorderRadius.all(Radius.circular(15))
),
shape: ContinuousRectangleBorder(
side: BorderSide.none,
borderRadius: BorderRadius.circular(40.0),
),
shape: StadiumBorder(
side: BorderSide(width: 2.0, color: Colors.grey)
),
shape: CircleBorder(
side: BorderSide(width: 2.0, color: Colors.grey),
),
shape: BeveledRectangleBorder(
borderRadius: BorderRadius.circular(20.0),
side: BorderSide(width: 2.0, color: Colors.grey)
),
shape: OutlineInputBorder(
borderSide: BorderSide(width: 2.0, color: Colors.purple),
borderRadius: BorderRadius.circular(20.0),
),
7.2. UnderlineInputBorder
shape: UnderlineInputBorder(
borderSide: BorderSide(width: 5.0, color: Colors.blue),
borderRadius: BorderRadius.circular(20),
),
Decoration decoration,对应子类如下:
const BoxDecoration({
this.color,
this.image,
this.border,
this.borderRadius,
this.boxShadow,
/** LinearGradient线性渐变和RadialGradient扫描渐变 */
this.gradient,
/** 图像混合模式 */
this.backgroundBlendMode,
/** BoxShape.circle和borderRadius不能同时使用 */
this.shape = BoxShape.rectangle,
})
decoration: BoxDecoration(
// 边色与边宽度
border: Border.all(color: Color(0xFFFFFF00), width: 0.5),
//背景图片
image: DecorationImage(
image: NetworkImage('地址'),
fit: BoxFit.fill
//centerSlice: new Rect.fromLTRB(270.0, 180.0, 1360.0, 730.0),// 固定大小
),
),
const ShapeDecoration({
this.color,
this.image,
this.gradient,
this.shadows,
//除了shape属性,其他与BoxDecoration一致
required this.shape,
})
const UnderlineTabIndicator({
this.borderSide = const BorderSide(width: 2.0, color: Colors.white),
//控制下划高底,左右边距,可以为负值
this.insets = EdgeInsets.zero,
})
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.resolveWith((state) {
if (state.contains(MaterialState.pressed)) {
//设置按下时背景颜色
return Colors.green[200];
}
return Colors.green;
}),
shape: MaterialStateProperty.all(const StadiumBorder()),
),
onPressed: () {},
child: Text("上传",style: TextStyle(color: Colors.white),)),
任何时候子组件都必须遵守其父组件的约束。如果Row里面嵌套Row,或者Column里面再嵌套Column,那么只有最外面的Row或Column会占用尽可能大的空间,里面Row或Column所占用的空间为实际大小,
DropdownButton的初始值必须是显示列表里面的值,比如DropdownButton的items属性使用的是list这个列表里面的值,那么这个初始值必须在list[index]里面取,要不就会报错。
Expanded、Flexible,只在Row、Column等组件内使用,不在其他组件内使用。在“Container、Padding、Stack”等组件中会报错。
ImagePicker().pickImage(source: ImageSource.gallery)
ImagePicker().pickVideo(source: ImageSource.camera)
ImagePicker().pickMultiImage()
images_picker: ^1.2.10
可以设置count同时选择多张,拍照和相册分别调用
// for pick
int count = 1,
PickType pickType = PickType.image,
bool gif = true,
int maxTime = 120,
CropOption cropOpt,
int maxSize,
double quality,
// for camera
PickType pickType = PickType.image,
int maxTime = 15,
CropOption cropOpt,
int maxSize,
double quality,
ImagesPicker.pick(
count: 3,
pickType: PickType.image,
gif: true, // default is true
cropOpt: CropOption(
aspectRatio: CropAspectRatio.custom,
cropType: CropType.rect, // currently for android
),
);
ImagesPicker.openCamera(
pickType: PickType.video,
maxTime: 15, // record video max time
);
File file = await downloadFile('图片下载地址');
ImagesPicker.saveImageToAlbum(file, albumName: "");