Created
December 17, 2023 13:43
-
-
Save mirkancal/533a2c11ab87a0596c67a944ca792c61 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( | |
debugShowCheckedModeBanner: false, | |
title: 'Deal Card', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
useMaterial3: true, | |
), | |
home: Scaffold( | |
backgroundColor: Colors.white, | |
body: Center( | |
child: DealCard( | |
title: 'Yearly', | |
currentPrice: '\$89.99', | |
previousPrice: '\$145.99', | |
discountAmount: '%25 SALE', | |
), | |
), | |
), | |
); | |
} | |
} | |
class DealCard extends StatelessWidget { | |
final String title; | |
final String currentPrice; | |
final String previousPrice; | |
final String discountAmount; | |
const DealCard({ | |
Key? key, | |
required this.title, | |
required this.currentPrice, | |
required this.previousPrice, | |
required this.discountAmount, | |
}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
return Stack( | |
alignment: Alignment.topRight, | |
children: [ | |
Container( | |
padding: EdgeInsets.all(16.0), | |
decoration: BoxDecoration( | |
border: Border.all(color: Theme.of(context).primaryColor), | |
borderRadius: BorderRadius.circular(8.0), | |
), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
Row( | |
children: [ | |
Icon(Icons.check_circle_outline, color: Theme.of(context).primaryColor), | |
SizedBox(width: 8.0), | |
Text(title, style: TextStyle(fontSize: 16.0)), | |
], | |
), | |
Row( | |
children: [ | |
Text(previousPrice, | |
style: TextStyle( | |
fontSize: 14.0, | |
color: Colors.grey, | |
decoration: TextDecoration.lineThrough, | |
)), | |
SizedBox(width: 8.0), | |
Text(currentPrice, style: TextStyle(fontSize: 18.0, fontWeight: FontWeight.bold)), | |
], | |
), | |
], | |
), | |
), | |
Positioned( | |
top: -10, | |
right: -10, | |
child: Container( | |
padding: EdgeInsets.symmetric(horizontal: 8.0, vertical: 4.0), | |
decoration: BoxDecoration( | |
color: Theme.of(context).primaryColor, | |
borderRadius: BorderRadius.circular(8.0), | |
), | |
child: Text( | |
discountAmount, | |
style: TextStyle(color: Colors.white, fontSize: 12.0), | |
), | |
), | |
), | |
], | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment