Created
February 23, 2025 17:10
-
-
Save Lxxyx/3b5274cddc6949e89a1bdadad9a74801 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 StatefulWidget { | |
final String title; | |
const MyHomePage({ | |
super.key, | |
required this.title, | |
}); | |
@override | |
State<MyHomePage> createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
@override | |
Widget build(BuildContext context) { | |
return Scaffold( | |
appBar: AppBar( | |
title: Text(widget.title), | |
), | |
body: ListView.builder( | |
itemCount: 10, | |
itemBuilder: (context, index) { | |
return ChatCard( | |
name: 'User $index', | |
intro: 'Introduction of User $index', | |
link: 'https://www.google.com', | |
); | |
}, | |
), | |
); | |
} | |
} | |
class ChatCard extends StatelessWidget { | |
final String name; | |
final String intro; | |
final String link; | |
const ChatCard({ | |
super.key, | |
required this.name, | |
required this.intro, | |
required this.link, | |
}); | |
@override | |
Widget build(BuildContext context) { | |
return Card( | |
child: Padding( | |
padding: const EdgeInsets.all(16.0), | |
child: Row( | |
children: [ | |
Expanded( | |
flex: 2, | |
child: Column( | |
crossAxisAlignment: CrossAxisAlignment.start, | |
children: [ | |
Text( | |
name, | |
style: Theme.of(context).textTheme.headlineMedium, | |
), | |
Text( | |
intro, | |
style: Theme.of(context).textTheme.bodySmall, | |
), | |
], | |
), | |
), | |
Expanded( | |
flex: 1, | |
child: ElevatedButton( | |
onPressed: () { | |
// Handle link press | |
print('Link pressed: $link'); | |
}, | |
child: const Text('Link'), | |
), | |
), | |
], | |
), | |
), | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment