0

我对 Flutter 很陌生,我正在尝试构建一个桌面应用程序。
我完成了以下指南的所有步骤:https ://medium.com/flutter-community/flutter-from-mobile-to-desktop-93635e8de64e (运行您自己的项目(编译 Go 桌面项目))

不幸的是,当我尝试运行代码时出现此错误:

NoSuchMethodError:类“窗口”没有实例获取器“区域设置”
接收器:窗口实例
尝试调用:区域设置

先感谢您

操作系统是 Windows 8.1 并遵循代码。这是我刚刚添加了 debugDefaultTargetPlatformOverride 部分的启动器。

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart' show 
debugDefaultTargetPlatformOverride;

void main(){
debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
runApp(MyApp());
}
class MyApp extends StatelessWidget {



  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(

        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key, this.title}) : super(key: key);



  final String title;

  @override
  _MyHomePageState 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>[
            Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.display1,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: Icon(Icons.add),
      ), 
methods.
    );
  }
}
4

0 回答 0