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?


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 package to load resource files.

Answered By – Günter Zöchbauer

Answer Checked By – Jay B. (FlutterFixes Admin)

Leave a Reply

Your email address will not be published.