在Flutter中,可以使用Card和Text Widget来创建卡片和标题。
示例代码如下:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Card and Title',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Flutter Card and Title'),
),
body: Center(
child: Card(
child: Column(
children: [
ListTile(
title: Text(
'Card Title',
style: TextStyle(
fontSize: 20,
fontWeight: FontWeight.bold,
),
),
subtitle: Text('Card Subtitle'),
),
Image.network('https://example.com/image.jpg'),
Padding(
padding: EdgeInsets.all(8.0),
child: Text(
'Card Content',
style: TextStyle(fontSize: 16),
),
),
],
),
),
),
);
}
}
注意:以上示例代码中的图片URL需要替换为有效的图片URL。
附腾讯云云计算服务链接:https://cloud.tencent.com/product/SCF
领取专属 10元无门槛券
手把手带您无忧上云