smart_content_viewer 1.0.1
smart_content_viewer: ^1.0.1 copied to clipboard
Comprehensive Flutter widget for educational content - LaTeX formulas, math graphs, statistical charts, physics diagrams, and chemistry diagrams. No WebView required.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:smart_content_viewer/smart_content_viewer.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Smart Content Viewer Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.blue),
useMaterial3: true,
),
home: const DemoPage(),
);
}
}
class DemoPage extends StatefulWidget {
const DemoPage({super.key});
@override
State<DemoPage> createState() => _DemoPageState();
}
class _DemoPageState extends State<DemoPage> {
final String demoContent = '''
<h3>Formules Mathématiques</h3>
<p>Voici quelques exemples de formules LaTeX :</p>
<h4>Formules en ligne</h4>
<p>La célèbre équation d'Einstein : \$E = mc^2\$</p>
<p>L'aire d'un cercle : \$A = \pi r^2\$</p>
<h4>Formules en bloc</h4>
<p>Le théorème de Pythagore :</p>
\$\$a^2 + b^2 = c^2\$\$
<p>La formule quadratique :</p>
\$\$x = \frac{-b \pm \sqrt{b^2 - 4ac}}{2a}\$\$
<h4>Matrices</h4>
<p>Une matrice 2x2 :</p>
\$\$\\begin{pmatrix} a & b \\\\ c & d \\end{pmatrix}\$\$
<p>Matrice avec crochets :</p>
\$\$\\begin{bmatrix} 1 & 2 & 3 \\\\ 4 & 5 & 6 \\end{bmatrix}\$\$
<h4>Systèmes d'équations</h4>
<p>Un système linéaire :</p>
\$\$\\begin{cases} x + y = 5 \\\\ 2x - y = 1 \\end{cases}\$\$
<h4>Intégrales et Sommes</h4>
<p>Intégrale définie :</p>
\$\$\int_{a}^{b} f(x) \, dx\$\$
<p>Somme :</p>
\$\$\sum_{i=1}^{n} x_i\$\$
<h4>Graphique de fonction</h4>
<p>Parabole : [graph: f(x)=x^2, x=-5..5, y=-10..10]</p>
<p>Fonction trigonométrique : [graph: f(x)=sin(2*x), x=-3.14..3.14, y=-2..2]</p>
<h4>Lettres grecques</h4>
<p>\$\$\alpha, \beta, \gamma, \delta, \theta, \lambda, \mu, \pi, \sigma, \phi, \omega\$\$
''';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text('Smart Content Viewer Demo'),
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
),
body: SingleChildScrollView(
padding: const EdgeInsets.all(16),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Info card
Card(
color: Colors.blue.shade50,
child: Padding(
padding: const EdgeInsets.all(16),
child: Row(
children: [
Icon(Icons.info, color: Colors.blue.shade700),
const SizedBox(width: 12),
Expanded(
child: Text(
'Contient des formules: ${hasMathFormulas(demoContent) ? "Oui" : "Non"}',
style: TextStyle(
fontWeight: FontWeight.bold,
color: Colors.blue.shade700,
),
),
),
],
),
),
),
const SizedBox(height: 16),
// Math content viewer
MathContentViewer(
htmlContent: demoContent,
minHeight: 300,
),
],
),
),
);
}
}