jamesblasco / modal_bottom_sheet

Flutter | Create advanced modal bottom sheets. Material, Cupertino or your own style
https://pub.dev/packages/modal_bottom_sheet
MIT License
1.83k stars 461 forks source link

[Sheet] Expands over screen size on keyboard open #370

Open LorenzoMioso opened 10 months ago

LorenzoMioso commented 10 months ago

In not able to figure out why in my project the sheet behaves in this way:

https://github.com/jamesblasco/modal_bottom_sheet/assets/29272035/9d729f3f-cdc5-434b-b470-91fd27de406d

I wrote the following code :

import 'package:flutter/cupertino.dart';
import 'package:sheet/sheet.dart';

class SheetTest extends StatelessWidget {
  const SheetTest({super.key});

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
        child: SheetMediaQuery(
      child: SafeArea(
          child: Padding(
        padding:
            EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
        child: const Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              CupertinoTextField(
                placeholder: 'Enter your name',
              ),
            ]),
      )),
    ));
  }
}
import 'package:flutter/cupertino.dart';
import 'package:sheet/route.dart';

import 'sheet_test.dart';

class TestPage extends StatelessWidget {
  const TestPage({super.key});

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
        child: SafeArea(
            child: Column(children: <Widget>[
      const SizedBox(height: 40),
      CupertinoListTile(
        title: const Text('Test Sheet'),
        onTap: () => Navigator.of(context).push(
          CupertinoSheetRoute<void>(
            builder: (_) => const SheetTest(),
          ),
        ),
      ),
    ])));
  }
}

I tried to put a text field in example project and it works correctly. There are no significant differences between the example and my project, other then that i'm using auto_route (but i doubt its the problem). Any help will be appreciated.

mfrischbutter commented 3 months ago

Thanks for the issue, in my case this was exactly what i wanted :D If i understand correctly you don't want to move when the keyboard shows up? Just remove the padding.

import 'package:flutter/cupertino.dart';
import 'package:sheet/sheet.dart';

class SheetTest extends StatelessWidget {
  const SheetTest({super.key});

  @override
  Widget build(BuildContext context) {
    return CupertinoPageScaffold(
        child: SheetMediaQuery(
      child: SafeArea(
          child: Padding(
        padding:
            // just remove this line, should be working then.
            // EdgeInsets.only(bottom: MediaQuery.of(context).viewInsets.bottom),
        child: const Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              CupertinoTextField(
                placeholder: 'Enter your name',
              ),
            ]),
      )),
    ));
  }
}