简体   繁体   English

如何在 Flutter.. 中创建此 UI?

[英]How can I create this UI in Flutter..?

I want to implement this UI in flutter, how can I do it.. ?我想在 flutter 中实现这个 UI,我该怎么做..? I tried doing it using CustomPainter() class but I am not getting this type of finishing..?我尝试使用 CustomPainter() class 来做,但我没有得到这种类型的整理..?

用户界面图像

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.

相关问题 我如何在 Flutter 中将渐变颜色用于 backgroundColor 或其他正常颜色属性..? - How can i use a Gradient Color for a backgroundColor or other normal Color properties in Flutter..? 我对颤动的造型很不满意……该怎么办? - i am so bad with styling in flutter.. what to do? 如何为我的颤振 UI 创建这个圆圈? - How can I create this circles for my flutter UI? 如何在 flutter 中以排序方式从 firebase 数据库中检索数据。当我将其检索为 Map 时出现问题 - how to retrieve the data from firebase database in a sorted way in flutter.. something went wrong when I used retrieve it as Map 如何在 - Flutter 中创建此 Ui - How to create This Ui in - Flutter 如何为 flutter 中的矩阵制作 UI - How can I make UI for matrices in flutter 我如何在 flutter 中实现此时间线 Ui - How can i implement this Timeline Ui in flutter 我如何在 flutter 中实现此 UI - how i can achieve this UI in flutter 如何通过按下/点击 Flutter.. 中的按钮来调用提供商以及导航到其他页面? - How to call a provider as well as navigate to other page by pressing/tapping a button in Flutter..? Flutter.. 如何实现自定义应用栏 - 使用和重用 - Flutter.. How to implement a Custom App Bar - Usage and Re-Usage
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM