Created
May 5, 2024 04:18
-
-
Save jwson-automation/7fd71c940f0181e00ec9948f84b16b74 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: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
visualDensity: VisualDensity.adaptivePlatformDensity, | |
), | |
home: MyHomePage(), | |
debugShowCheckedModeBanner: false, | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
final List<ItemDTO> items = [ | |
ItemDTO( | |
itemId: '1', | |
title: '맛있는 베니하루카 골드고구마', | |
originalPrice: 121900, | |
discountedPrice: 32910, | |
description: '국내산', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-ITKbDhdTPPh6qyEpwPkUd0rt.png%3Fst%3D2024-05-05T03%253A18%253A20Z%26se%3D2024-05-05T05%253A18%253A20Z%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%253A24%253A04Z%26ske%3D2024-05-05T21%253A24%253A04Z%26sks%3Db%26skv%3D2021-08-06%26sig%3D542Em4rBzNzmn32HPhpq9WFxdDZSZY1tdfWBDKN5A70%253D', | |
category: 'Food', | |
isMain: true, | |
productTitle: '고구마 (특상) 5kg x 1개', | |
productDescription: '100g당 658원 · 10시간 남음', | |
viewCount: 6645, | |
isSelled: [], | |
selled: [], | |
isLiked: [], | |
recommendedItems: [ | |
ItemDTO( | |
itemId: '2', | |
title: '고구마', | |
originalPrice: 0, | |
discountedPrice: 30760, | |
description: '한입에 쏙 고구마', | |
imageUrl: 'https://corsproxy.io/?https%3A%2F%2Foaidalleapiprodscus.blob.core.windows.net%2Fprivate%2Forg-TUBHLKYl2lBqM1b7iE99XgMQ%2Fuser-UjOypK7HRZS7bCpwDOO1UgLB%2Fimg-Rpji0tX5XYKFkYcXj7OCclrP.png%3Fst%3D2024-05-05T03%253A18%253A22Z%26se%3D2024-05-05T05%253A18%253A22Z%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%253A30%253A39Z%26ske%3D2024-05-05T21%253A30%253A39Z%26sks%3Db%26skv%3D2021-08-06%26sig%3Da6YWx5mJj1N67477b%252B6J1vK6j%2FtFqM2PRoiIGWw6Ycc%253D', | |
category: 'Food', | |
isMain: false, | |
productTitle: '고구마', | |
productDescription: '5kg', | |
viewCount: 0, | |
isSelled: [], | |
selled: [], | |
isLiked: [], | |
), | |
// Add more recommended items here | |
], | |
), | |
// Add more items here | |
]; | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text('Flutter Demo Home Page'), | |
), | |
body: ListView.builder( | |
itemCount: items.length, | |
itemBuilder: (context, index) { | |
final item = items[index]; | |
return ListTile( | |
title: Text(item.title), | |
subtitle: Text(item.productDescription), | |
trailing: Text('${item.discountedPrice}원'), | |
leading: Image.network(item.imageUrl), | |
); | |
}, | |
), | |
); | |
} | |
} | |
class ItemDTO { | |
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 String itemId; | |
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