feat: add environment variable substitution support for auth models

This commit is contained in:
Udhay-Adithya
2025-07-19 01:20:57 +05:30
parent 572688cb3b
commit cc8abee296
9 changed files with 318 additions and 150 deletions

View File

@@ -20,17 +20,16 @@ class ApiKeyAuthFields extends StatefulWidget {
}
class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
late TextEditingController _keyController;
late TextEditingController _nameController;
late String _key;
late String _name;
late String _addKeyTo;
@override
void initState() {
super.initState();
final apiAuth = widget.authData?.apikey;
_keyController = TextEditingController(text: apiAuth?.key ?? '');
_nameController =
TextEditingController(text: apiAuth?.name ?? kApiKeyHeaderName);
_key = apiAuth?.key ?? '';
_name = apiAuth?.name ?? kApiKeyHeaderName;
_addKeyTo = apiAuth?.location ?? kAddToDefaultLocation;
}
@@ -66,20 +65,26 @@ class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
},
),
const SizedBox(height: 16),
AuthTextField(
EnvAuthField(
readOnly: widget.readOnly,
controller: _nameController,
hintText: kHintTextFieldName,
onChanged: (value) => _updateApiKeyAuth(),
initialValue: widget.authData?.apikey?.name,
onChanged: (value) {
_name = value;
_updateApiKeyAuth();
},
),
const SizedBox(height: 16),
AuthTextField(
EnvAuthField(
readOnly: widget.readOnly,
controller: _keyController,
title: kLabelApiKey,
hintText: kHintTextKey,
isObscureText: true,
onChanged: (value) => _updateApiKeyAuth(),
initialValue: widget.authData?.apikey?.key,
onChanged: (value) {
_key = value;
_updateApiKeyAuth();
},
),
],
);
@@ -87,8 +92,8 @@ class _ApiKeyAuthFieldsState extends State<ApiKeyAuthFields> {
void _updateApiKeyAuth() {
final apiKey = AuthApiKeyModel(
key: _keyController.text.trim(),
name: _nameController.text.trim(),
key: _key.trim(),
name: _name.trim(),
location: _addKeyTo,
);
widget.updateAuth?.call(widget.authData?.copyWith(