This example shows how to programmatically select an item using two different methods.
RadioGroupController myController = RadioGroupController();
List<String> items = ["Choice1", "Choice2", "Choice3"];
RadioGroup(
controller: myController,
values: items,
)
// Method 1 - Selects a specific item from the list.
myController.value = items[1]; // Selects Choice2// Method 2 - Selects whatever item is at the given// index in the list.
myController.selectAt(2); // Selects Choice3
Example 4
This example shows how to programmatically select an item using two different silent methods. This means, when the new value in is selected in the list, the onChanged method will not be called.
RadioGroupController myController = RadioGroupController();
List<String> items = ["Choice1", "Choice2", "Choice3"];
RadioGroup(
controller: myController,
values: items,
)
// Method 1 - Selects a specific item from the list.
myController.setValueSilently(items[1]); // Selects Choice2// Method 2 - Selects whatever item is at the given// index in the list.
myController.selectSilentlyAt(2); // Selects Choice3
Example 5
This example shows how to retrieve the selected value.