Created
June 15, 2018 03:28
-
-
Save manujbahl/624de856cbe78cfa5ac4e517d61f06a0 to your computer and use it in GitHub Desktop.
FutureBuilder
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
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