26 lines
545 B
Dart
26 lines
545 B
Dart
import 'dart:async';
|
|
import 'dart:io' show Platform;
|
|
|
|
import 'package:flutter/material.dart';
|
|
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
|
|
|
class Debouncer {
|
|
final int milliseconds;
|
|
Timer? _timer;
|
|
|
|
Debouncer({required this.milliseconds});
|
|
|
|
void run(VoidCallback action) {
|
|
_timer?.cancel();
|
|
_timer = Timer(Duration(milliseconds: milliseconds), action);
|
|
}
|
|
|
|
void dispose() {
|
|
_timer?.cancel();
|
|
}
|
|
}
|
|
|
|
String getGooglePlacesApiKey() {
|
|
return dotenv.env['GMS_API_KEY'] ?? Platform.environment['GMS_API_KEY'] ?? "";
|
|
}
|