Giter Club home page Giter Club logo

flutter_feathersjs.dart's Introduction

flutter_feathersjs.dart's People

Contributors

dahkenangnon avatar dependabot[bot] avatar shabanovd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

flutter_feathersjs.dart's Issues

How do you detect errors with socketio methods? For a call like:

How do you detect errors with socketio methods? For a call like:

var sessionInfo = await _picServer.scketio.get(serviceName: "sessions", objectId: sessionId);

If the session is found a list is returned with the object JSON in sessionInfo[1].

Session join info: [null, {_id: 5ff9e945189544aabbdc940f, description: , invited_users: [], muted_users: [], active_users: [], name: 7239611028, images_dir: ./data/7239611028, creator_email: [email protected], creator_id: 5ff8c19e4d3f7b8c218e8240, createdAt: 2021-01-09T17:35:01.813Z, updatedAt: 2021-01-09T17:35:01.813Z, __v: 0}]

For invalid objectId values a JsonMap is returned.

{name: NotFound, message: No record found for id '5ff9e945189544aabbdc940e', code: 404, className: not-found, errors: {}}

What is the best way to check for success/failure from these API calls?

Thanks,

Kevin

Originally posted by @kevinbeck76 in #3 (comment)

Web support

Does this feathersjs client support Flutter Web target?

socket queries

Hello from Turkey; Firstly great job. How can we make socket queries with this library? I check the docs there is nothing about it

Allow developers to initialize the Rest and Socket config separately

Add offline database support Add synchronization with remote api

Seem like they'd be ideal!

These would be incredible features ๐Ÿš€
If it isn't possible yet: Allow developers to initialize the Rest and Socket config separately (especially the baseUrl) or as the official feathers-client, let the developer decide whether to work only with socket or rest. An example:

I host a Feathers API behind a reverse proxy at https://my-app.com/api - then the socket configuration would still need the https://my-app.com/ because the baseUrl of https://my-app.com/api would imply that the socket.io uses "api" as the namespace. On the other hand, the Rest API would still need the https://my-app.com/api as baseUrl. Therefore this should be configurable separately.

An idea for this could be, to initialize the package in flutter like the feathers package. Therefore to keep the mentality of feathers to be independent of the transportation mode and the package is easily extendable for the Primus Client for example.

A example initialization could be:

Socket.io

import 'package:flutter_feathersjs/flutter_feathersjs.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;

FlutterFeathersjs client = FlutterFeathersjs();
IO.Socket io = IO.io(baseUrl)

client.configure(FlutterFeathersjs.socket(io));

client.service('messages').create({
  text: 'A new message'
});

Rest (With Dio)

import 'package:flutter_feathersjs/flutter_feathersjs.dart';
import 'package:dio/dio.dart';

FlutterFeathersjs client = FlutterFeathersjs();
Dio dio = Dio(BaseOptions(
      baseUrl: baseUrl,
      headers: extraHeaders
));

client.configure(FlutterFeathersjs.rest(dio));

client.service('messages').create({
  text: 'A new message'
});

Originally posted by @dmatuschek in #19 (comment)

Troubleshooting Flutter App Integration with Feathers.js Server

I am reaching out regarding a project I am currently undertaking involving the development of a Flutter app. This project necessitates real-time data integration from the server socket, which is built using Feathers.js. After extensive research, I discovered that your plugin is the sole option available on pub.dev that meets our requirements.

I diligently followed the provided documentation to integrate the plugin into our application. However, despite our efforts, we encountered difficulties in retrieving data or user information, with occasional failures in the re-authentication process.

In light of this, I would greatly appreciate it if you could spare some time to review the attached main.dart file. Your expertise in this matter would be invaluable in identifying any potential mistakes or oversights in our implementation.

import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_feathersjs/flutter_feathersjs.dart';
import 'package:socket_io_client/socket_io_client.dart' as IO;

//Using following dependencies :

// flutter_feathersjs: ^4.1.3
// flutter_slidable: ^3.0.0
// http: ^0.13.5
// logger: ^1.3.0
// socket_io_client: ^1.0.2
// username_gen: ^1.0.4

//Variables to store login data
const BASE_URL = '';
const UserName = '';
const Password = '';
const Strategy = "local";

//  Main Function
void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const MyApp());
}

// Configuration for App
class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'FlutterFeathersJS',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
        fontFamily: "Abel",
        scaffoldBackgroundColor: const Color(0xffF5F5F3),
      ),
      home: const MySocketData(),
    );
  }
}

// Class to get Data from socket and manage it
class MySocketData extends StatefulWidget {
  const MySocketData({Key? key}) : super(key: key);

  @override
  State<MySocketData> createState() => _MySocketDataState();
}

class _MySocketDataState extends State<MySocketData> {
  late FlutterFeathersjs flutterFeathersjs;
  late FlutterFeathersjs client;

  @override
  void initState() {
    super.initState();
    // initialization of client
    flutterFeathersjs = FlutterFeathersjs()..init(baseUrl: BASE_URL);
    // Login to server socket and get data from service
    getData();
  }

  Future<void> getData() async {
    await flutterFeathersjs.init(baseUrl: BASE_URL);
    try {
      // Authenticate
      await flutterFeathersjs
          .authenticate(
        userName: UserName,
        password: Password,
        strategy: Strategy,
      )
          .then((response) {
        log("Login Response: $response");
      }).onError((error, stackTrace) {
        log("Auth Error: $error");
        log("Auth StackTrace: $stackTrace");
      });

      log("Login Successful");

      // Re-Authenticate

      var response = await flutterFeathersjs.reAuthenticate();
      print('RE-Auth : $response');

      // Getting User

      await flutterFeathersjs.user().then((value) {
        log("User : $value");
      });

      // Connecting to service

      dynamic a = await flutterFeathersjs.service("fire-data").then((value) {
        log("Fire data: ${value.toString()}");
      });
    } catch (e) {
      // Catch errors
      log("<>- Error -<>: \n$e");
    }
  }

  // Empty Screen (Output in Terminal)
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Socket Data Service'),
      ),
      body: Center(
        child: SingleChildScrollView(
          child: Container(
            child: Text("Check Terminal..."),
          ),
        ),
      ),
    );
  }
}

i need hendel Socket.io events !!

** Thanks for this package, @Dahkenangnon โ™ฅโ™ฅ
I have a different approach to connecting to the server.
Every device must connect to its own server.
if this address and port do not connect, show the client an error to check, and dispense with it so that auto-reconnecting does not occur;

i want ti handle this evnt whene socket = FlutterFeathersjs()..init(baseUrl: baseUrl);

2022-06-14_015805

this is my Ui Project ->

2022-06-14_020413

[New Features Plans] Some awesome feature are coming for this package user

๐ŸŸข New features

These features are planned for from now to June 2022.

More description will be push this weekend to explain in more details these features which are coming.
But before all, i want to know your point of view, would you like these features ?

  • Going to null safety ( #29 )
  • Update documentation
  • Testable version of flutter web
  • Testable version of flutter desktop
  • Add feathers services like api
  • Add authentication client
  • Update demo app to sound null safety

At the end, this package will be your very cool and very serious choice for flutter mobile app if you like using feathers js rest+realtime api.

cannot be called on 'Map<dynamic, dynamic>?' because it is potentially null

Describe the bug
When building my app with this package, I get the error "cannot be called on 'Map<dynamic, dynamic>?' because it is potentially null." We were able to resolve the issue by changing this._socket.io.options['extraHeaders'] = to this._socket.io.options!['extraHeaders'].

I have attached a screenshot of the error and a screenshot of the fix. Can you implement this fix or a fix you deem necessary to resolve the issue?

To Reproduce
Build app with package.

Expected behavior
Build successfully.

Screenshots
flutter-feathersjs-fix
feathersjs-error

soccer io errors on init()

Hi Team

I am having this issue when running the init with base url
my init looks like this
flutterFeathersjs.init(baseUrl: "https://www.mysite.xyz/api/");
I.m initialising the instance from an Oninit() hook in my GetxController

flutter logs this error :
flutter: WebSocketException: Connection to 'https://www.mysite.xyz:0/socket.io/?EIO=3&transport=websocket#' was not upgraded to websocket
Notice the https://www.mysite.xyz**:0** (colon zero at the end of the url...port being added to the url in the error message)
I don't know if this is the problem why ...I am testing my backend and all configs are fine on the backend.

this is my Nginx: (for that block - its all that that's required right?)
location /api {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $http_host;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:10123;
}

all my restful services work fine via postman only when I use this lib and run this init...I get the socket upgrade issue

can someone please assist (is there something that's appending the :0 at the end of the url?)

Other platform supported demo

  • Looking for a demo app tested for pur dart app

This feature want the package support a pur dart app (ex: a cli written 100% in dart)


  • Looking for a demo app tested for flutter Desktop

By now, the package is compatible with flutter desktop, but not tested on.
W're looking to provide a demo app and update test to run linux, windows and macOs


  • Looking for a flutter app tested for flutter Web

Flutter web support is not yet available in this project.
We think this should be quickly fixed.

Incoming Version 5.0.0

We're are working on the next release of this Project: ๐ŸŽฏ Version 5.0.0

This is a draft of our roadmap.

๐Ÿ‘ I use "We" becauase @AurelAgbodoyetin joined me to maintain and make great again this package.

You're always welcome to contribute, just email to dah.kenangnon [at] gmail [dot] com

Now, our roadmap:

  • Update and document current version (v4)
    • Updating package dependencies for version 4.1.1-dev (3)
    • Redeploy the feathers js version 4.0.0 api elsewhere because heroku has breaken the previous one. (0)
    • Flutter demo implementing all package methods in version 4.1.1-dev (2)
    • Update package documentation for version 4.1.1-dev (4)
    • Test package version 4.1.1-dev with version 4.0 of feathers (1)
  • Preparing version 5.0.0 of the package
    • Deploy a feathers js demo api with version 5.0.0 which should be use for flutter_feathersjs v5.0.0
    • Write a migration guide from package version 4.x to package version 5.0.0 (5)
    • Generate a basic API with feathersjs.com and deploy it in a test environment for the demo
    • Understand the breaking changes in version 5.0.0 of feathersjs.com
    • Take into account the breaking changes in version 5.0.0 of the package
    • Update the documentation for version 5.0.0 of the package

This is a draft and should be update when needed

Authentication Breaking Due to Casting Error on Future

I'm not entirely sure what changed within my project (new packed updated perhaps?), but Flutter Feathers started failing on authentication due to a casting error.

Tracked the problem down to feathersjs.dart, line 61:

//Then auth with jwt socketio
bool isAuthenticated = await (scketio.authWithJWT() as FutureOr<bool>);

Cast exception is thrown as it is expecting Future<dynamic>.

If I modify the code to use dynamic, it works:
bool isAuthenticated = await (scketio.authWithJWT() as Future<dynamic>);

Update: It's due to my project updating from 3.0.0 of the package to 4.0.2: I didn't have a version specified so it updated unintentionally. Seems there is an issue in 4.0.2?

I encounter a Late Field initialization error when using Socket-IO

This is the error I am encountering on calling find query on feathers Js server from flutter app both running on local machine

I/flutter ( 7821): โ”‚ โ›” Unexpected error ::: LateInitializationError: Field 'scketio' has not been initialized.

The error comes from this code below;
This code from my provider;

  Future<APIResponse<List<ActivityI>>> getActivities() async {
    List<ActivityI>? messages;
    String? error;
    try {
      Map<String, dynamic> response = await socketIOClient.scketio.find(
        serviceName: "activities",
        query: {},
      );
      logger.i(response.toString());
      messages = List<Map<String, dynamic>>.from(response["data"])
          .map((map) => ActivityI.fromMap(map))
          .toList();
    } on FeatherJsError catch (e) {
      logger.e("FeatherJsError error ::: Type => ${e.type} ::: Message => ${e.message}");
      error = "Unexpected FeatherJsError occurred, please retry!";
    } catch (e) {
      logger.e("Unexpected error ::: ${e.toString()}");
      error = "Unexpected error occurred, please retry!";
    }
    return APIResponse(errorMessage: error, data: messages);
  }

// Below is how I have initialized my socket-io client for the flutter app;

FlutterFeathersjs socketIOClient = FlutterFeathersjs();

void main() {
  WidgetsFlutterBinding.ensureInitialized();

  socket.Socket io = socket.io(API.baseUrl, <String, dynamic>{
    'transports': ['websocket'],
  });
  socketIOClient.configure(FlutterFeathersjs.socketioClient(io));

  runApp(MultiProvider(providers: [
    ChangeNotifierProvider(create: (_) => UserProvider()),
    ChangeNotifierProvider(create: (_) => ThemeProvider()),
    ChangeNotifierProvider(create: (_) => ActivityProvider()),

  ], child: const MyApp()));
}

//Currently using flutter_feathersjs: 4.1.5
//                       socket_io_client: ^2.0.1

//  This is my code calling on getActivities from ActivityProvider

 fetchActivities() async {
    context.read<ActivityProvider>().getActivities().then(
      (response) {
        isLoading = false;
        if (response.errorMessage == null) {
          setState(() {
            activities = response.data!;
          });
        } else {
          setState(() {
            error = response.errorMessage;
          });
        }
      },
    );
  }

  @override
  void initState() {
    isLoading = true;
    fetchActivities();
    super.initState();
  }

Currently running debug app on memu emulator

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.