How to get current class instance and assign to final property by `this` in Dart
final
in
final AnimationController _chatMessageAnimationController;
and
_chatMessageAnimationController = ...
contradict each other. final
on instance fields means it can only be initialized at object creation. This means before even the constructor body is executed.
You can only use
- constructor parameters like
this._chatMessageAnimationController
- initializer lists
ChatScreenState() : _chatMessageAnimationController = ... {
- field initializers
final AnimationController _chatMessageAnimationController = ...;
to assign a value to such a field.Unfortunately none of these methods allow you to reference this
because object initialization is not completed yet.