template_parser 0.0.2 copy "template_parser: ^0.0.2" to clipboard
template_parser: ^0.0.2 copied to clipboard

A flutter package to parse String template. It's a secure template language that is also very accessible for programmer audiences.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:template_parser/template_parser.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Template Parser',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      debugShowCheckedModeBanner: false,
      home: TemplateParserPage(),
    );
  }
}

class TemplateParserPage extends StatelessWidget {
  TemplateParserPage({Key? key}) : super(key: key);

  final template = 'My name is {{FullName}}. I am {{ Age }}, have worked as a '
      '{{designation}} for a bigger company, in an agile team, working mostly '
      'on {{Skills}} platform.';

  final List<TemplateModel> models = [
    TemplateModel(variable: 'FullName', value: 'Sodipto Saha'),
    TemplateModel(variable: 'Age', value: '26'),
    TemplateModel(variable: 'designation', value: 'Senior Software Engineer'),
    TemplateModel(variable: 'Skills', value: 'Flutter,C# And .NET Core'),
  ];

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Template Parser'),
      ),
      body: Padding(
          padding: const EdgeInsets.symmetric(horizontal: 20),
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              const Text(
                '-------- Before Parse -------',
                style: TextStyle(
                    fontSize: 16,
                    fontWeight: FontWeight.w700,
                    color: Colors.red),
              ),
              const SizedBox(
                height: 20,
              ),
              Text(
                template,
                style: const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                ),
              ),
              const Padding(
                padding: EdgeInsets.symmetric(vertical: 20),
                child: Text(
                  '-------- After Parse -------',
                  style: TextStyle(
                      fontSize: 16,
                      fontWeight: FontWeight.w700,
                      color: Colors.green),
                ),
              ),
              Text(
                TemplateParser.parse(template, models),
                style: const TextStyle(
                  fontSize: 16,
                  fontWeight: FontWeight.w500,
                ),
              ),
            ],
          )),
    );
  }
}
3
likes
160
pub points
48%
popularity

Publisher

verified publishersodipto.me

A flutter package to parse String template. It's a secure template language that is also very accessible for programmer audiences.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on template_parser