普通变量和以_ this开头的变量有什么区别

时间:2019-07-07 11:33:23

标签: android-studio flutter dart

我是扑扑的学生,想知道简单变量\ Class和变量\ class之间的区别,此键以_开头吗?

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;

1 个答案:

答案 0 :(得分:0)

以下划线作为前缀的变量表示该变量是该类的私有变量。 Source