mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-21 23:10:40 +00:00
added conditions to films model updateShouldNotifyDependent
This commit is contained in:
parent
e29920b757
commit
e7512e47c2
2 changed files with 11 additions and 6 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
import 'package:collection/collection.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
import 'package:lightmeter/utils/context_utils.dart';
|
import 'package:lightmeter/utils/context_utils.dart';
|
||||||
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
import 'package:m3_lightmeter_iap/m3_lightmeter_iap.dart';
|
||||||
|
@ -113,8 +114,8 @@ class FilmsProviderState extends State<FilmsProvider> {
|
||||||
}
|
}
|
||||||
|
|
||||||
enum _FilmsModelAspect {
|
enum _FilmsModelAspect {
|
||||||
customFilmsList,
|
customFilms,
|
||||||
predefinedFilmsList,
|
predefinedFilms,
|
||||||
filmsInUse,
|
filmsInUse,
|
||||||
selected,
|
selected,
|
||||||
}
|
}
|
||||||
|
@ -134,7 +135,7 @@ class Films extends InheritedModel<_FilmsModelAspect> {
|
||||||
});
|
});
|
||||||
|
|
||||||
static List<Film> predefinedFilmsOf<T>(BuildContext context) {
|
static List<Film> predefinedFilmsOf<T>(BuildContext context) {
|
||||||
return InheritedModel.inheritFrom<Films>(context, aspect: _FilmsModelAspect.predefinedFilmsList)!
|
return InheritedModel.inheritFrom<Films>(context, aspect: _FilmsModelAspect.predefinedFilms)!
|
||||||
.predefinedFilms
|
.predefinedFilms
|
||||||
.values
|
.values
|
||||||
.map((value) => value.film)
|
.map((value) => value.film)
|
||||||
|
@ -142,7 +143,7 @@ class Films extends InheritedModel<_FilmsModelAspect> {
|
||||||
}
|
}
|
||||||
|
|
||||||
static List<FilmExponential> customFilmsOf<T>(BuildContext context) {
|
static List<FilmExponential> customFilmsOf<T>(BuildContext context) {
|
||||||
return InheritedModel.inheritFrom<Films>(context, aspect: _FilmsModelAspect.customFilmsList)!
|
return InheritedModel.inheritFrom<Films>(context, aspect: _FilmsModelAspect.customFilms)!
|
||||||
.customFilms
|
.customFilms
|
||||||
.values
|
.values
|
||||||
.map((value) => value.film)
|
.map((value) => value.film)
|
||||||
|
@ -168,7 +169,10 @@ class Films extends InheritedModel<_FilmsModelAspect> {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
bool updateShouldNotifyDependent(Films oldWidget, Set<_FilmsModelAspect> dependencies) {
|
bool updateShouldNotifyDependent(Films oldWidget, Set<_FilmsModelAspect> dependencies) {
|
||||||
// TODO: reduce unnecessary notifications
|
return (dependencies.contains(_FilmsModelAspect.selected) && oldWidget.selected != selected) ||
|
||||||
return true;
|
(dependencies.contains(_FilmsModelAspect.predefinedFilms) &&
|
||||||
|
const DeepCollectionEquality().equals(oldWidget.predefinedFilms, predefinedFilms)) ||
|
||||||
|
(dependencies.contains(_FilmsModelAspect.predefinedFilms) &&
|
||||||
|
const DeepCollectionEquality().equals(oldWidget.predefinedFilms, predefinedFilms));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ dependencies:
|
||||||
camera: 0.10.5+2
|
camera: 0.10.5+2
|
||||||
camera_android_camerax: 0.6.1+1
|
camera_android_camerax: 0.6.1+1
|
||||||
clipboard: 0.1.3
|
clipboard: 0.1.3
|
||||||
|
collection: any
|
||||||
dynamic_color: 1.7.0
|
dynamic_color: 1.7.0
|
||||||
exif: 3.1.4
|
exif: 3.1.4
|
||||||
firebase_analytics: 10.6.2
|
firebase_analytics: 10.6.2
|
||||||
|
|
Loading…
Reference in a new issue