import 'package:flutter/material.dart'; import 'res/listData.dart';
void main() { runApp(MyApp()); }
class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( home: Scaffold( appBar: AppBar(title: Text("flutterDemo")), body: HomeContent(), )); } }
class HomeContent extends StatelessWidget { @override Widget build(BuildContext context) { return Container( height: 600, width: 400, color: Colors.pink.shade100, padding: EdgeInsets.all(10), child: Wrap( spacing: 10, // 元素左右间距 runSpacing: 10, // 元素上下间距 // alignment: WrapAlignment.spaceEvenly, // runAlignment: WrapAlignment.center, //spaceAround end direction: Axis.horizontal, // vertical children: [ MyButton('第一集'), MyButton('第一集'), MyButton('第一集'), MyButton('第一集'), MyButton('第一集'), MyButton('第二集'), MyButton('第一集'), MyButton('第二集'), MyButton('第一集'), MyButton('第二集'), MyButton('第一集'), MyButton('第二集'), ], )); } }
class MyButton extends StatelessWidget { String text;
MyButton(this.text); @override Widget build(BuildContext context) { return ElevatedButton( child: Text(this.text), onPressed: () {}, ); } }