-
Notifications
You must be signed in to change notification settings - Fork 2
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
refactor: adjust proposal creation #375
Conversation
@@ -27,6 +28,13 @@ class _ProposalContentViewState extends State<ProposalContentView> { | |||
void initState() { | |||
super.initState(); | |||
|
|||
_titleController.text = context.read<ProposalCreationBloc>().state.proposal!.title ?? ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IMO any time there's a ! that's a bug.
Generally - there may be exceptions.
Decide if proposal is always defined - if it is always defined, make it non-optional, meaning, it will always be defined in the codebase and at static compile time.
If it is nullable - then use ? and deal with situations where it's null.
The entire point of the nullable / non-nullable architecture is to force developers to think whether something can be null. This prevents the most prevalent bug out there, the null pointer exception. Using "!" gets around the architecture and should be done only as an exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So in this case
Preferred solution is proposal is not nullable
Second best is use ? you're already handling this anyway in this code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resolve nullable question please
@@ -31,15 +31,15 @@ class ProposalReviewView extends StatelessWidget { | |||
child: IntrinsicHeight( | |||
child: BlocBuilder<ProposalCreationBloc, ProposalCreationState>( | |||
builder: (context, state) { | |||
final List<dynamic> jsonData = jsonDecode(state.proposal!.details!); | |||
final List<dynamic> jsonData = jsonDecode(state.proposal.details!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
details! is still an issue - but I don't want to hold up the PR over this.
I think it's always defined.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All proposal fields start as null except for type, which defaults to policy. As fields are progressively filled across views, they are all non-null by the review view.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved with comment
Scope
This PR focuses on optimizing the
ProposalCreationBloc
and ensuring that thekeyboard
is dismissed when navigating between views on theProposalCreationPage
.