GOOGLE ADS

Montag, 18. April 2022

Importpakete funktionieren nicht/rote Unterstreichung. (Flattern) (Pfeil)

Ich versuche, einige Pakete zu verwenden, und aus irgendeinem Grund funktionieren sie nicht / Ich erhalte eine rote Unterstreichung bei jedem von ihnen. Irgendeine Antwort darauf, warum dies passieren könnte? und wenn es eine Lösung gibt, die bereitgestellt werden könnte, wäre das sehr zu schätzen! Ich bin neu in all dem und lerne noch!

Für diesen Codesatz wären die unterstrichenen das Logger-Paket, das Dio-Paket und das Einheiten-Paket.

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:url_launcher/url_launcher.dart';
import 'package:simple_gradient_text/simple_gradient_text.dart';
import '../utils/dreams_utils.dart';
class ResourcesPage extends StatefulWidget{
@override
_ResourcesPageState createState() => _ResourcesPageState();
}
class _ResourcesPageState extends State<ResourcesPage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: GradientText('Sleep Resources',
style: TextStyle(fontSize: 30.0,),
colors: [colorStyle("gradient1"), colorStyle("gradient2"),
colorStyle("gradient3"), colorStyle("gradient2"),
colorStyle("gradient1")]
),
backgroundColor: colorStyle("appHeader"),
),
backgroundColor: colorStyle("appBackground"),
resizeToAvoidBottomInset: true,
body: Center(
child: ListView(
shrinkWrap: true,
children: <Widget>[
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/SleepF.jpeg",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('Sleep Foundation',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://www.sleepfoundation.org/sleep-hygiene/healthy-sleep-tips')
),
),
Text('We work hard to bring you the most accurate and up-to-date information about different sleep health topics. Rest assured every Sleep Foundation guide is carefully vetted and fact-checked prior to publication.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/IFFA.png",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('International Functional Foods Association',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://iffassociation.org/learn/how-functional-foods-may-improve-sleep-and-immune-health?gclid=Cj0KCQiAys2MBhDOARIsAFf1D1eHFvfuovsyweVETX8I5DOztdqM_QmIN_1DjOtkDNOiKlHIn9RN1bAaAhsLEALw_wcB')
),
),
Text('We exist to ensure everyone, everywhere has an equal chance to take control of their own health and wellness. Functional foods are an important component of healthy, nutritious diets. A diet rich in functional foods promotes a healthy body, as well as a healthy mind.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/Kaiser.png",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('Kaiser Permanente',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://healthengagement.kaiserpermanente.org/wellness-topics/sleep/')
),
),
Text('We help people reach their health goals, by listening, supporting and guiding, so they can live their best lives.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/JHM.jpeg",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('John Hopkins Medical',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://www.hopkinsmedicine.org/health/wellness-and-prevention/sleep')
),
),
Text('At Johns Hopkins Medicine, your health and safety are our very highest priorities. We are ready to care for you and your family in our hospitals, surgery centers, and through in-person clinic and online video visits. Learn how we are keeping you safe and protected so that you can get the care you need.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/BMI.png",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('Beautiful Mind International',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://beauty-mind.org/sleep-guru/?gclid=Cj0KCQiAys2MBhDOARIsAFf1D1czPDb4ROkA_dhket7YAZrPB9H7AK4OqEclcbTaiU_OgDq9odhQ7x8aAhz7EALw_wcB')
),
),
Text('Beautiful Mind International project aims to educate people what is mental health, its issues, and ways to overcome them.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/CDC.png",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('Centers for Disease Control and Prevention',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://www.cdc.gov/sleep/index.html')
),
),
Text('The Centers for Disease Control and Prevention is the national public health agency of the United States.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/sleepnum1.jpeg",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('Sleep Number',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://www.sleepnumber.com/categories/beds-on-sale?acid=psnonbrand&ascid=Google%2BNational-_-google-_-NB_Number_Bed-_-Number_Bed_Exact-_-516451220073-_-b-_-kwd-846217698-_-mediacode-_-Beds-_-1&key=number%20beds&s_kwcid=AL!6200!3!516451220073!b!!g!!number%20beds&k_clickid=go_cmp-193921164_adg-14393203044_ad-516451220073_kwd-846217698_dev-c_ext-_prd-&gclid=Cj0KCQiAys2MBhDOARIsAFf1D1d4C7oDgf9l_gikrEEVbK2Y7EpcHjg8AvPAmFGam3Qgjgc-XknDyYYaAtNfEALw_wcB')
),
),
Text('Sleep Number is an American manufacturer that makes the Sleep Number and Comfortaire beds, as well as foundations and bedding accessories. The company is based in Minneapolis, Minnesota. In addition to its Minnesota headquarters, Sleep Number has manufacturing and distribution facilities in South Carolina and Utah.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
new Container(
margin: EdgeInsets.all(30.0),
child: new Card(
color: Colors.transparent,
elevation: 400.0,
child: new Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
new Image.asset("assets/images/sunset.jpeg",
height: 400,
width: 400,
fit: BoxFit.fill,
),
Padding(
padding: const EdgeInsets.all(8.0),
child: new InkWell(
child: new Text('UMN Duluth Health Services',
style: TextStyle(
color: colorStyle("main"),
fontWeight: FontWeight.bold,
fontSize: 20.0),
),
onTap: () => launch('https://health-services.d.umn.edu/health-education/sleep-education-initiatives')
),
),
Text('Health Education Staff, Interns, and our previous student health advisory committee developed and administered an informal needs assessment to measure student reported barriers to sleep and methods for sleep support that students would use. We learned a lot and are putting that information into practice with a series of initiatives on campus.',
style: TextStyle(
color: colorStyle("main"),
fontSize: 15.0),
),
],
),
),
),
],
),
),
);
}
}

Bei diesem Codesatz sind die rot unterstrichenen Pakete das Units-Paket, das Dio-Paket und das Logger-Paket.

import 'package:flutter/material.dart';
import 'package:units/dreams/utils/dreams_constant.dart';
import 'dart:math';
import 'package:shared_preferences/shared_preferences.dart';
import 'dart:async';
import 'package:flutter/material.dart';
import 'package:logger/logger.dart';
import 'package:dio/dio.dart';
import "package:units/api.dart";
List<dynamic> calculator(double hour, double minute, double sleepHour, double
sleepMinute,
UnitType uniType, UnitType unitTypeTime) {
List result = new List.filled(3, null, growable: false);
double tempHour = 0.0;
double tempMinute = 0.00;
if(uniType == UnitType.BED) {
tempHour = hour + sleepHour;
tempMinute = minute + sleepMinute;
if (tempMinute >= 60) {
tempMinute -= 60;
tempHour += 1;
}
}
if (uniType == UnitType.WAKE) {
tempHour = hour - sleepHour;
tempMinute = minute - sleepMinute;
if(tempMinute < 0){
tempMinute += 60.00;
tempHour -= 1;
}
}
if(tempHour > 12 || tempHour < 0) {
switch(unitTypeTime) {
case UnitType.AM: { unitTypeTime = UnitType.PM; }
break;
case UnitType.PM: { unitTypeTime = UnitType.AM; }
break;
default: {}
break;
}
tempHour %= 12;
}
if(tempHour ==0){
tempHour = 12;
}
//result = tempHour + (tempMinute/100);
result[0] = (tempHour + (tempMinute/100));
result[1] = unitTypeTime;
result[2] = uniType;
return result;
}
bool isEmptyString(String string){
return string == null || string.length == 0;
}
Future<int> loadValue() async{
SharedPreferences preferences = await SharedPreferences.getInstance();
int? data = preferences.getInt('data');
if( data!= null ) {
return data;
} else {
return 0;
}
}
void saveValue(int value) async{
SharedPreferences preferences = await SharedPreferences.getInstance();
preferences.setInt('data', value);
}
void setThemeKey(int color) async {
SharedPreferences prefs = await SharedPreferences.getInstance();
prefs.setInt('theme', color);
}
Future<int?> getThemeKey() async {
SharedPreferences prefs = await SharedPreferences.getInstance();
final color = prefs.getInt('theme');
return color;
}
void setTheme(int theme){
switch(theme) {
case 1: { defaultTheme(); }
break;
case 2: { monochromeTheme(); }
break;
case 3: { pinkTheme(); }
break;
case 4: { sherbetTheme(); }
break;
case 5: { thunderTheme(); }
break;
case 6: { redTheme(); }
break;
case 7: { transTheme(); }
break;
case 8: { enbyTheme(); }
break;
default: { defaultTheme(); }
break;
}
}
Color mains = Colors.white60;
Color accent = Colors.cyan;
Color widgets = Colors.blueGrey.shade700;
Color gradient1 = Colors.cyan.shade900;
Color gradient2 = Colors.cyan.shade700;
Color gradient3 = Colors.cyan.shade500;
Color appHeader = Colors.blueGrey.shade900;
Color appBackground = Colors.blueGrey.shade800;
Future<int> defaultTheme() async {
mains = Colors.white60;
accent = Colors.cyan;
widgets = Colors.blueGrey.shade700;
gradient1 = Colors.cyan.shade900;
gradient2 = Colors.cyan.shade700;
gradient3 = Colors.cyan.shade500;
appHeader = Colors.blueGrey.shade900;
appBackground = Colors.blueGrey.shade800;
return 1;
}
Future<int> monochromeTheme() async {
mains = Colors.black;
accent = Colors.grey.shade700;
widgets = Colors.grey;
gradient1 = Colors.grey.shade700;
gradient2 = Colors.grey.shade500;
gradient3 = Colors.grey.shade300;
appHeader = Colors.grey.shade900;
appBackground = Colors.grey.shade800;
return 1;
}
Future<int> pinkTheme() async {
mains = Colors.pink.shade500;
accent = Colors.pink;
widgets = Colors.pink.shade200;
gradient1 = Colors.pinkAccent.shade700;
gradient2 = Colors.pinkAccent.shade400;
gradient3 = Colors.pinkAccent;
appHeader = Colors.pink.shade900;
appBackground = Colors.pink.shade800;
return 1;
}
Future<int> sherbetTheme() async {
mains = Colors.deepOrange;
accent = Colors.green.shade300;
widgets = Colors.yellow.shade100;
gradient1 = Colors.purpleAccent.shade400;
gradient2 = Colors.orangeAccent.shade100;
gradient3 = Colors.cyanAccent;
appHeader = Colors.pink.shade300;
appBackground = Colors.pink.shade100;
return 1;
}
Future<int> thunderTheme() async {
mains = Colors.yellow;
accent = Colors.yellowAccent;
widgets = Colors.grey.shade700;
gradient1 = Colors.cyan.shade500;
gradient2 = Colors.yellow.shade700;
gradient3 = Colors.yellow.shade200;
appHeader = Colors.grey.shade900;
appBackground = Colors.grey.shade800;
return 1;
}
Future<int> redTheme() async {
mains = Colors.red.shade900;
accent = Colors.red.shade900;
widgets = Colors.white70;
gradient1 = Colors.red.shade900;
gradient2 = Colors.red.shade700;
gradient3 = Colors.red.shade500;
appHeader = Colors.grey.shade500;
appBackground = Colors.grey.shade200;
return 1;
}
Future<int> transTheme() async {
mains = Colors.blue;
accent = Colors.pink;
widgets = Colors.white70;
gradient1 = Colors.lightBlue.shade200;
gradient2 = Colors.pinkAccent.shade100;
gradient3 = Colors.white;
appHeader = Colors.blue.shade800;
appBackground = Colors.pinkAccent.shade100;
return 1;
}
Future<int> enbyTheme() async {
mains = Colors.black;
accent = Colors.yellow.shade700;
widgets = Colors.white;
gradient1 = Colors.black;
gradient2 = Colors.yellow;
gradient3 = Colors.white;
appHeader = Colors.purple;
appBackground = Colors.purple.shade200;
return 1;
}
Color colorStyle(String color){
switch(color){
case "main":
return mains;
case "accent":
return accent;
case "widgets":
return widgets;
case "gradient1":
return gradient1;
case "gradient2":
return gradient2;
case "gradient3":
return gradient3;
case "appHeader":
return appHeader;
case "appBackground":
return appBackground;
default:
return Colors.purpleAccent;
}
}

Dies ist der Fehlercode, den ich bekomme

Ungültiges Depfile: C:\Users\Mahjur - Coding\Desktop\SweetDreams-X.2.dart_tool\flutter_build\e98d11342ddd14555bbca12c2fd83e4a\kernel_snapshot.d Ungültiges Depfile: C:\Users\Mahjur - Coding\Desktop\SweetDreams-X.2.dart_tool \flutter_build\e98d11342ddd14555bbca12c2fd83e4a\kernel_snapshot.d Fehler: Das Paket „logger" in „package:logger/logger.dart" konnte nicht aufgelöst werden. Fehler: Das Paket „dio" in „package:dio/dio.dart" konnte nicht aufgelöst werden. lib/dreams/utils/dreams_utils.dart:7:8: Fehler: Nicht gefunden: 'package:logger/logger.dart' import 'package:logger/logger.dart'; ^ lib/dreams/utils/dreams_utils.dart:8:8: Fehler: Nicht gefunden: 'package:dio/dio.dart' import 'package:dio/dio.dart'; ^ lib/dreams/utils/dreams_utils.dart:9:8: Fehler: Fehler beim Lesen von 'lib/api.dart':

import "Paket:Einheiten/api.dart"; ^


Lösung des Problems

in der Kommandozeile ausführen

flutter clean

dann

flutter pub get

Wenn das nicht hilft, beenden und starten Sie Android Studio und die Datei neu.

Wenn dies nicht hilft, löschen Sie die Abhängigkeit aus pubspec.yaml, führen Sie pub get aus, fügen Sie die Abhängigkeit erneut hinzu und führen Sie pub get aus. Manchmal müssen Sie Flattern mit einem Hammer über den Kopf schlagen.

Keine Kommentare:

Kommentar veröffentlichen

Warum werden SCHED_FIFO-Threads derselben physischen CPU zugewiesen, obwohl CPUs im Leerlauf verfügbar sind?

Lösung des Problems Wenn ich das richtig verstehe, versuchen Sie, SCHED_FIFO mit aktiviertem Hyperthreading ("HT") zu verwenden, ...