import 'dart:math'; import 'package:flutter/material.dart'; import 'package:real_time_chart/real_time_chart.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( primarySwatch: 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 createState() => _MyHomePageState(); } class _MyHomePageState extends State { @override Widget build(BuildContext context) { final stream = getDataStream().asBroadcastStream(); return Scaffold( backgroundColor: Colors.black, appBar: AppBar( title: Text(widget.title), ), body: SizedBox( width: double.maxFinite, child: Column( children: [ Expanded( child: Container( color: Colors.green, child: RealTimeGraph( stream: stream, ), ), ), const SizedBox( height: 32, child: Divider(color: Colors.grey,), ), Expanded( child: Container( color: Colors.green, child: RealTimeGraph( stream: stream, displayMode: ChartDisplay.points, ), ), ), ], ), ), ); } int count = 0; bool up = true; Stream getDataStream() { return Stream.periodic(const Duration(milliseconds: 500), (_) { return Random().nextInt(500).toDouble(); }); } }