Skip to content

Instantly share code, notes, and snippets.

@TheAnimatrix
Created May 4, 2020 13:03
Show Gist options
  • Save TheAnimatrix/58c24add42b7432649661a9931b4a837 to your computer and use it in GitHub Desktop.
Save TheAnimatrix/58c24add42b7432649661a9931b4a837 to your computer and use it in GitHub Desktop.
an idea..
void main() {
runApp(MainApp());
}
class MainApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
MiniApp miniApp = MiniApp();
return StreamBuilder<Object>(
stream: miniApp.stateStream,
builder: (context, snapshot) {
if(snapshot.connectionstate=waiting) return loader
if(snapshot.data!="AUTHENTICATED")
return miniApp.buildWidget;
else
return other;
}
);
}
}
//let this be the mini-app
class MiniApp{
Widget w;
Stream s;
MiniApp();
Widget get buildWidget
{
return Builder(builder: (ctx){
return MyApp(); //pass stream controller etc to widget and set s
},);
}
Stream get stateStream
{
return s;
}
}
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return StreamProvider.value(
child: MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
fontFamily: 'PS',
primarySwatch: Colors.red,
),
home: Wrapper()),
value: AuthService().user,
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment