-
-
Save jonahwilliams/d1bce46daeab5927ec052f8eb4628fca to your computer and use it in GitHub Desktop.
Having trouble updating passed variable in flutter
This file contains 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 characters
class NavigationState extends State<MyNavigationHolder> { | |
var goToPass = "/page1"; | |
assignPass(page) { | |
print("inside assignPass"); | |
print("value of page: " + page); | |
setState(() {goToPass = page;}); | |
} | |
Widget build(BuildContext context) { | |
return new Flexible(child: new HeaderPage(goTo: goToPass)); | |
} | |
} | |
import 'package:flutter/material.dart'; | |
import 'main.dart'; | |
class HeaderPage extends StatefulWidget { | |
const HeaderPage({ | |
Key key, | |
this.goTo | |
}) : super(key: key); | |
final String goTo; | |
@override | |
HeaderPageState createState() => new HeaderPageState(); | |
} | |
class HeaderPageState extends State<HeaderPage> { | |
HeaderPageState(); | |
@override | |
Widget build(BuildContext context) { | |
return new Text(widget.goTo); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment