这是我设计的第一个屏幕,使用剪贴画曲线图,我滚动我的内容在曲线开始之前消失,2n屏幕显示。
在2n屏幕上,当我滚动它时,应用内容在曲线开始之前消失了,我想要在剪辑路径曲线开始的地方实现消失的应用程序内容。
颤振信息:
颤振(频道稳定,2.10.4,在Microsoft版本10.0.19044.1586,locale en-US)·颤振版本2.10.4在C:\颤振开发\颤振·上游存储库https://github.com/flutter/flutter.git·框架修订c860cba910 (2周前),2022-03-25 00:23:12-0500·Engine修订版57 d3bac3dd·Dart版本2.16.2·DevTools版本2.9.2
发布于 2022-04-08 06:58:27
由于您没有提供代码,所以我无法指出问题所在。我为您的问题编写了这个演示,使用Stack和CustomPaint在您的身体上方创建曲线。希望能帮上忙。
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
static const String _title = 'Flutter Code Sample';
@override
Widget build(BuildContext context) {
return MaterialApp(
title: _title,
home: Scaffold(
appBar: AppBar(title: const Text(_title), elevation: 0),
body: Stack(children: [
ListView(
children: List.generate(
100,
(i) {
return ListTile(
title: Text(
'item $i',
textAlign: TextAlign.center,
),
);
},
),
),
Positioned(
top: 0,
left: 0,
right: 0,
height: 100,
child: CustomPaint(
painter: ShapePainter(),
child: Container(),
),
),
]),
),
);
}
}
class ShapePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
var path = Path();
path.moveTo(0, 0);
path.lineTo(size.width, 0);
path.lineTo(size.width, size.height);
path.arcToPoint(
Offset(0, size.height),
radius: Radius.circular(size.width * 0.7),
clockwise: false,
);
path.close();
var paint = Paint();
paint.color = Colors.blue;
paint.style = PaintingStyle.fill;
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) => true;
},这是结果

发布于 2022-04-08 08:23:26
appBar: PreferredSize(首选尺寸: const Size.fromHeight(220) ),子: ClipPath(裁剪器: CustomAppBarClipper(),子容器:容器(颜色: LightColor.appBackground,高度: 220,填充:const EdgeInsets.only(顶部: 60,左: 20,右: 20),孩子: AppBar( const主题:const IconThemeData(颜色: LightColor.baseColor,//在这里更改颜色),领导:(ModalRoute.of(上下文)?.canPop?假的)?const BackButton():null,excludeHeaderSemantics: true,标题:const Text(‘蜜獾’,样式: TextStyle(颜色: Colors.redAccent,fontSize: 24,fontWeight: FontWeight.bold),backgroundColor: Colors.transparent,海拔:0,
),
),
),
),https://stackoverflow.com/questions/71792426
复制相似问题