1647044400
Flutter Dynamic Widget
A Backend-Driven UI toolkit, build your dynamic UI with json, and the json format is very similar with flutter widget code.
From 4.0.0-nullsafety.1 version, it supports null-safety.
From 3.0.0 version, it supports exporting your flutter code to json code. please check How to write the json code
From 1.0.4 version, it supports flutter web application.
I work for an e-commerce company. We need to build flexible pages. So we define a light UI protocol, and implement on Android and iOS. We can dynamic update App UIs by pushing a json file. With this ability, we can do some UI A/B testing without publishing App to app store. Flutter allows you to build beautiful native apps on iOS and Android from a single codebase, it can allow you to build web app later. Flutter's hot reload helps you quickly and easily experiment, build UIs, add features, and fix bugs faster. But it still build native app, the UIs can't be dynamic updated. If you want to modify the UIs, you need to publish the updated app to app store. With this project, you can build your UIs from a json string, which is the UI protocol. The json string is very similar with the Flutter widget dart code. All widget type and widget properties are the same.
Widget type will be a type property, and widget's properties will be the json properties too. All properties and their values will be almost the same. You can checkout the following document.
Currently support flutter widgets and properties
Add this to your package's pubspec.yaml file:
dependencies:
dynamic_widget: ^3.0.3
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:dynamic_widget/dynamic_widget.dart';
You should use DynamicWidgetBuilder().build
method to covert a json string into flutter widget. It will be time-consuming. so you'd better using FutureBuilder
to build the UI.
import 'package:dynamic_widget/dynamic_widget.dart';
class PreviewPage extends StatelessWidget {
final String jsonString;
PreviewPage(this.jsonString);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text("Preview"),
),
body: FutureBuilder<Widget>(
future: _buildWidget(context),
builder: (BuildContext context, AsyncSnapshot<Widget> snapshot) {
if (snapshot.hasError) {
print(snapshot.error);
}
return snapshot.hasData
? SizedBox.expand(
child: snapshot.data,
)
: Text("Loading...");
},
),
);
}
Future<Widget> _buildWidget(BuildContext context) async {
return DynamicWidgetBuilder.build(jsonString, context, new DefaultClickListener());
}
}
WidgetParser
abstract class.DynamicWidgetBuilder.addParser(WidgetParser parser)
method.This is a RaisedButton widget parser.
import 'package:dynamic_widget/dynamic_widget/utils.dart';
import 'package:dynamic_widget/dynamic_widget.dart';
import 'package:flutter/material.dart';
class RaisedButtonParser extends WidgetParser {
@override
String get widgetName => "RaisedButton";
@override
Widget parse(Map<String, dynamic> map, BuildContext buildContext, ClickListener listener) {
String clickEvent =
map.containsKey("click_event") ? map['click_event'] : "";
var raisedButton = RaisedButton(
color: map.containsKey('color') ? parseHexColor(map['color']) : null,
disabledColor: map.containsKey('disabledColor')
? parseHexColor(map['disabledColor'])
: null,
disabledElevation:
map.containsKey('disabledElevation') ? map['disabledElevation']?.toDouble() : 0.0,
disabledTextColor: map.containsKey('disabledTextColor')
? parseHexColor(map['disabledTextColor'])
: null,
elevation: map.containsKey('elevation') ? map['elevation']?.toDouble() : 0.0,
padding: map.containsKey('padding')
? parseEdgeInsetsGeometry(map['padding'])
: null,
splashColor: map.containsKey('splashColor')
? parseHexColor(map['splashColor'])
: null,
textColor:
map.containsKey('textColor') ? parseHexColor(map['textColor']) : null,
child: DynamicWidgetBuilder.buildFromMap(map['child'], buildContext, listener),
onPressed: () {
listener.onClicked(clickEvent);
},
);
return raisedButton;
}
}
Add it to parsers list.
DynamicWidgetBuilder.addParser(RaisedButtonParser());
Add "click_event" property to your widget json definition. for example:
var raisedButton_json =
'''
{
"type": "Container",
"alignment": "center",
"child": {
"type": "RaisedButton",
"color": "##FF00FF",
"padding": "8,8,8,8",
"textColor": "#00FF00",
"elevation" : 8.0,
"splashColor" : "#00FF00",
"click_event" : "route://productDetail?goods_id=123",
"child" : {
"type": "Text",
"data": "I am a button"
}
}
}
We suggest you'd better to use an URI to define the event, as the exmaple, it's a event for going to a product detail page.
Then, define a ClickListener
class DefaultClickListener implements ClickListener{
@override
void onClicked(String event) {
print("Receive click event: " + event);
}
}
Finally, pass the listener to build method.
Future<Widget> _buildWidget() async{
return DynamicWidgetBuilder.build(jsonString, buildContext, new DefaultClickListener());
}
You don't need to write the json code by hand, you can export your flutter code to json code efficiently with DynamicWidgetJsonExportor widget. You just need to wrap your flutter code with DynamicWidgetJsonExportor widget, then invoke its exportJsonString()
method, look at following example, click the "export" button, it will find the DynamicWidgetJsonExportor widget, and export its child to json code efficiently.
class _JSONExporterState extends State<JSONExporter> {
GlobalKey key = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text("export example"),
),
body: Builder(
builder: (context) => Column(
children: [
Expanded(
child: DynamicWidgetJsonExportor(
key: key,
child: Container(
child: GridViewWidget(
GridViewParams(
mainAxisSpacing: 2.0,
crossAxisSpacing: 2.0,
crossAxisCount: 2,
childAspectRatio: 1.6,
padding: EdgeInsets.all(10.0),
pageSize: 10,
children: [
ListTile(
leading: Text("Leading text"),
title: Text("title"),
subtitle: Text("subtitle"),
),
ListTile(
leading: Text("Leading text"),
title: Text("title"),
subtitle: Text("subtitle"),
)
]),
context),
),
),
),
RaisedButton(
child: Text("Export"),
onPressed: () {
var exportor = key.currentWidget as DynamicWidgetJsonExportor;
var exportJsonString = exportor.exportJsonString();
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("json string was exported to editor page.")));
Future.delayed(Duration(seconds: 3), (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CodeEditorPage(exportJsonString)));
});
},
)
],
),
),
);
}
}
You can use whatever your favorite IDE to build the UI, then use DynamicWidgetJsonExportor to export to json code. For detail, please check the Dynamic Widget Demo source code.
Already completed widgets:
You can view Currently support widgets and properties here.
Checkout this project and run demo.
Checkout this project and run demo.
Created by @deng.yin@gmail.com - feel free to contact me
Author: Dengyin2000
Source Code: https://github.com/dengyin2000/dynamic_widget
License: Apache-2.0 License
1625637060
In this video, we work with JSONs, which are a common data format for most web services (i.e. APIs). Thank you for watching and happy coding!
Need some new tech gadgets or a new charger? Buy from my Amazon Storefront https://www.amazon.com/shop/blondiebytes
What is an API?
https://youtu.be/T74OdSCBJfw
JSON Google Extension
https://chrome.google.com/webstore/detail/json-formatter/bcjindcccaagfpapjjmafapmmgkkhgoa?hl=en
Endpoint Example
http://maps.googleapis.com/maps/api/geocode/json?address=13+East+60th+Street+New+York,+NY
Check out my courses on LinkedIn Learning!
REFERRAL CODE: https://linkedin-learning.pxf.io/blondiebytes
https://www.linkedin.com/learning/instructors/kathryn-hodge
Support me on Patreon!
https://www.patreon.com/blondiebytes
Check out my Python Basics course on Highbrow!
https://gohighbrow.com/portfolio/python-basics/
Check out behind-the-scenes and more tech tips on my Instagram!
https://instagram.com/blondiebytes/
Free HACKATHON MODE playlist:
https://open.spotify.com/user/12124758083/playlist/6cuse5033woPHT2wf9NdDa?si=VFe9mYuGSP6SUoj8JBYuwg
MY FAVORITE THINGS:
Stitch Fix Invite Code: https://www.stitchfix.com/referral/10013108?sod=w&som=c
FabFitFun Invite Code: http://xo.fff.me/h9-GH
Uber Invite Code: kathrynh1277ue
Postmates Invite Code: 7373F
SoulCycle Invite Code: https://www.soul-cycle.com/r/WY3DlxF0/
Rent The Runway: https://rtr.app.link/e/rfHlXRUZuO
Want to BINGE?? Check out these playlists…
Quick Code Tutorials: https://www.youtube.com/watch?v=4K4QhIAfGKY&index=1&list=PLcLMSci1ZoPu9ryGJvDDuunVMjwKhDpkB
Command Line: https://www.youtube.com/watch?v=Jm8-UFf8IMg&index=1&list=PLcLMSci1ZoPvbvAIn_tuSzMgF1c7VVJ6e
30 Days of Code: https://www.youtube.com/watch?v=K5WxmFfIWbo&index=2&list=PLcLMSci1ZoPs6jV0O3LBJwChjRon3lE1F
Intermediate Web Dev Tutorials: https://www.youtube.com/watch?v=LFa9fnQGb3g&index=1&list=PLcLMSci1ZoPubx8doMzttR2ROIl4uzQbK
GitHub | https://github.com/blondiebytes
Twitter | https://twitter.com/blondiebytes
LinkedIn | https://www.linkedin.com/in/blondiebytes
#jsons #json arrays #json objects #what is json #jsons tutorial #blondiebytes
1591779939
Comparing UI Designers to UI Developers
User interface (UI) designers and developers are directly responsible for the consumer base’s experience using an application or software program. Designers specifically deal with the visual aspects of the program, while developers deal with the overall performance and functionality of the software.
To get in depth knowledge on UI, enrich your skills on UI online training Course
Responsibilities of UI Designers vs. UI Developers
UI designers and developers work in tandem to create a program or application that is easy to understand and operate by their customers or clients. Though there may be some occasional overlap in the duties within the workplace, their designated duties are quite clear and are dependent on the other. UI developers are responsible for the coding and programming in the conception of an application, specifically with regard to how the software operates at the hands of the user. UI designers are in charge of applying their understanding of the program operations to create a visual experience that is most compatible to the program’s functionality.
UI Designers
User interface designers are tasked with understanding the programming language of the application in creation so that they can conceptualize and craft visual aspects that will facilitate usage of the program. They are expected to understand computer programming as well as graphic design due to the demands of their work, since they are in charge of incorporating their designs into the program correctly. Their designs are implemented into the layout, which is typically drafted by the developers, while the style of their designs is contingent on the guidelines given by the directors. Once these designs are finished, they must implement them into the program and run a demo of it for the developers and directors to ensure they met the needs and expectations of the project while ensuring there aren’t any bugs caused from their designs. Get more skills from UI Training
Other responsibilities of UI designers are as follows:
UI Developers
User interface developers are responsible for the functional aspects of a software application, coding and programming throughout all stages of development with the clients and potential users of the application in mind. They usually begin the process by incorporating the clients’ expressed needs into a layout that is modified as progress is made. Once they get the general functions working, the designers will incorporate their visual conceptions into the layout to ensure that the first draft is operational. If there are any bugs or malfunctions to fix, the developers must troubleshoot and patch the application. While doing these tasks, they must take detailed notes of all the progress made to streamline any future updates made to the program, functionally or aesthetically. Learn more from ui design course
UI developers will also be responsible for:
#ui design course #ui training #online ui training #ui online course #ui online training #advanced ui design course
1595323277
The UX designer is someone who thinks about what should the user flow be like, which page should lead to which page, when should a confirm popup appear or not appear, should there be a listing page before or after a create-new page, should there be an address field in the page or geolocation is enough to serve the purpose? After brainstorming through each of these and several other questions, the UX designer comes up with something known as wireframes, which in simple terms is just a blueprint of the website/app.
To get in-Depth knowledge on UI Design you can enroll for a live demo on UI online training
The UI designer then takes the wireframes and makes them beautiful, also ensuring that the workflow of the product is communicated well to the user. He will add the pixel level details to the wireframes. What should be the font used, what should be the background image, do we need a background image, what should be the foreground color, how big should be the submit button, does it make more sense to have the menu at the bottom of the screen, what should the logo look like? The job of a UI designer is answering all these and thereafter delivering static mockups, using may be Photoshop, Invision and many other design tools.
The UI developer is the one who puts these static mockups in “real code”. They might need skills like HTML CSS , precompilers(like sass or less) , UI frameworks (like bootstrap or foundation), or xml layouts( in case of android UI) or a combined knowledge of all of them with Javascript (in case of react, react native). The result is a beautiful set of screens/pages which can be actually rendered in a browser or a mobile device.Learn more from ui design course
#ui online course #ui design course #ui training #online ui training #ui courses online #ui design classes online
1593084180
UI or User Interface is the interface that is the access point where users interact with computers. It is also a way through which users can interact with a website or an application. UI design typically refers to graphical user interfaces but also includes others, such as voice-controlled ones, a keyboard, a mouse, and the appearance of a desktop.
UI design considers the look, feel, and interactivity of the product. Users judge the design on the basis of usability and likeability very swiftly, so a designer will focus on making each visual element look pleasurable and meaningful. The designer has to consider the color scheme, font imagery, spacing, responsiveness. Also, understanding the user’s context and mindset is crucial while making design decisions.
Types of user interfaces
The various types of user interfaces include:
Often confused a lot and understood one and the same thing terms UI and UX are related but not the same.
UX or User Experience describes the overall experience of the product and the UI only considers the appearance of the product. A UX designer’s work is to make the product usable and useful. UX means focusing on the whole user journey and the steps a user will take to attain a goal. UX designers will make wireframes without making any detailed design decisions for each wireframe. Once the wireframes are final they are handed over to UI designers to start adding emotions to it through design and animations.
UI is a part of UX which helps in making the user experience more pleasurable and user-centric. UI designer’s job is to make the product visually appealing and desirable. Where a UX designer will try to make a critical judgment on what feature to add and how to user will interact, a UI designer will make critical design decisions regarding those features. Like what should be the font, color scheme, and animations for the features and pages decided by the UX team.
Let’s take a scenario to see how UI designers and UX designers influence the same feature differently.
A UX designer will decide whether a page will have a top navigation bar, side navigation bar, or bottom. What links should be added to the bar and whether there will be a search bar in it or not.
A UI designer will decide what will be the color scheme of the navigation bar, whether to use icons or text in link buttons, what should be the font style, what animation to use when the user toggles navigation bar or switch between pages.
#scala #user interface (ui) #good design #principles of ui #ui #ui vs ux #user experience #user interface #ux #what is ui #what is ux
1647044400
Flutter Dynamic Widget
A Backend-Driven UI toolkit, build your dynamic UI with json, and the json format is very similar with flutter widget code.
From 4.0.0-nullsafety.1 version, it supports null-safety.
From 3.0.0 version, it supports exporting your flutter code to json code. please check How to write the json code
From 1.0.4 version, it supports flutter web application.
I work for an e-commerce company. We need to build flexible pages. So we define a light UI protocol, and implement on Android and iOS. We can dynamic update App UIs by pushing a json file. With this ability, we can do some UI A/B testing without publishing App to app store. Flutter allows you to build beautiful native apps on iOS and Android from a single codebase, it can allow you to build web app later. Flutter's hot reload helps you quickly and easily experiment, build UIs, add features, and fix bugs faster. But it still build native app, the UIs can't be dynamic updated. If you want to modify the UIs, you need to publish the updated app to app store. With this project, you can build your UIs from a json string, which is the UI protocol. The json string is very similar with the Flutter widget dart code. All widget type and widget properties are the same.
Widget type will be a type property, and widget's properties will be the json properties too. All properties and their values will be almost the same. You can checkout the following document.
Currently support flutter widgets and properties
Add this to your package's pubspec.yaml file:
dependencies:
dynamic_widget: ^3.0.3
You can install packages from the command line:
with Flutter:
$ flutter packages get
Alternatively, your editor might support flutter packages get
. Check the docs for your editor to learn more.
Now in your Dart code, you can use:
import 'package:dynamic_widget/dynamic_widget.dart';
You should use DynamicWidgetBuilder().build
method to covert a json string into flutter widget. It will be time-consuming. so you'd better using FutureBuilder
to build the UI.
import 'package:dynamic_widget/dynamic_widget.dart';
class PreviewPage extends StatelessWidget {
final String jsonString;
PreviewPage(this.jsonString);
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text("Preview"),
),
body: FutureBuilder<Widget>(
future: _buildWidget(context),
builder: (BuildContext context, AsyncSnapshot<Widget> snapshot) {
if (snapshot.hasError) {
print(snapshot.error);
}
return snapshot.hasData
? SizedBox.expand(
child: snapshot.data,
)
: Text("Loading...");
},
),
);
}
Future<Widget> _buildWidget(BuildContext context) async {
return DynamicWidgetBuilder.build(jsonString, context, new DefaultClickListener());
}
}
WidgetParser
abstract class.DynamicWidgetBuilder.addParser(WidgetParser parser)
method.This is a RaisedButton widget parser.
import 'package:dynamic_widget/dynamic_widget/utils.dart';
import 'package:dynamic_widget/dynamic_widget.dart';
import 'package:flutter/material.dart';
class RaisedButtonParser extends WidgetParser {
@override
String get widgetName => "RaisedButton";
@override
Widget parse(Map<String, dynamic> map, BuildContext buildContext, ClickListener listener) {
String clickEvent =
map.containsKey("click_event") ? map['click_event'] : "";
var raisedButton = RaisedButton(
color: map.containsKey('color') ? parseHexColor(map['color']) : null,
disabledColor: map.containsKey('disabledColor')
? parseHexColor(map['disabledColor'])
: null,
disabledElevation:
map.containsKey('disabledElevation') ? map['disabledElevation']?.toDouble() : 0.0,
disabledTextColor: map.containsKey('disabledTextColor')
? parseHexColor(map['disabledTextColor'])
: null,
elevation: map.containsKey('elevation') ? map['elevation']?.toDouble() : 0.0,
padding: map.containsKey('padding')
? parseEdgeInsetsGeometry(map['padding'])
: null,
splashColor: map.containsKey('splashColor')
? parseHexColor(map['splashColor'])
: null,
textColor:
map.containsKey('textColor') ? parseHexColor(map['textColor']) : null,
child: DynamicWidgetBuilder.buildFromMap(map['child'], buildContext, listener),
onPressed: () {
listener.onClicked(clickEvent);
},
);
return raisedButton;
}
}
Add it to parsers list.
DynamicWidgetBuilder.addParser(RaisedButtonParser());
Add "click_event" property to your widget json definition. for example:
var raisedButton_json =
'''
{
"type": "Container",
"alignment": "center",
"child": {
"type": "RaisedButton",
"color": "##FF00FF",
"padding": "8,8,8,8",
"textColor": "#00FF00",
"elevation" : 8.0,
"splashColor" : "#00FF00",
"click_event" : "route://productDetail?goods_id=123",
"child" : {
"type": "Text",
"data": "I am a button"
}
}
}
We suggest you'd better to use an URI to define the event, as the exmaple, it's a event for going to a product detail page.
Then, define a ClickListener
class DefaultClickListener implements ClickListener{
@override
void onClicked(String event) {
print("Receive click event: " + event);
}
}
Finally, pass the listener to build method.
Future<Widget> _buildWidget() async{
return DynamicWidgetBuilder.build(jsonString, buildContext, new DefaultClickListener());
}
You don't need to write the json code by hand, you can export your flutter code to json code efficiently with DynamicWidgetJsonExportor widget. You just need to wrap your flutter code with DynamicWidgetJsonExportor widget, then invoke its exportJsonString()
method, look at following example, click the "export" button, it will find the DynamicWidgetJsonExportor widget, and export its child to json code efficiently.
class _JSONExporterState extends State<JSONExporter> {
GlobalKey key = GlobalKey();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
// Here we take the value from the MyHomePage object that was created by
// the App.build method, and use it to set our appbar title.
title: Text("export example"),
),
body: Builder(
builder: (context) => Column(
children: [
Expanded(
child: DynamicWidgetJsonExportor(
key: key,
child: Container(
child: GridViewWidget(
GridViewParams(
mainAxisSpacing: 2.0,
crossAxisSpacing: 2.0,
crossAxisCount: 2,
childAspectRatio: 1.6,
padding: EdgeInsets.all(10.0),
pageSize: 10,
children: [
ListTile(
leading: Text("Leading text"),
title: Text("title"),
subtitle: Text("subtitle"),
),
ListTile(
leading: Text("Leading text"),
title: Text("title"),
subtitle: Text("subtitle"),
)
]),
context),
),
),
),
RaisedButton(
child: Text("Export"),
onPressed: () {
var exportor = key.currentWidget as DynamicWidgetJsonExportor;
var exportJsonString = exportor.exportJsonString();
Scaffold.of(context).showSnackBar(SnackBar(
content: Text("json string was exported to editor page.")));
Future.delayed(Duration(seconds: 3), (){
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
CodeEditorPage(exportJsonString)));
});
},
)
],
),
),
);
}
}
You can use whatever your favorite IDE to build the UI, then use DynamicWidgetJsonExportor to export to json code. For detail, please check the Dynamic Widget Demo source code.
Already completed widgets:
You can view Currently support widgets and properties here.
Checkout this project and run demo.
Checkout this project and run demo.
Created by @deng.yin@gmail.com - feel free to contact me
Author: Dengyin2000
Source Code: https://github.com/dengyin2000/dynamic_widget
License: Apache-2.0 License