The flutter have way to run child process detached. But is it possible to do thoiut Flutter in pure Dart? I did not found such future in docs.
Looks like dart:io has a Process class that can do that.
Related
can I get some pointers on how to add Text To Speech functionality to a console/CLI app. I have tried packages for Flutter but I get this error 'Error: Not found: 'dart:ui'. I am assuming they expect a user interface.
I am pretty much a novice, would be glad answers do not assume too much on my side. Thanks!
Yes, Flutter is all about UI whereas a command line app has no UI.
They dont have anything to do with eachother except that Dart is the language used by Flutter.
Flutter tts plugins depend on the specific tts implementation embedded in the OS that the plugin will be running on — Android / IOS, etc.
A Dart command line tool runs in a VM and is OS-independent.
So, as far as I know, it is impossible to import a Flutter plugin into a Dart command line app and then compile it.
The only way I can see to get tts functionality in a Dart command line tool is to use a web based (OS-independent) tts service such as the Google text to speech API.
I see a warning about drake-visualizer on macOS will be deprecated. Could you tell me the new visualizer method? If possible, could you kindly provide a simple execution sample? Thanks!
I see a warning about drake-visualizer on macOS will be deprecated.
Yes, issue #16215 explains the background.
Could you tell me the new visualizer method?
Call the function pydrake.geometry.MeshcatVisualizerCpp.AddToBuilder to add it to your diagram. When you start your program, it will print a URL to the console where you can open a web browser to view it.
If possible, could you kindly provide a simple execution sample?
You can run drake/tutorials/rendering_multibody_plant.ipynb locally to see a demo.
Since dart:ffi is available from Dart 2.2.0-dev.2.0, I've been trying to use that library. The sample app works fine for me and I also tried to use it for my Flutter app but I couldn't call it with import "dart:ffi", although Flutter on my machine was HEAD of master that used Dart 2.3.0-dev.0.0.
I checked what happened, then I found that sky_engine didn't contain ffi.dart while it contained other libraries (e.g. "dart:core"). Also I noticed that the source files of those libraries were copied from $FLUTTER_ROOT/bin/cache/dart-sdk/lib to $FLUTTER_ROOT/bin/cache/pkg/sky_engine using BUILD.gn or _embedder.yaml and that seemed to be why I couldn't use the dart:ffi in my Flutter app.
However, in the first place, why does Flutter need sky_engine, which is "the interface between Dart and the Flutter Engine"? Why not calling them directly without this glue code?
Flutter has a good documentation for FFI to be able to call native C APIs. Adding import 'dart:ffi' as ffi; on the Flutter app works without issues as of my testing with Flutter 2.5. If you're able to provide a minimal repro of your issue, this will help folks to understand the question better.
As for the question on why sky_engine is used by Flutter, that's just simply because it's the "flutter_engine" - similar to what has been already mentioned in the comments.
The code_build (https://pub.dartlang.org/packages/code_builde) package provides a solution to generate classes and constructors, field and methods for that class.
My ultimate goal is to generate Flutter (https://flutter.io) Widgets based on the json structure given, but I don't know how to do this with the code_build or another package.
So help would be appreciated!
The general way to write something which outputs Dart code is to wrap up the functionality in a Builder and to perform the code generation with build_runner
At a high level you'd write a Builder that:
Has buildExtensions of {".json": [".dart"]}.
Reads in the buildStep.inputId asset and parses the json.
Uses code_builder to build up a String and then write it to the output asset.
Then you'd configure the builder in build.yaml. And either apply it manually to your package, or if you'd like to publish it as a utility it can apply to dependencies.
Your package would have a dev_dependency on build_runner and then you can execute builds with flutter packages run build_runner build.
There are more docs at https://github.com/dart-lang/build/tree/master/docs
You can see an example of a package which does something similar - starts with yaml files and outputs Dart files using code_builder at https://github.com/natebosch/message_builder
There is now an online tool which will generate the Dart classes from a JSON payload if you're only looking to structure your model classes. It won't do it dynamically at runtime, but it's super helpful when you're first building your program.
https://javiercbk.github.io/json_to_dart/
Or is that capability lost with the loss of the reflect package?
What I'm curious about is can I use annotations in my own flutter app? Or is that a feature only available in dart, but not flutter?
Annotations can only be used for static analysis in Flutter.
For example the analyzer that generates hints and warnings in your IDE, code generation tools like built_value, built_redux, json_serializable, and other packages that use https://github.com/dart-lang/build make use of this.
There is no way to get metadata information at runtime without dart:mirrors.
There is work in progress to make the reflectable package work with code generation. This might work with Flutter eventually to generate code that allows to access predefined metadata at runtime.
See also https://github.com/dart-lang/reflectable/tree/use_build
Yes, of course you can use metadata annotations in flutter. Flutter has a meta-library, which you can look into to know about available annotations that can be used with flutter.
Hope this helped!