diff --git a/analysis_options.yaml b/analysis_options.yaml index ea2fada5..873ec92e 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -73,7 +73,6 @@ linter: - only_throw_errors # in some places it is required to override fields # - overridden_fields - - package_api_docs - package_names - package_prefixed_library_names - parameter_assignments diff --git a/example/lib/main.dart b/example/lib/main.dart index 2a4bed0f..b2babd35 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,7 +1,7 @@ import 'package:flutter/material.dart'; import 'package:flutter_svg/flutter_svg.dart'; -import 'package:url_launcher/url_launcher.dart'; import 'package:getwidget/getwidget.dart'; +import 'package:url_launcher/url_launcher.dart'; void main() => runApp(MyApp()); diff --git a/lib/components/alert/gf_alert.dart b/lib/components/alert/gf_alert.dart index 9d862d62..de0e7994 100644 --- a/lib/components/alert/gf_alert.dart +++ b/lib/components/alert/gf_alert.dart @@ -186,7 +186,7 @@ class _GFAlertState extends State with TickerProviderStateMixin { boxShadow: widget.shadow ?? [ BoxShadow( - color: Colors.black87.withOpacity(0.1), + color: Colors.black87.withValues(alpha: 0.1), offset: const Offset(0, 1), blurRadius: 10, spreadRadius: 2, diff --git a/lib/components/appbar/gf_appbar.dart b/lib/components/appbar/gf_appbar.dart index 5543f915..f9b721fc 100644 --- a/lib/components/appbar/gf_appbar.dart +++ b/lib/components/appbar/gf_appbar.dart @@ -109,7 +109,7 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget { /// /// The value is non-negative. /// - /// If this property is null, then [ThemeData.appBarTheme.elevation] is used, + /// If this property is null, then [AppBarTheme.elevation] is used, /// if that is also null, the default value is 4, the appropriate elevation /// for app bars. final double? elevation; @@ -123,14 +123,14 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget { /// The color to use for the app bar's material. Typically this should be set /// along with [brightness], [iconTheme], [textTheme]. /// - /// If this property is null, then [ThemeData.appBarTheme.color] is used, + /// If this property is null, then [AppBarTheme.backgroundColor] is used, /// if that is also null, then [ThemeData.primaryColor] is used. final Color? backgroundColor; /// The brightness of the app bar's material. Typically this is set along /// with [backgroundColor], [iconTheme], [textTheme]. /// - /// If this property is null, then [ThemeData.appBarTheme.brightness] is used, + /// If this property is null, then [ThemeData.brightness] is used, /// if that is also null, then the appBarTheme can be used to configure the /// appearance of AppBars. The appearance of Keyboards for TextFields now uses /// the overall theme's ThemeData.brightness and can also be customized with @@ -141,7 +141,7 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget { /// The color, opacity, and size to use for app bar icons. Typically this /// is set along with [backgroundColor], [brightness], [textTheme]. /// - /// If this property is null, then [ThemeData.appBarTheme.iconTheme] is used, + /// If this property is null, then [AppBarTheme.iconTheme] is used, /// if that is also null, then [ThemeData.primaryIconTheme] is used. final IconThemeData? iconTheme; @@ -150,14 +150,14 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget { /// themed differently than the icon that appears in the app bar's [leading] /// widget. /// - /// If this property is null, then [ThemeData.appBarTheme.actionsIconTheme] is + /// If this property is null, then [AppBarTheme.actionsIconTheme] is /// used, if that is also null, then this falls back to [iconTheme]. final IconThemeData? actionsIconTheme; /// The typographic styles to use for text in the app bar. Typically this is /// set along with [brightness] [backgroundColor], [iconTheme]. /// - /// If this property is null, then [ThemeData.appBarTheme.textTheme] is used, + /// If this property is null, then [ThemeData.textTheme] is used, /// if that is also null, then [ThemeData.primaryTextTheme] is used. final TextTheme? textTheme; @@ -226,7 +226,7 @@ class GFAppBar extends StatefulWidget implements PreferredSizeWidget { /// /// * inputFormatters, which are called before [onChanged] /// runs and can validate and change ("format") the input value. - /// * onEditingComplete, [onSubmitted], [onSelectionChanged]: + /// * onEditingComplete, [onSubmitted]: /// which are more specialized input change notifications. final ValueChanged? onChanged; @@ -333,12 +333,12 @@ class _GFAppBarState extends State { ).transform(widget.toolbarOpacity); if (centerStyle?.color != null) { centerStyle = centerStyle!.copyWith( - color: centerStyle.color!.withOpacity(opacity), + color: centerStyle.color!.withValues(alpha: opacity), ); } if (sideStyle?.color != null) { sideStyle = sideStyle!.copyWith( - color: sideStyle.color!.withOpacity(opacity), + color: sideStyle.color!.withValues(alpha: opacity), ); } overallIconTheme = overallIconTheme.copyWith( diff --git a/lib/components/avatar/gf_avatar.dart b/lib/components/avatar/gf_avatar.dart index 2bf871ad..6c858bf7 100644 --- a/lib/components/avatar/gf_avatar.dart +++ b/lib/components/avatar/gf_avatar.dart @@ -137,7 +137,8 @@ class GFAvatar extends StatelessWidget { ? null : Center( child: MediaQuery( - data: MediaQuery.of(context).copyWith(textScaleFactor: 1), + data: MediaQuery.of(context) + .copyWith(textScaler: const TextScaler.linear(1)), child: IconTheme( data: theme.iconTheme.copyWith(color: textStyle?.color), child: DefaultTextStyle( diff --git a/lib/components/badge/gf_button_badge.dart b/lib/components/badge/gf_button_badge.dart index 53f0a9e0..18292a8f 100644 --- a/lib/components/badge/gf_button_badge.dart +++ b/lib/components/badge/gf_button_badge.dart @@ -148,7 +148,6 @@ class GFButtonBadge extends StatefulWidget { /// The color to use for this badge's text when the badge is disabled. /// /// The badge's [Material.textStyle] will be the current theme's badge - /// text style, [ThemeData.textTheme.badge], configured with this color. /// /// The default value is the theme's disabled color, /// [ThemeData.disabledColor]. diff --git a/lib/components/button/gf_button.dart b/lib/components/button/gf_button.dart index 6e5565aa..021244b8 100644 --- a/lib/components/button/gf_button.dart +++ b/lib/components/button/gf_button.dart @@ -152,7 +152,6 @@ class GFButton extends StatefulWidget { /// The color to use for this button's text when the button is disabled. /// /// The button's [Material.textStyle] will be the current theme's button - /// text style, [ThemeData.textTheme.button], configured with this color. /// /// The default value is the theme's disabled color, /// [ThemeData.disabledColor]. @@ -235,7 +234,7 @@ class _GFButtonState extends State { late GFPosition position; late BoxShadow boxShadow; - final Set _states = {}; + final Set _states = {}; @override void initState() { @@ -251,16 +250,16 @@ class _GFButtonState extends State { disabledColor = widget.disabledColor; disabledTextColor = widget.disabledTextColor; _updateState( - MaterialState.disabled, + WidgetState.disabled, !widget.enabled, ); super.initState(); } - bool get _hovered => _states.contains(MaterialState.hovered); - bool get _focused => _states.contains(MaterialState.focused); - bool get _pressed => _states.contains(MaterialState.pressed); - bool get _disabled => _states.contains(MaterialState.disabled); + bool get _hovered => _states.contains(WidgetState.hovered); + bool get _focused => _states.contains(WidgetState.focused); + bool get _pressed => _states.contains(WidgetState.pressed); + bool get _disabled => _states.contains(WidgetState.disabled); double? buttonWidth() { double? buttonWidth = 0; @@ -274,14 +273,14 @@ class _GFButtonState extends State { return buttonWidth; } - void _updateState(MaterialState state, bool value) { + void _updateState(WidgetState state, bool value) { value ? _states.add(state) : _states.remove(state); } void _handleHighlightChanged(bool value) { if (_pressed != value) { setState(() { - _updateState(MaterialState.pressed, value); + _updateState(WidgetState.pressed, value); if (widget.onHighlightChanged != null) { widget.onHighlightChanged!(value); } @@ -292,7 +291,7 @@ class _GFButtonState extends State { void _handleHoveredChanged(bool value) { if (_hovered != value) { setState(() { - _updateState(MaterialState.hovered, value); + _updateState(WidgetState.hovered, value); }); } } @@ -300,14 +299,14 @@ class _GFButtonState extends State { void _handleFocusedChanged(bool value) { if (_focused != value) { setState(() { - _updateState(MaterialState.focused, value); + _updateState(WidgetState.focused, value); }); } } @override void didUpdateWidget(GFButton oldWidget) { - _updateState(MaterialState.disabled, !widget.enabled); + _updateState(WidgetState.disabled, !widget.enabled); // If the button is disabled while a press gesture is currently ongoing, // InkWell makes a call to handleHighlightChanged. This causes an exception // because it calls setState in the middle of a build. To preempt this, we @@ -327,7 +326,7 @@ class _GFButtonState extends State { disabledColor = widget.disabledColor; disabledTextColor = widget.disabledTextColor; _updateState( - MaterialState.disabled, + WidgetState.disabled, !widget.enabled, ); super.didUpdateWidget(oldWidget); @@ -363,7 +362,7 @@ class _GFButtonState extends State { if (disabledColor != null) { return disabledColor!; } else { - return color.withOpacity(0.48); + return color.withValues(alpha: 0.48); } } } @@ -377,7 +376,7 @@ class _GFButtonState extends State { if (disabledColor != null) { return disabledColor!; } else { - return color.withOpacity(0.48); + return color.withValues(alpha: 0.48); } } @@ -426,10 +425,10 @@ class _GFButtonState extends State { } } - final Color? effectiveTextColor = MaterialStateProperty.resolveAs( - widget.textStyle?.color, _states); + final Color? effectiveTextColor = + WidgetStateProperty.resolveAs(widget.textStyle?.color, _states); final Color themeColor = - Theme.of(context).colorScheme.onSurface.withOpacity(0.12); + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.12); final BorderSide outlineBorder = BorderSide( color: widget.borderSide == null ? getBorderColor() diff --git a/lib/components/button/gf_icon_button.dart b/lib/components/button/gf_icon_button.dart index ca9acd74..d0522e76 100644 --- a/lib/components/button/gf_icon_button.dart +++ b/lib/components/button/gf_icon_button.dart @@ -122,7 +122,7 @@ class _GFIconButtonState extends State { if (widget.disabledColor != null) { return widget.disabledColor!; } else { - return color.withOpacity(0.48); + return color.withValues(alpha: 0.48); } } } @@ -136,7 +136,7 @@ class _GFIconButtonState extends State { if (widget.disabledColor != null) { return widget.disabledColor; } else { - return color.withOpacity(0.48); + return color.withValues(alpha: 0.48); } } @@ -158,7 +158,7 @@ class _GFIconButtonState extends State { ? color == GFColors.TRANSPARENT ? GFColors.DARK : color - : color.withOpacity(0.48); + : color.withValues(alpha: 0.48); } else if (color == GFColors.TRANSPARENT) { return widget.onPressed != null ? GFColors.DARK : GFColors.WHITE; } else { @@ -171,7 +171,7 @@ class _GFIconButtonState extends State { assert(debugCheckHasMaterial(context)); final Color themeColor = - Theme.of(context).colorScheme.onSurface.withOpacity(0.12); + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.12); final BorderSide outlineBorder = BorderSide( color: widget.borderSide == null ? getBorderColor() diff --git a/lib/components/card/gf_card.dart b/lib/components/card/gf_card.dart index 517192fb..12b36aa4 100644 --- a/lib/components/card/gf_card.dart +++ b/lib/components/card/gf_card.dart @@ -60,7 +60,7 @@ class GFCard extends StatelessWidget { /// Whether to paint the [shape] border in front of the child. final bool borderOnForeground; - /// If this property is null then [ThemeData.cardTheme.clipBehavior] is used. + /// If this property is null then [CardTheme.clipBehavior] is used. final Clip? clipBehavior; /// The empty space that surrounds the card. Defines the card's outer [Container.margin]. diff --git a/lib/components/form/form_field/widgets/gf_formdropdown.dart b/lib/components/form/form_field/widgets/gf_formdropdown.dart index d08d085d..8f0021c3 100644 --- a/lib/components/form/form_field/widgets/gf_formdropdown.dart +++ b/lib/components/form/form_field/widgets/gf_formdropdown.dart @@ -65,7 +65,7 @@ class _GfFormDropDownState extends State { padding: widget.padding ?? const EdgeInsets.symmetric(vertical: 2, horizontal: 2), child: DropdownButtonFormField( - value: selectedValue, + initialValue: selectedValue, decoration: GfFormFieldDecoration( context: context, shape: GFTextFieldShape.roundedsquare, diff --git a/lib/components/form/form_field/widgets/gf_formradiobutton.dart b/lib/components/form/form_field/widgets/gf_formradiobutton.dart index 9e76e6c6..e1243912 100644 --- a/lib/components/form/form_field/widgets/gf_formradiobutton.dart +++ b/lib/components/form/form_field/widgets/gf_formradiobutton.dart @@ -42,61 +42,55 @@ class _GfFormGenderbuttonState extends State builder: (context, child) { selectedValue = dataModel.selectedValue; return Card( - child: Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - InkWell( - onTap: () { - selectedValue = 'Male'; - widget.onChanged(selectedValue); - dataModel.setValue(selectedValue.toString()); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Radio( - value: 'Male', - groupValue: selectedValue, - onChanged: (String? val) { - if (val != null && val.isNotEmpty) { - selectedValue = val.toString(); - widget.onChanged(selectedValue); - dataModel.setValue(val.toString()); - } - }, - ), - const SizedBox( - width: 8, - ), - const Text('Male') - ]), - ), - InkWell( + child: RadioGroup( + onChanged: (String? val) { + setState(() { + selectedValue = val.toString(); + widget.onChanged(selectedValue); + dataModel.setValue(selectedValue.toString()); + }); + }, + groupValue: selectedValue, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + InkWell( onTap: () { - selectedValue = 'Female'; + selectedValue = 'Male'; widget.onChanged(selectedValue); dataModel.setValue(selectedValue.toString()); }, - child: Row( + child: const Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Radio( - value: 'Female', - groupValue: selectedValue, - onChanged: (String? val) { - if (val != null && val.isNotEmpty) { - selectedValue = val.toString(); - widget.onChanged(selectedValue); - dataModel.setValue(val.toString()); - } - }, + value: 'Male', ), - const SizedBox( + SizedBox( width: 8, ), - const Text('Female') - ])), - ], + Text('Male') + ]), + ), + InkWell( + onTap: () { + selectedValue = 'Female'; + widget.onChanged(selectedValue); + dataModel.setValue(selectedValue.toString()); + }, + child: const Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Radio( + value: 'Female', + ), + SizedBox( + width: 8, + ), + Text('Female') + ])), + ], + ), )); }), ); diff --git a/lib/components/form/form_field/widgets/gf_questionwidget.dart b/lib/components/form/form_field/widgets/gf_questionwidget.dart index 1371f696..3cb9f0f3 100644 --- a/lib/components/form/form_field/widgets/gf_questionwidget.dart +++ b/lib/components/form/form_field/widgets/gf_questionwidget.dart @@ -65,66 +65,57 @@ class _GfFormQuestionWidgetState extends State const SizedBox( height: 8, ), - Row( - mainAxisAlignment: MainAxisAlignment.spaceEvenly, - children: [ - InkWell( - onTap: () { - selectedValue = widget.accepttext ?? 'Yes'; - widget.onChanged(selectedValue); - dataModel.setValue(selectedValue.toString()); - }, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - Radio( - value: widget.accepttext ?? 'Yes', - groupValue: selectedValue, - onChanged: (String? val) { - setState(() { - selectedValue = widget.accepttext ?? 'Yes'; - widget.onChanged(selectedValue); - dataModel - .setValue(selectedValue.toString()); - }); - }, - ), - const SizedBox( - width: 8, - ), - Text(widget.accepttext ?? 'Yes') - ]), - ), - InkWell( + RadioGroup( + groupValue: selectedValue, + onChanged: (String? value) { + setState(() { + selectedValue = value.toString(); + widget.onChanged(selectedValue); + dataModel.setValue(selectedValue.toString()); + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.spaceEvenly, + children: [ + InkWell( onTap: () { - setState(() { - selectedValue = widget.declinetext ?? 'No'; - widget.onChanged(selectedValue); - dataModel.setValue(selectedValue.toString()); - }); + selectedValue = widget.accepttext ?? 'Yes'; + widget.onChanged(selectedValue); + dataModel.setValue(selectedValue.toString()); }, child: Row( mainAxisAlignment: MainAxisAlignment.center, children: [ Radio( - value: widget.declinetext ?? 'No', - groupValue: selectedValue, - onChanged: (String? val) { - setState(() { - selectedValue = - widget.declinetext ?? 'No'; - widget.onChanged(selectedValue); - dataModel - .setValue(selectedValue.toString()); - }); - }, + value: widget.accepttext ?? 'Yes', ), const SizedBox( width: 8, ), - Text(widget.declinetext ?? 'No') - ])), - ], + Text(widget.accepttext ?? 'Yes') + ]), + ), + InkWell( + onTap: () { + setState(() { + selectedValue = widget.declinetext ?? 'No'; + widget.onChanged(selectedValue); + dataModel.setValue(selectedValue.toString()); + }); + }, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + Radio( + value: widget.declinetext ?? 'No', + ), + const SizedBox( + width: 8, + ), + Text(widget.declinetext ?? 'No') + ])), + ], + ), ) ]), )); diff --git a/lib/components/list_tile/gf_list_tile.dart b/lib/components/list_tile/gf_list_tile.dart index f23edd52..cb29d131 100644 --- a/lib/components/list_tile/gf_list_tile.dart +++ b/lib/components/list_tile/gf_list_tile.dart @@ -149,7 +149,7 @@ class GFListTile extends StatelessWidget { ? [ shadow ?? BoxShadow( - color: Colors.grey.withOpacity(0.5), + color: Colors.grey.withValues(alpha: 0.5), spreadRadius: 4, blurRadius: 7, diff --git a/lib/components/progress_bar/gf_progress_bar.dart b/lib/components/progress_bar/gf_progress_bar.dart index 8ed7e64e..1bd4a329 100644 --- a/lib/components/progress_bar/gf_progress_bar.dart +++ b/lib/components/progress_bar/gf_progress_bar.dart @@ -386,7 +386,7 @@ class LinearPainter extends CustomPainter { _paintBackground.strokeWidth = circleWidth ?? 0.0; _paintLine.color = progress.toString() == '0.0' && progressBarColor != null - ? progressBarColor ?? Colors.transparent.withOpacity(0) + ? progressBarColor ?? Colors.transparent.withValues(alpha: 0) : progressBarColor ?? Colors.transparent; _paintLine.style = PaintingStyle.stroke; _paintLine.strokeWidth = circleWidth ?? 0.0; diff --git a/lib/components/toggle/gf_toggle.dart b/lib/components/toggle/gf_toggle.dart index 43a8d823..3aaacbcb 100644 --- a/lib/components/toggle/gf_toggle.dart +++ b/lib/components/toggle/gf_toggle.dart @@ -213,7 +213,7 @@ class _GFToggleState extends State with TickerProviderStateMixin { : widget.disabledThumbColor ?? Colors.white, boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.16), + color: Colors.black.withValues(alpha: 0.16), blurRadius: 6, spreadRadius: 0, ), diff --git a/test/card_test.dart b/test/card_test.dart index 9c748ef4..bbba1eb5 100644 --- a/test/card_test.dart +++ b/test/card_test.dart @@ -309,8 +309,8 @@ Future main() async { (tester) async { const imageOverlay = NetworkImage( 'https://cdn.pixabay.com/photo/2016/11/22/07/09/spruce-1848543__340.jpg'); - final colorFilter = - ColorFilter.mode(Colors.black.withOpacity(0.67), BlendMode.darken); + final colorFilter = ColorFilter.mode( + Colors.black.withValues(alpha: 0.67), BlendMode.darken); const customTitle = GFListTile( titleText: 'Card Title', subTitleText: 'Sub title', @@ -339,8 +339,8 @@ Future main() async { (tester) async { const imageOverlay = NetworkImage( 'https://cdn.pixabay.com/photo/2016/11/22/07/09/spruce-1848543__340.jpg'); - final colorFilter = - ColorFilter.mode(Colors.black.withOpacity(0.67), BlendMode.darken); + final colorFilter = ColorFilter.mode( + Colors.black.withValues(alpha: 0.67), BlendMode.darken); const customTitle = GFListTile( avatar: GFAvatar(), titleText: 'Card Title', diff --git a/test/checkbox_list_tile_test.dart b/test/checkbox_list_tile_test.dart index 1eb251af..865b20ca 100644 --- a/test/checkbox_list_tile_test.dart +++ b/test/checkbox_list_tile_test.dart @@ -117,46 +117,46 @@ void main() { MaterialApp( theme: ThemeData.light().copyWith( switchTheme: SwitchThemeData( - thumbColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + thumbColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return toggleableActiveColor; } return null; }), - trackColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + trackColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return toggleableActiveColor; } return null; }), ), radioTheme: RadioThemeData( - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return toggleableActiveColor; } return null; }), ), checkboxTheme: CheckboxThemeData( - fillColor: MaterialStateProperty.resolveWith( - (Set states) { - if (states.contains(MaterialState.disabled)) { + fillColor: WidgetStateProperty.resolveWith( + (Set states) { + if (states.contains(WidgetState.disabled)) { return null; } - if (states.contains(MaterialState.selected)) { + if (states.contains(WidgetState.selected)) { return toggleableActiveColor; } return null; diff --git a/test/typography_test.dart b/test/typography_test.dart index dfc9d797..48038e81 100644 --- a/test/typography_test.dart +++ b/test/typography_test.dart @@ -56,7 +56,7 @@ void main() { }); testWidgets('GF Typography with opacity', (tester) async { - final textopacity = Colors.black.withOpacity(0.56); + final textopacity = Colors.black.withValues(alpha: 0.56); final GFTypography typography = GFTypography( text: 'type1', @@ -69,7 +69,7 @@ void main() { }); testWidgets('GF Typography with Custom Heading', (tester) async { - final textopacity = Colors.black.withOpacity(0.56); + final textopacity = Colors.black.withValues(alpha: 0.56); const bool divider = true; const icon = GFAvatar(); const colorfilter = ColorFilter.mode(Colors.black, BlendMode.darken);