flutter_adaptive_cards 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 53

AdaptiveCards for Flutter

Adaptive Cards for Flutter #

A Flutter implementation of Adaptive Cards.

Installing #

Put this into your pubspec.yaml

      url: https://github.com/neohelden/Flutter-AdaptiveCards

Using #

Using Adaptive Cards in Flutter coudn't be simpler: All you need is the AdaptiveCard widget.

There are several constructors which handle data loading from different sources.

AdaptiveCard.network takes a url to download the payload and display it. AdaptiveCard.asset takes an asset path to load the payload from the local data. AdaptiveCard.memory takes a map (which can be obtained but decoding a string using the json class) and displays it.

An example:

  placeholder: Text("Loading, please wait"),
  url: "www.someUrlThatPoints.To/A.json",
  hostConfigPath: "assets/host_config.json",
  onSubmit: (map) {
    // Send to server or handle locally
  onOpenUrl: (url) {
    // Open url using the browser or handle differently
  // If this is set, a button will appear next to each adaptive card which when clicked shows the payload.
  // NOTE: this will only be shown in debug mode, this attribute does change nothing for realease builds.
  // This is very useful for debugging purposes
  showDebugJson: true,
  // If you have not implemented explicit dark theme, Adaptive Cards will try to approximate its colors to match the dark theme
  // so the contrast and color meaning stays the same.
  // Turn this off, if you want to have full control over the colors when using the dark theme.
  // NOTE: This is currently still under development
  approximateDarkThemeColors: true,

Running the tests #

Simply type

flutter test

and to update the golden files run

flutter test --update-goldens test/sample_golden_test.dart

This updates the golden files for the sample cards.

Contributing #

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests to us.

Authors #

  • Norbert Kozsir (@Norbert515) – Initial work, Head of Flutter development @Neohelden

See also the list of contributors who participated in this project.

About this project #

We decided to build a Flutter implementation of Adaptive Cards because we believe in the future of both technologies. With Flutter, we found an exciting framework for ultra-fast and cross-platform UI development. And with Adaptive Cards, we can combine that with an industry standard for exchanging card content in a structured way. At Neohelden, we're building on both of these technologies with our AI-assistant for business – and you can learn more about why we built this in our blog-post on the release of our Adaptive Cards in Flutter library.

License #

This project is licensed under the MIT License - see the LICENSE file for details

[0.0.1] - TODO: Add release date. #

  • TODO: Describe initial release.


import 'package:example/samples/samples.dart';
import 'package:example/text_block/text_block_examples_page.dart';
import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart'
    show debugDefaultTargetPlatformOverride;
import 'package:dynamic_theme/dynamic_theme.dart';

import 'about_page.dart';
import 'action_open_url/action_open_url_examples_page.dart';
import 'action_show_card/action_show_card_examples_page.dart';
import 'action_submit/action_submit_examples_page.dart';
import 'column/column_examples_page.dart';
import 'column_set/column_set_examples_page.dart';
import 'container/container_examples_page.dart';
import 'fact_set/fact_set_examples_page.dart';
import 'image/image_examples_page.dart';
import 'image_set/image_set_examples_page.dart';
import 'inputs/input_choice_set/input_choice_set.dart';
import 'inputs/input_date/input_date.dart';
import 'inputs/input_number/input_number.dart';
import 'inputs/input_text/input_text.dart';
import 'inputs/input_time/input_time.dart';
import 'inputs/input_toggle/input_toggle.dart';
import 'media/media.dart';
void main() {
  debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia;
  runApp(new MyApp());

class MyApp extends StatelessWidget {
  Widget build(BuildContext context) {
    return DynamicTheme(
      defaultBrightness: Brightness.dark,
      data: (brightness) => new ThemeData(
        primarySwatch: Colors.blue,
        brightness: brightness,
      themedWidgetBuilder: (context, theme) {
        return new MaterialApp(
          title: 'Flutter Adaptive Cards',
          theme: theme,
          home: new MyHomePage(),
          routes: {
            "Samples": (context) => SamplesPage(),
            "TextBlock": (context) => TextBlockPage(),
            "Image": (context) => ImagePage(),
            "Container": (context) => ContainerPage(),
            "ColumnSet": (context) => ColumnSetPage(),
            "Column": (context) => ColumnPage(),
            "FactSet": (context) => FactSetPage(),
            "ImageSet": (context) => ImageSetPage(),
            "Action.OpenUrl": (context) => ActionOpenUrlPage(),
            "Action.Submit": (context) => ActionSubmitPage(),
            "Action.ShowCard": (context) => ActionShowCardPage(),
            "Input.Text": (context) => InputText(),
            "Input.Number": (context) => InputNumber(),
            "Media": (context) => MediaPage(),
            "Input.Date": (context) => InputDatePage(),
            "Input.Time": (context) => InputTimePage(),
            "Input.Toggle": (context) => InputTogglePage(),
            "Input.ChoiceSet": (context) => InputChoiceSetPage(),
            "about": (context) => AboutPage(),

class MyHomePage extends StatefulWidget {

  _MyHomePageState createState() => new _MyHomePageState();

class _MyHomePageState extends State<MyHomePage> {

  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("Flutter Adaptive Cards"),
        actions: <Widget>[
            onPressed: () {
            child: Text("About"),
      body: ListView(
        padding: EdgeInsets.all(16.0),
        children: <Widget>[
            child: Padding(
              padding: const EdgeInsets.all(8.0),
              child: Column(
                children: <Widget>[
                    size: 50.0,
                  Text("Flutter - Adaptive Cards \nby Neohelden", style: TextStyle(fontSize: 24.0, fontWeight: FontWeight.w600), textAlign: TextAlign.center,),
          getRow(["Image", "ImageSet"]),
          getRow(["Action.OpenUrl", "Action.Submit", "Action.ShowCard"]),
          getRow(["Column", "ColumnSet"]),
          getRow(["Input.Text", "Input.Number", "Input.Date"]),
          getRow(["Input.Time", "Input.Toggle", "Input.ChoiceSet"]),

  Widget getRow(List<String> element) {
    return Row(
      children: element.map((it) => Expanded(child: getButton(it)),).toList(),

  Widget getButton(String element) {
    return Card(
      child: InkWell(
        onTap: () => pushNamed(element),
        child: SizedBox(
          height: 64.0,
          child: Center(child: Text(element)),

  void pushNamed(String element) {
    Navigator.pushNamed(context, element);

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_adaptive_cards: ^0.0.1

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_adaptive_cards/flutter_adaptive_cards.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Apr 8, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Fix lib/src/elements/input.dart. (-1 points)

Analysis of lib/src/elements/input.dart reported 2 hints:

line 3 col 8: Unused import: 'package:flutter_adaptive_cards/flutter_adaptive_cards.dart'.

line 4 col 8: Unused import: 'package:flutter_adaptive_cards/src/elements/basics.dart'.

Fix lib/src/flutter_adaptive_cards.dart. (-1 points)

Analysis of lib/src/flutter_adaptive_cards.dart reported 2 hints:

line 6 col 8: Unused import: 'package:uuid/uuid.dart'.

line 10 col 8: Unused import: 'package:flutter_adaptive_cards/src/elements/input.dart'.

Fix lib/src/action_handler.dart. (-0.50 points)

Analysis of lib/src/action_handler.dart reported 1 hint:

line 15 col 52: 'inheritFromWidgetOfExactType' is deprecated and shouldn't be used. Use dependOnInheritedWidgetOfExactType instead. This feature was deprecated after v1.12.1..

Fix additional 7 files with analysis or formatting issues. (-0.50 points)

Additional issues in the following files:

  • lib/src/registry.dart (1 hint)
  • lib/src/basic_markdown.dart (Run flutter format to format lib/src/basic_markdown.dart.)
  • lib/src/elements/actions.dart (Run flutter format to format lib/src/elements/actions.dart.)
  • lib/src/elements/additional.dart (Run flutter format to format lib/src/elements/additional.dart.)
  • lib/src/elements/base.dart (Run flutter format to format lib/src/elements/base.dart.)
  • lib/src/elements/basics.dart (Run flutter format to format lib/src/elements/basics.dart.)
  • lib/src/utils.dart (Run flutter format to format lib/src/utils.dart.)

Maintenance issues and suggestions

Prefer published dependencies. (-100 points)

The source code in a git repository is mutable and could disappear.

Support latest dependencies. (-50 points)

The version constraint in pubspec.yaml does not support the latest published versions for 5 dependencies (flutter_markdown, http, intl, provider, uuid).

Use constrained dependencies. (-20 points)

The pubspec.yaml contains 1 dependency without version constraints. Specify version ranges for the following dependencies: chewie.

The package description is too short. (-17 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
chewie 0.9.10
flutter 0.0.0
flutter_markdown ^0.2.0 0.2.0 0.3.4
http ^0.11.3+16 0.11.3+17 0.12.0+4
intl ^0.15.7 0.15.8 0.16.1
provider ^2.0.1 2.0.1+1 4.0.4
tinycolor ^1.0.2 1.0.2
uuid ^1.0.3 1.0.3 2.0.4
Transitive dependencies
args 1.6.0
async 2.4.1
charcode 1.1.3
collection 1.14.11 1.14.12
convert 2.1.1
crypto 2.1.4
flutter_web_plugins 0.0.0
http_parser 3.1.4
markdown 2.1.3
meta 1.1.8
open_iconic_flutter 0.3.0
path 1.6.4
pigment 1.0.3
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
video_player 0.10.8+1
video_player_platform_interface 1.0.5
video_player_web 0.1.2+1
wakelock 0.1.4+1
Dev dependencies
mockito ^4.0.0
test ^1.5.1