【问题标题】:Oops; flutter has exited unexpectedly: "Error on line 8, column 2: Expected ':'哎呀;颤振意外退出:“第 8 行第 2 列错误:预期为 ':'
【发布时间】:2021-11-26 11:03:57
【问题描述】:

我试图将我的应用程序国际化,并浏览了 Flutter 官方文档,昨天一切正常。今天我再次在模拟器上运行应用程序时,输出了以下错误:

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_localizations/flutter_localizations.dart';
import 'package:flutter_gen/gen_l10n/app_localizations.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:services_app/providers/language_provider.dart';
import 'package:services_app/util/const.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      debugShowCheckedModeBanner: false,
      title: 'Services App',
      theme: ThemeData(
        fontFamily: Constants.ENFONTFAMILY,
        primarySwatch: Colors.blue,
      ),
      localizationsDelegates: const [
        AppLocalizations.delegate,
        GlobalMaterialLocalizations.delegate,
        GlobalWidgetsLocalizations.delegate,
        GlobalCupertinoLocalizations.delegate,
      ],
      supportedLocales: const [Locale('en', ''), Locale('ar', '')],
      home: Home(),
    );
  }
}

// ignore: use_key_in_widget_constructors
class Home extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle.dark.copyWith(
      statusBarBrightness: Brightness.light,
      statusBarIconBrightness: Brightness.light,
    ));
    return Scaffold(
      body: Center(
        child: InkWell(
          onTap: () {},
          child: Text(AppLocalizations.of(context)!.helloWorld,
              style: const TextStyle(
                fontSize: 24,
              )),
        ),
      ),
    );
  }
}

【问题讨论】:

  • 请澄清您的具体问题或提供其他详细信息以准确突出您的需求。正如目前所写的那样,很难准确地说出你在问什么。

标签: flutter dart visual-studio-code localization


【解决方案1】:

如果显示“拒绝访问”,可能是因为您使用管理员权限安装了它。尝试删除当前安装的 Flutter 并按照文档中的官方指南重新安装,即; flutter.dev 并检查文件夹是否有正确的权限

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-26
    • 2020-02-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多