Coder Social home page Coder Social logo

nylo-core / support Goto Github PK

View Code? Open in Web Editor NEW
15.0 3.0 8.0 750 KB

Support library for the Nylo framework. This library supports routing, widgets, localization, cli, storage and more.

Home Page: https://nylo.dev

License: MIT License

Dart 100.00%
cli localization routing storage widgets

support's Introduction

support's People

Contributors

agordn52 avatar agwoosignal avatar lpdevit avatar youssefkadaouiabbassi avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

support's Issues

Exception on adding Route Guard

I'm getting exception while adding route guard to a route as below.

router.route(DashboardPage.path, (_) => DashboardPage()).addRouteGuard(AuthRouteGuard());

E/flutter ( 8167): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: Unsupported operation: Cannot add to an unmodifiable list
E/flutter ( 8167): #0      UnmodifiableListMixin.add (dart:_internal/list.dart:114:5)
E/flutter ( 8167): #1      NyRouterRoute.addRouteGuard (package:nylo_support/router/models/nyrouter_route.dart:88:18)
E/flutter ( 8167): #2      appRouter.<anonymous closure> (package:nalco_netra/routes/router.dart:15:72)
E/flutter ( 8167): #3      nyRoutes (package:nylo_support/router/router.dart:30:8)
E/flutter ( 8167): #4      appRouter (package:nalco_netra/routes/router.dart:8:16)
E/flutter ( 8167): #5      RouteProvider.boot (package:nalco_netra/app/providers/route_provider.dart:7:20)
E/flutter ( 8167): #6      bootApplication (package:nylo_support/providers/providers.dart:17:39)

Cannot determine whether updateLocale is finished or not

Hi, I have a question. I am trying out Nylo and having a problem with the localization, specifically the updateLocale method. As you can see in the snippet below, the method doesn't return anything. When I was trying to switch between two locales, sometimes the locale doesn't change. I'm guessing this is because the reloadLocale hasn't finished updating the locale. Is it possible to make updateLocale return a Future of when the locale has been updated. Thanks in advance!

// File: support/lib/localization/app_localization.dart

/// A locale class used to manage the current locale state.
class AppLocale {

  /// Updates the current locale for the app.
  /// Provide the [locale] you wish to use like Locale("es")
  /// The locale needs to also exist within your /lang directory
  updateLocale(BuildContext context, Locale locale) {
    this.locale = locale;
    reloadLocale(context, locale);
  }
}

Decoders does not contain a decoder for the following class: User in modelDecoders - But it does.

I've been trying to debug this issue for a couple hours now, but not sure what's going wrong and would really appreciate some help.

Context:
I hit the following error when trying to fetch / authenticate a user.

_AssertionError ('package:nylo_support/networking/models/default_response.dart': Failed assertion: line 11 pos 12: 'decoders.containsKey(type)': Your config/decoders.dart file does not contain a decoder for the following class: User in modelDecoders)

in fact, the decoders is returning an empty map (list), which is why it can't find the 'User' key. But my modelDecoders is definitely defined. See below for the relevant code.

Future<User?> logIn(String email, String password) async {
    return await network<User>(
      request: (request) => request
          .post("/api/v1/auth", data: {"email": email, "password": password}),
    );
  }

And the modelDecoders does in fact contain the User:

final Map<Type, dynamic> modelDecoders = {
  List<User>: (data) =>
      List.from(data).map((json) => User.fromJson(json)).toList(),
  User: (data) => User.fromJson(data),
  List<Product>: (data) =>
      List.from(data).map((json) => Product.fromJson(json)).toList(),
  Product: (data) => Product.fromJson(data),
  List<Vote>: (data) =>
      List.from(data).map((json) => Vote.fromJson(json)).toList(),
  Vote: (data) => Vote.fromJson(data),
};

The User model is also correct:

import 'package:nylo_framework/nylo_framework.dart';

class User extends Model {
  String? id;
  String? frlId;
  String? username;
  String? gender;
  String? email;
  String? token;
  String? sessionId;

  User({
    required this.id,
    this.username,
    this.gender,
    this.frlId,
    required this.email,
    required this.token,
    this.sessionId,
  });

  User.fromJson(dynamic data) {
    id = data['id'];
    frlId = data['frl_id'];
    username = data['username'];
    gender = data['gender'];
    email = data['email'];
    token = data['token'];
    sessionId = data['session_id'];
  }

  @override
  Map<String, dynamic> toJson() => {
        "id": id,
        "frl_id": frlId,
        "email": email,
        "token": token,
        "username": username,
        "gender": gender,
        "session_id": sessionId,
      };
}

So I am really clueless why this error is happening. Would really appreciate some assistance, been banging my head on this one for a while now.

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.