Флаттер: состояние обновляется, даже если изменения, внесенные в состояние из диалогового окна, не перенаправляются в него

#flutter #dart

Вопрос:

В настоящее время я разрабатываю проект, в котором я передаю Listlt;CertificateOfAttendanceDetailsLogListEntitygt; диалог, подобный

 showDialog(  context: context,  useSafeArea: false,  builder: (context) =gt; CertificateOfAttendanceDateBreakdownPage(  calendarParams: _pageState.calendarParams,  logs: _pageState.logs, lt; --- Passing this to the page  ),  ).then((value) {  if (value == null) return;  if (value is bool amp;amp; value == true) return;  if (value is! Listlt;CertificateOfAttendanceDetailsLogListEntitygt;) return;   _bloc.add(OnDateBreakdownLogsChangedEvent(  value,  calendarParams: _pageState.calendarParams,  ));  });  

В настоящее _pageState.logs время хранится внутри вводимого состояния страницы, например:

 @injectable class CertificateOfAttendanceFormPageState {  Listlt;CertificateOfAttendanceDetailsLogListEntitygt; logs = [];  CertificateOfAttendanceCalendarParams calendarParams =  CertificateOfAttendanceCalendarParams(); }  

Теперь принятие государства _pageState.logs CertificateOfAttendanceDateBreakdownPage похоже на

 class CertificateOfAttendanceDateBreakdownPage extends StatefulWidget {  final Listlt;CertificateOfAttendanceDetailsLogListEntitygt; logs;  final CertificateOfAttendanceCalendarParams calendarParams;  const CertificateOfAttendanceDateBreakdownPage({  Key? key,  required this.logs,  required this.calendarParams,  }) : super(key: key);   @override  _CertificateOfAttendanceDateBreakdownPageState createState() =gt;  _CertificateOfAttendanceDateBreakdownPageState(); }  class _CertificateOfAttendanceDateBreakdownPageState  extends Statelt;CertificateOfAttendanceDateBreakdownPagegt; {  final CertificateOfAttendanceDateBreakdownBloc _bloc =  CertificateOfAttendanceDateBreakdownBloc();  final _appLocalizations = GetIt.Ilt;AppLocalizationsgt;();  final _pageState = GetIt.Ilt;CertificateOfAttendanceDateBreakdownPageStategt;();   bool maximumLogs = false,  minimumLogs = false,  commonState = false,  isDoneButtonDisabled = true;   @override  void initState() {  _pageState.calendarParams = widget.calendarParams;  _pageState.logs = [];  super.initState();  }   @override  void didChangeDependencies() {  _pageState.calendarParams = widget.calendarParams;  _pageState.logs = widget.logs; lt;--- I am giving the state from the origin to this local page state  super.didChangeDependencies();  }   @override  void dispose() {  _bloc.close();  super.dispose();  }  

Now CertificateOfAttendanceDateBreakdownPage has its own Injectable Page state CertificateOfAttendanceDateBreakdownPageState

 @injectable class CertificateOfAttendanceDateBreakdownPageState {  late Listlt;CertificateOfAttendanceDetailsLogListEntitygt; _logs;  Listlt;CertificateOfAttendanceDetailsLogListEntitygt; get logs =gt; _logs;  set logs(Listlt;CertificateOfAttendanceDetailsLogListEntitygt; logs) {  _logs = logs;  }   late CertificateOfAttendanceCalendarParams _calendarParams;  CertificateOfAttendanceCalendarParams get calendarParams =gt; _calendarParams;  set calendarParams(CertificateOfAttendanceCalendarParams calendarParams) {  _calendarParams = calendarParams;  } }  

On the CertificateOfAttendanceDateBreakdownPage I am passing the logs from the origin page to it.

The problem is when I try to modify the _pageState.logs on the CertificateOfAttendanceDateBreakdownPage by doing setState((){}); and then hitting off a Navigator.of(context).pop(null); .

The changes from CertificateOfAttendanceDateBreakdownPage is being recognized by the origin page even when a condition is already applied if the value is null the corresponding Page State should not be modified.

This is the entity class of CertificateOfAttendanceDetailsLogListEntity

 class CertificateOfAttendanceDetailsLogListEntity extends Equatable {  final DateTime date;  final Listlt;CertificateOfAttendanceDetailsLogEntitygt; details;   const CertificateOfAttendanceDetailsLogListEntity({  required this.date,  required this.details,  });   @override  Listlt;Object?gt; get props =gt; [date, details]; }  

Где я ошибся?