Created
March 9, 2023 01:19
-
-
Save cerberodev/d1dd10c17c2ecfb4780b02dd3e58c335 to your computer and use it in GitHub Desktop.
Uclass 4
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}); | |
// This widget is the root of your application. | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
title: 'Flutter Demo', | |
theme: ThemeData( | |
primarySwatch: Colors.blue, | |
), | |
home: Scaffold( | |
backgroundColor: Colors.deepPurple.shade100, | |
appBar: AppBar( | |
title: const Text('Clase Cuatro'), | |
), | |
body: const ListOfStacks(), | |
), | |
); | |
} | |
} | |
class ListOfStacks extends StatelessWidget { | |
const ListOfStacks({Key? key}) : super(key: key); | |
@override | |
Widget build(BuildContext context) { | |
const TextAlign textAlign = TextAlign.center; | |
return SingleChildScrollView( | |
padding: const EdgeInsets.all(16), | |
child: Column( | |
mainAxisSize: MainAxisSize.min, | |
children: [ | |
SizedBox( | |
width: 250, | |
child: Row( | |
mainAxisSize: MainAxisSize.max, | |
children: [ | |
Expanded( | |
flex: 2, | |
child: Container( | |
color: Colors.red, | |
height: 100, | |
width: 50, | |
)), | |
Container(color: Colors.yellow, height: 100, width: 50), | |
Container(color: Colors.green, height: 100, width: 50), | |
], | |
), | |
), | |
const Divider(), | |
SizedBox( | |
width: 250, | |
child: Row( | |
children: [ | |
Flexible( | |
flex: 2, | |
child: Container( | |
color: Colors.red, | |
height: 100, | |
width: 100, | |
)), | |
Container(color: Colors.yellow, height: 100, width: 50), | |
], | |
), | |
), | |
GestureDetector( | |
onTap: () { | |
ScaffoldMessenger.of(context).showSnackBar( | |
const SnackBar( | |
content: Text('Tapped'), | |
), | |
); | |
}, | |
onLongPress: () => ScaffoldMessenger.of(context).showSnackBar( | |
const SnackBar( | |
content: Text('Long Pressed'), | |
), | |
), | |
child: Card( | |
clipBehavior: Clip.antiAlias, | |
shape: ShapeBorder.lerp( | |
const RoundedRectangleBorder( | |
borderRadius: BorderRadius.all(Radius.circular(16)), | |
), | |
const RoundedRectangleBorder( | |
borderRadius: BorderRadius.all(Radius.circular(16)), | |
), | |
0.5, | |
), | |
child: SizedBox( | |
width: 200, | |
height: 200, | |
child: Stack( | |
children: [ | |
Image.network( | |
'https://picsum.photos/800/800', | |
fit: BoxFit.cover, | |
), | |
SizedBox( | |
width: double.maxFinite, | |
height: 35, | |
child: Card( | |
margin: EdgeInsets.zero, | |
clipBehavior: Clip.antiAlias, | |
shape: ShapeBorder.lerp( | |
const RoundedRectangleBorder( | |
borderRadius: BorderRadius.all(Radius.circular(16)), | |
), | |
const RoundedRectangleBorder( | |
borderRadius: BorderRadius.all(Radius.circular(0)), | |
), | |
1, | |
), | |
child: const Center( | |
child: Text( | |
'Title Product', | |
textAlign: textAlign, | |
), | |
), | |
), | |
), | |
Align( | |
alignment: Alignment.bottomLeft, | |
child: SizedBox( | |
width: 150, | |
height: 35, | |
child: Card( | |
margin: EdgeInsets.zero, | |
color: Colors.deepPurple.shade200, | |
clipBehavior: Clip.antiAlias, | |
shape: ShapeBorder.lerp( | |
const RoundedRectangleBorder( | |
borderRadius: | |
BorderRadius.all(Radius.circular(16)), | |
), | |
const RoundedRectangleBorder( | |
borderRadius: | |
BorderRadius.all(Radius.circular(16)), | |
), | |
0.5, | |
), | |
child: const Center( | |
child: Text( | |
'Discount 50%', | |
textAlign: textAlign, | |
), | |
), | |
), | |
), | |
), | |
], | |
), | |
), | |
), | |
), | |
Container( | |
height: MediaQuery.of(context).size.height * 0.65, | |
padding: const EdgeInsets.all(16), | |
child: Stack( | |
children: [ | |
const Positioned( | |
top: 2, | |
left: 23, | |
child: CircleAvatar( | |
backgroundImage: | |
NetworkImage('https://picsum.photos/200/300'), | |
), | |
), | |
Positioned( | |
top: 66, | |
left: 66, | |
width: 66, | |
height: 66, | |
child: IconButton( | |
iconSize: 24, | |
icon: const Icon(Icons.add), | |
onPressed: () {}, | |
color: Colors.red, | |
), | |
), | |
Positioned( | |
top: 132, | |
child: Container( | |
width: 150, | |
height: 150, | |
color: Colors.blue, | |
child: const Text( | |
'Use Stack B', | |
textAlign: textAlign, | |
), | |
), | |
), | |
const Positioned( | |
top: 198, | |
child: Card( | |
color: Colors.green, | |
child: Text( | |
'Use Stack C', | |
textAlign: textAlign, | |
), | |
), | |
), | |
], | |
), | |
), | |
], | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment