diff --git a/examples/flutter_gallery/lib/demo/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/overscroll_demo.dart index 3e08c8d891..6d67524239 100644 --- a/examples/flutter_gallery/lib/demo/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/overscroll_demo.dart @@ -31,15 +31,18 @@ class OverscrollDemoState extends State { Completer completer = new Completer(); new Timer(new Duration(seconds: 3), () { completer.complete(null); }); return completer.future.then((_) { - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text("Refresh complete"), - action: new SnackBarAction( - label: 'RETRY', - onPressed: () { - _refreshIndicatorKey.currentState.show(); - } - ) - )); + final ScaffoldState scaffoldState = _scaffoldKey.currentState; + if (scaffoldState != null) { + scaffoldState.showSnackBar(new SnackBar( + content: new Text("Refresh complete"), + action: new SnackBarAction( + label: 'RETRY', + onPressed: () { + _refreshIndicatorKey.currentState.show(); + } + ) + )); + } }); } diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index 2ab1459bab..6b1a717ed1 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -46,14 +46,15 @@ abstract class ProgressIndicator extends StatefulWidget { /// much actual progress is being made. final double value; - /// The progress indicator's background color. If null, the background color is - /// the current theme's backgroundColor. + /// The progress indicator's background color. The current theme's + /// [ThemeData.backgroundColor] by default. final Color backgroundColor; /// The indicator's color is the animation's value. To specify a constant /// color use: `new AlwaysStoppedAnimation(color)`. /// - /// If null, the progress indicator is rendered with the current theme's primaryColor. + /// If null, the progress indicator is rendered with the current theme's + /// [ThemeData.primaryColor]. final Animation valueColor; Color _getBackgroundColor(BuildContext context) => backgroundColor ?? Theme.of(context).backgroundColor; @@ -485,7 +486,7 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { margin: const EdgeInsets.all(4.0), // acommodate the shadow child: new Material( type: MaterialType.circle, - color: Theme.of(context).canvasColor, + color: config.backgroundColor ?? Theme.of(context).canvasColor, elevation: 2, child: new Padding( padding: const EdgeInsets.all(12.0), diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 223472d7cf..d1676a6524 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -68,18 +68,20 @@ enum _DismissTransition { /// animated circular 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 refresh callback is called. The callback is -/// expected to udpate the scrollback and then complete the Future it -/// returns. The refresh indicator disappears after the callback's +/// 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. /// /// The required [scrollableKey] parameter identifies the scrollable widget /// whose scrollOffset is monitored by this RefreshIndicator. The same -/// scrollableKey must also be set on the scrollable. See [Block.scrollableKey] +/// scrollableKey must also be set on the scrollable. See [Block.scrollableKey], /// [ScrollableList.scrollableKey], etc. /// /// See also: /// /// * +/// * [RefreshIndicatorState] (can be used to programatically show the refresh indicator) +/// * [RefreshProgressIndicator] class RefreshIndicator extends StatefulWidget { /// Creates a refresh indicator. /// @@ -91,7 +93,9 @@ class RefreshIndicator extends StatefulWidget { this.child, this.displacement: 40.0, this.refresh, - this.location: RefreshIndicatorLocation.top + this.location: RefreshIndicatorLocation.top, + this.color, + this.backgroundColor }) : super(key: key) { assert(child != null); assert(refresh != null); @@ -116,10 +120,18 @@ class RefreshIndicator extends StatefulWidget { /// Future must complete when the refresh operation is finished. final RefreshCallback refresh; - /// Where the refresh indicator should appear, RefreshIndicatorLocation.top + /// Where the refresh indicator should appear, [RefreshIndicatorLocation.top] /// by default. final RefreshIndicatorLocation location; + /// The progress indicator's foreground color. The current theme's + /// [ThemeData.primaryColor] by default. + final Color color; + + /// The progress indicator's background color. The current theme's + /// [ThemeData.canvasColor] by default. + final Color backgroundColor; + @override RefreshIndicatorState createState() => new RefreshIndicatorState(); } @@ -156,8 +168,8 @@ class RefreshIndicatorState extends State { // Fully opaque when we've reached config.displacement. _valueColor = new ColorTween( - begin: theme.primaryColor.withOpacity(0.0), - end: theme.primaryColor.withOpacity(1.0) + begin: (config.color ?? theme.primaryColor).withOpacity(0.0), + end: (config.color ?? theme.primaryColor).withOpacity(1.0) ) .animate(new CurvedAnimation( parent: _sizeController, @@ -369,7 +381,8 @@ class RefreshIndicatorState extends State { builder: (BuildContext context, Widget child) { return new RefreshProgressIndicator( value: showIndeterminateIndicator ? null : _value.value, - valueColor: _valueColor + valueColor: _valueColor, + backgroundColor: config.backgroundColor ); } )