I recently stumbled across Dart, and got pretty excited about it because it almost feels like that perfect language I've always been looking for. I work with PHP at my job (Yes, I know, ew gross) as a web developer and was excited to try and build a web app using the language. Figured it couldn't be too hard as that's what Dart was originally made for. Turns out it more difficult than I though, and I can't even get off the ground. I was hoping someone else could help point me in the right direction.
So, I really haven't done any real coding in this project at all. I literally downloaded the Dart SDK, used stagehand to create web-simple project, then I added a bin/server.dart file to the project. The code in that file was pretty much taken straight out of the online documentation for the mojito package:
import 'package:mojito/mojito.dart';
main() {
var app = init();
app.router
..addStaticAssetHandler('/static');
app.start();
}
I added the dependency mojito: "^0.6.6" to the pubspec.yaml file as well of course. That's all I've done though, like I say, I haven't even managed to get off the ground yet.
When I run server.dart I get the following error:
'package:convert/src/percent/encoder.dart': malformed type: line 23 pos 13: cannot resolve class 'ChunkedConverter' from 'PercentEncoder'
I get the exact same error message if I try to build a server with the shelf_rest package instead of the mojito package.
A search of that error message doesn't bring up too much helpful info, though I found one forum where someone recommended adding convert: ^2.0.1 to the dependencies. Apparently there was a change made in that package that causes incompatibility with other packages. I tried that suggestion but it doesn't seem to be resolving the issue.
I'm certain the issue is some sort of dependency issue, I'm probably using a mix of dependencies that I guess just aren't meshing right. If someone could help me figure out what I'm doing wrong it would be much appreciated. I want to learn and start using Dart but obviously I'm not having such great luck with it...
Here's what the pubspec.yaml looks like in case it helps:
environment:
sdk: '>=1.24.0 <2.0.0'
dependencies:
shelf: ^0.6.0
mojito: "^0.6.6"
convert: ^2.0.1
dev_dependencies:
browser: ^0.10.0
dart_to_js_script_rewriter: ^1.0.1
transformers:
- dart_to_js_script_rewriter
The last version of mojito was uploaded in October 2016 and it seems abandoned. Since then, Dart has added Strong mode and begun transitioning to Dart 2. This included significant changes to the type system and updates to SDK libraries.
Additionally, transformers have also been removed - any documentation you find referencing them is out of date. And in this case, the dart2js script rewriter is for client side JavaScript, not servers.
If you're looking for Server libraries, I would recommend just starting with the latest version of Shelf
Related
I've just published an update to Dart a package that I'm working on.
https://pub.dev/packages/dshell
The latest updated doesn't seem to have any significant changes to the pubspec however pub.dev is reporting an error:
https://pub.dev/packages/dshell#flags
No valid SDK. (-20 points)
I've google this error and the associated description:
The analysis could not detect a valid SDK that can use this package.
I can't find any useful references to either message and I'm at a loss as to what might now be causing the problem.
The problem does appear to coincide with pub.dev moving to Dart 2.7 so maybe this is a bug in pana?
Any ideas on even where to look?
It looks like this is a known issue. Unfortunately, I think the only thing you can do at this point is wait until it gets fixed.
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 question is related to this one: How to check obfuscation results of flutter app?
But the answer there is unclear.
Is it possible for hackers to see the dart code in flutter apps? Or is it compiled in a way that is difficult to understand and track?
After unzipping the apk that resulted from flutter build apk - the only file I found related to my own Dart code was "libflutter.so". Looking at the functions in it by nm -D libflutter.so didn't show anything resembling my code, so it seems pretty safe. But - I would like someone who actually knows to confirm, perhaps I missed something.
What is the best practice used to publish flutter apps?
UPDATE - December 2019 - the following post says that if the app is compiled in release mode, then the dart code is compiled to assembly, which is pretty hard to reverse engineer: https://medium.com/#rondalal54/reverse-engineering-flutter-apps-5d620bb105c0
In debug mode flutter apps are jitted from source. This requires the source be distributed with the app. However you shouldn't be distributing a debug build, so let's not worry about that possibility.
In release mode your source is AoT compiled, so there is no actual copy of your source, but if someone wanted to recreate it, they could potentially (easily?) reverse engineer it from assembly.
If you want to obfuscate your compiled code, your best bet is probably to follow the advice given here:
https://github.com/flutter/flutter/wiki/Obfuscating-Dart-Code
I don't claim to be an expert on this so please do your own research, but hopefully this points you in the right direction.
Further reading about the build process:
https://proandroiddev.com/flutters-compilation-patterns-24e139d14177
Whenever I try to compile my Unity game in Xcode I get a 3 compile errors which are coming from the Unity Google Play Games plugin:
GPGSAchOrLbDelegate.h - Lexical or Preprocessor Issue 'GooglePlayGames/GooglePlayGames.h' file not found
GPGSRealTimeRoomDelegate.h - Lexical or Preprocessor Issue 'GooglePlayGames/GooglePlayGames.h' file not found
GPGSManager.h - Lexical or Preprocessor Issue 'GooglePlus/GooglePlayGames.h' file not found
I've no idea why this is happening, I followed all the setup instructions correctly.
Any help would be greatly appreciated!
one gotchya is they recently changed many of the method names in the library, in a recent update...
it's possible this has caught you out?
It's very hard to resolve this, but I found some discussion about this for example here,
http://answers.unity3d.com/questions/679424/google-play-games-plugin-for-unity-not-authenticat.html
it's a bit easier on iOS than Android.
Alternately: note that, essentially, you have not included the GooglePlayGames.h file. Include the link to "which" instructions you were following, to guess which step is problematic. (Most Unity plugins - like Prime31 - have a "preprocessor" stage that does that for you or in the case of Android fills in the damned manifest. Something is going wrong at that stage.)
I actually solved this myself by removing the plugin and starting afresh, and then starting a completely new xcode project rather than appending to an old one.
Irritating and time consuming but I got there in the end!
I'm going through the "targets" (tutorials) at dartlang.org. I'm at Target 6: Get Started with Web UI and have run into an error at step #1 under the section "Set up background compilation in Dart Editor".
Could someone explain why this error is happening, or what I could do to resolve it? The error is below.
Error setting breakpoint at 'main': 'package:logging/logging.dart':
Error: line 250 pos 24: wrong number of type arguments in type 'Comparable'
class Level implements Comparable<Level> {
^
I have not changed anything in any logging package, nor messed with any Comparable class. What gives?
Take a look at this question. I actually don't know why is this happening(If someone of the dart dev team is reading this, please, explain us :D), but it seems that they changed the Comparable interface structure in M3, and forgot to update the logging package ;)
To solve your problem, go to the "logging.dart" file and make this change:
FROM:
class Level implements Comparable<Level> {
TO:
class Level implements Comparable {
This is probably related to incompatibilities between the version of the SDK you are running and the version of web_ui. If you have the most recent version of both, they work together. If you don't want to use the most recent versions, then you have to explicitly manage the versions in your pubspec.yaml file.
I'm using Dart Editor version: 0.4.0_r18915 and web_ui version: 0.4.0
and it works fine.
Try getting the most recent version of Dart Editor, remove the pubspec.lock file, and run pub install again.
Meanwhile, I will figure out how to strengthen the language in the tutorial about managing versions.
Hope this helps.
mem