This is a first step towards enabling DCM for Flame. Though I have tested with all rules, and am working on selecting, assessing, and fixing violations, as a first step, we can merge the infrastructural changes to flame_lint to and GitHub actions.
As a proof of concept, I am enabling two rules for which we have no violations.
I will followup with enabling more rules, adding discussions for controversial changes, and fixing non-controversial violations.
While studying the existing text rendering pipeline and infrastructure, in order to better document it and add some easier user-facing ways to render rich text, I found it to be on a slightly overcomplicated state that seems to me to be an artifact of a migration.
Let me first briefly describe how it works with some diagrams (I am writing docs for everything and will re-use this content but wanted to propose this PR first as it will change how things look like).
We have 3 hierarchies related to rendering:
renderers: children of TextRenderer, these define how to render text (style). do not include text
formatters: children of TextFormatter, this also define how to render text (style), but a bit more higher level than TextRenderer.
elements: these are laid-out, styled and ready-render pieces of text (style + string), created by formatters
Note that the renderers and formatters kinda serve the same purpose, but the renderers are a more low-level API. Here is how it it looks like today:
Not only that but all of our TextRenderer are actually FormatterTextRenderer, which just use a formatter to "comply" with the "renderer" interface. There are no "raw" TextRenderers anymore.
This current structure seems to clearly derive from an unfinished transition into the new, higher level and more flexible "formatter" structure while still supporting the "renderers" while we transition. That transition, though, seems to have completed.
The current state makes things more complicated as our current versions of components (TextComponent and TextBoxComponent), specifically the former, have branching code to support both the raw TextRenderer and the specific FormatterTextRenderer implementation, which breaks the inheritance encapsulation and voids its purpose in the first place.
The purpose of this PR is to simplify this class structure by:
remove the base TextRenderer
rename FormatterTextRenderer to TextRenderer: all renderers are formatter-based now
update all references
simplify the code of the components by only dealing with (former FormatterTextRenderer) TextRenderers
This is what it looks like now:
Note that while this is a breaking change, it should not affect most users as they should be using much more user-facing classes, like the aforementioned components, instead of the backing implementations. In fact even if they use the renderers, they probably use one of the concrete implementations anyway, TextPaint or SpriteFontRenderer. Notwithstanding, I added migration instructions below.
This is a small step towards a world where we completely combine the converts of renderers and formatters, as, in my eyes, they do the same thing (carry the style information w/o the text).
Possible future (but definitely breaking) changes:
remove renderers entirely and use formatters directly
consider renaming formatters to renderers (or not)
rename TextPaint as the name does not make sense in any hierarchical model we use
(what I am really interested in): allow the creation of text_ and text_box_ components directly from renderers + elements
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
```
Apparently my previous change broke a lot of the README files because I used markdown on the HTML-only zone. It started all right but at some point after I started testing I accidentally switched.
The backticks also don't work well with links, so I removed them.
While taking a stroll through our pub.dev publishers, I noticed that all
our bridge packages were sorely inconsistent w.r.t their README files.
While some were just special in their own way, a lot of them were just
broken, incorrect, outdated, or otherwise unsuitable. I found:
* broken GitHub badges
* links to the old, non-monorepo versions of the packages
* hardcoded old versions of packages
* lacking bare minimum of details
* references to flame v1/pre v1
But the main thing bugging me was the inconsistency. So, instead of
pursuing fixing each individual mistake, I thought it would be much more
valuable and professional to keep them under a standard template.
This is my proposal, based on the current monorepo main README (which is
shared with the main `flame` package):

It includes:
* the flame logo if we have it for a package we own (can be replaced by
a more-specific logo, like for the flame_forge2d package)
* brief 1/2-liner describing what this bridges to, including at least
one link to the relevant library (GitHub preferred) and ending with "to
Flame games" where Flame links to the monorepo main
* badges:
* * pub version _of that package_ (not `flame`)
* * build of the monorepo (not old repos)
* * discord (all the same)
* * melos (all the same)
* a horizontal line
* package name written as `flame_x` in a 1-header (`# flame_x`)
* rest of the description
* other subsections as 2-headers
# Description
This does two things:
## Use double quotes for SDK constraints
Standardize the usage of single or double quotes to specify sdk
constraints across pubspecs
I see no reason this should not be kept consistent
I also see no reason to prefer one over the other, so I searched the
code base and there are 7 instances of single quote vs 32 of double
quotes, so I favored the later
## Update all SDK constraints to 2.18
Let me know if there are any issues with it, but I believe we should
keep this consistent across all packages.
Also there is a pubspec on root which imply all should be on 2.18
anyway.
## Checklist
- [x] I have followed the [Contributor Guide] when preparing my PR.
- [x] I have updated/added tests for ALL new/updated/fixed
functionality.
- [x] I have updated/added relevant documentation in `docs` and added
dartdoc comments with `///`.
- [x] I have updated/added relevant examples in `examples` or `docs`.
## Breaking Change?
- [ ] Yes, this PR is a breaking change.
- [x] No, this PR is not a breaking change.
<!-- Links -->
[Contributor Guide]:
https://github.com/flame-engine/flame/blob/main/CONTRIBUTING.md
[Conventional Commit]: https://conventionalcommits.org/
[CHANGELOG]:
https://github.com/flame-engine/flame/blob/main/CHANGELOG.md
Co-authored-by: Lukas Klingsbo <me@lukas.fyi>
The root level .gitignore file already works for all sub-repositories, so they are all actually unnecessary.
This PR leaves only the gitignore at the root of the repo, removing all others.
This simple refactor allows us to write class MyGame extends Game, instead of a more awkward class MyGame with Game. However, using ... with Game still continues to work, so no changes necessary for the users.
Pub gives a warning when using ^3.0.0 since that also implies less than 4.0.0, which your Flutter dependency shouldn't be.
With >= it is an open range instead.
* 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>