Ejemplo n.º 1
0
        protected override void OnCreate()
        {
            base.OnCreate();

            // Get paths to resources required for launch.
            string resPath     = Current.DirectoryInfo.Resource;
            string assetsPath  = $"{resPath}/flutter_assets";
            string icuDataPath = $"{resPath}/icudtl.dat";
            string aotLibPath  = $"{resPath}/../lib/libapp.so";

            // Read engine arguments passed from the tool.
            ParseEngineArgs();

            using var switches = new StringArray(EngineArgs);
            var engineProperties = new FlutterDesktopEngineProperties
            {
                assets_path      = assetsPath,
                icu_data_path    = icuDataPath,
                aot_library_path = aotLibPath,
                switches         = switches.Handle,
                switches_count   = (uint)switches.Length,
            };

            Handle = FlutterDesktopRunEngine(ref engineProperties, true);
            if (Handle.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            Utils.ParseEngineArgs(EngineArgs);

            using (var switches = new StringArray(EngineArgs))
                using (var entrypointArgs = new StringArray(DartEntrypointArgs))
                {
                    var engineProperties = new FlutterDesktopEngineProperties
                    {
                        assets_path          = "../res/flutter_assets",
                        icu_data_path        = "../res/icudtl.dat",
                        aot_library_path     = "../lib/libapp.so",
                        switches             = switches.Handle,
                        switches_count       = (uint)switches.Length,
                        entrypoint           = DartEntrypoint,
                        dart_entrypoint_argc = entrypointArgs.Length,
                        dart_entrypoint_argv = entrypointArgs.Handle,
                    };

                    Engine = FlutterDesktopEngineCreate(ref engineProperties);
                    if (Engine.IsInvalid)
                    {
                        throw new Exception("Could not create a Flutter engine.");
                    }

                    if (!FlutterDesktopEngineRun(Engine))
                    {
                        throw new Exception("Could not launch a service application.");
                    }
                }
        }
Ejemplo n.º 3
0
        protected override void OnCreate()
        {
            base.OnCreate();

            // Read engine arguments passed from the tool.
            ParseEngineArgs();
            InternalLog.Info(LogTag, $"switches: {string.Join(" ", EngineArgs)}");

            // Get the screen size of the currently running device.
            if (!Information.TryGetValue("http://tizen.org/feature/screen.width", out int width) ||
                !Information.TryGetValue("http://tizen.org/feature/screen.height", out int height))
            {
                InternalLog.Error(LogTag, "Could not obtain the screen size.");
                return;
            }
            var windowProperties = new FlutterWindowProperties
            {
                width  = width,
                height = height
            };

            // Get paths to resources required for launch.
            string resPath     = Current.DirectoryInfo.Resource;
            string assetsPath  = $"{resPath}/flutter_assets";
            string icuDataPath = $"{resPath}/icudtl.dat";
            string arch        = RuntimeInformation.ProcessArchitecture switch
            {
                Architecture.X86 => "x86",
                Architecture.X64 => "x64",
                Architecture.Arm => "arm",
                Architecture.Arm64 => "aarch64",
                _ => "",
            };
            string aotLibPath = $"{resPath}/../lib/{arch}/libapp.so";

            using var switches = new StringArray(EngineArgs);
            var engineProperties = new FlutterEngineProperties
            {
                assets_path      = assetsPath,
                icu_data_path    = icuDataPath,
                aot_library_path = aotLibPath,
                switches         = switches.Handle,
                switches_count   = (uint)switches.Length,
            };

            Handle = FlutterCreateWindow(ref windowProperties, ref engineProperties);
            if (Handle.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }
Ejemplo n.º 4
0
        protected override void OnCreate()
        {
            base.OnCreate();

            Utils.ParseEngineArgs(EngineArgs);

            using (var switches = new StringArray(EngineArgs))
                using (var entrypointArgs = new StringArray(DartEntrypointArgs))
                {
                    var engineProperties = new FlutterDesktopEngineProperties
                    {
                        assets_path          = "../res/flutter_assets",
                        icu_data_path        = "../res/icudtl.dat",
                        aot_library_path     = "../lib/libapp.so",
                        switches             = switches.Handle,
                        switches_count       = (uint)switches.Length,
                        entrypoint           = DartEntrypoint,
                        dart_entrypoint_argc = entrypointArgs.Length,
                        dart_entrypoint_argv = entrypointArgs.Handle,
                    };

                    Engine = FlutterDesktopEngineCreate(ref engineProperties);
                    if (Engine.IsInvalid)
                    {
                        throw new Exception("Could not create a Flutter engine.");
                    }
                }

            var windowProperties = new FlutterDesktopWindowProperties
            {
                x           = WindowOffsetX,
                y           = WindowOffsetY,
                width       = WindowWidth,
                height      = WindowHeight,
                transparent = IsWindowTransparent,
                focusable   = IsWindowFocusable,
                top_level   = IsTopLevel,
            };

            View = FlutterDesktopViewCreateFromNewWindow(ref windowProperties, Engine);
            if (View.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }
        protected override void OnCreate()
        {
            base.OnCreate();

            var windowProperties = new FlutterDesktopWindowProperties
            {
                headed      = IsHeaded,
                x           = WindowOffsetX,
                y           = WindowOffsetY,
                width       = WindowWidth,
                height      = WindowHeight,
                transparent = IsWindowTransparent,
                focusable   = IsWindowFocusable,
            };

            Utils.ParseEngineArgs(EngineArgs);

            using var switches       = new StringArray(EngineArgs);
            using var entrypointArgs = new StringArray(DartEntrypointArgs);
            var engineProperties = new FlutterDesktopEngineProperties
            {
                assets_path          = "../res/flutter_assets",
                icu_data_path        = "../res/icudtl.dat",
                aot_library_path     = "../lib/libapp.so",
                switches             = switches.Handle,
                switches_count       = (uint)switches.Length,
                entrypoint           = DartEntrypoint,
                dart_entrypoint_argc = entrypointArgs.Length,
                dart_entrypoint_argv = entrypointArgs.Handle,
            };

            Handle = FlutterDesktopRunEngine(ref windowProperties, ref engineProperties);
            if (Handle.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }
Ejemplo n.º 6
0
        protected override void OnCreate()
        {
            base.OnCreate();

            // Read the current platform version and choose a Tizen 4.0 embedder if applicable.
            Information.TryGetValue("http://tizen.org/feature/platform.version", out PlatformVersion);

            // Read engine arguments passed from the tool.
            ParseEngineArgs();
            InternalLog.Info(LogTag, $"switches: {string.Join(" ", EngineArgs)}");

            // Get the screen size of the currently running device.
            if (!Information.TryGetValue("http://tizen.org/feature/screen.width", out int width) ||
                !Information.TryGetValue("http://tizen.org/feature/screen.height", out int height))
            {
                InternalLog.Error(LogTag, "Could not obtain the screen size.");
                return;
            }
            var windowProperties = new FlutterWindowProperties
            {
                width  = width,
                height = height
            };

            // Get paths to resources required for launch.
            string resPath     = Current.DirectoryInfo.Resource;
            string assetsPath  = $"{resPath}/flutter_assets";
            string icuDataPath = $"{resPath}/icudtl.dat";
            string arch        = RuntimeInformation.ProcessArchitecture switch
            {
                Architecture.X86 => "x86",
                Architecture.X64 => "x64",
                Architecture.Arm => "arm",
                Architecture.Arm64 => "aarch64",
                _ => "",
            };
            string aotLibPath = $"{resPath}/../lib/{arch}/libapp.so";

            using var switches = new StringArray(EngineArgs);
            var engineProperties = new FlutterEngineProperties
            {
                assets_path      = assetsPath,
                icu_data_path    = icuDataPath,
                aot_library_path = aotLibPath,
                switches         = switches.Handle,
                switches_count   = (uint)switches.Length,
            };

            // This check is not actually required, but we want to make sure that libflutter_engine.so is loaded
            // before a call to FlutterCreateWindow() is made to avoid library loading issues on TV emulator.
            if (FlutterEngineRunsAOTCompiledDartCode())
            {
                InternalLog.Debug(LogTag, "Running in AOT mode.");
            }

            Handle = FlutterCreateWindow(ref windowProperties, ref engineProperties);
            if (Handle.IsInvalid)
            {
                throw new Exception("Could not launch a Flutter application.");
            }
        }