Autofill URL and TOKEN in debug mode. (#123)

* Autofill URL and TOKEN in debug mode.

* dart format.

* Set ENV priority higher than prefs.
This commit is contained in:
CloudWebRTC
2022-06-02 10:57:09 +08:00
committed by GitHub
parent e52a31f6ed
commit 741bead18c
2 changed files with 17 additions and 2 deletions
+11
View File
@@ -1,3 +1,14 @@
# LiveKit Flutter Example
This app implements a video room using LiveKit's Flutter SDK. Designed to run for iOS, Android, and web.
## Quickstart
Run example:
```bash
flutter pub get
# Due to the inconvenience of typing on mobile devices,
# you can autofill URL and TOKEN for first run in debug mode.
flutter run --dart-define=URL=ws://${LIVEKIT_SERVER_IP}:7880 --dart-define=TOKEN=${YOUR_TOKEN}
```
+6 -2
View File
@@ -48,8 +48,12 @@ class _ConnectPageState extends State<ConnectPage> {
// Read saved URL and Token
Future<void> _readPrefs() async {
final prefs = await SharedPreferences.getInstance();
_uriCtrl.text = prefs.getString(_storeKeyUri) ?? '';
_tokenCtrl.text = prefs.getString(_storeKeyToken) ?? '';
_uriCtrl.text = String.fromEnvironment('URL',
defaultValue: prefs.getString(_storeKeyUri) ?? '');
_tokenCtrl.text = String.fromEnvironment('TOKEN',
defaultValue: prefs.getString(_storeKeyToken) ?? '');
setState(() {
_simulcast = prefs.getBool(_storeKeySimulcast) ?? true;
_adaptiveStream = prefs.getBool(_storeKeyAdaptiveStream) ?? true;