mirror of
https://github.com/flutter/samples.git
synced 2026-07-09 18:43:03 +00:00
[Gallery] Fix directory structure (#312)
This commit is contained in:
70
gallery/lib/studies/shrine/model/product.dart
Normal file
70
gallery/lib/studies/shrine/model/product.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
// Copyright 2019 The Flutter team. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
import '../../../l10n/gallery_localizations.dart';
|
||||
|
||||
class Category {
|
||||
const Category({
|
||||
@required this.name,
|
||||
}) : assert(name != null);
|
||||
|
||||
// A function taking a BuildContext as input and
|
||||
// returns the internationalized name of the category.
|
||||
final String Function(BuildContext) name;
|
||||
}
|
||||
|
||||
Category categoryAll = Category(
|
||||
name: (context) => GalleryLocalizations.of(context).shrineCategoryNameAll,
|
||||
);
|
||||
|
||||
Category categoryAccessories = Category(
|
||||
name: (context) =>
|
||||
GalleryLocalizations.of(context).shrineCategoryNameAccessories,
|
||||
);
|
||||
|
||||
Category categoryClothing = Category(
|
||||
name: (context) =>
|
||||
GalleryLocalizations.of(context).shrineCategoryNameClothing,
|
||||
);
|
||||
|
||||
Category categoryHome = Category(
|
||||
name: (context) => GalleryLocalizations.of(context).shrineCategoryNameHome,
|
||||
);
|
||||
|
||||
List<Category> categories = [
|
||||
categoryAll,
|
||||
categoryAccessories,
|
||||
categoryClothing,
|
||||
categoryHome,
|
||||
];
|
||||
|
||||
class Product {
|
||||
const Product({
|
||||
@required this.category,
|
||||
@required this.id,
|
||||
@required this.isFeatured,
|
||||
@required this.name,
|
||||
@required this.price,
|
||||
}) : assert(category != null),
|
||||
assert(id != null),
|
||||
assert(isFeatured != null),
|
||||
assert(name != null),
|
||||
assert(price != null);
|
||||
|
||||
final Category category;
|
||||
final int id;
|
||||
final bool isFeatured;
|
||||
|
||||
// A function taking a BuildContext as input and
|
||||
// returns the internationalized name of the product.
|
||||
final String Function(BuildContext) name;
|
||||
|
||||
final int price;
|
||||
|
||||
String get assetName => '$id-0.jpg';
|
||||
String get assetPackage => 'shrine_images';
|
||||
}
|
||||
Reference in New Issue
Block a user