Closed zeexan-dev closed 3 years ago
Did you get it working?
@darran-kelinske-fivestars Nops
This seems to be working for me on flutter_web
Feel free to link a repo with a simple working project.
This seems to be working for me on flutter_web
Could you please share code, or preferably working repo?
yes please, can you share the code? need to have it working on flutter web
Please see the solution here:
https://stackoverflow.com/a/57746754/3268303
The solution outline below is outdated, but still works.
https://stackoverflow.com/a/57488553/3268303
I was able to get a workable solution without this library, but it isn't pretty. Here is the majority of the code.
import 'dart:html';
import 'package:flutter_web/material.dart';
import 'package:lift_ai/base/screen_state.dart';
import 'package:lift_ai/feature/property_common/property_contract.dart';
import 'package:lift_ai/feature/property_common/property_presenter_impl.dart';
import 'package:lift_ai/model/car_status.dart';
import 'package:lift_ai/model/property.dart';
import 'package:flutter_web_ui/ui.dart' as ui;
import 'package:lift_ai/util/widget_util.dart';
class PropertyMapPage extends StatefulWidget {
final CarStatus carStatus;
PropertyMapPage(Key key, this.carStatus) : super(key: key);
@override
_PropertyMapPageState createState() => _PropertyMapPageState(carStatus);
}
class _PropertyMapPageState extends State<PropertyMapPage>
implements PropertyListView {
PropertyPresenter _propertyListPresenter;
List<Property> properties = [];
ScreenState screenState = ScreenState.LOADING;
CarStatus carStatus;
String createdViewId = 'hello-world-html';
bool inProgress = true;
_PropertyMapPageState(this.carStatus) {
_propertyListPresenter = PropertyPresenterImpl(this);
}
@override
void initState() {
super.initState();
_propertyListPresenter.getProperties(carStatus, "");
}
@override
void dispose() {
super.dispose();
_propertyListPresenter = null;
}
@override
Widget build(BuildContext context) {
print("Creating html view");
if (inProgress) {
return Center(child: CircularProgressIndicator());
}
return Row(
children: <Widget>[
Container(
width: MediaQuery.of(context).size.width - 400,
child: HtmlView(
viewType: createdViewId,
)),
Container(
width: 400,
child: properties.isEmpty
? WidgetUtil.getEmptyPropertiesView(context)
: ListView.builder(
padding: EdgeInsets.all(8.0),
itemCount: properties.length,
itemBuilder: (_, index) {
return WidgetUtil.buildListRow(
context, _propertyListPresenter, properties[index]);
},
),
),
],
);
}
@override
void showProperties(List<Property> properties) {
String markers = "";
for (Property property in properties) {
String marker =
"var marker = new google.maps.Marker({position: new google.maps.LatLng(${property.lat}, ${property.lng}), map: map, title: 'Hello ${property.id}!'});\n";
markers += marker;
}
String createdViewUpdate = DateTime.now().toString();
rootBundle.loadString('map.html').then((value) {
value = value.replaceAll(new RegExp(r'markers'), markers);
ui.platformViewRegistry.registerViewFactory(
createdViewId,
(int viewId) => IFrameElement()
..width = (MediaQuery.of(context).size.width - 400).toString()
..height = MediaQuery.of(context).size.height.toString()
..srcdoc = value
..style.border = 'none');
});
setState(() {
inProgress = false;
this.createdViewId = createdViewUpdate;
this.properties = properties;
});
}
@override
void updateScreenState(ScreenState screenState) {
setState(() {
this.screenState = screenState;
});
}
@override
void showException(String string) {
// TODO: implement showException
}
}
@dazza5000 Thanks
I would also need a widget to add simplier and faster the plugin in my web app.
There is an easier solution outlined here: https://stackoverflow.com/a/57746754/3268303
I'm working on a web version of the google_maps_flutter
plugin.
It uses this package as the underlying JS-interop library with the Maps JS SDK, and offers a similar API to the current iOS / Android implementation.
Track progress here.
Hey, the google_maps_flutter_web plugin has been published, do check it out! https://pub.dev/packages/google_maps_flutter_web
As soon as I include the import statement
import 'package:google_maps/google_maps.dart';
I get the following error.
Trying to use this in flutter web