Created
February 15, 2020 16:50
-
-
Save ryanlid/53f5685bd43dfd64b6aff467c00dc16e to your computer and use it in GitHub Desktop.
Stack 层叠布局
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( | |
MaterialApp( | |
title: "Stack层叠布局示例", | |
home: MyApp(), | |
), | |
); | |
} | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
var stack = Stack( | |
alignment: Alignment.topLeft, | |
children: <Widget>[ | |
CircleAvatar( | |
backgroundImage: | |
NetworkImage("https://static.lidong.me/upload/XjGwvaVAI.png"), | |
radius: 100.0, | |
), | |
Container( | |
decoration: BoxDecoration( | |
color: Colors.black38, | |
), | |
child: Text( | |
"哈哈哈哈", | |
style: TextStyle( | |
fontSize: 22.0, | |
fontWeight: FontWeight.bold, | |
color: Colors.white, | |
), | |
), | |
) | |
], | |
); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Stack层叠布局示例"), | |
), | |
body: Center( | |
child: stack, | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment