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),
......
......@@ -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