質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

Q&A

0回答

587閲覧

Flutter 定義について

hiro.a

総合スコア28

Flutter

Flutterは、iOSとAndroidのアプリを同じコードで開発するためのフレームワークです。オープンソースで開発言語はDart。双方のプラットフォームにおける高度な実行パフォーマンスと開発効率を提供することを目的としています。

0グッド

0クリップ

投稿2020/07/24 11:11

### 前提・実現したいこと インポートディレクティブの1つに「プレフィックスとして」を使用するか、1つのインポート以外のすべてから名前を非表示にしてい。 ここに質問の内容を詳しく書いてください。 Flutter模写をしており、模写元のコピペしましたが、エラーが発生しており、説明が書かれていないので 調べたうえで質問させて頂きます。 ●アプリケーションの状態を一元化し、アプリケーション全体で状態を利用できるようにするコードです。 ### 発生している問題・エラーメッセージ インポートディレクティブの1つに「プレフィックスとして」を使用するか、1つのインポート以外のすべてから名前を非表示にしたい。
### 該当のソースコード ```Dart import 'package:flutter/foundation.dart' as foundation; import 'product.dart'; import 'products_repository.dart'; double _salesTaxRate = 0.06; double _shippingCostPerItem = 7; class AppStateModel extends foundation.ChangeNotifier { // All the available products. List<Product> _availableProducts; // The currently selected category of products. Category _selectedCategory = Category.all; // The IDs and quantities of products currently in the cart. final _productsInCart = <int, int>{}; Map<int, int> get productsInCart { return Map.from(_productsInCart); } // Total number of items in the cart. int get totalCartQuantity { return _productsInCart.values.fold(0, (accumulator, value) { return accumulator + value; }); } Category get selectedCategory { return _selectedCategory; } // Totaled prices of the items in the cart. double get subtotalCost { return _productsInCart.keys.map((id) { // Extended price for product line return getProductById(id).price * _productsInCart[id]; }).fold(0, (accumulator, extendedPrice) { return accumulator + extendedPrice; }); } // Total shipping cost for the items in the cart. double get shippingCost { return _shippingCostPerItem * _productsInCart.values.fold(0.0, (accumulator, itemCount) { return accumulator + itemCount; }); } // Sales tax for the items in the cart double get tax { return subtotalCost * _salesTaxRate; } // Total cost to order everything in the cart. double get totalCost { return subtotalCost + shippingCost + tax; } // Returns a copy of the list of available products, filtered by category. List<Product> getProducts() { if (_availableProducts == null) { return []; } if (_selectedCategory == Category.all) { return List.from(_availableProducts); } else { return _availableProducts.where((p) { return p.category == _selectedCategory; }).toList(); } } // Search the product catalog List<Product> search(String searchTerms) { return getProducts().where((product) { return product.name.toLowerCase().contains(searchTerms.toLowerCase()); }).toList(); } // Adds a product to the cart. void addProductToCart(int productId) { if (!_productsInCart.containsKey(productId)) { _productsInCart[productId] = 1; } else { _productsInCart[productId]++; } notifyListeners(); } // Removes an item from the cart. void removeItemFromCart(int productId) { if (_productsInCart.containsKey(productId)) { if (_productsInCart[productId] == 1) { _productsInCart.remove(productId); } else { _productsInCart[productId]--; } } notifyListeners(); } // Returns the Product instance matching the provided id. Product getProductById(int id) { return _availableProducts.firstWhere((p) => p.id == id); } // Removes everything from the cart. void clearCart() { _productsInCart.clear(); notifyListeners(); } // Loads the list of available products from the repo. void loadProducts() { _availableProducts = ProductsRepository.loadProducts(category.all); notifyListeners(); } void setCategory(Category newCategory) { _selectedCategory = newCategory; notifyListeners(); } }

試したこと

エラー表示の内容の通り調べましたが、やり方がわかりませんでした。

補足情報(FW/ツールのバージョンなど)

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

satokei

2020/09/08 16:46

質問が見づらくありませんか。見づらい質問は回答がつきにくいです。 Markdown記法を理解して修正してみてください。 あと、発生しているエラーのメッセージは正しいのでしょうか?(翻訳したメッセージ?)
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問