0

Firebase cliによって環境構築を行いました。
ビルドされる前に落ち実行が停止されます。
新しいブロジェクトを作成して同じ環境にて実行しても同じエラーが発生しました。
firebase_core: ^1.24.0

エラーメッセージ

    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface- 
   4.5.1/lib/src/pigeon/messages.pigeon.dart:242:7: Error: 'clathrow' isn't a type.
      clathrow PlatformException(
      ^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface- 
   4.5.1/lib/src/pigeon/messages.pigeon.dart:242:16: Error: Expected ';' after this.
      clathrow PlatformException(
               ^^^^^^^^^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface- 
   4.5.1/lib/src/pigeon/messages.pigeon.dart:243:13: Error: Expected ')' before this.

        code: 'null-error',
            ^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface- 
    4.5.1/lib/src/pigeon/messages.pigeon.dart:243:9: Error: The getter 'code' isn't defined 
    for the class 'FirebaseCoreHostApi'.
    - 'FirebaseCoreHostApi' is from 
    'package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart' 
    ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface- 
    4.5.1/lib/src/pigeon/messages.pigeon.dart').
    package:firebase_core_platform_interface/…/pigeon/messages.pigeon.dart:1
    Try correcting the name to the name of an existing getter, or defining a getter or field 
    named 'code'.

        code: 'null-error',
        ^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-        
    4.5.1/lib/src/pigeon/messages.pigeon.dart:222:33: Error: A non-null value must be 
    returned     since the return type 'PigeonFirebaseOptions' doesn't allow null.
    - 'PigeonFirebaseOptions' is from 
    'package:firebase_core_platform_interface/src/pigeon/messages.pigeon.dart'     
    ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/firebase_core_platform_interface-    
    4.5.1/lib/src/pigeon/messages.pigeon.dart').
    package:firebase_core_platform_interface/…/pigeon/messages.pigeon.dart:1
      Future<PigeonFirebaseOptions> optionsFromResource() async {
                                ^
    3

    FAILURE: Build failed with an exception.

    * Where:
    Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1159

    * What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1

    * Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.

    * Get more help at https://help.gradle.org

    BUILD FAILED in 33s
    Exception: Gradle task assembleDebug failed with exit code 1
    Exited (sigterm)

main.dart

import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';

import 'firebase_options.dart';

void main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
   );
  runApp(const MyApp());
}
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      _counter++;
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headline4,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ),
    );
  }
}

1 件の回答 1

0

根本原因は分かりませんが、Flutter自体を再インストールしたら問題なく実行できました。

この質問に回答するには、ログインする必要があります。

求めていた回答ではありませんか? のタグが付いた他の質問を参照する。