Securrency-OSS / mirai

Mirai is a Server-Driven UI (SDUI) library for Flutter. Mirai allows you to build beautiful cross-platform applications with JSON in real time.
https://pub.dev/packages/mirai
MIT License
478 stars 58 forks source link

feat: Added a new way to redefine how we declare EdgeInsets #276

Closed superiorsd10 closed 2 months ago

superiorsd10 commented 2 months ago

Description

Previously, there was only one way to define MiraiEdgeInsets and it looked like this

              "padding": {
                "top": 8,
                "left": 12,
                "right": 12,
                "bottom": 8
              }

In this pull request, I have added the two new ways as suggested to declare MiraiEdgeInsets.

  1. To give the same padding to all directions, you can now just write like this.
              "padding": 10, 
  1. To give padding to all directions, but in a better and more concise way, you can now just write it like this.
              "padding": [10, 12, 12, 10]

To approach this issue, I have defined a new static method inside MiraiEdgeInsets named _fromJson that takes a dynamic argument and checks if the type of argument is among three acceptable types i.e. num, List<num>, Map<String, dynamic>, and returns MiraiEdgeInsets; otherwise, throw an ArgumentError.

Related Issues

Closes #260

Screen Recording

https://github.com/Securrency-OSS/mirai/assets/92971894/6396a9b4-71fd-4272-a5ce-28cb173999e3

Type of Change

divyanshub024 commented 2 months ago

Hey @superiorsd10,

Loved what you did with that PR! You nailed the fix and seriously upped our game. Big thanks for your awesome work! πŸŒŸπŸ‘

There is one small error I'm getting when using "padding": [10, 12, 10, 10],. Can you please check?

196mβ”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€<…>
flutter: \^[[38;5;196mβ”‚ #0   Log.e (package:mirai/src/utils/log.dart:11:42)<…>
flutter: \^[[38;5;196mβ”‚ #1   Mirai.fromJson (package:mirai/src/framework/mirai.dart:107:11)<…>
flutter: \^[[38;5;196mβ”œβ”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„β”„<…>
flutter: \^[[38;5;196mβ”‚ β›” Invalid argument(s): Invalid input format for MiraiEdgeInsets<…>
flutter: \^[[38;5;196m└───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────<…>
superiorsd10 commented 2 months ago

Hello @divyanshub024 πŸ‘‹

On replicating the behavior stated by you, it's working fine, and I'm not getting any errors. Can you please tell me more about the issue?

divyanshub024 commented 2 months ago

Hey @superiorsd10,

I took the pull again and it still showed the same error.

https://github.com/Securrency-OSS/mirai/assets/16731434/a301932d-3160-4f61-8822-43be6dfa7db7

superiorsd10 commented 2 months ago

Hello @divyanshub024 πŸ‘‹

I have fixed the above issue. You can pull the latest changes now, and check if it works. I have tested it on my end, and it's working fine.

Thank you,