https://github.com/flame-engine/tiled.dart
A Dart Tiled library. Parse your TMX files into useful representations. Compatible with Flame.
https://github.com/flame-engine/tiled.dart
dart flame flutter game hacktoberfest tile tiled tiles tmx
Last synced: 3 months ago
JSON representation
A Dart Tiled library. Parse your TMX files into useful representations. Compatible with Flame.
- Host: GitHub
- URL: https://github.com/flame-engine/tiled.dart
- Owner: flame-engine
- License: mit
- Created: 2019-01-01T21:05:51.000Z (almost 7 years ago)
- Default Branch: main
- Last Pushed: 2025-06-15T20:49:09.000Z (4 months ago)
- Last Synced: 2025-06-15T22:02:36.168Z (4 months ago)
- Topics: dart, flame, flutter, game, hacktoberfest, tile, tiled, tiles, tmx
- Language: Dart
- Homepage: https://flame-engine.org/
- Size: 576 KB
- Stars: 50
- Watchers: 7
- Forks: 32
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- Funding: .github/FUNDING.yml
Awesome Lists containing this project
README
# Tiled Dart
[](https://pub.dartlang.org/packages/tiled)  [](https://discord.gg/pxrBmy4)
A Dart Tiled library.
## Install from Dart Pub Repository
To include the package as a dependency in your `pubspec.yaml`, run the following (or add it manually):
```sh
dart pub add tiled
```## Usage
Import the package like this:
```dart
import 'package:tiled/tiled.dart';
```### Load Tmx Files
Load a TMX file into a string by any means, and then pass the string to TileMapParser.parseXml():
```dart
final String tmxBody = /* ... */;
final TiledMap mapTmx = TileMapParser.parseTmx(tmxBody);
```If your tmx file includes an external tsx reference, you have to add a CustomParser
```dart
class CustomTsxProvider extends TsxProvider {
@override
Parser getSource(String fileName) {
final xml = File(fileName).readAsStringSync();
final node = XmlDocument.parse(xml).rootElement;
return XmlParser(node);
}
}
```
And use it in the parseTmx method
```dart
final String tmxBody = /* ... */;
final TiledMap mapTmx = TileMapParser.parseTmx(tmxBody, tsx: CustomTsxProvider());```
### Load Json Files
Alternatively load a json file.
```dart
final String jsonBody = /* ... */;
final TiledMap mapTmx = TileMapParser.parseJson(jsonBody);
```### Implementation
For further information and more usage examples, please take a look at the examples in [flame_tiled](https://github.com/flame-engine/flame_tiled).