mirror of
https://github.com/vodemn/m3_lightmeter.git
synced 2024-11-24 00:10:47 +00:00
fixed MeteringScreenLayout
This commit is contained in:
parent
abf55b3413
commit
0daa689c01
1 changed files with 28 additions and 1 deletions
|
@ -3,7 +3,34 @@ import 'package:lightmeter/data/models/metering_screen_layout_config.dart';
|
||||||
import 'package:lightmeter/data/shared_prefs_service.dart';
|
import 'package:lightmeter/data/shared_prefs_service.dart';
|
||||||
import 'package:lightmeter/utils/inherited_generics.dart';
|
import 'package:lightmeter/utils/inherited_generics.dart';
|
||||||
|
|
||||||
typedef MeteringScreenLayout = InheritedModelBase<MeteringScreenLayoutFeature, bool>;
|
class MeteringScreenLayout extends InheritedModelBase<MeteringScreenLayoutFeature, bool> {
|
||||||
|
const MeteringScreenLayout({
|
||||||
|
required super.data,
|
||||||
|
required super.child,
|
||||||
|
super.key,
|
||||||
|
});
|
||||||
|
|
||||||
|
static MeteringScreenLayoutConfig of(BuildContext context, {bool listen = true}) {
|
||||||
|
if (listen) {
|
||||||
|
return context
|
||||||
|
.dependOnInheritedWidgetOfExactType<
|
||||||
|
InheritedModelBase<MeteringScreenLayoutFeature, bool>>()!
|
||||||
|
.data;
|
||||||
|
} else {
|
||||||
|
return context
|
||||||
|
.findAncestorWidgetOfExactType<InheritedModelBase<MeteringScreenLayoutFeature, bool>>()!
|
||||||
|
.data;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool featureOf(BuildContext context, MeteringScreenLayoutFeature aspect) {
|
||||||
|
return InheritedModel.inheritFrom<InheritedModelBase<MeteringScreenLayoutFeature, bool>>(
|
||||||
|
context,
|
||||||
|
aspect: aspect,
|
||||||
|
)!
|
||||||
|
.data[aspect]!;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class MeteringScreenLayoutProvider extends StatefulWidget {
|
class MeteringScreenLayoutProvider extends StatefulWidget {
|
||||||
final Widget child;
|
final Widget child;
|
||||||
|
|
Loading…
Reference in a new issue