flutter 实现流式布局

学习flutter第一天打卡
布局真的是超级不适应
据说能无限复用
还在学习中
希望有点成果


class LayoutDemo extends StatelessWidget {
  const LayoutDemo({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Padding(
        padding: EdgeInsets.all(10),
        child: Wrap(
          children: [
            Button("第一集", onPressed: () {}),
            Button("第二二集", onPressed: () {}),
            Button("第三集", onPressed: () {}),
            Button("第四集", onPressed: () {}),
            Button("第五集", onPressed: () {}),
            Button("第六二集", onPressed: () {}),
            Button("第七集", onPressed: () {}),
            Button("第八集", onPressed: () {}),
            Button("第九二集", onPressed: () {}),
            Button("第十集", onPressed: () {}),
          ],
        ),
    );
  }
}
class Button extends StatelessWidget {
  String text;
  void Function()? onPressed;
   Button(this.text,{Key? key,required this.onPressed}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ElevatedButton(
        onPressed:onPressed ,
        style: ButtonStyle(
          backgroundColor: MaterialStateProperty.all(Colors.red,)
        ),
        child: Text(text));
  }
}

你可能感兴趣的:(flutter 实现流式布局)