想定読者 FlutterでのAPIレスポンスのハンドリングにResult<T> を使いたい swiftの Union や kotlinの sealed classのようなものをFlutterで扱いたい はじめに 普段Androidを書いているときに retrofit から受け取ったAPIレスポンスを sealed class を利用し、以下のように変換しています。 sealed class Result<T> { data class Success<T>(val body: T?) : Result<T>() data class Failure<T>(val type ErrorType) : Result<T>() companion object { fun create<T>(retrofitResponse: retrofit2.Response<T>): Result<T>
想定読者 FlutterでのAPIレスポンスのハンドリングにResult<T> を使いたい swiftの Union や kotlinの sealed classのようなものをFlutterで扱いたい はじめに 普段Androidを書いているときに retrofit から受け取ったAPIレスポンスを sealed class を利用し、以下のように変換しています。 sealed class Response<T> { data class Success<T>(val body: T?) : Response<T>() data class Error<T>(val type ErrorType) : Response<T>() companion object { fun create<T>(retrofitResponse: retrofit2.Response<T>): Respon
A powerful HTTP networking package, supports Interceptors, Aborting and canceling a request, Custom adapters, Transformers, etc. More... dio # Language: English | 简体中文 A powerful HTTP networking package for Dart/Flutter, supports Global configuration, Interceptors, FormData, Request cancellation, File uploading/downloading, Timeout, Custom adapters, Transformers, etc. Don't forget to add #dio topi
初めに ほとんどのアプリがapi通信をすると思います。 なんか楽にクライアント生成できるのないかな〜と調べていたらretrofitというライブラリを見つけました。 今回はそれを導入してみようと思います。 retrofit retrofit導入YouTube サンプルアプリ まずはサンプルアプリの仕様をざっくり決めます。 Qiitaのapiを使用して最新記事を取得する 取得した記事を一覧で表示する 記事のタイトルをタップしたら記事詳細をwebviewで開く 今回はこんな感じの簡単なアプリにします! retforitの仕組み 導入する前にざっくりとどういう仕組みで動くのか理解します。 公式のReadmeやSampleを見ればなんとなくわかると思いますが、 abstractでapiのエンドポイントを定義。 この定義されたファイルを元にクライアントの実体を自動生成する仕組みです。 自動生成されるフ
リリース、障害情報などのサービスのお知らせ
最新の人気エントリーの配信
処理を実行中です
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く