add
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class AuthInterceptor extends Interceptor{
|
||||
@override
|
||||
void onRequest(RequestOptions options, RequestInterceptorHandler handler) {
|
||||
// TODO: implement onRequest
|
||||
super.onRequest(options, handler);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
import 'package:app/core/network/auth_interceptor.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
|
||||
class Request {
|
||||
static final Request _instance = Request._internal();
|
||||
factory Request() => _instance;
|
||||
|
||||
late Dio dio;
|
||||
|
||||
Request._internal(){
|
||||
BaseOptions options = BaseOptions(
|
||||
baseUrl: "",
|
||||
responseType: ResponseType.json,
|
||||
contentType: 'application/json; charset=utf-8',
|
||||
);
|
||||
dio = Dio(options);
|
||||
dio.interceptors.addAll([
|
||||
AuthInterceptor()
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,7 @@
|
||||
|
||||
|
||||
import 'package:app/features/auth/pages/login_page.dart';
|
||||
import 'package:app/features/auth/pages/register_page.dart';
|
||||
import 'package:app/features/home/pages/index_page.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
|
||||
@@ -10,6 +11,7 @@ final appRouter = GoRouter(
|
||||
initialLocation: '/auth/login',
|
||||
routes: [
|
||||
GoRoute(path: '/auth/login', builder: (context, state) => const LoginPage()),
|
||||
GoRoute(path: '/auth/register', builder: (context, state) => const RegisterPage()),
|
||||
ShellRoute(
|
||||
builder: (context, state, child) {
|
||||
return MainPage(child: child);
|
||||
|
||||
Reference in New Issue
Block a user