child: Column( children: [ Container( margin: EdgeInsets.only( right: MyDimens.getWidth(207), ), width: 100, height: 100, decoration: BoxDecoration( borderRadius: BorderRadius.all(Radius.circular(10)), color: Colors.white, border: Border.all( width: 1, color: Color(0xff999999), ), ), // child: SizedBox( width: 20,height: 20,child: Utils.getLocalImgWidget('common/ic_img', 0, 0)), ), ], ), onTap: (){ UploadImgUtils.choseImage(context, _cropImage, hint: '用于上传头像'); }, ) ], ), );这里怎么能吧边框保存虚线
时间: 2024-01-04 10:03:11 浏览: 147
要将边框设置为虚线,可以使用`Border.fromBorderSide()`方法创建一个带有虚线边框的`BorderSide`对象,然后将其传递给`border`属性。以下是示例代码:
```
Container(
margin: EdgeInsets.only(right: MyDimens.getWidth(207)),
width: 100,
height: 100,
decoration: BoxDecoration(
borderRadius: BorderRadius.all(Radius.circular(10)),
color: Colors.white,
border: Border.fromBorderSide(BorderSide(
width: 1,
color: Color(0xff999999),
style: BorderStyle.dashed,
)),
),
onTap: () {
UploadImgUtils.choseImage(context, _cropImage, hint: '用于上传头像');
},
),
```
在上面的代码中,我们将`style`属性设置为`BorderStyle.dashed`,以将边框样式设置为虚线。这样就可以将边框保存为虚线了。
相关问题
Widget Maxcenter(RecordResultRecords item){ return Container( color: Color.fromRGBO(248,249,253,1), child: Column( children: [ MyDimens.height(height: 8), Text(item.createTime.substring(5,11) ?? "10/20", style: MyStyle.text_style_14_119, ), Container( width: MyDimens.getWidth(343), height: MyDimens.getHeight(109), margin: EdgeInsets.only( top: MyDimens.getHeight(10), right: MyDimens.getWidth(16), left: MyDimens.getWidth(16)), padding: EdgeInsets.only( top: MyDimens.getHeight(20), right: MyDimens.getWidth(16), left: MyDimens.getWidth(20) ), decoration: const BoxDecoration( color: Colors.white, borderRadius: BorderRadius.all(Radius.circular(10)), ), child: InkWell( child: Column( children: [ Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ Text('举报用户', style: MyStyle.text_style_16_0, ), Text('用户名称', style: MyStyle.text_style_16_254,), ], ), MyDimens.height(height: 14), Text(item.tmrDesc??'暂无数据', maxLines: 3, overflow: TextOverflow.ellipsis, style: MyStyle.text_style_12_102,textAlign: TextAlign.left, ) ], ), onTap: (){ RouteUtil.startActivity(context, Reportdetal()); }, )) ], ), ); }【在这里怎么吧05-29数据放在一起】如果有05-30的数据的话并显示【05-30的数据】注:5-29的数据和05-30的数据是分开的
你可以在这个Widget里面添加一个判断语句,判断当前的数据是否为05-29的数据,如果是,就显示05-29的数据,如果不是,就不显示。然后再添加一个类似的判断语句,判断当前的数据是否为05-30的数据,如果是,就显示05-30的数据,如果不是,就不显示。具体代码如下:
```
Widget Maxcenter(RecordResultRecords item){
return Container(
color: Color.fromRGBO(248,249,253,1),
child: Column(
children: [
MyDimens.height(height: 8),
Text(item.createTime.substring(5,11) ?? "10/20", style: MyStyle.text_style_14_119, ),
Container(
width: MyDimens.getWidth(343),
height: MyDimens.getHeight(109),
margin: EdgeInsets.only( top: MyDimens.getHeight(10), right: MyDimens.getWidth(16), left: MyDimens.getWidth(16)),
padding: EdgeInsets.only( top: MyDimens.getHeight(20), right: MyDimens.getWidth(16), left: MyDimens.getWidth(20) ),
decoration: const BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10)),
),
child: Column(
children: [
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text('举报用户', style: MyStyle.text_style_16_0, ),
Text('用户名称', style: MyStyle.text_style_16_254,),
],
),
MyDimens.height(height: 14),
Text(item.tmrDesc??'暂无数据', maxLines: 3, overflow: TextOverflow.ellipsis, style: MyStyle.text_style_12_102,textAlign: TextAlign.left, ),
if (item.createTime.substring(5,11) == "05-29") Text("05-29的数据"),
if (item.createTime.substring(5,11) == "05-30") Text("05-30的数据"),
],
),
onTap: (){ RouteUtil.startActivity(context, Reportdetal()); },
)
],
),
);
}
```
E/AndroidRuntime: FATAL EXCEPTION: main Process: com.example.photodiary, PID: 32496 java.lang.NullPointerException: Attempt to invoke virtual method 'int android.util.Size.getWidth()' on a null object reference at com.example.photodiary.Diary.createPreviewSession(Diary.java:139) at com.example.photodiary.Diary.access$100(Diary.java:44) at com.example.photodiary.Diary$1.onClick(Diary.java:75) at android.view.View.performClick(View.java:7125) at com.google.android.material.button.MaterialButton.performClick(MaterialButton.java:1131) at android.view.View.performClickInternal(View.java:7102) at android.view.View.access$3500(View.java:801) at android.view.View$PerformClick.run(View.java:27336) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)
这是一个 Android 运行时错误,具体是在 `com.example.photodiary.Diary.createPreviewSession` 方法中的第 139 行,尝试在一个空对象引用上调用 `getWidth()` 方法。这意味着你需要检查代码中是否有一个 `null` 对象被错误地使用。你可以使用 Android Studio 的调试功能来逐步执行代码并查找问题所在。
阅读全文