Flutter mobx mobx_codegen generates null safety code for computed getters - flutter

Using mobx and mobx_codegen for Flutter.
My code is NOT null safe (sdk: ">=2.7.0 <3.0.0").
When mobx_codegen generates code for #computed getters, it uses null safety, which won't compile...
Sample class counter (look at #computed):
import 'package:mobx/mobx.dart';
// Include generated file
part 'counter.g.dart';
// This is the class used by rest of your codebase
class Counter = _Counter with _$Counter;
// The store-class
abstract class _Counter with Store {
#observable
int value = 0;
#computed
int get test => 0;
#action
void increment() {
value++;
}
}
Relevant generated code (counter.g.dart):
Computed<int>? _$testComputed;
Shows this error:
This requires the 'non-nullable' language feature to be enabled.
Try updating your pubspec.yaml to set the minimum SDK constraint to 2.12.0 or higher, and running 'pub get'.
I'm new to mobx, am I doing something wrong?

How´s it going?
I am with the same issue in my project. I installed the new flutter version and after that my project stopped to compile. I changed my dependences of mobx, flutter_mobx, mobx_codegen and build_runner and them worked.
My first dependences:
mobx: ^1.2.1+4
flutter_mobx: ^1.1.0+2
build_runner: ^1.11.5
mobx_codegen: ^1.1.2
My last dependences:
mobx: ^2.0.6+1
flutter_mobx: ^2.0.4
build_runner: ^2.1.7
mobx_codegen: ^2.0.5+2
From there, It has started my issue of "#computed" while I run the build_runner.
I changed the Dart SDK of my project and It stopped to show error of "#computed". But broke all source code because I developed my code with "non- null-safety".
So, looking for replies. I figured out the root cause is the specifically the mobx_codegen newer dependency that uses null safety and doesn´t have a tratament to valid our Dart SDK.
In my opnion, It should´ve validated while running of build_runner.
So, Someone knows how could I resolve that issue?
I have a commercial solution of app, and I´ve planned to release until 3 months.
my pubspec.yaml is so:
name: XPTO
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
mobx: ^2.0.6+1
flutter_mobx: ^2.0.4
get_it: ^7.2.0
flutter_search_bar: ^3.0.0-dev.1
carousel_slider: ^4.0.0
intl: ^0.17.0
image_picker: ^0.8.4+5
image_cropper: ^1.4.1
parse_server_sdk_flutter: ^3.1.0
cpf_cnpj_validator: ^2.0.0
brasil_fields: ^1.3.0
mask_text_input_formatter: ^2.1.0
badges: ^2.0.2
flutter_rating_bar: ^4.0.0
expandable: ^5.0.1
flutter_easyloading: ^3.0.3
internet_connection_checker: ^0.0.1+3
cached_network_image: ^3.2.0
flutter_keyboard_visibility: ^5.1.1
json_annotation: ^4.4.0
dev_dependencies:
flutter_test:
sdk: flutter
build_runner: ^2.1.7
mobx_codegen: ^2.0.5+2
graphs: ^2.1.0
json_serializable: ^6.1.4
dependency_overrides:
plugin_platform_interface: ^2.0.0
build_resolvers: ^2.0.6
web_socket_channel: ^2.0.0
analyzer: ^3.2.0
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
assets:
- images/logo.jpeg
- images/empty.jpg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

Since you're using a version of MobX that has null-safety, you can either:
migrate your code to null-safety (recommended).
downgrade your mobx, mobx_codegen and build_runner packages to a version that doesn't have null-safety.
To migrate your code, you can follow this Migration Guide.
If you opt to downgrade, be aware that you might run into version conflicts and there's a chance you have to downgrade your Flutter SDK too.

Related

flutter location package version conflict with google_map_location_picker

I download a source code from codecanyone but
I am facing the following issue when adding google_map_location_picker package
Because location 4.3.0 depends on location_platform_interface ^2.3.0 and no versions of location_platform_interface match >2.3.0 <3.0.0, location 4.3.0 requires location_platform_interface 2.3.0.
And because location_platform_interface 2.3.0 depends on plugin_platform_interface ^2.0.0 and geolocator_platform_interface <2.0.0-nullsafety.0 depends on plugin_platform_interface ^1.0.2, location 4.3.0 is incompatible with geolocator_platform_interface <2.0.0-nullsafety.0.
And because google_map_location_picker >=4.1.3 depends on geolocator ^6.1.14 which depends on geolocator_platform_interface ^1.0.8, location 4.3.0 is incompatible with google_map_location_picker >=4.1.3.
So, because markets depends on both google_map_location_picker 4.1.7 and location 4.3.0, version solving failed.
pub get failed (1; So, because markets depends on both google_map_location_picker 4.1.7 and location 4.3.0, version solving failed.)
here is my pubspec.yaml file
name: markets
description: markets
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 2.2.0
environment:
sdk: ">=2.2.2 <3.0.0"
module:
androidX: true
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: 1.0.4
google_maps_flutter: 2.1.1
google_map_location_picker: 4.1.7
mvc_pattern: 6.6.4+2
global_configuration: 2.0.0-nullsafety.1
html: 0.15.0
shared_preferences: 2.0.13
flutter_html: 3.0.0-alpha.2
flutter_svg: 1.0.3
location: 4.3.0
webview_flutter: 3.0.0
url_launcher: 6.0.20
cached_network_image: 3.2.0
fluttertoast: 8.0.8
flutter_staggered_grid_view: 0.4.0-nullsafety.3
intl_utils: 2.6.1
carousel_slider: 4.0.0
cloud_firestore: 3.1.8
firebase_auth: 3.3.7
firebase_core: 1.12.0
firebase_messaging: 11.2.6
firebase_storage: 8.0.0
image_picker: 0.7.5+4
string_validator: 0.3.0
platform: 3.1.0
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/cfg/
- assets/img/
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: ProductSans
fonts:
- asset: assets/fonts/ProductSans-Thin.ttf
weight: 100
- asset: assets/fonts/ProductSans-Thin.ttf
weight: 200
- asset: assets/fonts/ProductSans-Light.ttf
weight: 300
- asset: assets/fonts/ProductSans-Regular.ttf
weight: 400
- asset: assets/fonts/ProductSans-Medium.ttf
weight: 500
- asset: assets/fonts/ProductSans-Bold.ttf
weight: 600
- asset: assets/fonts/ProductSans-Black.ttf
weight: 700
- asset: assets/fonts/ProductSans-Black.ttf
weight: 800
- asset: assets/fonts/ProductSans-Black.ttf
weight: 900
# - family: Trajan Pro
# fonts:
# - asset: assets/fonts/TrajanPro.ttf
# - asset: assets/fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-assets/fonts/#from-packages
flutter_intl:
enabled: true
You've just stumbled upon a Dependency Hell. google_map_location_picker is pretty old now (16 months already) and it uses outdated versions of other packages that some dependencies from the pubspec.yaml depends on itself.
If you remove google_map_location_picker from the dependencies everything installs smoothly. Your best option then would be to fork google_map_location_picker and change the dependencies yourself and point its dependency in the pubspec.yaml to this fork of yours.
To add the fork as a dependency, for example from Github, do something like this:
dependencies:
flutter:
sdk: flutter
carousel_pro:
git:
url: git://github.com/your_account/google_map_location_picker_fork.git
ref: main # branch name

flutter pubspec.yaml file unknown errors?

so I executed a flutter clean command for my flutter project and then the flutter pub get command but now my flutter project is showing multiple errors in the pubspec.yaml file the code is running but there are unknown errors that are shown. where now even if i create a new flutter project it shows error so i reinstalled the flutter and it still shows the same for pubspec.yaml file only.
please help me out..............
refer the image for error:
name: worksaga
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `flutter pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.16.1 <3.0.0"
# Dependencies specify other packages that your package needs in order to work.
# To automatically upgrade your package dependencies to the latest versions
# consider running `flutter pub upgrade --major-versions`. Alternatively,
# dependencies can be manually updated by changing the version numbers below to
# the latest version available on pub.dev. To see which dependencies have newer
# versions available, run `flutter pub outdated`.
dependencies:
flutter:
sdk: flutter
flutter_signin_button: ^2.0.0
multi_image_picker2: ^5.0.2
http: ^0.13.4
loader_overlay: ^2.0.5
shared_preferences: ^2.0.12
dio: ^4.0.4
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
path_provider: ^2.0.8
intl: ^0.17.0
flutter_date_picker_timeline: ^0.3.3
carousel_slider: ^4.0.0
cached_network_image: ^3.2.0
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
flutter_svg: ^1.0.3
dev_dependencies:
flutter_test:
sdk: flutter
google_fonts: ^2.3.1
# The "flutter_lints" package below contains a set of recommended lints to
# encourage good coding practices. The lint set provided by the package is
# activated in the `analysis_options.yaml` file located at the root of your
# package. See that file for information about deactivating specific lint
# rules and activating additional ones.
flutter_lints: ^1.0.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
- assets/icons/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: NanumMyeongjo
fonts:
- asset: assets/fonts/NanumMyeongjo-ExtraBold.ttf
# - asset: assets/fonts/NanumMyeongjo-Bold.ttf
# weight: 500
# - asset: assets/fonts/NanumMyeongjo-ExtraBold.ttf
# weight: 700
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
It seems that you've added a tab/space before the name property (first line) in your pubspec.yaml. Indentation is very important in YAML files since it indicates and separates flow blocks.

flutter : pubspec.yaml no error but gradle failed in android studio

My pubspec.yaml has no error, my app works perfectly on my emulator, but when I got to android studio (to add app logo or to create .aab) there is gradle failed.
I'm pretty sure this problem comes from my pubspec file, because when I create a new projet it works perfectly, but when I modify my pubspec, I can't open the projet in Android studio.
As I re-use lots of packages, I paste a pubspec from an other projet (Of course, I change the app id)
name: appid
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.2
auto_size_text:
shared_preferences:
firebase_core: ^1.0.3
firebase_database: ^6.1.2
uuid:
flutter_statusbarcolor:
flutter_admob_app_open:
google_mobile_ads:
open_ad_flutter:
pull_to_refresh:
flutter_launcher_icons:
cached_network_image:
url_launcher:
firebase_messaging: ^11.1.0
flutter_local_notifications: ^5.0.0+4
firebase_analytics:
in_app_review:
sendgrid_mailer:
google_fonts:
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/images/
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
It is quite annoying as I need to recreate a projet every time this happen.
I don't have errors, I got this message
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
The AbstractArchiveTask.destinationDir property has been deprecated. This is scheduled to be removed in Gradle 7.0. Please use the
destinationDirectory property instead.
This helps me for Deprecated Gradle features were used in build
cd android && ./gradlew clean

flutter_whatsapp depends on both integration_test ^1.0.2+3 and flutter_driver any from sdk, version solving failed

Because every version of flutter_driver from sdk depends on vm_service 7.3.0 and integration_test 1.0.2+3 depends on vm_service >=4.2.0 <7.0.0, flutter_driver from sdk is incompatible with integration_test 1.0.2+3.
And because no versions of integration_test match >1.0.2+3 <2.0.0, flutter_driver from sdk is incompatible with integration_test ^1.0.2+3.
So, because flutter_whatsapp depends on both integration_test ^1.0.2+3 and flutter_driver any from sdk, version solving failed.
Running "flutter pub get" in flutter_whatsapp...
pub get failed (1; So, because flutter_whatsapp depends on both integration_test ^1.0.2+3 and flutter_driver any from sdk, version solving
failed.)
Am getting this kinda error
Thanks in advance...
name: flutter_whatsapp
description: A new Flutter project.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^1.0.3
ext_storage: ^1.0.3
intl: ^0.17.0
http: ^0.13.4
contacts_service: ^0.6.3
cached_network_image: ^3.1.0
camera: ^0.9.4+3
# video_player: ^0.10.0+5
path_provider: ^2.0.6
fluro: ^2.0.3
sliding_up_panel: ^2.0.0+1
flutter_app_badger: ^1.3.0
url_launcher: ^6.0.12
shared_preferences: ^2.0.8
android_intent: ^0.3.7+6
permission_handler: ^8.2.5
integration_test: ^1.0.2+3
uuid: ^3.0.5
# fast_qr_reader_view: ^0.1.5
# fast_qr_reader_view:
# git:
# url: git://github.com/facundomedica/fast_qr_reader_view.git
dev_dependencies:
flutter_driver:
sdk: flutter
flutter_test:
sdk: flutter
version: any
# test: ^1.5.0
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
# assets:
# - images/a_dot_burr.jpeg
# - images/a_dot_ham.jpeg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
# fonts:
# - family: Schyler
# fonts:
# - asset: fonts/Schyler-Regular.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages

How do I fix pub get failed (66; Could not decompress gz stream Connection closed while receiving data, path = '')

description: A new Flutter application.
# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.0.0+1
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
# cloud_firestore: ^0.13.2+1
# firebase_auth: ^0.15.4
# shared_preferences: ^0.5.6+1
# fluttertoast: ^3.1.3
# image_picker: ^0.6.3+1
# firebase_storage: ^3.1.1
flutter_staggered_grid_view: ^0.3.0
# provider: ^4.0.4
# path_provider: ^0.5.0+1
image: ^2.1.14
# intl:
dev_dependencies:
flutter_test:
sdk: flutter
# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
# The following section is specific to Flutter.
flutter:
# The following line ensures that the Material Icons font is
# included with your application, so that you can use the icons in
# the material Icons class.
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- images/welcome.png
- images/login.png
- images/admin.png
- images/cash.png
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.
# For details regarding adding assets from package dependencies, see
# https://flutter.dev/assets-and-images/#from-packages
# To add custom fonts to your application, add a fonts section here,
# in this "flutter" section. Each entry in this list should have a
# "family" key with the font family name, and a "fonts" key with a
# list giving the asset and other descriptors for the font. For
# example:
fonts:
- family: Signatra
fonts:
- asset: assets/fonts/Signatra.ttf
# - asset: fonts/Schyler-Italic.ttf
# style: italic
# - family: Trajan Pro
# fonts:
# - asset: fonts/TrajanPro.ttf
# - asset: fonts/TrajanPro_Bold.ttf
# weight: 700
#
# For details regarding fonts from package dependencies,
# see https://flutter.dev/custom-fonts/#from-packages
Error Screen
How do I fix this error:
pub get failed
(66; Could not decompress gz stream Connection closed while receiving data, path = '')
I have tried using flutter clean, flutter pub pub cache repair
I have their results in pictures. Please help me, as I have never come across this bug before and there is no answer for it on Stack Overflow yet.
Fault Image
The error occurs when I try to pub get the following packages below:
flutter_staggered_grid_view:
image: ^2.1.14..
Clean flutter: flutter clean
Fix cache: flutter pub cache repair
Upgrade flutter flutter upgrade
If it doesn't work, run flutter doctor and show us the result.
Working pubspec.yaml
description: A new Flutter application.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev
version: 1.0.0+1
name: name_of_your_package
environment:
sdk: ">=2.7.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.0
flutter_staggered_grid_view: ^0.3.2
image: ^2.1.14
dev_dependencies:
flutter_test:
sdk: flutter
flutter:
uses-material-design: true
assets:
- images/welcome.png
- images/login.png
- images/admin.png
- images/cash.png
fonts:
- family: Signatra
fonts:
- asset: assets/fonts/Signatra.ttf
I think the problem has to do with your internet connection. Check if you're behind a proxy or a VPN. If yes, run the flutter pub get command without going through the proxy or VPN. Also, check your internet connection download speed.
Alternatively, you can add the package manually by following these steps:
Download the package archive. This is usually found on https://pub.dev/packages/PACKAGE_NAME/versions. Replace PACKAGE_NAME with the actual package name.
Unzip the file and place the extracted folder inside home/username/flutter/.pub-cache/hosted/pub.dartlang.org/ . This is where your downloaded packages are stored. For Windows, check C:\Users\Username\AppData\Local\Pub\Cache\hosted\pub.dartlang.org
For Mac, check users/*username*/Developer/flutter/.pub-cache/hosted/pub.dartlang.org/
At the root folder of your project, run flutter pub get again. This time, it should be successful because there is nothing to download.
try flutter clean
and then
pub get
good luck :)