Skip to content

Commit

Permalink
Use super params (#296)
Browse files Browse the repository at this point in the history
  • Loading branch information
tomgilder authored Jul 22, 2022
1 parent 8bb8952 commit e6f04ec
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 66 deletions.
2 changes: 2 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ linter:
- prefer_const_declarations
- prefer_const_literals_to_create_immutables
- public_member_api_docs
- unawaited_futures
- use_super_parameters
2 changes: 1 addition & 1 deletion example/book_store/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.17.0 <3.0.0"

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion example/deep_linking/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.17.0 <3.0.0"

dependencies:
flutter:
Expand Down
6 changes: 3 additions & 3 deletions example/mobile_app/lib/pages/bottom_sheet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ class BottomSheetPage extends Page<void> {
@override
Route<void> createRoute(BuildContext context) {
return CupertinoModalBottomSheetRoute(
containerBuilder: (context, _, child) => _CupertinoBottomSheetContainer(
containerBuilder: (context, _, child) => CupertinoBottomSheetContainer(
topRadius: Radius.circular(12),
child: child,
),
Expand Down Expand Up @@ -184,13 +184,13 @@ const double _kPreviousPageVisibleOffset = 10;
const BoxShadow _kDefaultBoxShadow =
BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5);

class _CupertinoBottomSheetContainer extends StatelessWidget {
class CupertinoBottomSheetContainer extends StatelessWidget {
final Widget child;
final Color? backgroundColor;
final Radius topRadius;
final BoxShadow? shadow;

const _CupertinoBottomSheetContainer({
const CupertinoBottomSheetContainer({
Key? key,
required this.child,
this.backgroundColor,
Expand Down
2 changes: 1 addition & 1 deletion example/mobile_app/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.17.0 <3.0.0"

dependencies:
flutter:
Expand Down
2 changes: 1 addition & 1 deletion example/simple_example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ publish_to: "none"
version: 1.0.0+1

environment:
sdk: ">=2.16.1 <3.0.0"
sdk: ">=2.17.0 <3.0.0"

dependencies:
flutter:
Expand Down
32 changes: 12 additions & 20 deletions lib/routemaster.dart
Original file line number Diff line number Diff line change
Expand Up @@ -1142,10 +1142,10 @@ class _RoutemasterWidget extends InheritedWidget {
final RouteData routeData;

const _RoutemasterWidget({
required Widget child,
required super.child,
required this.state,
required this.routeData,
}) : super(child: child);
});

@override
bool updateShouldNotify(covariant _RoutemasterWidget oldWidget) {
Expand Down Expand Up @@ -1290,26 +1290,25 @@ class PageStackNavigator extends StatefulWidget {

/// Provides a [Navigator] that shows pages from a [PageStack].
const PageStackNavigator({
Key? key,
super.key,
required this.stack,
this.transitionDelegate = const DefaultTransitionDelegate<dynamic>(),
this.observers = const [],
this.navigatorKey,
}) : builder = null,
super(key: key);
}) : builder = null;

/// Provides a [Navigator] that shows pages from a [PageStack].
///
/// This constructor provides an additional `builder` function that can filter
/// or transform the list of pages from the stack.
const PageStackNavigator.builder({
Key? key,
super.key,
required this.stack,
required this.builder,
this.transitionDelegate = const DefaultTransitionDelegate<dynamic>(),
this.observers = const [],
this.navigatorKey,
}) : super(key: key);
});

@override
PageStackNavigatorState createState() => PageStackNavigatorState();
Expand Down Expand Up @@ -1418,19 +1417,12 @@ class _StackNavigator extends Navigator {

const _StackNavigator({
required this.stack,
Key? key,
PopPageCallback? onPopPage,
TransitionDelegate transitionDelegate =
const DefaultTransitionDelegate<dynamic>(),
List<Page> pages = const <Page<dynamic>>[],
List<NavigatorObserver> observers = const <NavigatorObserver>[],
}) : super(
key: key,
onPopPage: onPopPage,
transitionDelegate: transitionDelegate,
pages: pages,
observers: observers,
);
super.key,
super.onPopPage,
super.transitionDelegate,
super.pages,
super.observers,
});

@override
NavigatorState createState() {
Expand Down
4 changes: 2 additions & 2 deletions lib/src/not_found_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ class DefaultNotFoundPage extends StatelessWidget {

/// Initializes the page with the path that couldn't be found.
const DefaultNotFoundPage({
Key? key,
super.key,
required this.path,
}) : super(key: key);
});

@override
Widget build(BuildContext context) {
Expand Down
3 changes: 1 addition & 2 deletions lib/src/pages/cupertino_tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ class _CupertinoTabPageStateProvider extends InheritedNotifier {
final CupertinoTabPageState pageState;

const _CupertinoTabPageStateProvider({
required Widget child,
required super.child,
required this.pageState,
}) : super(
child: child,
notifier: pageState,
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/pages/indexed_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,9 @@ class _IndexedPageStateProvider extends InheritedNotifier {
final IndexedPageState pageState;

const _IndexedPageStateProvider({
required Widget child,
required super.child,
required this.pageState,
}) : super(
child: child,
notifier: pageState,
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/pages/stack_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,9 @@ class _StackPageStateProvider extends InheritedNotifier {
final StackPageState pageState;

_StackPageStateProvider({
required Widget child,
required super.child,
required this.pageState,
}) : super(
child: child,
notifier: pageState.stack,
);
}
Expand Down
3 changes: 1 addition & 2 deletions lib/src/pages/tab_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@ class _TabPageStateProvider extends InheritedNotifier {
final TabPageState pageState;

const _TabPageStateProvider({
required Widget child,
required super.child,
required this.pageState,
}) : super(
child: child,
notifier: pageState,
);
}
Expand Down
42 changes: 14 additions & 28 deletions lib/src/pages/transition_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -120,26 +120,17 @@ class TransitionPage<T> extends TransitionBuilderPage<T> {
/// transition is used. This is the Cupertino animation on iOS and macOS, and
/// the fade upwards animation on all other platforms.
const TransitionPage({
required Widget child,
required super.child,
this.pushTransition,
this.popTransition,
bool maintainState = true,
bool fullscreenDialog = false,
bool opaque = true,
LocalKey? key,
String? name,
Object? arguments,
String? restorationId,
}) : super(
child: child,
arguments: arguments,
restorationId: restorationId,
maintainState: maintainState,
fullscreenDialog: fullscreenDialog,
opaque: opaque,
key: key,
name: name,
);
super.maintainState = true,
super.fullscreenDialog = false,
super.opaque = true,
super.key,
super.name,
super.arguments,
super.restorationId,
});

/// Configures the transition animation used when this page is pushed.
///
Expand Down Expand Up @@ -204,16 +195,11 @@ abstract class TransitionBuilderPage<T> extends Page<T> {
this.maintainState = true,
this.fullscreenDialog = false,
this.opaque = true,
LocalKey? key,
String? name,
Object? arguments,
String? restorationId,
}) : super(
key: key,
name: name,
arguments: arguments,
restorationId: restorationId,
);
super.key,
super.name,
super.arguments,
super.restorationId,
});

/// Called when this page is pushed, returns a [PageTransition] to configure
/// the push animation.
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ version: 1.0.1
homepage: https://github.com/tomgilder/routemaster

environment:
sdk: ">=2.12.0 <3.0.0"
sdk: ">=2.17.0 <3.0.0"
flutter: ">=1.17.0"

dependencies:
Expand Down

0 comments on commit e6f04ec

Please sign in to comment.