Toggle navigation
Toggle navigation
This project
Loading...
Sign in
flutter_package
/
modal_bottom_sheet
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Jaime Blasco
2022-09-03 12:22:30 +0200
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
fd723e515636d491794967e7d2f27928d23cd231
fd723e51
1 parent
5f4e09d4
fix: analyzer warnings
Hide whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
70 additions
and
66 deletions
analysis_options.yaml
example/lib/web_frame.dart
example/pubspec.lock
example/pubspec.yaml
lib/src/bottom_sheet.dart
lib/src/bottom_sheets/bar_bottom_sheet.dart
lib/src/bottom_sheets/cupertino_bottom_sheet.dart
lib/src/bottom_sheets/material_bottom_sheet.dart
lib/src/utils/scroll_to_top_status_bar.dart
pubspec.lock
pubspec.yaml
test/bottom_sheet_test.dart
analysis_options.yaml
View file @
fd723e5
include
:
package:lints/recommended.yaml
\ No newline at end of file
...
...
example/lib/web_frame.dart
View file @
fd723e5
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/material.dart'
;
import
'package:url_launcher/url_launcher.dart'
;
import
'package:url_launcher/url_launcher
_string
.dart'
;
class
WebFrame
extends
StatelessWidget
{
final
Widget
child
;
...
...
@@ -133,14 +133,14 @@ class WebFrame extends StatelessWidget {
Row
(
children:
<
Widget
>[
InkWell
(
onTap:
()
=>
launch
(
onTap:
()
=>
launch
UrlString
(
'https://pub.dev/packages/modal_bottom_sheet'
),
child:
Image
.
asset
(
'assets/flutter.png'
,
height:
60
),
),
Spacer
(),
InkWell
(
onTap:
()
=>
launch
(
onTap:
()
=>
launch
UrlString
(
'https://github.com/jamesblasco/modal_bottom_sheet'
),
child:
Image
.
asset
(
'assets/github.png'
,
height:
60
),
...
...
example/pubspec.lock
View file @
fd723e5
...
...
@@ -49,7 +49,7 @@ packages:
name: cupertino_icons
url: "https://pub.dartlang.org"
source: hosted
version: "
0.1.3
"
version: "
1.0.5
"
fake_async:
dependency: transitive
description:
...
...
@@ -174,56 +174,56 @@ packages:
name: url_launcher
url: "https://pub.dartlang.org"
source: hosted
version: "6.
0.20
"
version: "6.
1.5
"
url_launcher_android:
dependency: transitive
description:
name: url_launcher_android
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.1
5
"
version: "6.0.1
7
"
url_launcher_ios:
dependency: transitive
description:
name: url_launcher_ios
url: "https://pub.dartlang.org"
source: hosted
version: "6.0.1
5
"
version: "6.0.1
7
"
url_launcher_linux:
dependency: transitive
description:
name: url_launcher_linux
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.
0
"
version: "3.0.
1
"
url_launcher_macos:
dependency: transitive
description:
name: url_launcher_macos
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.
0
"
version: "3.0.
1
"
url_launcher_platform_interface:
dependency: transitive
description:
name: url_launcher_platform_interface
url: "https://pub.dartlang.org"
source: hosted
version: "2.
0.5
"
version: "2.
1.0
"
url_launcher_web:
dependency: transitive
description:
name: url_launcher_web
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.
9
"
version: "2.0.
13
"
url_launcher_windows:
dependency: transitive
description:
name: url_launcher_windows
url: "https://pub.dartlang.org"
source: hosted
version: "3.0.
0
"
version: "3.0.
1
"
vector_math:
dependency: transitive
description:
...
...
example/pubspec.yaml
View file @
fd723e5
...
...
@@ -14,19 +14,17 @@ publish_to: none
version
:
1.0.0+1
environment
:
sdk
:
"
>=2.12.0-29.10.beta
<3.0.0"
flutter
:
"
>=3.0.0"
sdk
:
'
>=2.17.0
<3.0.0'
dependencies
:
cupertino_icons
:
^1.0.5
flutter
:
sdk
:
flutter
url_launcher
:
^6.0.20
modal_bottom_sheet
:
path
:
'
../'
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons
:
^0.1.3
url_launcher
:
^6.1.5
dev_dependencies
:
flutter_test
:
...
...
lib/src/bottom_sheet.dart
View file @
fd723e5
...
...
@@ -101,7 +101,7 @@ class ModalBottomSheet extends StatefulWidget {
final
ScrollController
scrollController
;
@override
_ModalBottomSheetState
createState
()
=>
_
ModalBottomSheetState
();
ModalBottomSheetState
createState
()
=>
ModalBottomSheetState
();
/// Creates an [AnimationController] suitable for a
/// [ModalBottomSheet.animationController].
...
...
@@ -121,7 +121,7 @@ class ModalBottomSheet extends StatefulWidget {
}
}
class
_
ModalBottomSheetState
extends
State
<
ModalBottomSheet
>
class
ModalBottomSheetState
extends
State
<
ModalBottomSheet
>
with
TickerProviderStateMixin
{
final
GlobalKey
_childKey
=
GlobalKey
(
debugLabel:
'BottomSheet child'
);
...
...
lib/src/bottom_sheets/bar_bottom_sheet.dart
View file @
fd723e5
...
...
@@ -6,7 +6,7 @@ import 'package:flutter/services.dart';
import
'../../modal_bottom_sheet.dart'
;
import
'../bottom_sheet_route.dart'
;
const
Radius
_default_bar_top_r
adius
=
Radius
.
circular
(
15
);
const
Radius
kDefaultBarTopR
adius
=
Radius
.
circular
(
15
);
class
BarBottomSheet
extends
StatelessWidget
{
final
Widget
child
;
...
...
@@ -57,8 +57,8 @@ class BarBottomSheet extends StatelessWidget {
RoundedRectangleBorder
(
side:
BorderSide
(),
borderRadius:
BorderRadius
.
only
(
topLeft:
_default_bar_top_radius
,
topRight:
_default_bar_top_radius
),
topLeft:
kDefaultBarTopRadius
,
topRight:
kDefaultBarTopRadius
),
),
clipBehavior:
clipBehavior
??
Clip
.
hardEdge
,
color:
backgroundColor
??
Colors
.
white
,
...
...
lib/src/bottom_sheets/cupertino_bottom_sheet.dart
View file @
fd723e5
...
...
@@ -46,17 +46,17 @@ class _CupertinoBottomSheetContainer extends StatelessWidget {
final
topSafeAreaPadding
=
MediaQuery
.
of
(
context
).
padding
.
top
;
final
topPadding
=
_kPreviousPageVisibleOffset
+
topSafeAreaPadding
;
final
_shadow
=
shadow
??
_kDefaultBoxShadow
;
final
shadow
=
this
.
shadow
??
_kDefaultBoxShadow
;
BoxShadow
(
blurRadius:
10
,
color:
Colors
.
black12
,
spreadRadius:
5
);
final
_backgroundColor
=
backgroundColor
??
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
;
final
backgroundColor
=
this
.
backgroundColor
??
CupertinoTheme
.
of
(
context
).
scaffoldBackgroundColor
;
return
Padding
(
padding:
EdgeInsets
.
only
(
top:
topPadding
),
child:
ClipRRect
(
borderRadius:
BorderRadius
.
vertical
(
top:
topRadius
),
child:
Container
(
decoration:
BoxDecoration
(
color:
_backgroundColor
,
boxShadow:
[
_
shadow
]),
BoxDecoration
(
color:
backgroundColor
,
boxShadow:
[
shadow
]),
width:
double
.
infinity
,
child:
MediaQuery
.
removePadding
(
context:
context
,
...
...
@@ -211,10 +211,10 @@ class CupertinoModalBottomSheetRoute<T> extends ModalBottomSheetRoute<T> {
}
@override
Widget
getPreviousRouteTransition
(
BuildContext
context
,
Animation
<
double
>
secondaryAnimation
,
Widget
child
)
{
Widget
getPreviousRouteTransition
(
BuildContext
context
,
Animation
<
double
>
secondAnimation
,
Widget
child
)
{
return
_CupertinoModalTransition
(
secondaryAnimation:
second
ary
Animation
,
secondaryAnimation:
secondAnimation
,
body:
child
,
animationCurve:
previousRouteAnimationCurve
,
topRadius:
topRadius
,
...
...
@@ -290,20 +290,16 @@ class _CupertinoModalTransition extends StatelessWidget {
}
}
class
_CupertinoScaffol
d
extends
InheritedWidget
{
class
CupertinoScaffoldInheirte
d
extends
InheritedWidget
{
final
AnimationController
?
animation
;
final
Radius
?
topRadius
;
@override
final
Widget
child
;
const
_CupertinoScaffold
({
Key
?
key
,
const
CupertinoScaffoldInheirted
({
this
.
animation
,
required
this
.
child
,
required
super
.
child
,
this
.
topRadius
,
})
:
super
(
key:
key
,
child:
child
);
})
:
super
();
@override
bool
updateShouldNotify
(
InheritedWidget
oldWidget
)
{
...
...
@@ -313,8 +309,8 @@ class _CupertinoScaffold extends InheritedWidget {
// Support
class
CupertinoScaffold
extends
StatefulWidget
{
static
_CupertinoScaffold
?
of
(
BuildContext
context
)
=>
context
.
dependOnInheritedWidgetOfExactType
<
_CupertinoScaffold
>();
static
CupertinoScaffoldInheirted
?
of
(
BuildContext
context
)
=>
context
.
dependOnInheritedWidgetOfExactType
<
CupertinoScaffoldInheirted
>();
final
Widget
body
;
final
Radius
topRadius
;
...
...
@@ -405,7 +401,7 @@ class _CupertinoScaffoldState extends State<CupertinoScaffold>
@override
Widget
build
(
BuildContext
context
)
{
return
_CupertinoScaffol
d
(
return
CupertinoScaffoldInheirte
d
(
animation:
animationController
,
topRadius:
widget
.
topRadius
,
child:
_CupertinoModalTransition
(
...
...
lib/src/bottom_sheets/material_bottom_sheet.dart
View file @
fd723e5
...
...
@@ -61,17 +61,18 @@ WidgetWithChildBuilder _materialContainerBuilder(BuildContext context,
final
color
=
backgroundColor
??
bottomSheetTheme
.
modalBackgroundColor
??
bottomSheetTheme
.
backgroundColor
;
final
_elevation
=
elevation
??
bottomSheetTheme
.
elevation
??
0.0
;
final
_shape
=
shape
??
bottomSheetTheme
.
shape
;
final
_clipBehavior
=
final
effectiveElevation
=
elevation
??
bottomSheetTheme
.
elevation
??
0.0
;
final
effectiveShape
=
shape
??
bottomSheetTheme
.
shape
;
final
effectiveClipBehavior
=
clipBehavior
??
bottomSheetTheme
.
clipBehavior
??
Clip
.
none
;
final
result
=
(
context
,
animation
,
child
)
=>
Material
(
color:
color
,
elevation:
_elevation
,
shape:
_shape
,
clipBehavior:
_clipBehavior
,
child:
child
);
Widget
result
(
context
,
animation
,
child
)
=>
Material
(
color:
color
,
elevation:
effectiveElevation
,
shape:
effectiveShape
,
clipBehavior:
effectiveClipBehavior
,
child:
child
,
);
if
(
theme
!=
null
)
{
return
(
context
,
animation
,
child
)
=>
Theme
(
data:
theme
,
child:
result
(
context
,
animation
,
child
));
...
...
lib/src/utils/scroll_to_top_status_bar.dart
View file @
fd723e5
...
...
@@ -15,10 +15,10 @@ class ScrollToTopStatusBarHandler extends StatefulWidget {
})
:
super
(
key:
key
);
@override
_ScrollToTopStatusBarState
createState
()
=>
_
ScrollToTopStatusBarState
();
ScrollToTopStatusBarState
createState
()
=>
ScrollToTopStatusBarState
();
}
class
_
ScrollToTopStatusBarState
extends
State
<
ScrollToTopStatusBarHandler
>
{
class
ScrollToTopStatusBarState
extends
State
<
ScrollToTopStatusBarHandler
>
{
@override
void
initState
()
{
super
.
initState
();
...
...
pubspec.lock
View file @
fd723e5
...
...
@@ -60,6 +60,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
lints:
dependency: "direct dev"
description:
name: lints
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.0"
matcher:
dependency: transitive
description:
...
...
pubspec.yaml
View file @
fd723e5
...
...
@@ -13,4 +13,5 @@ dependencies:
dev_dependencies
:
flutter_test
:
sdk
:
flutter
\ No newline at end of file
sdk
:
flutter
lints
:
^2.0.0
...
...
test/bottom_sheet_test.dart
View file @
fd723e5
...
...
@@ -12,34 +12,34 @@ void main() {
Future
<
void
>
Function
(
BuildContext
context
,
WidgetBuilder
builder
)
onPressed
,
)
async
{
int
_initState
=
0
,
_
dispose
=
0
;
int
initState
=
0
,
dispose
=
0
;
await
_pumpWidget
(
tester:
tester
,
onPressed:
(
context
)
=>
onPressed
(
context
,
(
_
)
=>
_TestWidget
(
onInitState:
()
=>
_initState
++,
onDispose:
()
=>
_dispose
++,
onInitState:
()
=>
initState
++,
onDispose:
()
=>
dispose
++,
),
),
);
expect
(
_
initState
,
0
);
expect
(
initState
,
0
);
await
tester
.
tap
(
_textButtonWithText
(
'Press me'
));
await
tester
.
pumpAndSettle
();
expect
(
_initState
,
1
);
expect
(
_dispose
,
0
);
expect
(
initState
,
1
);
expect
(
dispose
,
0
);
await
tester
.
tap
(
_textButtonWithText
(
'TestWidget push'
));
await
tester
.
pumpAndSettle
();
expect
(
_initState
,
1
);
expect
(
_dispose
,
0
);
expect
(
initState
,
1
);
expect
(
dispose
,
0
);
await
tester
.
tap
(
_textButtonWithText
(
'TestWidget pushed pop'
));
await
tester
.
pumpAndSettle
();
expect
(
_initState
,
1
);
expect
(
_dispose
,
0
);
expect
(
initState
,
1
);
expect
(
dispose
,
0
);
await
tester
.
tap
(
_textButtonWithText
(
'TestWidget pop'
));
await
tester
.
pumpAndSettle
();
expect
(
_initState
,
1
);
expect
(
_dispose
,
1
);
expect
(
initState
,
1
);
expect
(
dispose
,
1
);
}
testWidgets
(
'with showCupertinoModalBottomSheet'
,
(
tester
)
{
...
...
Please
register
or
login
to post a comment