gpt4 book ai didi

Flutter Custom Painter 和键盘问题

转载 作者:行者123 更新时间:2023-12-05 05:01:52 27 4
gpt4 key购买 nike

我创建了一个 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;
}
}

最佳答案

我猜你已经解决了这个问题,但为了以防万一其他人找到这篇文章,这里是解决方案。

return Scaffold(
**resizeToAvoidBottomInset: false,**
body: SafeArea(

该属性将避免移动。

关于Flutter Custom Painter 和键盘问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62519192/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com