Skip to content

Instantly share code, notes, and snippets.

@Lxxyx
Created January 8, 2025 09:49
Show Gist options
  • Save Lxxyx/9a666b92ea9c6a6ad6bfa2fc09b6cc28 to your computer and use it in GitHub Desktop.
Save Lxxyx/9a666b92ea9c6a6ad6bfa2fc09b6cc28 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 Bot',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: Colors.blue,
),
home: const MyHomePage(title: 'Chat Bot'),
);
}
}
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 ChatBotCard(
name: 'Bot $index',
description: 'This is bot $index',
onPressed: () {
// Add your onPressed logic here
},
);
},
),
);
}
}
class ChatBotCard extends StatelessWidget {
final String name;
final String description;
final VoidCallback onPressed;
const ChatBotCard({
super.key,
required this.name,
required this.description,
required this.onPressed,
});
@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(description),
SizedBox(height: 16),
ElevatedButton(
onPressed: onPressed,
child: Text('Chat'),
),
],
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment