Git Product home page Git Product logo

jamesblasco / modal_bottom_sheet Goto Github PK

View Code? Open in Web Editor NEW
1.8K 27.0 454.0 33.07 MB

Flutter | Create advanced modal bottom sheets. Material, Cupertino or your own style

Home Page: https://pub.dev/packages/modal_bottom_sheet

License: MIT License

Kotlin 0.05% Swift 0.47% Objective-C 0.01% Dart 98.17% HTML 0.72% Ruby 0.52% Shell 0.07%
flutter modal-bottom-sheets cupertino material ios13 dart

modal_bottom_sheet's Introduction

A modal bottom sheet for your Flutter app

Awesome Flutter Pub

Check the package README for more information

Sheet (Experimental)

Sheet is a new package that reimplements the modal bottom sheet behavior from scratch. It is expected to be easier to use, more performant, more stable, more customaziable and with more features. It is used in several released apps already. If you want to be part of it, I encourge you to give it a try and provide any feedback you might have :)

modal_bottom_sheet's People

Contributors

alexv525 avatar andyblast avatar bierbaumtim avatar danreynolds avatar dendos avatar droplet-js avatar idkq avatar itome avatar jamesblasco avatar jdebecka avatar joaobentes avatar kitsuniru avatar kvenn avatar lefebvreilyas avatar legoffmael avatar naiksoftware avatar noordawod avatar remonh87 avatar richardshiue avatar rodineijf avatar saltedpotatos avatar seljmov avatar serjobas avatar simchacahn avatar skogsfrae avatar stevchow avatar t-moz avatar troyanskiy avatar yahu1031 avatar zfinix avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

modal_bottom_sheet's Issues

Problem with BouncingScrollPhysics and Modal with inside navigation

1 When you are using a BouncingScrollPhysics and scroll down the screen you see that the scroll startet to go under the borders. I understand why it's going. How I can get around it for make "as native" behawiour? For when I swipe down the window scroll stay at his place

2 If you make Cupertino Modal with inside navigation there will no way to create the next screen in stack with scroll which will afford you to swipe down all the navigation stack. Because scrollController which I receive from builder I can attach to only the first window at navigation stack

22

[Feature request] Set animation curve in constructor

Currently to change the duration of opening animation I have to modify the source code of package (variable _bottomSheetDuration in bottom_sheet_route.dart), and I think there must be an easier way to do it.
Also I didn't find a way to set curve at all.

Getting'_positions.isNotEmpty' Exception when programmatically scrolling inner scroll widget

when i try to programmatically scroll my inner scroll widget

mParentScrollController.animateTo( mParentScrollController.position.minScrollExtent, duration: Duration(milliseconds: 50), curve: Curves.linear);

i get this fatal error when using the library.

mParentScrollController is another scroll controller inside the BarModalBottomSheet that is added to a child scroll widget

ScrollController not attached to any scroll views.

I'm getting an error after upgrading to version 0.2.0

════════ Exception caught by scheduler library ═════════════════════════════════════════════════════
The following assertion was thrown during a scheduler callback:
ScrollController not attached to any scroll views.
'package:flutter/src/widgets/scroll_controller.dart':
Failed assertion: line 110 pos 12: '_positions.isNotEmpty'

When the exception was thrown, this was the stack: 
#2      ScrollController.position (package:flutter/src/widgets/scroll_controller.dart:110:12)
#3      _ModalBottomSheetState._handleScrollUpdate (package:modal_bottom_sheet/src/bottom_sheet.dart:261:46)
#4      _ModalBottomSheetState.build.<anonymous closure>.<anonymous closure>.<anonymous closure> (package:modal_bottom_sheet/src/bottom_sheet.dart:376:27)
#5      NotificationListener._dispatch (package:flutter/src/widgets/notification_listener.dart:129:41)
#6      Notification.visitAncestor (package:flutter/src/widgets/notification_listener.dart:47:20)
...

Bottom Sheet loses data on move

I tried the Bottom sheet with a simple increment integer with a + icon. If I change the state with incrementing a number and I move the bottom sheet, for example sliding a bit down and up, then the new state is lost. It shows me the initial number.

Is this normal that event to close the dialog is fired on moving the sheet? Or is there an error in my code?

By the way: Thanks for your great work!

version 0.2.0+1 breaks with Flutter Beta 1.22.0-12.1.pre

flutter doctor shows:

[✓] Flutter (Channel master, 1.22.0-10.0.pre.109, on Mac OS X 10.15.6 19G2021, locale en-GB)
modal_bottom_sheet: ^0.2.0+1

during compiling, it fail with:

../../../.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet.dart:295:43: Error: Too few positional arguments: 1 required, 0 given.
        _velocityTracker = VelocityTracker();
                                          ^
../../../Sandbox/flutter/packages/flutter/lib/src/gestures/velocity_tracker.dart:152:3: Context: Found this candidate, but the arguments don't match.
  VelocityTracker(this.kind);
  ^^^^^^^^^^^^^^^

Looks like flutter changed the interface:

/// Computes a pointer's velocity based on data from [PointerMoveEvent]s.
///
/// The input data is provided by calling [addPosition]. Adding data is cheap.
///
/// To obtain a velocity, call [getVelocity] or [getVelocityEstimate]. This will
/// compute the velocity based on the data added so far. Only call these when
/// you need to use the velocity, as they are comparatively expensive.
///
/// The quality of the velocity estimation will be better if more data points
/// have been received.
class VelocityTracker {
  /// Create a new velocity tracker for a pointer [kind].
  VelocityTracker(this.kind);

redundant call error

showMaterialModalBottomSheet(
        context: context,
        backgroundColor: Colors.transparent,
        builder: (BuildContext context, sc) {
          // It is called repeatedly many times unnecessarily.
          // Is it only me ?
          return Text("");
        }
    );
  }

Laggy Animation

Hi James,

Thank you for sharing this package, it is something I've been waiting for a long time to implement into my application.

However, I noticed the animation for the generic modal bottom sheet has a very low framerate (laggy). I am not sure if that is an issue caused from my end or not.

This is what the animation looks like on my actual device (not the iOS simulator)

ezgif com-video-to-gif

I'm invoking the modal bottom sheet with the following code:

showCupertinoModalBottomSheet( context: context, builder: (context, scrollController) => Container(), })

What are your thoughts?

Cheers!

How to dismiss the sheet manually if there is navigation inside?

Understand that normally we use Navigator.of(context).pop(); to dismiss the modal sheet.

However in my case, there is navigation inside the modal sheet. So, using Navigator.of(context).pop(); will only return to the previous page of the sheet.

I tried to google and use methods such as Navigator.of(context).popUntil((route) => route.isFirst); but still fail.

Anyone can shed some light on this? Many thanks.

Compile Error

Hello I am facing questions when building the app,
截屏2020-06-01 上午10 39 41
截屏2020-06-01 上午10 40 07
截屏2020-06-01 上午10 40 38

Compile error after importing the library

After installing the library and trying out the example simple show alert code, the code does not compile.
I get the following error

Compiler message: ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet.dart:184:3: Error: Type 'ParametricCurve' not found. ParametricCurve<double> animationCurve; ^^^^^^^^^^^^^^^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet.dart:184:3: Error: Expected 0 type arguments. ParametricCurve<double> animationCurve; ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet.dart:318:3: Error: Type 'ParametricCurve' not found. ParametricCurve<double> get _defaultCurve => ^^^^^^^^^^^^^^^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet.dart:318:3: Error: Expected 0 type arguments. ParametricCurve<double> get _defaultCurve => ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/utils/bottom_sheet_suspended_curve.dart:28:41: Error: Type 'ParametricCurve' not found. class BottomSheetSuspendedCurve extends ParametricCurve<double> { ^^^^^^^^^^^^^^^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/utils/bottom_sheet_suspended_curve.dart:28:41: Error: Expected 0 type arguments. class BottomSheetSuspendedCurve extends ParametricCurve<double> { ^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet.dart:184:3: Error: 'ParametricCurve' isn't a type. ParametricCurve<double> animationCurve; ^^^^^^^^^^^^^^^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet_route.dart:42:27: Error: Getter not found: 'linux'. case TargetPlatform.linux: ^^^^^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet_route.dart:43:27: Error: Getter not found: 'macOS'. case TargetPlatform.macOS: ^^^^^ ../../../flutter/.pub-cache/hosted/pub.dartlang.org/modal_bottom_sheet-0.2.0+1/lib/src/bottom_sheet_route.dart:44:27: Error: Getter not found: 'windows'. case TargetPlatform.windows: ^^^^^^^ Target kernel_snapshot failed: Exception: Errors during snapshot creation: null Failed to build bundle. Error launching application on iPhone 8.

This is how I am using it:

showCupertinoModalBottomSheet(
context: context,
builder: (context, scrollController) => MySuperPage(),
);

Doesn't go back to the top sometimes

Almost perfect except :

  1. sometimes when I let ago while dragging,
    the sheet doesn't go back to the top and just stops there. It happens quite frequently.

  2. The animation curve is ugly.
    Please provide a parameter to pass the animation curve. Haven't read the code but is this related to PageRoute ?

  3. Provide a parameter for the dismiss threshold.
    Personally, I feel it's a bit hard to dismiss. I prefer it easier to dismiss.

I am using dev channel of flutter.

Gif:
issue01

Regards
Hiroshi

run : example/lib/main.dart /// there is a issue.

warning code :
error: The method 'forgetChild' is always abstract in the supertype. (abstract_super_member_reference at [example] lib/examples/sliver_container.dart:72)

i cant run because of this problem and i cant use it another app also.
i hope you can find a solution. i already tried and i lost in lines because Solution hide from me because of code is belong you.

showBarModalBottomSheet does not adjust size on keyboard open

This is an my modal sheet:

    String _prevText =
        await Provider.of<FirebaseDataProvider>(context, listen: false)
            .getMarquee();
    TextEditingController _marqueeController =
        TextEditingController(text: _prevText);
    return showBarModalBottomSheet(
        context: context,
        expand: true,
        builder: (BuildContext context, ScrollController scrollController) {
          return Material(
            child: Container(
              // height: MediaQuery.of(context).size.height * 0.3,
              color: Theme.of(context).colorScheme.primary,
              child: Padding(
                padding: const EdgeInsets.all(12.0),
                child: ListView(
                  controller: scrollController,
                  shrinkWrap: true,
                  children: <Widget>[
                    AutoSizeText(
                      title,
                      style: TextStyle(
                          color: Theme.of(context).colorScheme.onPrimary),
                    ),
                    TextField(
                      decoration: InputDecoration(hintText: 'escribe aquí'),
                      controller: _marqueeController,
                      autofocus: true,
                    ),
                    FlatButton(
                      color: Colors.green,
                      child: AutoSizeText(
                        'OK',
                        style: TextStyle(color: Colors.white),
                      ),
                      onPressed: () {
                        Provider.of<FirebaseDataProvider>(context,
                                listen: false)
                            .setMarquee(_marqueeController.text);
                        Navigator.of(context).pop();
                      },
                    ),
                    FlatButton(
                      color: Colors.red,
                      child: AutoSizeText(
                        'Cancelar',
                        style: TextStyle(color: Colors.white),
                      ),
                      onPressed: () {
                        Navigator.of(context).pop();
                      },
                    ),
                  ],
                ),
              ),
            ),
          );
        });
  }
} 

So right now I have to fix the height to mediaquery * 0.6 so that keyboard does not interfere with textfileld inside the modal sheet. But I would really like for the size to change depending on the keyboard size.

I am going to attach a few pictures representing expand setting with and without keyboard...

expand_false_no_kb
expand_false_no_kb

expand_false_with_kb
expand_false_with_kb

expand_true_no_kb
expand_true_no_kb

expand_true_with_kb
expand_true_with_kb

Expose on popped API on showCupertinoModalBottomSheet

I need to run a specific function when the modal sheet is closed or return some value,
So is it possible to expose some API from CupertinoModalBottomSheetRoute which is rendered in showCupertinoModalBottomSheet

await showCupertinoModalBottomSheet(
	context: context,
	builder: (context, scrollController) => Container();
	popped: () {
       print('Modal is closed')
	}
);

or
the return value from widget which is rendered

T result = await showCupertinoModalBottomSheet<T>(
	context: context,
	builder: (context, scrollController) => Container();
);

Unexpected behavior of the bottom sheet with nested scrollables

Problem:
If you put nested scrollables inside the bottom sheet, then the scroll controller will handle scroll notifications from both of it.
It leads to unexpected behavior f.e. when you have a parent vertical scrollable and put a horizontal scrollable in it.
In this way, if you scroll the horizontal scrollable to the start then the sheet will handle scroll notifications, start tracking your gestures and try to close the sheet.

Solution description:
According to Flutter Docs, it may be fixed very easily (I hope) by adding one line of code.

Notifications bubble up through the tree, which means a given NotificationListener will receive notifications for all descendant Scrollable widgets. To focus on notifications from the nearest Scrollable descendant, check that the depth property of the notification is zero.

Solution:
So you can just add here notification.depth==0 to handle notification only from the top scrollable widget.

Could I call some method for closing the modal?

I call showMaterialModalBottomSheet. There are radio group buttons. I want to close the modal sheet when radio is tabbed. Is there any method for closing manually? Sometimes people need to close the sheet by calling function. Looking forward to your answer.

Floating modal, why no gap at the bottom

Hi,

I follow exactly the example code for the floating modal, however, there is different that my one does not have a gap at the bottom, may I know what am I missing?

My example:
image

Package example:
image

Unexpected shadow at the top of modal sheet

Hello guys,

When my modal sheet pops up, there is some unexpected shadow at the top. I tried "elevation: 0" but it doesn't work. Any one could shed some light on dealing with this? Thanks a lot!

image

How to add Padding?

Hello!

Can you please tell me how Padding can be applied for the whole bottomSheetDialog?
For example, I need to add padding from left/right and make it transparent from the sides.

thanks!

Question: Possible to remove background of new modal?

Hi,

Great stuff!

Is it possible to set the background of the new modal to complete transparency? I'm planning to use the barrierColor to make the whole background a little greyed out instead.

(CustomAdd() contains a top padding)

Right now I'm using modal_bottom_sheet 0.2.0+1 from https://pub.dev/packages/modal_bottom_sheet

Screenshot 2020-09-09 at 14 55 42

  CupertinoScaffold.showCupertinoModalBottomSheet(
    expand: true,
    context: context,
    backgroundColor: Colors.transparent,
    builder: (context, scrollController) => Material(
      child: CustomAdd(),
      color: Colors.transparent,
    ),
  );

Best regards

Please provide an example on how to use this library without routes

I would like to use this library by skipping the show__Sheet method and rendering the modal directly.

I understand that ModalBottomSheet documentation says it is 'rarely used directly', but can it be?

So far I have tried returning simply with a ModalBottomSheet, but nothing appears on the screen.

Before spending more time on this, I though I would ask if this is even possible and if so, is there an example somewhere for it?

Thank you

The getter 'animation' was called on null.

RaisedButton(
     child: const Text('Action'),
     onPressed: () {
         CupertinoScaffold.showCupertinoModalBottomSheet(
            context: context, 
            builder:(context, scrollController) => Container()
         );
     },
),

Multiple different heights

Hello, this is a great component. I fell in love with it at the first sight. I hope I can use it all the time.

I have a requirement now. I want content to show different styles at different heights. However, I use the modal_bottom_sheet to find that either close or display can't slide to different heights.

Maybe I don't know how to use it, or it needs some updates.

Thank you.

show the modal with 70% of the width

Hello, how are you? i would like to know if there is a possibility to show the modal with an specific width proporcional of the screen device, now is using by default the full widht of the screen.

How to properly dismiss the modal & how to make edges of CupertinoModalBottomSheet more round

Hi, I tried to dismiss the modal with a button press within the modal (#24) by calling Navigator.of(context).pop() but when I do, the modal shows an animation of going back to a previous screen within the modal (a plain blank modal) instead of being dismissed. It then shows this error in my console:
flutter: Another exception was thrown: 'package:flutter/src/widgets/navigator.dart': Failed assertion: line 3803 pos 12: '_history.isNotEmpty': is not true.
I'm using showCupertinoModalBottomSheet to be able to have navigation within the modal.

In addition, when I call showCupertinoModalBottomSheet I'm also supplying the shape parameter.

                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.circular(50)),
              ...

No matter what value I put in BorderRadius.circular(), the radius of the edges of my modal stays the same. Any insight would be appreciated!

iOS StatusBar color behaves wrong with CupertinoScaffold

The iOS status bar color should usually stay the same. However one I surround my CupertinoPageScaffold with CupertinoScaffold. It changes its default color to white (on white background).

CupertinoApp(
     home: CupertinoScaffold(
        body: CupertinoPageScaffold(
          child: Container(),
        ),
      ),
);

Although this works fine:

CupertinoApp(
     home: CupertinoPageScaffold(
       child: Container(),
     ),
);

Modal package not found

It's not really an issue, but you used and imported this modal folder in your main.dart example.
Please where in flutter sdk is this folder located ?
Screenshot 2020-06-17 at PM 8 18 14

Open showBarModalBottomSheet with CupertinoScaffold

First of all: I love your plugin. Thanks for your good work!

Just a question. I would like to use the Bar version of the BottomSheet (showBarModalBottomSheet). But for the transition of the previous route I have to use it with CupertinoScaffold.showCupertinoModalBottomSheet. There I can use only the basic version of the Modal, right?

How can I use the bar-version here? I have no specific route for my Bottom Sheet. I open it like that:

class MinistryReportHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
        backgroundColor: Colors.white,
        navigationBar: CupertinoNavigationBar(
          middle: Text("Juni 2020",
              style: Theme.of(context).appBarTheme.textTheme.headline1),
          backgroundColor: Theme.of(context).primaryColor,
        ),
        child: CupertinoScaffold(
          body: Container(
            color: Theme.of(context)
                .cupertinoOverrideTheme
                .scaffoldBackgroundColor,
            child: new Builder(
              builder: (context) => SafeArea(
                child: Column(
                    mainAxisAlignment: MainAxisAlignment.spaceBetween,
                    children: [
                      HomeSummary(),
                      FloatingActionButton(
                          child: Icon(Icons.add),
                          backgroundColor: Theme.of(context).primaryColor,
                          onPressed: () =>
                              CupertinoScaffold.showCupertinoModalBottomSheet(
                                  duration: Duration(milliseconds: 350),
                                  context: context,
                                  builder: (context, scrollController) =>
                                      AddReportDataDialog(scrollController))),
                    ]),
              ),
            ),
          ),
        ));
  }
}

Thanks so much for your help! :)

ScrollController not attached to any scroll views

Hi. First of all, thank you for this awesome library.
I've encountered an issue. When I ignore scrollController, which is passed as the second argument in build function, and my page uses any widget with its own scroll controller. I get this exception:
VERBOSE-2:ui_dart_state.cc(157)] Unhandled Exception: 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12: '_positions.isNotEmpty': ScrollController not attached to any scroll views.

Here is the code:

import 'package:flutter/material.dart';
import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      onGenerateRoute: (settings) {
        return MaterialWithModalsPageRoute(builder: (_) => MyHomePage());
      },
      initialRoute: '/',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      // home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);
  final String title;
  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Title'),
      ),
      body: Center(child: Container()),
      floatingActionButton: FloatingActionButton(
        onPressed: () => showCupertinoModalBottomSheet(
            context: context,
            builder: (context, _) => Scaffold(
                  body: Center(
                    child: TextField(),
                  ),
                )),
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), 
    );
  }
}

Here is example repo
Steps to reproduce:

  1. Run the app
  2. Click on the floating action button to open modal view
  3. Click on the text input

As far as I can understand, every scroll controller has to be attached to some widget. When we focus on text input, all scroll controllers are triggered, even the one, passed via build function. It is not attached, so I get an error.
As a workaround, I've created a dummy widget and attach the controller to it.
In my opinion, this should be done internally in the library

Webview not scrolling inside the modal

Webviews do not scroll inside the modal

showModalBottomSheet( context: context, builder: (builder) { return new Container( height: MediaQuery.of(context).size.height / 4, child: new Container( decoration: new BoxDecoration(color: Colors.amber, borderRadius: new BorderRadius.only(topLeft: const Radius.circular(20.0), topRight: const Radius.circular(20.0))), child: Container( child: WebView( initialUrl: 'https://google.com', )), ), ); }, );

Bottom Sheet not closes when using SliverList inside

I´m using your Bottom Sheet like this:

 GestureDetector(
                        onTap: () => showBarModalBottomSheet(
                            expand: true,
                            context: context,
                            builder: (context, scr) => HoursScreen(scr)),
                        child: MinistryReportChart(
                            mainValue: minutesData.getSum())),

Bottom Sheet Class:

class HoursScreen extends StatelessWidget {
  final ScrollController scrollController;

  HoursScreen(this.scrollController);

  @override
  Widget build(BuildContext context) {
    final minutesData = Provider.of<Minutes>(context);

    return Material(
      child: CupertinoPageScaffold(
          child: FutureBuilder<List<Minute>>(
        future: minutesData.getAll(), // async work
        builder: (BuildContext context, AsyncSnapshot<dynamic> snapshot) {
          switch (snapshot.connectionState) {
            case ConnectionState.waiting:
              return Center(
                child: CircularProgressIndicator(),
              );
            default:
              if (snapshot.hasError) {
                return new Text('Error: ${snapshot.error}');
              } else
                return CustomScrollView(
                  physics: ClampingScrollPhysics(),
                  controller: scrollController,
                  slivers: <Widget>[
                    CupertinoSliverNavigationBar(
                        largeTitle: Text("Stunden"),
                        border: Border.fromBorderSide(
                            BorderSide(color: Colors.transparent))),
                    SliverList(
                      delegate: SliverChildBuilderDelegate(
                        // The builder function returns a ListTile with a title that
                        // displays the index of the current item.
                        (context, index) => Column(
                          children: <Widget>[
                            ListTile(
                              leading: Column(
                                mainAxisAlignment: MainAxisAlignment.center,
                                children: <Widget>[
                                  Icon(
                                    Icons.timer,
                                    color: Theme.of(context).primaryColor,
                                  ),
                                ],
                              ),
                              trailing: Container(
                                width: 50,
                                child: Row(
                                  crossAxisAlignment: CrossAxisAlignment.center,
                                  children: <Widget>[
                                    IconButton(
                                        icon: Icon(Icons.edit), onPressed: null)
                                  ],
                                ),
                              ),
                              title: Text(
                                  snapshot.data[index].value.toString() +
                                      " Stunden"),
                              subtitle: Text(DateFormat("dd.MM.yyyy, HH:mm")
                                  .format(snapshot.data[index].timestamp
                                      .toDateTime())
                                  .toString()),
                            ),
                            Divider()
                          ],
                        ),
                        // Builds 1000 ListTiles
                        childCount: snapshot.data.length,
                      ),
                    ),
                  ],
                );
          }
        },
      )),
    );
  }
}

There are 2 issues:

  1. The App Bar shows a back button. Can I disable this in your Modal?
  2. I can not close the Bottom sheet by swiping the list at the bottom. It closes laggy only 10-15 pixels, then it stops. I think thats a problem with Sliverlist and physics: ClampingScrollPhysics(),

What do you think? Thanks in advance!

Rebuild

When sliding the sheet, it will always cause reconstruction,
In some cases this can cause performance issues 😢

Create a draggable bottom sheet with a sticky header

I need to have a draggable bottom sheet with a sticky header.

A quick solution is something like this:

Material(
        child: Container(
          padding: EdgeInsets.only(left: 16, right: 16, top: 16),
          decoration: BoxDecoration(
            borderRadius: const BorderRadius.all(Radius.circular(12)),
            color: backgroundColor,
          ),
          height: deviceHeight*bottomSheetHeightFraction,
          child: SingleChildScrollView(
            controller: widget.scrollController,
            child: Column(
              children: [
                Row(
                  mainAxisAlignment: MainAxisAlignment.end,
                  children: [
                    GestureDetector(
                      onVerticalDragUpdate: (details) {
                        setState(() {
                          var move = details.primaryDelta;
                          var height = (deviceHeight*bottomSheetHeightFraction - move).clamp(deviceHeight*0.3, deviceHeight*0.8);
                          setState(() {
                            bottomSheetHeightFraction = (height/deviceHeight).clamp(0.3, 0.8);
                          });
                        });
                      },
                      child: Icon(IconProvider.arrow_move_up, size: defaultIconSize, color: defaultIconColor),
                    ),
                  ],
                ),
                ...List.generate(25, (index) => ListTile(title: Text('List Tile $index', style: TextStyle(color: Colors.white),))),
              ],
            ),
          )
        )
      ),

and then calling route generator

showMaterialModalBottomSheet(
                        expand: false,
                        context: context,
                        backgroundColor: Colors.transparent,
                        builder: (context, scrollController) => ......
                      );

The problem is that the top row is of course not sticky.

If I create a column and inside of it a scrollable list then I get a bottom overflow.

How can this be done? Is there something in the library to cope with this ??

Showing CupertinoModalBottomSheet from floating action button

Hi!

I have a question related to using this with a FAB, in this case if I run CupertinoScaffold.showCupertinoModalBottomSheet() in its onPressed()-method, it will not have the CupertinoScaffold as a parent. Do you have any idea how to solve this?

Best regards

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      drawer: CustomDrawerMenu(),
      key: _scaffoldKey,
      body: CupertinoScaffold(
        body: Builder(
          builder: (context) => CupertinoPageScaffold(
            backgroundColor: Colors.white,
            child: getMainContent(),
          ),
        ),
      ),
      floatingActionButton: CustomFAB(
          size: 65.0,
        ),
      ),
      floatingActionButtonLocation: FloatingActionButtonLocation.centerFloat,
    );
  }

Great on Phone, not so on Tablet

This is an amazing package for use on the phone. However, it doesn't translate well on a tablet. Instead of animating the previous route, I just want to have a simpler sheet to show.

I tried setting backgroundColor to Colors.black12 and the bottom sheet route to have padding, but the boxShadow is still visible.

BoxShadow(blurRadius: 10, color: Colors.black12, spreadRadius: 5);

This is what I am trying to match:

Form Sheet
Reference: https://medium.com/@hacknicity/view-controller-presentation-changes-in-ios-13-ac8c901ebc4e

Bar modal breaks Text() inside

This:

  showBarModalBottomSheet(
    context: context,
    builder: (context, scrollController) =>
        Container(
          child: Row(
            mainAxisAlignment: MainAxisAlignment.spaceBetween,
            children: [
              Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  Text("dfsddfd")
                ],
              ),
              Column(
                mainAxisSize: MainAxisSize.min,
                children: [
                  RaisedButton(
                    child: Text('edit').tr(),
                    onPressed: () {

                    },
                  ),
                  FlatButton(
                    child: Text('changeOrdering').tr(),
                    onPressed: () {

                    },
                  )
                ],
              )
            ],
          ),
        ),
  );

Produces:
Screenshot_1598831265

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.