ethanblake4 / flutter_eval

Code push for Flutter, powered by dart_eval

Home Page:https://pub.dev/packages/flutter_eval

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when access property of a Map.

tannguyen3489 opened this issue · comments

hi @team,

I have an issue with Map type

library hot_update;

import 'dart:convert';

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

@RuntimeOverride('#myapp_main_scaffold_1')
// ignore: no_leading_underscores_for_local_identifiers
Widget scaffoldUpdate(BuildContext context, int counter, void Function() _incrementCounter) {

  Map testData = {
    "address": "address",
    "email": "abc@email.com",
    "fax": "+123",
    "faxCountryDial": "123123123",
    "phoneCountryDial": "+123",
    "phone": "123123123",
  };

  String encode = json.encode(testData);
  Map<String, dynamic> decodeData = json.decode(encode);

  return Scaffold(
    appBar: AppBar(
      title: const Text("Time counter"),
      backgroundColor: Colors.indigo,
    ),
    body: Center(
      child: Column(
        mainAxisAlignment: MainAxisAlignment.center,
        children: <Widget>[
          Text(
            'You have added this many seconds 123: ${decodeData["email"]}',
          ),
          Text(
            '$counter',
            style: Theme.of(context).textTheme.headlineMedium,
          ),
        ],
      ),
    ),
    floatingActionButton: FloatingActionButton(
      onPressed: _incrementCounter,
      tooltip: 'Increment',
      child: const Icon(Icons.access_time_filled),
    ),
  );
}

image

when load this widget to HotSwap widget, it will throw error. Please tell me how to fix this issue with Map type.

test2