From 4015de94e73ada8a69e528eb4518136fe1a575f1 Mon Sep 17 00:00:00 2001 From: creativecreatorormaybenot Date: Fri, 10 Sep 2021 00:52:09 +0000 Subject: [PATCH] Add & improve DropdownButtonFormField reference to DropdownButton (#89079) --- packages/flutter/lib/src/material/dropdown.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index f2d31cc31b..376e81fa07 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -821,6 +821,7 @@ class DropdownButtonHideUnderline extends InheritedWidget { /// /// See also: /// +/// * [DropdownButtonFormField], which integrates with the [Form] widget. /// * [DropdownMenuItem], the class used to represent the [items]. /// * [DropdownButtonHideUnderline], which prevents its descendant dropdown buttons /// from displaying their underlines. @@ -1474,7 +1475,20 @@ class _DropdownButtonState extends State> with WidgetsBindi } } -/// A convenience widget that makes a [DropdownButton] into a [FormField]. +/// A [FormField] that contains a [DropdownButton]. +/// +/// This is a convenience widget that wraps a [DropdownButton] widget in a +/// [FormField]. +/// +/// A [Form] ancestor is not required. The [Form] simply makes it easier to +/// save, reset, or validate multiple fields at once. To use without a [Form], +/// pass a [GlobalKey] to the constructor and use [GlobalKey.currentState] to +/// save or reset the form field. +/// +/// See also: +/// +/// * [DropdownButton], which is the underlying text field without the [Form] +/// integration. class DropdownButtonFormField extends FormField { /// Creates a [DropdownButton] widget that is a [FormField], wrapped in an /// [InputDecorator].