gpt4 book ai didi

flutter - Flutter:我要排成一排,有两张卡片,上面有一张图片和一个文字,如下图所示

转载 作者:行者123 更新时间:2023-12-03 04:25:07 25 4
gpt4 key购买 nike

Flutter:我要排成一排,有两张卡片,上面有一张图片和一个文字,如下图所示

body: groups.isEmpty
? Center(child: Text('No Students'))
: ListView(
children: [
...groups.map(
(group) => Card(
elevation: 7,
child: ListTile(
leading: CircleAvatar(
backgroundImage: AssetImage('assets/01.jpg'),
),
title: Text(group),
trailing: Icon(Icons.person),

)
),
)
],
)

This is The Full Code!

members image

最佳答案

您可以使用GridView,将crossAxisCount设置为2,然后将Column放入Card内。

 import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}

class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);

final String title;

@override
_MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: GridView.builder(
itemCount: 6,
gridDelegate: SliverGridDelegateWithFixedCrossAxisCount(
childAspectRatio: 8.0 / 10.0,
crossAxisCount: 2,
),
itemBuilder: (BuildContext context, int index) {
return Padding(
padding: EdgeInsets.all(5),
child: Card(
semanticContainer: true,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
clipBehavior: Clip.antiAlias,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Expanded(
child: Container(
decoration: BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/no_image.png'),
fit: BoxFit.fill),
),
)),
Padding(
padding: EdgeInsets.all(10.0),
child: Text(
"Name",
style: TextStyle(fontSize: 18.0),
)),
],
)));
},
));
}
}

关于flutter - Flutter:我要排成一排,有两张卡片,上面有一张图片和一个文字,如下图所示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60247904/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com