when i use TimeOfDay i get the error undefined class TimeOfDay. it was previously working tho.I am trying to get the time,
TimeOfDay theTime = new TimeOfDay.now();
I don't understand why I get the error.
Maybe you made a mistake and modified the class TimeOfDay inside time.dart, sometimes it happens.
Could you check the source code of the class theTimeTimeOfDay ? because it should not exists.
The class time.dart should start with something like this
#immutable
class TimeOfDay {
I'm 99% sure that you named it like this :
#immutable
class theTimeTimeOfDay {
The class is defined in material.dart (it really is defined in a subfile, but it is part of material.dart).
If the class is undefined for you, you will need to import it:
import 'package:flutter/material.dart';
TimeOfDay getCurrentTime() {
return TimeOfDay.now();
}
Related
I am getting the following error in my Apploader. I don't know from where ConfigurationComponents is getting included in my code.
Error:(63, 7) class AppComponents inherits conflicting members:
method configuration in class BuiltInComponentsFromContext of type => play.api.Configuration and
method configuration in trait ConfigurationComponents of type ()play.api.Configuration
(Note: this can be resolved by declaring an override in class AppComponents.);
other members with override errors are: environment, applicationLifecycle, httpErrorHandler, fileMimeTypes
class AppComponents (context: Context) extends BuiltInComponentsFromContext(context)
Also, I dont understand the statement in the above error other members with override errors are: environment, applicationLifecycle, httpErrorHandler, fileMimeTypes
Snippet of my Apploader.scala code is
class AppComponents (context: Context) extends BuiltInComponentsFromContext(context)
with CassandraRepositoryComponents
with HttpFiltersComponents
with AssetsComponents
with CSRFComponents { ... }
I also notice that the different use of () and => in the statement => play.api.Configuration and method configuration in trait ConfigurationComponents of type ()play.api.Configuration
The issue got resolved when I removed import play.controllers.AssetsComponents. It seems I included this file by mistake which caused conflicts.
I'm a groovy novice, so not sure if this is possible. I need something like an import, but not quite. Here is the simplified code example of what I'm trying to do:
in file FileToProcess.groovy I have
class FileToProcess implements Serializable {
String FileName
FileToProcess(fileName) {
this.FileName = fileName;
}
}
and then in a JenkinsFile I want to do something like
F1 = new FileToProcess('A');
List<FileToProcess> allFiles = new ArrayList<FileToProcess>();
allFiles.add(F1);
for (FileToProcess file : allFiles) {
System.out.println(file.FileName);
}
Now, on StackOverflow I've found examples of how to instantiate a class from another file, for example here or here, and that solves the line
F1 = new FileToProcess('A');
but it does not show how to use that class as a type in a declaration, for example
List<FileToProcess> allFiles = new ArrayList<FileToProcess>();
gives me "unable to resolve class FileToProcess". I also know that using a class as a type like this should work, because it does when I put the class in the same JenkinsFile, so the problem seems to be just that the class is not visible in the JenkinsFile.
Is there a way to do this?
I'm not sure how you tried to setup your class libraries but I attempted the same while using a class from a pipeline shared library and it worked as intended
https://jenkins.io/doc/book/pipeline/shared-libraries/
I did do it a little differently:
assuming you places the file under src/org/Foo.groovy
import org.Foo
def list = new ArrayList<Foo>
list.add(new Foo('str1'))
list.add(new Foo('str2'))
I am trying to use a NumericProperty but getting Type errors when trying to use it as a value
My code looks like this
from kivy.properties import NumericProperty
from kivy.uix.widget import Widget
class Segment(Widget):
def __init__(self, segments):
super(Segment, self).__init__()
self.segments = NumericPropery(segments)
def build(self):
for i in range(0, self.segments):
# Do something
I get an error :
for i in range(0, self.segments):
TypeError: range() integer end argument expected, got kivy.properties.NumericProperty.
so I tried using self.segments.get() instead, but then I got this error
TypeError: get() takes exactly one argument (0 given)
apperently the get function expects <kivy._event.EventDispatcher> object argument
Any idea how to get around this?
I had a similar problem with this code ...
class GameModel(object):
some_number = NumericProperty(1)
def __init__(self):
self.some_number = 2
... which raised the error:
TypeError: Argument 'obj' has incorrect type (expected kivy._event.EventDispatcher, got GameModel)
I did declare the property at class level though. In my case the problem was that the class itself was not derived from a Kivy Widget class or - as stated in the error message - from an EventDispatcher Object
Deriving from EventDispatcher fixed my problem:
class GameModel(EventDispatcher):
Hope this is helpful for someone else some day ;-)
You have to declare properties at class level.
class Segment(Widget):
segments = NumericProperty()
This will give the correct behaviour. The problem is that properties do their own management of per-instance values and interacting with the eventloop etc.. If you don't declare them at class level, they don't get to do this, so your functions only see the NumericProperty itself (which is your problem).
Shown below is a sample code.
Assume that "hi" and "hello" are complex objects and have to be evaluated inside the method.
The code below gives me:
Process finished with exit code -1
Expected result is an "Unrolled" explanation of what passed and failed.
Code:
import spock.lang.Shared
import spock.lang.Specification
import spock.lang.Unroll
#Unroll
class DataTableTest extends Specification {
def "#actual should equal #expected"() {
#Shared def hi = "hi"
#Shared def hello = "hello"
expect:
actual == expected
where:
actual | expected
hi | hi
hi | hello
}
}
I dont think you can even define Shared vars inside a method as their purpose is to be reusable in other methods as they are high-cost calculated variables. Try to set up the shared variables in the class scope.
Is there a way to do something akin to import <BLAH> as in actionscript? I've got some classes that I don't want to type the full class name out for every time I use them. That's why I'm trying to find an import as, or var C = ImportedClassThatIDontWantToTypeEveryTime. I've tried a few different ways, such as:
package com.mysite.blah {
// doesn't work
import com.mysite.ImportedClassThatIDontWantToTypeEveryTime as C;
// also doesn't work
import com.mysite.ImportedClassThatIDontWantToTypeEveryTime;
var C:Class = ImportedClassThatIDontWantToTypeEveryTime;
// ????
public class SomeOtherClass {
public function blah():void {
C.doSomething();
}
}
}
I know there is a way to do this - I've done it before years ago. However, I can't remember how to do it. Help?
What IDE are you using? I ask this because I haven't had to type out a class-path in full in years. The auto-complete features of both FlashDevelop and FlashBuilder will allow you to type the first couple of letters of the class you want in place, select it from a list, and it will automatically add the appropriate import statement to the top of your class.