I'm new to flutter and I made my main.dart route to my splashscreen. In my main.dart, it accepted the name splashscreen() but in my splashscreen.dart it kept flagging the error "Name types using UpperCamelCase" when I named my class splashscreen.
Here is my main.dart
import 'package:flutter/material.dart';
import 'Routes/splashscreen.dart';
void main (){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
MyApp ({Key? key}) : super(key: key)
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: "DoyarPay",
home: splashscreen(),
);
}
}
Here is my splashscreen.dart
import 'package:flutter/material.dart';
class splashscreen extends StatefulWidget {
const splashscreen({ Key? key }) : super(key: key);
@override
_splashscreenState createState() => _splashscreenState();
}
class _splashscreenState extends State<splashscreen> {
@override
Widget build(BuildContext context) {
return Container(
);
}
}
On the splashscreen.dart it gives the "Name types using UpperCamelCase" error. Can anyone help me out on this. Thanks
It is "accepted" but the warning indicates that you should follow some specific naming conventions. You should definetely check here which has more details about Effective Dart.
For class name in dart, suggest using CamelCase means it will start with an uppercase letter and the next word's 1st letter will be uppercase as well.
In your case splashscreen which starts with s which is lowercase. Appropriate will be SplashScreen.
For file name, we use snake_case. In this case splashscreen.dart will be splash_screen.dart
Learn more about
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With