1. Open vscode on the terminal and run the command path to the directory where you want to create the Model.

  2. Execute the following command: flutter create -t module flutter_module(directory name) generates the folder structure shown in the following figure:

    Open the AS(since I’m using Android Studio), import the Flutter_module project into the IDE, and select the emulator run side, since the library files required in the iOS project will only be generated after running. An important step: Hold Shift + Command +.(dot) to bring up the hidden files. The structure of the Flutter_module folder will look like this:

  3. Create an iOS project in the iOS flutte folder. The structure is as follows:

  4. Next, open the command line tool and go to the iOSFlutter(iOS Project) folder

    performpod initOpen the podfile and add two lines of code:

flutter_application_path = '.. /flutter_community'
load File.join(flutter_application_path, '.ios'.'Flutter'.'podhelper.rb')
Copy the code

As shown in figure:

And every Xcode target needs to bind the flutter by calling install_all_FLutter_PODS (flutter_APPLICation_path)

Note: The folder directory must be created as described above, otherwise the flutter_application_path of the podfile file will have to be pathadjusted. After the addition, execute pod Install in the command line window and the various files supported by POD will be generated.

  1. IOS project Enable Bitcode needs to be disabled because Bitcode is not supported by Flutter hybrid development

  2. Then write code to call the flutter interface.

-(void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor lightGrayColor];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button addTarget:self action:@selector(handleButtonAction)
forControlEvents:UIControlEventTouchUpInside];
 [button setTitle:@"Click to jump to the Flutter page" forState:UIControlStateNormal];
[button setBackgroundColor:[UIColor blueColor]]; Button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; } -(void)handleButtonAction { FlutterViewController *flutterViewController = [[FlutterViewController alloc] init]; flutterViewController.view.backgroundColor = [UIColor cyanColor]; // Distinguish flutter pages from incoming strings [flutterViewController]setInitialRoute:@"xxx"]; flutterViewController.modalPresentationStyle = UIModalPresentationFullScreen; [self presentViewController:flutterViewController animated:YES completion:nil]; // NSAssert([self navigationController], @" Must have a NaviationController "); // [[self navigationController] pushViewController:flutterViewController animated:YES]; }Copy the code

Note: If encountered as shown below

This is a bug in the flutter SDK. If you don’t upgrade the flutter, you can change a file in the FLUTTER SDK. Flutter/packages/flutter_tools/bin/xcode_backend. Sh 144 rows

RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -exec chmod a-w "{}" \;
=>
RunCommand find "${derived_dir}/engine/Flutter.framework" -type f -iname '.h' -exec chmod a-w "{}" \;
Copy the code