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

refactor: adjust proposal creation #375

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

Zied-Dahmani
Copy link
Collaborator

Scope

This PR focuses on optimizing the ProposalCreationBloc and ensuring that the keyboard is dismissed when navigating between views on the ProposalCreationPage.

@Zied-Dahmani Zied-Dahmani requested a review from n13 November 20, 2024 15:14
@Zied-Dahmani Zied-Dahmani self-assigned this Nov 20, 2024
@@ -27,6 +28,13 @@ class _ProposalContentViewState extends State<ProposalContentView> {
void initState() {
super.initState();

_titleController.text = context.read<ProposalCreationBloc>().state.proposal!.title ?? '';
Copy link
Collaborator

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.

Copy link
Collaborator

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

Copy link
Collaborator

@n13 n13 left a 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

@Zied-Dahmani Zied-Dahmani requested a review from n13 November 21, 2024 10:01
@@ -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!);
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@n13 n13 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with comment

@Zied-Dahmani Zied-Dahmani merged commit 242655f into main Nov 25, 2024
0 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants