Initial commit
This commit is contained in:
73
lib/core/functions/base_finctions.dart
Normal file
73
lib/core/functions/base_finctions.dart
Normal file
@@ -0,0 +1,73 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import '../../router/app_routes.dart';
|
||||
import '../entity/name/name_entity.dart';
|
||||
import '../models/name.dart';
|
||||
|
||||
class Functions {
|
||||
static String getTranslatedItem(NameEntity? name, BuildContext context) {
|
||||
var local = Localizations.localeOf(context);
|
||||
switch (local.languageCode) {
|
||||
case 'uz':
|
||||
{
|
||||
return name?.uz ?? " ";
|
||||
}
|
||||
case "ru":
|
||||
{
|
||||
return name?.ru ?? " ";
|
||||
}
|
||||
case "zh":
|
||||
{
|
||||
return name?.zh ?? " ";
|
||||
}
|
||||
default:
|
||||
{
|
||||
return name?.uz ?? " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static String getTranslatedNameModel(Name? name, BuildContext context) {
|
||||
var local = Localizations.localeOf(context);
|
||||
switch (local.languageCode) {
|
||||
case 'uz':
|
||||
{
|
||||
return name?.uz ?? " ";
|
||||
}
|
||||
case "ru":
|
||||
{
|
||||
return name?.ru ?? " ";
|
||||
}
|
||||
case "zh":
|
||||
{
|
||||
return name?.zh ?? " ";
|
||||
}
|
||||
default:
|
||||
{
|
||||
return name?.uz ?? " ";
|
||||
}
|
||||
}
|
||||
}
|
||||
static void showErrorSnackBar(String message) {
|
||||
final snackBar = SnackBar(
|
||||
backgroundColor: Colors.red,
|
||||
content: Row(
|
||||
children: [
|
||||
const Icon(Icons.error, color: Colors.white),
|
||||
const SizedBox(width: 8),
|
||||
Expanded(
|
||||
child: Text(
|
||||
message,
|
||||
style: const TextStyle(color: Colors.white),
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
behavior: SnackBarBehavior.floating,
|
||||
duration: const Duration(seconds: 3),
|
||||
);
|
||||
|
||||
ScaffoldMessenger.of(
|
||||
rootNavigatorKey.currentContext!,
|
||||
).showSnackBar(snackBar);
|
||||
}
|
||||
}
|
||||
13
lib/core/functions/debouncer.dart
Normal file
13
lib/core/functions/debouncer.dart
Normal file
@@ -0,0 +1,13 @@
|
||||
import 'dart:async';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
|
||||
class Debouncer {
|
||||
static Timer? _timer;
|
||||
|
||||
static run(VoidCallback action) {
|
||||
if (null != _timer) {
|
||||
_timer?.cancel();
|
||||
}
|
||||
_timer = Timer(const Duration(milliseconds: 600), action);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user