diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 3e34076..e4e4e4f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 7a0ecee..faff394 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -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 diff --git a/lib/bottom_navy_bar.dart b/lib/bottom_navy_bar.dart index d852fdb..277447e 100644 --- a/lib/bottom_navy_bar.dart +++ b/lib/bottom_navy_bar.dart @@ -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, @@ -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 @@ -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; @@ -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( @@ -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) { @@ -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; @@ -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; } diff --git a/pubspec.yaml b/pubspec.yaml index a62627d..3b54d7a 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -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: @@ -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 diff --git a/test/bottom_navy_bar_test.dart b/test/bottom_navy_bar_test.dart index 11ef03d..36c265c 100644 --- a/test/bottom_navy_bar_test.dart +++ b/test/bottom_navy_bar_test.dart @@ -32,11 +32,11 @@ final List dummyItems = [ final ValueChanged onItemSelected = (int index) {}; Widget buildNavyBarBoilerplate({ - int currentIndex, - bool showElevation, - double itemCornerRadius, - @required ValueChanged onItemSelected, - Curve curve, + Curve? curve, + int? currentIndex, + bool? showElevation, + double? itemCornerRadius, + required ValueChanged onItemSelected, }) { return MaterialApp( home: Scaffold( @@ -131,7 +131,7 @@ void main() { final Container containerFinder = tester.firstWidget(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); }); }