improved performance and battery usage on older devices
This commit is contained in:
@@ -214,8 +214,11 @@ class ChatBackgroundSettingsPage extends StatelessWidget {
|
||||
final file = File(AppPaths.chatBackgroundImage);
|
||||
await file.writeAsBytes(bytes);
|
||||
// Same filename across replacements → the decoded image is cached under
|
||||
// an identical key. Evict so the new bytes actually show.
|
||||
await FileImage(file).evict();
|
||||
// an identical key (for "cover" also wrapped in a viewport-sized
|
||||
// ResizeImage). Clearing the cache is fine for this rare action.
|
||||
PaintingBinding.instance.imageCache
|
||||
..clear()
|
||||
..clearLiveImages();
|
||||
final cs = settings.val(write: true).chatBackgroundSettings;
|
||||
cs.imageVersion++;
|
||||
cs.type = ChatBackgroundType.image;
|
||||
|
||||
@@ -3,13 +3,13 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:hydrated_bloc/hydrated_bloc.dart';
|
||||
|
||||
import '../../../../api/cache_store.dart';
|
||||
import '../../../../routing/app_routes.dart';
|
||||
import '../../../../state/app/modules/settings/bloc/settings_cubit.dart';
|
||||
import '../../../../storage/dev_tools_settings.dart';
|
||||
import '../../../../storage/settings.dart' as model;
|
||||
import '../../../../widget/centered_leading.dart';
|
||||
import '../../../../widget/confirm_dialog.dart';
|
||||
import '../../../../widget/debug/cache_view.dart';
|
||||
import '../../../../widget/debug/json_viewer.dart';
|
||||
import '../../../../widget/details_bottom_sheet.dart';
|
||||
import '../widgets/endpoint_picker.dart';
|
||||
@@ -24,6 +24,9 @@ class DevToolsSection extends StatefulWidget {
|
||||
}
|
||||
|
||||
class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
// Kept across rebuilds: the size walk lists the whole cache directory.
|
||||
Future<int>? _cacheSize;
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) => Column(
|
||||
children: [
|
||||
@@ -153,7 +156,7 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
leading: const CenteredLeading(Icon(Icons.data_object)),
|
||||
title: const Text('Cache-storage JSON dump'),
|
||||
subtitle: FutureBuilder(
|
||||
future: const CacheView().totalSize(),
|
||||
future: _cacheSize ??= CacheStore.instance.totalSize(),
|
||||
builder: (context, snapshot) => Text(
|
||||
"etwa ${snapshot.hasError
|
||||
? "?"
|
||||
@@ -169,8 +172,9 @@ class _DevToolsSectionState extends State<DevToolsSection> {
|
||||
content:
|
||||
'Alle cache Einträge werden gelöscht. Der Cache wird bei Nutzung der App automatisch erneut aufgebaut',
|
||||
confirmButton: 'Unwiederruflich löschen',
|
||||
onConfirm: () =>
|
||||
const CacheView().clear().then((value) => setState(() {})),
|
||||
onConfirm: () => CacheStore.instance.clear().then(
|
||||
(value) => setState(() => _cacheSize = null),
|
||||
),
|
||||
).asDialog(context);
|
||||
},
|
||||
trailing: const Icon(Icons.arrow_right),
|
||||
|
||||
Reference in New Issue
Block a user