Skip to main content
7 votes
Accepted

OOP Pac-man game

In these situations, I like to use a mix of the strategy pattern and the chain of command pattern. I define an interface with two methods: a predicate whose boolean result tells me if the strategy is ...
alexanderbird's user avatar
6 votes

OOP Pac-man game

I don't think that rule should be followed that strictly. Usually it's just meant as a hint to use the Strategy pattern, instead of putting lots of different logic in one if structure. But here you ...
Double_A's user avatar
  • 101
6 votes
Accepted

Search filter for words in dart

I have tried make a more optimized version here which also will work for string of any sizes and any number of words: ...
julemand101's user avatar
4 votes

Flutter - Implementing a simple ListView with MVVM

I'm not sure if this is helpful, but this is some feedback: PrepStep shouldn't have a static int id because that will be a class-...
chongman's user avatar
  • 141
4 votes

Dart Non-Reentrant Async Lock

Error Handling: The locked method will retry indefinitely if retainFutureErrors is set to false and the future fails. A timeout mechanism or a cap on the number of retries would be preferable in this ...
samuel k chris's user avatar
4 votes
Accepted

Flutter class extends StatefulWidget and Riverpod extends ConsumerStatefulWidget

inheritance tree does this mean the Riverpod documentation ... incorrectly specifies the type parameter? No. It describes classes in the most generic and broadly applicable terms possible, while the ...
J_H's user avatar
  • 43.3k
3 votes
Accepted

Created a Generic Row to do a lot of regular operation easily

First, I would like to encourage you to take the initiative. However, my advice is not to try reinventing the wheel. Meaning: the row widget already does what you need: it defies the purpose to ...
koussay issaoui's user avatar
3 votes
Accepted

Proper Handling of a Single Initialized Multiple FocusNode That is Shared Between Multiple Widget Classes in Flutter

I would personally scope the FocusNodes inside the children widgets because at every point in time, you would have one of these widgets rendered. Your implementation will not fail because you are ...
koussay issaoui's user avatar
3 votes

OOP Pac-man game

RULE: NEVER USE IF WITH ELSE refactor the following code to eliminate the else-if statement without using a switch statement? BEFORE ...
radarbob's user avatar
  • 8,249
3 votes

Am I writing Flutter code in the correct style?

Note, the reason I was able to answer so quickly is because this was originally asked on StackOverflow (now deleted) - to which I redirected the OP to here. You haven't really shared enough code, but: ...
MendelG's user avatar
  • 107
3 votes

Adding multiple items to a list in flutter

When naming JSON params, use Snail Case: json['product_name'] as String, json['product_description'] as String, Avoid dynamic as a List Type when you have already ...
Nirmal Code's user avatar
2 votes

Flutter Cubit: 2 Screens and Listview

Here's the fixed approach: Advice: Avoid calling events or cubit functions in init state, I have already explained why in the comments, but here is a summary: we use a third party library to avoid ...
koussay issaoui's user avatar
2 votes

Is this how Flutter BloC is suppose to be used?

Instead of writing toString() everywhere just to see what’s happening in your bloc, you can plug in the logger package with a BlocObserver. This way you don’t need to manually override toString() in ...
Yoyo's user avatar
  • 21
2 votes

DioClient using Clean Architecture following SOLID Principle

OverAll Review Clean Architecture is about doing what's necessary to ensure your code survives the project's pivoting. Now let's assess the need to abstract an HTTP client. The Client interface ...
koussay issaoui's user avatar
2 votes

Flutter input widget with multiple options (monthly/annual/currency/percentage)

Yeah, that possible you can make class function or a separate stateless widget for code reusability. ...
pixel's user avatar
  • 121
2 votes
Accepted

Should I add optional parameter to my function for test cases?

Do it the other way around. Pass the second argument always from outside - in both the tests and the real use case. It doesn't have to be a second parameter of a static function though. You can ...
slepic's user avatar
  • 5,657
2 votes

Dart Ioc Container

Is there anything obviously missing here? No, it is that simple. I recently implemented a generalized versions of the mediator pattern and it has a similar concept (Map with Types as keys). When you ...
D__'s user avatar
  • 21
1 vote

a Hebrew Date picker package in Flutter: single and range date selections

Here are a few suggestions: months is currently a List<String> in _getHebrewMonthName ...
Justin Chang's user avatar
  • 2,447
1 vote

Should I add optional parameter to my function for test cases?

By adding separate logic for your test case you are making it less representative of the code you are trying to test. If AppLocalizations.of(null) returned an ...
Ted Brownlow's user avatar
  • 1,692
1 vote

I have a input grid with more than 40 input-fields hardcoded

Make a data structure, an object, to hold all the data and meta data. The goal is to replace all that disconnected literal object creation with looping through the data structure. My sense is the ...
radarbob's user avatar
  • 8,249

Only top scored, non community-wiki answers of a minimum length are eligible