remove using context only after init of widget is complete, can use context during init
This commit is contained in:
parent
fd8bd9accd
commit
acbf3baa80
|
@ -1,7 +1,6 @@
|
|||
import "dart:async";
|
||||
|
||||
import "package:flutter/material.dart";
|
||||
import "package:flutter/scheduler.dart";
|
||||
import "package:logging/logging.dart";
|
||||
import "package:photos/core/constants.dart";
|
||||
import "package:photos/core/event_bus.dart";
|
||||
|
@ -37,13 +36,11 @@ class _AllSectionsExamplesProviderState
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
SchedulerBinding.instance.addPostFrameCallback((timeStamp) {
|
||||
//add all common events for all search sections to reload to here.
|
||||
_filesUpdatedEvent = Bus.instance.on<FilesUpdatedEvent>().listen((event) {
|
||||
reloadAllSections();
|
||||
});
|
||||
//add all common events for all search sections to reload to here.
|
||||
_filesUpdatedEvent = Bus.instance.on<FilesUpdatedEvent>().listen((event) {
|
||||
reloadAllSections();
|
||||
});
|
||||
reloadAllSections();
|
||||
}
|
||||
|
||||
void reloadAllSections() {
|
||||
|
|
|
@ -30,6 +30,8 @@ class _SearchSectionAllPageState extends State<SearchSectionAllPage> {
|
|||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
sectionData = widget.sectionType.getData(context);
|
||||
|
||||
final streamsToListenTo = widget.sectionType.viewAllUpdateEvents();
|
||||
for (Stream<Event> stream in streamsToListenTo) {
|
||||
streamSubscriptions.add(
|
||||
|
@ -42,12 +44,6 @@ class _SearchSectionAllPageState extends State<SearchSectionAllPage> {
|
|||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void didChangeDependencies() {
|
||||
super.didChangeDependencies();
|
||||
sectionData = widget.sectionType.getData(context);
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
for (var subscriptions in streamSubscriptions) {
|
||||
|
|
Loading…
Reference in a new issue