82 lines
1.9 KiB
Dart
Raw Normal View History

2023-02-09 15:05:33 +01:00
import 'dart:math';
2023-02-09 10:26:53 +01:00
import 'package:flutter/material.dart';
2023-02-09 11:25:48 +01:00
import 'package:real_time_chart/real_time_chart.dart';
2023-02-09 10:26:53 +01:00
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<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
2023-02-09 11:25:48 +01:00
backgroundColor: Colors.black,
2023-02-09 10:26:53 +01:00
appBar: AppBar(
title: Text(widget.title),
),
body: Column(
children: [
Flexible(
child: Container(
color: Colors.red,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: RealTimeGraph(
stream: getDataStream(),
),
),
2023-02-09 11:25:48 +01:00
),
const SizedBox(
height: 32,
),
Flexible(
child: Container(
color: Colors.red,
width: MediaQuery.of(context).size.width,
height: MediaQuery.of(context).size.width,
child: RealTimeGraph(
stream: getDataStream(),
displayMode: ChartDisplay.points,
),
),
),
],
2023-02-09 10:26:53 +01:00
),
);
}
2023-02-09 11:25:48 +01:00
int count = 0;
bool up = true;
Stream<double> getDataStream() {
2023-02-09 15:05:33 +01:00
return Stream.periodic(const Duration(milliseconds: 500), (_) {
return Random().nextInt(300).toDouble();
2023-02-09 11:25:48 +01:00
});
}
2023-02-09 10:26:53 +01:00
}