Created
February 4, 2020 03:12
-
-
Save Gazer/247894b7d2368dcfb743e2b7e3ced9e3 to your computer and use it in GitHub Desktop.
Flutter Stack Example
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
class TestWidget extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return Padding( | |
padding: const EdgeInsets.all(24.0), | |
child: AspectRatio( | |
aspectRatio: 3 / 2.0, | |
child: LayoutBuilder( | |
builder: (context, BoxConstraints constraints) { | |
return Stack( | |
children: <Widget>[ | |
Positioned( | |
top: constraints.maxHeight * 0.3, | |
bottom: 0, | |
left: 0, | |
right: 0, | |
child: Container( | |
height: constraints.maxHeight * 0.7, | |
decoration: BoxDecoration( | |
color: Colors.blue, | |
borderRadius: BorderRadius.circular(12.0), | |
), | |
), | |
), | |
Positioned( | |
right: 10, | |
top: -constraints.maxHeight * 0.1, | |
bottom: 0, | |
child: AspectRatio( | |
aspectRatio: 1.0, | |
child: Image.asset('assets/1075067_alt02.png')), | |
), | |
Positioned( | |
bottom: 10, | |
left: 10, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: <Widget>[ | |
Icon( | |
Icons.arrow_forward, | |
size: 40, | |
color: Colors.white, | |
), | |
Text( | |
"Lifetime Youth", | |
style: Theme.of(context) | |
.textTheme | |
.headline | |
.copyWith(color: Colors.white, fontSize: 32), | |
), | |
], | |
), | |
) | |
], | |
); | |
}, | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment