Skip to content

Commit

Permalink
refactor: increase code quality (#117)
Browse files Browse the repository at this point in the history
**No code logic is changed, only styling and formatting is done**

### Changes

- updated `.gitignore` file with the latest flutter template. (This
removes unnecessary root level `pubspec.lock` file)
- formatted code with dart standards using `dart fix --apply` and `dart
format .`
<img width="828" alt="Screenshot 2023-05-09 at 2 14 41 AM"
src="https://user-images.githubusercontent.com/74326345/236931044-78d77967-2fc1-47de-8cbe-53fae4f61c90.png">
  • Loading branch information
jogboms authored Jul 7, 2023
2 parents ba6678f + dd17acd commit aab47bc
Show file tree
Hide file tree
Showing 69 changed files with 1,646 additions and 755 deletions.
34 changes: 27 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,14 +1,34 @@
# Miscellaneous
*.class
*.log
*.pyc
*.swp
.DS_Store
.dart_tool/
.idea
.atom/
.buildlog/
.history
.svn/
migrate_working_dir/

.packages
.pub/
# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# The .vscode folder contains launch configuration and tasks you configure in
# VS Code which you may wish to be included in version control, so this line
# is commented out by default.
.vscode/

# Flutter/Dart/Pub related
# Libraries should not include pubspec.lock, per https://dart.dev/guides/libraries/private-files#pubspeclock.
/pubspec.lock
**/doc/api/
.dart_tool/
.packages
build/

# Custom
.pub/
coverage/
ios/.generated/
ios/Flutter/Generated.xcconfig
ios/Runner/GeneratedPluginRegistrant.*
1 change: 1 addition & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ linter:
- use_named_constants
- use_raw_strings
- use_super_parameters
- require_trailing_commas
28 changes: 28 additions & 0 deletions example/analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# This file configures the analyzer, which statically analyzes Dart code to
# check for errors, warnings, and lints.
#
# The issues identified by the analyzer are surfaced in the UI of Dart-enabled
# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be
# invoked from the command line by running `flutter analyze`.

# The following line activates a set of recommended lints for Flutter apps,
# packages, and plugins designed to encourage good coding practices.
include: package:flutter_lints/flutter.yaml

linter:
# The lint rules applied to this project can be customized in the
# section below to disable rules from the `package:flutter_lints/flutter.yaml`
# included above or to enable additional rules. A list of all available lints
# and their documentation is published at
# https://dart-lang.github.io/linter/lints/index.html.
#
# Instead of disabling a lint rule for the entire project in the
# section below, it can also be suppressed for a single line of code
# or a specific dart file by using the `// ignore: name_of_lint` and
# `// ignore_for_file: name_of_lint` syntax on the line or in the file
# producing the lint.
rules:
- require_trailing_commas

# Additional information about this file can be found at
# https://dart.dev/guides/language/analysis-options
8 changes: 6 additions & 2 deletions example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,12 @@ class App extends StatelessWidget {
builder: (context) => IconButton(
icon: const Icon(Icons.play_circle_filled),
iconSize: 50.0,
onPressed: () => Navigator.of(context)
.push(MaterialPageRoute<void>(builder: (_) => const ShowCase(), fullscreenDialog: true)),
onPressed: () => Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const ShowCase(),
fullscreenDialog: true,
),
),
),
),
alignment: Alignment.bottomCenter,
Expand Down
20 changes: 10 additions & 10 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ packages:
dependency: transitive
description:
name: async
sha256: bfe67ef28df125b7dddcea62755991f807aa39a2492a23e1550161692950bbe0
sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
url: "https://pub.dev"
source: hosted
version: "2.10.0"
version: "2.11.0"
boolean_selector:
dependency: transitive
description:
Expand Down Expand Up @@ -68,7 +68,7 @@ packages:
path: ".."
relative: true
source: path
version: "5.1.0"
version: "5.2.0"
flutter_test:
dependency: "direct dev"
description: flutter
Expand All @@ -94,10 +94,10 @@ packages:
dependency: transitive
description:
name: matcher
sha256: c94db23593b89766cda57aab9ac311e3616cf87c6fa4e9749df032f66f30dcb8
sha256: "6501fbd55da300384b768785b83e5ce66991266cec21af89ab9ae7f5ce1c4cbb"
url: "https://pub.dev"
source: hosted
version: "0.12.14"
version: "0.12.15"
material_color_utilities:
dependency: transitive
description:
Expand All @@ -110,10 +110,10 @@ packages:
dependency: transitive
description:
name: meta
sha256: "12307e7f0605ce3da64cf0db90e5fcab0869f3ca03f76be6bb2991ce0a55e82b"
sha256: "3c74dbf8763d36539f114c799d8a2d87343b5067e9d796ca22b5eb8437090ee3"
url: "https://pub.dev"
source: hosted
version: "1.9.0"
version: "1.9.1"
path:
dependency: transitive
description:
Expand Down Expand Up @@ -171,10 +171,10 @@ packages:
dependency: transitive
description:
name: test_api
sha256: "6182294da5abf431177fccc1ee02401f6df30f766bc6130a0852c6b6d7ee6b2d"
sha256: eb6ac1540b26de412b3403a163d919ba86f6a973fe6cc50ae3541b80092fdcfb
url: "https://pub.dev"
source: hosted
version: "0.4.18"
version: "0.5.1"
vector_math:
dependency: transitive
description:
Expand All @@ -184,5 +184,5 @@ packages:
source: hosted
version: "2.1.4"
sdks:
dart: ">=2.19.0 <4.0.0"
dart: ">=3.0.0-0 <4.0.0"
flutter: ">=2.0.0"
21 changes: 16 additions & 5 deletions lib/src/chasing_dots.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ class SpinKitChasingDots extends StatefulWidget {
this.size = 50.0,
this.itemBuilder,
this.duration = const Duration(milliseconds: 2000),
}) : assert(!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color'),
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color',
),
super(key: key);

final Color? color;
Expand Down Expand Up @@ -37,12 +39,16 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots> with TickerProv
}
})
..repeat(reverse: true);
_scale = Tween(begin: -1.0, end: 1.0).animate(CurvedAnimation(parent: _scaleCtrl, curve: Curves.easeInOut));
_scale = Tween(begin: -1.0, end: 1.0).animate(
CurvedAnimation(parent: _scaleCtrl, curve: Curves.easeInOut),
);

_rotateCtrl = AnimationController(vsync: this, duration: widget.duration)
..addListener(() => setState(() {}))
..repeat();
_rotate = Tween(begin: 0.0, end: 360.0).animate(CurvedAnimation(parent: _rotateCtrl, curve: Curves.linear));
_rotate = Tween(begin: 0.0, end: 360.0).animate(
CurvedAnimation(parent: _rotateCtrl, curve: Curves.linear),
);
}

@override
Expand Down Expand Up @@ -77,7 +83,12 @@ class _SpinKitChasingDotsState extends State<SpinKitChasingDots> with TickerProv
size: Size.square(widget.size * 0.6),
child: widget.itemBuilder != null
? widget.itemBuilder!(context, index)
: DecoratedBox(decoration: BoxDecoration(shape: BoxShape.circle, color: widget.color)),
: DecoratedBox(
decoration: BoxDecoration(
shape: BoxShape.circle,
color: widget.color,
),
),
),
);
}
Expand Down
24 changes: 19 additions & 5 deletions lib/src/circle.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ class SpinKitCircle extends StatefulWidget {
this.itemBuilder,
this.duration = const Duration(milliseconds: 1200),
this.controller,
}) : assert(!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color'),
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color',
),
super(key: key);

final Color? color;
Expand Down Expand Up @@ -59,8 +61,15 @@ class _SpinKitCircleState extends State<SpinKitCircle> with SingleTickerProvider
child: Align(
alignment: Alignment.center,
child: ScaleTransition(
scale: DelayTween(begin: 0.0, end: 1.0, delay: index / _itemCount).animate(_controller),
child: SizedBox.fromSize(size: Size.square(widget.size * 0.15), child: _itemBuilder(index)),
scale: DelayTween(
begin: 0.0,
end: 1.0,
delay: index / _itemCount,
).animate(_controller),
child: SizedBox.fromSize(
size: Size.square(widget.size * 0.15),
child: _itemBuilder(index),
),
),
),
),
Expand All @@ -73,5 +82,10 @@ class _SpinKitCircleState extends State<SpinKitCircle> with SingleTickerProvider

Widget _itemBuilder(int index) => widget.itemBuilder != null
? widget.itemBuilder!(context, index)
: DecoratedBox(decoration: BoxDecoration(color: widget.color, shape: BoxShape.circle));
: DecoratedBox(
decoration: BoxDecoration(
color: widget.color,
shape: BoxShape.circle,
),
);
}
51 changes: 38 additions & 13 deletions lib/src/cube_grid.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ class SpinKitCubeGrid extends StatefulWidget {
this.itemBuilder,
this.duration = const Duration(milliseconds: 1200),
this.controller,
}) : assert(!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color'),
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color',
),
super(key: key);

final Color? color;
Expand All @@ -36,16 +38,36 @@ class _SpinKitCubeGridState extends State<SpinKitCubeGrid> with SingleTickerProv

_controller = (widget.controller ?? AnimationController(vsync: this, duration: widget.duration))
..repeat(reverse: true);
_anim1 = Tween(begin: 1.0, end: 0.0)
.animate(CurvedAnimation(parent: _controller, curve: const Interval(0.1, 0.6, curve: Curves.easeIn)));
_anim2 = Tween(begin: 1.0, end: 0.0)
.animate(CurvedAnimation(parent: _controller, curve: const Interval(0.2, 0.7, curve: Curves.easeIn)));
_anim3 = Tween(begin: 1.0, end: 0.0)
.animate(CurvedAnimation(parent: _controller, curve: const Interval(0.3, 0.8, curve: Curves.easeIn)));
_anim4 = Tween(begin: 1.0, end: 0.0)
.animate(CurvedAnimation(parent: _controller, curve: const Interval(0.4, 0.9, curve: Curves.easeIn)));
_anim5 = Tween(begin: 1.0, end: 0.0)
.animate(CurvedAnimation(parent: _controller, curve: const Interval(0.5, 1.0, curve: Curves.easeIn)));
_anim1 = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.1, 0.6, curve: Curves.easeIn),
),
);
_anim2 = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.2, 0.7, curve: Curves.easeIn),
),
);
_anim3 = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.3, 0.8, curve: Curves.easeIn),
),
);
_anim4 = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.4, 0.9, curve: Curves.easeIn),
),
);
_anim5 = Tween(begin: 1.0, end: 0.0).animate(
CurvedAnimation(
parent: _controller,
curve: const Interval(0.5, 1.0, curve: Curves.easeIn),
),
);
}

@override
Expand Down Expand Up @@ -99,7 +121,10 @@ class _SpinKitCubeGridState extends State<SpinKitCubeGrid> with SingleTickerProv
Widget _square(Animation<double> animation, int index) {
return ScaleTransition(
scale: animation,
child: SizedBox.fromSize(size: Size.square(widget.size / 3), child: _itemBuilder(index)),
child: SizedBox.fromSize(
size: Size.square(widget.size / 3),
child: _itemBuilder(index),
),
);
}

Expand Down
35 changes: 28 additions & 7 deletions lib/src/dancing_square.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@ class SpinKitDancingSquare extends StatefulWidget {
this.itemBuilder,
this.duration = const Duration(milliseconds: 1200),
this.controller,
}) : assert(!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color'),
}) : assert(
!(itemBuilder is IndexedWidgetBuilder && color is Color) && !(itemBuilder == null && color == null),
'You should specify either a itemBuilder or a color',
),
super(key: key);

final Color? color;
Expand Down Expand Up @@ -63,7 +65,11 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
child: Align(
alignment: Alignment.center,
child: ScaleTransition(
scale: DelayTween(begin: 0.0, end: 1.0, delay: delay).animate(_controller),
scale: DelayTween(
begin: 0.0,
end: 1.0,
delay: delay,
).animate(_controller),
child: SizedBox.fromSize(
size: Size.square(widget.size * 0.15),
child: _itemBuilder(index),
Expand All @@ -80,7 +86,11 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
child: Align(
alignment: Alignment.center,
child: ScaleTransition(
scale: DelayTween(begin: 0.0, end: 1.0, delay: delay).animate(_controller),
scale: DelayTween(
begin: 0.0,
end: 1.0,
delay: delay,
).animate(_controller),
child: SizedBox.fromSize(
size: Size.square(widget.size * 0.15),
child: _itemBuilder(index),
Expand All @@ -97,7 +107,11 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
child: Align(
alignment: Alignment.center,
child: ScaleTransition(
scale: DelayTween(begin: 0.0, end: 1.0, delay: delay).animate(_controller),
scale: DelayTween(
begin: 0.0,
end: 1.0,
delay: delay,
).animate(_controller),
child: SizedBox.fromSize(
size: Size.square(widget.size * 0.15),
child: _itemBuilder(index),
Expand All @@ -114,7 +128,11 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
child: Align(
alignment: Alignment.center,
child: ScaleTransition(
scale: DelayTween(begin: 0.0, end: 1.0, delay: delay).animate(_controller),
scale: DelayTween(
begin: 0.0,
end: 1.0,
delay: delay,
).animate(_controller),
child: SizedBox.fromSize(
size: Size.square(widget.size * 0.15),
child: _itemBuilder(index),
Expand All @@ -134,6 +152,9 @@ class _SpinKitDancingSquareState extends State<SpinKitDancingSquare> with Single
Widget _itemBuilder(int index) => widget.itemBuilder != null
? widget.itemBuilder!(context, index)
: DecoratedBox(
decoration: BoxDecoration(color: widget.color, shape: BoxShape.rectangle),
decoration: BoxDecoration(
color: widget.color,
shape: BoxShape.rectangle,
),
);
}
Loading

0 comments on commit aab47bc

Please sign in to comment.