mac m1 flutter 3.0+ flutter_image_compress图片压缩插件安装问题

Error output from CocoaPods:

/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/universal-darwin21/rbconfig.rb:230: warning: Insecure world writable dir /opt/homebrew in PATH, mode 040777
Searching for inspections failed: undefined method `map’ for nil:NilClass

Error running pod install
Error launching application on iPhone 11 Pro.

解决
This line is very clear that some architecture is missing for building this pod. Apparently M1 mac does not have x86_64 arch.

So the solution is to run below two lines in terminal:

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
Now it should be working. 😉 Happy coding

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
您好!对于封装一个flutter_screenutil,您可以按照以下步骤进行操作: 1. 首先,在项目的`pubspec.yaml`文件中添加`flutter_screenutil`依赖项。可以在`dependencies`部分添加以下代码: ```yaml dependencies: flutter_screenutil: ^5.0.0 ``` 2. 在您的项目中创建一个名为`screen_util.dart`的文件,用于封装`flutter_screenutil`。 3. 在`screen_util.dart`文件中导入必要的库: ```dart import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:flutter/material.dart'; ``` 4. 创建一个名为`ScreenUtil`的类,并添加以下静态方法: ```dart class ScreenUtil { static void init(BuildContext context) { FlutterScreenUtil.init(context); } static double setWidth(double width) { return FlutterScreenUtil().setWidth(width); } static double setHeight(double height) { return FlutterScreenUtil().setHeight(height); } static double setSp(double fontSize) { return FlutterScreenUtil().setSp(fontSize); } } ``` 5. 在您的项目中的`main.dart`文件中,使用`ScreenUtil.init(context)`初始化`ScreenUtil`,例如: ```dart void main() { runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { ScreenUtil.init(context); return MaterialApp( title: 'Flutter Demo', theme: ThemeData( primarySwatch: Colors.blue, ), home: MyHomePage(), ); } } ``` 6. 现在,您可以在项目的任何地方使用`ScreenUtil.setWidth`、`ScreenUtil.setHeight`和`ScreenUtil.setSp`来设置宽度、高度和字体大小,例如: ```dart Container( width: ScreenUtil.setWidth(200), height: ScreenUtil.setHeight(100), child: Text( 'Hello', style: TextStyle(fontSize: ScreenUtil.setSp(20)), ), ), ``` 通过以上步骤,您可以封装一个简单的`flutter_screenutil`工具类,方便在项目中使用屏幕适配功能。希望对您有所帮助!如果您还有其他问题,请随时提问。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值