title: Login form in flutter
body: <p>I´m create a simple login in flutter. This login connect to a API. For do this I retrieve inputs value and send to a method, but return </p>
  
  <blockquote>
    <p>type '_InternalLinkedHashMap' is not a subtype of type 'Map'</p>
  </blockquote>
  
  <p>This is my model</p>
  
  <pre><code>class Login {
    final String usuario, password;
  
    Login({this.usuario, this.password});
  
    factory Login.fromJson(Map&lt;String, dynamic&gt; json) {
      return Login(
        usuario: json['usuario'] as String,
        password: json['password'] as String,
      );
    }
  }
  </code></pre>
  
  <p>And this is my main class </p>
  
  <pre><code>import 'package:flutter/material.dart';
  import 'package:igota/screens/home/home_page.dart';
  import 'package:igota/model/login.dart';
  import 'dart:async';
  import 'dart:convert';
  import 'package:http/http.dart' as http;
  
  class LoginPage extends StatefulWidget {
    static String tag = 'login-page';
    @override
    _LoginPageState createState() =&gt; new _LoginPageState();
  }
  
  class _LoginPageState extends State&lt;LoginPage&gt; {
    final _formKey = GlobalKey&lt;FormState&gt;();
    final userValue = new TextEditingController();
    final passwordValue = new TextEditingController();
  
    @override
    Widget build(BuildContext context) {
      final logo = Hero(
        tag: 'hero',
        child: CircleAvatar(
          backgroundColor: Colors.transparent,
          radius: 48.0,
          child: Image.asset('assets/logo.png'),
        ),
      );
  
      final username = TextFormField(
        controller: userValue,
        validator: (value) {
          if (value.isEmpty) {
            return 'Introduce un nombre';
          }
        },
        keyboardType: TextInputType.emailAddress,
        autofocus: false,
        decoration: InputDecoration(
          hintText: 'Usuario',
          contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
          border: OutlineInputBorder(borderRadius: BorderRadius.circular(32.0)),
        ),
      );
  
      final password = TextFormField(
        controller: passwordValue,
        validator: (value) {
          if (value.isEmpty) {
            return 'Introduce una contraseña';
          }
        },
        autofocus: false,
        obscureText: true,
        decoration: InputDecoration(
          hintText: 'Contraseña',
          contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
          border: OutlineInputBorder(borderRadius: BorderRadius.circular(32.0)),
        ),
      );
  
      Widget _buildLoginButton(BuildContext context) {
        return Padding(
          padding: EdgeInsets.symmetric(vertical: 16.0),
          child: Material(
            borderRadius: BorderRadius.circular(30.0),
            child: MaterialButton(
              minWidth: 200.0,
              height: 42.0,
              onPressed: () {
                fetchPost(userValue, passwordValue);
                //final snackBar = SnackBar(
                //    content: Text(
                //  'Usuario/Contraseña incorrecto',
                //  textAlign: TextAlign.center,
                //));
                //Scaffold.of(context).showSnackBar(snackBar);
                if (_formKey.currentState.validate()) {
                  Navigator.of(context).pushNamed(HomePage.tag);
                }
              },
              color: Colors.blue[300],
              child: Text('Entrar', style: TextStyle(color: Colors.white)),
            ),
          ),
        );
      }
  
      final forgotLabel = FlatButton(
        child: Text(
          '¿Contraseña olvidada?',
          style: TextStyle(color: Colors.black54),
        ),
        onPressed: () {},
      );
  
      return Scaffold(
        backgroundColor: Colors.white,
        body: Builder(
          builder: (context) =&gt; Center(
                  child: Form(
                key: _formKey,
                child: ListView(
                  shrinkWrap: true,
                  padding: EdgeInsets.only(left: 24.0, right: 24.0),
                  children: &lt;Widget&gt;[
                    logo,
                    SizedBox(height: 48.0),
                    username,
                    SizedBox(height: 8.0),
                    password,
                    SizedBox(height: 24.0),
                    _buildLoginButton(context),
                    forgotLabel
                  ],
                ),
              )),
        ),
      );
    }
  }
  
  //Test
  Future&lt;Login&gt; fetchPost(user, pass) async {
    Map headers = {
      'Content-type': 'application/json',
      'Accept': 'application/json',
    };
    final response = await http.post(
        'URL',
        body: {"usuario": user.text, "password": pass.text},
        headers: headers);
    final responseJson = json.decode(response.body);
    return Login.fromJson(responseJson);
  }
  </code></pre>
  
  <p>So i need to return response and check if correct or incorrect to show snackbar. I don't know exactly what i'm doing right or wrong :$</p>