【发布时间】:2020-06-22 16:31:40
【问题描述】:
我创建了一个 Painter 类,它应该在屏幕上绘制一条弧线,但当键盘聚焦在 TextField 上时它会升高。删除了 SingleChildScrollView 解决了这个问题,但它显示了 n 像素的溢出问题。还尝试了resizeToAvoidBottomInset,但它不会让我滚动查看所有字段。
这是一个快速预览: Custom Painter floats with the keyboard
页面类
return Scaffold(
body: SafeArea(
child: CustomPaint(
painter: SmallSunRiseCurvePainter(),
child: _isLoading
? Center(
child: MCircularProgressIndicator(),
)
: SingleChildScrollView(
child: Container(
width: size.width,
height: size.height,
child: Column(
crossAxisAlignment: CrossAxisAlignment.center,
children: [
SizedBox(height: 100),
_buildCreateNewAccountText(),
Padding(
padding: EdgeInsets.all(40),
child: Form(
key: registerFormKey,
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
_buildNameField(),
SizedBox(height: 40),
_buildEmailField(),
SizedBox(height: 40),
_buildSpecialKeyField(),
SizedBox(height: 40),
_buildPasswordField(),
SizedBox(height: 40),
_buildReEnterPasswordField(),
SizedBox(height: 60),
_buildRegisterButton(auth, context),
],
),
),
),
],
),
),
),
),
),
);
}
画家班
class SmallSunRiseCurvePainter extends CustomPainter {
@override
void paint(Canvas canvas, Size size) {
final paint = Paint();
paint.color = Color(AppConstants.yellowHex);
paint.style = PaintingStyle.fill;
final path = Path()
..moveTo(0, size.height * 0.95)
..quadraticBezierTo(
size.width * 0.5, size.height * 0.9, size.width, size.height * 0.95)
..lineTo(size.width, size.height)
..lineTo(0, size.height);
canvas.drawPath(path, paint);
}
@override
bool shouldRepaint(CustomPainter oldDelegate) {
return true;
}
}
【问题讨论】:
标签: flutter dart flutter-layout flutter-animation