-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
169 additions
and
114 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:smooth_sheets/smooth_sheets.dart'; | ||
|
||
/// Issue [#151](https://github.com/fujidaiti/smooth_sheets/issues/151): | ||
/// Attaching SheetController to NavigationSheet causes | ||
/// "Null check operator used on a null value" | ||
void main() { | ||
runApp(const Issue151()); | ||
} | ||
|
||
class Issue151 extends StatelessWidget { | ||
const Issue151({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return const MaterialApp( | ||
home: Stack( | ||
children: [ | ||
Scaffold(), | ||
_Sheet(), | ||
], | ||
), | ||
); | ||
} | ||
} | ||
|
||
class _Sheet extends StatefulWidget { | ||
const _Sheet(); | ||
|
||
@override | ||
State<_Sheet> createState() => _SheetState(); | ||
} | ||
|
||
class _SheetState extends State<_Sheet> { | ||
NavigationSheetTransitionObserver? _transitionObserver; | ||
late final SheetController _sheetController; | ||
|
||
@override | ||
void initState() { | ||
super.initState(); | ||
_transitionObserver = NavigationSheetTransitionObserver(); | ||
_sheetController = SheetController() | ||
..addListener(() { | ||
debugPrint('extent: ${_sheetController.value.maybePixels}'); | ||
}); | ||
} | ||
|
||
@override | ||
void dispose() { | ||
_transitionObserver = null; | ||
_sheetController.dispose(); | ||
super.dispose(); | ||
} | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
final nestedNavigator = Navigator( | ||
observers: [_transitionObserver!], | ||
onGenerateInitialRoutes: (navigator, initialRoute) { | ||
return [ | ||
DraggableNavigationSheetRoute( | ||
builder: (context) => Container( | ||
color: Colors.indigoAccent, | ||
height: 500, | ||
width: double.infinity, | ||
), | ||
), | ||
]; | ||
}, | ||
); | ||
|
||
return NavigationSheet( | ||
controller: _sheetController, | ||
transitionObserver: _transitionObserver!, | ||
child: Material( | ||
color: Colors.indigo, | ||
child: nestedNavigator, | ||
), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.