Minor perf improvements (#1112)
This commit is contained in:
commit
6b78ba8d05
2 changed files with 15 additions and 3 deletions
|
@ -1,3 +1,4 @@
|
|||
import "dart:async";
|
||||
import "dart:io";
|
||||
|
||||
import "package:flutter/cupertino.dart";
|
||||
|
@ -56,6 +57,7 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
|
|||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
_pageController ??= PageController(initialPage: _index);
|
||||
final file = widget.memories[_index].file;
|
||||
return Scaffold(
|
||||
appBar: AppBar(
|
||||
|
@ -140,6 +142,12 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
|
|||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController?.dispose();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
Future<void> onFileDeleted(Memory removedMemory) async {
|
||||
if (!mounted) {
|
||||
return;
|
||||
|
@ -268,7 +276,6 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
|
|||
}
|
||||
|
||||
Widget _buildSwiper() {
|
||||
_pageController = PageController(initialPage: _index);
|
||||
return ExtentsPageView.extents(
|
||||
itemBuilder: (BuildContext context, int index) {
|
||||
if (index < widget.memories.length - 1) {
|
||||
|
@ -294,7 +301,9 @@ class _FullScreenMemoryState extends State<FullScreenMemory> {
|
|||
itemCount: widget.memories.length,
|
||||
controller: _pageController,
|
||||
onPageChanged: (index) async {
|
||||
await MemoriesService.instance.markMemoryAsSeen(widget.memories[index]);
|
||||
unawaited(
|
||||
MemoriesService.instance.markMemoryAsSeen(widget.memories[index]),
|
||||
);
|
||||
if (mounted) {
|
||||
setState(() {
|
||||
_index = index;
|
||||
|
|
|
@ -77,16 +77,17 @@ class _DetailPageState extends State<DetailPage> {
|
|||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
_files = [
|
||||
...widget.config.files
|
||||
]; // Make a copy since we append preceding and succeeding entries to this
|
||||
_selectedIndex = widget.config.selectedIndex;
|
||||
_preloadEntries();
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_pageController?.dispose();
|
||||
SystemChrome.setEnabledSystemUIMode(
|
||||
SystemUiMode.manual,
|
||||
overlays: SystemUiOverlay.values,
|
||||
|
@ -140,6 +141,8 @@ class _DetailPageState extends State<DetailPage> {
|
|||
|
||||
Widget _buildPageView() {
|
||||
_logger.info("Building with " + _selectedIndex.toString());
|
||||
// todo: perf.. fix this
|
||||
_pageController?.dispose();
|
||||
_pageController = PageController(initialPage: _selectedIndex);
|
||||
return PageView.builder(
|
||||
itemBuilder: (context, index) {
|
||||
|
|
Loading…
Add table
Reference in a new issue