Flutter custom widget for a loading indicator
Create a dart file with the following code, my_custom_loading_indicator.dart
import 'package:flutter/material.dart';
class MyCustomLoadingIndicator extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const Scaffold(
body: Center(
child: CircularProgressIndicator(
valueColor: AlwaysStoppedAnimation(Colors.blue),
),
),
backgroundColor: Colors.white,
);
}
}
Import and use the custom loading indicator.
import 'my_custom_loading_indicator.dart';
// Other code...
@override
Widget build(BuildContext context) {
final _asyncSnapshotData = widget.data;
return Scaffold(
appBar: AppBar(
title: const Text('Hello World'),
),
body: _asyncSnapshotData.hasData ?
MyDataList(_asyncSnapshotData.data!)
:
MyCustomLoadingIndicator()
);
}
// Other code...
Search within Codexpedia
Custom Search
Search the entire web
Custom Search
Related Posts