Lots of trivial warning fixes
Add type annotations in many places. Fix some identifiers to have more lint-satisfying names. Make all operator==s consistent in style. Reorder some functions for consistency. Make ParentData no longer dynamic, and fix all the code around that.
This commit is contained in:
@@ -57,8 +57,8 @@ const _kChunkCount = 30;
|
||||
|
||||
String _urlToFetch(int chunk) {
|
||||
if (rootBundle == null)
|
||||
return '../data/stock_data_${chunk}.json';
|
||||
return 'https://domokit.github.io/examples/stocks/data/stock_data_${chunk}.json';
|
||||
return '../data/stock_data_$chunk.json';
|
||||
return 'https://domokit.github.io/examples/stocks/data/stock_data_$chunk.json';
|
||||
}
|
||||
|
||||
class StockDataFetcher {
|
||||
@@ -81,9 +81,7 @@ class StockDataFetcher {
|
||||
return;
|
||||
}
|
||||
JsonDecoder decoder = new JsonDecoder();
|
||||
|
||||
callback(new StockData(decoder.convert(json)));
|
||||
|
||||
if (_nextChunk < _kChunkCount)
|
||||
_fetchNextChunk();
|
||||
});
|
||||
|
||||
@@ -37,8 +37,10 @@ class StockHomeState extends State<StockHome> {
|
||||
}
|
||||
|
||||
void _handleSearchEnd() {
|
||||
assert(config.navigator.currentRoute is StateRoute);
|
||||
assert((config.navigator.currentRoute as StateRoute).owner == this); // TODO(ianh): remove cast once analyzer is cleverer
|
||||
assert(() {
|
||||
final StateRoute currentRoute = config.navigator.currentRoute;
|
||||
assert(currentRoute.owner == this);
|
||||
});
|
||||
config.navigator.pop();
|
||||
setState(() {
|
||||
_isSearching = false;
|
||||
@@ -74,7 +76,7 @@ class StockHomeState extends State<StockHome> {
|
||||
void _showDrawer() {
|
||||
showDrawer(
|
||||
navigator: config.navigator,
|
||||
child: new Block([
|
||||
child: new Block(<Widget>[
|
||||
new DrawerHeader(child: new Text('Stocks')),
|
||||
new DrawerItem(
|
||||
icon: 'action/assessment',
|
||||
@@ -88,7 +90,7 @@ class StockHomeState extends State<StockHome> {
|
||||
return new Dialog(
|
||||
title: new Text('Not Implemented'),
|
||||
content: new Text('This feature has not yet been implemented.'),
|
||||
actions: [
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text('USE IT'),
|
||||
enabled: false,
|
||||
@@ -117,7 +119,7 @@ class StockHomeState extends State<StockHome> {
|
||||
new DrawerItem(
|
||||
icon: 'action/thumb_up',
|
||||
onPressed: () => _handleStockModeChange(StockMode.optimistic),
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Optimistic')),
|
||||
new Radio(value: StockMode.optimistic, groupValue: config.stockMode, onChanged: _handleStockModeChange)
|
||||
])
|
||||
@@ -125,7 +127,7 @@ class StockHomeState extends State<StockHome> {
|
||||
new DrawerItem(
|
||||
icon: 'action/thumb_down',
|
||||
onPressed: () => _handleStockModeChange(StockMode.pessimistic),
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Pessimistic')),
|
||||
new Radio(value: StockMode.pessimistic, groupValue: config.stockMode, onChanged: _handleStockModeChange)
|
||||
])
|
||||
@@ -155,7 +157,7 @@ class StockHomeState extends State<StockHome> {
|
||||
onPressed: _showDrawer
|
||||
),
|
||||
center: new Text('Stocks'),
|
||||
right: [
|
||||
right: <Widget>[
|
||||
new IconButton(
|
||||
icon: "action/search",
|
||||
onPressed: _handleSearchBegin
|
||||
@@ -171,14 +173,14 @@ class StockHomeState extends State<StockHome> {
|
||||
int selectedTabIndex = 0;
|
||||
|
||||
Iterable<Stock> _getStockList(Iterable<String> symbols) {
|
||||
return symbols.map((symbol) => config.stocks[symbol]);
|
||||
return symbols.map((String symbol) => config.stocks[symbol]);
|
||||
}
|
||||
|
||||
Iterable<Stock> _filterBySearchQuery(Iterable<Stock> stocks) {
|
||||
if (_searchQuery == null)
|
||||
return stocks;
|
||||
RegExp regexp = new RegExp(_searchQuery, caseSensitive: false);
|
||||
return stocks.where((stock) => stock.symbol.contains(regexp));
|
||||
return stocks.where((Stock stock) => stock.symbol.contains(regexp));
|
||||
}
|
||||
|
||||
Widget buildStockList(BuildContext context, Iterable<Stock> stocks) {
|
||||
@@ -211,7 +213,7 @@ class StockHomeState extends State<StockHome> {
|
||||
)
|
||||
],
|
||||
selectedIndex: selectedTabIndex,
|
||||
onChanged: (tabIndex) {
|
||||
onChanged: (int tabIndex) {
|
||||
setState(() { selectedTabIndex = tabIndex; } );
|
||||
}
|
||||
);
|
||||
@@ -245,7 +247,7 @@ class StockHomeState extends State<StockHome> {
|
||||
navigator: config.navigator,
|
||||
placeholderKey: _snackBarPlaceholderKey,
|
||||
content: new Text("Stock purchased!"),
|
||||
actions: [
|
||||
actions: <SnackBarAction>[
|
||||
new SnackBarAction(label: "UNDO", onPressed: _handleUndo)
|
||||
]
|
||||
);
|
||||
|
||||
@@ -19,7 +19,7 @@ Future showStockMenu(NavigatorState navigator, { bool autorefresh, ValueChanged
|
||||
return <PopupMenuItem>[
|
||||
new PopupMenuItem(
|
||||
value: _MenuItems.autorefresh,
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Autorefresh')),
|
||||
new Checkbox(
|
||||
value: autorefresh,
|
||||
@@ -59,9 +59,9 @@ Future showStockMenu(NavigatorState navigator, { bool autorefresh, ValueChanged
|
||||
return new Dialog(
|
||||
title: new Text('Not Implemented'),
|
||||
content: new Text('This feature has not yet been implemented.'),
|
||||
actions: [
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Icon(
|
||||
type: 'device/dvr',
|
||||
size: 18
|
||||
|
||||
@@ -10,9 +10,15 @@ class StockRowPartGlobalKey extends GlobalKey {
|
||||
const StockRowPartGlobalKey(this.stock, this.part) : super.constructor();
|
||||
final Stock stock;
|
||||
final StockRowPartKind part;
|
||||
String toString() => '[StockRowPartGlobalKey ${stock.symbol}:${part.toString().split(".")[1]})]';
|
||||
bool operator==(other) => other is StockRowPartGlobalKey && identical(other.stock, stock) && identical(other.part, part);
|
||||
bool operator ==(dynamic other) {
|
||||
if (other is! StockRowPartGlobalKey)
|
||||
return false;
|
||||
final StockRowPartGlobalKey typedOther = other;
|
||||
return stock == typedOther.stock &&
|
||||
part == typedOther.part;
|
||||
}
|
||||
int get hashCode => 37 * (37 * (373) + identityHashCode(stock)) + identityHashCode(part);
|
||||
String toString() => '[StockRowPartGlobalKey ${stock.symbol}:${part.toString().split(".")[1]})]';
|
||||
}
|
||||
|
||||
typedef void StockRowActionCallback(Stock stock, GlobalKey row, GlobalKey arrowKey, GlobalKey symbolKey, GlobalKey priceKey);
|
||||
@@ -65,14 +71,14 @@ class StockRow extends StatelessComponent {
|
||||
bottom: new BorderSide(color: Theme.of(context).dividerColor)
|
||||
)
|
||||
),
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Container(
|
||||
key: arrowKey,
|
||||
child: new StockArrow(percentChange: stock.percentChange),
|
||||
margin: const EdgeDims.only(right: 5.0)
|
||||
),
|
||||
new Flexible(
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(
|
||||
flex: 2,
|
||||
child: new Text(
|
||||
|
||||
@@ -42,7 +42,7 @@ class StockSettingsState extends State<StockSettings> {
|
||||
onDismiss: () {
|
||||
navigator.pop(false);
|
||||
},
|
||||
actions: [
|
||||
actions: <Widget>[
|
||||
new FlatButton(
|
||||
child: new Text('NO THANKS'),
|
||||
onPressed: () {
|
||||
@@ -87,22 +87,22 @@ class StockSettingsState extends State<StockSettings> {
|
||||
child: new ScrollableViewport(
|
||||
child: new Container(
|
||||
padding: const EdgeDims.symmetric(vertical: 20.0),
|
||||
child: new BlockBody([
|
||||
child: new BlockBody(<Widget>[
|
||||
new DrawerItem(
|
||||
icon: 'action/thumb_up',
|
||||
onPressed: () => _confirmOptimismChange(),
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Everything is awesome')),
|
||||
new Checkbox(
|
||||
value: config.optimism == StockMode.optimistic,
|
||||
onChanged: (_) => _confirmOptimismChange()
|
||||
onChanged: (bool value) => _confirmOptimismChange()
|
||||
),
|
||||
])
|
||||
),
|
||||
new DrawerItem(
|
||||
icon: 'action/backup',
|
||||
onPressed: () { _handleBackupChanged(!(config.backup == BackupMode.enabled)); },
|
||||
child: new Row([
|
||||
child: new Row(<Widget>[
|
||||
new Flexible(child: new Text('Back up stock list to the cloud')),
|
||||
new Switch(
|
||||
value: config.backup == BackupMode.enabled,
|
||||
|
||||
@@ -33,12 +33,12 @@ class StockSymbolViewerState extends State<StockSymbolViewer> {
|
||||
center: new Text('${config.stock.name} (${config.stock.symbol})')
|
||||
),
|
||||
body: new Material(
|
||||
child: new Block([
|
||||
child: new Block(<Widget>[
|
||||
new Container(
|
||||
padding: new EdgeDims.all(20.0),
|
||||
child: new Column([
|
||||
child: new Column(<Widget>[
|
||||
new Text('Last Sale', style: headings),
|
||||
new Text('${lastSale} (${changeInPrice})'),
|
||||
new Text('$lastSale ($changeInPrice)'),
|
||||
new Container(
|
||||
height: 8.0
|
||||
),
|
||||
|
||||
Reference in New Issue
Block a user