[英]How can I create this UI in Flutter..?
You have to use some sort of mathematics to achieve this kind of output along with flutters custompaint().您必须使用某种数学来实现这种 output 以及颤振 custompaint()。 You can find a detailed explanation on how to use the axis values to draw curves and shapes here, Paths in flutter and here, Drawing Custom Shapes
您可以在此处找到有关如何使用轴值绘制曲线和形状的详细说明,flutter 中的路径和此处, 绘制自定义形状
I have applied somewhat similar curves in one of my application.我在我的一个应用程序中应用了一些类似的曲线。 Below is the code.
下面是代码。
Class file Class 文件
import 'package:flutter/material.dart';
class CurvePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var paint = Paint();
paint.color = Colors.indigo[50];
paint.style = PaintingStyle.fill;
var path = Path();
path.lineTo(0.0, size.height - 20);
var firstControlPoint = Offset(size.width / 4, size.height);
var firstEndPoint = Offset(size.width / 2.25, size.height - 30.0);
path.quadraticBezierTo(firstControlPoint.dx, firstControlPoint.dy,
firstEndPoint.dx, firstEndPoint.dy);
var secondControlPoint =
Offset(size.width - (size.width / 3.25), size.height - 65);
var secondEndPoint = Offset(size.width, size.height - 40);
path.quadraticBezierTo(secondControlPoint.dx, secondControlPoint.dy,
secondEndPoint.dx, secondEndPoint.dy);
path.lineTo(size.width, size.height - 40);
path.lineTo(size.width, 0.0);
path.close();
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
Then in file you want to apply, you can use然后在您要申请的文件中,您可以使用
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Container(
height: MediaQuery.of(context).size.height / 3,
child: CustomPaint(
painter: CurvePainter(),
child: <other widgets>
),
),
);
You can use the link above to understand how paths and curves can be drawn.您可以使用上面的链接来了解如何绘制路径和曲线。 Also with the example code above you can understand the use of such curves in flutter app.
同样通过上面的示例代码,您可以了解在 flutter 应用程序中使用此类曲线。
Best wishes !!!最好的祝愿 !!!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.