You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The readOnly property of ShadInputFormField does not update the UI when its value is changed dynamically. When toggling the readOnly boolean (e.g., via a button or state change), the input field does not reflect the new read-only state as expected.
Steps to Reproduce:
Create a ShadInputFormField with a boolean readOnly value tied to a state variable (e.g., _isReadOnly).
Add a button or switch to toggle the _isReadOnly value.
Observe that the input field does not update its read-only state when the boolean changes.
Expected Behavior:
When readOnly is true, the input field should prevent text entry and appear disabled. When readOnly is false, it should allow text entry.
Actual Behavior:
The readOnly state does not update visually or functionally after the initial value is set.
Example Code:
import'package:flutter/material.dart';
import'package:shadcn_ui/shadcn_ui.dart';
classFormPageextendsStatefulWidget {
constFormPage({super.key});
@overrideState<FormPage> createState() =>_FormPageState();
}
class_FormPageStateextendsState<FormPage> {
final formKey =GlobalKey<ShadFormState>();
bool _isReadOnly =false; // State for readOnly togglevoid_toggleReadOnly(bool value) {
setState(() {
_isReadOnly = value;
});
}
@overrideWidgetbuild(BuildContext context) {
returnScaffold(
body:Center(
child:ShadForm(
key: formKey,
child:ConstrainedBox(
constraints:constBoxConstraints(maxWidth:350),
child:Column(
crossAxisAlignment:CrossAxisAlignment.start,
mainAxisSize:MainAxisSize.min,
children: [
ShadInputFormField(
initialValue:'initial text',
id:'username',
label:constText('Username'),
placeholder:constText('Enter your username'),
description:constText('This is your public display name.'),
readOnly: _isReadOnly, // Dynamic readOnly property
validator: (v) {
if (v.length <2) {
return'Username must be at least 2 characters.';
}
returnnull;
},
),
constSizedBox(height:16),
// Toggle control for readOnly stateRow(
children: [
constText('Read Only:'),
Switch(
value: _isReadOnly,
onChanged: _toggleReadOnly,
),
],
),
constSizedBox(height:16),
ShadButton(
child:constText('Submit'),
onPressed: () {
if (formKey.currentState!.saveAndValidate()) {
print(
'Validation succeeded with ${formKey.currentState!.value}');
} else {
print('Validation failed');
}
},
),
],
),
),
),
),
);
}
}
Expected results
i should be able to edit the field.
Actual results
the field is not editable.
shadcn_ui version
0.18.7
Platform
Android
Code sample
Code sample
[Paste your code here]
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
[✓] Flutter (Channel stable, 3.27.3, on Microsoft Windows [Version 10.0.22631.4830], locale en-AE) • Flutter version 3.27.3 on channel stable at C:\Users\m_ben\.puro\envs\stable\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision c519ee916e (3 weeks ago), 2025-01-21 10:32:23 -0800 • Engine revision e672b006cb • Dart version 3.6.1 • DevTools version 2.40.2[✓] Windows Version (Installed version of Windows is version 10 or higher)[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.1) • Android SDK at C:\Program Files\Android SDK • Platform android-35, build-tools 33.0.1 • ANDROID_SDK_ROOT = C:\Program Files\Android SDK\cmdline-tools\latest\bin • Java binary at: C:\Program Files\Zulu\zulu-19\bin\java.exe • Java version OpenJDK Runtime Environment Zulu19.30+11-CA (build 19.0.1+10) • All Android licenses accepted.[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe) ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.12.4) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.12.35707.178 • Windows 10 SDK version 10.0.22621.0[!] Android Studio (not installed) • Android Studio not found; download from https://developer.android.com/studio/index.html (or visit https://flutter.dev/to/windows-android-setup for detailed instructions).[✓] VS Code (version 1.96.4) • VS Code at C:\Users\m_ben\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.102.0[✓] Connected device (2 available) • sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 13 (API 33) (emulator) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22631.4830][✓] Network resources • All expected network resources are available.! Doctor found issues in 2 categories.
The text was updated successfully, but these errors were encountered:
DarkHeros09
changed the title
ShadInputFormFieldreadOnly` Property Not Updating Dynamically
ShadInputFormField readOnly Property Not Updating Dynamically
Feb 8, 2025
Steps to reproduce
The
readOnly
property ofShadInputFormField
does not update the UI when its value is changed dynamically. When toggling thereadOnly
boolean (e.g., via a button or state change), the input field does not reflect the new read-only state as expected.Steps to Reproduce:
ShadInputFormField
with a booleanreadOnly
value tied to a state variable (e.g.,_isReadOnly
)._isReadOnly
value.Expected Behavior:
When
readOnly
istrue
, the input field should prevent text entry and appear disabled. WhenreadOnly
isfalse
, it should allow text entry.Actual Behavior:
The
readOnly
state does not update visually or functionally after the initial value is set.Example Code:
Expected results
i should be able to edit the field.
Actual results
the field is not editable.
shadcn_ui version
0.18.7
Platform
Android
Code sample
Code sample
[Paste your code here]
Screenshots or Video
Screenshots / Video demonstration
[Upload media here]
Logs
Logs
[Paste your logs here]
Flutter Doctor output
Doctor output
The text was updated successfully, but these errors were encountered: