Commit a0e91bf9 authored by Sarah Zakarias's avatar Sarah Zakarias Committed by GitHub

Update Flutter Gallery to use new asset api for package assets (#12254)

parent 49ba9747
......@@ -12,17 +12,33 @@ const Color _tomato = const Color(0xFFF95B57);
const Color _mySin = const Color(0xFFF3A646);
const Color _deepCerise = const Color(0xFFD93F9B);
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class SectionDetail {
const SectionDetail({ this.title, this.subtitle, this.imageAsset });
const SectionDetail({
this.title,
this.subtitle,
this.imageAsset,
this.imageAssetPackage,
});
final String title;
final String subtitle;
final String imageAsset;
final String imageAssetPackage;
}
class Section {
const Section({ this.title, this.backgroundAsset, this.leftColor, this.rightColor, this.details });
const Section({
this.title,
this.backgroundAsset,
this.backgroundAssetPackage,
this.leftColor,
this.rightColor,
this.details,
});
final String title;
final String backgroundAsset;
final String backgroundAssetPackage;
final Color leftColor;
final Color rightColor;
final List<SectionDetail> details;
......@@ -44,43 +60,51 @@ class Section {
// image SectionDetails in the allSections list.
const SectionDetail _eyeglassesDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png',
imageAsset: 'shrine/products/sunnies.png',
imageAssetPackage: _kGalleryAssetsPackage,
title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days',
);
const SectionDetail _eyeglassesImageDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png',
imageAsset: 'shrine/products/sunnies.png',
imageAssetPackage: _kGalleryAssetsPackage,
);
const SectionDetail _seatingDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png',
imageAsset: 'shrine/products/lawn_chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days',
);
const SectionDetail _seatingImageDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png',
imageAsset: 'shrine/products/lawn_chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
);
const SectionDetail _decorationDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lipstick.png',
imageAsset: 'shrine/products/lipstick.png',
imageAssetPackage: _kGalleryAssetsPackage,
title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days',
);
const SectionDetail _decorationImageDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lipstick.png',
imageAsset: 'shrine/products/lipstick.png',
imageAssetPackage: _kGalleryAssetsPackage,
);
const SectionDetail _protectionDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/helmet.png',
imageAsset: 'shrine/products/helmet.png',
imageAssetPackage: _kGalleryAssetsPackage,
title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days',
);
const SectionDetail _protectionImageDetail = const SectionDetail(
imageAsset: 'packages/flutter_gallery_assets/shrine/products/helmet.png',
imageAsset: 'shrine/products/helmet.png',
imageAssetPackage: _kGalleryAssetsPackage,
);
final List<Section> allSections = <Section>[
......@@ -88,7 +112,8 @@ final List<Section> allSections = <Section>[
title: 'EYEGLASSES',
leftColor: _mediumPurple,
rightColor: _mariner,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png',
backgroundAsset: 'shrine/products/sunnies.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[
_eyeglassesDetail,
_eyeglassesImageDetail,
......@@ -102,7 +127,8 @@ final List<Section> allSections = <Section>[
title: 'SEATING',
leftColor: _tomato,
rightColor: _mediumPurple,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png',
backgroundAsset: 'shrine/products/lawn_chair.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[
_seatingDetail,
_seatingImageDetail,
......@@ -116,7 +142,8 @@ final List<Section> allSections = <Section>[
title: 'DECORATION',
leftColor: _mySin,
rightColor: _tomato,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/lipstick.png',
backgroundAsset: 'shrine/products/lipstick.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[
_decorationDetail,
_decorationImageDetail,
......@@ -130,7 +157,8 @@ final List<Section> allSections = <Section>[
title: 'PROTECTION',
leftColor: Colors.white,
rightColor: _tomato,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/helmet.png',
backgroundAsset: 'shrine/products/helmet.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[
_protectionDetail,
_protectionImageDetail,
......
......@@ -35,6 +35,7 @@ class SectionCard extends StatelessWidget {
),
child: new Image.asset(
section.backgroundAsset,
package: section.backgroundAssetPackage,
color: const Color.fromRGBO(255, 255, 255, 0.075),
colorBlendMode: BlendMode.modulate,
fit: BoxFit.cover,
......@@ -130,7 +131,10 @@ class SectionDetailView extends StatelessWidget {
decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(6.0),
image: new DecorationImage(
image: new AssetImage(detail.imageAsset),
image: new AssetImage(
detail.imageAsset,
package: detail.imageAssetPackage,
),
fit: BoxFit.cover,
alignment: FractionalOffset.center,
),
......
......@@ -156,7 +156,8 @@ class ContactsDemoState extends State<ContactsDemo> {
fit: StackFit.expand,
children: <Widget>[
new Image.asset(
'packages/flutter_gallery_assets/ali_connors.jpg',
'ali_connors.jpg',
package: 'flutter_gallery_assets',
fit: BoxFit.cover,
height: _appBarHeight,
),
......
......@@ -5,10 +5,18 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class TravelDestination {
const TravelDestination({ this.assetName, this.title, this.description });
const TravelDestination({
this.assetName,
this.assetPackage,
this.title,
this.description,
});
final String assetName;
final String assetPackage;
final String title;
final List<String> description;
......@@ -17,7 +25,8 @@ class TravelDestination {
final List<TravelDestination> destinations = <TravelDestination>[
const TravelDestination(
assetName: 'packages/flutter_gallery_assets/top_10_australian_beaches.jpg',
assetName: 'top_10_australian_beaches.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Top 10 Australian beaches',
description: const <String>[
'Number 10',
......@@ -26,7 +35,8 @@ final List<TravelDestination> destinations = <TravelDestination>[
],
),
const TravelDestination(
assetName: 'packages/flutter_gallery_assets/kangaroo_valley_safari.jpg',
assetName: 'kangaroo_valley_safari.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Kangaroo Valley Safari',
description: const <String>[
'2031 Moss Vale Road',
......@@ -65,6 +75,7 @@ class TravelDestinationItem extends StatelessWidget {
new Positioned.fill(
child: new Image.asset(
destination.assetName,
package: destination.assetPackage,
fit: BoxFit.cover,
),
),
......
......@@ -4,9 +4,10 @@
import 'package:flutter/material.dart';
const String _kAsset0 = 'packages/flutter_gallery_assets/shrine/vendors/zach.jpg';
const String _kAsset1 = 'packages/flutter_gallery_assets/shrine/vendors/16c477b.jpg';
const String _kAsset2 = 'packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg';
const String _kAsset0 = 'shrine/vendors/zach.jpg';
const String _kAsset1 = 'shrine/vendors/16c477b.jpg';
const String _kAsset2 = 'shrine/vendors/sandra-adams.jpg';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class DrawerDemo extends StatefulWidget {
static const String routeName = '/material/drawer';
......@@ -93,10 +94,25 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
new UserAccountsDrawerHeader(
accountName: const Text('Zach Widget'),
accountEmail: const Text('zach.widget@example.com'),
currentAccountPicture: const CircleAvatar(backgroundImage: const AssetImage(_kAsset0)),
currentAccountPicture: const CircleAvatar(
backgroundImage: const AssetImage(
_kAsset0,
package: _kGalleryAssetsPackage,
),
),
otherAccountsPictures: const <Widget>[
const CircleAvatar(backgroundImage: const AssetImage(_kAsset1)),
const CircleAvatar(backgroundImage: const AssetImage(_kAsset2)),
const CircleAvatar(
backgroundImage: const AssetImage(
_kAsset1,
package: _kGalleryAssetsPackage,
),
),
const CircleAvatar(
backgroundImage: const AssetImage(
_kAsset2,
package: _kGalleryAssetsPackage,
),
),
],
onDetailsPressed: () {
_showDrawerContents = !_showDrawerContents;
......@@ -167,7 +183,10 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
decoration: const BoxDecoration(
shape: BoxShape.circle,
image: const DecorationImage(
image: const AssetImage(_kAsset0),
image: const AssetImage(
_kAsset0,
package: _kGalleryAssetsPackage,
),
),
),
),
......
......@@ -14,11 +14,19 @@ enum GridDemoTileStyle {
typedef void BannerTapCallback(Photo photo);
const double _kMinFlingVelocity = 800.0;
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class Photo {
Photo({ this.assetName, this.title, this.caption, this.isFavorite: false });
Photo({
this.assetName,
this.assetPackage,
this.title,
this.caption,
this.isFavorite: false,
});
final String assetName;
final String assetPackage;
final String title;
final String caption;
......@@ -130,7 +138,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
transform: new Matrix4.identity()
..translate(_offset.dx, _offset.dy)
..scale(_scale),
child: new Image.asset(widget.photo.assetName, fit: BoxFit.cover),
child: new Image.asset(
widget.photo.assetName,
package: widget.photo.assetPackage,
fit: BoxFit.cover,
),
),
),
);
......@@ -177,7 +189,11 @@ class GridDemoPhotoItem extends StatelessWidget {
child: new Hero(
key: new Key(photo.assetName),
tag: photo.tag,
child: new Image.asset(photo.assetName, fit: BoxFit.cover)
child: new Image.asset(
photo.assetName,
package: photo.assetPackage,
fit: BoxFit.cover,
)
)
);
......@@ -239,62 +255,74 @@ class GridListDemoState extends State<GridListDemo> {
List<Photo> photos = <Photo>[
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_0.jpg',
assetName: 'landscape_0.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Philippines',
caption: 'Batad rice terraces',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_1.jpg',
assetName: 'landscape_1.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Italy',
caption: 'Ceresole Reale',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_2.jpg',
assetName: 'landscape_2.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Somewhere',
caption: 'Beautiful mountains',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_3.jpg',
assetName: 'landscape_3.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'A place',
caption: 'Beautiful hills',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_4.jpg',
assetName: 'landscape_4.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'New Zealand',
caption: 'View from the van',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_5.jpg',
assetName: 'landscape_5.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Autumn',
caption: 'The golden season',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_6.jpg',
assetName: 'landscape_6.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Germany',
caption: 'Englischer Garten',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_7.jpg',
assetName: 'landscape_7.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'A country',
caption: 'Grass fields',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_8.jpg',
assetName: 'landscape_8.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Mountain country',
caption: 'River forest',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_9.jpg',
assetName: 'landscape_9.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Alpine place',
caption: 'Green hills',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_10.jpg',
assetName: 'landscape_10.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Desert land',
caption: 'Blue skies',
),
new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_11.jpg',
assetName: 'landscape_11.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Narnia',
caption: 'Rocks and rivers',
),
......
......@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
// Each TabBarView contains a _Page and for each _Page there is a list
// of _CardData objects. Each _CardData object is displayed by a _CardItem.
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class _Page {
_Page({ this.label });
final String label;
......@@ -14,62 +16,75 @@ class _Page {
}
class _CardData {
const _CardData({ this.title, this.imageAsset });
const _CardData({ this.title, this.imageAsset, this.imageAssetPackage });
final String title;
final String imageAsset;
final String imageAssetPackage;
}
final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
new _Page(label: 'LEFT'): <_CardData>[
const _CardData(
title: 'Vintage Bluetooth Radio',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/radio.png',
imageAsset: 'shrine/products/radio.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Sunglasses',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png',
imageAsset: 'shrine/products/sunnies.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Clock',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/clock.png',
imageAsset: 'shrine/products/clock.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Red popsicle',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/popsicle.png',
imageAsset: 'shrine/products/popsicle.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Folding Chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png',
imageAsset: 'shrine/products/lawn_chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Green comfort chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chair.png',
imageAsset: 'shrine/products/chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Old Binoculars',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/binoculars.png',
imageAsset: 'shrine/products/binoculars.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Teapot',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/teapot.png',
imageAsset: 'shrine/products/teapot.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Blue suede shoes',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chucks.png',
imageAsset: 'shrine/products/chucks.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Dipped Brush',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/brush.png',
imageAsset: 'shrine/products/brush.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
const _CardData(
title: 'Perfect Goldfish Bowl',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/fish_bowl.png',
imageAsset: 'shrine/products/fish_bowl.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
],
new _Page(label: 'RIGHT'): <_CardData>[
const _CardData(
title: 'Beachball',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/beachball.png',
imageAsset: 'shrine/products/beachball.png',
imageAssetPackage: _kGalleryAssetsPackage,
),
],
};
......@@ -99,7 +114,11 @@ class _CardDataItem extends StatelessWidget {
new SizedBox(
width: 144.0,
height: 144.0,
child: new Image.asset(data.imageAsset, fit: BoxFit.contain),
child: new Image.asset(
data.imageAsset,
package: data.imageAssetPackage,
fit: BoxFit.contain,
),
),
new Center(
child: new Text(data.title, style: Theme.of(context).textTheme.title),
......
......@@ -14,8 +14,9 @@ class PestoDemo extends StatelessWidget {
Widget build(BuildContext context) => new PestoHome();
}
const String _kSmallLogoImage = 'packages/flutter_gallery_assets/pesto/logo_small.png';
const String _kMediumLogoImage = 'packages/flutter_gallery_assets/pesto/logo_medium.png';
const String _kSmallLogoImage = 'pesto/logo_small.png';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
const double _kAppBarHeight = 128.0;
const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size
const double _kRecipePageMaxWidth = 500.0;
......@@ -218,7 +219,11 @@ class _PestoLogoState extends State<PestoLogo> {
children: <Widget>[
new Positioned.fromRect(
rect: _imageRectTween.lerp(widget.t),
child: new Image.asset(_kSmallLogoImage, fit: BoxFit.contain),
child: new Image.asset(
_kSmallLogoImage,
package: _kGalleryAssetsPackage,
fit: BoxFit.contain,
),
),
new Positioned.fromRect(
rect: _textRectTween.lerp(widget.t),
......@@ -254,8 +259,12 @@ class RecipeCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Hero(
tag: recipe.imagePath,
child: new Image.asset(recipe.imagePath, fit: BoxFit.contain)
tag: 'packages/$_kGalleryAssetsPackage/${recipe.imagePath}',
child: new Image.asset(
recipe.imagePath,
package: recipe.imagePackage,
fit: BoxFit.contain,
),
),
new Expanded(
child: new Row(
......@@ -264,6 +273,7 @@ class RecipeCard extends StatelessWidget {
padding: const EdgeInsets.all(16.0),
child: new Image.asset(
recipe.ingredientsImagePath,
package: recipe.ingredientsImagePackage,
width: 48.0,
height: 48.0,
),
......@@ -324,9 +334,10 @@ class _RecipePageState extends State<RecipePage> {
right: 0.0,
height: appBarHeight + _kFabHalfSize,
child: new Hero(
tag: widget.recipe.imagePath,
tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe.imagePath}',
child: new Image.asset(
widget.recipe.imagePath,
package: widget.recipe.imagePackage,
fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover,
),
),
......@@ -436,6 +447,7 @@ class RecipeSheet extends StatelessWidget {
verticalAlignment: TableCellVerticalAlignment.middle,
child: new Image.asset(
recipe.ingredientsImagePath,
package: recipe.ingredientsImagePackage,
width: 32.0,
height: 32.0,
alignment: FractionalOffset.centerLeft,
......@@ -512,7 +524,9 @@ class Recipe {
this.author,
this.description,
this.imagePath,
this.imagePackage,
this.ingredientsImagePath,
this.ingredientsImagePackage,
this.ingredients,
this.steps
});
......@@ -521,7 +535,9 @@ class Recipe {
final String author;
final String description;
final String imagePath;
final String imagePackage;
final String ingredientsImagePath;
final String ingredientsImagePackage;
final List<RecipeIngredient> ingredients;
final List<RecipeStep> steps;
}
......@@ -544,9 +560,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Pesto Bruschetta',
author: 'Peter Carlsson',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/quick.png',
ingredientsImagePath: 'pesto/quick.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Bask in greens this season by trying this delightful take on traditional bruschetta. Top with a dollop of homemade pesto, and season with freshly ground sea salt and pepper.',
imagePath: 'packages/flutter_gallery_assets/pesto/image1.jpg',
imagePath: 'pesto/image1.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '6 pieces', description: 'Mozzarella cheese'),
const RecipeIngredient(amount: '6 pieces', description: 'Toasts'),
......@@ -562,9 +580,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Rustic purple mash',
author: 'Trevor Hansen',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/veggie.png',
ingredientsImagePath: 'pesto/veggie.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Abundant in color, and healthy, delicious goodness, cooking with these South American purple potatoes is a treat. Boil, mash, bake, or roast them. For taste cook with chicken stock, and a dash of extra virgin olive oil.',
imagePath: 'packages/flutter_gallery_assets/pesto/image2.jpg',
imagePath: 'pesto/image2.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '2 lbs', description: 'Purple potatoes, skin on'),
const RecipeIngredient(amount: '1 tsp', description: 'Salt'),
......@@ -580,9 +600,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Bacon Sprouts',
author: 'Ali Connors',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/main.png',
ingredientsImagePath: 'pesto/main.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'This beautiful sprouts recipe is the most glorious side dish on a cold winter’s night. Construct it with bacon or fake-on, but always make sure the sprouts are deliciously seasoned and appropriately sautéed.',
imagePath: 'packages/flutter_gallery_assets/pesto/image3.jpg',
imagePath: 'pesto/image3.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '2 lbs', description: 'Brussel sprouts'),
const RecipeIngredient(amount: '3 lbs', description: 'Bacon'),
......@@ -599,9 +621,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Oven Sausage',
author: 'Sandra Adams',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/meat.png',
ingredientsImagePath: 'pesto/meat.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Robust cuts of portuguese sausage add layers of flavour. Bake or fry until sausages are slightly browned and with a crispy skin. Serve warm and with cuts of pineapple for a delightful mix of sweet and savory flavour. This is the perfect dish after a swim in the sea.',
imagePath: 'packages/flutter_gallery_assets/pesto/image4.jpg',
imagePath: 'pesto/image4.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1 1/2 lbs', description: 'Linguisa'),
const RecipeIngredient(amount: '1 lbs', description: 'Pineapple or other fresh citrus fruit'),
......@@ -614,9 +638,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Chicken tostadas',
author: 'Peter Carlsson',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/spicy.png',
ingredientsImagePath: 'pesto/spicy.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Crisp flavours and a bit of spice make this roasted chicken dish an easy go to when cooking for large groups. Top with Baja sauce for an extra kick of spice.',
imagePath: 'packages/flutter_gallery_assets/pesto/image5.jpg',
imagePath: 'pesto/image5.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '4-6', description: 'Small corn tortillas'),
const RecipeIngredient(amount: '½ cup', description: 'Chopped onion'),
......@@ -631,9 +657,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Coconut rice',
author: 'Ali Connors',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/healthy.png',
ingredientsImagePath: 'pesto/healthy.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'This dish is a terrific pairing to almost any main. Bonus- it’s quick, easy to make, and turns even the simplest of dishes into a delicacy. Sweet coconut cream will leave your mouth watering, with yummy caramelized flecks of rice adding an extra bit of taste. Fluff with fork before serving for best results.',
imagePath: 'packages/flutter_gallery_assets/pesto/image6.jpg',
imagePath: 'pesto/image6.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '2 cups', description: 'Jasmine rice'),
const RecipeIngredient(amount: '1 1/2 cups', description: 'Water'),
......@@ -649,9 +677,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Gin basil cocktail',
author: 'Trevor Hansen',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/quick.png',
ingredientsImagePath: 'pesto/quick.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'This mellow and herb filled blending of simple ingredients is easy enough to mix that a novice host will feel like a seasoned bartender. Top with crushed basil, shake or stir.',
imagePath: 'packages/flutter_gallery_assets/pesto/image7.jpg',
imagePath: 'pesto/image7.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '3 parts', description: 'Gin'),
const RecipeIngredient(amount: '1 part', description: 'Fresh lemon juice'),
......@@ -666,9 +696,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Seared sesame fish',
author: 'Ali Connors',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/fish.png',
ingredientsImagePath: 'pesto/fish.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Cuts of fish like this are perfect for simple searing with bright flavours. Try Sesame seeds on these fillets for crusty skin filled with crunch. For added flavour try dipping in a homemade ponzu sauce - delicious.',
imagePath: 'packages/flutter_gallery_assets/pesto/image8.jpg',
imagePath: 'pesto/image8.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1 ½ lbs', description: 'Thin fish fillets'),
const RecipeIngredient(amount: '1 lb', description: 'Salt and black pepper to taste'),
......@@ -685,9 +717,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Herb artichoke',
author: 'Sandra Adams',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/healthy.png',
ingredientsImagePath: 'pesto/healthy.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'This tasty and healthy veggie is a favorite. Artichoke like this can be paired with a hearty main or works well as a small meal with some white wine on the side. Simple and fresh, all foodies love tasty artichoke.',
imagePath: 'packages/flutter_gallery_assets/pesto/image9.jpg',
imagePath: 'pesto/image9.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1', description: 'Small garlic clove, peeled'),
const RecipeIngredient(amount: '2', description: 'Whole artichokes'),
......@@ -704,9 +738,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Pesto bruschetta',
author: 'Trevor Hansen',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/veggie.png',
ingredientsImagePath: 'pesto/veggie.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Life is good when you add amazingly warm bread, fresh pesto sauce, and roasted tomatoes to the table. This a classic starter to break out in a pinch. It’s easy to make and extra tasty.',
imagePath: 'packages/flutter_gallery_assets/pesto/image10.jpg',
imagePath: 'pesto/image10.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1 loaf', description: 'Sliced French bread'),
const RecipeIngredient(amount: '½ cup', description: 'Cheese'),
......@@ -725,9 +761,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Garlic bok choy',
author: 'Sandra Adams',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/spicy.png',
ingredientsImagePath: 'pesto/spicy.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Great stir-fried bok choy starts at the market. For me, nothing says tasty like garlic and baby bok choy. Choose fresh, crisp greens. Once home, wash, chop, and then ready for the wok. No family style spread is complete without these greens.',
imagePath: 'packages/flutter_gallery_assets/pesto/image11.jpg',
imagePath: 'pesto/image11.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1/2 cup', description: 'Chick broth'),
const RecipeIngredient(amount: '1 tbsp', description: 'Soy sauce'),
......@@ -743,9 +781,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Fresh Fettuccine',
author: 'Ali Connors',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/main.png',
ingredientsImagePath: 'pesto/main.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'Satisfy a need for rich, creamy homemade goodness with this classic. Creamy fettuccine alfredo will have you hitting the gym the next day, but it’s so good it’s worth it.',
imagePath: 'packages/flutter_gallery_assets/pesto/image12.jpg',
imagePath: 'pesto/image12.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '¾ cup', description: 'Milk'),
const RecipeIngredient(amount: '1 ½ tsp', description: 'Salt'),
......@@ -762,9 +802,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe(
name: 'Sicilian-Style sardines',
author: 'Peter Carlsson',
ingredientsImagePath: 'packages/flutter_gallery_assets/pesto/quick.png',
ingredientsImagePath: 'pesto/quick.png',
ingredientsImagePackage: _kGalleryAssetsPackage,
description: 'My go to way to eat sardines is with a splash of tangy lemon and fresh fennel drizzled on top. The best thing about this dish is the flavour it packs. Prepaid with wild caught sardines or canned.',
imagePath: 'packages/flutter_gallery_assets/pesto/image13.jpg',
imagePath: 'pesto/image13.jpg',
imagePackage: _kGalleryAssetsPackage,
ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1/4 cup', description: 'Dry white wine'),
const RecipeIngredient(amount: '1', description: 'Finely chopped shallot'),
......
......@@ -4,9 +4,12 @@
import 'shrine_types.dart';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
const Vendor _ali = const Vendor(
name: 'Ali’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/ali-connors.png',
avatarAsset: 'shrine/vendors/ali-connors.png',
avatarAssetPackage: _kGalleryAssetsPackage,
description:
'Ali Connor’s makes custom goods for folks of all shapes and sizes '
'made by hand and sometimes by machine, but always with love and care. '
......@@ -15,7 +18,8 @@ const Vendor _ali = const Vendor(
const Vendor _sandra = const Vendor(
name: 'Sandra’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg',
avatarAsset: 'shrine/vendors/sandra-adams.jpg',
avatarAssetPackage: _kGalleryAssetsPackage,
description:
'Sandra specializes in furniture, beauty and travel products with a classic vibe. '
'Custom orders are available if you’re looking for a certain color or material.'
......@@ -23,7 +27,8 @@ const Vendor _sandra = const Vendor(
const Vendor _trevor = const Vendor(
name: 'Trevor’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/zach.jpg',
avatarAsset: 'shrine/vendors/zach.jpg',
avatarAssetPackage: _kGalleryAssetsPackage,
description:
'Trevor makes great stuff for awesome people like you. Super cool and extra '
'awesome all of his shop’s goods are handmade with love. Custom orders are '
......@@ -32,7 +37,8 @@ const Vendor _trevor = const Vendor(
const Vendor _peter = const Vendor(
name: 'Peter’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/peter-carlsson.png',
avatarAsset: 'shrine/vendors/peter-carlsson.png',
avatarAssetPackage: _kGalleryAssetsPackage,
description:
'Peter makes great stuff for awesome people like you. Super cool and extra '
'awesome all of his shop’s goods are handmade with love. Custom orders are '
......@@ -41,7 +47,8 @@ const Vendor _peter = const Vendor(
const Vendor _stella = const Vendor(
name: 'Stella’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/16c477b.jpg',
avatarAsset: 'shrine/vendors/16c477b.jpg',
avatarAssetPackage: _kGalleryAssetsPackage,
description:
'Stella sells awesome stuff at lovely prices. made by hand and sometimes by '
'machine, but always with love and care. Custom orders are available upon request '
......@@ -51,7 +58,8 @@ const Vendor _stella = const Vendor(
const List<Product> _allProducts = const <Product> [
const Product(
name: 'Vintage Bluetooth Radio',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/radio.png',
imageAsset: 'shrine/products/radio.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture', 'latest'],
price: 300.00,
vendor: _sandra,
......@@ -62,7 +70,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Sunglasses',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png',
imageAsset: 'shrine/products/sunnies.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion', 'beauty'],
price: 20.00,
vendor: _trevor,
......@@ -74,7 +83,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Clock',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/clock.png',
imageAsset: 'shrine/products/clock.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture'],
price: 30.00,
vendor: _trevor,
......@@ -85,7 +95,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Red popsicle',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/popsicle.png',
imageAsset: 'shrine/products/popsicle.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['food', 'fashion'],
price: 300.00,
vendor: _stella,
......@@ -96,7 +107,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Folding Chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png',
imageAsset: 'shrine/products/lawn_chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture'],
price: 63.00,
vendor: _stella,
......@@ -105,7 +117,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Green comfort chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chair.png',
imageAsset: 'shrine/products/chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture'],
price: 36.00,
vendor: _ali,
......@@ -114,7 +127,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Better wearing heels',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/heels.png',
imageAsset: 'shrine/products/heels.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['fashion'],
price: 125.00,
vendor: _peter,
......@@ -123,7 +137,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Green Slip-ons',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/green-shoes.png',
imageAsset: 'shrine/products/green-shoes.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion'],
price: 75.00,
vendor: _sandra,
......@@ -134,7 +149,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Teapot',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/teapot.png',
imageAsset: 'shrine/products/teapot.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture', 'fashion'],
price: 70.00,
vendor: _trevor,
......@@ -148,7 +164,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Blue suede shoes',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chucks.png',
imageAsset: 'shrine/products/chucks.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion'],
price: 89.00,
vendor: _trevor,
......@@ -158,7 +175,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Dipped Brush',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/brush.png',
imageAsset: 'shrine/products/brush.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['fashion', 'beauty'],
price: 25.00,
vendor: _stella,
......@@ -169,7 +187,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Perfect Goldfish Bowl',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/fish_bowl.png',
imageAsset: 'shrine/products/fish_bowl.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['latest', 'furniture'],
price: 30.00,
vendor: _ali,
......@@ -180,7 +199,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Red Lipstick Set',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lipstick.png',
imageAsset: 'shrine/products/lipstick.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['fashion', 'beauty'],
price: 54.00,
vendor: _sandra,
......@@ -191,7 +211,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Backpack',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/backpack.png',
imageAsset: 'shrine/products/backpack.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion'],
price: 25.00,
vendor: _peter,
......@@ -202,7 +223,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Half Shield Helmet',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/helmet.png',
imageAsset: 'shrine/products/helmet.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion', 'latest'],
price: 25.00,
vendor: _ali,
......@@ -213,7 +235,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Beachball',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/beachball.png',
imageAsset: 'shrine/products/beachball.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['latest'],
price: 17.00,
vendor: _peter,
......@@ -224,7 +247,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Old Binoculars',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/binoculars.png',
imageAsset: 'shrine/products/binoculars.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion', 'latest'],
price: 25.00,
vendor: _stella,
......@@ -236,7 +260,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Lime Flippers',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/flippers.png',
imageAsset: 'shrine/products/flippers.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion', 'beauty'],
price: 25.00,
vendor: _peter,
......@@ -247,7 +272,8 @@ const List<Product> _allProducts = const <Product> [
),
const Product(
name: 'Surfboard',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/surfboard.png',
imageAsset: 'shrine/products/surfboard.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>[ 'travel', 'latest'],
price: 120.00,
vendor: _stella,
......
......@@ -132,7 +132,11 @@ class _VendorItem extends StatelessWidget {
width: 24.0,
child: new ClipRRect(
borderRadius: new BorderRadius.circular(12.0),
child: new Image.asset(vendor.avatarAsset, fit: BoxFit.cover),
child: new Image.asset(
vendor.avatarAsset,
package: vendor.avatarAssetPackage,
fit: BoxFit.cover,
),
),
),
const SizedBox(width: 8.0),
......@@ -271,7 +275,11 @@ class _Heading extends StatelessWidget {
),
new LayoutId(
id: _HeadingLayout.image,
child: new Image.asset(product.imageAsset, fit: BoxFit.cover),
child: new Image.asset(
product.imageAsset,
package: product.imageAssetPackage,
fit: BoxFit.cover,
),
),
new LayoutId(
id: _HeadingLayout.title,
......@@ -321,7 +329,11 @@ class _ProductItem extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: new Hero(
tag: product.tag,
child: new Image.asset(product.imageAsset, fit: BoxFit.contain),
child: new Image.asset(
product.imageAsset,
package: product.imageAssetPackage,
fit: BoxFit.contain,
),
),
),
new Padding(
......
......@@ -172,6 +172,7 @@ class _Heading extends StatelessWidget {
tag: product.tag,
child: new Image.asset(
product.imageAsset,
package: product.imageAssetPackage,
fit: BoxFit.contain,
alignment: FractionalOffset.center,
),
......@@ -302,6 +303,7 @@ class _OrderPageState extends State<OrderPage> {
elevation: 1.0,
child: new Image.asset(
product.imageAsset,
package: product.imageAssetPackage,
fit: BoxFit.contain,
),
);
......
......@@ -10,12 +10,14 @@ class Vendor {
const Vendor({
this.name,
this.description,
this.avatarAsset
this.avatarAsset,
this.avatarAssetPackage,
});
final String name;
final String description;
final String avatarAsset;
final String avatarAssetPackage;
bool isValid() {
return name != null &&
......@@ -34,6 +36,7 @@ class Product {
this.featureTitle,
this.featureDescription,
this.imageAsset,
this.imageAssetPackage,
this.categories,
this.price,
this.vendor
......@@ -44,6 +47,7 @@ class Product {
final String featureTitle;
final String featureDescription;
final String imageAsset;
final String imageAssetPackage;
final List<String> categories;
final double price;
final Vendor vendor;
......
......@@ -9,12 +9,15 @@ import 'drawer.dart';
import 'item.dart';
const double _kFlexibleSpaceMaxHeight = 256.0;
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class _BackgroundLayer {
_BackgroundLayer({ int level, double parallax })
: assetName = 'packages/flutter_gallery_assets/appbar/appbar_background_layer$level.png',
: assetName = 'appbar/appbar_background_layer$level.png',
assetPackage = _kGalleryAssetsPackage,
parallaxTween = new Tween<double>(begin: 0.0, end: parallax);
final String assetName;
final String assetPackage;
final Tween<double> parallaxTween;
}
......@@ -46,6 +49,7 @@ class _AppBarBackground extends StatelessWidget {
bottom: 0.0,
child: new Image.asset(
layer.assetName,
package: layer.assetPackage,
fit: BoxFit.cover,
height: _kFlexibleSpaceMaxHeight
)
......
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