Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Flutter UpperCamelCase

Tags:

flutter

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

like image 752
Salem Avatar asked May 12 '26 02:05

Salem


2 Answers

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.

like image 175
esentis Avatar answered May 19 '26 03:05

esentis


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

  • effective-dart
  • Camel case vs. snake case
like image 42
Yeasin Sheikh Avatar answered May 19 '26 05:05

Yeasin Sheikh



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!