Flutterエラーと解決策

8676 ワード

Flutterの使用で発生した問題:1,Expected a key while parsing a block mapping
Error on line 30, column 4 of pubspec.yaml: Expected a key while parsing a block mapping.
   assets:
   ^

異常原因:assetsの前にスペースソリューションが追加されました:assetsの前のスペースを除去し、全体のラベルの位置合わせに注意してください2、RichText widgets require a Directionality widget ancestor.奇妙な間違いです.昨日はこのような問題はありませんでしたが、今日は次のようになりました.
I/flutter (20611): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (20611): The following assertion was thrown building Text("xxx", inherit: true, color: Color(0xff2b6dea),
I/flutter (20611): size: 22.0):
I/flutter (20611): No Directionality widget found.
I/flutter (20611): RichText widgets require a Directionality widget ancestor.
I/flutter (20611): The specific widget that could not find a Directionality ancestor was:
I/flutter (20611):   RichText(softWrap: wrapping at box width, maxLines: unlimited, text: "xxx")
I/flutter (20611): The ownership chain for the affected widget is:
I/flutter (20611):   RichText ← Text ← Column ← Padding ← DecoratedBox ← Container ← Login ← [root]
I/flutter (20611): Typically, the Directionality widget is introduced by the MaterialApp or WidgetsApp widget at the
I/flutter (20611): top of your application widget tree. It determines the ambient reading direction and is used, for
I/flutter (20611): example, to determine how to lay out text, how to interpret "start" and "end" values, and to resolve
I/flutter (20611): EdgeInsetsDirectional, AlignmentDirectional, and other *Directional objects.

今まで何が起こったのか分からなかった.解決策は次のとおりです.
     :
  @override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xFFFFFFFF),
      padding: EdgeInsets.fromLTRB(0.0, 78.0, 0.0, 5.0),
      child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
          Image.asset("images/logo.png", width: 48.0, ),
          new Container(height: 5.0),
          Text(
            "Helloword",
            style: TextStyle(
              color: Color(0xFF2B6DEA),
              fontSize: 22.0,
            ),
          ),
           ],
        ),
    );
  }
       :
@override
  Widget build(BuildContext context) {
    return Container(
      color: Color(0xFFFFFFFF),
      padding: EdgeInsets.fromLTRB(0.0, 78.0, 0.0, 5.0),
      child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          children: [
          Image.asset("images/logo.png", width: 48.0, ),
          new Container(height: 5.0),
          Text(
            "Helloword",
            style: TextStyle(
              color: Color(0xFF2B6DEA),
              fontSize: 22.0,
            ),
     		textDirection: TextDirection.ltr
          ),
           ],
        ),
    );
  }

重要なのは次のコードです:(不明覚)textDirection:TextDirection.ltr 3,TextField widgets require a Material widget ancestor.
I/flutter (20611): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (20611): The following assertion was thrown building TextField(decoration: InputDecoration(hintText:
I/flutter (20611): "      ", prefixIcon: Icon(IconData(U+0E7FD))), autofocus: true, autocorrect: true, max length
I/flutter (20611): enforced, onTap: null, dirty, state: _TextFieldState#8027d):
I/flutter (20611): No Material widget found.
I/flutter (20611): TextField widgets require a Material widget ancestor.
I/flutter (20611): In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's
I/flutter (20611): material library, that material is represented by the Material widget. It is the Material widget
I/flutter (20611): that renders ink splashes, for instance. Because of this, many material library widgets require that
I/flutter (20611): there be a Material widget in the tree above them.
I/flutter (20611): To introduce a Material widget, you can either directly include one, or use a widget that contains
I/flutter (20611): Material itself, such as a Card, Dialog, Drawer, or Scaffold.
I/flutter (20611): The specific widget that could not find a Material ancestor was:
I/flutter (20611):   TextField(decoration: InputDecoration(hintText: "      ", prefixIcon: Icon(IconData(U+0E7FD))),
I/flutter (20611):   autofocus: true, autocorrect: true, max length enforced, onTap: null)
I/flutter (20611): The ancestors of this widget were:
I/flutter (20611):   Column(direction: vertical, mainAxisAlignment: start, crossAxisAlignment: center)
I/flutter (20611):   Padding(padding: EdgeInsets(0.0, 78.0, 0.0, 5.0))
I/flutter (20611):   DecoratedBox(bg: BoxDecoration(color: Color(0xffffffff)))
I/flutter (20611):   Container(padding: EdgeInsets(0.0, 78.0, 0.0, 5.0), bg: BoxDecoration(color: Color(0xffffffff)))
I/flutter (20611):   Login
I/flutter (20611):   [root]

TextField widgetはScaffold widgetに包まれる必要があります.そうしないと、textfield widgets require a material widget ancestor 4、No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of()
I/flutter (20611): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (20611): The following assertion was thrown building Login:
I/flutter (20611): MediaQuery.of() called with a context that does not contain a MediaQuery.
I/flutter (20611): No MediaQuery ancestor could be found starting from the context that was passed to MediaQuery.of().
I/flutter (20611): This can happen because you do not have a WidgetsApp or MaterialApp widget (those widgets introduce
I/flutter (20611): a MediaQuery), or it can happen if the context you use comes from a widget above those widgets.
I/flutter (20611): The context used was:
I/flutter (20611):   Scaffold(dirty, state: ScaffoldState#9a79e(lifecycle state: initialized, tickers: tracking 1
I/flutter (20611):   ticker))

原因は、main.dartのrunAppから直接StatefulWidgetにジャンプし、このStatefulWidgetはScaffold 5、Finished with error:FormatException:Bad UTF-8 encoding 0 xe 4(at offset 9)を返します.これはappのバージョンがreleaseのためkeystoreファイルが見つからないためです.
Finished with error: FormatException: Bad UTF-8 encoding 0xe4 (at offset 9)

Android–app–build.gradleのsigningConfigsが正しいかどうかを確認します6、Because xxx requires K SDversion 2.0.0-dev.68.0、version solving failed.FlutterエラーgithubのFlutterプロジェクトをダウンロードし、実行後、次のエラーを報告します
The current Dart SDK version is 2.0.0-dev.58.0.flutter-f981f09760.
Because sample_catalog requires SDK version >=2.0.0-dev.68.0 <3.0.0, version solving failed.

文字通り、Dartのバージョンは2.0ですが、プロジェクトには2.0より大きいDartバージョンが必要です.このエラーの原因は、依存するパッケージ、または自分のプロジェクト自体が高バージョンのdartを使用しているためです.私の解決策は、Android Studio–Tools–Flutter–Flutter Upgradeの実行結果は次の通りです(ログが縮小されました)
Upgrading Flutter from C:\Users\Hzx\flutter...
From https://github.com/flutter/flutter
   c7ea3ca377..5391447fae  beta       -> origin/beta
 * [new branch]            gallery    -> origin/gallery
 * [new branch]            maryx-animated-container -> origin/maryx-animated-container
   5413560415..aca3aba10e  master     -> origin/master
 * [new branch]            stable     -> origin/stable
 * [new tag]               v1.1.5     -> v1.1.5
Checking out files:  10% (239/2211)   
Checking out files: 100% (2211/2211), done.
Updating c7ea3ca377..5391447fae
 .../app/src/main/res/mipmap-mdpi/ic_launcher.png   |   Bin
 .../android}/gradle.properties                     |     0
 .../src/main/res/mipmap-hdpi/ic_launcher.png       |   Bin 0 -> 544 bytes
 .../common}/.idea/modules.xml.tmpl                 |     0
 .../LaunchImage.imageset/[email protected]        |   Bin 0 -> 68 bytes
 2140 files changed, 204402 insertions(+), 95793 deletions(-)
 mode change 100644 => 100755
Upgrading engine...
Checking Dart SDK version...
Downloading Dart SDK from Flutter engine 7375a0f414bde4bc941e623482221db2fc8c4ab5...
Unzipping Dart SDK...
Building flutter tool...
Running pub upgrade...
Flutter assets will be downloaded from https://storage.flutter-io.cn. Make sure you trust this source!
Downloading package sky_engine...                                0.6s
Downloading common tools...                                      1.8s

実行後、赤いヒントが消えていることに気づきました.この時runプロジェクトができて、プロジェクトがパッケージをダウンロードしていることに気づきました.「Dart Packages/Dart SDK/Flutter Plugins」などのSDKパッケージが初めて稼働するのはもちろん、手動でFlutterをダウンロードする方法もあります.ダウンロード先は次のとおりです.https://github.com/flutter/flutter