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); ...@@ -12,17 +12,33 @@ const Color _tomato = const Color(0xFFF95B57);
const Color _mySin = const Color(0xFFF3A646); const Color _mySin = const Color(0xFFF3A646);
const Color _deepCerise = const Color(0xFFD93F9B); const Color _deepCerise = const Color(0xFFD93F9B);
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class SectionDetail { 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 title;
final String subtitle; final String subtitle;
final String imageAsset; final String imageAsset;
final String imageAssetPackage;
} }
class Section { 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 title;
final String backgroundAsset; final String backgroundAsset;
final String backgroundAssetPackage;
final Color leftColor; final Color leftColor;
final Color rightColor; final Color rightColor;
final List<SectionDetail> details; final List<SectionDetail> details;
...@@ -44,43 +60,51 @@ class Section { ...@@ -44,43 +60,51 @@ class Section {
// image SectionDetails in the allSections list. // image SectionDetails in the allSections list.
const SectionDetail _eyeglassesDetail = const SectionDetail( 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', title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days', subtitle: '3K views - 5 days',
); );
const SectionDetail _eyeglassesImageDetail = const SectionDetail( 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( 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', title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days', subtitle: '3K views - 5 days',
); );
const SectionDetail _seatingImageDetail = const SectionDetail( 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( 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', title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days', subtitle: '3K views - 5 days',
); );
const SectionDetail _decorationImageDetail = const SectionDetail( 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( 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', title: 'Flutter enables interactive animation',
subtitle: '3K views - 5 days', subtitle: '3K views - 5 days',
); );
const SectionDetail _protectionImageDetail = const SectionDetail( 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>[ final List<Section> allSections = <Section>[
...@@ -88,7 +112,8 @@ final List<Section> allSections = <Section>[ ...@@ -88,7 +112,8 @@ final List<Section> allSections = <Section>[
title: 'EYEGLASSES', title: 'EYEGLASSES',
leftColor: _mediumPurple, leftColor: _mediumPurple,
rightColor: _mariner, rightColor: _mariner,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png', backgroundAsset: 'shrine/products/sunnies.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[ details: const <SectionDetail>[
_eyeglassesDetail, _eyeglassesDetail,
_eyeglassesImageDetail, _eyeglassesImageDetail,
...@@ -102,7 +127,8 @@ final List<Section> allSections = <Section>[ ...@@ -102,7 +127,8 @@ final List<Section> allSections = <Section>[
title: 'SEATING', title: 'SEATING',
leftColor: _tomato, leftColor: _tomato,
rightColor: _mediumPurple, rightColor: _mediumPurple,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png', backgroundAsset: 'shrine/products/lawn_chair.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[ details: const <SectionDetail>[
_seatingDetail, _seatingDetail,
_seatingImageDetail, _seatingImageDetail,
...@@ -116,7 +142,8 @@ final List<Section> allSections = <Section>[ ...@@ -116,7 +142,8 @@ final List<Section> allSections = <Section>[
title: 'DECORATION', title: 'DECORATION',
leftColor: _mySin, leftColor: _mySin,
rightColor: _tomato, rightColor: _tomato,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/lipstick.png', backgroundAsset: 'shrine/products/lipstick.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[ details: const <SectionDetail>[
_decorationDetail, _decorationDetail,
_decorationImageDetail, _decorationImageDetail,
...@@ -130,7 +157,8 @@ final List<Section> allSections = <Section>[ ...@@ -130,7 +157,8 @@ final List<Section> allSections = <Section>[
title: 'PROTECTION', title: 'PROTECTION',
leftColor: Colors.white, leftColor: Colors.white,
rightColor: _tomato, rightColor: _tomato,
backgroundAsset: 'packages/flutter_gallery_assets/shrine/products/helmet.png', backgroundAsset: 'shrine/products/helmet.png',
backgroundAssetPackage: _kGalleryAssetsPackage,
details: const <SectionDetail>[ details: const <SectionDetail>[
_protectionDetail, _protectionDetail,
_protectionImageDetail, _protectionImageDetail,
......
...@@ -35,6 +35,7 @@ class SectionCard extends StatelessWidget { ...@@ -35,6 +35,7 @@ class SectionCard extends StatelessWidget {
), ),
child: new Image.asset( child: new Image.asset(
section.backgroundAsset, section.backgroundAsset,
package: section.backgroundAssetPackage,
color: const Color.fromRGBO(255, 255, 255, 0.075), color: const Color.fromRGBO(255, 255, 255, 0.075),
colorBlendMode: BlendMode.modulate, colorBlendMode: BlendMode.modulate,
fit: BoxFit.cover, fit: BoxFit.cover,
...@@ -130,7 +131,10 @@ class SectionDetailView extends StatelessWidget { ...@@ -130,7 +131,10 @@ class SectionDetailView extends StatelessWidget {
decoration: new BoxDecoration( decoration: new BoxDecoration(
borderRadius: new BorderRadius.circular(6.0), borderRadius: new BorderRadius.circular(6.0),
image: new DecorationImage( image: new DecorationImage(
image: new AssetImage(detail.imageAsset), image: new AssetImage(
detail.imageAsset,
package: detail.imageAssetPackage,
),
fit: BoxFit.cover, fit: BoxFit.cover,
alignment: FractionalOffset.center, alignment: FractionalOffset.center,
), ),
......
...@@ -156,7 +156,8 @@ class ContactsDemoState extends State<ContactsDemo> { ...@@ -156,7 +156,8 @@ class ContactsDemoState extends State<ContactsDemo> {
fit: StackFit.expand, fit: StackFit.expand,
children: <Widget>[ children: <Widget>[
new Image.asset( new Image.asset(
'packages/flutter_gallery_assets/ali_connors.jpg', 'ali_connors.jpg',
package: 'flutter_gallery_assets',
fit: BoxFit.cover, fit: BoxFit.cover,
height: _appBarHeight, height: _appBarHeight,
), ),
......
...@@ -5,10 +5,18 @@ ...@@ -5,10 +5,18 @@
import 'package:flutter/foundation.dart'; import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class TravelDestination { 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 assetName;
final String assetPackage;
final String title; final String title;
final List<String> description; final List<String> description;
...@@ -17,7 +25,8 @@ class TravelDestination { ...@@ -17,7 +25,8 @@ class TravelDestination {
final List<TravelDestination> destinations = <TravelDestination>[ final List<TravelDestination> destinations = <TravelDestination>[
const 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', title: 'Top 10 Australian beaches',
description: const <String>[ description: const <String>[
'Number 10', 'Number 10',
...@@ -26,7 +35,8 @@ final List<TravelDestination> destinations = <TravelDestination>[ ...@@ -26,7 +35,8 @@ final List<TravelDestination> destinations = <TravelDestination>[
], ],
), ),
const TravelDestination( const TravelDestination(
assetName: 'packages/flutter_gallery_assets/kangaroo_valley_safari.jpg', assetName: 'kangaroo_valley_safari.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Kangaroo Valley Safari', title: 'Kangaroo Valley Safari',
description: const <String>[ description: const <String>[
'2031 Moss Vale Road', '2031 Moss Vale Road',
...@@ -65,6 +75,7 @@ class TravelDestinationItem extends StatelessWidget { ...@@ -65,6 +75,7 @@ class TravelDestinationItem extends StatelessWidget {
new Positioned.fill( new Positioned.fill(
child: new Image.asset( child: new Image.asset(
destination.assetName, destination.assetName,
package: destination.assetPackage,
fit: BoxFit.cover, fit: BoxFit.cover,
), ),
), ),
......
...@@ -4,9 +4,10 @@ ...@@ -4,9 +4,10 @@
import 'package:flutter/material.dart'; import 'package:flutter/material.dart';
const String _kAsset0 = 'packages/flutter_gallery_assets/shrine/vendors/zach.jpg'; const String _kAsset0 = 'shrine/vendors/zach.jpg';
const String _kAsset1 = 'packages/flutter_gallery_assets/shrine/vendors/16c477b.jpg'; const String _kAsset1 = 'shrine/vendors/16c477b.jpg';
const String _kAsset2 = 'packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg'; const String _kAsset2 = 'shrine/vendors/sandra-adams.jpg';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class DrawerDemo extends StatefulWidget { class DrawerDemo extends StatefulWidget {
static const String routeName = '/material/drawer'; static const String routeName = '/material/drawer';
...@@ -93,10 +94,25 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -93,10 +94,25 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
new UserAccountsDrawerHeader( new UserAccountsDrawerHeader(
accountName: const Text('Zach Widget'), accountName: const Text('Zach Widget'),
accountEmail: const Text('zach.widget@example.com'), 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>[ otherAccountsPictures: const <Widget>[
const CircleAvatar(backgroundImage: const AssetImage(_kAsset1)), const CircleAvatar(
const CircleAvatar(backgroundImage: const AssetImage(_kAsset2)), backgroundImage: const AssetImage(
_kAsset1,
package: _kGalleryAssetsPackage,
),
),
const CircleAvatar(
backgroundImage: const AssetImage(
_kAsset2,
package: _kGalleryAssetsPackage,
),
),
], ],
onDetailsPressed: () { onDetailsPressed: () {
_showDrawerContents = !_showDrawerContents; _showDrawerContents = !_showDrawerContents;
...@@ -167,7 +183,10 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin { ...@@ -167,7 +183,10 @@ class _DrawerDemoState extends State<DrawerDemo> with TickerProviderStateMixin {
decoration: const BoxDecoration( decoration: const BoxDecoration(
shape: BoxShape.circle, shape: BoxShape.circle,
image: const DecorationImage( image: const DecorationImage(
image: const AssetImage(_kAsset0), image: const AssetImage(
_kAsset0,
package: _kGalleryAssetsPackage,
),
), ),
), ),
), ),
......
...@@ -14,11 +14,19 @@ enum GridDemoTileStyle { ...@@ -14,11 +14,19 @@ enum GridDemoTileStyle {
typedef void BannerTapCallback(Photo photo); typedef void BannerTapCallback(Photo photo);
const double _kMinFlingVelocity = 800.0; const double _kMinFlingVelocity = 800.0;
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class Photo { 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 assetName;
final String assetPackage;
final String title; final String title;
final String caption; final String caption;
...@@ -130,7 +138,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv ...@@ -130,7 +138,11 @@ class _GridPhotoViewerState extends State<GridPhotoViewer> with SingleTickerProv
transform: new Matrix4.identity() transform: new Matrix4.identity()
..translate(_offset.dx, _offset.dy) ..translate(_offset.dx, _offset.dy)
..scale(_scale), ..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 { ...@@ -177,7 +189,11 @@ class GridDemoPhotoItem extends StatelessWidget {
child: new Hero( child: new Hero(
key: new Key(photo.assetName), key: new Key(photo.assetName),
tag: photo.tag, 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> { ...@@ -239,62 +255,74 @@ class GridListDemoState extends State<GridListDemo> {
List<Photo> photos = <Photo>[ List<Photo> photos = <Photo>[
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_0.jpg', assetName: 'landscape_0.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Philippines', title: 'Philippines',
caption: 'Batad rice terraces', caption: 'Batad rice terraces',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_1.jpg', assetName: 'landscape_1.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Italy', title: 'Italy',
caption: 'Ceresole Reale', caption: 'Ceresole Reale',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_2.jpg', assetName: 'landscape_2.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Somewhere', title: 'Somewhere',
caption: 'Beautiful mountains', caption: 'Beautiful mountains',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_3.jpg', assetName: 'landscape_3.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'A place', title: 'A place',
caption: 'Beautiful hills', caption: 'Beautiful hills',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_4.jpg', assetName: 'landscape_4.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'New Zealand', title: 'New Zealand',
caption: 'View from the van', caption: 'View from the van',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_5.jpg', assetName: 'landscape_5.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Autumn', title: 'Autumn',
caption: 'The golden season', caption: 'The golden season',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_6.jpg', assetName: 'landscape_6.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Germany', title: 'Germany',
caption: 'Englischer Garten', caption: 'Englischer Garten',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_7.jpg', assetName: 'landscape_7.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'A country', title: 'A country',
caption: 'Grass fields', caption: 'Grass fields',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_8.jpg', assetName: 'landscape_8.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Mountain country', title: 'Mountain country',
caption: 'River forest', caption: 'River forest',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_9.jpg', assetName: 'landscape_9.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Alpine place', title: 'Alpine place',
caption: 'Green hills', caption: 'Green hills',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_10.jpg', assetName: 'landscape_10.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Desert land', title: 'Desert land',
caption: 'Blue skies', caption: 'Blue skies',
), ),
new Photo( new Photo(
assetName: 'packages/flutter_gallery_assets/landscape_11.jpg', assetName: 'landscape_11.jpg',
assetPackage: _kGalleryAssetsPackage,
title: 'Narnia', title: 'Narnia',
caption: 'Rocks and rivers', caption: 'Rocks and rivers',
), ),
......
...@@ -7,6 +7,8 @@ import 'package:flutter/material.dart'; ...@@ -7,6 +7,8 @@ import 'package:flutter/material.dart';
// Each TabBarView contains a _Page and for each _Page there is a list // Each TabBarView contains a _Page and for each _Page there is a list
// of _CardData objects. Each _CardData object is displayed by a _CardItem. // of _CardData objects. Each _CardData object is displayed by a _CardItem.
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class _Page { class _Page {
_Page({ this.label }); _Page({ this.label });
final String label; final String label;
...@@ -14,62 +16,75 @@ class _Page { ...@@ -14,62 +16,75 @@ class _Page {
} }
class _CardData { class _CardData {
const _CardData({ this.title, this.imageAsset }); const _CardData({ this.title, this.imageAsset, this.imageAssetPackage });
final String title; final String title;
final String imageAsset; final String imageAsset;
final String imageAssetPackage;
} }
final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{
new _Page(label: 'LEFT'): <_CardData>[ new _Page(label: 'LEFT'): <_CardData>[
const _CardData( const _CardData(
title: 'Vintage Bluetooth Radio', title: 'Vintage Bluetooth Radio',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/radio.png', imageAsset: 'shrine/products/radio.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Sunglasses', title: 'Sunglasses',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png', imageAsset: 'shrine/products/sunnies.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Clock', title: 'Clock',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/clock.png', imageAsset: 'shrine/products/clock.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Red popsicle', title: 'Red popsicle',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/popsicle.png', imageAsset: 'shrine/products/popsicle.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Folding Chair', title: 'Folding Chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/lawn_chair.png', imageAsset: 'shrine/products/lawn_chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Green comfort chair', title: 'Green comfort chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chair.png', imageAsset: 'shrine/products/chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Old Binoculars', title: 'Old Binoculars',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/binoculars.png', imageAsset: 'shrine/products/binoculars.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Teapot', title: 'Teapot',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/teapot.png', imageAsset: 'shrine/products/teapot.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Blue suede shoes', title: 'Blue suede shoes',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chucks.png', imageAsset: 'shrine/products/chucks.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Dipped Brush', title: 'Dipped Brush',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/brush.png', imageAsset: 'shrine/products/brush.png',
imageAssetPackage: _kGalleryAssetsPackage,
), ),
const _CardData( const _CardData(
title: 'Perfect Goldfish Bowl', 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>[ new _Page(label: 'RIGHT'): <_CardData>[
const _CardData( const _CardData(
title: 'Beachball', 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 { ...@@ -99,7 +114,11 @@ class _CardDataItem extends StatelessWidget {
new SizedBox( new SizedBox(
width: 144.0, width: 144.0,
height: 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( new Center(
child: new Text(data.title, style: Theme.of(context).textTheme.title), child: new Text(data.title, style: Theme.of(context).textTheme.title),
......
...@@ -14,8 +14,9 @@ class PestoDemo extends StatelessWidget { ...@@ -14,8 +14,9 @@ class PestoDemo extends StatelessWidget {
Widget build(BuildContext context) => new PestoHome(); 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 _kAppBarHeight = 128.0;
const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size
const double _kRecipePageMaxWidth = 500.0; const double _kRecipePageMaxWidth = 500.0;
...@@ -218,7 +219,11 @@ class _PestoLogoState extends State<PestoLogo> { ...@@ -218,7 +219,11 @@ class _PestoLogoState extends State<PestoLogo> {
children: <Widget>[ children: <Widget>[
new Positioned.fromRect( new Positioned.fromRect(
rect: _imageRectTween.lerp(widget.t), 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( new Positioned.fromRect(
rect: _textRectTween.lerp(widget.t), rect: _textRectTween.lerp(widget.t),
...@@ -254,8 +259,12 @@ class RecipeCard extends StatelessWidget { ...@@ -254,8 +259,12 @@ class RecipeCard extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[ children: <Widget>[
new Hero( new Hero(
tag: recipe.imagePath, tag: 'packages/$_kGalleryAssetsPackage/${recipe.imagePath}',
child: new Image.asset(recipe.imagePath, fit: BoxFit.contain) child: new Image.asset(
recipe.imagePath,
package: recipe.imagePackage,
fit: BoxFit.contain,
),
), ),
new Expanded( new Expanded(
child: new Row( child: new Row(
...@@ -264,6 +273,7 @@ class RecipeCard extends StatelessWidget { ...@@ -264,6 +273,7 @@ class RecipeCard extends StatelessWidget {
padding: const EdgeInsets.all(16.0), padding: const EdgeInsets.all(16.0),
child: new Image.asset( child: new Image.asset(
recipe.ingredientsImagePath, recipe.ingredientsImagePath,
package: recipe.ingredientsImagePackage,
width: 48.0, width: 48.0,
height: 48.0, height: 48.0,
), ),
...@@ -324,9 +334,10 @@ class _RecipePageState extends State<RecipePage> { ...@@ -324,9 +334,10 @@ class _RecipePageState extends State<RecipePage> {
right: 0.0, right: 0.0,
height: appBarHeight + _kFabHalfSize, height: appBarHeight + _kFabHalfSize,
child: new Hero( child: new Hero(
tag: widget.recipe.imagePath, tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe.imagePath}',
child: new Image.asset( child: new Image.asset(
widget.recipe.imagePath, widget.recipe.imagePath,
package: widget.recipe.imagePackage,
fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover, fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover,
), ),
), ),
...@@ -436,6 +447,7 @@ class RecipeSheet extends StatelessWidget { ...@@ -436,6 +447,7 @@ class RecipeSheet extends StatelessWidget {
verticalAlignment: TableCellVerticalAlignment.middle, verticalAlignment: TableCellVerticalAlignment.middle,
child: new Image.asset( child: new Image.asset(
recipe.ingredientsImagePath, recipe.ingredientsImagePath,
package: recipe.ingredientsImagePackage,
width: 32.0, width: 32.0,
height: 32.0, height: 32.0,
alignment: FractionalOffset.centerLeft, alignment: FractionalOffset.centerLeft,
...@@ -512,7 +524,9 @@ class Recipe { ...@@ -512,7 +524,9 @@ class Recipe {
this.author, this.author,
this.description, this.description,
this.imagePath, this.imagePath,
this.imagePackage,
this.ingredientsImagePath, this.ingredientsImagePath,
this.ingredientsImagePackage,
this.ingredients, this.ingredients,
this.steps this.steps
}); });
...@@ -521,7 +535,9 @@ class Recipe { ...@@ -521,7 +535,9 @@ class Recipe {
final String author; final String author;
final String description; final String description;
final String imagePath; final String imagePath;
final String imagePackage;
final String ingredientsImagePath; final String ingredientsImagePath;
final String ingredientsImagePackage;
final List<RecipeIngredient> ingredients; final List<RecipeIngredient> ingredients;
final List<RecipeStep> steps; final List<RecipeStep> steps;
} }
...@@ -544,9 +560,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -544,9 +560,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Pesto Bruschetta', name: 'Pesto Bruschetta',
author: 'Peter Carlsson', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '6 pieces', description: 'Mozzarella cheese'), const RecipeIngredient(amount: '6 pieces', description: 'Mozzarella cheese'),
const RecipeIngredient(amount: '6 pieces', description: 'Toasts'), const RecipeIngredient(amount: '6 pieces', description: 'Toasts'),
...@@ -562,9 +580,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -562,9 +580,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Rustic purple mash', name: 'Rustic purple mash',
author: 'Trevor Hansen', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '2 lbs', description: 'Purple potatoes, skin on'), const RecipeIngredient(amount: '2 lbs', description: 'Purple potatoes, skin on'),
const RecipeIngredient(amount: '1 tsp', description: 'Salt'), const RecipeIngredient(amount: '1 tsp', description: 'Salt'),
...@@ -580,9 +600,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -580,9 +600,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Bacon Sprouts', name: 'Bacon Sprouts',
author: 'Ali Connors', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '2 lbs', description: 'Brussel sprouts'), const RecipeIngredient(amount: '2 lbs', description: 'Brussel sprouts'),
const RecipeIngredient(amount: '3 lbs', description: 'Bacon'), const RecipeIngredient(amount: '3 lbs', description: 'Bacon'),
...@@ -599,9 +621,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -599,9 +621,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Oven Sausage', name: 'Oven Sausage',
author: 'Sandra Adams', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1 1/2 lbs', description: 'Linguisa'), const RecipeIngredient(amount: '1 1/2 lbs', description: 'Linguisa'),
const RecipeIngredient(amount: '1 lbs', description: 'Pineapple or other fresh citrus fruit'), const RecipeIngredient(amount: '1 lbs', description: 'Pineapple or other fresh citrus fruit'),
...@@ -614,9 +638,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -614,9 +638,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Chicken tostadas', name: 'Chicken tostadas',
author: 'Peter Carlsson', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '4-6', description: 'Small corn tortillas'), const RecipeIngredient(amount: '4-6', description: 'Small corn tortillas'),
const RecipeIngredient(amount: '½ cup', description: 'Chopped onion'), const RecipeIngredient(amount: '½ cup', description: 'Chopped onion'),
...@@ -631,9 +657,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -631,9 +657,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Coconut rice', name: 'Coconut rice',
author: 'Ali Connors', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '2 cups', description: 'Jasmine rice'), const RecipeIngredient(amount: '2 cups', description: 'Jasmine rice'),
const RecipeIngredient(amount: '1 1/2 cups', description: 'Water'), const RecipeIngredient(amount: '1 1/2 cups', description: 'Water'),
...@@ -649,9 +677,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -649,9 +677,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Gin basil cocktail', name: 'Gin basil cocktail',
author: 'Trevor Hansen', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '3 parts', description: 'Gin'), const RecipeIngredient(amount: '3 parts', description: 'Gin'),
const RecipeIngredient(amount: '1 part', description: 'Fresh lemon juice'), const RecipeIngredient(amount: '1 part', description: 'Fresh lemon juice'),
...@@ -666,9 +696,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -666,9 +696,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Seared sesame fish', name: 'Seared sesame fish',
author: 'Ali Connors', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1 ½ lbs', description: 'Thin fish fillets'), const RecipeIngredient(amount: '1 ½ lbs', description: 'Thin fish fillets'),
const RecipeIngredient(amount: '1 lb', description: 'Salt and black pepper to taste'), const RecipeIngredient(amount: '1 lb', description: 'Salt and black pepper to taste'),
...@@ -685,9 +717,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -685,9 +717,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Herb artichoke', name: 'Herb artichoke',
author: 'Sandra Adams', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1', description: 'Small garlic clove, peeled'), const RecipeIngredient(amount: '1', description: 'Small garlic clove, peeled'),
const RecipeIngredient(amount: '2', description: 'Whole artichokes'), const RecipeIngredient(amount: '2', description: 'Whole artichokes'),
...@@ -704,9 +738,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -704,9 +738,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Pesto bruschetta', name: 'Pesto bruschetta',
author: 'Trevor Hansen', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1 loaf', description: 'Sliced French bread'), const RecipeIngredient(amount: '1 loaf', description: 'Sliced French bread'),
const RecipeIngredient(amount: '½ cup', description: 'Cheese'), const RecipeIngredient(amount: '½ cup', description: 'Cheese'),
...@@ -725,9 +761,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -725,9 +761,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Garlic bok choy', name: 'Garlic bok choy',
author: 'Sandra Adams', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1/2 cup', description: 'Chick broth'), const RecipeIngredient(amount: '1/2 cup', description: 'Chick broth'),
const RecipeIngredient(amount: '1 tbsp', description: 'Soy sauce'), const RecipeIngredient(amount: '1 tbsp', description: 'Soy sauce'),
...@@ -743,9 +781,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -743,9 +781,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Fresh Fettuccine', name: 'Fresh Fettuccine',
author: 'Ali Connors', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '¾ cup', description: 'Milk'), const RecipeIngredient(amount: '¾ cup', description: 'Milk'),
const RecipeIngredient(amount: '1 ½ tsp', description: 'Salt'), const RecipeIngredient(amount: '1 ½ tsp', description: 'Salt'),
...@@ -762,9 +802,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[ ...@@ -762,9 +802,11 @@ const List<Recipe> kPestoRecipes = const <Recipe>[
const Recipe( const Recipe(
name: 'Sicilian-Style sardines', name: 'Sicilian-Style sardines',
author: 'Peter Carlsson', 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.', 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>[ ingredients: const<RecipeIngredient>[
const RecipeIngredient(amount: '1/4 cup', description: 'Dry white wine'), const RecipeIngredient(amount: '1/4 cup', description: 'Dry white wine'),
const RecipeIngredient(amount: '1', description: 'Finely chopped shallot'), const RecipeIngredient(amount: '1', description: 'Finely chopped shallot'),
......
...@@ -4,9 +4,12 @@ ...@@ -4,9 +4,12 @@
import 'shrine_types.dart'; import 'shrine_types.dart';
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
const Vendor _ali = const Vendor( const Vendor _ali = const Vendor(
name: 'Ali’s shop', name: 'Ali’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/ali-connors.png', avatarAsset: 'shrine/vendors/ali-connors.png',
avatarAssetPackage: _kGalleryAssetsPackage,
description: description:
'Ali Connor’s makes custom goods for folks of all shapes and sizes ' '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. ' 'made by hand and sometimes by machine, but always with love and care. '
...@@ -15,7 +18,8 @@ const Vendor _ali = const Vendor( ...@@ -15,7 +18,8 @@ const Vendor _ali = const Vendor(
const Vendor _sandra = const Vendor( const Vendor _sandra = const Vendor(
name: 'Sandra’s shop', name: 'Sandra’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/sandra-adams.jpg', avatarAsset: 'shrine/vendors/sandra-adams.jpg',
avatarAssetPackage: _kGalleryAssetsPackage,
description: description:
'Sandra specializes in furniture, beauty and travel products with a classic vibe. ' '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.' 'Custom orders are available if you’re looking for a certain color or material.'
...@@ -23,7 +27,8 @@ const Vendor _sandra = const Vendor( ...@@ -23,7 +27,8 @@ const Vendor _sandra = const Vendor(
const Vendor _trevor = const Vendor( const Vendor _trevor = const Vendor(
name: 'Trevor’s shop', name: 'Trevor’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/zach.jpg', avatarAsset: 'shrine/vendors/zach.jpg',
avatarAssetPackage: _kGalleryAssetsPackage,
description: description:
'Trevor makes great stuff for awesome people like you. Super cool and extra ' '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 ' 'awesome all of his shop’s goods are handmade with love. Custom orders are '
...@@ -32,7 +37,8 @@ const Vendor _trevor = const Vendor( ...@@ -32,7 +37,8 @@ const Vendor _trevor = const Vendor(
const Vendor _peter = const Vendor( const Vendor _peter = const Vendor(
name: 'Peter’s shop', name: 'Peter’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/peter-carlsson.png', avatarAsset: 'shrine/vendors/peter-carlsson.png',
avatarAssetPackage: _kGalleryAssetsPackage,
description: description:
'Peter makes great stuff for awesome people like you. Super cool and extra ' '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 ' 'awesome all of his shop’s goods are handmade with love. Custom orders are '
...@@ -41,7 +47,8 @@ const Vendor _peter = const Vendor( ...@@ -41,7 +47,8 @@ const Vendor _peter = const Vendor(
const Vendor _stella = const Vendor( const Vendor _stella = const Vendor(
name: 'Stella’s shop', name: 'Stella’s shop',
avatarAsset: 'packages/flutter_gallery_assets/shrine/vendors/16c477b.jpg', avatarAsset: 'shrine/vendors/16c477b.jpg',
avatarAssetPackage: _kGalleryAssetsPackage,
description: description:
'Stella sells awesome stuff at lovely prices. made by hand and sometimes by ' '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 ' 'machine, but always with love and care. Custom orders are available upon request '
...@@ -51,7 +58,8 @@ const Vendor _stella = const Vendor( ...@@ -51,7 +58,8 @@ const Vendor _stella = const Vendor(
const List<Product> _allProducts = const <Product> [ const List<Product> _allProducts = const <Product> [
const Product( const Product(
name: 'Vintage Bluetooth Radio', 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'], categories: const <String>['furniture', 'latest'],
price: 300.00, price: 300.00,
vendor: _sandra, vendor: _sandra,
...@@ -62,7 +70,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -62,7 +70,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Sunglasses', name: 'Sunglasses',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/sunnies.png', imageAsset: 'shrine/products/sunnies.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion', 'beauty'], categories: const <String>['travel', 'fashion', 'beauty'],
price: 20.00, price: 20.00,
vendor: _trevor, vendor: _trevor,
...@@ -74,7 +83,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -74,7 +83,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Clock', name: 'Clock',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/clock.png', imageAsset: 'shrine/products/clock.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture'], categories: const <String>['furniture'],
price: 30.00, price: 30.00,
vendor: _trevor, vendor: _trevor,
...@@ -85,7 +95,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -85,7 +95,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Red popsicle', name: 'Red popsicle',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/popsicle.png', imageAsset: 'shrine/products/popsicle.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['food', 'fashion'], categories: const <String>['food', 'fashion'],
price: 300.00, price: 300.00,
vendor: _stella, vendor: _stella,
...@@ -96,7 +107,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -96,7 +107,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Folding Chair', 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'], categories: const <String>['furniture'],
price: 63.00, price: 63.00,
vendor: _stella, vendor: _stella,
...@@ -105,7 +117,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -105,7 +117,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Green comfort chair', name: 'Green comfort chair',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/chair.png', imageAsset: 'shrine/products/chair.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture'], categories: const <String>['furniture'],
price: 36.00, price: 36.00,
vendor: _ali, vendor: _ali,
...@@ -114,7 +127,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -114,7 +127,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Better wearing heels', name: 'Better wearing heels',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/heels.png', imageAsset: 'shrine/products/heels.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['fashion'], categories: const <String>['fashion'],
price: 125.00, price: 125.00,
vendor: _peter, vendor: _peter,
...@@ -123,7 +137,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -123,7 +137,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Green Slip-ons', 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'], categories: const <String>['travel', 'fashion'],
price: 75.00, price: 75.00,
vendor: _sandra, vendor: _sandra,
...@@ -134,7 +149,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -134,7 +149,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Teapot', name: 'Teapot',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/teapot.png', imageAsset: 'shrine/products/teapot.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['furniture', 'fashion'], categories: const <String>['furniture', 'fashion'],
price: 70.00, price: 70.00,
vendor: _trevor, vendor: _trevor,
...@@ -148,7 +164,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -148,7 +164,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Blue suede shoes', 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'], categories: const <String>['travel', 'fashion'],
price: 89.00, price: 89.00,
vendor: _trevor, vendor: _trevor,
...@@ -158,7 +175,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -158,7 +175,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Dipped Brush', name: 'Dipped Brush',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/brush.png', imageAsset: 'shrine/products/brush.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['fashion', 'beauty'], categories: const <String>['fashion', 'beauty'],
price: 25.00, price: 25.00,
vendor: _stella, vendor: _stella,
...@@ -169,7 +187,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -169,7 +187,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Perfect Goldfish Bowl', 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'], categories: const <String>['latest', 'furniture'],
price: 30.00, price: 30.00,
vendor: _ali, vendor: _ali,
...@@ -180,7 +199,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -180,7 +199,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Red Lipstick Set', 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'], categories: const <String>['fashion', 'beauty'],
price: 54.00, price: 54.00,
vendor: _sandra, vendor: _sandra,
...@@ -191,7 +211,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -191,7 +211,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Backpack', name: 'Backpack',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/backpack.png', imageAsset: 'shrine/products/backpack.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['travel', 'fashion'], categories: const <String>['travel', 'fashion'],
price: 25.00, price: 25.00,
vendor: _peter, vendor: _peter,
...@@ -202,7 +223,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -202,7 +223,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Half Shield Helmet', 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'], categories: const <String>['travel', 'fashion', 'latest'],
price: 25.00, price: 25.00,
vendor: _ali, vendor: _ali,
...@@ -213,7 +235,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -213,7 +235,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Beachball', name: 'Beachball',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/beachball.png', imageAsset: 'shrine/products/beachball.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>['latest'], categories: const <String>['latest'],
price: 17.00, price: 17.00,
vendor: _peter, vendor: _peter,
...@@ -224,7 +247,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -224,7 +247,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Old Binoculars', 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'], categories: const <String>['travel', 'fashion', 'latest'],
price: 25.00, price: 25.00,
vendor: _stella, vendor: _stella,
...@@ -236,7 +260,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -236,7 +260,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Lime Flippers', 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'], categories: const <String>['travel', 'fashion', 'beauty'],
price: 25.00, price: 25.00,
vendor: _peter, vendor: _peter,
...@@ -247,7 +272,8 @@ const List<Product> _allProducts = const <Product> [ ...@@ -247,7 +272,8 @@ const List<Product> _allProducts = const <Product> [
), ),
const Product( const Product(
name: 'Surfboard', name: 'Surfboard',
imageAsset: 'packages/flutter_gallery_assets/shrine/products/surfboard.png', imageAsset: 'shrine/products/surfboard.png',
imageAssetPackage: _kGalleryAssetsPackage,
categories: const <String>[ 'travel', 'latest'], categories: const <String>[ 'travel', 'latest'],
price: 120.00, price: 120.00,
vendor: _stella, vendor: _stella,
......
...@@ -132,7 +132,11 @@ class _VendorItem extends StatelessWidget { ...@@ -132,7 +132,11 @@ class _VendorItem extends StatelessWidget {
width: 24.0, width: 24.0,
child: new ClipRRect( child: new ClipRRect(
borderRadius: new BorderRadius.circular(12.0), 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), const SizedBox(width: 8.0),
...@@ -271,7 +275,11 @@ class _Heading extends StatelessWidget { ...@@ -271,7 +275,11 @@ class _Heading extends StatelessWidget {
), ),
new LayoutId( new LayoutId(
id: _HeadingLayout.image, 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( new LayoutId(
id: _HeadingLayout.title, id: _HeadingLayout.title,
...@@ -321,7 +329,11 @@ class _ProductItem extends StatelessWidget { ...@@ -321,7 +329,11 @@ class _ProductItem extends StatelessWidget {
padding: const EdgeInsets.symmetric(horizontal: 8.0), padding: const EdgeInsets.symmetric(horizontal: 8.0),
child: new Hero( child: new Hero(
tag: product.tag, 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( new Padding(
......
...@@ -172,6 +172,7 @@ class _Heading extends StatelessWidget { ...@@ -172,6 +172,7 @@ class _Heading extends StatelessWidget {
tag: product.tag, tag: product.tag,
child: new Image.asset( child: new Image.asset(
product.imageAsset, product.imageAsset,
package: product.imageAssetPackage,
fit: BoxFit.contain, fit: BoxFit.contain,
alignment: FractionalOffset.center, alignment: FractionalOffset.center,
), ),
...@@ -302,6 +303,7 @@ class _OrderPageState extends State<OrderPage> { ...@@ -302,6 +303,7 @@ class _OrderPageState extends State<OrderPage> {
elevation: 1.0, elevation: 1.0,
child: new Image.asset( child: new Image.asset(
product.imageAsset, product.imageAsset,
package: product.imageAssetPackage,
fit: BoxFit.contain, fit: BoxFit.contain,
), ),
); );
......
...@@ -10,12 +10,14 @@ class Vendor { ...@@ -10,12 +10,14 @@ class Vendor {
const Vendor({ const Vendor({
this.name, this.name,
this.description, this.description,
this.avatarAsset this.avatarAsset,
this.avatarAssetPackage,
}); });
final String name; final String name;
final String description; final String description;
final String avatarAsset; final String avatarAsset;
final String avatarAssetPackage;
bool isValid() { bool isValid() {
return name != null && return name != null &&
...@@ -34,6 +36,7 @@ class Product { ...@@ -34,6 +36,7 @@ class Product {
this.featureTitle, this.featureTitle,
this.featureDescription, this.featureDescription,
this.imageAsset, this.imageAsset,
this.imageAssetPackage,
this.categories, this.categories,
this.price, this.price,
this.vendor this.vendor
...@@ -44,6 +47,7 @@ class Product { ...@@ -44,6 +47,7 @@ class Product {
final String featureTitle; final String featureTitle;
final String featureDescription; final String featureDescription;
final String imageAsset; final String imageAsset;
final String imageAssetPackage;
final List<String> categories; final List<String> categories;
final double price; final double price;
final Vendor vendor; final Vendor vendor;
......
...@@ -9,12 +9,15 @@ import 'drawer.dart'; ...@@ -9,12 +9,15 @@ import 'drawer.dart';
import 'item.dart'; import 'item.dart';
const double _kFlexibleSpaceMaxHeight = 256.0; const double _kFlexibleSpaceMaxHeight = 256.0;
const String _kGalleryAssetsPackage = 'flutter_gallery_assets';
class _BackgroundLayer { class _BackgroundLayer {
_BackgroundLayer({ int level, double parallax }) _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); parallaxTween = new Tween<double>(begin: 0.0, end: parallax);
final String assetName; final String assetName;
final String assetPackage;
final Tween<double> parallaxTween; final Tween<double> parallaxTween;
} }
...@@ -46,6 +49,7 @@ class _AppBarBackground extends StatelessWidget { ...@@ -46,6 +49,7 @@ class _AppBarBackground extends StatelessWidget {
bottom: 0.0, bottom: 0.0,
child: new Image.asset( child: new Image.asset(
layer.assetName, layer.assetName,
package: layer.assetPackage,
fit: BoxFit.cover, fit: BoxFit.cover,
height: _kFlexibleSpaceMaxHeight 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