-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Closed
flutter/packages
#8650Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.27Found to occur in 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28Found to occur in 3.28has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: rfwRemote Flutter Widgets packageRemote Flutter Widgets packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Steps to reproduce
- Create a local widget and provide a builderArg containing an array of texts (could be a map as well).
runtime.update(localLibraryName, LocalWidgetLibrary(<String, LocalWidgetBuilder> {
'Builder': (context, source) {
final args = {
'values': ['Value1', 'Value2', 'Value3'],
};
return source.builder(['builder'], args);
},
}));
- Try to loop through the strings inside "values" in a ListView.
widget root = Builder(
builder: (scope) => ListView(
children: [
...for value in scope.values:
Text(text: value, textDirection: 'ltr')
],
),
);
Expected results
A ListView having 3 Text widgets with values "Value1", "Value2", "Value3" respectively should be rendered.
Actual results
Nothing is rendered properly. Basically, the loop is ignored.
But, we can see the content when we use the array of values in a Text widget.
widget root = Builder(
builder: (scope) => Text(text: scope.values, textDirection: 'ltr'),
);
The output of above is "Value1Value2Value3".
Is there anything that I miss to make loops work in widget builders or this is a legit issue?
Here's a full example
import 'package:flutter/material.dart';
import 'package:rfw/formats.dart' show parseLibraryFile;
import 'package:rfw/rfw.dart';
void main() {
runApp(const Example());
}
class Example extends StatefulWidget {
const Example({super.key});
@override
State<Example> createState() => _ExampleState();
}
class _ExampleState extends State<Example> {
final Runtime _runtime = Runtime();
final DynamicContent _data = DynamicContent();
static const coreLibraryName = LibraryName(['core', 'widgets']);
static const localLibraryName = LibraryName(['local', 'widgets']);
static const remoteLibraryName = LibraryName(['remote']);
static final RemoteWidgetLibrary _remoteWidgets = parseLibraryFile('''
import core.widgets;
import local.widgets;
widget root = Builder(
builder: (scope) => ListView(
children: [
...for value in scope.values:
Text(text: value, textDirection: 'ltr')
],
),
);
''');
static final WidgetLibrary _localWidgets =
LocalWidgetLibrary(<String, LocalWidgetBuilder>{
'Builder': (context, source) {
final args = {
'values': ['Value1', 'Value2', 'Value3'],
};
return source.builder(['builder'], args);
},
});
@override
void initState() {
super.initState();
// Core widget library
_runtime.update(coreLibraryName, createCoreWidgets());
// Local widget library
_runtime.update(localLibraryName, _localWidgets);
// Remote widget library
_runtime.update(remoteLibraryName, _remoteWidgets);
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(toolbarHeight: 0),
body: RemoteWidget(
runtime: _runtime,
data: _data,
widget: const FullyQualifiedWidgetName(
remoteLibraryName,
'root',
),
),
),
);
}
}
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work listfound in release: 3.27Found to occur in 3.27Found to occur in 3.27found in release: 3.28Found to occur in 3.28Found to occur in 3.28has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onp: rfwRemote Flutter Widgets packageRemote Flutter Widgets packagepackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer versionteam-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team