Last active
January 10, 2023 17:22
-
-
Save yaashwardhan/6dbf621609420db5ff92286197f32631 to your computer and use it in GitHub Desktop.
Revisions
-
yaashwardhan revised this gist
Jan 3, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -25,7 +25,7 @@ class _PageTwoState extends State<PageTwo> { Container( height: 400, width: double.infinity, color: passedColor, ), Text('$passedColorName color was passed'), RaisedButton( -
yaashwardhan revised this gist
Jan 3, 2021 . 1 changed file with 1 addition and 5 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -34,8 +34,4 @@ class _PageTwoState extends State<PageTwo> { Navigator.pop(context); }, child: Text('<- Go back')) ],),);} -
yaashwardhan revised this gist
Jan 3, 2021 . 2 changed files with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,5 +1,4 @@ import 'package:flutter/material.dart'; class PageTwo extends StatefulWidget { final Color passedColor; final String passedColorName; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ import 'package:flutter/material.dart'; class PageTwo extends StatefulWidget { final Color passedColor; final String passedColorName; -
yaashwardhan revised this gist
Jan 3, 2021 . 2 changed files with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,7 +32,8 @@ class _PageTwoState extends State<PageTwo> { }, child: Text('<- Go back')) ],),);},} // Use this if u want to later make changes to the passed value in the code. Full code in the file below // NOTE: Here 'foo' means 'your value' // class MyStateful extends StatefulWidget { // final String foo; // const MyStateful({Key key, this.foo}): super(key: key); File renamed without changes. -
yaashwardhan revised this gist
Jan 3, 2021 . 1 changed file with 40 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,40 @@ class PageTwo extends StatefulWidget { final Color passedColor; final String passedColorName; const PageTwo({Key key, this.passedColor, this.passedColorName}) : super(key: key); @override _PageTwoState createState() => _PageTwoState( passedColor: this.passedColor, passedColorName: this.passedColorName); } class _PageTwoState extends State<PageTwo> { Color passedColor; String passedColorName; _PageTwoState({this.passedColor, this.passedColorName}); @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Page 2'), automaticallyImplyLeading: false, //to disable going back ), body: Column( children: [ Container( height: 400, width: double.infinity, color: passedColor.withOpacity(0.5), ), Text('$passedColorName color was passed'), RaisedButton( color: Colors.grey, onPressed: () { Navigator.pop(context); }, child: Text('<- Go back')) ], ), ); } } -
yaashwardhan revised this gist
Jan 3, 2021 . 2 changed files with 5 additions and 30 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,11 +1,9 @@ import 'package:flutter/material.dart'; import 'page2.dart'; class PageOne extends StatefulWidget { @override _PageOneState createState() => _PageOneState(); } class _PageOneState extends State<PageOne> { @override Widget build(BuildContext context) { @@ -23,10 +21,7 @@ class _PageOneState extends State<PageOne> { builder: (_) => PageTwo( passedColor: Colors.pink, passedColorName: 'Pink', ),),);}, child: Text('Pink')), RaisedButton( color: Colors.blueGrey, @@ -37,17 +32,9 @@ class _PageOneState extends State<PageOne> { builder: (_) => PageTwo( passedColor: Colors.blueGrey, passedColorName: 'Blue', ),),);}, child: Text('Blue'), ), SizedBox( height: 250, )],),);}} This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,5 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; class PageTwo extends StatefulWidget { final Color passedColor; final String passedColorName; @@ -10,7 +9,6 @@ class PageTwo extends StatefulWidget { @override _PageTwoState createState() => _PageTwoState(); } class _PageTwoState extends State<PageTwo> { @override Widget build(BuildContext context) { @@ -33,28 +31,18 @@ class _PageTwoState extends State<PageTwo> { Navigator.pop(context); }, child: Text('<- Go back')) ],),);},} // Use this if u want to later make changes to the passed value in the code // class MyStateful extends StatefulWidget { // final String foo; // const MyStateful({Key key, this.foo}): super(key: key); // @override // _MyStatefulState createState() => _MyStatefulState(foo: this.foo); // } // class _MyStatefulState extends State<MyStateful> { // String foo; // _MyStatefulState({this.foo}); // @override // Widget build(BuildContext context) { // return Text(foo); // },} -
yaashwardhan revised this gist
Dec 30, 2020 . 1 changed file with 0 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ import 'package:flutter/material.dart'; import 'page1.dart'; -
yaashwardhan revised this gist
Dec 30, 2020 . 1 changed file with 1 addition and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,4 @@ //Passing data to a Stateful Widget from another Stateful Widget import 'package:flutter/material.dart'; import 'page1.dart'; -
yaashwardhan created this gist
Dec 30, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ import 'package:flutter/material.dart'; import 'page1.dart'; void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( theme: ThemeData.dark(), home: Scaffold( appBar: AppBar( title: Text('Page 1'), ), body: PageOne(), ), ); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,53 @@ import 'package:flutter/material.dart'; import 'page2.dart'; class PageOne extends StatefulWidget { @override _PageOneState createState() => _PageOneState(); } class _PageOneState extends State<PageOne> { @override Widget build(BuildContext context) { return Center( child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text('Choose the color (value to be passed) of the Next Page:'), RaisedButton( color: Colors.pink, onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) => PageTwo( passedColor: Colors.pink, passedColorName: 'Pink', ), ), ); }, child: Text('Pink')), RaisedButton( color: Colors.blueGrey, onPressed: () { Navigator.push( context, MaterialPageRoute( builder: (_) => PageTwo( passedColor: Colors.blueGrey, passedColorName: 'Blue', ), ), ); }, child: Text('Blue'), ), SizedBox( height: 250, ) ], ), ); } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,60 @@ import 'package:flutter/material.dart'; import 'package:flutter/cupertino.dart'; class PageTwo extends StatefulWidget { final Color passedColor; final String passedColorName; const PageTwo( {Key key, this.passedColor, this.passedColorName}) //key:key is used : super(key: key); @override _PageTwoState createState() => _PageTwoState(); } class _PageTwoState extends State<PageTwo> { @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Page 2'), automaticallyImplyLeading: false, //to disable going back ), body: Column( children: [ Container( height: 400, width: double.infinity, color: widget.passedColor, ), Text('${widget.passedColorName} color was passed'), RaisedButton( color: Colors.grey, onPressed: () { Navigator.pop(context); }, child: Text('<- Go back')) ], ), ); } } // Use this if u want to later make changes to the passed value in the code // class MyStateful extends StatefulWidget { // final String foo; // const MyStateful({Key key, this.foo}): super(key: key); // @override // _MyStatefulState createState() => _MyStatefulState(foo: this.foo); // } // class _MyStatefulState extends State<MyStateful> { // String foo; // _MyStatefulState({this.foo}); // @override // Widget build(BuildContext context) { // return Text(foo); // } // }