- 引导页协议多语言支持(languageId传递) - 登录页双书名号修复 + 注册页协议勾选 - 个人中心页面多语言(18个翻译键) - 网络断开提示增加关闭/刷新按钮 - 了解我们:新增秋叶qy开发者 + ayk签名修改 + 贡献者精简 + 微风暴微信搜索 - iOS快捷按钮重复修复(删除Info.plist静态定义) - 测试账号123456警告提示 - 扫码登录自动跳转(HTTP轮询+WebSocket双通道) - 登录页老用户按钮改次要色 - Syncfusion图表崩溃修复(DeferredBuilder+animationDuration:0) - macOS标题栏跟随软件夜间模式 - 平台兼容分发渠道弹窗 - 软件著作权图片+交叉水印 - 桌面小部件平台兼容说明默认收起 - iOS/macOS图标更新+名称确认为闲言 - 12个语言文件补全roleNative+7个分发渠道翻译字段
49 lines
1.5 KiB
Dart
49 lines
1.5 KiB
Dart
/// ============================================================
|
||
/// 闲言APP — 延迟渲染包装组件
|
||
/// 创建时间: 2026-06-02
|
||
/// 更新时间: 2026-06-02
|
||
/// 作用: 将子组件(如syncfusion chart)延迟到postFrameCallback渲染
|
||
/// 避免chart在build阶段触发markNeedsLayout导致卡死/闪退
|
||
/// 内置RepaintBoundary隔离重绘,避免图表重绘波及父级
|
||
/// 上次更新: 增加RepaintBoundary隔离 + 可选placeholder + mounted安全检查
|
||
/// ============================================================
|
||
|
||
import 'package:flutter/widgets.dart';
|
||
|
||
class DeferredBuilder extends StatefulWidget {
|
||
const DeferredBuilder({
|
||
super.key,
|
||
required this.builder,
|
||
this.placeholder,
|
||
});
|
||
|
||
final WidgetBuilder builder;
|
||
|
||
/// 首帧占位组件,默认 SizedBox.expand() 填充父级约束
|
||
/// 对于有固定高度的图表区域,SizedBox.expand 会自动适配父级高度
|
||
final Widget? placeholder;
|
||
|
||
@override
|
||
State<DeferredBuilder> createState() => _DeferredBuilderState();
|
||
}
|
||
|
||
class _DeferredBuilderState extends State<DeferredBuilder> {
|
||
bool _ready = false;
|
||
|
||
@override
|
||
void initState() {
|
||
super.initState();
|
||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||
if (mounted) setState(() => _ready = true);
|
||
});
|
||
}
|
||
|
||
@override
|
||
Widget build(BuildContext context) {
|
||
if (!_ready) {
|
||
return widget.placeholder ?? const SizedBox.expand();
|
||
}
|
||
return RepaintBoundary(child: widget.builder(context));
|
||
}
|
||
}
|