由于您没有提供代码,我无法指出问题所在。我用
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;
}
这就是结果