tmdb_movie_app_riverpod
Flutter 電影應用,使用 Riverpod(TMDB API)
- 星標
- 272
- 分支
- 51
- 最近推送(UTC)
- 2024年5月15日
- 專案狀態
- 未封存
原始 README
以下為英文專案原文快照,最新內容請造訪 GitHub。
Flutter Movies app with Riverpod (TMDB API)
This is an improved version of my old movies app based on the latest Riverpod 2.0 APIs.
Motivation
I built this app to showcase the latest APIs for popular packages such as Riverpod and GoRouter.
This is not meant to be a complete movies app, yet it should implement common use cases and features. 👇
Current Features
- Infinite scrolling with pagination
- Pull to refresh
- Search functionality
- Loading UI with the Shimmer package
- Stateful nested routing with
StatefulShellRoute
Here's a detailed tutorial explaining how the pagination and search UI works:
Planned Features (no promises 😅)
- Favourites
- Responsive UI
Packages in use
- flutter_riverpod and riverpod_generator for data caching (and much more!)
- freezed for JSON serialization
- dio for networking
- go_router for navigation
- shimmer for the loading UI
- envied for handling API keys
- cached_network_image for caching images
App Architecture & Folder structure
The project follows my Riverpod app architecture with a feature-first project structure.
More details here:
- Flutter App Architecture with Riverpod: An Introduction
- Flutter Project Structure: Feature-first or Layer-first?
It also uses the new Riverpod Generator package, which I have covered here:
Getting a TMDB API Key and Running the Project
This project uses the TMDB API to get the latest movies data.
Before running the app, you need to sign up on the TMDB website, then obtain an API key on the settings API page.
Once you have this, create an .env file at the root of the project and add your key:
// .env
TMDB_KEY=your-api-key
Then, run the code generator:
dart run build_runner build -d
This will generate a env.g.dart file inside lib/env. This contains the tmdbApiKey that is used when making requests to the TMDB API.
Congratulations, you're good to go. 😎
Note: Loading images from insecure HTTP endpoints
The data returned by the TMBD API points to image URLs using http rather than https. For the images to load correctly, the following changes have been made:
Android
Created a file at android/app/src/main/res/xml/network_security_config.xml with these contents:
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<base-config cleartextTrafficPermitted="true" />
</network-security-config>
Added this to the application tag in the AndroidManifest.xml:
android:networkSecurityConfig="@xml/network_security_config"
iOS
Add the following to ios/Runner/info.pList:
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
More information here:
macOS
Since macOS applications are sandboxed by default, we get a SocketException if we haven't added the required entitlements. This has been fixes by adding these lines to macos/Runner/DebugProfile.entitlements and macos/Runner/Release.entitlements:
<key>com.apple.security.network.client</key>
<true/>
More info here:
LICENSE: MIT
分類
使用的依賴
依賴清單 19 項
- flutter
{"sdk":"flutter"} - cupertino_icons
^1.0.8 - freezed_annotation
^2.4.1 - json_annotation
^4.9.0 - transparent_image
^2.0.1 - dio
^5.4.3 - flutter_riverpod
^2.5.1 - riverpod_annotation
^2.3.5 - envied
^0.5.4+1 - shimmer
^3.0.0 - cached_network_image
^3.3.1 - go_router
^13.2.3 - flutter_test開發依賴
{"sdk":"flutter"} - build_runner開發依賴
^2.4.9 - riverpod_generator開發依賴
^2.4.0 - freezed開發依賴
^2.5.2 - json_serializable開發依賴
^6.8.0 - envied_generator開發依賴
^0.5.4+1 - flutter_lints開發依賴
^4.0.0
所在榜單
如何選擇適合專案的儲存庫?
先依使用情境篩選,再比較專案活躍情況,最後到原始儲存庫確認使用要求。
- 透過儲存庫名稱、作者或描述搜尋,再依技術分類縮小範圍。
- 綜合星標、分支與最近推送比較專案;星標反映社群關注,不保證品質。
- 使用前在 GitHub 確認 README、授權條款與 Issues。
來源與維護
“A repository is the most basic element of GitHub.”
GitHub Docs — About repositories ↗