Flutter 在BoxEdition图像上强制ClipRect
我想把我的图像做成圆形,但作为背景。问题是,ClipRect并没有做我认为它应该做的事情。我喜欢使用堆栈以外的解决方案,因为这样一来,根据列调整图像的大小将成为一个问题,因为图像比列大。多谢各位 编辑:所以,我很抱歉大家。似乎同事给我的图像是无意中填充的,因此边界不起作用。目前,我和我的同事已经修复了图像,现在一切正常。我是通过使用BoxFit.fill来实现这一点的,因此,如果有人偶然发现这一点,他们可能会想试试BoxFit.first来检查图像。Flutter 在BoxEdition图像上强制ClipRect,flutter,dart,flutter-layout,Flutter,Dart,Flutter Layout,我想把我的图像做成圆形,但作为背景。问题是,ClipRect并没有做我认为它应该做的事情。我喜欢使用堆栈以外的解决方案,因为这样一来,根据列调整图像的大小将成为一个问题,因为图像比列大。多谢各位 编辑:所以,我很抱歉大家。似乎同事给我的图像是无意中填充的,因此边界不起作用。目前,我和我的同事已经修复了图像,现在一切正常。我是通过使用BoxFit.fill来实现这一点的,因此,如果有人偶然发现这一点,他们可能会想试试BoxFit.first来检查图像。 取下你的阴蒂边框半径的装饰框足以实现这一
取下你的阴蒂<代码>边框半径的
装饰框
足以实现这一点
试试这个:
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
image: DecorationImage(
image: AssetImage(
'images/ic_blackbackground.png',
),
fit: BoxFit.cover,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
top: 24,
bottom: 16,
left: 24,
),
child: Text(
"Info Kios",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 16,
),
),
),
Container(
width: double.infinity,
height: 1,
color: Colors.white,
),
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Text(
'Nama Kios',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
),
Text(
widget._kurirPengambilanModel.pedagang.namaKios,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
],
),
Column(
children: [
Text(
'Nomor Kios',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
),
Text(
widget._kurirPengambilanModel.pedagang.nomorKios,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
],
)
],
),
),
],
),
),
);
}
}
import 'package:flutter/material.dart';
final Color darkBlue = Color.fromARGB(255, 18, 32, 47);
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.dark().copyWith(scaffoldBackgroundColor: darkBlue),
debugShowCheckedModeBanner: false,
home: Scaffold(
body: Center(
child: MyWidget(),
),
),
);
}
}
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Container(
child: DecoratedBox(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
image: DecorationImage(
image: AssetImage(
'images/ic_blackbackground.png',
),
fit: BoxFit.cover,
),
),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Padding(
padding: const EdgeInsets.only(
top: 24,
bottom: 16,
left: 24,
),
child: Text(
"Info Kios",
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.w700,
fontSize: 16,
),
),
),
Container(
width: double.infinity,
height: 1,
color: Colors.white,
),
Padding(
padding: const EdgeInsets.only(top: 20, bottom: 24),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Column(
children: [
Text(
'Nama Kios',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
),
Text(
widget._kurirPengambilanModel.pedagang.namaKios,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
],
),
Column(
children: [
Text(
'Nomor Kios',
style: TextStyle(
fontSize: 14,
fontWeight: FontWeight.w400,
color: Colors.white,
),
),
Text(
widget._kurirPengambilanModel.pedagang.nomorKios,
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w700,
color: Colors.white,
),
),
],
)
],
),
),
],
),
),
);
}
}