Local Development Setup
Relevant source files
The following files were used as context for generating this wiki page:
Local development for LuCI Mobile involves configuring a Flutter environment to build and test the application against OpenWrt routers. The project uses the Flutter SDK and depends on specific LuCI RPC modules on the target router to function.
Sources: CONTRIBUTING.md:14-23, README.md:104-111
Prerequisites
Before starting development, you must install the following software and SDKs:
- Flutter SDK: Version 3.8.1 or higher.
- Dart SDK: Included with the Flutter SDK.
- Git: Required for version control and cloning.
- IDE: VS Code, Android Studio, or IntelliJ IDEA with Flutter and Dart extensions installed.
- OpenWrt Router: An actual router or virtualized instance for functional testing.
Sources: CONTRIBUTING.md:27-32, pubspec.yaml:26-28, README.md:104-106
Initial Environment Setup
Follow these steps to prepare the local repository for development:
- Clone the Repository:
git clone https://github.com/cogwheel0/luci-mobile.git cd luci-mobile - Install Dependencies: Fetch the required packages defined in
pubspec.yaml.flutter pub get - Verify Configuration: Ensure the Dart analyzer and linter are active.
flutter analyze
Sources: CONTRIBUTING.md:36-41, CONTRIBUTING.md:52-54, README.md:107-111
Repository Structure and Tooling
The project uses several configuration files to manage the development environment:
| File | Purpose |
|---|---|
pubspec.yaml | Manages dependencies, versioning, and assets. |
analysis_options.yaml | Defines linting rules and static analysis settings. |
l10n.yaml | Configures localization and ARB file generation. |
devtools_options.yaml | Stores settings for Dart and Flutter DevTools. |
Sources: pubspec.yaml:1-5, analysis_options.yaml:1-10, l10n.yaml:1-5, devtools_options.yaml:1-2
Router Preparation
The application communicates with routers via LuCI RPC. You must install specific modules on the OpenWrt router for the app to retrieve network and wireless information.
Required Router Modules
Install the following packages on the router using opkg or apk:
rpcd-mod-lucirpcd-mod-iwinfo
After installation, restart the RPC daemon:
/etc/init.d/rpcd restart
Sources: README.md:121-133
Connection Verification
Verify that the RPC object is accessible from the router's command line:
ubus list luci-rpc
ubus call luci-rpc getNetworkDevices '{}'
Sources: README.md:135-138
Development Workflow
The development workflow focuses on maintaining code quality through static analysis and testing.
Coding Standards
- Formatting: Use
dart formatto maintain consistent style. - Analysis: Run
flutter analyze. The CI environment treats info-level issues as fatal for constant identifier names. - Style: Follow the official Dart Style Guide. Use
snake_casefor files andPascalCasefor classes.
Sources: CONTRIBUTING.md:60-78
Build and Test Flow
The following diagram illustrates the standard process for verifying changes:
The diagram shows the sequence of commands required to validate code before execution.
Sources: CONTRIBUTING.md:99-107, README.md:113-116
Localization
The project supports multiple locales. Localization files are managed in lib/l10n.
- Template:
app_en.arb - Supported Languages: English, German, French, Italian, Chinese, Russian, Dutch, Spanish, Korean, Japanese, Czech, Slovak, and Polish.
Sources: l10n.yaml:1-22
Quality Assurance
Testing Types
- Unit Tests: Validate individual components and logic.
- Integration Tests: Test API communication, authentication flows, and error handling.
- Manual Testing: Verify behavior on different devices and router configurations.
Sources: CONTRIBUTING.md:162-178
Static Analysis Phases
The project implements a gradual adoption strategy for linting rules in analysis_options.yaml:
- Critical Rules: Resource management (e.g.,
close_sinks) and security (e.g.,avoid_print). - Error Handling: Stability rules (e.g.,
unawaited_futures). - Code Quality: Optional rules for final locals and const constructors.
- Performance and Style: Formatting and collection literals.
Sources: analysis_options.yaml:31-70
Release Management
For developers with release permissions, the scripts/release.sh script automates versioning. It performs the following actions:
- Checks if the git working directory is clean.
- Increments the version (major, minor, or patch) in
pubspec.yaml. - Increments the build number.
- Commits the change and creates a Git tag.
Sources: scripts/release.sh:26-104
LuCI Mobile development requires a synchronized environment between the Flutter local setup and the OpenWrt router configuration. Adhering to the defined linting rules and testing procedures ensures compatibility across different router models and software versions.