0

フラッターフォームに問題があります。

基本的に、スタックに 3 つの単純な行が追加されています。最後のものにはフォームが含まれています。その下には Adob​​e XD による「固定」要素がありますが、フォームを含む行が画面の上部に浮いています... 最初の 2 行の下に配置されると思います。

以下のスクリーンショットで問題を確認できます。フォームは画像の上にありますが、機能的なフォーム フィールドに置き換えたい 2 本の白い線の上に配置したいと考えています。

画面中央に浮かぶフォルム

どこが間違っていますか?フォームを別のウィジェットに入れました。

LoginPage.dart

Widget build(BuildContext context) {
    return Container(
      decoration: BoxDecoration(
          gradient: LinearGradient(
              begin: Alignment.topRight,
              end: Alignment.bottomLeft,
              stops: [
            0.4,
            1
          ],
              colors: [
            Colors.black,
            Color(0xff7d060b),
          ])),
      child: Scaffold(
        resizeToAvoidBottomInset: false,
        backgroundColor: Colors.transparent,
        body: SafeArea(
          child: Stack(
            children: <Widget>[
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  /* Image.asset(
                  'assets/images/Logo.png',
                  height: 100,
                  width: 250,
                ),*/
                  Image.asset(
                    'assets/images/fewturelogo.png',
                    height: 50,
                  ),
                  Container(
                      padding: const EdgeInsets.only(left: 30.0),
                      child: IconButton(
                        color: Colors.white,
                        icon: const Icon(Icons.not_listed_location_rounded),
                        onPressed: () {
                          print('Hello');
                          showDialog(
                              context: context,
                              barrierDismissible: false,
                              // user must tap button!
                              builder: (BuildContext context) {
                                return AlertDialog(
                                  title: Text('Was ist Rentalsplanet?'),
                                  content: new SingleChildScrollView(
                                    child: new ListBody(children: [
                                      new Text(
                                          'Hier erscheinen Informationen über Rentalsplanet')
                                    ]),
                                  ),
                                  actions: [
                                    new ElevatedButton(
                                        child: Text('Alles klar!'),
                                        onPressed: () {
                                          Navigator.of(context).pop();
                                        })
                                  ],
                                );
                              });
                        },
                      )),
                ],
              ),
              Row(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Container(
                    margin: const EdgeInsets.only(top: 70.0),
                    child: Image.asset(
                      'assets/images/SplashImageLogin.png',
                      scale: 1.1,
                    ),
                  ),
                ],
              ),
              Row(children: [
                Container(
                  margin: const EdgeInsets.only(top: 70.0),
                  child: SizedBox(width: 100, child: LoginForm()),
                )
              ]),
            ],
          ),
        ),
      ),
    );

ログインフォーム.dart

Widget build(BuildContext context) {
    // Build a Form widget using the _formKey created above.
    return Form(
      key: _formKey,
      child: Column(
        children: <Widget>[
          new Flexible(
            child: TextFormField(
              // The validator receives the text that the user has entered.
              validator: (value) {
                if (value == null || value.isEmpty) {
                  return 'Please enter some text';
                }
                return null;
              },
            ),
          ),

          ElevatedButton(
            onPressed: () {
              // Validate returns true if the form is valid, or false otherwise.
              if (_formKey.currentState.validate()) {
                // If the form is valid, display a snackbar. In the real world,
                // you'd often call a server or save the information in a database.
                ScaffoldMessenger.of(context)
                    .showSnackBar(SnackBar(content: Text('Processing Data')));
              }
            },

            child: Text('Submit'),
          ),

          // Add TextFormFields and ElevatedButton here.
        ],
      ),
    );
  }
4

1 に答える 1