Skip to content

Instantly share code, notes, and snippets.

@jonahwilliams
Forked from patientplatypus/flutterprob.dart
Last active March 6, 2018 02:51
Show Gist options
  • Save jonahwilliams/d1bce46daeab5927ec052f8eb4628fca to your computer and use it in GitHub Desktop.
Save jonahwilliams/d1bce46daeab5927ec052f8eb4628fca to your computer and use it in GitHub Desktop.
Having trouble updating passed variable in flutter
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