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

Quick and dirty null-safety #144

Closed
wants to merge 5 commits into from
Closed
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: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
.pub-cache/
.pub/
/build/
pubspec.lock
example/pubspec.lock

# Web related
lib/generated_plugin_registrant.dart
Expand Down
24 changes: 8 additions & 16 deletions example/lib/screens.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,8 @@ class MainScreen extends StatelessWidget {
final BuildContext menuScreenContext;
final Function onScreenHideButtonPressed;
final bool hideStatus;
const MainScreen(
{Key key,
this.menuScreenContext,
this.onScreenHideButtonPressed,
this.hideStatus = false})

const MainScreen({Key key, this.menuScreenContext, this.onScreenHideButtonPressed, this.hideStatus = false})
: super(key: key);

@override
Expand All @@ -27,8 +24,7 @@ class MainScreen extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.center,
children: <Widget>[
Padding(
padding: const EdgeInsets.symmetric(
horizontal: 30.0, vertical: 20.0),
padding: const EdgeInsets.symmetric(horizontal: 30.0, vertical: 20.0),
child: TextField(
decoration: InputDecoration(hintText: "Test Text Field"),
),
Expand All @@ -41,8 +37,7 @@ class MainScreen extends StatelessWidget {
context,
settings: RouteSettings(name: '/home'),
screen: MainScreen2(),
pageTransitionAnimation:
PageTransitionAnimation.scaleRotate,
pageTransitionAnimation: PageTransitionAnimation.scaleRotate,
);
},
child: Text(
Expand Down Expand Up @@ -88,11 +83,11 @@ class MainScreen extends StatelessWidget {
backgroundColor: Colors.white,
useRootNavigator: false,
builder: (context) => Center(
child: RaisedButton(
child: ElevatedButton(
style: ElevatedButton.styleFrom(primary: Colors.blue),
onPressed: () {
Navigator.pop(context);
},
color: Colors.blue,
child: Text(
"Exit",
style: TextStyle(color: Colors.white),
Expand All @@ -111,8 +106,7 @@ class MainScreen extends StatelessWidget {
child: RaisedButton(
color: Colors.lime,
onPressed: () {
pushDynamicScreen(context,
screen: SampleModalScreen(), withNavBar: true);
pushDynamicScreen(context, screen: SampleModalScreen(), withNavBar: true);
},
child: Text(
"Push Dynamic/Modal Screen",
Expand All @@ -127,9 +121,7 @@ class MainScreen extends StatelessWidget {
this.onScreenHideButtonPressed();
},
child: Text(
this.hideStatus
? "Unhide Navigation Bar"
: "Hide Navigation Bar",
this.hideStatus ? "Unhide Navigation Bar" : "Hide Navigation Bar",
style: TextStyle(color: Colors.white),
),
),
Expand Down
153 changes: 0 additions & 153 deletions example/pubspec.lock

This file was deleted.

24 changes: 12 additions & 12 deletions lib/animations/animations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ part of persistent_bottom_nav_bar;

class OffsetAnimation extends StatefulWidget {
OffsetAnimation(
{Key key,
{Key? key,
this.child,
this.hideNavigationBar,
this.navBarHeight,
this.onAnimationComplete,
this.extendedLength = false})
: super(key: key);
final Widget child;
final bool hideNavigationBar;
final double navBarHeight;
final Widget? child;
final bool? hideNavigationBar;
final double? navBarHeight;
final bool extendedLength;
final Function(bool, bool) onAnimationComplete;
final Function(bool, bool)? onAnimationComplete;

@override
_OffsetAnimationState createState() => _OffsetAnimationState();
}

class _OffsetAnimationState extends State<OffsetAnimation>
with SingleTickerProviderStateMixin {
AnimationController _navBarHideAnimationController;
Animation<Offset> _navBarOffsetAnimation;
bool _hideNavigationBar;
late AnimationController _navBarHideAnimationController;
late Animation<Offset> _navBarOffsetAnimation;
bool? _hideNavigationBar;

@override
void initState() {
Expand All @@ -33,14 +33,14 @@ class _OffsetAnimationState extends State<OffsetAnimation>
_navBarHideAnimationController =
AnimationController(vsync: this, duration: Duration(milliseconds: 200));
_navBarOffsetAnimation = Tween<Offset>(
begin: Offset(0, 0), end: Offset(0, widget.navBarHeight + 22.0))
begin: Offset(0, 0), end: Offset(0, widget.navBarHeight! + 22.0))
.chain(CurveTween(curve: Curves.ease))
.animate(_navBarHideAnimationController);

_hideAnimation();

_navBarHideAnimationController.addListener(() {
widget.onAnimationComplete(_navBarHideAnimationController.isAnimating,
widget.onAnimationComplete!(_navBarHideAnimationController.isAnimating,
_navBarHideAnimationController.isCompleted);
});
}
Expand All @@ -52,8 +52,8 @@ class _OffsetAnimationState extends State<OffsetAnimation>
}

_hideAnimation() {
WidgetsBinding.instance.addPostFrameCallback((_) {
if (_hideNavigationBar) {
WidgetsBinding.instance!.addPostFrameCallback((_) {
if (_hideNavigationBar!) {
_navBarHideAnimationController.forward();
} else {
_navBarHideAnimationController.reverse();
Expand Down
4 changes: 2 additions & 2 deletions lib/models/nav-bar-animation.model.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ class ScreenTransitionAnimation {
}

class ItemAnimationProperties {
final Duration duration;
final Curve curve;
final Duration? duration;
final Curve? curve;

const ItemAnimationProperties({this.duration, this.curve});
}
46 changes: 23 additions & 23 deletions lib/models/nav-bar-essentials.model.dart
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
part of persistent_bottom_nav_bar;

class NavBarEssentials {
final int selectedIndex;
final int previousIndex;
final Color backgroundColor;
final List<PersistentBottomNavBarItem> items;
final ValueChanged<int> onItemSelected;
final double navBarHeight;
final NavBarPadding padding;
final Function(int) popAllScreensForTheSelectedTab;
final bool popScreensOnTapOfSelectedTab;
final ItemAnimationProperties itemAnimationProperties;
final int? selectedIndex;
final int? previousIndex;
final Color? backgroundColor;
final List<PersistentBottomNavBarItem>? items;
final ValueChanged<int>? onItemSelected;
final double? navBarHeight;
final NavBarPadding? padding;
final Function(int)? popAllScreensForTheSelectedTab;
final bool? popScreensOnTapOfSelectedTab;
final ItemAnimationProperties? itemAnimationProperties;

const NavBarEssentials({
Key key,
Key? key,
this.selectedIndex,
this.previousIndex,
this.backgroundColor,
this.popScreensOnTapOfSelectedTab,
this.itemAnimationProperties,
this.navBarHeight = 0.0,
@required this.items,
required this.items,
this.onItemSelected,
this.popAllScreensForTheSelectedTab,
this.padding,
});

NavBarEssentials copyWith({
int selectedIndex,
int previousIndex,
double iconSize,
Color backgroundColor,
List<PersistentBottomNavBarItem> items,
ValueChanged<int> onItemSelected,
double navBarHeight,
NavBarPadding padding,
Function(int) popAllScreensForTheSelectedTab,
bool popScreensOnTapOfSelectedTab,
ItemAnimationProperties itemAnimationProperties,
int? selectedIndex,
int? previousIndex,
double? iconSize,
Color? backgroundColor,
List<PersistentBottomNavBarItem>? items,
ValueChanged<int>? onItemSelected,
double? navBarHeight,
NavBarPadding? padding,
Function(int)? popAllScreensForTheSelectedTab,
bool? popScreensOnTapOfSelectedTab,
ItemAnimationProperties? itemAnimationProperties,
}) {
return NavBarEssentials(
selectedIndex: selectedIndex ?? this.selectedIndex,
Expand Down