Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9199919
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:38:56+00:00 2026-06-17T22:38:56+00:00

I basically know how to use them; for instance listening to the onClick Stream

  • 0

I basically know how to use them; for instance listening to the onClick Stream of an Element.

But, how do you set up your own Streams?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T22:38:57+00:00Added an answer on June 17, 2026 at 10:38 pm

    Simple example

    Here’s a complete working example:

    import 'dart:async';
    import 'dart:io';
    
    class Application {
      Stream onExit;
      
      Application() {
        // Create a stream controller and assign its stream to "onExit".
        var controller = new StreamController();
        onExit = controller.stream;
    
        // Create some class that uses our stream.
        new UserOfStream(this);
        
        // Whenever we exit the application, notify everyone about it first.
        controller.add('we are shutting down!');
        exit(0);
      }
    }
    
    class UserOfStream {
      UserOfStream(app) {
        app.onExit.listen((String message) => print(message));
      }
    }
    
    main() => new Application();
    

    You can also do cool things like check if there are subscribers with controller.hasListener or you can signal an error. Be sure to check the API documentation on StreamController.

    You can use new StreamController.broadcast() for allowing multiple listeners.

    For copy-pasters

    Here’s a simple way to create a stream (great snippet for copy-pasters):

    class Something {
      StreamController _onExitController = new StreamController.broadcast();
      Stream get onExit => _onExitController.stream;
    }
    

    Then the class can just access _onExitController to control the stream (to for example .add()).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

They are pretty popular but I never have the balls to use them. Basically,
Basically I'm still in the starting phase, and I know how to use Console.WriteLine
Basically, I just want to know if its possible to use Nhibernate to migrate
For instance, I know that basically all languages that are object oriented based are
As I know alpha composition uses straight alpha basically. But all GLES blending sample
Basically, I want to enter text into a text area, and then use them.
I am wondering about timers in WPF. what i basically know is how to
I basically want to know what the system's input language is currently on (for
Basically, I want to know what is best to avoid future problems and confusions
Let me know if anyone know what is the issue with this code. Basically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.