Search
 
SCRIPT & CODE EXAMPLE
 

DART

Flutter Rendering Widgets Using JSON Data

import 'dart:convert';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:json_dynamic_widget/json_dynamic_widget.dart';


void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        debugShowCheckedModeBanner: false,
        theme: ThemeData(
          primarySwatch: Colors.teal,
        ),
        home: const RenderingWidget());
  }
}

class RenderingWidget extends StatefulWidget {
  const RenderingWidget({Key? key}) : super(key: key);

  @override
  _RenderingWidgetState createState() => _RenderingWidgetState();
}

class _RenderingWidgetState extends State<RenderingWidget> {
  Map<dynamic, dynamic> mapData = {};
  var registry = JsonWidgetRegistry.instance;

  Future<Map> readJson() async {
    final String response = await rootBundle.loadString('assets/sample.json');
    final data = await json.decode(response);
    return data;
  }

  @override
  Widget build(BuildContext context) {
    readJson().then((value) => mapData = value);
    var widget = JsonWidgetData.fromDynamic(mapData, registry: registry);
    return widget!.build(context: context);
  }
}
Comment

PREVIOUS NEXT
Code Example
Dart :: dart list slice 
Dart :: ordered/numbered list in flutter 
Dart :: vxstate listen not working flutter 
Dart :: * In pubspec.yaml the flutter.plugin.{androidPackage,iosPrefix,pluginClass} keys are deprecated. Instead use the flutter.plugin.platforms key introduced in Flutter 1.10.0 
Dart :: dropdown flutter transparent 
Dart :: dart multi line print statement 
Dart :: icons flutter to put a right 
Dart :: accumulator code example in flutter 
Dart :: Should I learn Dart for Flutter? 
Dart :: what is the problem to aqueduct with dart 2.8 
Swift :: time formats swift 
Swift :: how to change the font of buttons programmatically swift 
Swift :: shadow color swiftui 
Swift :: swift func for constraint 
Swift :: stackoverflow get firbas analytics in ios 
Swift :: How to control the line spacing in UILabel 
Swift :: swift check dictionary has key 
Swift :: swift programming language wikipedia 
Swift :: swift go back to previous view controller 
Swift :: add top corner radius swift 
Swift :: swift dispatch queue 
Swift :: swift date difference in days 
Swift :: define struct swift 
Swift :: hex color swiftui 
Swift :: swift simulatore condition 
Swift :: swift pdf thumbnail 
Swift :: uilabel set fon siz 
Swift :: swift check if array values are equal 
Swift :: enum in swift 
Swift :: two variable sum in swift 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =