fix: 彻底修复 flow-anim.dart Obx 嵌套导致的页面卡死
- 移除 FlowingBorderContainer 内部的 Obx 和 ThemeController - FlowingBorderContainer 不再自行监听主题色变化 - 颜色通过 widget.color 参数从外部传入 - poetry.dart 中传入 primaryColor 变量 - 避免 Obx 嵌套导致的 GetX 异常
This commit is contained in:
@@ -1,9 +1,7 @@
|
||||
import 'dart:math';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:get/get.dart';
|
||||
|
||||
import '../../../services/get/theme_controller.dart';
|
||||
import '../../../models/colors/theme_colors.dart';
|
||||
|
||||
/// 流动边框装饰器
|
||||
@@ -84,7 +82,6 @@ class _FlowingBorderContainerState extends State<FlowingBorderContainer>
|
||||
with SingleTickerProviderStateMixin {
|
||||
late AnimationController _controller;
|
||||
late Animation<double> _animation;
|
||||
final ThemeController _themeController = Get.find<ThemeController>();
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -111,21 +108,15 @@ class _FlowingBorderContainerState extends State<FlowingBorderContainer>
|
||||
return AnimatedBuilder(
|
||||
animation: _animation,
|
||||
builder: (context, child) {
|
||||
return Obx(() {
|
||||
final color =
|
||||
widget.color ??
|
||||
ThemeColors.getThemeColor(_themeController.themeColorIndexRx.value);
|
||||
|
||||
return Container(
|
||||
padding: EdgeInsets.all(widget.width),
|
||||
decoration: FlowingBorderDecoration(
|
||||
animation: _animation,
|
||||
color: color,
|
||||
width: widget.width,
|
||||
),
|
||||
child: widget.child,
|
||||
);
|
||||
});
|
||||
return Container(
|
||||
padding: EdgeInsets.all(widget.width),
|
||||
decoration: FlowingBorderDecoration(
|
||||
animation: _animation,
|
||||
color: widget.color ?? ThemeColors.getThemeColor(0),
|
||||
width: widget.width,
|
||||
),
|
||||
child: widget.child,
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user