Skip to content

Commit

Permalink
Fix FileTileProvider to work on the web (#1170)
Browse files Browse the repository at this point in the history
* fix FileTileProvider to work on the web

* export FileTileProvider

* Delete Podfile
  • Loading branch information
mu-dawood authored Feb 27, 2022
1 parent e80c398 commit e408ce7
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 10 deletions.
2 changes: 2 additions & 0 deletions lib/flutter_map.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ export 'package:flutter_map/src/layer/polygon_layer.dart';
export 'package:flutter_map/src/layer/polyline_layer.dart';
export 'package:flutter_map/src/layer/tile_builder/tile_builder.dart';
export 'package:flutter_map/src/layer/tile_layer.dart';
export 'package:flutter_map/src/layer/tile_provider/file_tile_provider_io.dart'
if (dart.library.html) 'package:flutter_map/src/layer/tile_provider/file_tile_provider_web.dart';
export 'package:flutter_map/src/layer/tile_provider/tile_provider.dart';
export 'package:flutter_map/src/plugins/plugin.dart';

Expand Down
15 changes: 15 additions & 0 deletions lib/src/layer/tile_provider/file_tile_provider_io.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import 'dart:io';

import 'package:flutter/widgets.dart';

import '../tile_layer.dart';
import 'tile_provider.dart';

/// FileTileProvider
class FileTileProvider extends TileProvider {
const FileTileProvider();
@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
return FileImage(File(getTileUrl(coords, options)));
}
}
14 changes: 14 additions & 0 deletions lib/src/layer/tile_provider/file_tile_provider_web.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import 'package:flutter/widgets.dart';

import '../tile_layer.dart';
import 'tile_provider.dart';

/// FileTileProvider
class FileTileProvider extends TileProvider {
const FileTileProvider();
@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
return NetworkImage(getTileUrl(coords, options));
}
}
10 changes: 0 additions & 10 deletions lib/src/layer/tile_provider/tile_provider.dart
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import 'dart:io';

import 'package:flutter/widgets.dart';
import 'package:flutter_map/flutter_map.dart';

Expand Down Expand Up @@ -81,14 +79,6 @@ class AssetTileProvider extends TileProvider {
}
}

class FileTileProvider extends TileProvider {
const FileTileProvider();
@override
ImageProvider getImage(Coords<num> coords, TileLayerOptions options) {
return FileImage(File(getTileUrl(coords, options)));
}
}

class CustomTileProvider extends TileProvider {
final String Function(Coords coors, TileLayerOptions options) customTileUrl;

Expand Down

0 comments on commit e408ce7

Please sign in to comment.