@@ -139,11 +139,13 @@ class _SliderState extends State<Slider> with TickerProviderStateMixin {
139
139
@override
140
140
Widget build (BuildContext context) {
141
141
assert (debugCheckHasMaterial (context));
142
+ ThemeData theme = Theme .of (context);
142
143
return new _SliderRenderObjectWidget (
143
144
value: (config.value - config.min) / (config.max - config.min),
144
145
divisions: config.divisions,
145
146
label: config.label,
146
- activeColor: config.activeColor ?? Theme .of (context).accentColor,
147
+ activeColor: config.activeColor ?? theme.accentColor,
148
+ textTheme: theme.primaryTextTheme,
147
149
onChanged: config.onChanged != null ? _handleChanged : null ,
148
150
vsync: this ,
149
151
);
@@ -157,6 +159,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
157
159
this .divisions,
158
160
this .label,
159
161
this .activeColor,
162
+ this .textTheme,
160
163
this .onChanged,
161
164
this .vsync,
162
165
}) : super (key: key);
@@ -165,6 +168,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
165
168
final int divisions;
166
169
final String label;
167
170
final Color activeColor;
171
+ final TextTheme textTheme;
168
172
final ValueChanged <double > onChanged;
169
173
final TickerProvider vsync;
170
174
@@ -174,6 +178,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
174
178
divisions: divisions,
175
179
label: label,
176
180
activeColor: activeColor,
181
+ textTheme: textTheme,
177
182
onChanged: onChanged,
178
183
vsync: vsync,
179
184
);
@@ -185,6 +190,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget {
185
190
..divisions = divisions
186
191
..label = label
187
192
..activeColor = activeColor
193
+ ..textTheme = textTheme
188
194
..onChanged = onChanged;
189
195
// Ticker provider cannot change since there's a 1:1 relationship between
190
196
// the _SliderRenderObjectWidget object and the _SliderState object.
@@ -229,11 +235,13 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
229
235
int divisions,
230
236
String label,
231
237
Color activeColor,
238
+ TextTheme textTheme,
232
239
this .onChanged,
233
240
TickerProvider vsync,
234
241
}) : _value = value,
235
242
_divisions = divisions,
236
243
_activeColor = activeColor,
244
+ _textTheme = textTheme,
237
245
super (additionalConstraints: _getAdditionalConstraints (label)) {
238
246
assert (value != null && value >= 0.0 && value <= 1.0 );
239
247
this .label = label;
@@ -290,7 +298,7 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
290
298
// https://github.com/flutter/flutter/issues/5938
291
299
_labelPainter
292
300
..text = new TextSpan (
293
- style: Typography .white .body1.copyWith (fontSize: 10.0 ),
301
+ style: _textTheme .body1.copyWith (fontSize: 10.0 ),
294
302
text: newLabel
295
303
)
296
304
..layout ();
@@ -309,6 +317,15 @@ class _RenderSlider extends RenderConstrainedBox implements SemanticsActionHandl
309
317
markNeedsPaint ();
310
318
}
311
319
320
+ TextTheme get textTheme => _textTheme;
321
+ TextTheme _textTheme;
322
+ set textTheme (TextTheme value) {
323
+ if (value == _textTheme)
324
+ return ;
325
+ _textTheme = value;
326
+ markNeedsPaint ();
327
+ }
328
+
312
329
ValueChanged <double > onChanged;
313
330
314
331
double get _trackLength => size.width - 2.0 * _kReactionRadius;
0 commit comments