Skip to content

Long list variable slowing performance #80176

@nausharipov

Description

@nausharipov

When I try to use a list of 14216 maps, this widget freezes for a few seconds during initialization:

class Slow extends StatefulWidget {
  Slow({Key key}) : super(key: key);

  @override
  _SlowState createState() => _SlowState();
}

class _SlowState extends State<Slow> {
List _list = [
  {
    "code": "110000000",
    "region": "11",
    "district": "0",
    "locality_center": "0",
    "locality": "0",
    "ru_name": "Акмолинская область",
    "kk_name": "Ақмола облысы"
  },
// 14215 maps
];

@override
Widget build(BuildContext context) {
    print('it takes a few seconds before this message is printed in terminal');
    print(_list.length);
    return Container();
}
}

Is there a better way of storing and using huge lists in flutter?

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work lista: animationAnimation APIsc: performanceRelates to speed or footprint issues (see "perf:" labels)f: scrollingViewports, list views, slivers, etc.found in release: 2.10Found to occur in 2.10found in release: 2.13Found to occur in 2.13frameworkflutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onteam-frameworkOwned by Framework teamtriaged-frameworkTriaged by Framework team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions