Skip to content

Instantly share code, notes, and snippets.

@manujbahl
Created June 15, 2018 03:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save manujbahl/624de856cbe78cfa5ac4e517d61f06a0 to your computer and use it in GitHub Desktop.
Save manujbahl/624de856cbe78cfa5ac4e517d61f06a0 to your computer and use it in GitHub Desktop.
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