我在Flutter中遇到了一个问题:构建Scaffold时引发了以下断言,这使我感到陌生

时间:2020-05-06 16:36:34

标签: flutter flutter-layout flutter-dependencies

在Flutter中,我陷入了一个问题:构建TextField时引发了以下断言,短时间内让我感到一个奇怪的问题!

对于代码或错误的任何澄清,请在下面发表评论,我将在几分钟内回复,因为我迫不及待地想解决这个问题,并且不加思索地前进!!

错误:-

 ════════ Exception caught by widgets library ═══════════════════════════════════════════════════════
The following assertion was thrown building Scaffold-[LabeledGlobalKey<ScaffoldState>#2906d](dirty, dependencies: [_LocalizationsScope-[GlobalKey#54a24], Directionality, _EffectiveTickerMode, MediaQuery, _InheritedTheme], state: ScaffoldState#ba5af(tickers: tracking 2 tickers)):
'dart:ui/geometry.dart': Failed assertion: line 19: '<optimized out>': is not true.

The relevant error-causing widget was: 
  Scaffold-[LabeledGlobalKey<ScaffoldState>#2906d] file:///home/ankit/work_space_flutter/designer-app-flutter/lib/src/ui/setting/editProfile/entrepreneur/edit_entrepreneur_profile_screen.dart:90:21
When the exception was thrown, this was the stack: 
#2      new OffsetBase (dart:ui/geometry.dart:19:16)
#3      new Size (dart:ui/geometry.dart:350:45)
#4      DDAppBar.preferredSize (package:designer/src/widgets/dd_app_bar.dart:57:14)
#5      ScaffoldState.build (package:flutter/src/material/scaffold.dart:2370:40)
#6      StatefulElement.build (package:flutter/src/widgets/framework.dart:4619:28)
...
════════════════════════════════════════════════════════════════════════════════════════════════════

代码:-

@override
  Widget build(BuildContext context) => ChangeNotifierProvider<LoadingIndicator>(
        create: (context) => LoadingIndicator(),
        child: SafeArea(
          top: true,
          bottom: true,
          child: Consumer<LoadingIndicator>(
            builder: (context, loadingIndicator, child) {
              return WillPopScope(
                onWillPop: loadingIndicator.isLoading ? _backButtonPressed : null,
                child: Stack(
                  fit: StackFit.expand,
                  children: <Widget>[
                    Scaffold(
                      key: _drawerKey,
                      backgroundColor: Colors.white,
                      appBar: _getAppBar(),
                      drawer: Drawer(child: SideDrawer()),
                      body: Form(
                        key: _formKey,
                        autovalidate: false,
                        child: SingleChildScrollView(
                          child: Padding(
                            padding: const EdgeInsets.all(spacingLarge),
                            child: Center(
                              child: Column(
                                crossAxisAlignment: CrossAxisAlignment.center,
                                children: <Widget>[
                                  _getProfileAvatar(),
                                  _getFirstNameTextInput(),
                                  _getLastNameTextInput(),
                                  _getEmailTextInput(),
                                  _getPhoneNumberTextInput(),
                                  _getPasswordFiled(),
                                  _getConfirmPasswordFiled(),
                                  _getPayoutDetailHeader(),
                                  _getPaymentsOptions(),
                                  _getEntrepreneurDetailsHeader(),
                                  _getDisplayedNameField(),
                                  _getAddressLine1Field(),
                                  _getAddressLine2Field(),
                                  _getPinCodeField(),
                                  _getStateCountryDropDown(),
                                  _getSignUpButton(),
                                  _getTermsCondition()
                                ],
                              ),
                            ),
                          ),
                        ),
                      ),
                    ),
                    Consumer<LoadingIndicator>(
                      builder: (context, loadingIndicator, child) {
                        return AbsorbPointer(
                          absorbing: loadingIndicator.isLoading,
                          child: Container(),
                        );
                      },
                    ),
                  ],
                ),
              );
            },
          ),
        ),
      );

从flutter升级到1.17后出现错误

环境: sdk:“> = 2.7.0 <3.0.0”

预先感谢

0 个答案:

没有答案