mirror of
https://github.com/openfoodfacts/smooth-app.git
synced 2025-08-06 18:25:11 +08:00
22 lines
753 B
Dart
22 lines
753 B
Dart
import 'package:flutter/widgets.dart';
|
|
|
|
/// A [SliverChildBuilderDelegate] that can show progress by displaying
|
|
/// [loadingWidget]s.
|
|
///
|
|
/// When [loading] is `true`, [loadingCount] of [loadingWidget] will be
|
|
/// displayed.
|
|
class LoadingSliverChildBuilderDelegate extends SliverChildBuilderDelegate {
|
|
LoadingSliverChildBuilderDelegate({
|
|
required IndexedWidgetBuilder childBuilder,
|
|
required int childCount,
|
|
Widget? loadingWidget,
|
|
int loadingCount = 4,
|
|
bool loading = false,
|
|
}) : assert(loading == false || loadingWidget != null),
|
|
super(
|
|
(BuildContext context, int index) =>
|
|
loading ? loadingWidget : childBuilder(context, index),
|
|
childCount: loading ? loadingCount : childCount,
|
|
);
|
|
}
|