Giter Site home page Giter Site logo

itamadev / golang-flutter-app-ffi Goto Github PK

View Code? Open in Web Editor NEW
20.0 2.0 3.0 210 KB

A Flutter app with Golang as a backend using FFI to bind and communicate between them

License: MIT License

Makefile 0.95% Kotlin 0.36% Swift 1.20% Objective-C 0.11% Dart 9.30% HTML 11.63% CMake 24.38% C++ 49.90% C 2.18%
application ffi flutter flutter-apps fullstack golang dart go flutter3 hacktoberfest example

golang-flutter-app-ffi's Introduction

Golang Flutter App FFI

This repo demonstrates a very simple Flutter app with Golang used as backend lanugage, communicating using FFI (Foreign Function Interface), the app is a very simple note taking app that currently allows you to whip up a message and save it into a message.txt file.

Example

Example

Prerequisites

  • go
  • make
  • flutter sdk version 2.16.2^

Usage

Try it out:

$ make run

# Overrite FLUTTER_DEVICE to change the flutter device build option
# WARNNING: may not work with certain devices
$ make run FLUTTER_DEVICE=chrome

Tested Devices

The following are the Flutter Supported Devices

Mobile

  • android
  • ios

Desktop

  • windows
  • linux

Project Structure

  • lib
    • main.dart
    • create_message.dart
  • vendor
    • text.go
    • go.mod
  • vendor/out (tmp)
    • text.a
    • text.h

lib - flutter code files

create_message.dart - Golang logic using FFI to Dart

vendor - Golang files as backend

vendor/out - Golang compiled files

License

MIT.

golang-flutter-app-ffi's People

Contributors

itamadev avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

golang-flutter-app-ffi's Issues

Error: no such file or directory

Hey, just testing your little demo out as I'm looking for a good way to build mobile apps in Flutter (for the UI part) with a Go backend.

I tried to build this on my iMac, deployed to my iPhone and got this error:

══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════
The following ArgumentError was thrown while handling a gesture:
Invalid argument(s): Failed to load dynamic library './vendor-out/text.a':
dlopen(./vendor-out/text.a, 0x0001): tried: '/usr/lib/swift/./vendor-out/text.a' (no such file),
'/private/var/containers/Bundle/Application/407A3657-732C-43E9-BEF6-D4C2FB5EF36C/Runner.app/Frameworks/./vendor-out/text.a'
(no such file), './vendor-out/text.a' (no such file)

When the exception was thrown, this was the stack:
#0      _open (dart:ffi-patch/ffi_dynamic_library_patch.dart:12:43)
#1      new DynamicLibrary.open (dart:ffi-patch/ffi_dynamic_library_patch.dart:23:12)
#2      dylib (package:app/create_message.dart:9:34)
#3      dylib (package:app/create_message.dart)
#4      _createMessage (package:app/create_message.dart:11:38)
#5      _createMessage (package:app/create_message.dart)
#6      createMessage (package:app/create_message.dart:16:3)
#7      _CreateTextFormState.build.<anonymous closure> (package:app/main.dart:54:11)
#8      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1072:21)
#9      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:253:24)
#10     TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:627:11)
#11     BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:306:5)
#12     BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:276:7)
#13     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:163:27)
#14     GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:464:20)
#15     GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:440:22)
#16     RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:337:11)
#17     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:395:7)
#18     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:357:5)
#19     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:314:7)
#20     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:295:7)
#21     _invoke1 (dart:ui/hooks.dart:167:13)
#22     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:341:7)
#23     _dispatchPointerDataPacket (dart:ui/hooks.dart:94:31)

Handler: "onTap"
Recognizer:
  TapGestureRecognizer#94dcc

I run:

$ make run FLUTTER_DEVICE=<device>

Where <device> is the device-id my my connected iPhone.

What did I do wrong? 🤔

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.