Ad

Flutter WebView Not Working M1 Chipset MacOS 11.4

I am working on M1 mac.

For several days now, I am struggling with a problem to implement a widget 'WebView' in my project. I can't wrap my hand around this problem, I have tried all of the possibilities I have found on the internet.

  1. I have added the webview_flutter: ^2.0.10 dependency to the pubspec.yaml file

  2. Code below

import 'package:flutter/material.dart';
import 'package:webview_flutter/webview_flutter.dart';

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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        title: 'WebView',
        home: WebView(
            initialUrl: ('https://google.com'),
            javascriptMode: JavascriptMode.unrestricted));
  }
}
  1. I have followed instructions from other posts and YouTube videos and I have duplicated an iTerm app, right clicked on it --> get info --> translate by Rosseta --> cd to project app --> sudo gem install cocoapods (I think it's necessary for WebView to work) --> sudo gem install ffi

  2. I have played with android --> app --> build.gradle --> minSdkVersion 16/19

Unfortunetaly, none of these helped me get any closer to the solution for the problem, I can compile the code both on Android Emulator, and on iOS Simulator, however in both scenarios the application is just blank

PHOTO Flutter doctor, code, etc.

Ad

Answer

I fixed this by running pod install with arch -x86_64

So here are the steps that worked for me:- Uninstall pods to start fresh,

  • sudo gem uninstall cocoapod
  • sudo gem uninstall ffi

Now will reinstall again with arch -x86_64 value,

  • arch -x86_64 sudo gem install cocoapods
  • arch -x86_64 pod install --repo-update

This should work. By this we exclude arm64 architecture.

Ad
source: stackoverflow.com
Ad