Params:
{
"textDocument": {
"uri": "file:///home/itome/Projects/animated_list_sample/lib/main.dart",
"languageId": null,
"version": 8,
"text": "// Copyright 2017 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport 'package:flutter/foundation.dart';\nimport 'package:flutter/material.dart';\n\nclass AnimatedListSample extends StatefulWidget {\n @override\n _AnimatedListSampleState createState() => _AnimatedListSampleState();\n}\n\nclass _AnimatedListSampleState extends State {\n final GlobalKey _listKey = GlobalKey();\n ListModel _list;\n int _selectedItem;\n int _nextItem; // The next item inserted when the user presses the '+' button.\n\n @override\n void initState() {\n super.initState();\n _list = ListModel(\n listKey: _listKey,\n initialItems: [0, 1, 2],\n removedItemBuilder: _buildRemovedItem,\n );\n _nextItem = 3;\n }\n\n // Used to build list items that haven't been removed.\n Widget _buildItem(\n BuildContext context, int index, Animation animation) {\n return CardItem(\n animation: animation,\n item: _list[index],\n selected: _selectedItem == _list[index],\n onTap: () {\n setState(() {\n _selectedItem = _selectedItem == _list[index] ? null : _list[index];\n });\n }\n );\n }\n\n // Used to build an item after it has been removed from the list. This method is\n // needed because a removed item remains visible until its animation has\n // completed (even though it's gone as far this ListModel is concerned).\n // The widget will be used by the [AnimatedListState.removeItem] method's\n // [AnimatedListRemovedItemBuilder] parameter.\n Widget _buildRemovedItem(\n int item, BuildContext context, Animation animation) {\n return CardItem(\n animation: animation,\n item: item,\n selected: false,\n // No gesture detector here: we don't want removed items to be interactive.\n );\n }\n\n // Insert the \"next item\" into the list model.\n void _insert() {\n final int index =\n _selectedItem == null ? _list.length : _list.indexOf(_selectedItem);\n _list.insert(index, _nextItem++);\n }\n\n void _remove() {\n if (_selectedItem != null) {\n _list.removeAt(_list.indexOf(_selectedItem));\n setState(() {\n _selectedItem = null;\n });\n }\n }\n\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home: Scaffold(\n appBar: AppBar(\n title: const Text('AnimatedList'),\n actions: [\n IconButton(\n icon: const Icon(Icons.add_circle),\n onPressed: _insert,\n tooltip: 'insert a new item',\n ),\n IconButton(\n icon: const Icon(Icons.remove_circle),\n onPressed: _remove,\n tooltip: 'remove the selected item',\n\n\n ),\n ],\n ),\n body: Padding(\n padding: const EdgeInsets.all(16.0),\n child: AnimatedList(\n key: _listKey,\n initialItemCount: _list.length,\n itemBuilder: _buildItem,\n ),\n ),\n ),\n );\n }\n}\n\n/// Keeps a Dart List in sync with an AnimatedList.\n///\n/// The [insert] and [removeAt] methods apply to both the internal list and the\n/// animated list that belongs to [listKey].\n///\n/// This class only exposes as much of the Dart List API as is needed by the\n/// sample app. More list methods are easily added, however methods that mutate the\n/// list must make the same changes to the animated list in terms of\n/// [AnimatedListState.insertItem] and [AnimatedList.removeItem].\nclass ListModel {\n ListModel({\n @required this.listKey,\n @required this.removedItemBuilder,\n Iterable initialItems,\n }) : assert(listKey != null),\n assert(removedItemBuilder != null),\n _items = List.from(initialItems ?? []);\n\n final GlobalKey listKey;\n final dynamic removedItemBuilder;\n final List _items;\n\n AnimatedListState get _animatedList => listKey.currentState;\n\n void insert(int index, E item) {\n _items.insert(index, item);\n _animatedList.insertItem(index);\n }\n\n E removeAt(int index) {\n final E removedItem = _items.removeAt(index);\n if (removedItem != null) {\n _animatedList.removeItem(index,\n (BuildContext context, Animation animation) {\n return removedItemBuilder(removedItem, context, animation);\n });\n }\n return removedItem;\n }\n\n int get length => _items.length;\n\n E operator [](int index) => _items[index];\n\n int indexOf(E item) => _items.indexOf(item);\n}\n\n/// Displays its integer item as 'item N' on a Card whose color is based on\n/// the item's value. The text is displayed in bright green if selected is true.\n/// This widget's height is based on the animation parameter, it varies\n/// from 0 to 128 as the animation varies from 0.0 to 1.0.\nclass CardItem extends StatelessWidget {\n const CardItem(\n {Key key,\n @required this.animation,\n this.onTap,\n @required this.item,\n this.selected: false})\n : assert(animation != null),\n assert(item != null && item >= 0),\n assert(selected != null),\n super(key: key);\n\n final Animation animation;\n final VoidCallback onTap;\n final int item;\n final bool selected;\n\n @override\n Widget build(BuildContext context) {\n TextStyle textStyle = Theme.of(context).textTheme.display1;\n if (selected)\n textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]);\n return Padding(\n padding: const EdgeInsets.all(2.0),\n child: SizeTransition(\n axis: Axis.vertical,\n sizeFactor: animation,\n child: GestureDetector(\n behavior: HitTestBehavior.opaque,\n onTap: onTap,\n child: SizedBox(\n height: 128.0,\n child: Card(\n color: Colors.primaries[item % Colors.primaries.length],\n child: Center(\n child: Text('Item $item', style: textStyle),\n ),\n ),\n ),\n ),\n ),\n );\n }\n}\n\nvoid main() {\n runApp(AnimatedListSample());\n}\n"
}
}
- Response
Received notification 'window/showMessage'.
Params:
{
"message": "Invalid params for textDocument/didOpen",
"type": 1
}
"Invalid params for textDocument/didOpen" sended.
Params: { "textDocument": { "uri": "file:///home/itome/Projects/animated_list_sample/lib/main.dart", "languageId": null, "version": 8, "text": "// Copyright 2017 The Chromium Authors. All rights reserved.\n// Use of this source code is governed by a BSD-style license that can be\n// found in the LICENSE file.\n\nimport 'package:flutter/foundation.dart';\nimport 'package:flutter/material.dart';\n\nclass AnimatedListSample extends StatefulWidget {\n @override\n _AnimatedListSampleState createState() => _AnimatedListSampleState();\n}\n\nclass _AnimatedListSampleState extends State {\n final GlobalKey _listKey = GlobalKey();\n ListModel _list;\n int _selectedItem;\n int _nextItem; // The next item inserted when the user presses the '+' button.\n\n @override\n void initState() {\n super.initState();\n _list = ListModel(\n listKey: _listKey,\n initialItems: [0, 1, 2],\n removedItemBuilder: _buildRemovedItem,\n );\n _nextItem = 3;\n }\n\n // Used to build list items that haven't been removed.\n Widget _buildItem(\n BuildContext context, int index, Animation animation) {\n return CardItem(\n animation: animation,\n item: _list[index],\n selected: _selectedItem == _list[index],\n onTap: () {\n setState(() {\n _selectedItem = _selectedItem == _list[index] ? null : _list[index];\n });\n }\n );\n }\n\n // Used to build an item after it has been removed from the list. This method is\n // needed because a removed item remains visible until its animation has\n // completed (even though it's gone as far this ListModel is concerned).\n // The widget will be used by the [AnimatedListState.removeItem] method's\n // [AnimatedListRemovedItemBuilder] parameter.\n Widget _buildRemovedItem(\n int item, BuildContext context, Animation animation) {\n return CardItem(\n animation: animation,\n item: item,\n selected: false,\n // No gesture detector here: we don't want removed items to be interactive.\n );\n }\n\n // Insert the \"next item\" into the list model.\n void _insert() {\n final int index =\n _selectedItem == null ? _list.length : _list.indexOf(_selectedItem);\n _list.insert(index, _nextItem++);\n }\n\n void _remove() {\n if (_selectedItem != null) {\n _list.removeAt(_list.indexOf(_selectedItem));\n setState(() {\n _selectedItem = null;\n });\n }\n }\n\n @override\n Widget build(BuildContext context) {\n return MaterialApp(\n home: Scaffold(\n appBar: AppBar(\n title: const Text('AnimatedList'),\n actions: [\n IconButton(\n icon: const Icon(Icons.add_circle),\n onPressed: _insert,\n tooltip: 'insert a new item',\n ),\n IconButton(\n icon: const Icon(Icons.remove_circle),\n onPressed: _remove,\n tooltip: 'remove the selected item',\n\n\n ),\n ],\n ),\n body: Padding(\n padding: const EdgeInsets.all(16.0),\n child: AnimatedList(\n key: _listKey,\n initialItemCount: _list.length,\n itemBuilder: _buildItem,\n ),\n ),\n ),\n );\n }\n}\n\n/// Keeps a Dart List in sync with an AnimatedList.\n///\n/// The [insert] and [removeAt] methods apply to both the internal list and the\n/// animated list that belongs to [listKey].\n///\n/// This class only exposes as much of the Dart List API as is needed by the\n/// sample app. More list methods are easily added, however methods that mutate the\n/// list must make the same changes to the animated list in terms of\n/// [AnimatedListState.insertItem] and [AnimatedList.removeItem].\nclass ListModel {\n ListModel({\n @required this.listKey,\n @required this.removedItemBuilder,\n Iterable initialItems,\n }) : assert(listKey != null),\n assert(removedItemBuilder != null),\n _items = List.from(initialItems ?? []);\n\n final GlobalKey listKey;\n final dynamic removedItemBuilder;\n final List _items;\n\n AnimatedListState get _animatedList => listKey.currentState;\n\n void insert(int index, E item) {\n _items.insert(index, item);\n _animatedList.insertItem(index);\n }\n\n E removeAt(int index) {\n final E removedItem = _items.removeAt(index);\n if (removedItem != null) {\n _animatedList.removeItem(index,\n (BuildContext context, Animation animation) {\n return removedItemBuilder(removedItem, context, animation);\n });\n }\n return removedItem;\n }\n\n int get length => _items.length;\n\n E operator [](int index) => _items[index];\n\n int indexOf(E item) => _items.indexOf(item);\n}\n\n/// Displays its integer item as 'item N' on a Card whose color is based on\n/// the item's value. The text is displayed in bright green if selected is true.\n/// This widget's height is based on the animation parameter, it varies\n/// from 0 to 128 as the animation varies from 0.0 to 1.0.\nclass CardItem extends StatelessWidget {\n const CardItem(\n {Key key,\n @required this.animation,\n this.onTap,\n @required this.item,\n this.selected: false})\n : assert(animation != null),\n assert(item != null && item >= 0),\n assert(selected != null),\n super(key: key);\n\n final Animation animation;\n final VoidCallback onTap;\n final int item;\n final bool selected;\n\n @override\n Widget build(BuildContext context) {\n TextStyle textStyle = Theme.of(context).textTheme.display1;\n if (selected)\n textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]);\n return Padding(\n padding: const EdgeInsets.all(2.0),\n child: SizeTransition(\n axis: Axis.vertical,\n sizeFactor: animation,\n child: GestureDetector(\n behavior: HitTestBehavior.opaque,\n onTap: onTap,\n child: SizedBox(\n height: 128.0,\n child: Card(\n color: Colors.primaries[item % Colors.primaries.length],\n child: Center(\n child: Text('Item $item', style: textStyle),\n ),\n ),\n ),\n ),\n ),\n );\n }\n}\n\nvoid main() {\n runApp(AnimatedListSample());\n}\n"
}
}
Received notification 'window/showMessage'.
Params: { "message": "Invalid params for textDocument/didOpen", "type": 1 }