37 lines
954 B
Dart
37 lines
954 B
Dart
import 'package:flutter/material.dart';
|
|
|
|
class LoadingOverlay {
|
|
static final ValueNotifier<bool> _isLoading = ValueNotifier<bool>(false);
|
|
|
|
static void show() {
|
|
_isLoading.value = true;
|
|
}
|
|
|
|
static void hide() {
|
|
_isLoading.value = false;
|
|
}
|
|
|
|
static Widget buildLoader() {
|
|
return ValueListenableBuilder<bool>(
|
|
valueListenable: _isLoading,
|
|
builder: (context, isLoading, child) {
|
|
return isLoading
|
|
? Stack(
|
|
children: [
|
|
ModalBarrier(
|
|
color: Colors.black.withOpacity(0.5), dismissible: false),
|
|
Center(
|
|
child: Image.asset(
|
|
"assets/FCSC-GIF.gif", // Make sure to add the GIF in assets
|
|
width: 100,
|
|
height: 100,
|
|
),
|
|
),
|
|
],
|
|
)
|
|
: const SizedBox.shrink();
|
|
},
|
|
);
|
|
}
|
|
}
|