This PR adds the following lint rules to our list:
```
always_put_required_named_parameters_first
avoid_multiple_declarations_per_line
avoid_positional_boolean_parameters
avoid_returning_null_for_void
avoid_returning_this
avoid_unnecessary_containers
enable_null_safety
library_private_types_in_public_api
no_leading_underscores_for_library_prefixes
no_leading_underscores_for_local_identifiers
prefer_null_aware_method_calls
tighten_type_of_initializing_formals
unnecessary_late
use_setters_to_change_properties
```
And these rules were considered, and some changes were made according to
them as a clean-up, but in many places they didn't make sense
(`prefer_asserts_with_message` I would have included, but there were too
many places that needed to be changes):
```
collection_methods_unrelated_type
prefer_asserts_with_message
avoid_renaming_method_parameters
```
This PR is the second in a series of refactors that aim to simplify event handling in Flame. The approach is as follows:
Added the MultiTapDispatcher component, which contains the logic that used to be within the HasTappableComponents mixin. This component is internal; it mounts to a FlameGame directly, and ensures that it is a singleton.
Whenever any TapCallbacks component is added to a game, it automatically adds the MultiTapDispatcher component (unless there is already one), which in turn registers a tap gesture detector with GestureDetectorBuilder and rebuilds the game widget.
The end result is that now in order to make a component tappable you only need to add the TapCallbacks mixin to that component, everything else will be handled by the framework.
Consequently, the HasTappableComponents mixin is now empty and marked as deprecated.
Before this PR, the return type of onLoad() was Future<void>?, after this PR the return type is FutureOr<void> -- both for classes Component and Game.
Reasons:
The use of FutureOr is more idiomatic in Dart, this class was specifically created in order to be used in situations like ours.
This makes learning Flame easier for beginners, since you no longer need to explain what asynchronous programming is from the start (and onLoad() is one of the first methods the user encounters in Flame).
The code can be cleaner in case when onLoad doesn't need to be async.
With new approach, the onLoad() method can be overridden as either
@override
Future<void> onLoad() async { ... }
or
@override
void onLoad() { ... }
Of course, it can also be overridden as
@override
FutureOr<void> onLoad() { ... }
but this is rare, only for components that are designed to be further subclassed, or for mixins.
The documentation was updated to show the new recommended usage.
* Added Component.childrenFactory
* fix some of the lint warnings
* more lint warnings
* remove changelog entry
* more analyzer warnings
* one more warning
* one more warning
* remove more unused imports
* fix more warnings
* another warning
* one more warning
* a lot more warnings
* some more warnings
* fix warnings in flame_svg
* fix warnings in flame_bloc
* Remove OrderedSet override feature
* Remove testRandom change
* Remove unnecessary type checks
* Re-remove deprecated argument in random_test
Co-authored-by: Pasha Stetsenko <stpasha@google.com>
* `ShapeComponent` changes size, position and angle of underlying Shape
* Added description to ShapeComponent
* Fix test
* Update packages/flame/lib/src/components/shape_component.dart
Co-authored-by: Erick <erickzanardoo@gmail.com>
* Add absoluteScale and absoluteAngle to PositionComponent
* Refactor ShapeComponent
* Should be scaled by total scale, not scaled size
* Premature optimization for creation for objects in Polygon
* Use path for default Polygon constructor
* Do not sync component and hitbox shape
* Fix analyze issue
* Add example for flipping with collision detection
* Don't use absoluteScale
* Fix examples
* Fix examples
* Doesn't need super.render
* Fix Circle dartdoc
* Update changelog
* Update names of vertices caches in Polygon
* Update text docs
* Revert "Update text docs"
This reverts commit 73a68a465d76eb0eb50bb3753e57b2f4e3b5a7f4.
* Fix examples
* ShapeComponents docs
* Move example games to the top
* Fix dartdoc comment about polygon vertex relation
* Fix order of polygon vertices in dartdoc
* Fix anchor for PolygonComponent.fromPoints
* Add test with ancestors
* Update doc/components.md
Co-authored-by: Pasha Stetsenko <stpasha@google.com>
* Update doc/components.md
Co-authored-by: Erick <erickzanardoo@gmail.com>
* Rename example classes
* Fix linting issues in examples
* Don't use px
* Use isTrue and isFalse
* Update doc/components.md
Co-authored-by: Erick <erickzanardoo@gmail.com>
* Fixed comments on PR
Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Pasha Stetsenko <stpasha@google.com>
* Add `randomColor` to the `Color` extension
* Add flame rive package to monorepo (#1048)
Add flame rive package to monorepo
* Add random to PaintExtension
* Update examples/pubspec.yaml
Co-authored-by: Erick <erickzanardoo@gmail.com>
Co-authored-by: Renan <6718144+renancaraujo@users.noreply.github.com>
Co-authored-by: Erick <erickzanardoo@gmail.com>