<p>In this example, I'm going to share the code which will help you to show a Loader icon when an operation is being performed.</p> <p> async { await new Future.delayed(const Duration(seconds: 5), () ); return 'Hello World'; }</p> <p>void main() => runApp(MyApp(str: fetchStr()));</p> <p snapshot.error="">class MyApp extends StatelessWidget { final Future str; MyApp({Key key, this.str}) : super(key: key); @override Widget build(BuildContext context) { return MaterialApp( title: 'Fetch Data Example', theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( appBar: AppBar( title: Text('Fetch Data Example'), ), body: Center( child: FutureBuilder( future: str, builder: (context, snapshot) { if (snapshot.hasData) { return Text(snapshot.data); } else if (snapshot.hasError) { return Text("$"); } // By default, show a loading spinner return CircularProgressIndicator(); }, ), ), ), ); } }</p> <p>Hope this will be useful to you.</p> <p>Thanks, Srikanth</p>
Show loading while performing an operation in Flutter
This Article is posted by seven.srikanth at 2/6/2019 6:54:29 AM
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter
Tags: Show loading while performing an operation in Flutter
Check out our other latest articles
Safearea widget - How to avoid visual overlap with Notch on flutter mobile app?How to convert row of widgets into column of widgets in flutter based on screen size?
How to run Flutter programs from GitHub?
How to get screen orientation in flutter?
NavigationRail example in flutter