84 lines
3.2 KiB
Markdown
84 lines
3.2 KiB
Markdown
# MyApp
|
|
|
|
Generic Flutter Android starter built with Flutter **3.47** (Dart **3.13**), Material 3, null safety, and [Provider](https://pub.dev/packages/provider) for state management.
|
|
|
|
Package name: `com.example.myapp`
|
|
|
|
## Features
|
|
|
|
- Splash screen that fades into the main shell
|
|
- Bottom navigation: Home, Search, Profile, Settings
|
|
- `ListView.builder` catalog with rounded, shadowed cards
|
|
- Detail screen with a matching `Hero` animation
|
|
- Light / dark / system theme, persisted with `shared_preferences`
|
|
- Add-item form with validation
|
|
- Mock catalog plus an `http` client aimed at JSONPlaceholder (toggle in Settings)
|
|
|
|
## Folder structure
|
|
|
|
```
|
|
android-flutter-app-generic/
|
|
├── android/ # Android embedding, Gradle, manifest
|
|
├── lib/
|
|
│ ├── main.dart # Entry point, Provider scope, MaterialApp
|
|
│ ├── models/
|
|
│ │ └── item.dart # Item + ItemCategory
|
|
│ ├── providers/
|
|
│ │ ├── item_provider.dart # Catalog ChangeNotifier
|
|
│ │ └── theme_provider.dart # ThemeMode ChangeNotifier
|
|
│ ├── screens/
|
|
│ │ ├── splash_screen.dart
|
|
│ │ ├── main_shell.dart # NavigationBar host
|
|
│ │ ├── home_screen.dart
|
|
│ │ ├── search_screen.dart
|
|
│ │ ├── profile_screen.dart
|
|
│ │ ├── settings_screen.dart
|
|
│ │ ├── item_detail_screen.dart
|
|
│ │ └── add_item_screen.dart
|
|
│ ├── services/
|
|
│ │ ├── storage_service.dart # shared_preferences wrapper
|
|
│ │ ├── item_api.dart # http placeholder
|
|
│ │ ├── fake_item_data.dart # Offline sample catalog
|
|
│ │ └── item_repository.dart # Mock vs remote switch
|
|
│ ├── utils/
|
|
│ │ ├── app_theme.dart # Material 3 light/dark themes
|
|
│ │ ├── constants.dart
|
|
│ │ └── helpers.dart
|
|
│ └── widgets/
|
|
│ ├── app_text_field.dart
|
|
│ ├── empty_state.dart
|
|
│ ├── item_card.dart
|
|
│ ├── item_hero_badge.dart
|
|
│ ├── loading_view.dart
|
|
│ └── responsive_body.dart
|
|
├── test/
|
|
│ └── widget_test.dart
|
|
└── pubspec.yaml
|
|
```
|
|
|
|
## Run the app
|
|
|
|
You need the [Flutter SDK](https://docs.flutter.dev/get-started/install) (3.47 or newer) and an Android emulator or device.
|
|
|
|
```bash
|
|
cd android-flutter-app-generic
|
|
flutter pub get
|
|
flutter run
|
|
```
|
|
|
|
Useful extras:
|
|
|
|
```bash
|
|
flutter devices # list emulators / devices
|
|
flutter run -d android # target Android explicitly
|
|
flutter analyze # static analysis
|
|
flutter test # widget + unit tests
|
|
```
|
|
|
|
On first Android run, Flutter will download a Gradle distribution and compile the app. Accept any Android licenses with `flutter doctor --android-licenses` if prompted.
|
|
|
|
## Theme and data
|
|
|
|
- Open **Settings** to switch System / Light / Dark. The choice is stored locally.
|
|
- Turn on **Use remote sample API** to fetch posts from `https://jsonplaceholder.typicode.com/posts` through the `http` package. If the request fails, the app falls back to the bundled mock list.
|