Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

How can I load block on workspace using dart language (I'm using flutter_blockly_plus library)

29 views
Skip to first unread message

Quốc Hưng

unread,
Nov 14, 2024, 2:06:35 PM11/14/24
to Blockly
I can save block on workspace with xml, json, how to load this on workspace 
String _generatedCode = '';
String _CodeXml = '';

final BlocklyOptions workspaceConfiguration =
BlocklyOptions.fromJson(const {
'grid': {
'spacing': 12,
'length': 30,
'colour': '#b6b6b6',
'snap': true,
},
'toolbox': initialToolboxJson,

'theme': null,
// null safety example
'collapse': null,
'comments': true,
'css': null,
'disable': null,
'horizontalLayout': null,
'maxBlocks': 200,
'maxInstances': null,
'media': null,
'modalInputs': null,
'move': null,
'oneBasedIndex': null,
'readOnly': null,
'renderer': 'zelos',
'rendererOverrides': null,
'rtl': null,
'scrollbars': {
'horizontal': false,
'vertical': false
},
'sounds': true,
'toolboxPosition': null,
'trashcan': true,
'maxTrashcanContents': null,
'plugins': null,
'zoom': {
'controls': false,
'wheel': false,
'startScale': 0.6,
'maxScale': 1.0,
'minScale': 0.1,
'scaleSpeed': 0.5
},
'parentWorkspace': null,

});

void onInject(BlocklyData data) {
print('Injected: ${data.xml}');
}

onChange(BlocklyData data) {
setState(() {
// Check if there are any blocks in the workspace
if (data.js != null && data.js!.isNotEmpty) {
_generatedCode = data.js!; // Update with the generated code
} else {
_generatedCode = ''; // No blocks, so clear the generated code
}
//_generatedCode = jsonEncode(data);
_CodeXml = jsonEncode(data);
});
print('Changed: ${data.xml}');

}

Mark Friedman

unread,
Nov 15, 2024, 5:26:58 PM11/15/24
to blo...@googlegroups.com
The Blockly team did not develop the flutter_blockly_plus package, nor have I seen many Flutter users in this group, so you might consider trying to contact the author(s) of that package.  That said I did find some of the documentation of that package and perhaps this example from that documentation would help.

-Mark


--
You received this message because you are subscribed to the Google Groups "Blockly" group.
To unsubscribe from this group and stop receiving emails from it, send an email to blockly+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/blockly/60efd19e-7bf6-4f5b-bf57-20be245d11cbn%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages