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