refresh_indicator.dart 22.7 KB
Newer Older
Ian Hickson's avatar
Ian Hickson committed
1
// Copyright 2014 The Flutter Authors. All rights reserved.
2 3 4 5
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
6
import 'dart:math' as math;
7 8 9

import 'package:flutter/widgets.dart';

10 11
import 'debug.dart';
import 'material_localizations.dart';
12
import 'progress_indicator.dart';
13
import 'theme.dart';
14 15 16 17 18 19 20 21 22 23

// The over-scroll distance that moves the indicator to its maximum
// displacement, as a percentage of the scrollable's container extent.
const double _kDragContainerExtentPercentage = 0.25;

// How much the scroll's drag gesture can overshoot the RefreshIndicator's
// displacement; max displacement = _kDragSizeFactorLimit * displacement.
const double _kDragSizeFactorLimit = 1.5;

// When the scroll ends, the duration of the refresh indicator's animation
Josh Soref's avatar
Josh Soref committed
24
// to the RefreshIndicator's displacement.
25
const Duration _kIndicatorSnapDuration = Duration(milliseconds: 150);
26 27 28

// The duration of the ScaleTransition that starts when the refresh action
// has completed.
29
const Duration _kIndicatorScaleDuration = Duration(milliseconds: 200);
30

31 32 33 34 35
/// The signature for a function that's called when the user has dragged a
/// [RefreshIndicator] far enough to demonstrate that they want the app to
/// refresh. The returned [Future] must complete when the refresh operation is
/// finished.
///
36
/// Used by [RefreshIndicator.onRefresh].
37
typedef RefreshCallback = Future<void> Function();
38

39 40
// The state machine moves through these modes only when the scrollable
// identified by scrollableKey has been scrolled to its min or max limit.
41
enum _RefreshIndicatorMode {
42 43 44 45 46 47
  drag,     // Pointer is down.
  armed,    // Dragged far enough that an up event will run the onRefresh callback.
  snap,     // Animating to the indicator's final "displacement".
  refresh,  // Running the refresh callback.
  done,     // Animating the indicator's fade-out after refreshing.
  canceled, // Animating the indicator's fade-out after not arming.
48 49
}

50 51 52 53 54 55 56 57 58 59 60
/// Used to configure how [RefreshIndicator] can be triggered.
enum RefreshIndicatorTriggerMode {
  /// The indicator can be triggered regardless of the scroll position
  /// of the [Scrollable] when the drag starts.
  anywhere,

  /// The indicator can only be triggered if the [Scrollable] is at the edge
  /// when the drag starts.
  onEdge,
}

61 62
/// A widget that supports the Material "swipe to refresh" idiom.
///
63 64
/// {@youtube 560 315 https://www.youtube.com/watch?v=ORApMlzwMdM}
///
Adam Barth's avatar
Adam Barth committed
65
/// When the child's [Scrollable] descendant overscrolls, an animated circular
66 67 68 69 70 71
/// progress indicator is faded into view. When the scroll ends, if the
/// indicator has been dragged far enough for it to become completely opaque,
/// the [onRefresh] callback is called. The callback is expected to update the
/// scrollable's contents and then complete the [Future] it returns. The refresh
/// indicator disappears after the callback's [Future] has completed.
///
72 73
/// The trigger mode is configured by [RefreshIndicator.triggerMode].
///
74 75 76 77 78 79
/// {@tool dartpad}
/// This example shows how [RefreshIndicator] can be triggered in different ways.
///
/// ** See code in examples/api/lib/material/refresh_indicator/refresh_indicator.0.dart **
/// {@end-tool}
///
80 81 82 83 84 85 86 87 88
/// ## Troubleshooting
///
/// ### Refresh indicator does not show up
///
/// The [RefreshIndicator] will appear if its scrollable descendant can be
/// overscrolled, i.e. if the scrollable's content is bigger than its viewport.
/// To ensure that the [RefreshIndicator] will always appear, even if the
/// scrollable's content fits within its viewport, set the scrollable's
/// [Scrollable.physics] property to [AlwaysScrollableScrollPhysics]:
89 90
///
/// ```dart
91
/// ListView(
92 93
///   physics: const AlwaysScrollableScrollPhysics(),
///   children: ...
94
/// )
95 96 97
/// ```
///
/// A [RefreshIndicator] can only be used with a vertical scroll view.
98 99 100
///
/// See also:
///
101
///  * <https://material.io/design/platform-guidance/android-swipe-to-refresh.html>
102
///  * [RefreshIndicatorState], can be used to programmatically show the refresh indicator.
103 104
///  * [RefreshProgressIndicator], widget used by [RefreshIndicator] to show
///    the inner circular progress spinner during refreshes.
105
///  * [CupertinoSliverRefreshControl], an iOS equivalent of the pull-to-refresh pattern.
106 107 108
///    Must be used as a sliver inside a [CustomScrollView] instead of wrapping
///    around a [ScrollView] because it's a part of the scrollable instead of
///    being overlaid on top of it.
109
class RefreshIndicator extends StatefulWidget {
110 111
  /// Creates a refresh indicator.
  ///
112 113
  /// The [onRefresh], [child], and [notificationPredicate] arguments must be
  /// non-null. The default
114
  /// [displacement] is 40.0 logical pixels.
115 116 117 118
  ///
  /// The [semanticsLabel] is used to specify an accessibility label for this widget.
  /// If it is null, it will be defaulted to [MaterialLocalizations.refreshIndicatorSemanticLabel].
  /// An empty string may be passed to avoid having anything read by screen reading software.
119
  /// The [semanticsValue] may be used to specify progress on the widget.
120
  const RefreshIndicator({
121 122
    Key? key,
    required this.child,
123
    this.displacement = 40.0,
124
    this.edgeOffset = 0.0,
125
    required this.onRefresh,
126
    this.color,
127
    this.backgroundColor,
128
    this.notificationPredicate = defaultScrollNotificationPredicate,
129 130
    this.semanticsLabel,
    this.semanticsValue,
131
    this.strokeWidth = RefreshProgressIndicator.defaultStrokeWidth,
132
    this.triggerMode = RefreshIndicatorTriggerMode.onEdge,
133 134
  }) : assert(child != null),
       assert(onRefresh != null),
135
       assert(notificationPredicate != null),
136
       assert(strokeWidth != null),
137
       assert(triggerMode != null),
138
       super(key: key);
139

140 141
  /// The widget below this widget in the tree.
  ///
142 143
  /// The refresh indicator will be stacked on top of this child. The indicator
  /// will appear when child's Scrollable descendant is over-scrolled.
144 145
  ///
  /// Typically a [ListView] or [CustomScrollView].
146 147
  final Widget child;

148 149 150 151 152 153 154
  /// The distance from the child's top or bottom [edgeOffset] where
  /// the refresh indicator will settle. During the drag that exposes the refresh
  /// indicator, its actual displacement may significantly exceed this value.
  ///
  /// In most cases, [displacement] distance starts counting from the parent's
  /// edges. However, if [edgeOffset] is larger than zero then the [displacement]
  /// value is calculated from that offset instead of the parent's edge.
155 156
  final double displacement;

157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172
  /// The offset where [RefreshProgressIndicator] starts to appear on drag start.
  ///
  /// Depending whether the indicator is showing on the top or bottom, the value
  /// of this variable controls how far from the parent's edge the progress
  /// indicator starts to appear. This may come in handy when, for example, the
  /// UI contains a top [Widget] which covers the parent's edge where the progress
  /// indicator would otherwise appear.
  ///
  /// By default, the edge offset is set to 0.
  ///
  /// See also:
  ///
  ///  * [displacement], can be used to change the distance from the edge that
  ///    the indicator settles.
  final double edgeOffset;

173 174
  /// A function that's called when the user has dragged the refresh indicator
  /// far enough to demonstrate that they want the app to refresh. The returned
175
  /// [Future] must complete when the refresh operation is finished.
176
  final RefreshCallback onRefresh;
177

178
  /// The progress indicator's foreground color. The current theme's
179
  /// [ColorScheme.primary] by default.
180
  final Color? color;
181 182 183

  /// The progress indicator's background color. The current theme's
  /// [ThemeData.canvasColor] by default.
184
  final Color? backgroundColor;
185

186 187 188 189 190 191
  /// A check that specifies whether a [ScrollNotification] should be
  /// handled by this widget.
  ///
  /// By default, checks whether `notification.depth == 0`. Set it to something
  /// else for more complicated layouts.
  final ScrollNotificationPredicate notificationPredicate;
192

193
  /// {@macro flutter.progress_indicator.ProgressIndicator.semanticsLabel}
194 195 196
  ///
  /// This will be defaulted to [MaterialLocalizations.refreshIndicatorSemanticLabel]
  /// if it is null.
197
  final String? semanticsLabel;
198

199
  /// {@macro flutter.progress_indicator.ProgressIndicator.semanticsValue}
200
  final String? semanticsValue;
201

202 203 204 205 206
  /// Defines `strokeWidth` for `RefreshIndicator`.
  ///
  /// By default, the value of `strokeWidth` is 2.0 pixels.
  final double strokeWidth;

207 208 209 210 211 212 213 214 215 216 217 218 219 220 221
  /// Defines how this [RefreshIndicator] can be triggered when users overscroll.
  ///
  /// The [RefreshIndicator] can be pulled out in two cases,
  /// 1, Keep dragging if the scrollable widget at the edge with zero scroll position
  ///    when the drag starts.
  /// 2, Keep dragging after overscroll occurs if the scrollable widget has
  ///    a non-zero scroll position when the drag starts.
  ///
  /// If this is [RefreshIndicatorTriggerMode.anywhere], both of the cases above can be triggered.
  ///
  /// If this is [RefreshIndicatorTriggerMode.onEdge], only case 1 can be triggered.
  ///
  /// Defaults to [RefreshIndicatorTriggerMode.onEdge].
  final RefreshIndicatorTriggerMode triggerMode;

222
  @override
223
  RefreshIndicatorState createState() => RefreshIndicatorState();
224 225
}

226 227
/// Contains the state for a [RefreshIndicator]. This class can be used to
/// programmatically show the refresh indicator, see the [show] method.
228
class RefreshIndicatorState extends State<RefreshIndicator> with TickerProviderStateMixin<RefreshIndicator> {
229 230 231 232 233 234 235 236
  late AnimationController _positionController;
  late AnimationController _scaleController;
  late Animation<double> _positionFactor;
  late Animation<double> _scaleFactor;
  late Animation<double> _value;
  late Animation<Color?> _valueColor;

  _RefreshIndicatorMode? _mode;
237
  late Future<void> _pendingRefreshFuture;
238 239
  bool? _isIndicatorAtTop;
  double? _dragOffset;
240

241 242 243 244
  static final Animatable<double> _threeQuarterTween = Tween<double>(begin: 0.0, end: 0.75);
  static final Animatable<double> _kDragSizeFactorLimitTween = Tween<double>(begin: 0.0, end: _kDragSizeFactorLimit);
  static final Animatable<double> _oneToZeroTween = Tween<double>(begin: 1.0, end: 0.0);

245 246 247
  @override
  void initState() {
    super.initState();
248
    _positionController = AnimationController(vsync: this);
249 250
    _positionFactor = _positionController.drive(_kDragSizeFactorLimitTween);
    _value = _positionController.drive(_threeQuarterTween); // The "value" of the circular progress indicator during a drag.
251

252
    _scaleController = AnimationController(vsync: this);
253
    _scaleFactor = _scaleController.drive(_oneToZeroTween);
254 255 256
  }

  @override
257
  void didChangeDependencies() {
258
    final ThemeData theme = Theme.of(context);
259 260
    _valueColor = _positionController.drive(
      ColorTween(
261 262
        begin: (widget.color ?? theme.colorScheme.primary).withOpacity(0.0),
        end: (widget.color ?? theme.colorScheme.primary).withOpacity(1.0),
263
      ).chain(CurveTween(
264
        curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit),
265 266
      )),
    );
267
    super.didChangeDependencies();
268 269
  }

270 271 272 273 274 275 276
  @override
  void didUpdateWidget(covariant RefreshIndicator oldWidget) {
    super.didUpdateWidget(oldWidget);
    if (oldWidget.color != widget.color) {
      final ThemeData theme = Theme.of(context);
      _valueColor = _positionController.drive(
        ColorTween(
277 278
          begin: (widget.color ?? theme.colorScheme.primary).withOpacity(0.0),
          end: (widget.color ?? theme.colorScheme.primary).withOpacity(1.0),
279
        ).chain(CurveTween(
280
            curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit),
281 282 283 284 285
        )),
      );
    }
  }

286 287
  @override
  void dispose() {
288
    _positionController.dispose();
289 290 291 292
    _scaleController.dispose();
    super.dispose();
  }

293
  bool _shouldStart(ScrollNotification notification) {
294 295 296 297 298
    // If the notification.dragDetails is null, this scroll is not triggered by
    // user dragging. It may be a result of ScrollController.jumpTo or ballistic scroll.
    // In this case, we don't want to trigger the refresh indicator.
    return ((notification is ScrollStartNotification && notification.dragDetails != null)
            || (notification is ScrollUpdateNotification && notification.dragDetails != null && widget.triggerMode == RefreshIndicatorTriggerMode.anywhere))
299 300
      && (( notification.metrics.axisDirection == AxisDirection.up && notification.metrics.extentAfter == 0.0)
            || (notification.metrics.axisDirection == AxisDirection.down && notification.metrics.extentBefore == 0.0))
301 302 303 304
      && _mode == null
      && _start(notification.metrics.axisDirection);
  }

Adam Barth's avatar
Adam Barth committed
305
  bool _handleScrollNotification(ScrollNotification notification) {
306
    if (!widget.notificationPredicate(notification))
307
      return false;
308
    if (_shouldStart(notification)) {
309 310 311
      setState(() {
        _mode = _RefreshIndicatorMode.drag;
      });
312
      return false;
313
    }
314
    bool? indicatorAtTopNow;
315
    switch (notification.metrics.axisDirection) {
316 317
      case AxisDirection.down:
      case AxisDirection.up:
318
        indicatorAtTopNow = true;
319 320 321 322 323 324 325 326 327 328 329
        break;
      case AxisDirection.left:
      case AxisDirection.right:
        indicatorAtTopNow = null;
        break;
    }
    if (indicatorAtTopNow != _isIndicatorAtTop) {
      if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed)
        _dismiss(_RefreshIndicatorMode.canceled);
    } else if (notification is ScrollUpdateNotification) {
      if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) {
330 331
        if ((notification.metrics.axisDirection  == AxisDirection.down && notification.metrics.extentBefore > 0.0)
            || (notification.metrics.axisDirection  == AxisDirection.up && notification.metrics.extentAfter > 0.0)) {
332 333
          _dismiss(_RefreshIndicatorMode.canceled);
        } else {
334 335 336 337 338
          if (notification.metrics.axisDirection == AxisDirection.down) {
            _dragOffset = _dragOffset! - notification.scrollDelta!;
          } else if (notification.metrics.axisDirection == AxisDirection.up) {
            _dragOffset = _dragOffset! + notification.scrollDelta!;
          }
339 340 341
          _checkDragOffset(notification.metrics.viewportDimension);
        }
      }
342 343 344 345 346 347
      if (_mode == _RefreshIndicatorMode.armed && notification.dragDetails == null) {
        // On iOS start the refresh when the Scrollable bounces back from the
        // overscroll (ScrollNotification indicating this don't have dragDetails
        // because the scroll activity is not directly triggered by a drag).
        _show();
      }
348 349
    } else if (notification is OverscrollNotification) {
      if (_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed) {
350 351 352 353 354
        if (notification.metrics.axisDirection == AxisDirection.down) {
          _dragOffset = _dragOffset! - notification.overscroll;
        } else if (notification.metrics.axisDirection == AxisDirection.up) {
          _dragOffset = _dragOffset! + notification.overscroll;
        }
355 356 357 358 359 360 361 362 363 364
        _checkDragOffset(notification.metrics.viewportDimension);
      }
    } else if (notification is ScrollEndNotification) {
      switch (_mode) {
        case _RefreshIndicatorMode.armed:
          _show();
          break;
        case _RefreshIndicatorMode.drag:
          _dismiss(_RefreshIndicatorMode.canceled);
          break;
365 366 367 368 369
        case _RefreshIndicatorMode.canceled:
        case _RefreshIndicatorMode.done:
        case _RefreshIndicatorMode.refresh:
        case _RefreshIndicatorMode.snap:
        case null:
370 371 372
          // do nothing
          break;
      }
373 374
    }
    return false;
375 376
  }

377 378 379 380 381 382
  bool _handleGlowNotification(OverscrollIndicatorNotification notification) {
    if (notification.depth != 0 || !notification.leading)
      return false;
    if (_mode == _RefreshIndicatorMode.drag) {
      notification.disallowGlow();
      return true;
383
    }
384
    return false;
385 386
  }

387 388 389 390 391 392 393
  bool _start(AxisDirection direction) {
    assert(_mode == null);
    assert(_isIndicatorAtTop == null);
    assert(_dragOffset == null);
    switch (direction) {
      case AxisDirection.down:
      case AxisDirection.up:
394
        _isIndicatorAtTop = true;
395 396 397 398 399 400 401
        break;
      case AxisDirection.left:
      case AxisDirection.right:
        _isIndicatorAtTop = null;
        // we do not support horizontal scroll views.
        return false;
    }
402 403
    _dragOffset = 0.0;
    _scaleController.value = 0.0;
404 405
    _positionController.value = 0.0;
    return true;
406 407
  }

408 409
  void _checkDragOffset(double containerExtent) {
    assert(_mode == _RefreshIndicatorMode.drag || _mode == _RefreshIndicatorMode.armed);
410
    double newValue = _dragOffset! / (containerExtent * _kDragContainerExtentPercentage);
411 412
    if (_mode == _RefreshIndicatorMode.armed)
      newValue = math.max(newValue, 1.0 / _kDragSizeFactorLimit);
413 414
    _positionController.value = newValue.clamp(0.0, 1.0); // this triggers various rebuilds
    if (_mode == _RefreshIndicatorMode.drag && _valueColor.value!.alpha == 0xFF)
415
      _mode = _RefreshIndicatorMode.armed;
416 417
  }

418
  // Stop showing the refresh indicator.
419
  Future<void> _dismiss(_RefreshIndicatorMode newMode) async {
420
    await Future<void>.value();
421 422 423 424
    // This can only be called from _show() when refreshing and
    // _handleScrollNotification in response to a ScrollEndNotification or
    // direction change.
    assert(newMode == _RefreshIndicatorMode.canceled || newMode == _RefreshIndicatorMode.done);
425
    setState(() {
426
      _mode = newMode;
427
    });
428
    switch (_mode!) {
429
      case _RefreshIndicatorMode.done:
430 431
        await _scaleController.animateTo(1.0, duration: _kIndicatorScaleDuration);
        break;
432 433 434
      case _RefreshIndicatorMode.canceled:
        await _positionController.animateTo(0.0, duration: _kIndicatorScaleDuration);
        break;
435 436 437 438
      case _RefreshIndicatorMode.armed:
      case _RefreshIndicatorMode.drag:
      case _RefreshIndicatorMode.refresh:
      case _RefreshIndicatorMode.snap:
439
        assert(false);
440
    }
441 442 443
    if (mounted && _mode == newMode) {
      _dragOffset = null;
      _isIndicatorAtTop = null;
444 445 446 447
      setState(() {
        _mode = null;
      });
    }
448 449
  }

450 451 452
  void _show() {
    assert(_mode != _RefreshIndicatorMode.refresh);
    assert(_mode != _RefreshIndicatorMode.snap);
453
    final Completer<void> completer = Completer<void>();
454
    _pendingRefreshFuture = completer.future;
455
    _mode = _RefreshIndicatorMode.snap;
456
    _positionController
457
      .animateTo(1.0 / _kDragSizeFactorLimit, duration: _kIndicatorSnapDuration)
458
      .then<void>((void value) {
459
        if (mounted && _mode == _RefreshIndicatorMode.snap) {
460
          assert(widget.onRefresh != null);
461 462 463 464 465
          setState(() {
            // Show the indeterminate progress indicator.
            _mode = _RefreshIndicatorMode.refresh;
          });

466
          final Future<void> refreshResult = widget.onRefresh();
467 468
          assert(() {
            if (refreshResult == null)
469 470
              FlutterError.reportError(FlutterErrorDetails(
                exception: FlutterError(
471
                  'The onRefresh callback returned null.\n'
472
                  'The RefreshIndicator onRefresh callback must return a Future.',
473
                ),
474
                context: ErrorDescription('when calling onRefresh'),
475 476 477
                library: 'material library',
              ));
            return true;
478
          }());
479
          if (refreshResult == null)
480 481
            return;
          refreshResult.whenComplete(() {
482 483
            if (mounted && _mode == _RefreshIndicatorMode.refresh) {
              completer.complete();
484
              _dismiss(_RefreshIndicatorMode.done);
485 486 487
            }
          });
        }
488 489 490 491 492 493 494
      });
  }

  /// Show the refresh indicator and run the refresh callback as if it had
  /// been started interactively. If this method is called while the refresh
  /// callback is running, it quietly does nothing.
  ///
495
  /// Creating the [RefreshIndicator] with a [GlobalKey<RefreshIndicatorState>]
496
  /// makes it possible to refer to the [RefreshIndicatorState].
497
  ///
498 499
  /// The future returned from this method completes when the
  /// [RefreshIndicator.onRefresh] callback's future completes.
500 501 502 503 504 505 506
  ///
  /// If you await the future returned by this function from a [State], you
  /// should check that the state is still [mounted] before calling [setState].
  ///
  /// When initiated in this manner, the refresh indicator is independent of any
  /// actual scroll view. It defaults to showing the indicator at the top. To
  /// show it at the bottom, set `atTop` to false.
507
  Future<void> show({ bool atTop = true }) {
508 509
    if (_mode != _RefreshIndicatorMode.refresh &&
        _mode != _RefreshIndicatorMode.snap) {
510 511
      if (_mode == null)
        _start(atTop ? AxisDirection.down : AxisDirection.up);
512
      _show();
513
    }
514
    return _pendingRefreshFuture;
515 516
  }

517 518
  @override
  Widget build(BuildContext context) {
519
    assert(debugCheckHasMaterialLocalizations(context));
520
    final Widget child = NotificationListener<ScrollNotification>(
521
      onNotification: _handleScrollNotification,
522
      child: NotificationListener<OverscrollIndicatorNotification>(
523
        onNotification: _handleGlowNotification,
524
        child: widget.child,
525 526
      ),
    );
527 528 529 530 531 532 533 534 535 536
    assert(() {
      if (_mode == null) {
        assert(_dragOffset == null);
        assert(_isIndicatorAtTop == null);
      } else {
        assert(_dragOffset != null);
        assert(_isIndicatorAtTop != null);
      }
      return true;
    }());
537

538 539 540
    final bool showIndeterminateIndicator =
      _mode == _RefreshIndicatorMode.refresh || _mode == _RefreshIndicatorMode.done;

541
    return Stack(
542 543
      children: <Widget>[
        child,
544
        if (_mode != null) Positioned(
545 546
          top: _isIndicatorAtTop! ? widget.edgeOffset : null,
          bottom: !_isIndicatorAtTop! ? widget.edgeOffset : null,
547 548
          left: 0.0,
          right: 0.0,
549
          child: SizeTransition(
550
            axisAlignment: _isIndicatorAtTop! ? 1.0 : -1.0,
551
            sizeFactor: _positionFactor, // this is what brings it down
552
            child: Container(
553
              padding: _isIndicatorAtTop!
554 555
                ? EdgeInsets.only(top: widget.displacement)
                : EdgeInsets.only(bottom: widget.displacement),
556
              alignment: _isIndicatorAtTop!
557 558
                ? Alignment.topCenter
                : Alignment.bottomCenter,
559
              child: ScaleTransition(
560
                scale: _scaleFactor,
561
                child: AnimatedBuilder(
562
                  animation: _positionController,
563
                  builder: (BuildContext context, Widget? child) {
564
                    return RefreshProgressIndicator(
565
                      semanticsLabel: widget.semanticsLabel ?? MaterialLocalizations.of(context).refreshIndicatorSemanticLabel,
566
                      semanticsValue: widget.semanticsValue,
567 568
                      value: showIndeterminateIndicator ? null : _value.value,
                      valueColor: _valueColor,
569
                      backgroundColor: widget.backgroundColor,
570
                      strokeWidth: widget.strokeWidth,
571 572 573 574 575
                    );
                  },
                ),
              ),
            ),
576
          ),
577 578
        ),
      ],
579 580 581
    );
  }
}