Created
January 8, 2025 09:55
-
-
Save Lxxyx/8e629b37e125d80741d3cc813c2d962b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: 'Flutter Demo', | |
debugShowCheckedModeBanner: false, | |
theme: ThemeData( | |
colorSchemeSeed: Colors.blue, | |
), | |
home: const MyHomePage(title: 'Flutter Demo Home Page'), | |
); | |
} | |
} | |
class MyHomePage extends StatelessWidget { | |
final String title; | |
const MyHomePage({ | |
super.key, | |
required this.title, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(title), | |
), | |
body: ListView.builder( | |
itemCount: 10, // Assuming you have 10 chat cards | |
itemBuilder: (context, index) { | |
return ChatCard( | |
name: 'John Doe $index', | |
introduction: 'This is a brief introduction about John Doe $index', | |
link: 'https://www.example.com/user/$index', | |
); | |
}, | |
), | |
); | |
} | |
} | |
class ChatCard extends StatelessWidget { | |
final String name; | |
final String introduction; | |
final String link; | |
const ChatCard({ | |
super.key, | |
required this.name, | |
required this.introduction, | |
required this.link, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return Card( | |
child: Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
name, | |
style: Theme.of(context).textTheme.titleMedium, | |
), | |
Text( | |
introduction, | |
style: Theme.of(context).textTheme.bodyMedium, | |
), | |
SizedBox(height: 8), | |
ElevatedButton( | |
onPressed: () { | |
// Handle link button press | |
print('Link button pressed: $link'); | |
}, | |
child: Text('Visit Profile'), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment