0

I am a student of flutter and wants to know the difference between simple variable\Class and the variable\class starts with _ this key ?

import 'package:flutter/material.dart';
import 'package:flutter/foundation.dart';

    void main() {
        runApp(AnimatedList());
     }

    class AnimatedList extends StatefulWidget {
        @override
       _AnimatedListState createState() => _AnimatedListState();   
     }

    class _AnimatedListState extends State<AnimatedList> {
        final GlobalKey<AnimatedListState> _listKey = 
        GlobalKey<AnimatedListState>();
        ListModel<int> _list;
            int _selectedItem;
            int _nextItem;
  • Possible duplicate of [What does Underscore "\_" before variable name mean for Flutter](https://stackoverflow.com/questions/53142171/what-does-underscore-before-variable-name-mean-for-flutter) – deHaar Jul 07 '19 at 11:58

1 Answers1

0

Variables that has an underscore as a prefix is indicating that the variable is private for the class. Source

flarkmarup
  • 5,129
  • 3
  • 24
  • 25
  • Thanks man, can you please tell where we have to use comma , and where we use semicolon ; at the end of statement and where we don't need both of them ? – Faizan Bashir Jul 07 '19 at 13:32
  • I think you are better of looking at the [language samples](https://dart.dev/samples) to understand Dart :) – flarkmarup Jul 07 '19 at 18:47