Application propre sans erreurs. Bonne base sur laquelle repartir de zero en cas de soucis majeurs.

This commit is contained in:
DahoudG
2024-08-26 22:45:58 +00:00
parent bcf714ab73
commit eb8368b1ee
24 changed files with 397 additions and 201 deletions

View File

@@ -0,0 +1,6 @@
class Urls {
static const String baseUrl = 'http://localhost:8085';
// static const String login = baseUrl + 'auth/login';
// static const String events = baseUrl + 'events';
// Ajoute d'autres URLs ici
}

View File

@@ -0,0 +1,3 @@
class ServerException implements Exception {}
class CacheException implements Exception {}

View File

@@ -0,0 +1,9 @@
import 'package:equatable/equatable.dart';
abstract class Failure extends Equatable {
@override
List<Object> get props => [];
}
class ServerFailure extends Failure {}
class CacheFailure extends Failure {}

View File

@@ -0,0 +1,20 @@
import 'package:flutter/material.dart';
class AppTheme {
static final ThemeData lightTheme = ThemeData(
primaryColor: Colors.blue,
colorScheme: const ColorScheme.light(
secondary: Colors.orange,
),
brightness: Brightness.light,
buttonTheme: const ButtonThemeData(buttonColor: Colors.blue),
);
static final ThemeData darkTheme = ThemeData(
primaryColor: Colors.black,
colorScheme: const ColorScheme.dark(
secondary: Colors.red,
),
brightness: Brightness.dark,
);
}

View File

@@ -0,0 +1,16 @@
import 'package:dartz/dartz.dart';
import 'package:afterwork/core/errors/failures.dart';
class InputConverter {
Either<Failure, int> stringToUnsignedInteger(String str) {
try {
final integer = int.parse(str);
if (integer < 0) throw const FormatException();
return Right(integer);
} catch (e) {
return Left(InvalidInputFailure());
}
}
}
class InvalidInputFailure extends Failure {}