fix: 切换时间周期不显示loading转圈

This commit is contained in:
2026-04-07 17:00:45 +08:00
parent b00e0390fb
commit bc8462cc52
3 changed files with 6336 additions and 6327 deletions

View File

@@ -37,6 +37,6 @@ _flutter.buildConfig = {"engineRevision":"e4b8dca3f1b4ede4c30371002441c88c12187e
_flutter.loader.load({
serviceWorkerSettings: {
serviceWorkerVersion: "1257193474" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
serviceWorkerVersion: "2949537379" /* Flutter's service worker is deprecated and will be removed in a future Flutter release. */
}
});

File diff suppressed because one or more lines are too long

View File

@@ -121,7 +121,7 @@ class ChartProvider extends ChangeNotifier {
void setSymbol(String symbol) {
if (_symbol != symbol) {
_symbol = symbol;
loadCandles();
loadCandles(); // 切换币种显示loading
}
}
@@ -129,7 +129,7 @@ class ChartProvider extends ChangeNotifier {
void setInterval(ChartInterval interval) {
if (_interval != interval) {
_interval = interval;
loadCandles();
loadCandles(showLoading: false); // 切换时间周期不显示loading
}
}
@@ -140,10 +140,12 @@ class ChartProvider extends ChangeNotifier {
}
/// 加载 K 线数据
Future<void> loadCandles() async {
_loading = true;
_error = null;
notifyListeners();
Future<void> loadCandles({bool showLoading = true}) async {
if (showLoading) {
_loading = true;
_error = null;
notifyListeners();
}
try {
// TODO: 对接真实 API
@@ -153,13 +155,19 @@ class ChartProvider extends ChangeNotifier {
// );
// 临时使用模拟数据
await Future.delayed(const Duration(milliseconds: 500));
await Future.delayed(const Duration(milliseconds: 300));
_candles = _generateMockCandles();
_loading = false;
notifyListeners();
if (showLoading) {
_loading = false;
notifyListeners();
} else {
notifyListeners();
}
} catch (e) {
_loading = false;
if (showLoading) {
_loading = false;
}
_error = e.toString();
notifyListeners();
}