Android Studio没有将Chrome显示为Flutter设备。
创始人
2024-08-17 19:00:43
0

要将Chrome显示为Flutter设备,需要在Android Studio中进行以下设置:

  1. 打开Flutter项目并运行flutter doctor命令,确保Flutter环境正常。

  2. 确保Chrome已安装并处于最新版本。

  3. 在Android Studio的顶部工具栏中,选择“Edit Configurations”(编辑配置)。

  4. 在左侧面板中,选择“Flutter”选项。

  5. 在右侧面板中,找到“Additional Run args”(附加运行参数)字段,并添加以下参数:

--enable-software-rendering --disable-dart-asserts

这些参数将允许在Chrome浏览器中运行Flutter应用。

  1. 单击“Apply”(应用)按钮保存更改。

  2. 关闭“Edit Configurations”窗口。

  3. 在Android Studio的顶部工具栏中,找到并点击“Run”(运行)按钮。

  4. 在弹出的运行配置中,选择“main.dart”作为入口点,并选择“Chrome”作为目标设备。

  5. 单击“OK”按钮以开始在Chrome浏览器中运行Flutter应用。

以下是一个代码示例,展示如何在Flutter应用中设置Chrome为目标设备:

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter/widgets.dart';

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

确保以上代码在main.dart文件中,并按照上述步骤配置Android Studio以在Chrome浏览器中运行Flutter应用程序。

相关内容

热门资讯

2分钟法门!德州透视hhpok... 2分钟法门!德州透视hhpoker(透视)真是真的有辅助神器(哔哩哔哩)1、超多福利:超高返利,海量...
3分钟绝活!wepokerpl... 3分钟绝活!wepokerplus外开挂(透视)好像有辅助开挂(哔哩哔哩)该软件可以轻松地帮助玩家将...
4分钟资料!wepoker免费... 您好,wepoker免费脚本弱密码这款游戏可以开挂的,确实是有挂的,需要了解加去威信【4852750...
第7分钟积累!hhpoker哪... 第7分钟积累!hhpoker哪个俱乐部靠谱(透视)确实真的有辅助透视(哔哩哔哩)1、hhpoker哪...
第6分钟举措!wepoker私... 第6分钟举措!wepoker私人局怎么玩(透视)一贯存在有辅助插件(哔哩哔哩)一、wepoker私人...
第2分钟操作!wepoker免... 第2分钟操作!wepoker免费透视脚本(透视)原来存在有辅助下载(哔哩哔哩)1、起透看视 wepo...
第9分钟法门!we-poker... 第9分钟法门!we-poker辅助器(透视)切实真的有辅助神器(哔哩哔哩)1、让任何用户在无需we-...
四分钟积累!wepoker辅助... 四分钟积累!wepoker辅助器激活码(透视)一直是真的有辅助脚本(哔哩哔哩)1、实时wepoker...
第6分钟手册!智星德州辅助译码... 第6分钟手册!智星德州辅助译码插件靠谱吗(透视)总是是真的有辅助透视(哔哩哔哩)1、进入到智星德州辅...
第一分钟绝活儿!hhpoker... 第一分钟绝活儿!hhpoker软件靠谱吗(透视)切实真的有辅助工具(哔哩哔哩)1、首先打开hhpok...