Skip to content

Instantly share code, notes, and snippets.

@Lxxyx
Created January 8, 2025 09:47
Show Gist options
  • Save Lxxyx/e87cae16e2dd0543c9fdbb0a75e14432 to your computer and use it in GitHub Desktop.
Save Lxxyx/e87cae16e2dd0543c9fdbb0a75e14432 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: '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: Padding(
padding: const EdgeInsets.all(16.0),
child: GridView.count(
crossAxisCount: 2,
childAspectRatio: 3,
children: [
ChatCard(
name: 'John Doe',
introduction: 'Software Engineer',
link: 'https://www.linkedin.com/in/johndoe/',
),
ChatCard(
name: 'Jane Doe',
introduction: 'Product Manager',
link: 'https://www.linkedin.com/in/janedoe/',
),
ChatCard(
name: 'Bob Smith',
introduction: 'UI Designer',
link: 'https://www.linkedin.com/in/bobsmith/',
),
ChatCard(
name: 'Alice Brown',
introduction: 'Data Scientist',
link: 'https://www.linkedin.com/in/alicebrown/',
),
],
),
),
);
}
}
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.headlineMedium,
),
Text(
introduction,
style: Theme.of(context).textTheme.bodyMedium,
),
SizedBox(height: 8),
ElevatedButton(
onPressed: () {
// Implement link opening logic here
print('Opening link: $link');
},
child: Text('View Profile'),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment