flutter - 如何在 Flutter 中的图像中添加波浪效果
解决方案
看一下这个!
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
primaryColor: const Color.fromARGB(255,0,0,255),
primaryColorDark: const Color(0xFF167F67),
accentColor: const Color(0xFF02BB9F),
),
home: MyHomePage(title: 'Flutter Clip Path',),
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.white,
appBar: AppBar(
title: Text(widget.title,style: TextStyle(color:Colors.white),),
),
body: Padding(
padding: const EdgeInsets.all(0.0),
child: ClipPath(
child: Container(
width: MediaQuery.of(context).size.width,
height: 400,
color: Colors.orange,
),
clipper: CustomClipPath(),
),
),
);
}
}
class CustomClipPath extends CustomClipper<Path> {
var radius=10.0;
@override
Path getClip(Size size) {
Path path = Path();
path.lineTo(0, size.height);
path.quadraticBezierTo(size.width/4, size.height
- 40, size.width/2, size.height-20);
path.quadraticBezierTo(3/4*size.width, size.height,
size.width, size.height-30);
path.lineTo(size.width, 0);
return path;
}
@override
bool shouldReclip(CustomClipper<Path> oldClipper) => false;
}
输出看起来像你的第一个屏幕,
推荐阅读
- python - 从数据集 Python 中获取缺失的日期时间 - 数据系列
- javascript - 网络说 Dom 内容已加载。Console.log 不记录到开发者控制台。调试器没有命中。未调用函数
- scikit-learn - 升级的 sklearn 使我之前的 onehotencoder 无法转换
- java - JAVA 序列化和反序列化:在一个文件下有自己的数组列表的两个独立对象
- android - 如何在recyclerview中显示所有复选框?
- sql - 如何将 UNIX 纪元日转换为 Snowflake 中的 DATE?
- wavesplatform - 如何从其他 Waves Oracle 读取数据?
- pentaho - 如何用百万个寄存器在 Pentaho 中搜索寄存器
- sql - postgres SQL 中的函数
- python - 如何使用复杂的条件以有效的方式在熊猫中逐列填充?