gpt_markdown 0.1.4 gpt_markdown: ^0.1.4 copied to clipboard
The purpose of this package is to render the response of ChatGPT into a Flutter app.
example #
import 'package:flutter/material.dart';
import 'package:tex_markdown/tex_markdown.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
useMaterial3: true,
colorSchemeSeed: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
final TextEditingController _controller = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Column(
children: [
Expanded(
child: ListView(
children: [
AnimatedBuilder(
animation: _controller,
builder: (context, _) {
return TexMarkdown(
_controller.text,
style: const TextStyle(
color: Colors.red,
),
);
}),
],
),
),
ConstrainedBox(
constraints: const BoxConstraints(maxHeight: 300),
child: TextField(
decoration: const InputDecoration(border: OutlineInputBorder()),
maxLines: null,
controller: _controller,
),
),
],
),
);
}
}