Created
March 2, 2020 21:11
-
-
Save Bruising6802/45bd7fe8d23ddcdd5e051eef7c7bb54a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'package:flutter/material.dart'; | |
import 'dart:convert'; | |
void main() => runApp(MyApp()); | |
class MyApp extends StatelessWidget { | |
@override | |
Widget build(BuildContext context) { | |
return MaterialApp( | |
home: MyHomePage(), | |
); | |
} | |
} | |
class MyHomePage extends StatefulWidget { | |
@override | |
_MyHomePageState createState() => _MyHomePageState(); | |
} | |
class _MyHomePageState extends State<MyHomePage> { | |
static String _widget = Text('D').toString(); | |
static String rawJson = """{"widget":"L($_widget..replaceAll(" ", ' '))L"}"""; | |
static Map<String, dynamic> map = jsonDecode(rawJson); | |
static String widgete = map['widget']; | |
WidgetJson widgetJson = WidgetJson(widget: widgete); | |
@override | |
Widget build(BuildContext context) { | |
print(_widget); | |
return Scaffold( | |
appBar: AppBar( | |
title: Text("Widget Title"), | |
), | |
body: Stack( | |
children: <Widget>[Text("$widgete")], | |
), | |
); | |
} | |
} | |
class WidgetJson { | |
WidgetJson({this.widget}); | |
String widget; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment