step 3 : hapus ai_barcode_scanner, ai barcode, update permission_handler, flutter_map,latlong2
This commit is contained in:
70
lib/screen/kurir_konfirmasi_screen/kurir_tolak_provider.dart
Normal file
70
lib/screen/kurir_konfirmasi_screen/kurir_tolak_provider.dart
Normal file
@@ -0,0 +1,70 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:equatable/equatable.dart';
|
||||
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
||||
import '../../repository/base_repository.dart';
|
||||
|
||||
import '../../provider/dio_provider.dart';
|
||||
import '../../repository/kurir_tolak_repository.dart';
|
||||
|
||||
//provider
|
||||
final kurirTolakProvider =
|
||||
StateNotifierProvider<KurirTolakNotifier, KurirTolakState>(
|
||||
(ref) => KurirTolakNotifier(ref: ref));
|
||||
|
||||
// notifier
|
||||
class KurirTolakNotifier extends StateNotifier<KurirTolakState> {
|
||||
final Ref ref;
|
||||
KurirTolakNotifier({
|
||||
required this.ref,
|
||||
}) : super(KurirTolakStateInit());
|
||||
|
||||
void tolakKurir(
|
||||
{required String id,
|
||||
required String tipeId,
|
||||
required String deliveryId,
|
||||
required String note}) async {
|
||||
try {
|
||||
state = KurirTolakStateLoading();
|
||||
final dio = ref.read(dioProvider);
|
||||
final resp = await KurirTolakRepository(dio: dio).getKurirTolak(
|
||||
id: id, tipeId: tipeId, deliveryId: deliveryId, note: note);
|
||||
state = KurirTolakStateDone(model: resp);
|
||||
} catch (e) {
|
||||
if (e is BaseRepositoryException) {
|
||||
state = KurirTolakStateError(message: e.message.toString());
|
||||
} else {
|
||||
state = KurirTolakStateError(message: e.toString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
abstract class KurirTolakState extends Equatable {
|
||||
final DateTime date;
|
||||
const KurirTolakState(this.date);
|
||||
@override
|
||||
List<Object?> get props => [date];
|
||||
}
|
||||
|
||||
class KurirTolakStateInit extends KurirTolakState {
|
||||
KurirTolakStateInit() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class KurirTolakStateLoading extends KurirTolakState {
|
||||
KurirTolakStateLoading() : super(DateTime.now());
|
||||
}
|
||||
|
||||
class KurirTolakStateError extends KurirTolakState {
|
||||
final String message;
|
||||
KurirTolakStateError({
|
||||
required this.message,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
|
||||
class KurirTolakStateDone extends KurirTolakState {
|
||||
final bool model;
|
||||
KurirTolakStateDone({
|
||||
required this.model,
|
||||
}) : super(DateTime.now());
|
||||
}
|
||||
Reference in New Issue
Block a user