How to create an empty list in Dart

前端 未结 1 613
逝去的感伤
逝去的感伤 2021-01-17 07:13

I want to create an empty list for a Flutter project.

final prefs = await SharedPreferences.getInstance();
final myStringList = prefs.getStringList(\'my_stri         


        
相关标签:
1条回答
  • 2021-01-17 07:53

    There are a few ways to create an empty list in Dart:

    []
    List()
    <String>[]
    List<String>()
    

    However, the Effective Dart Usage Guide recommends this:

    []
    

    Or if you need to specify the type, then this:

    <String>[]
    
    0 讨论(0)
提交回复
热议问题