For this recipe, we will build a simple example of using streams:
- Create a new app and name it stream_demo.
- Update the content of the main.dart file as follows:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Stream',
theme: ThemeData(
primarySwatch: Colors.deepPurple,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: StreamHomePage(),
);
}
}
class StreamHomePage extends StatefulWidget {
@override
_StreamHomePageState createState() => _StreamHomePageState();
}
class _StreamHomePageState extends State<StreamHomePage> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}
- Create a new file in the lib folder of your project, called stream.dart.
- In the stream.dart file, import...