flutter_mjpeg 1.2.3 flutter_mjpeg: ^1.2.3 copied to clipboard
Flutter widget to show mjpeg stream from URL
import 'package:flutter/material.dart';
import 'package:flutter_hooks/flutter_hooks.dart';
import 'package:flutter_mjpeg/flutter_mjpeg.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(),
);
}
}
class MyHomePage extends HookWidget {
@override
Widget build(BuildContext context) {
final isRunning = useState(true);
return Scaffold(
appBar: AppBar(
title: Text('Flutter Demo Home Page'),
),
body: Column(
children: <Widget>[
Expanded(
child: Center(
child: Mjpeg(
isLive: isRunning.value,
stream: 'http://64.74.184.131:8080/mjpg/video.mjpg?timestamp=1560785721651', //'http://192.168.1.37:8081',
),
),
),
Row(
children: <Widget>[
RaisedButton(
onPressed: () {
isRunning.value = !isRunning.value;
},
child: Text('Toggle'),
),
RaisedButton(
onPressed: () {
Navigator.of(context).push(MaterialPageRoute(builder: (context) => Scaffold(appBar: AppBar(),)));
},
child: Text('Push new route'),
),
],
),
],
),
);
}
}