Skip to content

Instantly share code, notes, and snippets.

@Lxxyx
Created January 8, 2025 09:52
Show Gist options
  • Save Lxxyx/a1f55fa68e107b6a1909e9c280335209 to your computer and use it in GitHub Desktop.
Save Lxxyx/a1f55fa68e107b6a1909e9c280335209 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 Card Demo',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: Colors.blue,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatelessWidget {
const MyHomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Chat Card Demo'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 3,
children: [
ChatCard(
name: 'John Doe',
introduction: ' Software Engineer',
link: 'https://github.com/johndoe',
),
ChatCard(
name: 'Jane Doe',
introduction: ' UX Designer',
link: 'https://dribbble.com/janedoe',
),
ChatCard(
name: 'Bob Smith',
introduction: 'Data Analyst',
link: 'https://www.linkedin.com/in/bobsmith/',
),
ChatCard(
name: 'Alice Johnson',
introduction: 'Full Stack Developer',
link: 'https://twitter.com/alicejohnson',
),
],
),
),
);
}
}
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(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
name,
style: Theme.of(context).textTheme.headlineMedium,
),
Text(introduction),
TextButton(
onPressed: () {
// Open link in browser
// You can use url_launcher package for this
print('Link button pressed: $link');
},
child: const Text('Connect'),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment