추석 연휴가 끼어있어서 답변이 조금 늦었습니다
말씀하신 내용으로 아래와 같이 샘플 코드 작성해서 구현해봤는데요, 이슈가 재현되지 않고 정상적으로 동작하는 것을 확인했습니다.
조금 번거로우시더라도 샘플 프로젝트를 만들어서 kakao_flutter_sdk와 go_router 의 의존성만 추가해서 구현했을 때 이슈가 재현되는지 확인부탁드리고, 여전히 이슈가 발생한다면 구현하신 코드 첨부 부탁드리겠습니다.
참고로 제가 테스트한 환경은 kakao_flutter_sdk 1.9.5 버전, go_router 14.2.7 버전입니다.
main.dart
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';
import 'package:go_router_login_error/test.dart';
import 'package:kakao_flutter_sdk/kakao_flutter_sdk.dart';
void main() {
KakaoSdk.init(nativeAppKey: 'NATIVE_APP_KEY'); // 실제 앱 키 입력
runApp(MyApp());
}
class MyApp extends StatelessWidget {
final _router = GoRouter(
initialLocation: '/home',
routes: [
GoRoute(
path: '/home',
builder: (_, __) => const MyHomePage(title: 'Flutter Demo Home Page'),
routes: [GoRoute(path: 'test', builder: (_, __) => const TestPage())],
redirect: (BuildContext context, GoRouterState state) {
if (state.uri.scheme.toString() == 'https' ||
state.uri.scheme.toString() == 'applinks') {
print('deepLink O');
} else {
print('deepLink X');
}
print(state.uri.toString());
return null;
},
)
],
);
MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp.router(
routerConfig: _router,
title: 'Flutter Demo',
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key, required this.title});
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
backgroundColor: Theme.of(context).colorScheme.inversePrimary,
title: Text(widget.title),
),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'Home',
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
context.go("/home/test");
},
child: const Icon(Icons.add),
),
);
}
}
test.dart
import 'package:flutter/material.dart';
import 'package:kakao_flutter_sdk/kakao_flutter_sdk.dart';
class TestPage extends StatelessWidget {
const TestPage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text('Test Page')),
body: const Center(
child: Text('Test'),
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
try {
await UserApi.instance.loginWithKakaoTalk();
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Login Success')));
} catch (e) {
ScaffoldMessenger.of(context)
.showSnackBar(SnackBar(content: Text('Login Error: $e')));
}
},
child: const Icon(Icons.add),
),
);
}
}