Flutter: call a method from another class / setState a page from outside that class with StreamController
This Flutter demo shows how to call a method from another class or how to setState a page from outside that class, using StreamController. main.dart import 'package:flutter/material.dart' ; import 'dart:async' ; StreamController<int> streamController = StreamController <int>(); void main() { runApp( MyApp ()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp ( title: 'Flutter Demo' , theme: ThemeData ( primarySwatch: Colors. blue , ), home: MyHomePage ( 'Flutter Demo Home Page' , streamController. stream ), ); } } class MyHomePage extends StatefulWidget { MyHomePage( this . title , this . stream ); final String title ; final Stream<int> stream ; @override _MyHomePageState createState() => _MyHomePageState (); } class _MyHomePageState extends State<MyHomePage> { String menuName = 'A' ; @override void i...