Skip to content

Commit 2841dfa

Browse files
SaadArdatiBirjuVachhani
authored andcommitted
🔧 Update Pack V1 #6
1 parent 8392e3c commit 2841dfa

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

example/lib/stories/text_animation.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ class _TextAnimationState extends State<TextAnimation> {
7575
symbolDistanceMultiplier: 2,
7676
staggerSoftness: 10,
7777
tapeStrategy: const ConsistentSymbolTapeStrategy(0, true),
78+
fixedTapeWidth: 18,
7879
// clipBehavior: Clip.none,
7980
)
8081
.animate(

lib/src/rolling_text_controller.dart

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)