How to use platform channels with FlutterView or Flutter.createFragment - flutter

I just saw the flutter roadmap mentioning a preview of adding flutter to existing project.
I am still not sure how to use platform channels when using FlutterView or Flutter.createFragment. Usually they are available in the FlutterActivity instance.

You create a new instance of the channel and pass in your FlutterView. This documentation gives a good overview.

Related

Firebase 9 & Flutter: How to initializeApp?

I am desperately trying to figure out how to initializeApp with Flutter (not React Native).
I know about the functions to use, but I can not find the firebaseConfig I need to pass into the function.
And no matter what I search for, every resources references to React Native, like as if nobody codes with Flutter since Firebase 9 has been released anymore (or I am the only dummy which is not able to resolve this by myself).
Can someone tell me where to get the firebaseConfig object from?
If I add a new app to my project, I only get the google-services.json, which does NOT include the firebaseConfig object I need to pass.
I understand your confusion now, let me explain. When the guy in the video talks about Firebase v9 he is talking about the SDK version which in the case of Javascript (which I suppose is his main topic in his channel) is currently 9.17.1 an the version 9 has been around since 2021 so it is not new. The different SDKs have their own versions for each platform so thinking it will be the same in every SDK is a mistake by itself. You can check the SDKS here. So there is no Firebase v9, there is a Firebase SDK for javascript version 9. They managed in that way in javascript and in flutter it is not the same. Being that the last update in the flutter SDK was literally yesterday I'm pretty sure they have their reasons to not implement the same functions in flutter since 2021.
Now, one of the thinks the guy talks in the video is deconstructing, which is something common in javascript. The way you do this in flutter is by using show.
So you would be doing this for example:
import 'package:cloud_firestore/cloud_firestore.dart' show FirebaseFirestore, QuerySnapshot; //Add everything you would be using
This way only the specific parts of the library will be imported and the amount of code the Dart VM has to load will be reduced.
As of the access to documents, it is still the same but you can easily create a helper class that contents your references to your collections and then just use that class to reduce the boilerplate code created by the firebase SDK.
You have to install the Firebase CLI and run firebase init.
You need to use the package firebase_core that will give you access to the class Firebase so you can use it to initialize your app Firebase.initializeApp() you can pass the default options for the current platform using Firebase.initilizeApp(options: DefaultFirebaseOptions.currentPlatform) usually your IDE will automatically import the corresponding package but in case it does not you would have to import 'firebase/firebase_options.dart';
An useful link to the documentation: Add Firebase to your Flutter App

How can I set tflite PoseNet "Single-Person Pose Estimation" on Flutter?

I'm on a project that uses tflite Posenet to run on a mobile with Flutter Framework. We wanted more precision score on our tests, but we realized that the repository which is given us by the original example on Dart API docs https://pub.dev/documentation/tflite/latest/ uses Multi-Person Pose Estimation by defalt. (Repository mentioned:https://github.com/shaqian/flutter_realtime_detection).
We know that the original tfjs repository talks about it and give examples https://github.com/tensorflow/tfjs-models/tree/master/posenet but we can't find it on Dart API for flutter.
How can I set Single-Person Pose Estimation?
There is another tflite_flutter plugin which is actively being developed: https://pub.dev/packages/tflite_flutter. Please take a look.
This plugin allows you to run any custom .tflite model, so you should be able to download the single person posenet model provided from the official TFLite site here: https://www.tensorflow.org/lite/models/pose_estimation/overview.
There aren't any official flutter examples, but you should be able to refer to the Android/iOS examples to see how to pre-process / post-process the data.
Hy guys, updating the issue:
We maneged it after some tests with the Tflite.runPoseNetOnImage function. This function has a property called numResults, wich we can set to "1". Tflite.runPoseNetOnFrame has the same property.
You can see it in this link (https://pub.dev/documentation/tflite/latest/)

How to get GLFW window Id of FlutterWindow

I am trying to build a video player using flutter for Desktop. There is a video_player plugin available for iOS and Android, but not for Desktop. So, for the time being thought of trying to use gstreamer for decoding and hardware rendering in C++ code as back-end to flutter. The idea is to pass the Window Id of the flutter window to gstreamer's glimagesink plugin for rendering the video.
I am using the latest code from https://github.com/google/flutter-desktop-embedding as the base for my experiments. Below mentioned points are with reference to this repo.
In file flutter-desktop-embedding/example/linux/main.cc, FlutterWindowController object is created as shown below.
flutter::FlutterWindowController flutter_controller(icu_data_path);
This internally calls
FlutterDesktopInit();
While hovering the mouse pointer on the above method, VS code shows the following
bool FlutterDesktopInit()
Sets up the library's graphic context. Must be called before any other
methods.
Note: Internally, this library uses GLFW, which does not support multiple
copies within the same process. Internally this calls glfwInit, which will
fail if you have called glfwInit elsewhere in the process.
It is clear that FlutterDesktopInit() uses GLFW to create window. Checked whether I can get the window handle. But, no luck. I could only get the FlutterWindow object as shown below.
flutter::FlutterWindow *win = flutter_controller.window();
Appreciate if somebody can give some hint on how to get the GLFW window handle, which can be used with glimagesink.
You can't get references to any GLFW objects through that API. This is by design because, as the comment you quoted says, you can't have multiple copies of GLFW within the same process. GLFW is statically linked into the Linux Flutter embedding, so you can't use GLFW in the runner or a plugin.
Implementing a video player should be done using the texture APIs, which will be added for GLFW in this PR.

How can I use faunaDB on the flutter?

As FaunaDB documentation, it seems that there is no dart API nor REST API. Also, I can't find the FaunaDB package in the Flutter Packages.
Is there any way to use the FaunaDB on the flutter?
I think the easiest way to use Flutter with FaunaDB is to use FaunaDB's GraphQL interface and Dart package graphql_flutter.
I recently managed to read data from FaunaDB using graphql_flutter, and will update this post when I have tested it more.
Currently we don't offer first party support for flutter. You can build a third-party driver for Dart based on our current open source drivers if you'd like. They do use json/http under the hood. If you are targeting android another option might be to fork the java driver and switch out http clients to be android friendly and use a platform channel.
Dart is able to use javascript libraries
How to use JavaScript libraries in your Dart applications
You can simply use the javascript driver
https://github.com/fauna/faunadb-js
https://medium.com/flutter-community/building-a-simple-application-with-flutter-and-graphql-5786764df102
Recently there was a new package published that can help you to use faunaDB with dart/flutter: faunadb_http This library also provides query classes that closely mimic FQL functions.

Flutter Adding Account with AccountManager?

Query
I want to adding account with AccountManager in Flutter.
I have googled but I found in Android not in Flutter; I found flutter package:
https://pub.dev/packages/account_manager_plugin
this package get all account but never to add new account.
any body help me...
Currently, there is no available plugin that has all the features of Android’s AccountManager. You’ll either have to dive into its source to jumpstart and create your own plugin, wait for one to be available, or integrate your own Android-specific code.