flutter RTL语法错误,“package:intl/intl.dart”

fzsnzjdm  于 2023-05-29  发布在  Flutter
关注(0)|答案(3)|浏览(198)

嗨,我最近尝试使用日期选择器为Flutter,我没有找到任何文件或教程,所以我打开Flutter画廊项目,并尝试复制代码。如下代码我导入“package:intl/intl.dart”库。之后在main.dart构建函数中:

Widget build(BuildContext context) {
return new MaterialApp(
    title: 'Welcome to Flutter',
    theme: new ThemeData.light(),
    home: new InitiateAppPage(),
    builder: (BuildContext context, Widget child) {
      return new Directionality(
        textDirection: TextDirection.rtl,
        child: child,
      );
    },
    );   }

SDK库“ui.dart”中的元素“TextDirection”被“intl. dart”隐式隐藏。这个问题有什么解决办法吗?

5rgfhyps

5rgfhyps1#

导入命名空间如下并使用别名

import 'package:intl/intl.dart' as intl;
bxfogqkk

bxfogqkk2#

import 'dart:ui' as ui;

..

textDirection: ui.TextDirection.ltr,
5w9g7ksd

5w9g7ksd3#

添加:

import 'package:intl/intl.dart' hide TextDirection;

应该可以

相关问题