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