Skip to content

bradmartin333/flutter_sys_template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

The most detailed systems template

Features and Examples

TODO

  • More sample UI stuff
  • Automated Linux release
  • Go through all steps on new machine to validate!!!

Making the UI

  • Make it's own directory, UI
  • Make a simple navigator using the DefaultTabController
  • Create a simple BLoC structure

Implementing C++ JSON Library (To test with)

  • Download json.hpp and put in json_library\src
  • Create a bridge C++ class (Don't know if that is best practice or not... new to this) and .def file
  • Create json_library\CMakeLists.txt and a build/generator script
  • Create root level .gitignore for *library/bin and *library/build

Implementing async FFI with native ports

  • Download the contents of the json_library\src\dart directory from the dart-lang repo
  • Add Dart_InitializeApiDL to the .def file
  • Make some test functions in *bridge.cpp and include them in *bridge.hpp and the .def file
  • Add C as a a language to json_library\CMakeLists.txt
  • Look for *.c and *.h files in json_library\CMakeLists.txt
  • Implement the ReceivePort and required funtions in UI\lib\native_json.dart as per this comment
  • Add ../json_library/src/dart/dart_api_dl.h to entry points in UI\config.yaml
  • Update UI\android\app\CMakeLists.txt in the same way

windows

  1. Download and install CMake and make sure to add to path during installation
  2. Download and install VS2022 Build Tools
  3. Open PowerShell and run where.exe /R C:\ msbuild and confirm that C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe is present
  4. Add C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\MSBuild.exe to Environment Variables PATH
  5. winget install -e --id LLVM.LLVM (For dart ffigen)
  6. Restart any open shells
  7. Configure Flutter project for ffigen
    • Add ffigen to dev_dependencies in UI\pubspec.yaml
    • Create UI\config.yaml based off the file in this repo
    • Create empty UI\lib\generated_bindings.dart
  8. run json_library\build.bat
  9. Create wrapper like UI\lib\native_json.dart

android built from windows

These steps assume that you have completed the windows specific steps above and also have a working Android Studio installation / android mobile emulator.

  1. Add **/.cxx to UI\android\.gitignore
  2. Setup CMake for Android
    • where.exe cmake in PowerShell should yield C:\Program Files\CMake\bin\cmake.exe
    • Update UI\android\local.properties by adding cmake.dir=C:\\Program Files\\CMake (Make sure not to have trailing slashes or bin!)
  3. Update UI\android\build.gradle by adding:
    android {
        ...
        externalNativeBuild {
            cmake {
                path = file("CMakeLists.txt")
            }
        }
    }
    
  4. (Not sure if necessary) Update beginning of UI\android\app\src\main\AndroidManifest.xml with:
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools">
        <application
            ...
            android:extractNativeLibs="true"
            tools:replace="android:extractNativeLibs">
        </application>
    
  5. Create UI\windows\CMakeLists.txt based off the file in this repo

ubuntu

Install the manual way, not using snap. Huge speed decrease with snap.

  1. sudo apt install cmake clang lldb lld
  2. cd json_library/
  3. ./build.sh (Not sudo or paths will be wrong!)

android built from ubuntu