Skip to content

Instantly share code, notes, and snippets.

@felangel felangel/main.dart
Created Dec 26, 2018

Embed
What would you like to do?
StatefulWidget Issues
import 'package:flutter/material.dart';
void main() {
runApp(
MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Example'),
),
body: PageA(),
),
),
);
}
class PageA extends StatefulWidget {
@override
_PageAState createState() => _PageAState();
}
class _PageAState extends State<PageA> {
List<String> texts;
@override
Widget build(BuildContext context) {
return Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
PageB(this.texts),
RaisedButton(
child: Text('Get Details'),
onPressed: () => getDetails(),
),
],
);
}
Future<void> getDetails() async {
var texts = await Future.value(['hi']);
setState(() {
this.texts = texts;
});
}
}
class PageB extends StatefulWidget {
final List<String> text;
PageB(this.text);
@override
_PageBState createState() => _PageBState();
}
class _PageBState extends State<PageB> {
@override
Widget build(BuildContext context) {
return someAnimation();
}
Widget someAnimation() {
return Container(
child: Center(
child: Text(
'Details: ${widget.text.toString()}',
),
),
);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.