This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
This is a Flutter news app (news_app) that displays news, videos, activities, and topics. The app uses:
# Get dependencies
flutter pub get
# Run the app
flutter run
# Run on specific device (use `flutter devices` to list)
flutter run -d <device-id>
# Run on iOS simulator (auto-detect or use device-id)
flutter run -d ios
# Build APK (release)
flutter build apk --release
# Build APK with custom naming (uses build.py script)
python3 build.py
# Run tests
flutter test
# Analyze code
flutter analyze
# Generate code (for build_runner dependencies)
flutter pub run build_runner build --delete-conflicting-outputs
# Generate assets (for flutter_gen)
flutter pub run build_runner watch --delete-conflicting-outputs
lib/
├── main.dart # App entry point, router config, global providers
├── constant/ # Configuration constants (API endpoints, config)
├── http/ # HTTP layer (Dio wrapper, exception handling)
├── model/ # Data models (JSON parsing with fromJson/toJson)
├── provider/ # Riverpod providers (state management)
├── ui/ # UI pages (news, video, activity, topic, user, login, search)
├── util/ # Utilities (toast, cache, permissions, share, etc.)
├── widget/ # Reusable widgets
├── event/ # Event bus events (e.g., LogoutEvent)
├── extension/ # Dart extensions
└── gen/ # Generated assets (from flutter_gen)
The app uses Riverpod 2.x with Notifier and FamilyNotifier APIs (not deprecated StateNotifierProvider).
Common patterns:
Global Providers - defined in main.dart:
globalUserProvider - current user sessionglobalThemeProvider - theme mode (light/dark)grayProvider - grayscale mode toggleFeature Providers - located in lib/provider/, typically named [feature]_provider.dart:
Notifier<State> or FamilyNotifier<State, Arg>copyWith() methodNewsNotifier in news_provider.dartUsage in widgets:
// Read state
final state = ref.watch(newsProvider(index));
// Call provider methods
ref.read(newsProvider(index).notifier).fetchNewsItemList(1);
lib/http/http_util.dart wraps Dio for all API calls:
HttpUtil() instancelib/constant/api_const.dartget(), post(), put(), delete(), upload(), download()uuid header for authentication, shows error toastsdata['data'] or throws MyException on code != 200LogoutEvent via EventBusAPI endpoints are defined in lib/constant/api_const.dart.
Router configuration in lib/main.dart (_routerConfig):
GoRoute with path and builder/pageBuilderCustomTransitionPage with fade animationsstate.extra (not query params)/login, /main, /news/detail, /video/detailAll models in lib/model/ use JSON serialization:
fromJson(Map<String, dynamic> json) - parses from API responsetoJson() - serializes for API requests (if needed)Global EventBus in lib/constant/config.dart:
LogoutEvent)eventBus.fire(LogoutEvent(jumLogin: true))SharedPreferences (see lib/util/shared_prefs_instance_util.dart)uuid and Authorization-M headers in all requestsuuid variable in lib/constant/config.dartglobalUserProviderAll sizes use flutter_screenutil:
20.w, 30.h, 12.sp for width/height/font-sizeScreenUtilInitEasyRefresh for pull-to-refresh and load-morepageNum parameter, append results on pageNum > 1Controlled by grayProvider:
ColorFiltered with grayscale matrix when enabledenableProxy flag in lib/constant/config.dart (also controls packet capture proxy)Use generated assets from lib/gen/assets.gen.dart:
Image.asset(Assets.images.navNewsSelect.path)
The app includes video content using:
better_player_plus - Video player for streaming/local videosflutter_swiper_view - Carousel/swiper for banners and image listsUses fluwx package for WeChat-related features:
Current base URL: https://app.xhrbxxf.com/ (configured in lib/constant/api_const.dart)
Tests are minimal (test/widget_test.dart contains a basic template).
When adding tests, follow Flutter testing conventions and use flutter test to run.
enableProxy = true in lib/constant/config.dart192.168.3.21:9090 (hardcoded)