Skip to content

Commit

Permalink
Merge pull request #77 from pedromassango/nnbd
Browse files Browse the repository at this point in the history
nnbd migration
  • Loading branch information
pedromassango authored Feb 17, 2021
2 parents db09361 + 96662b3 commit 6df144f
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 135 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v1
- uses: subosito/flutter-action@v1
with:
channel: stable
channel: beta
- run: flutter pub get
- run: flutter analyze
- run: pub global activate coverage
Expand Down
59 changes: 4 additions & 55 deletions example/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,74 +1,23 @@
name: example
description: A new Flutter project.

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1

environment:
sdk: ">=2.1.0 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"

dependencies:
flutter:
sdk: flutter

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

dependency_overrides:
bottom_navy_bar:
path: ../

dev_dependencies:
flutter_test:
sdk: flutter


# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true

# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg

# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.

# For details regarding adding assets from package dependencies, see
# https://flutter.io/assets-and-images/#from-packages

# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.io/custom-fonts/#from-packages
52 changes: 19 additions & 33 deletions lib/bottom_navy_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import 'package:flutter/widgets.dart';
class BottomNavyBar extends StatelessWidget {

BottomNavyBar({
Key key,
Key? key,
this.selectedIndex = 0,
this.showElevation = true,
this.iconSize = 24,
Expand All @@ -20,14 +20,10 @@ class BottomNavyBar extends StatelessWidget {
this.containerHeight = 56,
this.animationDuration = const Duration(milliseconds: 270),
this.mainAxisAlignment = MainAxisAlignment.spaceBetween,
@required this.items,
@required this.onItemSelected,
required this.items,
required this.onItemSelected,
this.curve = Curves.linear,
}) : assert(items != null),
assert(items.length >= 2 && items.length <= 5),
assert(onItemSelected != null),
assert(animationDuration != null),
assert(curve != null),
}) : assert(items.length >= 2 && items.length <= 5),
super(key: key);

/// The selected item is index. Changing this property will change and animate
Expand All @@ -39,7 +35,7 @@ class BottomNavyBar extends StatelessWidget {

/// The background color of the navigation bar. It defaults to
/// [Theme.bottomAppBarColor] if not provided.
final Color backgroundColor;
final Color? backgroundColor;

/// Whether this navigation bar should show a elevation. Defaults to true.
final bool showElevation;
Expand Down Expand Up @@ -69,9 +65,7 @@ class BottomNavyBar extends StatelessWidget {

@override
Widget build(BuildContext context) {
final bgColor = (backgroundColor == null)
? Theme.of(context).bottomAppBarColor
: backgroundColor;
final bgColor = backgroundColor ?? Theme.of(context).bottomAppBarColor;

return Container(
decoration: BoxDecoration(
Expand Down Expand Up @@ -123,22 +117,15 @@ class _ItemWidget extends StatelessWidget {
final Curve curve;

const _ItemWidget({
Key key,
@required this.item,
@required this.isSelected,
@required this.backgroundColor,
@required this.animationDuration,
@required this.itemCornerRadius,
@required this.iconSize,
Key? key,
required this.item,
required this.isSelected,
required this.backgroundColor,
required this.animationDuration,
required this.itemCornerRadius,
required this.iconSize,
this.curve = Curves.linear,
}) : assert(isSelected != null),
assert(item != null),
assert(backgroundColor != null),
assert(animationDuration != null),
assert(itemCornerRadius != null),
assert(iconSize != null),
assert(curve != null),
super(key: key);
}) : super(key: key);

@override
Widget build(BuildContext context) {
Expand Down Expand Up @@ -205,13 +192,12 @@ class _ItemWidget extends StatelessWidget {
class BottomNavyBarItem {

BottomNavyBarItem({
@required this.icon,
@required this.title,
required this.icon,
required this.title,
this.activeColor = Colors.blue,
this.textAlign,
this.inactiveColor,
}) : assert(icon != null),
assert(title != null);
});

/// Defines this item's icon which is placed in the right side of the [title].
final Widget icon;
Expand All @@ -224,11 +210,11 @@ class BottomNavyBarItem {
final Color activeColor;

/// The [icon] and [title] color defined when this item is not selected.
final Color inactiveColor;
final Color? inactiveColor;

/// The alignment for the [title].
///
/// This will take effect only if [title] it a [Text] widget.
final TextAlign textAlign;
final TextAlign? textAlign;

}
41 changes: 2 additions & 39 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: bottom_navy_bar
description: A beautiful and animated bottom navigation. The navigation bar use your current theme, but you are free to customize it.
version: 5.6.0
version: 6.0.0
homepage: https://github.com/pedromassango/bottom_navy_bar

environment:
sdk: ">=2.2.2 <3.0.0"
sdk: ">=2.12.0-0 <3.0.0"

dependencies:
flutter:
Expand All @@ -13,40 +13,3 @@ dependencies:
dev_dependencies:
flutter_test:
sdk: flutter

# For information on the generic Dart part of this file, see the
# following page: https://www.dartlang.org/tools/pub/pubspec

# The following section is specific to Flutter.
flutter:

# To add assets to your package, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
#
# For details regarding assets in packages, see
# https://flutter.io/assets-and-images/#from-packages
#
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.io/assets-and-images/#resolution-aware.

# To add custom fonts to your package, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts in packages, see
# https://flutter.io/custom-fonts/#from-packages
14 changes: 7 additions & 7 deletions test/bottom_navy_bar_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@ final List<BottomNavyBarItem> dummyItems = <BottomNavyBarItem>[
final ValueChanged<int> onItemSelected = (int index) {};

Widget buildNavyBarBoilerplate({
int currentIndex,
bool showElevation,
double itemCornerRadius,
@required ValueChanged<int> onItemSelected,
Curve curve,
Curve? curve,
int? currentIndex,
bool? showElevation,
double? itemCornerRadius,
required ValueChanged<int> onItemSelected,
}) {
return MaterialApp(
home: Scaffold(
Expand Down Expand Up @@ -131,7 +131,7 @@ void main() {
final Container containerFinder = tester.firstWidget<Container>(find.byType(Container));

expect((containerFinder.decoration as BoxDecoration).boxShadow, isNotNull);
expect((containerFinder.decoration as BoxDecoration).boxShadow.length, 1);
expect((containerFinder.decoration as BoxDecoration).boxShadow.first.blurRadius, 2);
expect((containerFinder.decoration as BoxDecoration).boxShadow!.length, 1);
expect((containerFinder.decoration as BoxDecoration).boxShadow!.first.blurRadius, 2);
});
}

0 comments on commit 6df144f

Please sign in to comment.