Skip to content

Commit

Permalink
perf: avoid unnecessarily creating new list on every frame (#1708)
Browse files Browse the repository at this point in the history
  • Loading branch information
ignatz committed Oct 28, 2023
1 parent c24b6e6 commit 394dc27
Showing 1 changed file with 30 additions and 26 deletions.
56 changes: 30 additions & 26 deletions lib/src/map/widget.dart
Original file line number Diff line number Diff line change
Expand Up @@ -139,38 +139,42 @@ class _FlutterMapStateContainer extends State<FlutterMap>
Widget build(BuildContext context) {
super.build(context);

final widgets = ClipRect(
child: Stack(
children: <Widget>[
Positioned.fill(
child: ColoredBox(color: widget.options.backgroundColor),
),
...widget.children.map(
(child) => TranslucentPointer(
translucent: widget.options.applyPointerTranslucencyToLayers,
child: child,
),
),
...widget.nonRotatedChildren.map(
(child) => TranslucentPointer(
translucent: widget.options.applyPointerTranslucencyToLayers,
child: child,
),
),
],
),
);

return LayoutBuilder(
builder: (context, constraints) {
_updateAndEmitSizeIfConstraintsChanged(constraints);

return FlutterMapInteractiveViewer(
controller: _flutterMapInternalController,
builder: (context, options, camera) => FlutterMapInheritedModel(
controller: _mapController,
options: options,
camera: camera,
child: ClipRect(
child: Stack(
children: [
Positioned.fill(
child: ColoredBox(color: options.backgroundColor),
),
...widget.children.map(
(child) => TranslucentPointer(
translucent: options.applyPointerTranslucencyToLayers,
child: child,
),
),
...widget.nonRotatedChildren.map(
(child) => TranslucentPointer(
translucent: options.applyPointerTranslucencyToLayers,
child: child,
),
),
],
),
),
),
builder: (context, options, camera) {
return FlutterMapInheritedModel(
controller: _mapController,
options: options,
camera: camera,
child: widgets,
);
},
);
},
);
Expand Down

0 comments on commit 394dc27

Please sign in to comment.