Files
social-app/apps/lib/main.dart
T
qzl 8539f05a66 feat: 增强 HomeScreen 录音交互与 ChatBloc 状态管理
- 新增录音启动延迟处理,解决权限未就绪时的竞态问题
- 实现历史分页滚动位置保持,提升加载体验
- 添加文本输入框点击键盘显示与焦点管理
- 优化 ChatBloc provider 到 MultiBlocProvider 支持
- 修复 ApiException 429 错误详情解析(支持 JSON 字符串 body)
- 改进 LocalNotificationService 精确闹钟权限请求
- 优化 UiSchemaRenderer GridView children 生成
- 支持导航 action 的 replace 参数
- 移除 Agent router 速率限制逻辑(_allow_run_request, _allow_transcribe_request)
- 补充相关单元测试与集成测试
2026-03-18 17:03:22 +08:00

69 lines
2.0 KiB
Dart

import 'dart:async';
import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'core/constants/app_constants.dart';
import 'core/di/injection.dart';
import 'core/notifications/local_notification_service.dart';
import 'core/router/app_router.dart';
import 'core/startup/auth_session_bootstrapper.dart';
import 'core/theme/app_theme.dart';
import 'features/auth/presentation/bloc/auth_bloc.dart';
import 'features/auth/presentation/bloc/auth_event.dart';
import 'features/auth/presentation/bloc/auth_state.dart';
import 'features/calendar/data/services/calendar_service.dart';
import 'features/chat/presentation/bloc/chat_bloc.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await configureDependencies();
await AppConstants.init();
final authBloc = sl<AuthBloc>();
authBloc.add(AuthStarted());
runApp(
LinksyApp(
authBloc: authBloc,
sessionBootstrapper: AuthSessionBootstrapper(
calendarService: sl<CalendarService>(),
notificationService: sl<LocalNotificationService>(),
),
),
);
}
class LinksyApp extends StatelessWidget {
final AuthBloc authBloc;
final AuthSessionBootstrapper sessionBootstrapper;
const LinksyApp({
super.key,
required this.authBloc,
required this.sessionBootstrapper,
});
@override
Widget build(BuildContext context) {
return MultiBlocProvider(
providers: [
BlocProvider<AuthBloc>.value(value: authBloc),
BlocProvider<ChatBloc>(create: (_) => ChatBloc(apiClient: sl())),
],
child: BlocListener<AuthBloc, AuthState>(
listenWhen: (previous, current) => previous != current,
listener: (context, state) {
unawaited(sessionBootstrapper.syncForAuthState(state));
},
child: MaterialApp.router(
title: 'Linksy',
debugShowCheckedModeBanner: false,
theme: AppTheme.light,
routerConfig: createAppRouter(authBloc),
),
),
);
}
}