martinrybak / keyboard_avoider

A lightweight alternative to the Scaffold widget for avoiding the on-screen software keyboard. Automatically scrolls obscured TextField child widgets into view on focus.
https://medium.com/flutter-nyc/avoiding-the-on-screen-keyboard-in-flutter-ae0e46ecb96c
MIT License
118 stars 41 forks source link

Error on CupertinoApp #2

Closed mateusfsilva closed 5 years ago

mateusfsilva commented 5 years ago

Hi,

I have the following layout on a CupertinoApp and I am trying to add the keyboard_avoider to scroll the TextFields.

Simulator Screen Shot - iPhone Xs - 2019-05-30 at 12 28 05

When I add the KeyboardAvoider widget I have the following error:

Launching lib/main.dart on iPhone Xs in debug mode...
Xcode build done.                                            6,8s
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following message was thrown during layout:
flutter: A RenderFlex overflowed by 97 pixels on the bottom.
flutter:
flutter: The overflowing RenderFlex has an orientation of Axis.vertical.
flutter: The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and
flutter: black striped pattern. This is usually caused by the contents being too big for the RenderFlex.
flutter: Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the
flutter: RenderFlex to fit within the available space instead of being sized to their natural size.
flutter: This is considered an error condition because it indicates that there is content that cannot be
flutter: seen. If the content is legitimately bigger than the available space, consider clipping it with a
flutter: ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex,
flutter: like a ListView.
flutter: The specific RenderFlex in question is:
flutter:   RenderFlex#550cc relayoutBoundary=up4 OVERFLOWING
flutter:   creator: Column ← Padding ← MediaQuery ← Padding ← SafeArea ← Padding ← MediaQuery ←
flutter:   PrimaryScrollController ← Stack ← DecoratedBox ← CupertinoPageScaffold ← MyWidget ← ⋯
flutter:   parentData: offset=Offset(0.0, 25.0) (can use size)
flutter:   constraints: BoxConstraints(0.0<=w<=375.0, 0.0<=h<=383.0)
flutter:   size: Size(375.0, 383.0)
flutter:   direction: vertical
flutter:   mainAxisAlignment: start
flutter:   mainAxisSize: max
flutter:   crossAxisAlignment: stretch
flutter:   verticalDirection: down
flutter: ◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
flutter: The following assertion was thrown during performLayout():
flutter: RenderFlex children have non-zero flex but incoming height constraints are unbounded.
flutter: When a column is in a parent that does not provide a finite height constraint, for example if it is
flutter: in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
flutter: flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
flutter: space in the vertical direction.
flutter: These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
flutter: cannot simultaneously expand to fit its parent.
flutter: Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
flutter: children (using Flexible rather than Expanded). This will allow the flexible children to size
flutter: themselves to less than the infinite remaining space they would otherwise be forced to take, and
flutter: then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
flutter: constraints provided by the parent.
flutter: The affected RenderFlex is:
flutter:   RenderFlex#435aa relayoutBoundary=up14 NEEDS-LAYOUT NEEDS-PAINT
flutter: The creator information is set to:
flutter:   Column ← ConstrainedBox ← _SingleChildViewport ← IgnorePointer-[GlobalKey#ef658] ← Semantics ←
flutter:   Listener ← _GestureSemantics ←
flutter:   RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#d6466] ← Listener ← _ScrollableScope
flutter:   ← _ScrollSemantics-[GlobalKey#3d42b] ← Scrollable ← ⋯
flutter: The nearest ancestor providing an unbounded width constraint is:
flutter:   _RenderSingleChildViewport#87742 relayoutBoundary=up12 NEEDS-LAYOUT NEEDS-PAINT
flutter:   creator: _SingleChildViewport ← IgnorePointer-[GlobalKey#ef658] ← Semantics ← Listener ←
flutter:   _GestureSemantics ← RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#d6466] ←
flutter:   Listener ← _ScrollableScope ← _ScrollSemantics-[GlobalKey#3d42b] ← Scrollable ←
flutter:   SingleChildScrollView ← LayoutBuilder ← ⋯
flutter:   parentData: <none> (can use size)
flutter:   constraints: BoxConstraints(0.0<=w<=375.0, 0.0<=h<=640.0)
flutter:   size: MISSING
flutter: See also: https://flutter.dev/layout/
flutter: If this message did not help you determine the problem, consider using debugDumpRenderTree():
flutter:   https://flutter.dev/debugging/#rendering-layer
flutter:   http://docs.flutter.io/flutter/rendering/debugDumpRenderTree.html
flutter: If none of the above helps enough to fix this problem, please don't hesitate to file a bug:
flutter:   https://github.com/flutter/flutter/issues/new?template=BUG.md
flutter:
flutter: When the exception was thrown, this was the stack:
flutter: #0      RenderFlex.performLayout.<anonymous closure> 
flutter: #1      RenderFlex.performLayout 
flutter: #2      RenderObject.layout 
flutter: #3      RenderConstrainedBox.performLayout 
flutter: #4      RenderObject.layout 
flutter: #5      _RenderSingleChildViewport.performLayout 
flutter: #6      RenderObject.layout 
flutter: #7      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #8      RenderObject.layout 
flutter: #9      _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #10     RenderObject.layout 
flutter: #11     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #12     RenderObject.layout 
flutter: #13     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #14     RenderObject.layout 
flutter: #15     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #16     RenderObject.layout 
flutter: #17     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #18     RenderObject.layout 
flutter: #19     _RenderLayoutBuilder.performLayout 
flutter: #20     RenderObject.layout 
flutter: #21     RenderPadding.performLayout 
flutter: #22     RenderObject.layout 
flutter: #23     RenderPadding.performLayout 
flutter: #24     RenderObject.layout 
flutter: #25     RenderPadding.performLayout 
flutter: #26     RenderObject.layout 
flutter: #27     RenderPadding.performLayout 
flutter: #28     RenderObject.layout 
flutter: #29     RenderStack.performLayout 
flutter: #30     RenderObject.layout 
flutter: #31     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #32     RenderObject.layout 
flutter: #33     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #34     RenderObject.layout 
flutter: #35     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #36     RenderObject.layout 
flutter: #37     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #38     RenderObject.layout 
flutter: #39     RenderStack.performLayout 
flutter: #40     RenderObject.layout 
flutter: #41     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #42     RenderObject.layout 
flutter: #43     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #44     RenderObject.layout 
flutter: #45     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #46     RenderObject.layout 
flutter: #47     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #48     RenderObject.layout 
flutter: #49     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #50     RenderObject.layout 
flutter: #51     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #52     RenderOffstage.performLayout 
flutter: #53     RenderObject.layout 
flutter: #54     RenderStack.performLayout 
flutter: #55     RenderObject.layout 
flutter: #56     __RenderTheatre&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #57     RenderObject.layout 
flutter: #58     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #59     RenderObject.layout 
flutter: #60     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #61     RenderObject.layout 
flutter: #62     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #63     RenderObject.layout 
flutter: #64     _RenderProxyBox&RenderBox&RenderObjectWithChildMixin&RenderProxyBoxMixin.performLayout 
flutter: #65     RenderObject.layout 
flutter: #66     RenderView.performLayout 
flutter: #67     RenderObject._layoutWithoutResize 
flutter: #68     PipelineOwner.flushLayout 
flutter: #69     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding.drawFrame 
flutter: #70     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame 
flutter: #71     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback 
flutter: #72     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback 
flutter: #73     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame 
flutter: #74     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> 
flutter: #76     _Timer._runTimers  (dart:isolate-patch/timer_impl.dart:382:19)
flutter: #77     _Timer._handleMessage  (dart:isolate-patch/timer_impl.dart:416:5)
flutter: #78     _RawReceivePortImpl._handleMessage  (dart:isolate-patch/isolate_patch.dart:171:12)
flutter: (elided one frame from package dart:async-patch)
flutter:
flutter: The following RenderObject was being processed when the exception was fired:
flutter:   RenderFlex#435aa relayoutBoundary=up14 NEEDS-LAYOUT NEEDS-PAINT
flutter:   creator: Column ← ConstrainedBox ← _SingleChildViewport ← IgnorePointer-[GlobalKey#ef658] ←
flutter:   Semantics ← Listener ← _GestureSemantics ←
flutter:   RawGestureDetector-[LabeledGlobalKey<RawGestureDetectorState>#d6466] ← Listener ← _ScrollableScope
flutter:   ← _ScrollSemantics-[GlobalKey#3d42b] ← Scrollable ← ⋯
flutter:   parentData: <none> (can use size)
flutter:   constraints: BoxConstraints(0.0<=w<=375.0, 640.0<=h<=Infinity)
flutter:   size: MISSING
flutter:   direction: vertical
flutter:   mainAxisAlignment: start
flutter:   mainAxisSize: max
flutter:   crossAxisAlignment: stretch
flutter:   verticalDirection: down
flutter: This RenderObject had the following descendants (showing up to depth 5):
flutter:   RenderPadding#1d1e4 relayoutBoundary=up15 NEEDS-PAINT
flutter:     RenderLimitedBox#8b8e0 relayoutBoundary=up16 NEEDS-PAINT
flutter:       RenderCustomPaint#c34fb relayoutBoundary=up17 NEEDS-PAINT
flutter:   RenderPadding#be360 relayoutBoundary=up15 NEEDS-PAINT
flutter:     RenderSemanticsAnnotations#7082f relayoutBoundary=up16 NEEDS-PAINT
flutter:       RenderIgnorePointer#d8bfb relayoutBoundary=up17 NEEDS-PAINT
flutter:         RenderDecoratedBox#f5c19 relayoutBoundary=up18 NEEDS-PAINT
flutter:           RenderPadding#86287 relayoutBoundary=up19 NEEDS-PAINT
flutter:   RenderPadding#1f407 relayoutBoundary=up15 NEEDS-PAINT
Reloaded 2 of 343 libraries in 346ms.
flutter:     RenderSemanticsAnnotations#7619a relayoutBoundary=up16 NEEDS-PAINT
flutter:       RenderIgnorePointer#fd1ba relayoutBoundary=up17 NEEDS-PAINT
flutter:         RenderDecoratedBox#02cce relayoutBoundary=up18 NEEDS-PAINT
flutter:           RenderPadding#4487a relayoutBoundary=up19 NEEDS-PAINT
flutter:   RenderPadding#0f32b relayoutBoundary=up15 NEEDS-PAINT
flutter:     RenderSemanticsAnnotations#99b22 relayoutBoundary=up16 NEEDS-PAINT
flutter:       RenderIgnorePointer#d5c23 relayoutBoundary=up17 NEEDS-PAINT
flutter:         RenderDecoratedBox#e3d8a relayoutBoundary=up18 NEEDS-PAINT
flutter:           RenderPadding#073ac relayoutBoundary=up19 NEEDS-PAINT
flutter:   RenderPadding#47695 relayoutBoundary=up15 NEEDS-PAINT
flutter:     RenderSemanticsAnnotations#ede08 relayoutBoundary=up16 NEEDS-PAINT
flutter:       RenderIgnorePointer#75445 relayoutBoundary=up17 NEEDS-PAINT
flutter:         RenderDecoratedBox#c9a60 relayoutBoundary=up18 NEEDS-PAINT
flutter:           RenderPadding#95192 relayoutBoundary=up19 NEEDS-PAINT
flutter:   RenderPadding#436d5 relayoutBoundary=up15 NEEDS-PAINT
flutter:     RenderSemanticsAnnotations#7df92 relayoutBoundary=up16 NEEDS-PAINT
flutter:       RenderIgnorePointer#7db5c relayoutBoundary=up17 NEEDS-PAINT
flutter:         RenderDecoratedBox#85e2c relayoutBoundary=up18 NEEDS-PAINT
flutter:           RenderPadding#ff8a3 relayoutBoundary=up19 NEEDS-PAINT
flutter: ════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: Another exception was thrown: RenderBox was not laid out: RenderFlex#435aa relayoutBoundary=up14 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderConstrainedBox#e9a91 relayoutBoundary=up13 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#87742 relayoutBoundary=up12 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderIgnorePointer#7b37f relayoutBoundary=up11 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#3ac56 relayoutBoundary=up10 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#173f1 relayoutBoundary=up9 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#a7243 relayoutBoundary=up8 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPointerListener#d1336 relayoutBoundary=up7 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderScrollSemantics#f9f89 relayoutBoundary=up6 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderLayoutBuilder#55b14 relayoutBoundary=up5 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: RenderPadding#7a0f7 relayoutBoundary=up4 NEEDS-PAINT
flutter: Another exception was thrown: RenderBox was not laid out: _RenderSingleChildViewport#87742 relayoutBoundary=up12 NEEDS-PAINT
flutter: Another exception was thrown: Updated layout information required for RenderPositionedBox#b19dd NEEDS-LAYOUT NEEDS-PAINT to calculate semantics.

I am using the following code to make the app.

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

void main() => runApp(
      const MyApp(),
    );

class MyApp extends StatelessWidget {
  const MyApp() : super();

  @override
  Widget build(BuildContext context) => CupertinoApp(
        debugShowCheckedModeBanner: false,
        home: const MyWidget(),
        title: 'Test Actions Keyboard',
      );
}

class MyWidget extends StatefulWidget {
  const MyWidget() : super();

  static const Key textFieldKey01 = Key('textFieldKey01');
  static const Key textFieldKey02 = Key('textFieldKey02');
  static const Key textFieldKey03 = Key('textFieldKey03');
  static const Key textFieldKey04 = Key('textFieldKey04');
  static const Key textFieldKey05 = Key('textFieldKey05');

  @override
  State<MyWidget> createState() => _MyWidgetState();
}

class _MyWidgetState extends State<MyWidget> {
  FocusNode focusNode01;
  TextEditingController controller01;
  FocusNode focusNode02;
  TextEditingController controller02;
  FocusNode focusNode03;
  TextEditingController controller03;
  FocusNode focusNode04;
  TextEditingController controller04;
  FocusNode focusNode05;
  TextEditingController controller05;

  @override
  void initState() {
    super.initState();

    focusNode01 = FocusNode();
    controller01 = TextEditingController();
    focusNode02 = FocusNode();
    controller02 = TextEditingController();
    focusNode03 = FocusNode();
    controller03 = TextEditingController();
    focusNode04 = FocusNode();
    controller04 = TextEditingController();
    focusNode05 = FocusNode();
    controller05 = TextEditingController();
  }

  Widget _createTextField({
    @required Key key,
    @required FocusNode focusNode,
    @required TextEditingController controller,
    @required ValueChanged<String> onSubmitted,
    TextInputAction textInputAction = TextInputAction.next,
  }) =>
      Padding(
        padding: const EdgeInsets.symmetric(
          vertical: 5.0,
          horizontal: 25.0,
        ),
        child: CupertinoTextField(
          key: key,
          controller: controller,
          focusNode: focusNode,
          clearButtonMode: OverlayVisibilityMode.editing,
          keyboardType: TextInputType.text,
          textInputAction: textInputAction,
          autofocus: false,
          autocorrect: false,
          maxLength: 50,
          onSubmitted: onSubmitted,
        ),
      );

  @override
  Widget build(BuildContext context) => CupertinoPageScaffold(
        navigationBar: CupertinoNavigationBar(
          middle: const Text(
            'Keyboard Avoider',
          ),
        ),
        backgroundColor: CupertinoColors.white,
        child: SafeArea(
          child: Padding(
            padding: const EdgeInsets.symmetric(
              vertical: 25.0,
            ),
            // child: KeyboardAvoider(
            //   autoScroll: true,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              children: <Widget>[
                const Padding(
                  padding: EdgeInsets.symmetric(
                    vertical: 10.0,
                    horizontal: 25.0,
                  ),
                  child: Placeholder(
                    fallbackHeight: 250.0,
                  ),
                ),
                _createTextField(
                  key: MyWidget.textFieldKey01,
                  focusNode: focusNode01,
                  controller: controller01,
                  onSubmitted: (_) {
                    FocusScope.of(context).requestFocus(focusNode02);
                  },
                ),
                _createTextField(
                  key: MyWidget.textFieldKey02,
                  focusNode: focusNode02,
                  controller: controller02,
                  onSubmitted: (_) {
                    FocusScope.of(context).requestFocus(focusNode03);
                  },
                ),
                _createTextField(
                  key: MyWidget.textFieldKey03,
                  focusNode: focusNode03,
                  controller: controller03,
                  onSubmitted: (_) {
                    FocusScope.of(context).requestFocus(focusNode04);
                  },
                ),
                _createTextField(
                  key: MyWidget.textFieldKey04,
                  focusNode: focusNode04,
                  controller: controller04,
                  onSubmitted: (_) {
                    FocusScope.of(context).requestFocus(focusNode05);
                  },
                ),
                _createTextField(
                  key: MyWidget.textFieldKey05,
                  focusNode: focusNode05,
                  controller: controller05,
                  onSubmitted: (_) {
                    FocusScope.of(context).requestFocus(focusNode01);
                  },
                ),
                Expanded(
                  child: Container(
                    child: Container(
                      alignment: Alignment.bottomCenter,
                      child: Padding(
                        padding: const EdgeInsets.symmetric(
                          vertical: 10.0,
                          horizontal: 25.0,
                        ),
                        child: CupertinoButton(
                          color: CupertinoColors.activeBlue,
                          child: const Text(
                            'Unfocus',
                            style: TextStyle(
                              color: CupertinoColors.white,
                            ),
                          ),
                          onPressed: () {
                            FocusScope.of(context).requestFocus(FocusNode());
                          },
                        ),
                      ),
                    ),
                  ),
                ),
              ],
            ),
            // ),
          ),
        ),
      );

  @override
  void dispose() {
    focusNode01.dispose();
    controller01.dispose();
    focusNode02.dispose();
    controller02.dispose();
    focusNode03.dispose();
    controller03.dispose();
    focusNode04.dispose();
    controller04.dispose();
    focusNode05.dispose();
    controller05.dispose();

    super.dispose();
  }
}
name: test_keyboard_avoider
description: A new Flutter project.

version: 1.0.0+1

environment:
  sdk: ">=2.1.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  cupertino_icons: ^0.1.2

  keyboard_avoider: ^0.1.2

dev_dependencies:
  flutter_test:
    sdk: flutter

flutter:
  uses-material-design: false

Here is the flutter doctor result:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel unknown, v1.5.8, on Mac OS X 10.14.5 18F132, locale pt-BR)

[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.2.1)
[✓] Android Studio (version 3.4)
[✓] IntelliJ IDEA Community Edition (version 2019.1.1)
[✓] VS Code (version 1.34.0)
[✓] Connected device (3 available)

• No issues found!
martinrybak commented 5 years ago

The issue is the Expanded widget inside your Column. That effectively gives the column infinite height. You can't have a widget of unbounded height inside a ScrollView, which is what KeyboardAvoider uses to scroll your content. Replace KeyboardAvoider with SingleChildScrollView and you'll get the same result. If you remove the Expanded widget, it will work fine.

omarsawalhah commented 5 years ago

But KeyboardAvoider is meant to avoid the keyboard automatically when text fields get focus, am I right. In this post, https://medium.com/flutter-nyc/avoiding-the-on-screen-keyboard-in-flutter-ae0e46ecb96c you said we can use it instead of "Scaffold", if remove the scaffold widget, you will get an error that the "TextField" needs a wrapping Material widget.

martinrybak commented 5 years ago

Regarding your original issue, KeyboardAvoider works by wrapping your content in a ScrollView to make it scrollable. So your content has to play nice inside a ScrollView, which means no widgets with unbounded height.

Re: your most recent comment: you can still use a Scaffold for the other features it offers (app bar, drawer, etc.). Just set resizeToAvoidBottomInset to false. Or you can give your TextField an explicit Material ancestor widget.