@@ -125,23 +125,17 @@ class RollingTextController with ChangeNotifier {
125125 this .textHeightBehavior,
126126 });
127127
128- List <String >? _tapes;
129-
130128 /// A list containing strings that represent a tape of characters
131129 /// to roll through for each character index between the old and
132130 /// new text.
133- List <String > get tapes => _tapes! ;
134-
135- List <TextPainter >? _tapePainters;
131+ late final List <String > tapes = [];
136132
137133 /// A list containing painters that represent each tape of characters
138134 /// from [tapes] .
139- List <TextPainter > get tapePainters => _tapePainters! ;
140-
141- Map <int , double >? _tapeHeights;
135+ late final List <TextPainter > tapePainters = [];
142136
143137 /// A cached map of tape heights for each tape painter.
144- Map <int , double > get tapeHeights => _tapeHeights ! ;
138+ late final Map <int , double > tapeHeights;
145139
146140 /// Multiplies the index by 2 to account for new-line \n characters.
147141 int _mapCharKitIndexToSelection (String charKit, int index) => index * 2 ;
@@ -169,19 +163,25 @@ class RollingTextController with ChangeNotifier {
169163 void layout () {
170164 disposePainters ();
171165
172- _tapes = buildTapes ();
173- _tapePainters = buildTapePainters (tapes);
166+ tapes
167+ ..clear ()
168+ ..addAll (buildTapes ());
169+ tapePainters
170+ ..clear ()
171+ ..addAll (buildTapePainters (tapes));
174172
175173 for (final TextPainter painter in tapePainters) {
176174 painter.layout ();
177175 }
178176
179- _tapeHeights = calculateTapeHeights ();
177+ tapeHeights
178+ ..clear ()
179+ ..addAll (calculateTapeHeights ());
180180 }
181181
182182 /// Disposes of the text painters.
183183 void disposePainters () {
184- for (final TextPainter painter in (_tapePainters ?? []) ) {
184+ for (final TextPainter painter in tapePainters ) {
185185 painter.dispose ();
186186 }
187187 }
0 commit comments