base project
This commit is contained in:
@@ -0,0 +1,239 @@
|
||||
// ignore: depend_on_referenced_packages
|
||||
import 'package:awesome_dio_interceptor/awesome_dio_interceptor.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../env.dart';
|
||||
import 'api_failure.dart';
|
||||
import 'errors/bad_network_error.dart';
|
||||
import 'errors/bad_request_error.dart';
|
||||
import 'errors/connection_timeout_error.dart';
|
||||
import 'errors/internal_server_error.dart';
|
||||
import 'errors/not_found_error.dart';
|
||||
import 'errors/unauthorized_error.dart';
|
||||
import 'interceptors/bad_network_interceptor.dart';
|
||||
import 'interceptors/bad_request_interceptor.dart';
|
||||
import 'interceptors/connection_timeout_interceptor.dart';
|
||||
import 'interceptors/internal_server_interceptor.dart';
|
||||
import 'interceptors/not_found_interceptor.dart';
|
||||
import 'interceptors/unauthorized_interceptor.dart';
|
||||
|
||||
@lazySingleton
|
||||
class ApiClient {
|
||||
final Dio _dio;
|
||||
final Env _env;
|
||||
|
||||
ApiClient(this._dio, this._env) {
|
||||
_dio.options.baseUrl = _env.baseUrl;
|
||||
_dio.options.connectTimeout = const Duration(seconds: 20);
|
||||
_dio.interceptors.add(BadNetworkErrorInterceptor());
|
||||
_dio.interceptors.add(BadRequestErrorInterceptor());
|
||||
_dio.interceptors.add(InternalServerErrorInterceptor());
|
||||
_dio.interceptors.add(NotFoundErrorInterceptor());
|
||||
_dio.interceptors.add(UnauthorizedInterceptor());
|
||||
_dio.interceptors.add(ConnectionTimeoutErrorInterceptor());
|
||||
|
||||
if (kDebugMode) {
|
||||
_dio.interceptors.add(
|
||||
AwesomeDioInterceptor(
|
||||
logResponseHeaders: false,
|
||||
logRequestTimeout: false,
|
||||
logRequestHeaders: true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> post(
|
||||
String path, {
|
||||
dynamic data,
|
||||
Map<String, dynamic>? headers,
|
||||
Map<String, dynamic>? params,
|
||||
bool followRedirects = true,
|
||||
bool Function(int?)? validateStatus,
|
||||
String? contentType,
|
||||
}) async {
|
||||
try {
|
||||
return await _dio.post(
|
||||
path,
|
||||
data: data,
|
||||
options: Options(
|
||||
headers: headers,
|
||||
followRedirects: followRedirects,
|
||||
validateStatus: validateStatus,
|
||||
contentType: contentType,
|
||||
),
|
||||
queryParameters: params,
|
||||
);
|
||||
} on UnauthorizedError catch (e) {
|
||||
throw ApiFailure.unauthorized(e.messageError);
|
||||
} on InternalServerError {
|
||||
throw const ApiFailure.internalServerError();
|
||||
} on BadNetworkError {
|
||||
throw const ApiFailure.connectionError();
|
||||
} on BadRequestError catch (e) {
|
||||
throw ApiFailure.badRequest(e.messageError);
|
||||
} on NotFoundError catch (e) {
|
||||
throw ApiFailure.notFound(e.messageError);
|
||||
} on ConnectionTimeoutError {
|
||||
throw const ApiFailure.connectionTimeout();
|
||||
} on DioException catch (e) {
|
||||
var errorMessage =
|
||||
e.response?.data['message'] ?? e.response?.statusMessage ?? e.error;
|
||||
|
||||
if (errorMessage.toString().contains('Connection reset')) {
|
||||
errorMessage = 'Connection reset';
|
||||
}
|
||||
|
||||
throw ApiFailure.serverError(
|
||||
statusCode: e.response?.statusCode ?? 0,
|
||||
errorMessage: errorMessage.toString(),
|
||||
);
|
||||
} catch (e, s) {
|
||||
throw ApiFailure.unexpectedError(errorMessage: e, stackTrace: s);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> get(
|
||||
String path, {
|
||||
Map<String, dynamic>? headers,
|
||||
Map<String, dynamic>? params,
|
||||
bool followRedirects = true,
|
||||
bool Function(int?)? validateStatus,
|
||||
String? contentType,
|
||||
}) async {
|
||||
try {
|
||||
return await _dio.get(
|
||||
path,
|
||||
options: Options(
|
||||
headers: headers,
|
||||
followRedirects: followRedirects,
|
||||
validateStatus: validateStatus,
|
||||
contentType: contentType,
|
||||
),
|
||||
queryParameters: params,
|
||||
);
|
||||
} on UnauthorizedError catch (e) {
|
||||
throw ApiFailure.unauthorized(e.messageError);
|
||||
} on InternalServerError {
|
||||
throw const ApiFailure.internalServerError();
|
||||
} on BadNetworkError {
|
||||
throw const ApiFailure.connectionError();
|
||||
} on BadRequestError catch (e) {
|
||||
throw ApiFailure.badRequest(e.messageError);
|
||||
} on NotFoundError catch (e) {
|
||||
throw ApiFailure.notFound(e.messageError);
|
||||
} on ConnectionTimeoutError {
|
||||
throw const ApiFailure.connectionTimeout();
|
||||
} on DioException catch (e) {
|
||||
var errorMessage =
|
||||
e.response?.data['message'] ?? e.response?.statusMessage ?? e.error;
|
||||
|
||||
if (errorMessage.toString().contains('Connection reset')) {
|
||||
errorMessage = 'Connection reset';
|
||||
}
|
||||
|
||||
throw ApiFailure.serverError(
|
||||
statusCode: e.response?.statusCode ?? 0,
|
||||
errorMessage: errorMessage.toString(),
|
||||
);
|
||||
} catch (e, s) {
|
||||
throw ApiFailure.unexpectedError(errorMessage: e, stackTrace: s);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> put(
|
||||
String path, {
|
||||
dynamic data,
|
||||
Map<String, dynamic>? headers,
|
||||
Map<String, dynamic>? params,
|
||||
bool followRedirects = true,
|
||||
bool Function(int?)? validateStatus,
|
||||
String? contentType,
|
||||
void Function(int count, int total)? onSendProgress,
|
||||
}) async {
|
||||
try {
|
||||
return await _dio.put(
|
||||
path,
|
||||
data: data,
|
||||
options: Options(
|
||||
headers: headers,
|
||||
followRedirects: followRedirects,
|
||||
validateStatus: validateStatus,
|
||||
contentType: contentType,
|
||||
),
|
||||
queryParameters: params,
|
||||
onSendProgress: onSendProgress,
|
||||
);
|
||||
} on UnauthorizedError catch (e) {
|
||||
throw ApiFailure.unauthorized(e.messageError);
|
||||
} on InternalServerError {
|
||||
throw const ApiFailure.internalServerError();
|
||||
} on BadNetworkError {
|
||||
throw const ApiFailure.connectionError();
|
||||
} on BadRequestError catch (e) {
|
||||
throw ApiFailure.badRequest(e.messageError);
|
||||
} on NotFoundError catch (e) {
|
||||
throw ApiFailure.notFound(e.messageError);
|
||||
} on ConnectionTimeoutError {
|
||||
throw const ApiFailure.connectionTimeout();
|
||||
} on DioException catch (e) {
|
||||
var errorMessage =
|
||||
e.response?.data['message'] ?? e.response?.statusMessage ?? e.error;
|
||||
|
||||
if (errorMessage.toString().contains('Connection reset')) {
|
||||
errorMessage = 'Connection reset';
|
||||
}
|
||||
|
||||
throw ApiFailure.serverError(
|
||||
statusCode: e.response?.statusCode ?? 0,
|
||||
errorMessage: errorMessage.toString(),
|
||||
);
|
||||
} catch (e, s) {
|
||||
throw ApiFailure.unexpectedError(errorMessage: e, stackTrace: s);
|
||||
}
|
||||
}
|
||||
|
||||
Future<Response> delete(
|
||||
String path, {
|
||||
dynamic data,
|
||||
Map<String, dynamic>? headers,
|
||||
Map<String, dynamic>? params,
|
||||
bool followRedirects = true,
|
||||
bool Function(int?)? validateStatus,
|
||||
String? contentType,
|
||||
}) async {
|
||||
try {
|
||||
return await _dio.delete(
|
||||
path,
|
||||
data: data,
|
||||
options: Options(
|
||||
headers: headers,
|
||||
followRedirects: followRedirects,
|
||||
validateStatus: validateStatus,
|
||||
contentType: contentType,
|
||||
),
|
||||
queryParameters: params,
|
||||
);
|
||||
} on UnauthorizedError catch (e) {
|
||||
throw ApiFailure.unauthorized(e.messageError);
|
||||
} on InternalServerError {
|
||||
throw const ApiFailure.internalServerError();
|
||||
} on BadNetworkError {
|
||||
throw const ApiFailure.connectionError();
|
||||
} on BadRequestError catch (e) {
|
||||
throw ApiFailure.badRequest(e.messageError);
|
||||
} on NotFoundError catch (e) {
|
||||
throw ApiFailure.notFound(e.messageError);
|
||||
} on DioException catch (e) {
|
||||
throw ApiFailure.serverError(
|
||||
statusCode: e.response?.statusCode ?? 0,
|
||||
errorMessage:
|
||||
e.response?.data['message'] ?? e.response?.statusMessage ?? e.error,
|
||||
);
|
||||
} catch (e, s) {
|
||||
throw ApiFailure.unexpectedError(errorMessage: e, stackTrace: s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
|
||||
part 'api_failure.freezed.dart';
|
||||
|
||||
@freezed
|
||||
sealed class ApiFailure with _$ApiFailure {
|
||||
const ApiFailure._();
|
||||
|
||||
const factory ApiFailure.serverError({
|
||||
required int statusCode,
|
||||
required Object errorMessage,
|
||||
}) = _ServerError;
|
||||
|
||||
const factory ApiFailure.unexpectedError({
|
||||
required Object errorMessage,
|
||||
required StackTrace stackTrace,
|
||||
}) = _UnexpectedError;
|
||||
|
||||
const factory ApiFailure.connectionError() = _ConnectionError;
|
||||
|
||||
const factory ApiFailure.internalServerError() = _InternalServerError;
|
||||
|
||||
const factory ApiFailure.unauthorized(String? message) = _Unauthorized;
|
||||
|
||||
const factory ApiFailure.badRequest(String? message) = _BadRequest;
|
||||
|
||||
const factory ApiFailure.notFound(String? message) = _NotFound;
|
||||
|
||||
const factory ApiFailure.connectionTimeout() = _ConnectionTimeout;
|
||||
|
||||
String toStringFormatted(
|
||||
BuildContext context, {
|
||||
String? unauthorizedMessage,
|
||||
}) {
|
||||
return switch (this) {
|
||||
_ServerError(:final statusCode, :final errorMessage) =>
|
||||
'There is a problem with the server. Status code: $statusCode Error: $errorMessage',
|
||||
|
||||
_UnexpectedError() => 'An error occurred. Please try again later.',
|
||||
|
||||
_ConnectionError() => 'No Internet',
|
||||
|
||||
_InternalServerError() =>
|
||||
'The server is experiencing problems. Please try again later.',
|
||||
|
||||
_Unauthorized(:final message) =>
|
||||
message ?? unauthorizedMessage ?? 'Session has expired.',
|
||||
|
||||
_BadRequest(:final message) =>
|
||||
message ?? 'There is an incorrect entry. Please check again',
|
||||
|
||||
_NotFound(:final message) => message ?? 'Not Found',
|
||||
|
||||
_ConnectionTimeout() => 'Connection Timeout',
|
||||
};
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class BadNetworkError extends DioException {
|
||||
final DioException dioError;
|
||||
|
||||
BadNetworkError(this.dioError)
|
||||
: super(
|
||||
requestOptions: dioError.requestOptions,
|
||||
error: dioError.error,
|
||||
response: dioError.response,
|
||||
type: dioError.type,
|
||||
message: dioError.message,
|
||||
stackTrace: dioError.stackTrace,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class BadRequestError extends DioException {
|
||||
final DioException dioError;
|
||||
final String? messageError;
|
||||
|
||||
BadRequestError(this.dioError, this.messageError)
|
||||
: super(
|
||||
error: dioError.error,
|
||||
requestOptions: dioError.requestOptions,
|
||||
response: dioError.response,
|
||||
type: dioError.type,
|
||||
message: dioError.message,
|
||||
stackTrace: dioError.stackTrace,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class ConnectionTimeoutError extends DioException {
|
||||
final DioException dioError;
|
||||
|
||||
ConnectionTimeoutError(this.dioError)
|
||||
: super(
|
||||
error: dioError.error,
|
||||
requestOptions: dioError.requestOptions,
|
||||
response: dioError.response,
|
||||
type: dioError.type,
|
||||
message: dioError.message,
|
||||
stackTrace: dioError.stackTrace,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class InternalServerError extends DioException {
|
||||
final DioException dioError;
|
||||
|
||||
InternalServerError(this.dioError)
|
||||
: super(
|
||||
requestOptions: dioError.requestOptions,
|
||||
error: dioError.error,
|
||||
response: dioError.response,
|
||||
type: dioError.type,
|
||||
message: dioError.message,
|
||||
stackTrace: dioError.stackTrace,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class NotFoundError extends DioException {
|
||||
final DioException dioError;
|
||||
final String? messageError;
|
||||
|
||||
NotFoundError(this.dioError, this.messageError)
|
||||
: super(
|
||||
error: dioError.error,
|
||||
requestOptions: dioError.requestOptions,
|
||||
response: dioError.response,
|
||||
type: dioError.type,
|
||||
message: dioError.message,
|
||||
stackTrace: dioError.stackTrace,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class UnauthorizedError extends DioException {
|
||||
final DioException dioError;
|
||||
final String? messageError;
|
||||
|
||||
UnauthorizedError(this.dioError, this.messageError)
|
||||
: super(
|
||||
requestOptions: dioError.requestOptions,
|
||||
error: dioError.error,
|
||||
response: dioError.response,
|
||||
type: dioError.type,
|
||||
message: dioError.message,
|
||||
stackTrace: dioError.stackTrace,
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../../../injection.dart';
|
||||
import '../../network/network_client.dart';
|
||||
import '../errors/bad_network_error.dart';
|
||||
|
||||
class BadNetworkErrorInterceptor extends Interceptor {
|
||||
final _networkClient = getIt<NetworkClient>();
|
||||
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) async {
|
||||
final isConnected = await _networkClient.isConnected;
|
||||
|
||||
if (err.type == DioExceptionType.connectionTimeout ||
|
||||
!isConnected ||
|
||||
err.type == DioExceptionType.receiveTimeout ||
|
||||
err.type == DioExceptionType.connectionError) {
|
||||
return super.onError(BadNetworkError(err), handler);
|
||||
}
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../errors/bad_request_error.dart';
|
||||
|
||||
class BadRequestErrorInterceptor extends Interceptor {
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
if (err.response?.statusCode == 422 ||
|
||||
err.response?.statusCode == 400 ||
|
||||
err.response?.statusCode == 405) {
|
||||
return super.onError(BadRequestError(err, null), handler);
|
||||
}
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../errors/connection_timeout_error.dart';
|
||||
|
||||
class ConnectionTimeoutErrorInterceptor extends Interceptor {
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
if (err.type == DioExceptionType.connectionTimeout) {
|
||||
return super.onError(ConnectionTimeoutError(err), handler);
|
||||
}
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../errors/internal_server_error.dart';
|
||||
|
||||
class InternalServerErrorInterceptor extends Interceptor {
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
if (err.response != null) {
|
||||
if (err.response?.statusCode != null &&
|
||||
err.response!.statusCode! >= 500 &&
|
||||
err.response!.statusCode! < 600) {
|
||||
return super.onError(InternalServerError(err), handler);
|
||||
}
|
||||
}
|
||||
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../errors/not_found_error.dart';
|
||||
|
||||
class NotFoundErrorInterceptor extends Interceptor {
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
if (err.response?.statusCode == 404) {
|
||||
return super.onError(NotFoundError(err, null), handler);
|
||||
}
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
import '../errors/unauthorized_error.dart';
|
||||
|
||||
class UnauthorizedInterceptor extends Interceptor {
|
||||
@override
|
||||
void onError(DioException err, ErrorInterceptorHandler handler) {
|
||||
if (err.response?.statusCode == 401 ||
|
||||
err.response?.statusCode == 403 ||
|
||||
err.response?.statusCode == 419) {
|
||||
return super.onError(UnauthorizedError(err, null), handler);
|
||||
}
|
||||
super.onError(err, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// TODO: define your code
|
||||
@@ -0,0 +1,3 @@
|
||||
class AppConstant {
|
||||
static const String appName = "";
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
import '../../presentation/router/app_router.dart';
|
||||
|
||||
@module
|
||||
abstract class AutoRouteDi {
|
||||
@lazySingleton
|
||||
AppRouter get appRouter => AppRouter();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
@module
|
||||
abstract class ConnectivityDi {
|
||||
@lazySingleton
|
||||
Connectivity get connectivity => Connectivity();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
@module
|
||||
abstract class DioDi {
|
||||
@lazySingleton
|
||||
Dio get dio => Dio();
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:injectable/injectable.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
@module
|
||||
abstract class SharedPreferencesDi {
|
||||
@preResolve
|
||||
Future<SharedPreferences> get prefs => SharedPreferences.getInstance();
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
// TODO: define your code
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
void dismissKeyboard(BuildContext context) {
|
||||
final currentFocus = FocusScope.of(context);
|
||||
if (!currentFocus.hasPrimaryFocus && currentFocus.focusedChild != null) {
|
||||
FocusManager.instance.primaryFocus?.unfocus();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import 'package:connectivity_plus/connectivity_plus.dart';
|
||||
import 'package:injectable/injectable.dart';
|
||||
|
||||
@lazySingleton
|
||||
class NetworkClient extends NetworkInfoBase {
|
||||
final Connectivity connectivity;
|
||||
|
||||
NetworkClient(this.connectivity);
|
||||
|
||||
@override
|
||||
Future<bool> get isConnected async {
|
||||
final result = await connectivity.checkConnectivity();
|
||||
return result.first != ConnectivityResult.none;
|
||||
}
|
||||
}
|
||||
|
||||
abstract class NetworkInfoBase {
|
||||
Future<bool> get isConnected;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
part of 'theme.dart';
|
||||
|
||||
class AppColor {
|
||||
// Primary Colors (Merah)
|
||||
static const Color primary = Color(0xFFD90000); // #d90000
|
||||
static const Color primaryLight = Color(0xFFFF4D4D); // merah terang
|
||||
static const Color primaryDark = Color(0xFF990000); // merah gelap
|
||||
|
||||
// Secondary Colors (biar tetap harmonis → hijau dipertahankan)
|
||||
static const Color secondary = Color(0xFF4CAF50);
|
||||
static const Color secondaryLight = Color(0xFF81C784);
|
||||
static const Color secondaryDark = Color(0xFF388E3C);
|
||||
|
||||
// Background Colors
|
||||
static const Color background = Color(0xFFF8F9FA);
|
||||
static const Color backgroundLight = Color(0xFFFFFFFF);
|
||||
static const Color backgroundDark = Color(0xFF1A1A1A);
|
||||
static const Color surface = Color(0xFFFFFFFF);
|
||||
static const Color surfaceDark = Color(0xFF2D2D2D);
|
||||
|
||||
// Text Colors
|
||||
static const Color textPrimary = Color(0xFF212121);
|
||||
static const Color textSecondary = Color(0xFF757575);
|
||||
static const Color textLight = Color(0xFFBDBDBD);
|
||||
static const Color textWhite = Color(0xFFFFFFFF);
|
||||
|
||||
// Status Colors
|
||||
static const Color success = Color(0xFF4CAF50);
|
||||
static const Color error = Color(0xFFE53E3E);
|
||||
static const Color warning = Color(0xFFFF9800);
|
||||
static const Color info = Color(0xFF2196F3);
|
||||
|
||||
// Border Colors
|
||||
static const Color border = Color(0xFFE0E0E0);
|
||||
static const Color borderLight = Color(0xFFF0F0F0);
|
||||
static const Color borderDark = Color(0xFFBDBDBD);
|
||||
|
||||
// Basic Color
|
||||
static const Color white = Color(0xFFFFFFFF);
|
||||
static const Color black = Color(0xFF000000);
|
||||
|
||||
// Gradient Colors
|
||||
static const List<Color> primaryGradient = [
|
||||
Color(0xFFD90000), // primary
|
||||
Color(0xFF990000), // dark red
|
||||
];
|
||||
|
||||
static const List<Color> successGradient = [
|
||||
Color(0xFF4CAF50),
|
||||
Color(0xFF81C784),
|
||||
];
|
||||
|
||||
static const List<Color> backgroundGradient = [
|
||||
Color(0xFFF5F5F5),
|
||||
Color(0xFFE8E8E8),
|
||||
];
|
||||
|
||||
// Opacity Variations
|
||||
static Color primaryWithOpacity(double opacity) =>
|
||||
primary.withOpacity(opacity);
|
||||
static Color successWithOpacity(double opacity) =>
|
||||
success.withOpacity(opacity);
|
||||
static Color errorWithOpacity(double opacity) => error.withOpacity(opacity);
|
||||
static Color warningWithOpacity(double opacity) =>
|
||||
warning.withOpacity(opacity);
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
part of 'theme.dart';
|
||||
|
||||
class AppStyle {
|
||||
static TextStyle xs = TextStyle(color: AppColor.textPrimary, fontSize: 11);
|
||||
|
||||
static TextStyle sm = TextStyle(color: AppColor.textPrimary, fontSize: 12);
|
||||
|
||||
static TextStyle md = TextStyle(color: AppColor.textPrimary, fontSize: 14);
|
||||
|
||||
static TextStyle lg = TextStyle(color: AppColor.textPrimary, fontSize: 16);
|
||||
|
||||
static TextStyle xl = TextStyle(color: AppColor.textPrimary, fontSize: 18);
|
||||
|
||||
static TextStyle xxl = TextStyle(color: AppColor.textPrimary, fontSize: 20);
|
||||
|
||||
static TextStyle h6 = TextStyle(color: AppColor.textPrimary, fontSize: 22);
|
||||
|
||||
static TextStyle h5 = TextStyle(color: AppColor.textPrimary, fontSize: 24);
|
||||
|
||||
static TextStyle h4 = TextStyle(color: AppColor.textPrimary, fontSize: 26);
|
||||
|
||||
static TextStyle h3 = TextStyle(color: AppColor.textPrimary, fontSize: 28);
|
||||
|
||||
static TextStyle h2 = TextStyle(color: AppColor.textPrimary, fontSize: 30);
|
||||
|
||||
static TextStyle h1 = TextStyle(color: AppColor.textPrimary, fontSize: 32);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
part of 'theme.dart';
|
||||
|
||||
class AppValue {}
|
||||
@@ -0,0 +1,11 @@
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
part 'app_color.dart';
|
||||
part 'app_style.dart';
|
||||
part 'app_value.dart';
|
||||
|
||||
class ThemeApp {
|
||||
static ThemeData get theme => ThemeData(
|
||||
useMaterial3: true,
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user