I'm running into this exception after flutter update to 1.17. It basically keeps retrying to generate files forever.
main.dart
import 'package:flutter/material.dart';
import 'package:flutterapp/counter_store.dart';
void main() {
runApp(MyApp());
}
final CounterStore store = CounterStore();
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
//
primarySwatch: Colors.blue,
visualDensity: VisualDensity.adaptivePlatformDensity,
),
home: MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatelessWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(title),
),
body: Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Text(
'You have pushed the button this many times:',
),
Text(
'${store.count}',
style: Theme.of(context).textTheme.headline4,
),
],
),
),
floatingActionButton: FloatingActionButton(
onPressed: () => store.count++,
tooltip: 'Increment',
child: Icon(Icons.add),
),
);
}
}
counter_store.dart
import 'package:mobx/mobx.dart';
part 'counter_store.g.dart';
class CounterStore extends _Store with _$Store {}
abstract class _Store with CounterStore {
@observable
int count = 0;
@action
Future throwException() {
throw new Exception("Some exception happened");
}
}
pubspec.yaml
name: flutterapp
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.8.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
mobx:
flutter_mobx:
# The following adds the Cupertino Icons font to your application.
# Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.3
dev_dependencies:
flutter_test:
sdk: flutter
mobx_codegen:
build_runner:
# 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
flutter pub run build_runner watch
Bad state: Unexpected diagnostics:
D:\libs\Android\flutter\bin\cache\dart-sdk\lib\internal\internal.dart:172:16 - This requires the 'non-nullable' language feature to be enabled.
[SEVERE] mobx_codegen:mobx_generator on lib/counter_store.dart:
flutter doctor -v
[√] Flutter (Channel master, 1.19.0-1.0.pre.13, on Microsoft Windows [Version 10.0.18363.778], locale en-US)
• Flutter version 1.19.0-1.0.pre.13 at D:\libs\Android\flutter
• Framework revision f865ac7e25 (32 hours ago), 2020-05-08 12:06:15 -0700
• Engine revision 9b905d3f03
• Dart version 2.9.0 (build 2.9.0-7.0.dev 617bc54b71)
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at D:\libs\Android\android-sdk
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = D:\libs\Android\android-sdk
• Java binary at: C:\Program Files\Android\Android Studio Preview\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.5.4)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community
• Visual Studio Community 2019 version 16.5.30011.22
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 44.0.2
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio Preview
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] IntelliJ IDEA Community Edition (version 2019.3)
• IntelliJ at C:\Program Files\JetBrains\IntelliJ IDEA Community Edition 2018.2.2
• Flutter plugin version 43.0.3
• Dart plugin version 193.6494.35
[√] VS Code, 64-bit edition (version 1.44.2)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.10.1
[√] Connected device (5 available)
• Mi A3 • 6b02ac5194ce • android-arm64 • Android 10 (API 29)
• Android SDK built for x86 • emulator-5556 • android-x86 • Android 10 (API 29) (emulator)
• Windows • Windows • windows-x64 • Microsoft Windows [Version 10.0.18363.778]
• Web Server • web-server • web-javascript • Flutter Tools
• Chrome • chrome • web-javascript • Google Chrome 81.0.4044.138
• No issues found!
hello,
i have the same problem on visual code on a mac or a pc
all version is the last version for channel master
@stephane3434 It's weird that sometimes this error occurs sometimes not after updating. You could try to switch to stable or dev it worked for me on both.
i have found a solution,
i have replace build_runner: 1.9.0 (version Apr 22, 2020)
with the last one 1.10
dev_dependencies:
build_runner: ^1.10.0
and all is ok now
i have found a solution,
i have replace build_runner: 1.9.0 (version Apr 22, 2020)
with the last one 1.10
dev_dependencies:
build_runner: ^1.10.0and all is ok now
I had the same problem, this solved :)
Most helpful comment
i have found a solution,
i have replace build_runner: 1.9.0 (version Apr 22, 2020)
with the last one 1.10
dev_dependencies:
build_runner: ^1.10.0
and all is ok now