Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Region Create Error #1914

Open
n13 opened this issue Jun 28, 2022 · 0 comments · Fixed by #1915
Open

Region Create Error #1914

n13 opened this issue Jun 28, 2022 · 0 comments · Fixed by #1915
Assignees
Labels
bug Something isn't working

Comments

@n13
Copy link
Member

n13 commented Jun 28, 2022

Describe the bug
A clear and concise description of what the bug is.

To Reproduce
Steps to reproduce the behavior:

  1. Create a region

Current behavior
Crash

Expected behavior
No crash

Analysis

These two getters are incorrect.

  Stream<List<RegionMessageModel>> get regionMessages => _firebaseRepository.getMessagesForRegion(state.region!.id);

  Stream<List<RegionEventModel>> get regionEvents => _firebaseRepository.getEventsForRegion(state.region!.id);

state.region can be null - so this crashes when region is null.

I don't know why region is null here, but the way to fix it is

  • Either make the state.region never be null (not nullable)
    Or
  • Deal with it being null here

I was not sure which is better in this case, since it seems that what needs to happen is that this view shows at some point with the region being == null, then later updates with the region != null.

I did not look into why region was null there, but the fundamental problem is forcing the nullable - this is a logical error in the code. Either it can't be null - or it can be and needs to be dealt with.

@RaulUrtecho to investigate.

Screenshots
Simulator Screen Shot - iPhone 8 Plus - 2022-06-28 at 11 34 14

Platform & App Version

  • iOS

Additional context

flutter: Transition { currentState: TransactionsListState(null, PageState.failure, [TransactionModel(a354a8f353c82bcfe6eb87de3c2f27bbfdb7b5e89bffbaf7182f4f27959a68d5), TransactionModel(6e9b98425790257729162ca49fed3c3f1f58deb6e897dabd2fa94eafac791a91), TransactionModel(f7ed44123f8db24075879caf7a481776faf2cff0db9552e522f4726632da6b53), TransactionModel(f7ed44123f8db24075879caf7a481776faf2cff0db9552e522f4726632da6b53), TransactionModel(50b21b8058cb99b346a7426921cb38873665adf606dd329e374dfab7aca4c535), TransactionModel(40e2c9cee66340ed9bb1d3d6d58338e480802746c91ee539e865e81fcc0ecd11), TransactionModel(40e2c9cee66340ed9bb1d3d6d58338e480802746c91ee539e865e81fcc0ecd11), TransactionModel(53ac57dce601ba869d31bafcfe37acb7e104fb22550013a1d81da895a1d0c497), TransactionModel(53ac57dce601ba869d31bafcfe37acb7e104fb22550013a1d81da895a1d0c497), TransactionModel(56a76443b69ff704c9c06a33bd22658bc21a432c814e6971aeacaee30370f0d8), TransactionModel(a7be3ad974a0e91a14487f8512aa8c8765e68b171ea7d80b120e95f2ff887a85), T<…>
flutter: mapEosResponse - transaction id: 746210ba962428195101526eb05f3e9f63bc3791b8f4096f610b270d64be58a2
flutter: Model Class: Closure: (dynamic) => TransactionResponse
flutter: Transaction ID: 746210ba962428195101526eb05f3e9f63bc3791b8f4096f610b270d64be58a2
flutter: Transition { currentState: CreateRegionState(PageState.loading, null, CreateRegionScreen.reviewRegion, The Metaverse, The Metaverse. A virtual Region. , File: '/Users/elohim/Library/Developer/CoreSimulator/Devices/482A42C3-DF3A-47B3-B0B9-C3A096D396EF/data/Containers/Data/Application/B98F95FD-9BC7-4DEB-8AED-C7294994ED29/tmp/image_cropper_432C1643-3C6D-46F5-B372-5EDC70D44299-87501-00013DCA905C4AE7.jpg', https://firebasestorage.googleapis.com/v0/b/seeds-77371.appspot.com/o/regionImage%2Fthemetav%2Fa941ad9f-aa98-4e14-9cbb-7c0023f2a29a%20%20.jpg?alt=media&token=f82cecb2-fd42-4ded-8168-e64e35efef8b, PictureBoxState.imagePicked, themetav, null, Instance of 'Place', RegionIdStatusIcon.valid, false, false), event: onCreateRegionTapped, nextState: CreateRegionState(PageState.success, Instance of 'NavigateToRoute', CreateRegionScreen.reviewRegion, The Metaverse, The Metaverse. A virtual Region. , File: '/Users/elohim/Library/Developer/CoreSimulator/Devices/482A42C3-DF3A-47B3-B0B9-C3A096D396EF/dat<…>

flutter: Transition { currentState: CreateRegionState(PageState.success, Instance of 'NavigateToRoute', CreateRegionScreen.reviewRegion, The Metaverse, The Metaverse. A virtual Region. , File: '/Users/elohim/Library/Developer/CoreSimulator/Devices/482A42C3-DF3A-47B3-B0B9-C3A096D396EF/data/Containers/Data/Application/B98F95FD-9BC7-4DEB-8AED-C7294994ED29/tmp/image_cropper_432C1643-3C6D-46F5-B372-5EDC70D44299-87501-00013DCA905C4AE7.jpg', https://firebasestorage.googleapis.com/v0/b/seeds-77371.appspot.com/o/regionImage%2Fthemetav%2Fa941ad9f-aa98-4e14-9cbb-7c0023f2a29a%20%20.jpg?alt=media&token=f82cecb2-fd42-4ded-8168-e64e35efef8b, PictureBoxState.imagePicked, themetav, null, Instance of 'Place', RegionIdStatusIcon.valid, false, false), event: clearCreateRegionPageCommand , nextState: CreateRegionState(PageState.success, null, CreateRegionScreen.reviewRegion, The Metaverse, The Metaverse. A virtual Region. , File: '/Users/elohim/Library/Developer/CoreSimulator/Devices/482A42C3-DF3A-47B3-B0B9-C3A096D<…>
flutter: OnRegionMounted

The following _CastError was thrown building BlocBuilder<RegionBloc, RegionState>(dirty, dependencies: [_InheritedProviderScope<RegionBloc?>], state: _BlocBuilderBaseState<RegionBloc, RegionState>#9d893):
Null check operator used on a null value

The relevant error-causing widget was
BlocBuilder<RegionBloc, RegionState>
package:seeds/…/components/region_events.dart:14
When the exception was thrown, this was the stack
#0 RegionBloc.regionEvents
package:seeds/…/viewmodel/region_bloc.dart:53
#1 RegionEvents.build.
package:seeds/…/components/region_events.dart:26
#2 BlocBuilder.build
package:flutter_bloc/src/bloc_builder.dart:90
#3 _BlocBuilderBaseState.build
package:flutter_bloc/src/bloc_builder.dart:166
#4 StatefulElement.build
package:flutter/…/widgets/framework.dart:4919
#5 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4806
#6 StatefulElement.performRebuild
package:flutter/…/widgets/framework.dart:4977
#7 Element.rebuild
package:flutter/…/widgets/framework.dart:4529
#8 ComponentElement._firstBuild
package:flutter/…/widgets/framework.dart:4787
#9 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:4968
#10 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4781
... Normal element mounting (45 frames)

Add any other context about the problem here.
#128 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#129 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#130 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#131 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#132 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#133 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#134 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#135 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#136 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#137 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#138 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#139 RenderOffstage.performLayout
package:flutter/…/rendering/proxy_box.dart:3460
#140 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#141 RenderProxyBoxMixin.performLayout
package:flutter/…/rendering/proxy_box.dart:116
#142 RenderObject.layout
package:flutter/…/rendering/object.dart:1915
#143 _RenderTheatre.performLayout
package:flutter/…/widgets/overlay.dart:749
#144 RenderObject._layoutWithoutResize
package:flutter/…/rendering/object.dart:1757
#145 PipelineOwner.flushLayout
package:flutter/…/rendering/object.dart:887
#146 RendererBinding.drawFrame
package:flutter/…/rendering/binding.dart:504
#147 WidgetsBinding.drawFrame
package:flutter/…/widgets/binding.dart:892
#148 SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1146
#149 SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1083
#153 _invoke (dart:ui/hooks.dart:151:10)
#154 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:308:5)
#155 _drawFrame (dart:ui/hooks.dart:115:31)
(elided 3 frames from dart:async)
════════════════════════════════════════════════════════════════════════════════

flutter: Transition { currentState: TransactionsListState(null, PageState.failure, [TransactionModel(a354a8f353c82bcfe6eb87de3c2f27bbfdb7b5e89bffbaf7182f4f27959a68d5), TransactionModel(6e9b98425790257729162ca49fed3c3f1f58deb6e897dabd2fa94eafac791a91), TransactionModel(f7ed44123f8db24075879caf7a481776faf2cff0db9552e522f4726632da6b53), TransactionModel(f7ed44123f8db24075879caf7a481776faf2cff0db9552e522f4726632da6b53), TransactionModel(50b21b8058cb99b346a7426921cb38873665adf606dd329e374dfab7aca4c535), TransactionModel(40e2c9cee66340ed9bb1d3d6d58338e480802746c91ee539e865e81fcc0ecd11), TransactionModel(40e2c9cee66340ed9bb1d3d6d58338e480802746c91ee539e865e81fcc0ecd11), TransactionModel(53ac57dce601ba869d31bafcfe37acb7e104fb22550013a1d81da895a1d0c497), TransactionModel(53ac57dce601ba869d31bafcfe37acb7e104fb22550013a1d81da895a1d0c497), TransactionModel(56a76443b69ff704c9c06a33bd22658bc21a432c814e6971aeacaee30370f0d8), TransactionModel(a7be3ad974a0e91a14487f8512aa8c8765e68b171ea7d80b120e95f2ff887a85), T<…>
flutter: OnTick
flutter: Transition { currentState: TransactionsListState(null, PageState.failure, [TransactionModel(a354a8f353c82bcfe6eb87de3c2f27bbfdb7b5e89bffbaf7182f4f27959a68d5), TransactionModel(6e9b98425790257729162ca49fed3c3f1f58deb6e897dabd2fa94eafac791a91), TransactionModel(f7ed44123f8db24075879caf7a481776faf2cff0db9552e522f4726632da6b53), TransactionModel(f7ed44123f8db24075879caf7a481776faf2cff0db9552e522f4726632da6b53), TransactionModel(50b21b8058cb99b346a7426921cb38873665adf606dd329e374dfab7aca4c535), TransactionModel(40e2c9cee66340ed9bb1d3d6d58338e480802746c91ee539e865e81fcc0ecd11), TransactionModel(40e2c9cee66340ed9bb1d3d6d58338e480802746c91ee539e865e81fcc0ecd11), TransactionModel(53ac57dce601ba869d31bafcfe37acb7e104fb22550013a1d81da895a1d0c497), TransactionModel(53ac57dce601ba869d31bafcfe37acb7e104fb22550013a1d81da895a1d0c497), TransactionModel(56a76443b69ff704c9c06a33bd22658bc21a432c814e6971aeacaee30370f0d8), TransactionModel(a7be3ad974a0e91a14487f8512aa8c8765e68b171ea7d80b120e95f2ff887a85), T<…>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants