@@ -37,6 +37,7 @@ import 'runtime.dart';
3737/// * [Scaffold]
3838/// * [TextButton]
3939/// * [VerticalDivider]
40+ /// * [OverflowBar]
4041///
4142/// For each, every parameter is implemented using the same name. Parameters
4243/// that take structured types are represented using maps, with each named
@@ -50,6 +51,22 @@ import 'runtime.dart';
5051/// * [VisualDensity] is represented in the manner described in the documentation
5152/// of the [ArgumentDecoders.visualDensity] method.
5253///
54+ /// Some features have changed in the underlying Flutter's material library and are
55+ /// therefore no longer supported, including:
56+ ///
57+ /// * The [ButtonBar] widget in the Flutter's material library is planned to be
58+ /// deprecated in favor of the [OverflowBar] widget. The [ButtonBar] widget in
59+ /// `rfw` package uses the [OverflowBar] widget internally for backward compatibility.
60+ /// The [ButtonBar] widget in `rfw` package is not deprecated and will continue to
61+ /// be supported. As a result, the following [ButtonBar] parameters are no longer
62+ /// supported:
63+ ///
64+ /// * `buttonMinWidth`
65+ /// * `buttonHeight`
66+ /// * `buttonAlignedDropdown`
67+ ///
68+ /// It is recommended to use the [OverflowBar] widget.
69+ ///
5370/// Some features are not supported:
5471///
5572/// * [AppBar] s do not support [AppBar.bottom] , [AppBar.flexibleSpace] , and
@@ -123,18 +140,66 @@ Map<String, LocalWidgetBuilder> get _materialWidgetsDefinitions => <String, Loca
123140 );
124141 },
125142
143+ // The ButtonBar widget in package:flutter/material.dart is planned to be deprecated
144+ // in favor of the OverflowBar widget. This ButtonBar implementation uses the
145+ // OverflowBar widget internally for backward compatibility. The ButtonBar
146+ // widget in rfw package is not deprecated and will continue to be supported.
147+ //
148+ // The ButtonBar widget in package:flutter/material.dart has changed over time.
149+ // The following parameters are no longer supported:
150+ // - buttonMinWidth
151+ // - buttonHeight
152+ // - buttonAlignedDropdown
153+ //
154+ // It is recommended to use the OverflowBar widget.
126155 'ButtonBar' : (BuildContext context, DataSource source) {
127- // not implemented: buttonTextTheme
128- return ButtonBar (
156+ final EdgeInsetsGeometry buttonPadding = ArgumentDecoders .edgeInsets (source, ['buttonPadding' ]) ?? const EdgeInsets .all (8.0 );
157+ final ButtonBarLayoutBehavior layoutBehavior = ArgumentDecoders .enumValue <ButtonBarLayoutBehavior >(ButtonBarLayoutBehavior .values, source, ['layoutBehavior' ])
158+ ?? ButtonBarLayoutBehavior .padded;
159+
160+ Widget overflowBar = OverflowBar (
129161 alignment: ArgumentDecoders .enumValue <MainAxisAlignment >(MainAxisAlignment .values, source, ['alignment' ]) ?? MainAxisAlignment .start,
130- mainAxisSize: ArgumentDecoders .enumValue <MainAxisSize >(MainAxisSize .values, source, ['mainAxisSize' ]) ?? MainAxisSize .max,
131- buttonMinWidth: source.v <double >(['buttonMinWidth' ]),
132- buttonHeight: source.v <double >(['buttonHeight' ]),
133- buttonPadding: ArgumentDecoders .edgeInsets (source, ['buttonPadding' ]),
134- buttonAlignedDropdown: source.v <bool >(['buttonAlignedDropdown' ]) ?? false ,
135- layoutBehavior: ArgumentDecoders .enumValue <ButtonBarLayoutBehavior >(ButtonBarLayoutBehavior .values, source, ['layoutBehavior' ]),
136- overflowDirection: ArgumentDecoders .enumValue <VerticalDirection >(VerticalDirection .values, source, ['overflowDirection' ]),
137- overflowButtonSpacing: source.v <double >(['overflowButtonSpacing' ]),
162+ spacing: buttonPadding.horizontal / 2 ,
163+ overflowDirection: ArgumentDecoders .enumValue <VerticalDirection >(VerticalDirection .values, source, ['overflowDirection' ]) ?? VerticalDirection .down,
164+ overflowSpacing: source.v <double >(['overflowButtonSpacing' ]) ?? 0.0 ,
165+ children: source.childList (['children' ]),
166+ );
167+
168+ switch (layoutBehavior) {
169+ case ButtonBarLayoutBehavior .padded:
170+ overflowBar = Padding (
171+ padding: EdgeInsets .symmetric (
172+ vertical: 2.0 * (buttonPadding.horizontal / 4.0 ),
173+ horizontal: buttonPadding.horizontal / 2.0 ,
174+ ),
175+ child: overflowBar,
176+ );
177+ case ButtonBarLayoutBehavior .constrained:
178+ overflowBar = Container (
179+ padding: EdgeInsets .symmetric (horizontal: buttonPadding.horizontal / 2.0 ),
180+ constraints: const BoxConstraints (minHeight: 52.0 ),
181+ alignment: Alignment .center,
182+ child: overflowBar,
183+ );
184+ }
185+
186+ if (ArgumentDecoders .enumValue <MainAxisSize >(MainAxisSize .values, source, ['mainAxisSize' ]) == MainAxisSize .min) {
187+ return IntrinsicWidth (child: overflowBar);
188+ }
189+
190+ return overflowBar;
191+ },
192+
193+ 'OverflowBar' : (BuildContext context, DataSource source) {
194+ return OverflowBar (
195+ spacing: source.v <double >(['spacing' ]) ?? 0.0 ,
196+ alignment: ArgumentDecoders .enumValue <MainAxisAlignment >(MainAxisAlignment .values, source, ['alignment' ]),
197+ overflowSpacing: source.v <double >(['overflowSpacing' ]) ?? 0.0 ,
198+ overflowAlignment: ArgumentDecoders .enumValue <OverflowBarAlignment >(OverflowBarAlignment .values, source, ['overflowAlignment' ])
199+ ?? OverflowBarAlignment .start,
200+ overflowDirection: ArgumentDecoders .enumValue <VerticalDirection >(VerticalDirection .values, source, ['overflowDirection' ])
201+ ?? VerticalDirection .down,
202+ textDirection: ArgumentDecoders .enumValue <TextDirection >(TextDirection .values, source, ['textDirection' ]),
138203 children: source.childList (['children' ]),
139204 );
140205 },
0 commit comments