Created
May 5, 2024 04:12
-
-
Save jwson-automation/58b99cc8f94acbc405d7d8361d9c604b to your computer and use it in GitHub Desktop.
Generated code from pixels2flutter.dev
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
void main() { | |
runApp(MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Item Detail Page', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
visualDensity: VisualDensity.adaptivePlatformDensity, | |
), | |
home: ItemDetailPage(), | |
debugShowCheckedModeBanner: false, | |
); | |
} | |
} | |
class ItemDetailPage extends StatelessWidget { | |
final ItemDTO item = ItemDTO( | |
itemId: '1', | |
title: '스탠다드 더블 룸', | |
originalPrice: 215000, | |
discountedPrice: 151000, | |
description: '8,000원 즉시 할인\n체크인 15:00 체크아웃 12:00', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-QTMVmPSEPbzg2NKXRi9S74Qm.png%3Fst%3D2024-05-05T03%253A12%253A09Z%26se%3D2024-05-05T05%253A12%253A09Z%26sp%3Dr%26sv%3D2021-08-06%26sr%3Db%26rscd%3Dinline%26rsct%3Dimage%2Fpng%26skoid%3D6aaadede-4fb3-4698-a8f6-684d7786b067%26sktid%3Da48cca56-e6da-484e-a814-9c849652bcb3%26skt%3D2024-05-04T21%253A31%253A02Z%26ske%3D2024-05-05T21%253A31%253A02Z%26sks%3Db%26skv%3D2021-08-06%26sig%3D7QqUmLE5HB93oL3AV0J0hYtSgfisPdR%252BorxV4Pjke7E%253D', | |
category: '호텔', | |
isMain: true, | |
productTitle: '스탠다드 더블 룸', | |
productDescription: '편안한 퀸사이즈 베드와 넓은 공간', | |
createdAt: DateTime.now(), | |
recommendedItems: [ | |
ItemDTO( | |
itemId: '2', | |
title: '스위트 룸', | |
originalPrice: 309760, | |
discountedPrice: 267000, | |
description: '8,000원 즉시 할인\n체크인 15:00 체크아웃 12:00', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-b1BqdH2Gi6OPK6898IBAlHlo.png%3Fst%3D2024-05-05T03%253A12%253A14Z%26se%3D2024-05-05T05%253A12%253A14Z%26sp%3Dr%26sv%3D2021-08-06%26sr%3Db%26rscd%3Dinline%26rsct%3Dimage%2Fpng%26skoid%3D6aaadede-4fb3-4698-a8f6-684d7786b067%26sktid%3Da48cca56-e6da-484e-a814-9c849652bcb3%26skt%3D2024-05-04T21%253A38%253A20Z%26ske%3D2024-05-05T21%253A38%253A20Z%26sks%3Db%26skv%3D2021-08-06%26sig%3DF%252BdIhYC%252B%2FnzmKAMqQlodgM0pTPy0z%2FrhiKMqLaMfNu4%253D', | |
category: '호텔', | |
isMain: false, | |
productTitle: '스위트 룸', | |
productDescription: '넓은 거실과 침실이 있는 스위트 룸', | |
createdAt: DateTime.now(), | |
), | |
ItemDTO( | |
itemId: '3', | |
title: '디럭스 더블', | |
originalPrice: 290000, | |
discountedPrice: 267000, | |
description: '8,000원 즉시 할인\n체크인 15:00 체크아웃 12:00', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-j5XsPnqQFp2fr0iN6HLNy3Wi.png%3Fst%3D2024-05-05T03%253A12%253A09Z%26se%3D2024-05-05T05%253A12%253A09Z%26sp%3Dr%26sv%3D2021-08-06%26sr%3Db%26rscd%3Dinline%26rsct%3Dimage%2Fpng%26skoid%3D6aaadede-4fb3-4698-a8f6-684d7786b067%26sktid%3Da48cca56-e6da-484e-a814-9c849652bcb3%26skt%3D2024-05-04T21%253A26%253A07Z%26ske%3D2024-05-05T21%253A26%253A07Z%26sks%3Db%26skv%3D2021-08-06%26sig%3DWA1R0%252BboAR%2FEd2q8koBtK4IyE30oXEa2HHgyrG89aZY%253D', | |
category: '호텔', | |
isMain: false, | |
productTitle: '디럭스 더블', | |
productDescription: '킹사이즈 베드와 넓은 창문이 있는 방', | |
createdAt: DateTime.now(), | |
), | |
], | |
); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(item.title), | |
leading: IconButton( | |
icon: Icon(Icons.arrow_back), | |
onPressed: () => Navigator.of(context).pop(), | |
), | |
actions: [ | |
IconButton( | |
icon: Icon(Icons.favorite_border), | |
onPressed: () {}, | |
), | |
], | |
), | |
body: SingleChildScrollView( | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Image.network(item.imageUrl, fit: BoxFit.cover, width: double.infinity, height: 250), | |
Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text(item.productTitle, style: TextStyle(fontSize: 24, fontWeight: FontWeight.bold)), | |
SizedBox(height: 8), | |
Text(item.productDescription, style: TextStyle(fontSize: 16)), | |
SizedBox(height: 16), | |
Text('₩${item.discountedPrice}', style: TextStyle(fontSize: 28, fontWeight: FontWeight.bold, color: Colors.red)), | |
Text('₩${item.originalPrice}', style: TextStyle(fontSize: 16, decoration: TextDecoration.lineThrough)), | |
SizedBox(height: 16), | |
Text(item.description), | |
SizedBox(height: 16), | |
Text('추천 상품', style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold)), | |
SizedBox(height: 16), | |
ListView.builder( | |
shrinkWrap: true, | |
physics: NeverScrollableScrollPhysics(), | |
itemCount: item.recommendedItems.length, | |
itemBuilder: (context, index) { | |
final recommendedItem = item.recommendedItems[index]; | |
return ListTile( | |
leading: Image.network(recommendedItem.imageUrl, width: 100, height: 100, fit: BoxFit.cover), | |
title: Text(recommendedItem.productTitle), | |
subtitle: Text('₩${recommendedItem.discountedPrice}'), | |
trailing: Text('₩${recommendedItem.originalPrice}', style: TextStyle(decoration: TextDecoration.lineThrough)), | |
); | |
}, | |
), | |
], | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} | |
class ItemDTO { | |
final String itemId; | |
final String title; | |
final num originalPrice; | |
final num discountedPrice; | |
final String description; | |
final String imageUrl; | |
final String category; | |
final bool isMain; | |
final String productTitle; | |
final String productDescription; | |
final num viewCount; | |
final List<String> isSelled; | |
final List<String> selled; | |
final List<String> isLiked; | |
final List<ItemDTO> recommendedItems; | |
final DateTime createdAt; | |
ItemDTO({ | |
required this.itemId, | |
required this.title, | |
required this.originalPrice, | |
required this.discountedPrice, | |
required this.description, | |
required this.imageUrl, | |
required this.category, | |
required this.isMain, | |
required this.productTitle, | |
required this.productDescription, | |
DateTime? createdAt, | |
num? viewCount, | |
List<String>? isSell, | |
List<String>? totalSell, | |
List<String>? isLiked, | |
List<ItemDTO>? recommendedItems, | |
}) : createdAt = createdAt ?? DateTime.now(), | |
viewCount = viewCount ?? 0, | |
isSelled = isSell ?? [], | |
selled = totalSell ?? [], | |
isLiked = isLiked ?? [], | |
recommendedItems = recommendedItems ?? []; | |
Map<String, dynamic> toMap() { | |
return { | |
'itemId': itemId, | |
'title': title, | |
'originalPrice': originalPrice, | |
'discountedPrice': discountedPrice, | |
'description': description, | |
'imageUrl': imageUrl, | |
'category': category, | |
'createdAt': createdAt.toIso8601String(), | |
'isMain': isMain, | |
'productTitle': productTitle, | |
'productDescription': productDescription, | |
}; | |
} | |
factory ItemDTO.fromMap(Map<String, dynamic> map) { | |
return ItemDTO( | |
itemId: map['itemId'], | |
title: map['title'], | |
originalPrice: map['originalPrice'], | |
discountedPrice: map['discountedPrice'], | |
description: map['description'], | |
imageUrl: map['imageUrl'], | |
category: map['category'], | |
isMain: map['isMain'], | |
productTitle: map['productTitle'], | |
productDescription: map['productDescription'], | |
createdAt: DateTime.parse(map['createdAt']), | |
viewCount: map['viewCount'] as num?, | |
isSell: List<String>.from(map['isSelled'] ?? []), | |
totalSell: List<String>.from(map['selled'] ?? []), | |
isLiked: List<String>.from(map['isLiked'] ?? []), | |
recommendedItems: (map['recommendedItems'] as List?) | |
?.map((item) => ItemDTO.fromMap(item)) | |
.toList() ?? | |
[], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment