phpscriptcoder
phpscriptcoder

Reputation: 737

Reading an HTML template from a file in Dart

I'm working on an application that's built with Dart and Angular2. I'm using an external JS library that takes a simple HTML template (not an Angular template) in the form of a string. Right now I'm just storing the template inline in the Dart file, but that's a little messy. Is there a way I could put the template in a separate file?

Upvotes: 0

Views: 316

Answers (1)

Günter Zöchbauer
Günter Zöchbauer

Reputation: 657018

You can create a file with the content like

const String someString = '''
here goes the template content
''';

and then import that file and pass someString around.

You can also safe the template content in a non-Dart file and request it from the server.

There is also the https://pub.dartlang.org/packages/resource package to load resource files.

Upvotes: 1

Related Questions