Last active
September 27, 2023 14:44
-
-
Save codesxt/0e028e0201d2c02e2055dfc16eb3d907 to your computer and use it in GitHub Desktop.
Flutter Layout Example: Credit card app
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(const MyApp()); | |
} | |
class MyApp extends StatelessWidget { | |
const MyApp({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), | |
useMaterial3: true, | |
), | |
home: const MyHomePage(), | |
debugShowCheckedModeBanner: false, | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
const MyHomePage({super.key}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
body: SafeArea( | |
child: Container( | |
padding: const EdgeInsets.all(16), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: [ | |
Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
IconButton( | |
iconSize: 40, | |
icon: const Icon(Icons.circle_notifications_rounded), | |
onPressed: () {}, | |
color: Colors.grey.shade400, | |
), | |
CircleAvatar( | |
backgroundColor: Colors.grey.shade400, | |
child: const Icon(Icons.person_2_rounded), | |
) | |
], | |
), | |
const SizedBox(height: 40), | |
Text( | |
'Total Balance', | |
style: Theme.of(context).textTheme.headlineSmall!.copyWith( | |
color: Colors.grey.shade600, | |
), | |
), | |
Text( | |
'\$123.123', | |
style: Theme.of(context).textTheme.displaySmall, | |
), | |
const SizedBox(height: 20), | |
Row( | |
mainAxisAlignment: MainAxisAlignment.start, | |
children: [ | |
Container( | |
padding: const EdgeInsets.symmetric( | |
horizontal: 40, | |
vertical: 10, | |
), | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(20), | |
color: Colors.grey.shade200, | |
), | |
child: const Icon( | |
Icons.credit_card_rounded, | |
color: Colors.red, | |
size: 30, | |
), | |
), | |
const SizedBox(width: 20), | |
const Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
'Primary Card', | |
style: TextStyle( | |
fontWeight: FontWeight.bold, | |
), | |
), | |
Text( | |
'Card 1234', | |
style: TextStyle( | |
fontWeight: FontWeight.w300, | |
), | |
), | |
], | |
), | |
], | |
), | |
const SizedBox(height: 20), | |
Column( | |
children: [ | |
Container( | |
padding: const EdgeInsets.all(20), | |
decoration: BoxDecoration( | |
borderRadius: BorderRadius.circular(20), | |
color: Colors.deepPurple, | |
), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.stretch, | |
children: [ | |
const Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
Icon( | |
Icons.credit_card_rounded, | |
size: 40, | |
color: Colors.white, | |
), | |
Icon( | |
Icons.signal_cellular_alt_sharp, | |
size: 40, | |
color: Colors.white, | |
), | |
], | |
), | |
const SizedBox(height: 30), | |
Text( | |
'1234 5678 1234 0000', | |
textAlign: TextAlign.justify, | |
style: Theme.of(context) | |
.textTheme | |
.headlineMedium! | |
.copyWith( | |
color: Colors.white, | |
), | |
), | |
const SizedBox(height: 30), | |
const Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
Text( | |
'Lorem Ipsum', | |
style: TextStyle( | |
fontSize: 18, | |
color: Colors.white, | |
), | |
), | |
Text( | |
'AA/BB', | |
style: TextStyle( | |
fontSize: 18, | |
color: Colors.white, | |
), | |
), | |
Icon( | |
Icons.credit_card_rounded, | |
color: Colors.red, | |
), | |
], | |
) | |
], | |
), | |
), | |
Container( | |
height: 100, | |
padding: const EdgeInsets.all(20), | |
decoration: BoxDecoration( | |
borderRadius: const BorderRadius.only( | |
bottomLeft: Radius.circular(20), | |
bottomRight: Radius.circular(20), | |
), | |
color: Colors.grey.shade300, | |
), | |
child: Row( | |
mainAxisAlignment: MainAxisAlignment.spaceBetween, | |
children: [ | |
Text( | |
'Add New Card', | |
style: Theme.of(context).textTheme.headlineMedium, | |
), | |
IconButton.outlined( | |
onPressed: () {}, | |
icon: const Icon(Icons.add), | |
) | |
], | |
), | |
), | |
], | |
), | |
], | |
), | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ejemplo de Flutter replicando la estructura de la app vista en el siguiente diseño: https://dribbble.com/shots/22657456-Mobile-Banking-App
Hay algunas diferencias con íconos y tipografías pero se aceptan ya que el objetivo de este ejemplo es demostrar cómo se construye un layout de una aplicación a través de combinar filas, columnas y Widgets simples.