Skip to content

Instantly share code, notes, and snippets.

@ryanlid
Created February 16, 2020 13:48
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/0f23160a775cde81adcfd1d24d43577b to your computer and use it in GitHub Desktop.
Save ryanlid/0f23160a775cde81adcfd1d24d43577b to your computer and use it in GitHub Desktop.
Wrap 按宽高自动换行布局
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
title: "Wrap按宽高自动换行布局示例",
home: MyApp(),
),
);
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Wrap按宽高自动换行布局示例"),
),
body: Wrap(
spacing: 8.0,
runSpacing: 4.0,
children: <Widget>[
Chip(
avatar: CircleAvatar(
backgroundColor: Colors.lightGreen.shade800,
child: Text(
"西门",
style: TextStyle(fontSize: 10.0),
),
),
label: Text("西门吹雪"),
),
Chip(
avatar: CircleAvatar(
backgroundColor: Colors.lightBlue.shade700,
child: Text(
"司空",
style: TextStyle(fontSize: 10.0),
),
),
label: Text("司空摘星"),
),
Chip(
avatar: CircleAvatar(
backgroundColor: Colors.lightBlue.shade700,
child: Text(
"婉清",
style: TextStyle(fontSize: 10.0),
),
),
label: Text("木婉清"),
),
Chip(
avatar: CircleAvatar(
backgroundColor: Colors.lightBlue.shade700,
child: Text(
"一郎",
style: TextStyle(fontSize: 10.0),
),
),
label: Text("萧十一郎"),
),
],
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment