Here is an example of how to show loading while an image is loading in flutter.
For this, you need to add your loading icon into pubspec.yaml file.
And then use the FadeInImage widget.
Here is the full code from main.dart file.
import 'package:flutter/material.dart';
main(List<String> args) {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@
override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(body: MyHomePage()),
);
}
}
class MyHomePage extends StatelessWidget {
@
override
Widget build(BuildContext context) {
return Center(
child: Padding(
padding: const EdgeInsets.all(38.0),
child: FadeInImage(
image: NetworkImage(
'https://flutter.dev/assets/images/shared/brand/flutter/logo/flutter-lockup.png'),
placeholder: AssetImage('assets/spinner2.gif'),
),
),
);
}
}
Thanks,Srikanth