[SOLVED] Flutter : Unhandled Exception: type ‘int’ is not a subtype of type ‘String’ in type cast

Problem

I’m Calling An API to update my data and I got this error, the Error Says,

E/flutter (32582): type 'int' is not a subtype of type 'String' in type cast

Solution

Step 1: use "content-type": "application/json" in header

Step 2: encode your body like jsonEncode( {"param1": 10, "param2":20,"param3": "abc","param4": true})

Example Code Like

headers: {
      "content-type": "application/json",
    },
    body:jsonEncode( {
      "qualificationId": 10,
      "year":2001,
      "instituteName": "example",
      "isActive": true
    })

That’s it.

Thanks for Reading.

Keep Coding.

How to Send Email when someone Register and also send email verification

In this tutorial Iโ€™m going to describe how to get email verification when someone register in laravel. Please follow some easy steps mentioned below.

First letโ€™s go to install laravel project

composer create-project laravel/laravel mail-verification "5.8.*"

๐Ÿ‘‡ Database Configuration

Setup database with your installed laravel 8 project . lets go to .env folder and put database name and connect to database.

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel-mail
DB_USERNAME=root
DB_PASSWORD=

Next click on create

Next set up to mail trap for getting mail

Go to this URL โ€” MailTrapio

Go to .env and put your mailtrap credentials

MAIL_MAILER=smtp
MAIL_HOST=smtp.mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=puthere-----
MAIL_PASSWORD=puthere-----
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"

Now migrate the table

php artisan migrate

Now Create Auth

php artisan make:auth

Go to App/user.php file and paste below code

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Contracts\Auth\MustVerifyEmail;
use Illuminate\Foundation\Auth\User as Authenticatable;

class User extends Authenticatable implements MustVerifyEmail
{
use Notifiable;

/**
* The attributes that are mass assignable.
*
* @var array
*/
protected $fillable = [
'name', 'email', 'password',
];

/**
* The attributes that should be hidden for arrays.
*
* @var array
*/
protected $hidden = [
'password', 'remember_token',
];

/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'email_verified_at' => 'datetime',
];
}

Next go to Set-up Routes

Routes/web.php

Replace Auth:Routes to below code

Auth::routes(['verify' => true]);

Next go to HomeController.php file and paste below function code

public function __construct()
{
$this->middleware(['auth', 'verified']);
}

Now set-up is completed run below code

php artisan serve

Now page is look like this

Now you got successfully got verification email

Now also youโ€™ll get email when register

Login successfully when you verify email

Thanks i hope its helpful for you ๐Ÿ™๐Ÿ™

Tagged : / / /