Skip to content

Instantly share code, notes, and snippets.

@Lxxyx
Created February 22, 2025 14:13
Show Gist options
  • Save Lxxyx/4512ef243e508b309eb6c7a777edb308 to your computer and use it in GitHub Desktop.
Save Lxxyx/4512ef243e508b309eb6c7a777edb308 to your computer and use it in GitHub Desktop.
import 'package:flutter/material.dart';
void main() => runApp(const MyApp());
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Chat List',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: Colors.blue,
),
home: const ChatListPage(),
);
}
}
class ChatListPage extends StatelessWidget {
const ChatListPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Chat List'),
),
body: ListView.builder(
itemCount: 20, // You can replace 20 with your actual list length
itemBuilder: (context, index) {
return ChatCard(
name: 'Person $index',
intro: 'This is person $index\'s intro',
linkUrl: 'https://google.com',
);
},
),
);
}
}
class ChatCard extends StatelessWidget {
final String name;
final String intro;
final String linkUrl;
const ChatCard({
super.key,
required this.name,
required this.intro,
required this.linkUrl,
});
@override
Widget build(BuildContext context) {
return Card(
child: InkWell(
onTap: () {
// You can handle the tap event here
print('Tap on $name');
},
child: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
name,
style: Theme.of(context).textTheme.titleMedium,
),
Text(
intro,
style: Theme.of(context).textTheme.bodyMedium,
),
Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () {
// You can handle the link tap event here
print('Tap on link of $name');
},
child: const Text('Link'),
),
],
),
],
),
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment