应该在那个“流:”部分传递什么?

what should be passed in that " stream: " section?

https://i.stack.imgur.com/0SSFQ.jpg

https://i.stack.imgur.com/0DO8k.jpg

https://i.stack.imgur.com/1nXOz.jpg

https://i.stack.imgur.com/tGpU5.jpg

如何获取要通过多提供程序数组传递的值或流参数类型?

您之前创建的 Stream 函数。

工作示例代码(在本例中为UsingStreamBuilder

import 'dart:async';

import 'package:flutter/material.dart';

class UsingStreamBuilder extends StatelessWidget {
  Stream<int> timedCounter(Duration interval, [int maxCount]) async* {
    int i = 0;
    while (true) {
      await Future.delayed(interval);
      yield i++;
      if (i == maxCount) break;
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: Text("StreamBuilder in Flutter")),
      body: Center(
        child: StreamBuilder<int>(
          stream: timedCounter(Duration(seconds: 2), 10),
          //print an integer every 2secs, 10 times
          builder: (context, snapshot) {
            if (!snapshot.hasData) {
              return Text("No data");
            }
            return Text("${snapshot.data.toString()}",
                style: TextStyle(fontSize: 20));
          },
        ),
      ),
    );
  }
}