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 ...
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 ...
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:
...
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-...
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 ...
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 ...
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 ...
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 ...
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
...
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:
...
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 ...
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 ...
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 ...
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 ...
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.
...
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 ...
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 ...
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 ...
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
flutter × 24dart × 21
state × 2
c++ × 1
performance × 1
beginner × 1
object-oriented × 1
game × 1
design-patterns × 1
datetime × 1
unit-testing × 1
android × 1
api × 1
generics × 1
thread-safety × 1
windows × 1
library × 1
gui × 1
dependency-injection × 1
mvvm × 1
locking × 1
factory-method × 1
layout × 1
firebase × 1
fluent-interface × 1