Skip to content

Instantly share code, notes, and snippets.

@aa53420
Last active April 7, 2023 13:10
Show Gist options
  • Select an option

  • Save aa53420/913f0d2c9b9a0c050f70a392c90f2976 to your computer and use it in GitHub Desktop.

Select an option

Save aa53420/913f0d2c9b9a0c050f70a392c90f2976 to your computer and use it in GitHub Desktop.
Nomard Coders flutter-for-beginners lecture #3.9 Code Challenge
import 'package:flutter/material.dart';
class CurrencyCard extends StatelessWidget {
final String name, code, amount;
final IconData icon;
final bool isInverted;
final int order;
final _blackColor = const Color(0xFF1F2123);
final _whiteColor = Colors.white;
final _offsetYStep = -20.0;
const CurrencyCard({
super.key,
required this.name,
required this.code,
required this.amount,
required this.icon,
required this.isInverted,
required this.order
});
@override
Widget build(BuildContext context) {
return Transform.translate(
offset: Offset(0, ((order -1) * _offsetYStep)),
child: Container(
clipBehavior: Clip.hardEdge,
decoration: BoxDecoration(
color: isInverted ? Colors.white : _blackColor,
borderRadius: BorderRadius.circular(20),
),
child: Padding(
padding: const EdgeInsets.all(30),
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: TextStyle(
color: isInverted ? _blackColor : _whiteColor,
fontSize: 32,
fontWeight: FontWeight.w600,
),
),
const SizedBox(
height: 10,
),
Row(
children: [
Text(
amount,
style: TextStyle(
color: isInverted ? _blackColor : _whiteColor,
fontSize: 20,
),
),
const SizedBox(
width: 5,
),
Text(
code,
style: TextStyle(
color: isInverted ? _blackColor.withOpacity(0.8) : _whiteColor.withOpacity(0.8),
fontSize: 20,
),
),
],
),
],
),
Transform.scale(
scale: 2.2,
child: Transform.translate(
offset: const Offset(-5, 12),
child: Icon(
icon,
color: isInverted ? _blackColor : _whiteColor,
size: 88,
),
),
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment