Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
FutureBuilder
import 'package:flutter/material.dart';
main() {
runApp(new TestSample());
}
class TestSample extends StatelessWidget{
@override
Widget build(BuildContext context) {
var widget = new MaterialApp(
home: new Scaffold(
body: new Center(
child: new MyContainer(),
)
),
);
return widget;
}
}
class MyContainer extends StatelessWidget {
@override
Widget build(BuildContext context) {
return new FutureBuilder<dynamic>(
future: getWidgetText(),
builder: (context, snapshot) {
return new Text(snapshot.data);
}
);
}
getWidgetText() async {
return "CHanges";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment