title: How to use dart.core.sink in flutter
body: <pre><code>import 'package:flutter/material.dart';
  import 'dart:async';
  
  
  
  void main() =&gt; runApp(MyApp());
  
  //Using Bloc
  class MyApp extends StatelessWidget {
    @override
    Widget build(BuildContext context) {
      return StreamBuilder(
        stream: bloc.darkThemeEnabled,
        initialData: false,
        builder: (context, snapshot) =&gt; MaterialApp(
            theme: snapshot.data ? ThemeData.dark() : ThemeData.light(),
            home: HomePage(snapshot.data)),
      );
    }
  }
  
  class HomePage extends StatelessWidget {
    final bool darkThemeEnabled;
  
    HomePage(this.darkThemeEnabled);
  
    @override
    Widget build(BuildContext context) {
      return Scaffold(
        appBar: AppBar(
          title: Text("Dynamic Theme"),
        ),
        body: Center(
          child: Text("Hello World"),
        ),
        drawer: Drawer(
          child: ListView(
            children: &lt;Widget&gt;[
              ListTile(
                title: Text("Dark Theme"),
                trailing: Switch(
                  value: darkThemeEnabled,
                  onChanged: bloc.changeTheme,
                ),
              )
            ],
          ),
        ),
      );
    }
  }
  
  
  class Bloc {
    final _themeController = StreamController&lt;bool&gt;();
    get changeTheme =&gt; _themeController.sink.add;
    get darkThemeEnabled =&gt; _themeController.stream;
  }
  
  final bloc = Bloc();
  
  </code></pre>
  
  <p><strong>1.A warning says to Close instances of dart.core.sink 
  2.Why dart.core.sink is used in flutter?
  3.How can I solve this error 
  4.Its error documentation redirects me to this website <a href="https://dart-lang.github.io/linter/lints/close_sinks.html" rel="noreferrer">link</a> 
  5.I don't know how to use these methods in flutter please guide me</strong></p>