Stock Master Tracker docs
v2.0.0
Get help
● Set up · Android and iOS

Home-screen widgets
watchlist and portfolio.

Two widgets on Android and iOS: the watchlist and the selected portfolio. They refresh themselves about every 30 minutes from your API.

Android AppWidgetsiOS WidgetKitApp Group

01The two widgets

WidgetShowsTap
WatchlistPrices and changes for tickers from the user's watchlistOpens the app; a stock row opens that company (stockmaster://stock?symbol=…)
PortfolioThe selected portfolio's valueOpens the app

They follow the system light or dark mode and are translated into the 9 app languages. The example build and the web build have no widgets.

02How they get data

  • The app writes the watchlist, the selected portfolio and your API_BASE_URL to storage the widgets can read (app/lib/services/widget_sync.dart, package home_widget): SharedPreferences on Android, the App Group on iOS.
  • Between app launches the widgets fetch fresh prices themselves from <API_BASE_URL>/v1/quotes?symbols=… every 30 minutes: Android with WorkManager (WidgetRefreshWorker.kt), iOS with a WidgetKit timeline (WidgetStore.swift). The operating system decides the exact moment.
  • No key and no account are involved, but the quotes endpoint is a price endpoint: without the display licence the widgets have no prices (Market data).

03Switch widgets off, or make them Pro-only

Console settingDefaultEffect
Features → Home-screen widgets offOnThe widgets show a notice that the operator switched widgets off.
Pro and purchases → Widgets for Pro only onOffUsers without Pro see a Pro notice. Applies only while Pro is on sale.

A widget changes after the app has started once with the new configuration. Settings → Home-screen widgets explains the state to the user.

04Android files

FileWhat
app/android/app/src/main/kotlin/com/yourcompany/stockmaster/WatchlistWidgetProvider.kt, PortfolioWidgetProvider.kt, WidgetViews.kt, WidgetStore.kt, WidgetRefreshWorker.kt
app/android/app/src/main/res/layout/sm_widget_*.xmlLayouts
app/android/app/src/main/res/xml/sm_widget_*_info.xmlSizes and preview
app/android/app/src/main/res/values*/sm_widget_*.xmlTexts per language, colours (light and values-night), dimensions

The receivers are declared in AndroidManifest.xml. The Dart side refers to the providers by the Kotlin package (androidPackage in widget_sync.dart). If you move the Kotlin files to your own package, change both together.

05iOS widget extension

FileWhat
app/ios/StockMasterWidget/StockMasterWidget.swiftThe two widgets (kinds StockMasterWatchlist and StockMasterPortfolio) and their timeline
app/ios/StockMasterWidget/WidgetStore.swiftReads the App Group and refreshes prices
app/ios/StockMasterWidget/*.lproj/Texts in 9 languages
app/ios/StockMasterWidget/StockMasterWidget.entitlementsThe App Group
app/ios/scripts/add_widget_extension.rbAdds or repairs the extension target in the Xcode project

The extension target is already in Runner.xcodeproj, with bundle id <app bundle id>.StockMasterWidget and iOS 15.0. Sign it with your team. Run the script only if the target got lost: cd app/ios && ruby scripts/add_widget_extension.rb.

06The App Group must match in four places

The app and the widget share data through the App Group group.com.yourcompany.stockmaster. When you change the bundle id, change the group in all of these, register it in your Apple Developer account and enable it for both App IDs:

  • app/ios/Runner/Runner.entitlements
  • app/ios/StockMasterWidget/StockMasterWidget.entitlements
  • app/ios/StockMasterWidget/WidgetStore.swift (appGroup)
  • app/lib/services/widget_sync.dart (WidgetSync.appGroup)

A mismatch shows as an iOS widget in its empty state although the app has data.

07Change the look

Widget colours are native and are not taken from the app's theme tokens: edit the colours in StockMasterWidget.swift and values/sm_widget_colors.xml plus values-night/sm_widget_colors.xml on Android.