android - 如何在 Flutter 中创建这种形状?
解决方案
您可以使用 Stack 小部件,并将其作为其子元素的 Positioned 小部件,其中包含一个带有圆圈的容器,之后您可以将圆圈推出屏幕,以便只渲染它的一部分
class _MyAppState extends State<MyApp> {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: MyApp._title,
home: Scaffold(
body: Column(
children: [
CircleCorner(),
],
)),
);
}
}
class CircleCorner extends StatelessWidget {
const CircleCorner({
Key? key,
}) : super(key: key);
@override
Widget build(BuildContext context) {
Size size = MediaQuery.of(context).size;
return SizedBox(
width: size.width,
height: 300,
child: Stack(
children: [
Positioned(
top: -460,
right: -380,
child: Container(
width: 600.0,
height: 600.0,
decoration: new BoxDecoration(
color: Colors.black87,
shape: BoxShape.circle,
),
),
),
],
),
);
}
}
推荐阅读
- delphi - 在 TTimer 事件中重命名文件会产生错误
- html - 如何构造 HTML/CSS 以允许根据屏幕大小在图像旁边和下方响应式显示文本
- odoo-11 - 我可以在笔记本/页面中设置字段的默认查看模式吗
- sed - sed:替换'-'之前的字符
- android - 如何使用双簧管在多声道音频应用程序中获得更小的缓冲区大小
- jsonpath - 如何使用 JSON 选择其中包含 () 的元素
- jmeter - Jmeter 5.1.1 中不存在侦听器“监控结果”
- javascript - 当模式框关闭时,如何将我的复选框重置为未选中?
- php - Laravel:ErrorException(E_ERROR)试图获取非对象的属性(查看:..../show.blade.php)
- python-3.x - Python请求http.client.RemoteDisconnected:远程结束关闭连接没有响应:(