throw error if inherited widget is not found in tree

This commit is contained in:
ashilkn 2022-10-10 19:21:54 +05:30
parent 08f81bab17
commit 7405a4097e
2 changed files with 5 additions and 4 deletions

View file

@ -4,6 +4,7 @@ import 'package:logging/logging.dart';
import 'package:photos/models/user_details.dart';
import 'package:photos/states/user_details_state.dart';
import 'package:photos/ui/common/loading_widget.dart';
// ignore: import_of_legacy_library_into_null_safe
import 'package:photos/ui/payment/subscription.dart';
import 'package:photos/utils/data_util.dart';
@ -42,11 +43,11 @@ class _DetailsSectionWidgetState extends State<DetailsSectionWidget> {
if (inheritedUserDetails == null) {
_logger.severe(
(InheritedUserDetails).toString() +
'not found before ' +
' not found before ' +
(_DetailsSectionWidgetState).toString() +
' on tree',
);
return const SizedBox.shrink();
throw Error();
} else {
return GestureDetector(
behavior: HitTestBehavior.translucent,

View file

@ -39,11 +39,11 @@ class SettingsTitleBarWidget extends StatelessWidget {
if (InheritedUserDetails.of(context) == null) {
logger.severe(
(InheritedUserDetails).toString() +
'not found before ' +
' not found before ' +
(SettingsTitleBarWidget).toString() +
' on tree',
);
return const SizedBox.shrink();
throw Error();
}
if (snapshot.hasData) {
final userDetails = snapshot.data as UserDetails;