Dart if(A is B) condition not working properly - flutter

var data = snapshot.data as List;
return ListView.builder(
itemCount: data.length,
itemBuilder: (context, i) {
var item = data[i];
print('instance: $item');
if (item is BookFavorItem) {
return BookItemCard(
bookId: item.bookId,
title: item.title,
author: item.author,
);
} else if (item is BookLentItem) {
return BookItemCard(
bookId: item.bookId,
title: item.title,
author: item.author,
dateRange: '${item.lentDate} - ${item.deadline}',
);
} else {
return ListTile(
title: Text('<$item> not matched'),
);
}
},
);
Console Output
I/flutter ( 6832): instance: Instance of 'BookFavorItem'
I/flutter ( 6832): instance: Instance of 'BookFavorItem'
I/flutter ( 6832): instance: Instance of 'BookFavorItem'
I/chatty ( 6832): uid=10336(com.example.library) 1.ui identical 6 lines
I/flutter ( 6832): instance: Instance of 'BookFavorItem'
I/flutter ( 6832): instance: Instance of 'BookFavorItem'
I/chatty ( 6832): uid=10336(com.example.library) 1.ui identical 5 lines
I/flutter ( 6832): instance: Instance of 'BookFavorItem'
Screen Result
As you can see from the code, I got a variable called item which is an instance of BookFavorItem.
However, when I use condition if( item is BookFavorItem ) to control the flow, it did not work as expected behavior. (I thought this condition should be true, but it didn't)
The evidence is that I got the message of "Instance of BookFavorItem", which is the exact type used for is condition from Debug Console and App Screen
What's wrong with me?
-> flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, v1.17.1, on Microsoft Windows [Version 10.0.19041.264], locale zh-CN)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
X Android license status unknown.
Try re-installing or updating your Android SDK Manager.
See https://developer.android.com/studio/#downloads or visit visit
https://flutter.dev/docs/get-started/install/windows#android-setup for detailed instructions.
[!] Android Studio (version 3.6)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[√] VS Code (version 1.45.1)
[√] Connected device (1 available)

Related

Flutter Build failure

I'm unable to build an app with a build failure. The following is what is observed when the build fails with exit code 1 :
[ ] FAILURE: Build failed with an exception.
[ +5 ms] * Where:
[ ] Script 'E:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1156
[ ] * What went wrong:
[ ] Execution failed for task ':app:compileFlutterBuildDebug'.
[ ] > Process 'command 'E:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
[ ] * Try:
[ ] > Run with --stacktrace option to get the stack trace.
[ +1 ms] > Run with --info or --debug option to get more log output.
[ +1 ms] > Run with --scan to get full insights.
[ +1 ms] * Get more help at https://help.gradle.org
[ ] BUILD FAILED in 23s
[ +569 ms] Running Gradle task 'assembleDebug'... (completed in 24.0s)
[ +3 ms] Exception: Gradle task assembleDebug failed with exit code 1
[ +1 ms] "flutter run" took 25,982ms.
[ +5 ms]
#0 throwToolExit (package:flutter_tools/src/base/common.dart:10:3)
#1 RunCommand.runCommand (package:flutter_tools/src/commands/run.dart:699:9)
<asynchronous suspension>
#2 FlutterCommand.run.<anonymous closure> (package:flutter_tools/src/runner/flutter_command.dart:1183:27)
<asynchronous suspension>
#3 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#4 CommandRunner.runCommand (package:args/command_runner.dart:209:13)
<asynchronous suspension>
#5 FlutterCommandRunner.runCommand.<anonymous closure> (package:flutter_tools/src/runner/flutter_command_runner.dart:281:9)
<asynchronous suspension>
#6 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#7 FlutterCommandRunner.runCommand (package:flutter_tools/src/runner/flutter_command_runner.dart:229:5)
<asynchronous suspension>
#8 run.<anonymous closure>.<anonymous closure> (package:flutter_tools/runner.dart:62:9)
<asynchronous suspension>
#9 AppContext.run.<anonymous closure> (package:flutter_tools/src/base/context.dart:150:19)
<asynchronous suspension>
#10 main (package:flutter_tools/executable.dart:94:3)
<asynchronous suspension>
This is my build.gradle code :
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {gradle
classpath 'com.android.tools.build:gradle:7.2.0'
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
ext {
flutterFFmpegPackage = "full-gpl-lts"
}
subprojects {
project.evaluationDependsOn(':app')
}
task clean(type: Delete) {
delete rootProject.buildDir
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "26.1.0"
}
}
}
}
My gradle wrapper :
#Fri Jun 23 08:50:38 CEST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
Flutter doctor shows :
[√] Flutter (Channel stable, 3.0.2, on Microsoft Windows [Version 10.0.22000.708], locale en-IN)
• Flutter version 3.0.2 at E:\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision cd41fdd495 (4 days ago), 2022-06-08 09:52:13 -0700
• Engine revision f15f824b57
• Dart version 2.17.3
• DevTools version 2.12.2
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)
• Android SDK at C:\Users\earthling\AppData\Local\Android\Sdk
• Platform android-32, build-tools 32.1.0-rc1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
• All Android licenses accepted.
[X] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[X] Visual Studio - develop for Windows
X Visual Studio not installed; this is necessary for Windows development.
Download at https://visualstudio.microsoft.com/downloads/.
Please install the "Desktop development with C++" workload, including all of its default components
[√] Android Studio (version 2021.2)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.12+7-b1504.28-7817840)
[√] VS Code, 64-bit edition (version 1.68.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 3.42.0
[√] Connected device (3 available)
• sdk gphone64 x86 64 (mobile) • emulator-5554 • android-x64 • Android 12 (API 32) (emulator)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.22000.708]
• Edge (web) • edge • web-javascript • Microsoft Edge 102.0.1245.39
App level build.gradle
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.")
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"
android {
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
defaultConfig {
// TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
applicationId "com.example.earthling_app_final"
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
// TODO: Add your own signing config for the release build.
// Signing with the debug keys for now, so `flutter run --release` works.
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
}
The following has already been done :
Replaced the flutter folder entirely by downloading flutter stable 3.0.2 and run flutter pub get.
Deleted build folder
Deleted pubspec.lock
Re-Ran ./gradlew :app:assembleDebug --stacktrace --warning-mode all
The error still exists.
Please take a backup of your project. Run flutter create .. This should create all missing files. As an alternative create a new project in 3.0.2 and copy files to the new project and try building it

The following _CastError was thrown building Container: Null check operator used on a null value

I got this error when I run my simple flutter APP. I could not figure out why this error occurred.
Error
Null check operator used on a null value
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:star_book/src/controller/mapDataController.dart';
import 'package:star_book/src/model/app_settings.dart';
import 'package:star_book/src/model/category.dart';
import 'package:star_book/src/model/map_data.dart';
class MapInformationPage extends StatefulWidget {
late final String selectedMap;
MapInformationPage(this.selectedMap);
#override
_MapInformationPageState createState() => _MapInformationPageState();
}
class _MapInformationPageState extends State<MapInformationPage> {
final _mapController = Get.put(MapDataController());
late final MapData mapData;
late AppSettings _appSettings;
late List<Category> _favoriteIcons;
late int _favoriteIconsIndex;
#override
void initState() {
super.initState();
_appSettings = AppSettings();
_favoriteIcons = [
Category(Icons.favorite_border, Colors.black),
Category(Icons.favorite, Colors.red),
];
_favoriteIconsIndex = 0;
_mapController.selectedMapData(widget.selectedMap);
}
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
leading: IconButton(
onPressed: () {
Get.back();
},
icon: Icon(Icons.arrow_back),
iconSize: 24,
),
backgroundColor: _appSettings.appBarAndNavColor,
),
body: Container(
width: _appSettings.appWidth * 0.9,
height: _appSettings.appHeight - _appSettings.appBarHeight,
child: ListView(children: [
Container(
child: GetBuilder(
builder: (_) {
return Text(
'map > star1 >' + _mapController.mapData.name.toString(),
style: TextStyle(fontSize: 20),
);
},
),
),
]),
),
);
}
}
My flutter doctor output
[√] Flutter (Channel stable, 2.2.3, on Microsoft Windows [Version 10.0.19043.1165], locale ko-KR)
• Flutter version 2.2.3 at C:\Program Files\flutter
• Framework revision f4abaa0735 (8 weeks ago), 2021-07-01 12:46:11 -0700
• Engine revision 241c87ad80
• Dart version 2.13.4
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at C:\Users\HOME\AppData\Local\Android\sdk
• Platform android-30, build-tools 29.0.3
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 4.1.0)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin can be installed from:
https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01)
[√] VS Code (version 1.59.1)
• VS Code at C:\Users\HOME\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.25.0
[√] Connected device (3 available)
• sdk gphone x86 (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.78
Can anyone provide a solution for this?
Normally, "Null check operator used on a null value" is throw when
var v = null;
var s = v!.value; <--"Null check operator used on a null value"
You can check the simple flutter APP codes.
Also, this may help: Null check operator used on a null value
It's most probably you are using SDK of flutter which employs null safety.
Edit your pubspec.yaml with fluuter sdk less than 2.12 or ensure null safety in your code.

Getting an error "Null check operator used on a null value" when trying to consume value from provider

I'm getting the below error when trying to execute my flutter app:
======== Exception caught by widgets library =======================================================
The following _CastError was thrown building VerifyEmail(dirty, dependencies: [_InheritedProviderScope<User?>], state: _VerifyEmailState#da862):
Null check operator used on a null value
The relevant error-causing widget was:
VerifyEmail file:///Users/sas/Projects/Development/App/Flutter/netapp/lib/screens/sign_up.dart:152:61
When the exception was thrown, this was the stack:
#0 _VerifyEmailState.build (package:netapp/screens/verify_email.dart:58:40)
#1 StatefulElement.build (package:flutter/src/widgets/framework.dart:4691:27)
#2 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4574:15)
#3 StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4746:11)
#4 Element.rebuild (package:flutter/src/widgets/framework.dart:4267:5)
...
====================================================================================================
The error causing code:
User? firebaseUser = Provider.of<User?>(context, listen: false);
String? emailAddress = firebaseUser!.email;
If I do not specify the null check operator [!] to email then I get a syntax error.
I'm using this emailAddress variable within a Text widget.
Text(
emailAddress!,
textAlign: TextAlign.center,
style: GoogleFonts.roboto(
textStyle: Theme.of(context).textTheme.subtitle1!.copyWith(
color: kBrandAccentColor,
),
),
),
The code listed below is relevant to the provider present within the main.dart file:
return MultiProvider(
providers: [
StreamProvider<User?>.value(
value: AuthService().onAuthStateChanged,
initialData: null,
),
]
)
The below code is present within my authentication service file:
Stream<User?> get onAuthStateChanged => authInstance.authStateChanges();
Versions of the packages:
firebase_core: ^1.3.0
firebase_auth: ^1.4.1
cloud_firestore: ^2.2.2
provider: ^5.0.0
Output of the flutter --version:
Flutter 2.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 02c026b03c (5 weeks ago) • 2021-05-27 12:24:44 -0700
Engine • revision 0fdb562ac8
Tools • Dart 2.13.1
The firebaseUser is still null when you want to ask its email. By using the ! operator, you explicitly tell "I personally guarantee this object is not null", which isn't the case so it throws the exception.
Maybe you wanted to use the ? operator instead?
String? emailAddress = firebaseUser?.email;
This will use optional chaining, which seems to be the thing you need here.

Flutter: Getting "Null check operator used on a null value" error creating MaterialColor

I'm creating a custom MaterialColor object but it's throwing that error.
colors.dart (where I'm creating the MaterialColor object)
import 'package:flutter/material.dart';
class JarsColors {
static const MaterialColor palette = MaterialColor(
0xFF276678,
<int, Color> {
0: Color(0xFFF6F5F5),
100: Color(0xFFD3E0EA),
400: Color(0xFF1687A7),
500: Color(0xFF276678),
}
);
}
main.dart
class MyApp extends StatelessWidget {
#override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: JarsColors.palette,
),
home: JarsHome(title: 'Hello'),
);
}
}
Error output:
The following _CastError was thrown building MyApp(dirty):
Null check operator used on a null value
The relevant error-causing widget was
MyApp
When the exception was thrown, this was the stack
#0 new ThemeData
#1 MyApp.build
#2 StatelessElement.build
#3 ComponentElement.performRebuild
#4 Element.rebuild
flutter doctor output
λ flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.0.3, on Microsoft Windows [Version 10.0.19042.928], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[√] Chrome - develop for the web
[√] Android Studio (version 4.1.0)
[√] VS Code (version 1.55.2)
[√] Connected device (3 available)
• No issues found!
I managed to make it work by adding more shades to the MaterialColor swatch argument:
class JarsColors {
static const MaterialColor palette = MaterialColor(
0xFF276678,
<int, Color> {
50: Color(0xFFF6F5F5),
100: Color(0xFFD3E0EA),
200: Color(0xFFD3E0EA),
300: Color(0xFFD3E0EA),
400: Color(0xFF1687A7),
500: Color(0xFF276678),
600: Color(0xFFD3E0EA),
700: Color(0xFF1687A7),
}
);
}
With the help of: https://api.flutter.dev/flutter/material/MaterialColor-class.html
Nonetheless I can't find an explanation to this. It'd be great to know.
To keep answer short and straight forward, when defining MaterialColor you must start from 50, then 100 and increments in interval of 100 to 800 is enough to allow you to use it without null check errors, check this one how they did it here
How to define and use custom MaterialColor in flutter

Compiler error using webView in flutter: The argument type 'AutoMediaPlaybackPolicy can't be assigned to the parameter type 'AutoMediaPlaybackPolicy

I'm trying to write an app with the use of the WebView in flutter. However, i'm receiving the error described below:
compiler message:
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart:395:37: Error: The argument type 'AutoMediaPlaybackPolicy/*1*/' can't be assigned to the parameter type 'AutoMediaPlaybackPolicy/*2*/'.
- 'AutoMediaPlaybackPolicy/*1*/' is from 'package:webview_flutter/webview_flutter.Dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart').
- 'AutoMediaPlaybackPolicy/*2*/' is from 'package:webview_flutter/webview_flutter.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.dart').
autoMediaPlaybackPolicy: widget.initialMediaPlaybackPolicy,
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart:401:28: Error: The argument type 'JavascriptMode/*1*/' can't be assigned to the parameter type 'JavascriptMode/*2*/'.
- 'JavascriptMode/*1*/' is from 'package:webview_flutter/webview_flutter.Dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart').
- 'JavascriptMode/*2*/' is from 'package:webview_flutter/webview_flutter.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.dart').
javascriptMode: widget.javascriptMode,
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart:426:31: Error: A value of type 'JavascriptMode/*1*/' can't be assigned to a variable of type 'JavascriptMode/*2*/'.
- 'JavascriptMode/*1*/' is from 'package:webview_flutter/webview_flutter.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.dart').
- 'JavascriptMode/*2*/' is from 'package:webview_flutter/webview_flutter.Dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart').
javascriptMode = newValue.javascriptMode;
^
/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart:439:21: Error: The argument type 'JavascriptMode/*1*/' can't be assigned to the parameter type 'JavascriptMode/*2*/'.
- 'JavascriptMode/*1*/' is from 'package:webview_flutter/webview_flutter.Dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.Dart').
- 'JavascriptMode/*2*/' is from 'package:webview_flutter/webview_flutter.dart' ('/C:/flutter/.pub-cache/hosted/pub.dartlang.org/webview_flutter-0.3.22+1/lib/webview_flutter.dart').
javascriptMode: javascriptMode,
I created a separate app only using WebView (to test my environment) and that's running correctly. I don't understand because in the first application (with error) presents the issue. If I remove all code related to WebView the compiler message still the same, i.e, the problem happens when I do the import in the package. The pubspec.yaml is identical in the two Applications.
The respective code:
import 'package:webview_flutter/webview_flutter.Dart';
class WebViewContainer extends StatefulWidget {
final url;
WebViewContainer(this.url);
#override
createState() => _WebViewContainerState(this.url);
}
class _WebViewContainerState extends State<WebViewContainer> {
var _url;
final _key = UniqueKey();
_WebViewContainerState(this._url);
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: Column(
children: [
Expanded(
child: WebView(
key: _key,
javascriptMode: JavascriptMode.unrestricted,
initialUrl: _url))
],
));
}
}
The piece of code where the action happens:
class CursoDeNoivos extends StatelessWidget{
#override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("Curso de Noivos"),
centerTitle: true,
backgroundColor: Colors.deepPurple,
),
body:SingleChildScrollView(
child: Column(
children: <Widget>[
Expanded(
child: Padding(
padding: EdgeInsets.only(left: 1.0, top: 1.0, right: 1.0, bottom: 1.0),
child: Container(
height: button_height,
child: buildIconButton("Inscrições", _insc, context, Icons.add_circle_outline),
)
),
)
],
The action when the button is pressed:
Widget buildIconButton(String _text, Object _obj, BuildContext _context, IconData _icon) {
return RaisedButton.icon(
onPressed: (){
//Navigator.push(_context, MaterialPageRoute(builder: (context) => _obj));
Navigator.push(_context, MaterialPageRoute(builder: (context) => WebViewContainer('https://google.com')));
},
icon: Icon(_icon, color: Colors.white, size: 30.0,),
label: Text(_text, style: TextStyle(color: Colors.white, fontSize: 20), textAlign: TextAlign.left),
color: Colors.deepPurple,
);
}
The pubspec.yaml file:
# 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
webview_flutter: ^0.3.3
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
assets:
- images/casados.jpg
- images/noivos.jpg
The Flutter doctor results:
C:\flutter\bin\flutter.bat doctor --verbose
[√] Flutter (Channel beta, v1.17.0, on Microsoft Windows [versão 10.0.18362.836], locale pt-BR)
• Flutter version 1.17.0 at C:\flutter
• Framework revision e6b34c2b5c (4 weeks ago), 2020-05-02 11:39:18 -0700
• Engine revision 540786dd51
• Dart version 2.8.1
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.0-rc4)
• Android SDK at C:\Users\feps\AppData\Local\Android\sdk
• Platform android-29, build-tools 30.0.0-rc4
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.
[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 45.1.1
• Dart plugin version 192.7761
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
[√] VS Code, 64-bit edition (version 1.24.0)
• VS Code at C:\Program Files\Microsoft VS Code
• Flutter extension version 2.21.1
[√] Connected device (1 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• No issues found!
Process finished with exit code 0
I've got no idea about the cause of the issue...
(I'm new in Flutter or Apps development)