flutter_live_data 1.0.1
flutter_live_data: ^1.0.1

Flutter Android iOS web

Live Data in Flutter

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter_live_data/flutter_live_data.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: 'Live Data',
      theme: ThemeData(
        primarySwatch: Colors.lightGreen,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  @override
  State<StatefulWidget> createState() => HomePageState();
}

class HomePageState extends State<HomePage> {
  LiveData liveData;

  HomePageState() {
    liveData = LiveData<int>(0);

    Timer.periodic(Duration(seconds: 1), (timer) {
      liveData.value += 1;
    });
  }

  @override
  void dispose() {
    liveData.dispose();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return StreamBuilder(
      stream: liveData.stream,
      builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
        return Text('count: ${snapshot.data}');
      },
    );
  }
}
2
likes
80
pub points
43%
popularity

Live Data in Flutter

Homepage

Documentation

API reference

Uploader

nartra@gmail.com

License

MIT (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_live_data