Skip to content

Commit

Permalink
Null Safety migration
Browse files Browse the repository at this point in the history
  • Loading branch information
pedromassango committed Mar 3, 2021
1 parent bea7684 commit 422f604
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 76 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,8 @@

## 5.0.0-nullsafety.0

* Null Safety support

## 4.1.0

* Added support RTL TextDirection. See (#22)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -41,7 +41,7 @@ Follow these steps to use this library
```yaml
dependencies:
...
titled_navigation_bar: ^4.1.0
titled_navigation_bar: ^5.0.0-nullsafety.0
```

### Import the package
Expand Down
59 changes: 4 additions & 55 deletions 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
titled_navigation_bar:

dependencies_overrides:
titled_navigation_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
27 changes: 11 additions & 16 deletions lib/src/navigation_bar.dart
Expand Up @@ -8,32 +8,28 @@ import 'navigation_bar_item.dart';
class TitledBottomNavigationBar extends StatefulWidget {
final bool reverse;
final Curve curve;
final Color activeColor;
final Color inactiveColor;
final Color inactiveStripColor;
final Color indicatorColor;
final Color? activeColor;
final Color? inactiveColor;
final Color? inactiveStripColor;
final Color? indicatorColor;
final bool enableShadow;
int currentIndex;
final ValueChanged<int> onTap;
final List<TitledNavigationBarItem> items;

TitledBottomNavigationBar({
Key key,
Key? key,
this.reverse = false,
this.curve = Curves.linear,
@required this.onTap,
@required this.items,
required this.onTap,
required this.items,
this.activeColor,
this.inactiveColor,
this.inactiveStripColor,
this.indicatorColor,
this.enableShadow = true,
this.currentIndex = 0,
}) : assert(items != null),
assert(items.length >= 2 && items.length <= 5),
assert(onTap != null),
assert(currentIndex != null),
assert(enableShadow != null),
}) : assert(items.length >= 2 && items.length <= 5),
super(key: key);

@override
Expand All @@ -51,15 +47,15 @@ class _TitledBottomNavigationBarState extends State<TitledBottomNavigationBar> {
List<TitledNavigationBarItem> get items => widget.items;

double width = 0;
Color activeColor;
Color? activeColor;
Duration duration = Duration(milliseconds: 270);

double _getIndicatorPosition(int index) {
var isLtr = Directionality.of(context) == TextDirection.ltr;
if (isLtr)
return lerpDouble(-1.0, 1.0, index / (items.length - 1));
return lerpDouble(-1.0, 1.0, index / (items.length - 1))!;
else
return lerpDouble(1.0, -1.0, index / (items.length - 1));
return lerpDouble(1.0, -1.0, index / (items.length - 1))!;
}

@override
Expand All @@ -79,7 +75,6 @@ class _TitledBottomNavigationBarState extends State<TitledBottomNavigationBar> {
: null,
),
child: Stack(
overflow: Overflow.visible,
children: <Widget>[
Positioned(
top: INDICATOR_HEIGHT,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/navigation_bar_item.dart
Expand Up @@ -6,8 +6,8 @@ class TitledNavigationBarItem {
final Color backgroundColor;

TitledNavigationBarItem({
@required this.icon,
@required this.title,
required this.icon,
required this.title,
this.backgroundColor = Colors.white,
});
}
4 changes: 2 additions & 2 deletions pubspec.yaml
@@ -1,10 +1,10 @@
name: titled_navigation_bar
description: A beautiful, clean and simple bottom navigation bar with smooth animation on click. This package is high customizable, read more bellow for more details.
version: 4.1.0
version: 5.0.0-nullsafety.0
homepage: https://github.com/pedromassango/titled_navigation_bar

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

dependencies:
flutter:
Expand Down

0 comments on commit 422f604

Please sign in to comment.