Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

changes done as lints 3.0.0 #83

Merged
merged 4 commits into from Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/lib/main.dart
Expand Up @@ -77,7 +77,7 @@ class MyApp extends StatelessWidget {
inactiveFgColor: Colors.white,
totalSwitches: 2,
labels: ['YES', ''],
icons: [null, FontAwesomeIcons.times],
icons: [null, FontAwesomeIcons.xmark],
onToggle: (index) {
print('switched to: $index');
},
Expand Down
187 changes: 0 additions & 187 deletions example/pubspec.lock

This file was deleted.

7 changes: 4 additions & 3 deletions example/pubspec.yaml
Expand Up @@ -12,9 +12,10 @@ description: An example application using toggle switch widget.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.1.0
publish_to: none

environment:
sdk: '>=2.12.0 <3.0.0'
sdk: '>=2.12.0 <4.0.0'

dependencies:
flutter:
Expand All @@ -23,11 +24,11 @@ dependencies:
toggle_switch:
path: ../

font_awesome_flutter: ^10.4.0
font_awesome_flutter: ^10.6.0

# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2
cupertino_icons: ^1.0.6

dev_dependencies:
flutter_test:
Expand Down
23 changes: 11 additions & 12 deletions lib/toggle_switch.dart
@@ -1,5 +1,4 @@
//Credit : @Eugene (https://stackoverflow.com/questions/56340682/flutter-equvalent-android-toggle-switch)

import 'package:flutter/material.dart';
import 'dart:math';

Expand Down Expand Up @@ -287,7 +286,7 @@ class _ToggleSwitchState extends State<ToggleSwitch>
);
} else {
/// Matches corner radius of active switch to that of border
var cornerRadius;
late BorderRadius cornerRadius;
if (index == 0 && !widget.isVertical) {
/// Checks if text direction is set right-to-left and
/// assigns corner radius accordingly.
Expand Down Expand Up @@ -397,7 +396,7 @@ class _ToggleSwitchState extends State<ToggleSwitch>
/// Assigns active border if available.
/// If only one active border is passed then we assume that we wanna
/// apply that active border to all the switches.
var activeBorder;
Border? activeBorder;
if (widget.activeBorders != null) {
activeBorder = widget.activeBorders!.length == 1
? widget.activeBorders![0]
Expand All @@ -414,11 +413,11 @@ class _ToggleSwitchState extends State<ToggleSwitch>
padding: const EdgeInsets.only(left: 10.0, right: 10.0),
constraints: BoxConstraints(
maxWidth: widget.isVertical
? BoxConstraints().maxWidth
? const BoxConstraints().maxWidth
: _calculateWidth(index ~/ 2, totalSwitches),
maxHeight: widget.isVertical
? _calculateHeight(index ~/ 2, totalSwitches)
: BoxConstraints().maxHeight,
: const BoxConstraints().maxHeight,
),
alignment: Alignment.center,
decoration: BoxDecoration(
Expand Down Expand Up @@ -552,17 +551,17 @@ class RowToColumn extends StatelessWidget {
Widget build(BuildContext context) {
return ((isColumnToRow ?? false) ? isVertical : !isVertical)
? Row(
mainAxisAlignment: mainAxisAlignment ?? const Row().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? const Row().mainAxisSize,
crossAxisAlignment: crossAxisAlignment ?? const Row().crossAxisAlignment,
children: children,
mainAxisAlignment: mainAxisAlignment ?? Row().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? Row().mainAxisSize,
crossAxisAlignment: crossAxisAlignment ?? Row().crossAxisAlignment,
)
: Column(
children: children,
mainAxisAlignment: mainAxisAlignment ?? Column().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? Column().mainAxisSize,
mainAxisAlignment: mainAxisAlignment ?? const Column().mainAxisAlignment,
mainAxisSize: mainAxisSize ?? const Column().mainAxisSize,
crossAxisAlignment:
crossAxisAlignment ?? Column().crossAxisAlignment,
crossAxisAlignment ?? const Column().crossAxisAlignment,
children: children,
);
}
}