CopyPastor

Detecting plagiarism made easy.

Score: 1.8409278988838196; Reported for: String similarity, Exact paragraph match Open both answers

Possible Plagiarism

Plagiarized on 2020-05-15
by Apurv Jha

Original Post

Original - Posted on 2020-05-10
by Michael Aziz



            
Present in both answers; Present only in the new answer; Present only in the old answer;

Yes, you can leave a stream open. but it will impact your app performance and in my opinion it's a complex approach for a simple callback action. Here's what i would do:
** in the Drawer's page: // add a callback parameter
final Function(Widget w) onItemTap;
// add the callback to the drawer's constructor
Drawer(this.onItemTap);
** in The Drawer's gesture detector: // on tapping on an item, send this callback to the page where you have instantiated the drawer page.
onTap(){ widget.onItemTap( WidgetToShow() ) },
Now when you instantiate the drawer class anywhere in your mainscreen you have a callback parameter you can use like this:
Drawer( onItemTap:(Widget w){ // now you have your widget in the mainScreen, do as you want with it } )
So here's your final drawer/menu's code:
class Drawer extends StatefulWidget { final Function(Widget w) onItemTap; Drawer(this.onItemTap); } // .... GestureDetector( onTap: (){ return widget.onItemTap( WidgetToShow() ); }, ), // ...
and here's your main screen code:
// ... stack( children:[ Drawer( onItemTap:(Widget w){ // now you have your widget in the mainScreen, do as you want with it } ), ] ), //...

Hope that helped :)
short answer? Yes, you can leave a stream open. but it will impact your app performance and in my opinion it's a complex approach for a simple callback action. Here's what i would do:
** in the Drawer's page: // add a callback parameter
final Function(Widget w) onItemTap;
// add the callback to the drawer's constructor
Drawer(this.onItemTap);
** in The Drawer's gesture detector: // on tapping on an item, send this callback to the page where you have instantiated the drawer page.
onTap(){ widget.onItemTap( WidgetToShow() ) },
Now when you instantiate the drawer class anywhere in your mainscreen you have a callback parameter you can use like this:
Drawer( onItemTap:(Widget w){ // now you have your widget in the mainScreen, do as you want with it } )
So here's your final drawer/menu's code:
class Drawer extends StatefulWidget { final Function(Widget w) onItemTap; Drawer(this.onItemTap); } // .... GestureDetector( onTap: (){ return widget.onItemTap( WidgetToShow() ); }, ), // ...
and here's your main screen code:
// ... stack( children:[ Drawer( onItemTap:(Widget w){ // now you have your widget in the mainScreen, do as you want with it } ), ] ), //...

Hope that helped :)

        
Present in both answers; Present only in the new answer; Present only in the old answer;