Flutter Desktop Application- NoSuchMethodError:类“ Window”没有距离获取器“ locales”

时间:2019-01-05 18:36:10

标签: flutter desktop-application

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

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

NoSuchMethodError:类“ Window”没有实例获取方法“ locales”
接收方:Window的实例
尝试致电:地区设置

提前谢谢

操作系统为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.
    );
  }
}

0 个答案:

没有答案