Commit c674b4a8 authored by Adam Barth's avatar Adam Barth Committed by GitHub

Rename Image.fromNetwork and Image.fromAssetBundle (#5149)

These now have sorter names to make the callers less verbose.
parent 79364f0a
......@@ -427,7 +427,7 @@ class CardCollectionState extends State<CardCollection> {
if (_sunshine) {
cardCollection = new Stack(
children: <Widget>[
new Column(children: <Widget>[new Image.fromNetwork(src: _sunshineURL)]),
new Column(children: <Widget>[new Image.network(_sunshineURL)]),
new ShaderMask(child: cardCollection, shaderCallback: _createShader)
]
);
......
......@@ -157,8 +157,8 @@ class WeatherButton extends StatelessWidget {
child: new InkWell(
onTap: onPressed,
child: new Center(
child: new Image.fromAssetBundle(
name: icon,
child: new Image.asset(
icon,
width: _kWeatherIconSize,
height: _kWeatherIconSize
)
......
......@@ -66,8 +66,8 @@ class TravelDestinationItem extends StatelessWidget {
top: 0.0,
bottom: 0.0,
right: 0.0,
child: new Image.fromAssetBundle(
name: destination.assetName,
child: new Image.asset(
destination.assetName,
fit: ImageFit.cover
)
),
......
......@@ -129,8 +129,8 @@ class ContactsDemoState extends State<ContactsDemo> {
title : new Text('Ali Connors'),
background: new Stack(
children: <Widget>[
new Image.fromAssetBundle(
name: 'packages/flutter_gallery_assets/ali_connors.png',
new Image.asset(
'packages/flutter_gallery_assets/ali_connors.png',
fit: ImageFit.cover,
height: _appBarHeight
),
......
......@@ -62,10 +62,7 @@ class GridDemoPhotoItem extends StatelessWidget {
body: new Material(
child: new Hero(
tag: photoHeroTag,
child: new Image.fromAssetBundle(
name: photo.assetName,
fit: ImageFit.cover
)
child: new Image.asset(photo.assetName, fit: ImageFit.cover)
)
)
);
......@@ -80,10 +77,7 @@ class GridDemoPhotoItem extends StatelessWidget {
child: new Hero(
key: new Key(photo.assetName),
tag: photoHeroTag,
child: new Image.fromAssetBundle(
name: photo.assetName,
fit: ImageFit.cover
)
child: new Image.asset(photo.assetName, fit: ImageFit.cover)
)
);
......
......@@ -105,10 +105,7 @@ class _PestoDemoState extends State<PestoDemo> {
bottom: extraPadding
),
child: new Center(
child: new Image.fromAssetBundle(
name: _kLogoImages[bestHeight],
fit: ImageFit.scaleDown
)
child: new Image.asset(_kLogoImages[bestHeight], fit: ImageFit.scaleDown)
)
);
}
......@@ -134,10 +131,7 @@ class _PestoDemoState extends State<PestoDemo> {
padding: const EdgeInsets.all(2.0),
margin: const EdgeInsets.only(bottom: 16.0),
child: new ClipOval(
child: new Image.fromAssetBundle(
name: _kUserImage,
fit: ImageFit.contain
)
child: new Image.asset(_kUserImage, fit: ImageFit.contain)
)
),
new Text(_kUserName, style: userStyle),
......@@ -237,17 +231,14 @@ class _RecipeCard extends StatelessWidget {
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.fromAssetBundle(
name: recipe.imagePath,
fit: ImageFit.contain
),
new Image.asset(recipe.imagePath, fit: ImageFit.contain),
new Flexible(
child: new Row(
children: <Widget>[
new Padding(
padding: const EdgeInsets.all(16.0),
child: new Image.fromAssetBundle(
name: recipe.ingredientsImagePath,
child: new Image.asset(
recipe.ingredientsImagePath,
width: 48.0,
height: 48.0
)
......@@ -420,8 +411,8 @@ class _RecipeSheet extends StatelessWidget {
children: <Widget>[
new TableCell(
verticalAlignment: TableCellVerticalAlignment.middle,
child: new Image.fromAssetBundle(
name: recipe.ingredientsImagePath,
child: new Image.asset(
recipe.ingredientsImagePath,
width: 32.0,
height: 32.0,
alignment: FractionalOffset.centerLeft,
......
......@@ -78,10 +78,7 @@ class VendorItem extends StatelessWidget {
child: new ClipRRect(
xRadius: 12.0,
yRadius: 12.0,
child: new Image.fromAssetBundle(
name: vendor.avatarAsset,
fit: ImageFit.cover
)
child: new Image.asset(vendor.avatarAsset, fit: ImageFit.cover)
)
),
new SizedBox(width: 8.0),
......@@ -209,10 +206,7 @@ class FeatureItem extends StatelessWidget {
minHeight: 340.0,
maxHeight: 340.0,
alignment: FractionalOffset.topRight,
child: new Image.fromAssetBundle(
name: product.imageAsset,
fit: ImageFit.cover
)
child: new Image.asset(product.imageAsset, fit: ImageFit.cover)
)
)
),
......@@ -273,10 +267,7 @@ class ProductItem extends StatelessWidget {
child: new Hero(
tag: productHeroTag,
key: new ObjectKey(product),
child: new Image.fromAssetBundle(
name: product.imageAsset,
fit: ImageFit.contain
)
child: new Image.asset(product.imageAsset, fit: ImageFit.contain)
)
),
new Padding(
......
......@@ -41,10 +41,7 @@ class OrderItem extends StatelessWidget {
height: 248.0,
child: new Hero(
tag: productHeroTag,
child: new Image.fromAssetBundle(
name: product.imageAsset,
fit: ImageFit.contain
)
child: new Image.asset(product.imageAsset, fit: ImageFit.contain)
)
)
),
......@@ -201,10 +198,7 @@ class _OrderPageState extends State<OrderPage> {
.map((Product product) {
return new Card(
elevation: 0,
child: new Image.fromAssetBundle(
name: product.imageAsset,
fit: ImageFit.contain
)
child: new Image.asset(product.imageAsset, fit: ImageFit.contain)
);
}).toList()
)
......
......@@ -99,10 +99,7 @@ class _CardDataItem extends StatelessWidget {
new SizedBox(
width: 144.0,
height: 144.0,
child: new Image.fromAssetBundle(
name: data.imageAsset,
fit: ImageFit.contain
)
child: new Image.asset(data.imageAsset, fit: ImageFit.contain)
),
new Center(
child: new Text(data.title, style: Theme.of(context).textTheme.title)
......
......@@ -222,10 +222,7 @@ new ScrollableGrid(
footer: new GridTileBar(
title: new Text(url)
),
child: new Image.fromNetwork(
src: url,
fit: ImageFit.cover
)
child: new Image.network(url, fit: ImageFit.cover)
);
})
);
......
......@@ -96,8 +96,8 @@ class GalleryHomeState extends State<GalleryHome> {
appBar: new AppBar(
expandedHeight: _kFlexibleSpaceMaxHeight,
flexibleSpace: new FlexibleSpaceBar(
background: new Image.fromAssetBundle(
name: 'packages/flutter_gallery_assets/appbar_background.jpg',
background: new Image.asset(
'packages/flutter_gallery_assets/appbar_background.jpg',
fit: ImageFit.cover,
height: _kFlexibleSpaceMaxHeight
),
......
......@@ -51,7 +51,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) {
new RaisedButton(
child: new Row(
children: <Widget>[
new Image.fromNetwork(src: 'http://flutter.io/favicon.ico'),
new Image.network('http://flutter.io/favicon.ico'),
new Text('PRESS ME'),
]
),
......
......@@ -33,8 +33,8 @@ ImageConfiguration createLocalImageConfiguration(BuildContext context, { Size si
/// specified:
///
/// * [new Image], for obtaining an image from an [ImageProvider].
/// * [new Image.fromNetwork], for obtaining an image from a URL.
/// * [new Image.fromAssetBundle], for obtaining an image from an [AssetBundle]
/// * [new Image.network], for obtaining an image from a URL.
/// * [new Image.asset], for obtaining an image from an [AssetBundle]
/// using a key.
///
/// To automatically perform pixel-density-aware asset resolution, specify the
......@@ -47,7 +47,7 @@ class Image extends StatefulWidget {
/// Creates a widget that displays an image.
///
/// To show an image from the network or from an asset bundle, consider using
/// [new Image.fromNetwork] and [new Image.fromAssetBundle] respectively.
/// [new Image.network] and [new Image.asset] respectively.
///
/// The [image] and [repeat] arguments must not be null.
Image({
......@@ -68,9 +68,8 @@ class Image extends StatefulWidget {
/// Creates a widget that displays an [ImageStream] obtained from the network.
///
/// The [src], [scale], and [repeat] arguments must not be null.
Image.fromNetwork({
Image.network(String src, {
Key key,
@required String src,
double scale: 1.0,
this.width,
this.height,
......@@ -96,10 +95,9 @@ class Image extends StatefulWidget {
/// size-aware asset resolution will be attempted also.
///
/// The [name] and [repeat] arguments must not be null.
Image.fromAssetBundle({
Image.asset(String name, {
Key key,
AssetBundle bundle,
@required String name,
double scale,
this.width,
this.height,
......
......@@ -485,11 +485,7 @@ class _Block {
}
}
return new Image.fromNetwork(
src: path,
width: width,
height: height
);
return new Image.network(path, width: width, height: height);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment