Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 15, 2020 16:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ryanlid/53f5685bd43dfd64b6aff467c00dc16e to your computer and use it in GitHub Desktop.
Save ryanlid/53f5685bd43dfd64b6aff467c00dc16e to your computer and use it in GitHub Desktop.
Stack 层叠布局
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