Future Api
Complete Code For Future Api In Flutter
main.dart
import 'dart:async'; import 'package:flutter/material.dart'; void main() { runApp(new MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { return new MaterialApp( debugShowCheckedModeBanner: false, title: 'Transform', home: new MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State<MyHomePage> { bool _isLoading = false; initApp() async { setState(() => _isLoading = true); Future.delayed(Duration(seconds: 6)).then((_) { setState(() => _isLoading = false); }); } @override void initState() { super.initState(); initApp(); } @override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.black, appBar: AppBar( backgroundColor: Colors.amber, title: Text("Future Example")), body: Center( child: _isLoading ? CircularProgressIndicator() : Text("Future Completed!", style: TextStyle(fontSize: 20, fontWeight: FontWeight.bold,color: Colors.white))), ); } }