Showing
3 changed files
with
18 additions
and
15 deletions
| 1 | import 'dart:async'; | 1 | import 'dart:async'; |
| 2 | 2 | ||
| 3 | -import 'package:flutter/material.dart'; | 3 | +import 'package:flutter/material.dart' hide ModalBottomSheetRoute; |
| 4 | import 'package:flutter/services.dart'; | 4 | import 'package:flutter/services.dart'; |
| 5 | 5 | ||
| 6 | -import '../../modal_bottom_sheet.dart' as modal_bottom_sheet; | ||
| 7 | - | ||
| 8 | const Radius kDefaultBarTopRadius = Radius.circular(15); | 6 | const Radius kDefaultBarTopRadius = Radius.circular(15); |
| 9 | 7 | ||
| 10 | class BarBottomSheet extends StatelessWidget { | 8 | class BarBottomSheet extends StatelessWidget { |
| @@ -98,7 +96,7 @@ Future<T?> showBarModalBottomSheet<T>({ | @@ -98,7 +96,7 @@ Future<T?> showBarModalBottomSheet<T>({ | ||
| 98 | assert(debugCheckHasMediaQuery(context)); | 96 | assert(debugCheckHasMediaQuery(context)); |
| 99 | assert(debugCheckHasMaterialLocalizations(context)); | 97 | assert(debugCheckHasMaterialLocalizations(context)); |
| 100 | final result = await Navigator.of(context, rootNavigator: useRootNavigator) | 98 | final result = await Navigator.of(context, rootNavigator: useRootNavigator) |
| 101 | - .push(modal_bottom_sheet.ModalSheetRoute<T>( | 99 | + .push(ModalBottomSheetRoute<T>( |
| 102 | builder: builder, | 100 | builder: builder, |
| 103 | bounce: bounce, | 101 | bounce: bounce, |
| 104 | closeProgressThreshold: closeProgressThreshold, | 102 | closeProgressThreshold: closeProgressThreshold, |
| 1 | -import 'package:flutter/material.dart'; | ||
| 2 | -import 'package:modal_bottom_sheet/modal_bottom_sheet.dart' | ||
| 3 | - as modal_bottom_sheet; | ||
| 4 | import 'dart:async'; | 1 | import 'dart:async'; |
| 5 | 2 | ||
| 3 | +import 'package:flutter/material.dart' hide ModalBottomSheetRoute; | ||
| 4 | +import 'package:modal_bottom_sheet/modal_bottom_sheet.dart'; | ||
| 5 | + | ||
| 6 | /// Shows a modal material design bottom sheet. | 6 | /// Shows a modal material design bottom sheet. |
| 7 | Future<T?> showMaterialModalBottomSheet<T>({ | 7 | Future<T?> showMaterialModalBottomSheet<T>({ |
| 8 | required BuildContext context, | 8 | required BuildContext context, |
| @@ -26,7 +26,7 @@ Future<T?> showMaterialModalBottomSheet<T>({ | @@ -26,7 +26,7 @@ Future<T?> showMaterialModalBottomSheet<T>({ | ||
| 26 | assert(debugCheckHasMediaQuery(context)); | 26 | assert(debugCheckHasMediaQuery(context)); |
| 27 | assert(debugCheckHasMaterialLocalizations(context)); | 27 | assert(debugCheckHasMaterialLocalizations(context)); |
| 28 | final result = await Navigator.of(context, rootNavigator: useRootNavigator) | 28 | final result = await Navigator.of(context, rootNavigator: useRootNavigator) |
| 29 | - .push(modal_bottom_sheet.ModalSheetRoute<T>( | 29 | + .push(ModalBottomSheetRoute<T>( |
| 30 | builder: builder, | 30 | builder: builder, |
| 31 | closeProgressThreshold: closeProgressThreshold, | 31 | closeProgressThreshold: closeProgressThreshold, |
| 32 | containerBuilder: _materialContainerBuilder( | 32 | containerBuilder: _materialContainerBuilder( |
| @@ -52,8 +52,7 @@ Future<T?> showMaterialModalBottomSheet<T>({ | @@ -52,8 +52,7 @@ Future<T?> showMaterialModalBottomSheet<T>({ | ||
| 52 | } | 52 | } |
| 53 | 53 | ||
| 54 | //Default container builder is the Material Appearance | 54 | //Default container builder is the Material Appearance |
| 55 | -modal_bottom_sheet.WidgetWithChildBuilder _materialContainerBuilder( | ||
| 56 | - BuildContext context, | 55 | +WidgetWithChildBuilder _materialContainerBuilder(BuildContext context, |
| 57 | {Color? backgroundColor, | 56 | {Color? backgroundColor, |
| 58 | double? elevation, | 57 | double? elevation, |
| 59 | ThemeData? theme, | 58 | ThemeData? theme, |
| 1 | import 'package:flutter/cupertino.dart'; | 1 | import 'package:flutter/cupertino.dart'; |
| 2 | -import 'package:flutter/material.dart'; | 2 | +import 'package:flutter/material.dart' hide ModalBottomSheetRoute; |
| 3 | 3 | ||
| 4 | -import '../modal_bottom_sheet.dart' as modal_bottom_sheet; | 4 | +import '../modal_bottom_sheet.dart'; |
| 5 | +import 'bottom_sheet_route.dart'; | ||
| 5 | 6 | ||
| 6 | class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | 7 | class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { |
| 7 | /// Construct a MaterialPageRoute whose contents are defined by [builder]. | 8 | /// Construct a MaterialPageRoute whose contents are defined by [builder]. |
| @@ -19,7 +20,7 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | @@ -19,7 +20,7 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | ||
| 19 | builder: builder, | 20 | builder: builder, |
| 20 | maintainState: maintainState); | 21 | maintainState: maintainState); |
| 21 | 22 | ||
| 22 | - modal_bottom_sheet.ModalSheetRoute? _nextModalRoute; | 23 | + ModalBottomSheetRoute? _nextModalRoute; |
| 23 | 24 | ||
| 24 | @override | 25 | @override |
| 25 | bool canTransitionTo(TransitionRoute<dynamic> nextRoute) { | 26 | bool canTransitionTo(TransitionRoute<dynamic> nextRoute) { |
| @@ -28,12 +29,12 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | @@ -28,12 +29,12 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | ||
| 28 | (nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog) || | 29 | (nextRoute is CupertinoPageRoute && !nextRoute.fullscreenDialog) || |
| 29 | (nextRoute is MaterialWithModalsPageRoute && | 30 | (nextRoute is MaterialWithModalsPageRoute && |
| 30 | !nextRoute.fullscreenDialog) || | 31 | !nextRoute.fullscreenDialog) || |
| 31 | - (nextRoute is modal_bottom_sheet.ModalSheetRoute); | 32 | + (nextRoute is ModalBottomSheetRoute); |
| 32 | } | 33 | } |
| 33 | 34 | ||
| 34 | @override | 35 | @override |
| 35 | void didChangeNext(Route? nextRoute) { | 36 | void didChangeNext(Route? nextRoute) { |
| 36 | - if (nextRoute is modal_bottom_sheet.ModalSheetRoute) { | 37 | + if (nextRoute is ModalBottomSheetRoute) { |
| 37 | _nextModalRoute = nextRoute; | 38 | _nextModalRoute = nextRoute; |
| 38 | } | 39 | } |
| 39 | 40 | ||
| @@ -41,6 +42,11 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | @@ -41,6 +42,11 @@ class MaterialWithModalsPageRoute<T> extends MaterialPageRoute<T> { | ||
| 41 | } | 42 | } |
| 42 | 43 | ||
| 43 | @override | 44 | @override |
| 45 | + void didPopNext(Route nextRoute) { | ||
| 46 | + super.didPopNext(nextRoute); | ||
| 47 | + } | ||
| 48 | + | ||
| 49 | + @override | ||
| 44 | bool didPop(T? result) { | 50 | bool didPop(T? result) { |
| 45 | _nextModalRoute = null; | 51 | _nextModalRoute = null; |
| 46 | return super.didPop(result); | 52 | return super.didPop(result); |
-
Please register or login to post a comment