peiffer-innovations / json_dynamic_widget

MIT License
226 stars 68 forks source link

Possible bug using Flutter Web 3.24.4 #336

Closed vinicius-gregorio closed 2 weeks ago

vinicius-gregorio commented 2 weeks ago

Describe the bug Everything is as in the README.MD and docs, but still not working a simple text.

To Reproduce

  1. Create a simple json structure

    const json01 = {
    "type": "text",
    "args": {"data": "Hello, World!"}
    };
  2. Create a simple page

    
    import 'package:fl_server_driven/common/widgets/global_appbar/global_appbar.dart';
    import 'package:fl_server_driven/common/widgets/global_drawer/global_drawer.dart';
    import 'package:fl_server_driven/data/json/json01.dart';
    import 'package:json_dynamic_widget/json_dynamic_widget.dart';

class RendererHomePage extends StatefulWidget { const RendererHomePage({super.key});

@override State createState() => _RendererHomePageState(); }

class _RendererHomePageState extends State { late JsonWidgetData? _data;

@override void initState() { super.initState(); _data = JsonWidgetData.fromDynamic(json01, registry: JsonWidgetRegistry.instance); }

@override Widget build(BuildContext context) { return Scaffold( backgroundColor: Colors.grey[200], appBar: GlobalAppbar(title: "Renderer"), drawer: GlobalDrawer(), body: Column( children: [ if (_data != null) Container( decoration: BoxDecoration( color: Colors.transparent, border: Border.all( color: Colors.black, width: 1, )), width: 500, height: 300, child: _data!.build( context: context, registry: JsonWidgetRegistry.instance, ), ) ], ), ); } }


3. This will create a Container with nothing inside:
![image](https://github.com/user-attachments/assets/6eb7558a-1089-4d5f-bddf-0f5dccda8d5e)

> Note: No errors on console.

**Expected behavior**
A text with "Hello, World!"  inside.
![image](https://github.com/user-attachments/assets/79d9c112-7ba9-478a-a2d8-45d6a459d930)

## Enviroment

### Flutter doctor

```bash
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 3.24.4, on Microsoft Windows [versao 10.0.22631.4317], locale pt-BR)        
[✓] Windows Version (Installed version of Windows is version 10 or higher)
[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
[✓] Chrome - develop for the web
[✓] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.1.4)
[✓] Android Studio (version 2021.1)
[✓] IntelliJ IDEA Community Edition (version 2022.1)
[✓] VS Code, 64-bit edition (version 1.94.2)
[✓] Connected device (3 available)
[✓] Network resources

• No issues found!

Pubspec.yaml of my test project:

name: json_widget_test
description: "A new Flutter project."

version: 0.0.0+1
environment:
  sdk: ^3.5.4

dependencies:
  flutter:
    sdk: flutter
  cupertino_icons: ^1.0.8
  build_runner: ^2.4.13
  json_dynamic_widget_codegen: ^1.0.6
  json_dynamic_widget_plugin_components: ^1.0.1
  json_dynamic_widget_plugin_font_awesome: ^4.0.0+24
  json_dynamic_widget_plugin_ionicons: ^4.0.0+28
  json_dynamic_widget_plugin_js: ^2.0.2+20
  json_dynamic_widget_plugin_lottie: ^4.0.0+23
  json_dynamic_widget_plugin_material_icons: ^4.0.0+24
  json_dynamic_widget_plugin_markdown: ^5.0.0+16
  json_dynamic_widget_plugin_rive: ^4.0.0+15
  json_dynamic_widget_plugin_svg: ^4.0.0+25
  flutter_modular: ^6.3.4
  json_dynamic_widget: ^7.3.1+6

dev_dependencies:
  flutter_test:
    sdk: flutter
  flutter_lints: ^5.0.0
flutter:
  uses-material-design: true

OS:

Windows 11 / MacOS Sonoma 14.7

vinicius-gregorio commented 2 weeks ago

IF I'm being dumb, could you point where the problem relies?

vinicius-gregorio commented 2 weeks ago

I was being dumb. after debugging it for 4h I noticed. The problem was inside the json structure. Before:

const json01 = {
  "type": "text",
  "args": {"data": "Hello, World!"}
};

after:

const json01 = {
  "type": "text",
  "args": {"text": "Hello, World!"}
};

I think the problem relies where the EXPORTER is exporting the "Text" args as "data". And not as "text"

jpeiffer commented 2 weeks ago

So wait,.is there an issue? If so, please reopen this. It seems like the problem may not be with the renderer but with the exporter.