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

chore: Updated example and images #98

Merged
merged 1 commit into from
Mar 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ There are 2 types of BottomSheets:
## Example
#### Simple BottomSheet

![](https://i.ibb.co/KKR0SDF/open-flexible-bottom-sheet.gif)
![](https://i.ibb.co/Xjntn3H/open-flexible-bottom-sheet.gif)

To show bottomSheet, use :

Expand Down Expand Up @@ -66,7 +66,7 @@ Widget _buildBottomSheet(

#### BottomSheet with height based on content

![](https://i.ibb.co/xmhkTQm/example-with-height-base-on-content.gif)
![](https://i.ibb.co/gMcvMyp/example-with-height-base-on-content.gif)

```dart
showFlexibleBottomSheet(
Expand Down Expand Up @@ -97,7 +97,7 @@ Widget _buildBottomSheet(

#### Sticky BottomSheet

![](https://i.ibb.co/M7C1qtB/open-sticky-bottom-sheet.gif)
![](https://i.ibb.co/bBz6pJk/open-sticky-bottom-sheet.gif)

To show sticky BottomSheet, use:
**You have to return SliverChildListDelegate from builder !!!**
Expand Down
52 changes: 25 additions & 27 deletions example/lib/bottom_sheet_based_on_content_height.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,37 +75,35 @@ class _BottomSheet extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Padding(
return ListView(
padding: const EdgeInsets.all(16),
child: ListView(
controller: controller,
shrinkWrap: true,
children: [
Text(
animal.animalName,
style: const TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
textAlign: TextAlign.center,
controller: controller,
shrinkWrap: true,
children: [
Text(
animal.animalName,
style: const TextStyle(
fontSize: 25,
fontWeight: FontWeight.bold,
),
const SizedBox(height: 16),
ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image(
image: AssetImage(animal.photo),
),
textAlign: TextAlign.center,
),
const SizedBox(height: 16),
ClipRRect(
borderRadius: BorderRadius.circular(16),
child: Image(
image: AssetImage(animal.photo),
),
const SizedBox(height: 16),
Text(
animal.description,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
),
),
const SizedBox(height: 16),
Text(
animal.description,
style: const TextStyle(
fontSize: 20,
fontWeight: FontWeight.normal,
),
],
),
),
],
);
}
}
Expand Down
74 changes: 30 additions & 44 deletions example/lib/standard_bottom_sheet_example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,24 +22,11 @@ class _StandardBottomSheetExampleState
bottomSheetBorderRadius: const BorderRadius.only(
topLeft: Radius.circular(40),
),
bottomSheetColor: Colors.transparent,
bottomSheetColor: Colors.white,
builder: (context, controller, offset) {
return Column(
mainAxisSize: MainAxisSize.min,
children: [
Container(
color: Colors.orange,
height: 40,
),
Container(
color: Colors.transparent,
height: 100,
),
Container(
color: Colors.orange,
height: 100,
),
],
return _BottomSheet(
scrollController: controller,
bottomSheetOffset: offset,
);
},
);
Expand Down Expand Up @@ -98,9 +85,12 @@ class _StandardBottomSheetExampleState
),
),
),
Text(
'position $offset',
style: textTheme.titleLarge,
Padding(
padding: const EdgeInsets.all(8),
child: Text(
'position $offset',
style: textTheme.titleLarge,
),
),
],
),
Expand All @@ -111,7 +101,7 @@ class _StandardBottomSheetExampleState
_children,
);
},
anchors: [.2, 0.5, .8],
anchors: [0.2, 0.5, 0.8],
);
}

Expand All @@ -124,15 +114,15 @@ class _StandardBottomSheetExampleState
ElevatedButton(
onPressed: () => ScaffoldMessenger.of(context).showSnackBar(
const SnackBar(
content: Text("I'm a snackbar"),
content: Text("I'm a SnackBar"),
),
),
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
child: const Text('Show SnackBar'),
),
const SizedBox(height: 20),
const Text(
'To see how to customize the display of the snackbar click on the red button, then the green or blue button. The isRegisterScaffold property is responsible for the behavior',
'To see how to customize the display of the SnackBar click on the red button, then the green or blue button. The isRegisterScaffold property is responsible for the behavior',
textAlign: TextAlign.center,
),
const SizedBox(height: 20),
Expand Down Expand Up @@ -186,21 +176,18 @@ class _BottomSheet extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Padding(
return ListView(
padding: const EdgeInsets.all(16),
child: ListView(
padding: EdgeInsets.zero,
controller: scrollController,
children: [
Text(
'position $bottomSheetOffset',
style: Theme.of(context).textTheme.titleLarge,
),
Column(
children: _children,
),
],
),
controller: scrollController,
children: [
Text(
'position $bottomSheetOffset',
style: Theme.of(context).textTheme.titleLarge,
),
Column(
children: _children,
),
],
);
}
}
Expand All @@ -219,9 +206,9 @@ List<Widget> _children = [
const _TextField(),
const _TestContainer(color: Color(0x9900FF00)),
const _TextField(),
const _TestContainer(color: Color(0x8800FF00)),
const _TestContainer(color: Color(0xFFBD8AFF)),
const _TextField(),
const _TestContainer(color: Color(0x7700FF00)),
const _TestContainer(color: Color(0xFF0078C0)),
const _TextField(),
];

Expand All @@ -234,6 +221,7 @@ class _TextField extends StatelessWidget {
decoration: InputDecoration(
border: InputBorder.none,
hintText: 'Enter a search term',
contentPadding: EdgeInsets.all(8),
),
);
}
Expand All @@ -248,12 +236,10 @@ class _TestContainer extends StatelessWidget {

@override
Widget build(BuildContext context) {
return Padding(
return Container(
padding: const EdgeInsets.all(8),
child: Container(
height: 100,
color: color,
),
height: 100,
color: color,
);
}
}
Loading