From d927c9331005f81157fa39dff7b5dab415ad330b Mon Sep 17 00:00:00 2001 From: Alexandre Ardhuin Date: Wed, 12 Sep 2018 08:29:29 +0200 Subject: [PATCH] Unnecessary new (#20138) * enable lint unnecessary_new * fix tests * fix tests * fix tests --- analysis_options.yaml | 2 +- .../exception_handling_expectation.txt | 2 +- .../flutter_test/exception_handling_test.dart | 4 +- .../test_async_utils_guarded_test.dart | 4 +- .../test_async_utils_unguarded_test.dart | 2 +- .../flutter_test/ticker_test.dart | 2 +- .../test_smoke_test/timeout_fail_test.dart | 2 +- .../test_smoke_test/timeout_pass_test.dart | 2 +- dev/benchmarks/complex_layout/lib/main.dart | 252 ++++----- .../test_driver/scroll_perf_test.dart | 8 +- .../test_driver/semantics_perf_test.dart | 4 +- .../test_memory/scroll_perf.dart | 22 +- .../microbenchmarks/lib/common.dart | 4 +- .../lib/gestures/velocity_tracker_bench.dart | 6 +- .../lib/stocks/animation_bench.dart | 8 +- .../lib/stocks/build_bench.dart | 6 +- .../lib/stocks/layout_bench.dart | 10 +- dev/bots/analyze-sample-code.dart | 32 +- dev/bots/analyze.dart | 36 +- dev/bots/prepare_package.dart | 52 +- dev/bots/run_command.dart | 4 +- dev/bots/test.dart | 10 +- dev/bots/test/analyze-sample-code_test.dart | 4 +- dev/bots/test/common.dart | 2 +- dev/bots/test/fake_process_manager.dart | 22 +- dev/bots/test/fake_process_manager_test.dart | 18 +- dev/bots/test/prepare_package_test.dart | 46 +- dev/devicelab/bin/run.dart | 4 +- dev/devicelab/bin/tasks/commands_test.dart | 10 +- .../complex_layout_scroll_perf__memory.dart | 2 +- .../tasks/complex_layout_semantics_perf.dart | 2 +- dev/devicelab/bin/tasks/dartdocs.dart | 10 +- .../bin/tasks/flutter_attach_test.dart | 18 +- .../flutter_gallery__back_button_memory.dart | 6 +- .../tasks/flutter_gallery__memory_nav.dart | 2 +- ...llery__transition_perf_with_semantics.dart | 2 +- .../flutter_gallery_instrumentation_test.dart | 2 +- .../bin/tasks/flutter_test_performance.dart | 14 +- .../bin/tasks/gradle_plugin_test.dart | 32 +- .../bin/tasks/hello_world__memory.dart | 6 +- dev/devicelab/bin/tasks/module_test.dart | 46 +- dev/devicelab/bin/tasks/plugin_test.dart | 4 +- dev/devicelab/bin/tasks/plugin_test_ios.dart | 4 +- dev/devicelab/bin/tasks/plugin_test_win.dart | 4 +- dev/devicelab/bin/tasks/routing_test.dart | 4 +- .../run_machine_concurrent_hot_reload.dart | 10 +- dev/devicelab/bin/tasks/run_release_test.dart | 4 +- .../bin/tasks/service_extensions_test.dart | 6 +- .../bin/tasks/smoke_test_failure.dart | 2 +- .../bin/tasks/smoke_test_success.dart | 2 +- .../bin/tasks/technical_debt__cost.dart | 16 +- dev/devicelab/lib/framework/adb.dart | 42 +- dev/devicelab/lib/framework/framework.dart | 28 +- dev/devicelab/lib/framework/manifest.dart | 10 +- dev/devicelab/lib/framework/runner.dart | 18 +- dev/devicelab/lib/framework/utils.dart | 36 +- dev/devicelab/lib/tasks/analysis.dart | 14 +- dev/devicelab/lib/tasks/gallery.dart | 4 +- dev/devicelab/lib/tasks/hot_mode_tests.dart | 10 +- .../lib/tasks/integration_tests.dart | 16 +- dev/devicelab/lib/tasks/integration_ui.dart | 2 +- dev/devicelab/lib/tasks/microbenchmarks.dart | 8 +- dev/devicelab/lib/tasks/perf_tests.dart | 62 +-- dev/devicelab/lib/tasks/plugin_tests.dart | 14 +- .../lib/tasks/sample_catalog_generator.dart | 2 +- .../lib/tasks/save_catalog_screenshots.dart | 18 +- dev/devicelab/test/adb_test.dart | 8 +- dev/devicelab/test/common.dart | 2 +- dev/devicelab/test/manifest_test.dart | 2 +- dev/devicelab/test/utils_test.dart | 2 +- .../android_semantics_testing/lib/main.dart | 20 +- .../lib/src/common.dart | 6 +- .../lib/src/flutter_test_alternative.dart | 2 +- .../lib/src/matcher.dart | 2 +- .../lib/src/tests/controls_page.dart | 30 +- .../lib/src/tests/text_field_page.dart | 18 +- .../test_driver/main_test.dart | 2 +- .../android_views/lib/main.dart | 62 +-- .../android_views/lib/motion_event_diff.dart | 2 +- .../android_views/test_driver/main_test.dart | 2 +- dev/integration_tests/channels/lib/main.dart | 36 +- .../channels/lib/src/basic_messaging.dart | 4 +- .../channels/lib/src/method_calls.dart | 4 +- .../channels/lib/src/test_step.dart | 22 +- .../external_ui/lib/main.dart | 30 +- .../external_ui/test_driver/main_test.dart | 8 +- dev/integration_tests/flavors/lib/main.dart | 8 +- .../platform_interaction/lib/main.dart | 20 +- .../lib/src/system_navigation.dart | 2 +- .../lib/src/test_step.dart | 10 +- dev/integration_tests/ui/lib/commands.dart | 4 +- dev/integration_tests/ui/lib/driver.dart | 24 +- .../ui/lib/keyboard_resize.dart | 26 +- .../ui/lib/keyboard_textfield.dart | 24 +- dev/integration_tests/ui/lib/screenshot.dart | 32 +- .../ui/test_driver/driver_test.dart | 8 +- .../ui/test_driver/keyboard_resize_test.dart | 4 +- .../test_driver/keyboard_textfield_test.dart | 2 +- dev/manual_tests/lib/animated_icons.dart | 22 +- dev/manual_tests/lib/card_collection.dart | 122 ++--- dev/manual_tests/lib/color_testing_demo.dart | 26 +- dev/manual_tests/lib/drag_and_drop.dart | 96 ++-- dev/manual_tests/lib/material_arc.dart | 108 ++-- dev/manual_tests/lib/overlay_geometry.dart | 62 +-- dev/manual_tests/lib/page_view.dart | 50 +- dev/manual_tests/lib/raw_keyboard.dart | 30 +- dev/manual_tests/lib/text.dart | 300 +++++------ dev/manual_tests/test/mock_image_http.dart | 14 +- .../test/overlay_geometry_test.dart | 2 +- dev/tools/dartdoc.dart | 54 +- dev/tools/gen_date_localizations.dart | 18 +- dev/tools/gen_localizations.dart | 30 +- dev/tools/java_and_objc_doc.dart | 10 +- dev/tools/lib/roll_dev.dart | 4 +- dev/tools/localizations_utils.dart | 8 +- dev/tools/localizations_validator.dart | 16 +- dev/tools/mega_gallery.dart | 22 +- dev/tools/update_icons.dart | 12 +- dev/tools/vitool/bin/main.dart | 10 +- dev/tools/vitool/lib/vitool.dart | 82 +-- dev/tools/vitool/test/vitool_test.dart | 10 +- examples/catalog/bin/sample_page.dart | 28 +- examples/catalog/lib/animated_list.dart | 42 +- examples/catalog/lib/app_bar_bottom.dart | 40 +- examples/catalog/lib/basic_app_bar.dart | 38 +- .../catalog/lib/custom_a11y_traversal.dart | 62 +-- examples/catalog/lib/custom_semantics.dart | 28 +- .../catalog/lib/expansion_tile_sample.dart | 56 +- examples/catalog/lib/tabbed_app_bar.dart | 32 +- .../lib/demo/animation/home.dart | 120 ++--- .../lib/demo/animation/widgets.dart | 56 +- .../lib/demo/calculator/home.dart | 98 ++-- .../lib/demo/calculator/logic.dart | 30 +- .../flutter_gallery/lib/demo/colors_demo.dart | 74 +-- .../lib/demo/contacts_demo.dart | 100 ++-- .../cupertino_activity_indicator_demo.dart | 4 +- .../demo/cupertino/cupertino_alert_demo.dart | 68 +-- .../cupertino/cupertino_buttons_demo.dart | 22 +- .../cupertino/cupertino_navigation_demo.dart | 220 ++++---- .../demo/cupertino/cupertino_picker_demo.dart | 52 +- .../cupertino/cupertino_refresh_demo.dart | 48 +- .../cupertino_segmented_control_demo.dart | 22 +- .../demo/cupertino/cupertino_slider_demo.dart | 22 +- .../demo/cupertino/cupertino_switch_demo.dart | 24 +- .../flutter_gallery/lib/demo/images_demo.dart | 14 +- .../lib/demo/material/backdrop_demo.dart | 94 ++-- .../demo/material/bottom_app_bar_demo.dart | 94 ++-- .../demo/material/bottom_navigation_demo.dart | 56 +- .../lib/demo/material/buttons_demo.dart | 106 ++-- .../lib/demo/material/cards_demo.dart | 60 +-- .../lib/demo/material/chip_demo.dart | 116 ++-- .../lib/demo/material/data_table_demo.dart | 146 ++--- .../material/date_and_time_picker_demo.dart | 60 +-- .../lib/demo/material/dialog_demo.dart | 72 +-- .../lib/demo/material/drawer_demo.dart | 84 +-- .../lib/demo/material/elevation_demo.dart | 18 +- .../demo/material/expansion_panels_demo.dart | 110 ++-- .../material/full_screen_dialog_demo.dart | 98 ++-- .../lib/demo/material/grid_list_demo.dart | 110 ++-- .../lib/demo/material/icons_demo.dart | 38 +- .../lib/demo/material/leave_behind_demo.dart | 62 +-- .../lib/demo/material/list_demo.dart | 78 +-- .../lib/demo/material/menu_demo.dart | 66 +-- .../material/modal_bottom_sheet_demo.dart | 16 +- .../lib/demo/material/overscroll_demo.dart | 30 +- .../lib/demo/material/page_selector_demo.dart | 36 +- .../persistent_bottom_sheet_demo.dart | 30 +- .../material/progress_indicator_demo.dart | 40 +- .../demo/material/reorderable_list_demo.dart | 46 +- .../demo/material/scrollable_tabs_demo.dart | 40 +- .../lib/demo/material/search_demo.dart | 86 +-- .../material/selection_controls_demo.dart | 44 +- .../lib/demo/material/slider_demo.dart | 54 +- .../lib/demo/material/snack_bar_demo.dart | 28 +- .../lib/demo/material/tabs_demo.dart | 58 +- .../lib/demo/material/tabs_fab_demo.dart | 64 +-- .../demo/material/text_form_field_demo.dart | 74 +-- .../lib/demo/material/tooltip_demo.dart | 28 +- .../demo/material/two_level_list_demo.dart | 8 +- .../flutter_gallery/lib/demo/pesto_demo.dart | 206 +++---- .../lib/demo/shrine/shrine_data.dart | 2 +- .../lib/demo/shrine/shrine_home.dart | 130 ++--- .../lib/demo/shrine/shrine_order.dart | 100 ++-- .../lib/demo/shrine/shrine_page.dart | 32 +- .../lib/demo/shrine/shrine_theme.dart | 18 +- .../lib/demo/shrine/shrine_types.dart | 2 +- .../flutter_gallery/lib/demo/shrine_demo.dart | 8 +- .../lib/demo/typography_demo.dart | 42 +- .../flutter_gallery/lib/demo/video_demo.dart | 92 ++-- .../flutter_gallery/lib/gallery/about.dart | 18 +- examples/flutter_gallery/lib/gallery/app.dart | 22 +- .../flutter_gallery/lib/gallery/backdrop.dart | 92 ++-- .../flutter_gallery/lib/gallery/demo.dart | 50 +- .../flutter_gallery/lib/gallery/demos.dart | 180 +++---- .../lib/gallery/example_code.dart | 48 +- .../flutter_gallery/lib/gallery/home.dart | 114 ++-- .../flutter_gallery/lib/gallery/options.dart | 100 ++-- .../lib/gallery/syntax_highlighter.dart | 72 +-- .../flutter_gallery/lib/gallery/themes.dart | 8 +- .../flutter_gallery/lib/gallery/updater.dart | 14 +- .../test/accessibility_test.dart | 132 ++--- .../test/calculator/logic.dart | 12 +- .../test/calculator/smoke_test.dart | 2 +- .../test/demo/material/chip_demo_test.dart | 6 +- .../test/demo/material/drawer_demo_test.dart | 6 +- .../material/text_form_field_demo_test.dart | 2 +- .../flutter_gallery/test/drawer_test.dart | 2 +- .../test/example_code_parser_test.dart | 4 +- .../flutter_gallery/test/live_smoketest.dart | 8 +- examples/flutter_gallery/test/smoke_test.dart | 2 +- .../flutter_gallery/test/update_test.dart | 2 +- .../test_driver/scroll_perf_test.dart | 6 +- .../test_driver/transitions_perf_test.dart | 10 +- .../test_memory/back_button.dart | 4 +- .../test_memory/memory_nav.dart | 16 +- examples/flutter_view/lib/main.dart | 28 +- examples/layers/raw/canvas.dart | 24 +- examples/layers/raw/hello_world.dart | 14 +- examples/layers/raw/spinning_square.dart | 12 +- examples/layers/raw/text.dart | 24 +- examples/layers/raw/touch_input.dart | 10 +- .../rendering/custom_coordinate_systems.dart | 18 +- examples/layers/rendering/flex_layout.dart | 52 +- examples/layers/rendering/hello_world.dart | 6 +- .../layers/rendering/spinning_square.dart | 20 +- .../layers/rendering/src/sector_layout.dart | 54 +- .../layers/rendering/src/solid_color_box.dart | 4 +- examples/layers/rendering/touch_input.dart | 14 +- examples/layers/services/isolate.dart | 40 +- examples/layers/services/lifecycle.dart | 4 +- examples/layers/test/gestures_test.dart | 4 +- examples/layers/test/sector_test.dart | 2 +- .../layers/widgets/custom_render_box.dart | 6 +- examples/layers/widgets/gestures.dart | 50 +- examples/layers/widgets/media_query.dart | 38 +- examples/layers/widgets/sectors.dart | 68 +-- examples/layers/widgets/spinning_mixed.dart | 38 +- examples/layers/widgets/spinning_square.dart | 10 +- examples/layers/widgets/styled_text.dart | 42 +- examples/platform_channel/lib/main.dart | 18 +- examples/platform_channel_swift/lib/main.dart | 18 +- examples/platform_view/lib/main.dart | 36 +- examples/stocks/lib/main.dart | 24 +- examples/stocks/lib/stock_arrow.dart | 12 +- examples/stocks/lib/stock_data.dart | 6 +- examples/stocks/lib/stock_home.dart | 90 ++-- examples/stocks/lib/stock_list.dart | 4 +- examples/stocks/lib/stock_row.dart | 36 +- examples/stocks/lib/stock_settings.dart | 54 +- examples/stocks/lib/stock_strings.dart | 2 +- examples/stocks/lib/stock_symbol_viewer.dart | 56 +- examples/stocks/lib/stock_types.dart | 2 +- examples/stocks/test/icon_color_test.dart | 6 +- .../stocks/test_driver/scroll_perf_test.dart | 6 +- .../src/animation/animation_controller.dart | 20 +- .../flutter/lib/src/animation/animations.dart | 2 +- .../flutter/lib/src/animation/curves.dart | 2 +- .../lib/src/animation/listener_helpers.dart | 12 +- packages/flutter/lib/src/animation/tween.dart | 6 +- .../lib/src/animation/tween_sequence.dart | 4 +- .../lib/src/cupertino/action_sheet.dart | 134 ++--- .../lib/src/cupertino/activity_indicator.dart | 14 +- packages/flutter/lib/src/cupertino/app.dart | 14 +- .../lib/src/cupertino/bottom_tab_bar.dart | 42 +- .../flutter/lib/src/cupertino/button.dart | 30 +- .../lib/src/cupertino/date_picker.dart | 116 ++-- .../flutter/lib/src/cupertino/dialog.dart | 176 +++--- .../lib/src/cupertino/localizations.dart | 2 +- .../flutter/lib/src/cupertino/nav_bar.dart | 302 +++++------ .../lib/src/cupertino/page_scaffold.dart | 18 +- .../flutter/lib/src/cupertino/picker.dart | 40 +- .../flutter/lib/src/cupertino/refresh.dart | 22 +- packages/flutter/lib/src/cupertino/route.dart | 78 +-- .../flutter/lib/src/cupertino/scrollbar.dart | 18 +- .../lib/src/cupertino/segmented_control.dart | 48 +- .../flutter/lib/src/cupertino/slider.dart | 28 +- .../flutter/lib/src/cupertino/switch.dart | 38 +- .../lib/src/cupertino/tab_scaffold.dart | 34 +- .../flutter/lib/src/cupertino/tab_view.dart | 14 +- .../lib/src/cupertino/text_selection.dart | 60 +-- .../lib/src/cupertino/thumb_painter.dart | 8 +- .../lib/src/foundation/assertions.dart | 16 +- .../lib/src/foundation/basic_types.dart | 18 +- .../flutter/lib/src/foundation/binding.dart | 12 +- .../lib/src/foundation/change_notifier.dart | 8 +- .../src/foundation/consolidate_response.dart | 4 +- .../flutter/lib/src/foundation/debug.dart | 4 +- .../lib/src/foundation/diagnostics.dart | 34 +- .../flutter/lib/src/foundation/isolates.dart | 4 +- packages/flutter/lib/src/foundation/key.dart | 2 +- .../flutter/lib/src/foundation/licenses.dart | 2 +- .../lib/src/foundation/observer_list.dart | 2 +- .../flutter/lib/src/foundation/platform.dart | 2 +- .../flutter/lib/src/foundation/print.dart | 12 +- .../lib/src/foundation/serialization.dart | 4 +- .../src/foundation/synchronous_future.dart | 10 +- packages/flutter/lib/src/gestures/arena.dart | 6 +- .../flutter/lib/src/gestures/binding.dart | 14 +- .../flutter/lib/src/gestures/converter.dart | 28 +- packages/flutter/lib/src/gestures/debug.dart | 2 +- .../flutter/lib/src/gestures/hit_test.dart | 2 +- .../flutter/lib/src/gestures/lsq_solver.dart | 18 +- .../flutter/lib/src/gestures/monodrag.dart | 20 +- .../flutter/lib/src/gestures/multidrag.dart | 18 +- .../flutter/lib/src/gestures/multitap.dart | 16 +- .../lib/src/gestures/pointer_router.dart | 10 +- .../flutter/lib/src/gestures/recognizer.dart | 12 +- packages/flutter/lib/src/gestures/scale.dart | 12 +- packages/flutter/lib/src/gestures/tap.dart | 10 +- packages/flutter/lib/src/gestures/team.dart | 4 +- .../lib/src/gestures/velocity_tracker.dart | 26 +- packages/flutter/lib/src/material/about.dart | 86 +-- .../animated_icons/animated_icons.dart | 12 +- packages/flutter/lib/src/material/app.dart | 34 +- .../flutter/lib/src/material/app_bar.dart | 66 +-- packages/flutter/lib/src/material/arc.dart | 18 +- .../flutter/lib/src/material/back_button.dart | 6 +- .../lib/src/material/bottom_app_bar.dart | 12 +- .../src/material/bottom_navigation_bar.dart | 112 ++-- .../lib/src/material/bottom_sheet.dart | 38 +- packages/flutter/lib/src/material/button.dart | 26 +- .../flutter/lib/src/material/button_bar.dart | 10 +- .../lib/src/material/button_theme.dart | 20 +- packages/flutter/lib/src/material/card.dart | 6 +- .../flutter/lib/src/material/checkbox.dart | 18 +- .../lib/src/material/checkbox_list_tile.dart | 6 +- packages/flutter/lib/src/material/chip.dart | 150 +++--- .../flutter/lib/src/material/chip_theme.dart | 32 +- .../lib/src/material/circle_avatar.dart | 16 +- .../flutter/lib/src/material/data_table.dart | 92 ++-- .../flutter/lib/src/material/date_picker.dart | 202 +++---- packages/flutter/lib/src/material/debug.dart | 4 +- packages/flutter/lib/src/material/dialog.dart | 74 +-- .../flutter/lib/src/material/divider.dart | 14 +- packages/flutter/lib/src/material/drawer.dart | 50 +- .../lib/src/material/drawer_header.dart | 14 +- .../flutter/lib/src/material/dropdown.dart | 98 ++-- .../flutter/lib/src/material/expand_icon.dart | 14 +- .../lib/src/material/expansion_panel.dart | 32 +- .../lib/src/material/expansion_tile.dart | 46 +- .../flutter/lib/src/material/feedback.dart | 4 +- .../flutter/lib/src/material/flat_button.dart | 28 +- .../lib/src/material/flexible_space_bar.dart | 30 +- .../src/material/floating_action_button.dart | 20 +- .../floating_action_button_location.dart | 20 +- .../lib/src/material/flutter_logo.dart | 4 +- .../flutter/lib/src/material/grid_tile.dart | 8 +- .../lib/src/material/grid_tile_bar.dart | 28 +- .../flutter/lib/src/material/icon_button.dart | 22 +- .../lib/src/material/ink_decoration.dart | 20 +- .../lib/src/material/ink_highlight.dart | 8 +- .../flutter/lib/src/material/ink_ripple.dart | 22 +- .../flutter/lib/src/material/ink_splash.dart | 16 +- .../flutter/lib/src/material/ink_well.dart | 14 +- .../lib/src/material/input_border.dart | 44 +- .../lib/src/material/input_decorator.dart | 166 +++--- .../flutter/lib/src/material/list_tile.dart | 46 +- .../flutter/lib/src/material/material.dart | 70 +-- .../src/material/material_localizations.dart | 8 +- .../lib/src/material/mergeable_material.dart | 58 +- .../lib/src/material/outline_button.dart | 56 +- packages/flutter/lib/src/material/page.dart | 18 +- .../src/material/paginated_data_table.dart | 76 +-- .../flutter/lib/src/material/popup_menu.dart | 88 +-- .../lib/src/material/progress_indicator.dart | 60 +-- packages/flutter/lib/src/material/radio.dart | 10 +- .../lib/src/material/radio_list_tile.dart | 6 +- .../lib/src/material/raised_button.dart | 30 +- .../lib/src/material/refresh_indicator.dart | 48 +- .../lib/src/material/reorderable_list.dart | 64 +-- .../flutter/lib/src/material/scaffold.dart | 168 +++--- .../flutter/lib/src/material/scrollbar.dart | 22 +- packages/flutter/lib/src/material/search.dart | 32 +- packages/flutter/lib/src/material/slider.dart | 68 +-- .../lib/src/material/slider_theme.dart | 92 ++-- .../flutter/lib/src/material/snack_bar.dart | 44 +- .../flutter/lib/src/material/stepper.dart | 134 ++--- packages/flutter/lib/src/material/switch.dart | 30 +- .../lib/src/material/switch_list_tile.dart | 6 +- .../lib/src/material/tab_controller.dart | 8 +- .../lib/src/material/tab_indicator.dart | 8 +- packages/flutter/lib/src/material/tabs.dart | 128 ++--- .../flutter/lib/src/material/text_field.dart | 54 +- .../lib/src/material/text_form_field.dart | 8 +- .../lib/src/material/text_selection.dart | 50 +- packages/flutter/lib/src/material/theme.dart | 16 +- .../flutter/lib/src/material/theme_data.dart | 100 ++-- packages/flutter/lib/src/material/time.dart | 4 +- .../flutter/lib/src/material/time_picker.dart | 174 +++--- .../flutter/lib/src/material/toggleable.dart | 18 +- .../flutter/lib/src/material/tooltip.dart | 50 +- .../lib/src/material/two_level_list.dart | 52 +- .../flutter/lib/src/material/typography.dart | 30 +- .../material/user_accounts_drawer_header.dart | 88 +-- .../flutter/lib/src/painting/alignment.dart | 70 +-- .../painting/beveled_rectangle_border.dart | 34 +- .../flutter/lib/src/painting/binding.dart | 2 +- .../lib/src/painting/border_radius.dart | 64 +-- .../flutter/lib/src/painting/borders.dart | 28 +- .../flutter/lib/src/painting/box_border.dart | 40 +- .../lib/src/painting/box_decoration.dart | 26 +- .../flutter/lib/src/painting/box_fit.dart | 24 +- .../flutter/lib/src/painting/box_shadow.dart | 8 +- .../lib/src/painting/circle_border.dart | 16 +- packages/flutter/lib/src/painting/clip.dart | 2 +- packages/flutter/lib/src/painting/colors.dart | 26 +- packages/flutter/lib/src/painting/debug.dart | 2 +- .../lib/src/painting/decoration_image.dart | 12 +- .../flutter/lib/src/painting/edge_insets.dart | 82 +-- .../lib/src/painting/flutter_logo.dart | 74 +-- .../lib/src/painting/fractional_offset.dart | 24 +- .../flutter/lib/src/painting/geometry.dart | 2 +- .../flutter/lib/src/painting/gradient.dart | 22 +- .../flutter/lib/src/painting/image_cache.dart | 2 +- .../lib/src/painting/image_decoder.dart | 2 +- .../lib/src/painting/image_provider.dart | 30 +- .../lib/src/painting/image_resolution.dart | 18 +- .../lib/src/painting/image_stream.dart | 24 +- .../lib/src/painting/matrix_utils.dart | 18 +- .../lib/src/painting/notched_shapes.dart | 20 +- .../lib/src/painting/paint_utilities.dart | 2 +- .../painting/rounded_rectangle_border.dart | 46 +- .../lib/src/painting/shape_decoration.dart | 30 +- .../lib/src/painting/stadium_border.dart | 84 +-- .../lib/src/painting/text_painter.dart | 30 +- .../flutter/lib/src/painting/text_span.dart | 12 +- .../flutter/lib/src/painting/text_style.dart | 54 +- .../lib/src/physics/friction_simulation.dart | 4 +- .../lib/src/physics/spring_simulation.dart | 14 +- .../lib/src/rendering/animated_size.dart | 6 +- .../flutter/lib/src/rendering/binding.dart | 12 +- packages/flutter/lib/src/rendering/box.dart | 108 ++-- .../lib/src/rendering/custom_layout.dart | 28 +- .../lib/src/rendering/custom_paint.dart | 18 +- packages/flutter/lib/src/rendering/debug.dart | 8 +- .../rendering/debug_overflow_indicator.dart | 34 +- .../flutter/lib/src/rendering/editable.dart | 106 ++-- packages/flutter/lib/src/rendering/error.dart | 10 +- packages/flutter/lib/src/rendering/flex.dart | 50 +- packages/flutter/lib/src/rendering/flow.dart | 16 +- packages/flutter/lib/src/rendering/image.dart | 38 +- packages/flutter/lib/src/rendering/layer.dart | 60 +-- .../flutter/lib/src/rendering/list_body.dart | 32 +- .../src/rendering/list_wheel_viewport.dart | 18 +- .../flutter/lib/src/rendering/object.dart | 92 ++-- .../flutter/lib/src/rendering/paragraph.dart | 52 +- .../src/rendering/performance_overlay.dart | 6 +- .../lib/src/rendering/platform_view.dart | 18 +- .../flutter/lib/src/rendering/proxy_box.dart | 190 +++---- .../lib/src/rendering/rotated_box.dart | 6 +- .../lib/src/rendering/shifted_box.dart | 66 +-- .../flutter/lib/src/rendering/sliver.dart | 84 +-- .../lib/src/rendering/sliver_fill.dart | 2 +- .../rendering/sliver_fixed_extent_list.dart | 6 +- .../lib/src/rendering/sliver_grid.dart | 12 +- .../lib/src/rendering/sliver_list.dart | 8 +- .../rendering/sliver_multi_box_adaptor.dart | 10 +- .../lib/src/rendering/sliver_padding.dart | 20 +- .../rendering/sliver_persistent_header.dart | 30 +- packages/flutter/lib/src/rendering/stack.dart | 40 +- packages/flutter/lib/src/rendering/table.dart | 72 +-- .../lib/src/rendering/table_border.dart | 16 +- .../flutter/lib/src/rendering/texture.dart | 4 +- packages/flutter/lib/src/rendering/view.dart | 26 +- .../flutter/lib/src/rendering/viewport.dart | 56 +- packages/flutter/lib/src/rendering/wrap.dart | 34 +- .../flutter/lib/src/scheduler/binding.dart | 30 +- packages/flutter/lib/src/scheduler/debug.dart | 2 +- .../flutter/lib/src/scheduler/priority.dart | 2 +- .../flutter/lib/src/scheduler/ticker.dart | 12 +- .../flutter/lib/src/semantics/semantics.dart | 178 +++--- .../lib/src/semantics/semantics_service.dart | 4 +- .../lib/src/services/asset_bundle.dart | 16 +- .../flutter/lib/src/services/binding.dart | 10 +- .../flutter/lib/src/services/clipboard.dart | 2 +- .../lib/src/services/message_codecs.dart | 34 +- .../lib/src/services/platform_channel.dart | 12 +- .../lib/src/services/platform_messages.dart | 6 +- .../lib/src/services/platform_views.dart | 6 +- .../lib/src/services/raw_keyboard.dart | 18 +- .../lib/src/services/system_chrome.dart | 2 +- .../lib/src/services/text_editing.dart | 6 +- .../lib/src/services/text_formatter.dart | 12 +- .../flutter/lib/src/services/text_input.dart | 18 +- .../lib/src/widgets/animated_cross_fade.dart | 40 +- .../lib/src/widgets/animated_list.dart | 18 +- .../lib/src/widgets/animated_size.dart | 2 +- .../lib/src/widgets/animated_switcher.dart | 20 +- .../lib/src/widgets/annotated_region.dart | 2 +- packages/flutter/lib/src/widgets/app.dart | 36 +- packages/flutter/lib/src/widgets/async.dart | 22 +- .../lib/src/widgets/automatic_keep_alive.dart | 16 +- packages/flutter/lib/src/widgets/banner.dart | 28 +- packages/flutter/lib/src/widgets/basic.dart | 342 ++++++------ packages/flutter/lib/src/widgets/binding.dart | 36 +- .../flutter/lib/src/widgets/container.dart | 42 +- packages/flutter/lib/src/widgets/debug.dart | 16 +- .../flutter/lib/src/widgets/dismissible.dart | 42 +- .../flutter/lib/src/widgets/drag_target.dart | 32 +- .../lib/src/widgets/editable_text.dart | 66 +-- .../lib/src/widgets/fade_in_image.dart | 36 +- .../lib/src/widgets/focus_manager.dart | 4 +- .../flutter/lib/src/widgets/focus_scope.dart | 6 +- packages/flutter/lib/src/widgets/form.dart | 10 +- .../flutter/lib/src/widgets/framework.dart | 146 ++--- .../lib/src/widgets/gesture_detector.dart | 82 +-- .../flutter/lib/src/widgets/grid_paper.dart | 10 +- packages/flutter/lib/src/widgets/heroes.dart | 50 +- packages/flutter/lib/src/widgets/icon.dart | 30 +- .../flutter/lib/src/widgets/icon_theme.dart | 6 +- .../lib/src/widgets/icon_theme_data.dart | 10 +- packages/flutter/lib/src/widgets/image.dart | 52 +- .../flutter/lib/src/widgets/image_icon.dart | 10 +- .../lib/src/widgets/implicit_animations.dart | 218 ++++---- .../lib/src/widgets/inherited_model.dart | 6 +- .../lib/src/widgets/layout_builder.dart | 8 +- .../src/widgets/list_wheel_scroll_view.dart | 34 +- .../lib/src/widgets/localizations.dart | 28 +- .../flutter/lib/src/widgets/media_query.dart | 18 +- .../lib/src/widgets/modal_barrier.dart | 16 +- .../lib/src/widgets/navigation_toolbar.dart | 22 +- .../flutter/lib/src/widgets/navigator.dart | 34 +- .../lib/src/widgets/nested_scroll_view.dart | 90 ++-- .../lib/src/widgets/orientation_builder.dart | 2 +- packages/flutter/lib/src/widgets/overlay.dart | 32 +- .../lib/src/widgets/overscroll_indicator.dart | 50 +- .../flutter/lib/src/widgets/page_storage.dart | 2 +- .../flutter/lib/src/widgets/page_view.dart | 36 +- .../lib/src/widgets/performance_overlay.dart | 2 +- .../flutter/lib/src/widgets/placeholder.dart | 10 +- .../lib/src/widgets/platform_view.dart | 6 +- .../widgets/primary_scroll_controller.dart | 2 +- .../src/widgets/raw_keyboard_listener.dart | 4 +- packages/flutter/lib/src/widgets/routes.dart | 76 +-- .../flutter/lib/src/widgets/safe_area.dart | 28 +- .../lib/src/widgets/scroll_activity.dart | 26 +- .../lib/src/widgets/scroll_configuration.dart | 4 +- .../lib/src/widgets/scroll_controller.dart | 6 +- .../lib/src/widgets/scroll_metrics.dart | 2 +- .../lib/src/widgets/scroll_physics.dart | 22 +- .../lib/src/widgets/scroll_position.dart | 14 +- .../scroll_position_with_single_context.dart | 14 +- .../lib/src/widgets/scroll_simulation.dart | 6 +- .../flutter/lib/src/widgets/scroll_view.dart | 52 +- .../flutter/lib/src/widgets/scrollable.dart | 40 +- .../flutter/lib/src/widgets/scrollbar.dart | 14 +- .../lib/src/widgets/semantics_debugger.dart | 28 +- .../src/widgets/single_child_scroll_view.dart | 28 +- .../widgets/size_changed_layout_notifier.dart | 4 +- packages/flutter/lib/src/widgets/sliver.dart | 36 +- .../src/widgets/sliver_persistent_header.dart | 24 +- .../widgets/sliver_prototype_extent_list.dart | 6 +- packages/flutter/lib/src/widgets/spacer.dart | 2 +- .../lib/src/widgets/status_transitions.dart | 2 +- packages/flutter/lib/src/widgets/table.dart | 24 +- packages/flutter/lib/src/widgets/text.dart | 38 +- .../lib/src/widgets/text_selection.dart | 64 +-- packages/flutter/lib/src/widgets/texture.dart | 2 +- .../lib/src/widgets/ticker_provider.dart | 18 +- packages/flutter/lib/src/widgets/title.dart | 6 +- .../flutter/lib/src/widgets/transitions.dart | 42 +- .../src/widgets/value_listenable_builder.dart | 2 +- .../flutter/lib/src/widgets/viewport.dart | 24 +- .../flutter/lib/src/widgets/visibility.dart | 20 +- .../lib/src/widgets/widget_inspector.dart | 148 ++--- .../lib/src/widgets/will_pop_scope.dart | 2 +- .../animation/animation_controller_test.dart | 58 +- .../test/animation/animations_test.dart | 90 ++-- .../flutter/test/animation/futures_test.dart | 20 +- .../animation/iteration_patterns_test.dart | 8 +- .../flutter/test/animation/tween_test.dart | 28 +- .../test/cupertino/action_sheet_test.dart | 202 +++---- .../cupertino/activity_indicator_test.dart | 2 +- packages/flutter/test/cupertino/app_test.dart | 10 +- .../test/cupertino/bottom_tab_bar_test.dart | 36 +- .../flutter/test/cupertino/button_test.dart | 24 +- .../test/cupertino/date_picker_test.dart | 44 +- .../flutter/test/cupertino/dialog_test.dart | 148 ++--- .../flutter/test/cupertino/nav_bar_test.dart | 182 +++---- .../cupertino/nav_bar_transition_test.dart | 36 +- .../flutter/test/cupertino/page_test.dart | 28 +- .../flutter/test/cupertino/picker_test.dart | 68 +-- .../flutter/test/cupertino/refresh_test.dart | 176 +++--- .../flutter/test/cupertino/route_test.dart | 32 +- .../flutter/test/cupertino/scaffold_test.dart | 60 +-- .../test/cupertino/scrollbar_paint_test.dart | 10 +- .../test/cupertino/scrollbar_test.dart | 12 +- .../cupertino/segmented_control_test.dart | 192 +++---- .../flutter/test/cupertino/slider_test.dart | 92 ++-- .../flutter/test/cupertino/switch_test.dart | 26 +- .../test/cupertino/tab_scaffold_test.dart | 62 +-- packages/flutter/test/cupertino/tab_test.dart | 24 +- packages/flutter/test/engine/color_test.dart | 6 +- packages/flutter/test/engine/dart_test.dart | 2 +- .../test/engine/paragraph_builder_test.dart | 4 +- packages/flutter/test/engine/rect_test.dart | 8 +- packages/flutter/test/engine/rrect_test.dart | 8 +- .../flutter/test/engine/task_order_test.dart | 6 +- .../test/flutter_test_alternative.dart | 2 +- .../test/foundation/assertions_test.dart | 8 +- .../test/foundation/bit_field_test.dart | 6 +- .../foundation/caching_iterable_test.dart | 10 +- .../test/foundation/capture_output.dart | 2 +- .../test/foundation/change_notifier_test.dart | 44 +- .../foundation/consolidate_response_test.dart | 8 +- .../foundation/covariant_templates_test.dart | 4 +- .../flutter/test/foundation/debug_test.dart | 6 +- .../test/foundation/diagnostics_test.dart | 296 +++++----- .../test/foundation/error_reporting_test.dart | 20 +- .../flutter/test/foundation/print_test.dart | 2 +- .../test/foundation/reassemble_test.dart | 4 +- .../test/foundation/serialization_test.dart | 34 +- .../foundation/service_extensions_test.dart | 6 +- .../foundation/synchronous_future_test.dart | 4 +- .../flutter/test/gestures/arena_test.dart | 24 +- .../flutter/test/gestures/debug_test.dart | 8 +- .../test/gestures/double_tap_test.dart | 34 +- packages/flutter/test/gestures/drag_test.dart | 50 +- .../test/gestures/gesture_binding_test.dart | 16 +- .../flutter/test/gestures/gesture_tester.dart | 6 +- .../flutter/test/gestures/locking_test.dart | 4 +- .../test/gestures/long_press_test.dart | 12 +- .../test/gestures/lsq_solver_test.dart | 8 +- .../flutter/test/gestures/multidrag_test.dart | 12 +- .../flutter/test/gestures/multitap_test.dart | 6 +- .../test/gestures/pointer_router_test.dart | 30 +- .../test/gestures/recognizer_test.dart | 2 +- .../flutter/test/gestures/scale_test.dart | 20 +- packages/flutter/test/gestures/tap_test.dart | 28 +- packages/flutter/test/gestures/team_test.dart | 22 +- .../test/gestures/velocity_tracker_test.dart | 6 +- .../flutter/test/material/about_test.dart | 20 +- .../material/animated_icons_private_test.dart | 36 +- .../test/material/animated_icons_test.dart | 22 +- .../flutter/test/material/app_bar_test.dart | 474 ++++++++-------- .../test/material/app_builder_test.dart | 16 +- packages/flutter/test/material/app_test.dart | 100 ++-- packages/flutter/test/material/arc_test.dart | 56 +- .../test/material/back_button_test.dart | 24 +- .../test/material/bottom_app_bar_test.dart | 48 +- .../material/bottom_navigation_bar_test.dart | 186 +++---- .../test/material/button_theme_test.dart | 48 +- .../flutter/test/material/buttons_test.dart | 228 ++++---- packages/flutter/test/material/card_test.dart | 50 +- .../flutter/test/material/checkbox_test.dart | 66 +-- packages/flutter/test/material/chip_test.dart | 324 +++++------ .../test/material/chip_theme_test.dart | 56 +- .../test/material/circle_avatar_test.dart | 52 +- .../test/material/control_list_tile_test.dart | 40 +- .../test/material/data_table_test.dart | 72 +-- .../test/material/data_table_test_utils.dart | 20 +- .../test/material/date_picker_test.dart | 230 ++++---- .../flutter/test/material/dialog_test.dart | 76 +-- .../flutter/test/material/drawer_test.dart | 20 +- .../flutter/test/material/dropdown_test.dart | 130 ++--- .../test/material/expand_icon_test.dart | 18 +- .../test/material/expansion_panel_test.dart | 126 ++--- .../test/material/expansion_tile_test.dart | 24 +- .../flutter/test/material/feedback_test.dart | 32 +- .../test/material/flat_button_test.dart | 12 +- ...flexible_space_bar_collapse_mode_test.dart | 112 ++-- .../material/flexible_space_bar_test.dart | 18 +- .../floating_action_button_location_test.dart | 20 +- .../material/floating_action_button_test.dart | 140 ++--- .../test/material/grid_title_test.dart | 16 +- .../test/material/icon_button_test.dart | 86 +-- .../flutter/test/material/ink_paint_test.dart | 84 +-- .../test/material/ink_splash_test.dart | 12 +- .../flutter/test/material/ink_well_test.dart | 56 +- .../test/material/input_decorator_test.dart | 42 +- .../flutter/test/material/list_tile_test.dart | 114 ++-- .../flutter/test/material/material_test.dart | 112 ++-- .../material/mergeable_material_test.dart | 174 +++--- .../material/modal_bottom_sheet_test.dart | 54 +- .../test/material/outline_button_test.dart | 82 +-- .../test/material/page_selector_test.dart | 30 +- packages/flutter/test/material/page_test.dart | 56 +- .../material/paginated_data_table_test.dart | 54 +- .../persistent_bottom_sheet_test.dart | 62 +-- .../test/material/popup_menu_test.dart | 144 ++--- .../material/progress_indicator_test.dart | 28 +- .../flutter/test/material/radio_test.dart | 82 +-- .../material/raw_material_button_test.dart | 58 +- .../test/material/refresh_indicator_test.dart | 98 ++-- .../test/material/reorderable_list_test.dart | 110 ++-- .../flutter/test/material/scaffold_test.dart | 478 ++++++++--------- .../test/material/scrollbar_paint_test.dart | 16 +- .../flutter/test/material/scrollbar_test.dart | 54 +- .../flutter/test/material/search_test.dart | 108 ++-- .../flutter/test/material/slider_test.dart | 362 ++++++------- .../test/material/slider_theme_test.dart | 78 +-- .../flutter/test/material/snack_bar_test.dart | 164 +++--- .../flutter/test/material/stepper_test.dart | 86 +-- .../flutter/test/material/switch_test.dart | 134 ++--- .../material/tabbed_scrollview_warp_test.dart | 26 +- packages/flutter/test/material/tabs_test.dart | 430 +++++++-------- .../test/material/text_field_focus_test.dart | 52 +- .../material/text_field_helper_text_test.dart | 4 +- .../test/material/text_field_splash_test.dart | 34 +- .../test/material/text_field_test.dart | 506 +++++++++--------- .../test/material/text_form_field_test.dart | 40 +- .../test/material/theme_data_test.dart | 80 +-- .../flutter/test/material/theme_test.dart | 162 +++--- .../test/material/time_picker_test.dart | 98 ++-- packages/flutter/test/material/time_test.dart | 10 +- .../flutter/test/material/tooltip_test.dart | 210 ++++---- .../test/material/two_level_list_test.dart | 38 +- .../test/material/typography_test.dart | 10 +- .../user_accounts_drawer_header_test.dart | 62 +-- .../flutter/test/material/will_pop_test.dart | 86 +-- .../flutter/test/painting/alignment_test.dart | 2 +- .../beveled_rectangle_border_test.dart | 10 +- .../test/painting/border_radius_test.dart | 96 ++-- .../test/painting/border_rtl_test.dart | 72 +-- .../test/painting/border_side_test.dart | 8 +- .../flutter/test/painting/border_test.dart | 8 +- .../test/painting/box_decoration_test.dart | 4 +- .../test/painting/box_painter_test.dart | 6 +- .../test/painting/circle_border_test.dart | 6 +- .../flutter/test/painting/colors_test.dart | 28 +- .../test/painting/decoration_test.dart | 96 ++-- .../test/painting/edge_insets_test.dart | 26 +- .../flutter/test/painting/fake_codec.dart | 6 +- .../test/painting/fake_image_provider.dart | 6 +- .../test/painting/flutter_logo_test.dart | 4 +- .../test/painting/fractional_offset_test.dart | 4 +- .../flutter/test/painting/gradient_test.dart | 18 +- .../painting/image_cache_resize_test.dart | 2 +- .../test/painting/image_cache_test.dart | 2 +- .../test/painting/image_decoder_test.dart | 2 +- .../test/painting/image_provider_test.dart | 20 +- .../test/painting/image_resolution_test.dart | 30 +- .../test/painting/image_stream_test.dart | 136 ++--- .../test/painting/image_test_utils.dart | 12 +- .../test/painting/matrix_utils_test.dart | 24 +- .../test/painting/mocks_for_image_cache.dart | 10 +- .../test/painting/notched_shapes_test.dart | 16 +- .../test/painting/paint_image_test.dart | 12 +- .../rounded_rectangle_border_test.dart | 24 +- .../test/painting/shape_border_test.dart | 8 +- .../test/painting/shape_decoration_test.dart | 36 +- .../test/painting/stadium_border_test.dart | 12 +- .../test/painting/text_painter_rtl_test.dart | 32 +- .../test/painting/text_painter_test.dart | 56 +- .../flutter/test/painting/text_span_test.dart | 12 +- .../test/painting/text_style_test.dart | 16 +- .../test/physics/clamped_simulation_test.dart | 4 +- .../physics/friction_simulation_test.dart | 4 +- .../test/physics/gravity_simulation_test.dart | 4 +- .../flutter/test/physics/newton_test.dart | 44 +- .../test/rendering/annotated_region_test.dart | 66 +-- .../test/rendering/aspect_ratio_test.dart | 22 +- .../flutter/test/rendering/baseline_test.dart | 6 +- packages/flutter/test/rendering/box_test.dart | 54 +- .../rendering/cached_intrinsics_test.dart | 2 +- .../test/rendering/constraints_test.dart | 10 +- .../flutter/test/rendering/debug_test.dart | 36 +- .../rendering/dynamic_intrinsics_test.dart | 10 +- .../flutter/test/rendering/editable_test.dart | 6 +- .../flutter/test/rendering/error_test.dart | 4 +- .../test/rendering/flex_overflow_test.dart | 16 +- .../flutter/test/rendering/flex_test.dart | 104 ++-- .../flutter/test/rendering/image_test.dart | 34 +- .../rendering/independent_layout_test.dart | 26 +- .../test/rendering/intrinsic_width_test.dart | 42 +- .../flutter/test/rendering/layers_test.dart | 6 +- .../test/rendering/limited_box_test.dart | 26 +- .../test/rendering/localized_fonts_test.dart | 54 +- .../flutter/test/rendering/mock_canvas.dart | 80 +-- .../test/rendering/mutations_test.dart | 6 +- .../non_render_object_root_test.dart | 10 +- .../flutter/test/rendering/object_test.dart | 8 +- .../flutter/test/rendering/offstage_test.dart | 12 +- .../flutter/test/rendering/overflow_test.dart | 18 +- .../rendering/paragraph_intrinsics_test.dart | 4 +- .../test/rendering/paragraph_test.dart | 24 +- .../test/rendering/positioned_box_test.dart | 30 +- .../test/rendering/proxy_box_test.dart | 78 +-- .../proxy_getters_and_setters_test.dart | 12 +- .../flutter/test/rendering/reattach_test.dart | 44 +- .../test/rendering/recording_canvas.dart | 10 +- .../test/rendering/relative_rect_test.dart | 6 +- .../test/rendering/rendering_tester.dart | 6 +- .../test/rendering/repaint_boundary_test.dart | 10 +- .../semantics_and_children_test.dart | 10 +- .../test/rendering/simple_semantics_test.dart | 4 +- .../flutter/test/rendering/size_test.dart | 4 +- .../test/rendering/sliver_cache_test.dart | 86 +-- .../test/rendering/slivers_block_test.dart | 72 +-- .../test/rendering/slivers_layout_test.dart | 14 +- .../flutter/test/rendering/slivers_test.dart | 230 ++++---- .../flutter/test/rendering/stack_test.dart | 28 +- .../test/rendering/table_border_test.dart | 16 +- .../flutter/test/rendering/table_test.dart | 50 +- .../test/rendering/transform_test.dart | 70 +-- .../flutter/test/rendering/view_test.dart | 2 +- .../flutter/test/rendering/viewport_test.dart | 180 +++---- .../flutter/test/rendering/wrap_test.dart | 2 +- .../test/scheduler/animation_test.dart | 2 +- .../test/scheduler/scheduler_test.dart | 6 +- .../flutter/test/scheduler/ticker_test.dart | 12 +- .../custom_semantics_action_test.dart | 6 +- .../test/semantics/semantics_test.dart | 88 +-- .../test/semantics/traversal_order_test.dart | 40 +- .../test/services/asset_bundle_test.dart | 10 +- .../test/services/fake_platform_views.dart | 34 +- .../test/services/message_codecs_test.dart | 30 +- .../test/services/platform_channel_test.dart | 10 +- .../test/services/platform_messages_test.dart | 2 +- .../test/services/platform_views_test.dart | 16 +- .../test/widgets/absorb_pointer_test.dart | 22 +- packages/flutter/test/widgets/align_test.dart | 40 +- .../test/widgets/animated_align_test.dart | 14 +- .../test/widgets/animated_container_test.dart | 58 +- .../widgets/animated_cross_fade_test.dart | 90 ++-- .../test/widgets/animated_list_test.dart | 52 +- .../test/widgets/animated_padding_test.dart | 16 +- .../widgets/animated_positioned_test.dart | 176 +++--- .../test/widgets/animated_size_test.dart | 56 +- .../test/widgets/animated_switcher_test.dart | 112 ++-- .../test/widgets/app_navigator_key_test.dart | 10 +- .../test/widgets/app_overrides_test.dart | 4 +- .../flutter/test/widgets/app_title_test.dart | 6 +- .../test/widgets/aspect_ratio_test.dart | 26 +- .../test/widgets/async_lifecycle_test.dart | 8 +- packages/flutter/test/widgets/async_test.dart | 174 +++--- .../widgets/automatic_keep_alive_test.dart | 140 ++--- .../flutter/test/widgets/banner_test.dart | 42 +- .../flutter/test/widgets/baseline_test.dart | 22 +- packages/flutter/test/widgets/basic_test.dart | 44 +- .../flutter/test/widgets/binding_test.dart | 6 +- .../test/widgets/box_decoration_test.dart | 112 ++-- .../widgets/box_sliver_mismatch_test.dart | 10 +- .../test/widgets/build_scope_test.dart | 62 +-- .../flutter/test/widgets/center_test.dart | 4 +- .../test/widgets/clamp_overscrolls_test.dart | 12 +- packages/flutter/test/widgets/clip_test.dart | 306 +++++------ .../flutter/test/widgets/column_test.dart | 188 +++---- .../widgets/composited_transform_test.dart | 108 ++-- .../test/widgets/constrained_box_test.dart | 16 +- .../flutter/test/widgets/container_test.dart | 14 +- .../test/widgets/coordinates_test.dart | 14 +- .../custom_multi_child_layout_test.dart | 48 +- .../test/widgets/custom_paint_test.dart | 46 +- .../test/widgets/custom_painter_test.dart | 240 ++++----- .../custom_single_child_layout_test.dart | 26 +- .../test/widgets/directionality_test.dart | 16 +- .../test/widgets/dismissible_test.dart | 32 +- .../widgets/dispose_ancestor_lookup_test.dart | 30 +- .../flutter/test/widgets/draggable_test.dart | 354 ++++++------ .../flutter/test/widgets/drawer_test.dart | 100 ++-- .../editable_text_show_on_screen_test.dart | 138 ++--- .../test/widgets/editable_text_test.dart | 290 +++++----- .../test/widgets/ensure_visible_test.dart | 160 +++--- .../widgets/error_widget_builder_test.dart | 4 +- .../test/widgets/fade_in_image_test.dart | 22 +- .../test/widgets/fade_transition_test.dart | 4 +- .../flutter/test/widgets/fitted_box_test.dart | 118 ++-- packages/flutter/test/widgets/flex_test.dart | 64 +-- packages/flutter/test/widgets/flow_test.dart | 20 +- packages/flutter/test/widgets/focus_test.dart | 32 +- packages/flutter/test/widgets/form_test.dart | 124 ++--- .../widgets/fractionally_sized_box_test.dart | 10 +- .../flutter/test/widgets/framework_test.dart | 396 +++++++------- .../gesture_detector_semantics_test.dart | 20 +- .../test/widgets/gesture_detector_test.dart | 56 +- .../widgets/gesture_disambiguation_test.dart | 8 +- .../widgets/global_keys_duplicated_test.dart | 28 +- .../test/widgets/global_keys_moving_test.dart | 18 +- .../test/widgets/grid_view_layout_test.dart | 16 +- .../flutter/test/widgets/grid_view_test.dart | 144 ++--- .../flutter/test/widgets/heroes_test.dart | 332 ++++++------ .../flutter/test/widgets/hyperlink_test.dart | 16 +- packages/flutter/test/widgets/icon_test.dart | 4 +- .../test/widgets/image_headers_test.dart | 16 +- .../widgets/image_package_asset_test.dart | 4 +- .../test/widgets/image_resolution_test.dart | 84 +-- .../flutter/test/widgets/image_rtl_test.dart | 346 ++++++------ packages/flutter/test/widgets/image_test.dart | 238 ++++---- .../widgets/implicit_animations_test.dart | 18 +- .../test/widgets/implicit_semantics_test.dart | 82 +-- .../independent_widget_layout_test.dart | 38 +- .../test/widgets/inherited_model_test.dart | 94 ++-- .../flutter/test/widgets/inherited_test.dart | 162 +++--- .../flutter/test/widgets/init_state_test.dart | 6 +- .../flutter/test/widgets/keep_alive_test.dart | 30 +- packages/flutter/test/widgets/key_test.dart | 44 +- .../layout_builder_and_global_keys_test.dart | 14 +- .../layout_builder_and_parent_data_test.dart | 14 +- .../layout_builder_and_state_test.dart | 14 +- .../layout_builder_mutations_test.dart | 34 +- .../test/widgets/layout_builder_test.dart | 52 +- .../test/widgets/linked_scroll_view_test.dart | 48 +- .../flutter/test/widgets/list_body_test.dart | 60 +-- .../test/widgets/list_view_builder_test.dart | 58 +- .../widgets/list_view_correction_test.dart | 114 ++-- .../test/widgets/list_view_fling_test.dart | 6 +- .../widgets/list_view_horizontal_test.dart | 16 +- .../test/widgets/list_view_misc_test.dart | 62 +-- .../test/widgets/list_view_relayout_test.dart | 56 +- .../flutter/test/widgets/list_view_test.dart | 170 +++--- .../test/widgets/list_view_vertical_test.dart | 16 +- .../widgets/list_view_viewporting_test.dart | 134 ++--- .../list_view_with_inherited_test.dart | 14 +- .../widgets/list_wheel_scroll_view_test.dart | 340 ++++++------ .../flutter/test/widgets/listener_test.dart | 8 +- .../widgets/listview_end_append_test.dart | 14 +- .../test/widgets/media_query_test.dart | 50 +- .../test/widgets/modal_barrier_test.dart | 30 +- .../flutter/test/widgets/multichild_test.dart | 66 +-- .../widgets/navigator_and_layers_test.dart | 20 +- .../widgets/navigator_replacement_test.dart | 4 +- .../flutter/test/widgets/navigator_test.dart | 168 +++--- .../test/widgets/nested_scroll_view_test.dart | 128 ++--- .../test/widgets/notification_test.dart | 32 +- .../widgets/obscured_animated_image_test.dart | 12 +- .../flutter/test/widgets/opacity_test.dart | 26 +- .../test/widgets/overflow_box_test.dart | 12 +- .../flutter/test/widgets/overlay_test.dart | 28 +- .../widgets/overscroll_indicator_test.dart | 66 +-- .../page_forward_transitions_test.dart | 26 +- .../test/widgets/page_storage_test.dart | 16 +- .../test/widgets/page_transitions_test.dart | 64 +-- .../flutter/test/widgets/page_view_test.dart | 212 ++++---- .../test/widgets/pageable_list_test.dart | 24 +- .../test/widgets/parent_data_test.dart | 104 ++-- .../widgets/performance_overlay_test.dart | 2 +- .../test/widgets/physical_model_test.dart | 6 +- .../test/widgets/placeholder_test.dart | 6 +- .../test/widgets/platform_view_test.dart | 120 ++--- .../flutter/test/widgets/positioned_test.dart | 42 +- .../widgets/raw_keyboard_listener_test.dart | 26 +- .../flutter/test/widgets/reassemble_test.dart | 2 +- .../remember_scroll_position_test.dart | 20 +- .../widgets/render_object_widget_test.dart | 54 +- .../widgets/reparent_state_harder_test.dart | 42 +- .../test/widgets/reparent_state_test.dart | 172 +++--- ...parent_state_with_layout_builder_test.dart | 54 +- .../test/widgets/rotated_box_test.dart | 16 +- .../flutter/test/widgets/routes_test.dart | 100 ++-- packages/flutter/test/widgets/row_test.dart | 260 ++++----- packages/flutter/test/widgets/rtl_test.dart | 12 +- .../flutter/test/widgets/run_app_test.dart | 6 +- .../flutter/test/widgets/safe_area_test.dart | 42 +- .../test/widgets/scroll_behavior_test.dart | 12 +- .../test/widgets/scroll_controller_test.dart | 130 ++--- .../test/widgets/scroll_events_test.dart | 8 +- .../test/widgets/scroll_interaction_test.dart | 6 +- .../widgets/scroll_notification_test.dart | 16 +- .../test/widgets/scroll_physics_test.dart | 16 +- .../test/widgets/scroll_simulation_test.dart | 2 +- .../test/widgets/scroll_view_test.dart | 136 ++--- .../widgets/scrollable_animations_test.dart | 24 +- .../test/widgets/scrollable_dispose_test.dart | 10 +- .../test/widgets/scrollable_fling_test.dart | 24 +- .../test/widgets/scrollable_grid_test.dart | 28 +- .../scrollable_list_hit_testing_test.dart | 58 +- .../test/widgets/scrollable_of_test.dart | 8 +- .../widgets/scrollable_semantics_test.dart | 170 +++--- ...llable_semantics_traversal_order_test.dart | 380 ++++++------- .../flutter/test/widgets/scrollable_test.dart | 6 +- .../test/widgets/semantics_10_test.dart | 18 +- .../test/widgets/semantics_11_test.dart | 30 +- .../test/widgets/semantics_1_test.dart | 102 ++-- .../test/widgets/semantics_2_test.dart | 72 +-- .../test/widgets/semantics_3_test.dart | 56 +- .../test/widgets/semantics_4_test.dart | 64 +-- .../test/widgets/semantics_5_test.dart | 16 +- .../test/widgets/semantics_6_test.dart | 20 +- .../test/widgets/semantics_7_test.dart | 50 +- .../test/widgets/semantics_8_test.dart | 34 +- .../test/widgets/semantics_9_test.dart | 72 +-- .../test/widgets/semantics_clipping_test.dart | 56 +- .../test/widgets/semantics_debugger_test.dart | 148 ++--- .../test/widgets/semantics_event_test.dart | 12 +- .../test/widgets/semantics_merge_test.dart | 62 +-- .../flutter/test/widgets/semantics_test.dart | 374 ++++++------- .../test/widgets/semantics_tester.dart | 24 +- ...xpressionForCurrentSemanticsTree_test.dart | 24 +- .../widgets/semantics_traversal_test.dart | 30 +- .../semantics_zero_surface_size_test.dart | 16 +- .../test/widgets/set_state_1_test.dart | 14 +- .../test/widgets/set_state_2_test.dart | 10 +- .../test/widgets/set_state_3_test.dart | 10 +- .../test/widgets/set_state_4_test.dart | 4 +- .../test/widgets/set_state_5_test.dart | 6 +- .../test/widgets/shader_mask_test.dart | 14 +- .../flutter/test/widgets/shadow_test.dart | 36 +- .../test/widgets/shape_decoration_test.dart | 52 +- .../test/widgets/simple_semantics_test.dart | 36 +- .../single_child_scroll_view_test.dart | 308 +++++------ ...size_changed_layout_notification_test.dart | 14 +- .../flutter/test/widgets/sized_box_test.dart | 78 +-- .../widgets/sliver_fill_remaining_test.dart | 16 +- .../widgets/sliver_fill_viewport_test.dart | 12 +- .../test/widgets/sliver_list_test.dart | 30 +- .../sliver_prototype_item_extent_test.dart | 28 +- .../test/widgets/sliver_semantics_test.dart | 422 +++++++-------- .../slivers_appbar_floating_pinned_test.dart | 10 +- .../widgets/slivers_appbar_floating_test.dart | 86 +-- .../widgets/slivers_appbar_pinned_test.dart | 82 +-- .../slivers_appbar_scrolling_test.dart | 42 +- .../slivers_block_global_key_test.dart | 16 +- .../test/widgets/slivers_block_test.dart | 102 ++-- .../test/widgets/slivers_evil_test.dart | 164 +++--- .../test/widgets/slivers_padding_test.dart | 198 +++---- .../test/widgets/slivers_protocol_test.dart | 22 +- .../flutter/test/widgets/slivers_test.dart | 54 +- .../flutter/test/widgets/spacer_test.dart | 10 +- packages/flutter/test/widgets/stack_test.dart | 286 +++++----- .../state_setting_in_scrollables_test.dart | 18 +- .../test/widgets/stateful_component_test.dart | 4 +- .../widgets/stateful_components_test.dart | 8 +- .../test/widgets/status_transitions_test.dart | 12 +- .../flutter/test/widgets/syncing_test.dart | 60 +-- packages/flutter/test/widgets/table_test.dart | 168 +++--- .../flutter/test/widgets/test_widgets.dart | 2 +- .../test/widgets/text_formatter_test.dart | 16 +- .../test/widgets/text_golden_test.dart | 56 +- packages/flutter/test/widgets/text_test.dart | 60 +-- .../test/widgets/ticker_provider_test.dart | 10 +- packages/flutter/test/widgets/title_test.dart | 24 +- .../tracking_scroll_controller_test.dart | 14 +- .../flutter/test/widgets/transform_test.dart | 124 ++--- .../test/widgets/transitions_test.dart | 50 +- .../test/widgets/unique_widget_test.dart | 8 +- .../value_listenable_builder_test.dart | 14 +- .../flutter/test/widgets/visibility_test.dart | 58 +- .../test/widgets/widget_inspector_test.dart | 284 +++++----- packages/flutter/test/widgets/wrap_test.dart | 110 ++-- .../lib/src/common/enum_util.dart | 4 +- .../flutter_driver/lib/src/common/error.dart | 4 +- .../flutter_driver/lib/src/common/find.dart | 22 +- .../lib/src/common/frame_sync.dart | 2 +- .../lib/src/common/gesture.dart | 6 +- .../flutter_driver/lib/src/common/health.dart | 4 +- .../lib/src/common/message.dart | 2 +- .../lib/src/common/render_tree.dart | 2 +- .../lib/src/common/request_data.dart | 2 +- .../lib/src/common/semantics.dart | 2 +- .../flutter_driver/lib/src/common/text.dart | 6 +- .../flutter_driver/lib/src/driver/common.dart | 2 +- .../flutter_driver/lib/src/driver/driver.dart | 86 +-- .../lib/src/driver/timeline.dart | 10 +- .../lib/src/driver/timeline_summary.dart | 10 +- .../lib/src/extension/extension.dart | 90 ++-- packages/flutter_driver/test/common.dart | 2 +- .../test/flutter_driver_test.dart | 46 +- .../test/src/extension_test.dart | 20 +- .../test/src/timeline_summary_test.dart | 2 +- .../test/src/timeline_test.dart | 2 +- .../flutter_goldens/lib/flutter_goldens.dart | 6 +- .../test/flutter_goldens_test.dart | 28 +- .../flutter_goldens_client/lib/client.dart | 2 +- .../lib/src/l10n/localizations.dart | 158 +++--- .../lib/src/material_localizations.dart | 40 +- .../lib/src/widgets_localizations.dart | 2 +- .../test/basics_test.dart | 24 +- .../test/date_picker_test.dart | 48 +- .../test/date_time_test.dart | 28 +- .../test/override_test.dart | 50 +- .../test/time_picker_test.dart | 36 +- .../test/translations_test.dart | 18 +- .../test/widgets_test.dart | 122 ++--- .../flutter_test/lib/src/accessibility.dart | 22 +- .../flutter_test/lib/src/all_elements.dart | 2 +- packages/flutter_test/lib/src/binding.dart | 142 ++--- packages/flutter_test/lib/src/controller.dart | 18 +- packages/flutter_test/lib/src/finders.dart | 30 +- packages/flutter_test/lib/src/goldens.dart | 10 +- packages/flutter_test/lib/src/matchers.dart | 62 +-- .../lib/src/stack_manipulation.dart | 10 +- .../lib/src/test_async_utils.dart | 26 +- .../lib/src/test_exception_reporter.dart | 2 +- .../flutter_test/lib/src/test_pointer.dart | 14 +- .../flutter_test/lib/src/test_text_input.dart | 12 +- packages/flutter_test/lib/src/test_vsync.dart | 2 +- .../flutter_test/lib/src/widget_tester.dart | 24 +- .../flutter_test/test/accessibility_test.dart | 106 ++-- .../flutter_test_config.dart | 2 +- packages/flutter_test/test/finders_test.dart | 16 +- packages/flutter_test/test/goldens_test.dart | 20 +- packages/flutter_test/test/matchers_test.dart | 122 ++--- .../test/stack_manipulation_test.dart | 4 +- .../test/test_async_utils_test.dart | 8 +- .../test/test_config/config_test_utils.dart | 2 +- .../test/test_text_input_test.dart | 4 +- .../flutter_test/test/widget_tester_test.dart | 124 ++--- .../bin/fuchsia_asset_builder.dart | 4 +- .../flutter_tools/bin/fuchsia_tester.dart | 6 +- packages/flutter_tools/lib/executable.dart | 58 +- packages/flutter_tools/lib/runner.dart | 14 +- .../flutter_tools/lib/src/android/adb.dart | 2 +- .../lib/src/android/android_device.dart | 62 +-- .../lib/src/android/android_emulator.dart | 6 +- .../lib/src/android/android_sdk.dart | 22 +- .../lib/src/android/android_studio.dart | 20 +- .../src/android/android_studio_validator.dart | 24 +- .../lib/src/android/android_workflow.dart | 58 +- .../flutter_tools/lib/src/android/gradle.dart | 28 +- .../lib/src/application_package.dart | 28 +- packages/flutter_tools/lib/src/artifacts.dart | 8 +- packages/flutter_tools/lib/src/asset.dart | 50 +- .../flutter_tools/lib/src/base/build.dart | 14 +- .../flutter_tools/lib/src/base/common.dart | 2 +- .../flutter_tools/lib/src/base/context.dart | 14 +- .../lib/src/base/file_system.dart | 8 +- .../lib/src/base/fingerprint.dart | 14 +- packages/flutter_tools/lib/src/base/io.dart | 2 +- .../flutter_tools/lib/src/base/logger.dart | 26 +- packages/flutter_tools/lib/src/base/net.dart | 6 +- packages/flutter_tools/lib/src/base/os.dart | 24 +- .../flutter_tools/lib/src/base/platform.dart | 2 +- .../flutter_tools/lib/src/base/process.dart | 8 +- .../lib/src/base/process_manager.dart | 2 +- .../flutter_tools/lib/src/base/terminal.dart | 6 +- .../flutter_tools/lib/src/base/utils.dart | 26 +- .../flutter_tools/lib/src/base/version.dart | 14 +- .../flutter_tools/lib/src/build_info.dart | 4 +- packages/flutter_tools/lib/src/bundle.dart | 22 +- packages/flutter_tools/lib/src/cache.dart | 12 +- .../lib/src/commands/analyze.dart | 4 +- .../lib/src/commands/analyze_base.dart | 8 +- .../src/commands/analyze_continuously.dart | 8 +- .../lib/src/commands/analyze_once.dart | 10 +- .../lib/src/commands/attach.dart | 14 +- .../flutter_tools/lib/src/commands/build.dart | 10 +- .../lib/src/commands/build_aot.dart | 2 +- .../lib/src/commands/channel.dart | 4 +- .../lib/src/commands/create.dart | 8 +- .../lib/src/commands/daemon.dart | 64 +-- .../lib/src/commands/doctor.dart | 2 +- .../flutter_tools/lib/src/commands/drive.dart | 2 +- .../lib/src/commands/fuchsia_reload.dart | 18 +- .../lib/src/commands/ide_config.dart | 6 +- .../flutter_tools/lib/src/commands/logs.dart | 2 +- .../lib/src/commands/materialize.dart | 6 +- .../lib/src/commands/packages.dart | 8 +- .../flutter_tools/lib/src/commands/run.dart | 20 +- .../lib/src/commands/screenshot.dart | 2 +- .../flutter_tools/lib/src/commands/test.dart | 4 +- .../flutter_tools/lib/src/commands/trace.dart | 4 +- .../lib/src/commands/update_packages.dart | 72 +-- .../lib/src/commands/upgrade.dart | 4 +- packages/flutter_tools/lib/src/compile.dart | 30 +- .../flutter_tools/lib/src/context_runner.dart | 36 +- .../lib/src/crash_reporting.dart | 14 +- .../flutter_tools/lib/src/dart/analysis.dart | 8 +- .../lib/src/dart/dependencies.dart | 14 +- .../lib/src/dart/package_map.dart | 2 +- packages/flutter_tools/lib/src/dart/pub.dart | 28 +- .../lib/src/dependency_checker.dart | 2 +- packages/flutter_tools/lib/src/devfs.dart | 36 +- packages/flutter_tools/lib/src/device.dart | 26 +- .../flutter_tools/lib/src/disabled_usage.dart | 2 +- packages/flutter_tools/lib/src/doctor.dart | 72 +-- packages/flutter_tools/lib/src/emulator.dart | 16 +- .../lib/src/flutter_manifest.dart | 12 +- .../lib/src/fuchsia/fuchsia_device.dart | 6 +- .../lib/src/intellij/intellij.dart | 12 +- .../flutter_tools/lib/src/ios/cocoapods.dart | 6 +- .../lib/src/ios/code_signing.dart | 8 +- .../flutter_tools/lib/src/ios/devices.dart | 34 +- .../lib/src/ios/ios_emulators.dart | 2 +- .../lib/src/ios/ios_workflow.dart | 42 +- packages/flutter_tools/lib/src/ios/mac.dart | 32 +- .../flutter_tools/lib/src/ios/simulators.dart | 44 +- .../flutter_tools/lib/src/ios/xcodeproj.dart | 12 +- packages/flutter_tools/lib/src/plugins.dart | 10 +- packages/flutter_tools/lib/src/project.dart | 20 +- .../lib/src/protocol_discovery.dart | 8 +- .../lib/src/resident_runner.dart | 24 +- packages/flutter_tools/lib/src/run_cold.dart | 2 +- packages/flutter_tools/lib/src/run_hot.dart | 46 +- .../lib/src/runner/flutter_command.dart | 24 +- .../src/runner/flutter_command_runner.dart | 16 +- packages/flutter_tools/lib/src/services.dart | 2 +- packages/flutter_tools/lib/src/template.dart | 6 +- .../lib/src/test/coverage_collector.dart | 10 +- .../lib/src/test/flutter_platform.dart | 60 +-- .../lib/src/tester/flutter_tester.dart | 22 +- packages/flutter_tools/lib/src/tracing.dart | 8 +- packages/flutter_tools/lib/src/usage.dart | 2 +- packages/flutter_tools/lib/src/version.dart | 14 +- packages/flutter_tools/lib/src/vmservice.dart | 100 ++-- .../lib/src/vmservice_record_replay.dart | 40 +- .../flutter_tools/lib/src/vscode/vscode.dart | 28 +- .../lib/src/vscode/vscode_validator.dart | 12 +- .../flutter_tools/test/analytics_test.dart | 32 +- .../test/android/android_device_test.dart | 18 +- .../test/android/android_emulator_test.dart | 6 +- .../test/android/android_sdk_test.dart | 12 +- .../test/android/android_workflow_test.dart | 40 +- .../test/android/gradle_test.dart | 18 +- .../test/application_package_test.dart | 20 +- .../flutter_tools/test/artifacts_test.dart | 16 +- .../test/asset_bundle_package_fonts_test.dart | 2 +- .../test/asset_bundle_package_test.dart | 4 +- .../flutter_tools/test/asset_bundle_test.dart | 2 +- .../test/asset_bundle_variant_test.dart | 2 +- packages/flutter_tools/test/asset_test.dart | 2 +- .../flutter_tools/test/base/build_test.dart | 76 +-- .../flutter_tools/test/base/context_test.dart | 8 +- .../test/base/file_system_test.dart | 10 +- .../test/base/fingerprint_test.dart | 74 +-- .../flutter_tools/test/base/flags_test.dart | 2 +- packages/flutter_tools/test/base/io_test.dart | 6 +- .../flutter_tools/test/base/logger_test.dart | 18 +- .../flutter_tools/test/base/logs_test.dart | 2 +- .../flutter_tools/test/base/net_test.dart | 22 +- packages/flutter_tools/test/base/os_test.dart | 38 +- .../test/base/os_utils_test.dart | 2 +- .../test/base/terminal_test.dart | 14 +- .../flutter_tools/test/base_utils_test.dart | 2 +- packages/flutter_tools/test/cache_test.dart | 40 +- packages/flutter_tools/test/channel_test.dart | 36 +- .../commands/analyze_continuously_test.dart | 6 +- .../test/commands/analyze_once_test.dart | 14 +- .../test/commands/analyze_test.dart | 2 +- .../test/commands/attach_test.dart | 46 +- .../test/commands/config_test.dart | 6 +- .../test/commands/create_test.dart | 20 +- .../test/commands/daemon_test.dart | 104 ++-- .../test/commands/devices_test.dart | 12 +- .../test/commands/doctor_test.dart | 130 ++--- .../test/commands/drive_test.dart | 18 +- .../test/commands/format_test.dart | 6 +- .../test/commands/fuchsia_reload_test.dart | 6 +- .../test/commands/ide_config_test.dart | 2 +- .../test/commands/install_test.dart | 8 +- .../test/commands/packages_test.dart | 18 +- .../flutter_tools/test/commands/run_test.dart | 2 +- .../test/commands/shell_completion_test.dart | 18 +- .../test/commands/test_test.dart | 4 +- packages/flutter_tools/test/compile_test.dart | 90 ++-- packages/flutter_tools/test/config_test.dart | 2 +- .../test/crash_reporting_test.dart | 30 +- .../flutter_tools/test/dart/pub_get_test.dart | 50 +- .../test/dart_dependencies_test.dart | 12 +- .../test/dependency_checker_test.dart | 16 +- packages/flutter_tools/test/devfs_test.dart | 36 +- packages/flutter_tools/test/device_test.dart | 12 +- .../flutter_tools/test/emulator_test.dart | 42 +- .../test/flutter_manifest_test.dart | 4 +- .../test/forbidden_imports_test.dart | 4 +- packages/flutter_tools/test/hot_test.dart | 20 +- .../expression_evaluation_test.dart | 8 +- .../test/integration/flutter_attach_test.dart | 8 +- .../test/integration/flutter_run_test.dart | 2 +- .../test/integration/hot_reload_test.dart | 6 +- .../test/integration/lifetime_test.dart | 8 +- .../integration/test_data/test_project.dart | 2 +- .../test/integration/test_driver.dart | 28 +- .../test/integration/test_utils.dart | 4 +- .../test/intellij/intellij_test.dart | 14 +- .../test/ios/cocoapods_test.dart | 14 +- .../test/ios/code_signing_test.dart | 124 ++--- .../flutter_tools/test/ios/devices_test.dart | 44 +- .../test/ios/ios_workflow_test.dart | 54 +- packages/flutter_tools/test/ios/mac_test.dart | 36 +- .../test/ios/simulators_test.dart | 78 +-- .../test/ios/xcodeproj_test.dart | 50 +- packages/flutter_tools/test/project_test.dart | 14 +- .../test/protocol_discovery_test.dart | 34 +- .../test/resident_runner_test.dart | 4 +- .../runner/flutter_command_runner_test.dart | 6 +- .../test/runner/flutter_command_test.dart | 24 +- packages/flutter_tools/test/src/common.dart | 12 +- packages/flutter_tools/test/src/context.dart | 32 +- packages/flutter_tools/test/src/mocks.dart | 40 +- packages/flutter_tools/test/stop_test.dart | 12 +- .../test/tester/flutter_tester_test.dart | 32 +- packages/flutter_tools/test/trace_test.dart | 2 +- packages/flutter_tools/test/utils_test.dart | 52 +- packages/flutter_tools/test/version_test.dart | 68 +-- .../examples/drive_todo_list_scroll.dart | 2 +- .../lib/src/common/logging.dart | 10 +- .../lib/src/common/network.dart | 2 +- .../lib/src/dart/dart_vm.dart | 34 +- .../lib/src/fuchsia_remote_connection.dart | 26 +- .../lib/src/runners/ssh_command_runner.dart | 4 +- .../test/common.dart | 2 +- .../test/fuchsia_remote_connection_test.dart | 14 +- .../test/src/dart/dart_vm_test.dart | 34 +- .../src/runners/ssh_command_runner_test.dart | 22 +- 1285 files changed, 26519 insertions(+), 26519 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 41a88b9137..19c137ca2a 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -152,7 +152,7 @@ linter: - unnecessary_const - unnecessary_getters_setters # - unnecessary_lambdas # has false positives: https://github.com/dart-lang/linter/issues/498 - # - unnecessary_new # not yet tested + - unnecessary_new - unnecessary_null_aware_assignments - unnecessary_null_in_if_null_operators - unnecessary_overrides diff --git a/dev/automated_tests/flutter_test/exception_handling_expectation.txt b/dev/automated_tests/flutter_test/exception_handling_expectation.txt index 346aa983bc..a7ec74b22a 100644 --- a/dev/automated_tests/flutter_test/exception_handling_expectation.txt +++ b/dev/automated_tests/flutter_test/exception_handling_expectation.txt @@ -42,7 +42,7 @@ The following message was thrown running a test: Who lives, who dies, who tells your story\? When the exception was thrown, this was the stack: -#[0-9]+ +main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:16:9\) +#[0-9]+ +main. \(.+[/\\]dev[/\\]automated_tests[/\\]flutter_test[/\\]exception_handling_test\.dart:15:105\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) #[0-9]+ +.+ \(package:flutter_test[/\\]src[/\\]binding.dart:[0-9]+:[0-9]+\) diff --git a/dev/automated_tests/flutter_test/exception_handling_test.dart b/dev/automated_tests/flutter_test/exception_handling_test.dart index 04dc1a1fa6..c9f9c42463 100644 --- a/dev/automated_tests/flutter_test/exception_handling_test.dart +++ b/dev/automated_tests/flutter_test/exception_handling_test.dart @@ -10,9 +10,9 @@ void main() { throw 'Who lives, who dies, who tells your story?'; }); testWidgets('Exception handling in test harness - FlutterError', (WidgetTester tester) async { - throw new FlutterError('Who lives, who dies, who tells your story?'); + throw FlutterError('Who lives, who dies, who tells your story?'); }); testWidgets('Exception handling in test harness - uncaught Future error', (WidgetTester tester) async { - new Future.error('Who lives, who dies, who tells your story?'); + Future.error('Who lives, who dies, who tells your story?'); }); } diff --git a/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart b/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart index 9a99f3aae1..ca842db7a9 100644 --- a/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart +++ b/dev/automated_tests/flutter_test/test_async_utils_guarded_test.dart @@ -19,9 +19,9 @@ Future guardedHelper(WidgetTester tester) { } void main() { - new TestTestBinding(); + TestTestBinding(); testWidgets('TestAsyncUtils - custom guarded sections', (WidgetTester tester) async { - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(find.byElementType(Container), isNotNull); guardedHelper(tester); expect(find.byElementType(Container), isNull); diff --git a/dev/automated_tests/flutter_test/test_async_utils_unguarded_test.dart b/dev/automated_tests/flutter_test/test_async_utils_unguarded_test.dart index 3f2ce913e8..29caf7bd5c 100644 --- a/dev/automated_tests/flutter_test/test_async_utils_unguarded_test.dart +++ b/dev/automated_tests/flutter_test/test_async_utils_unguarded_test.dart @@ -16,7 +16,7 @@ Future helperFunction(WidgetTester tester) async { } void main() { - new TestTestBinding(); + TestTestBinding(); testWidgets('TestAsyncUtils - handling unguarded async helper functions', (WidgetTester tester) async { helperFunction(tester); helperFunction(tester); diff --git a/dev/automated_tests/flutter_test/ticker_test.dart b/dev/automated_tests/flutter_test/ticker_test.dart index fb4c1308be..3d819ab6ca 100644 --- a/dev/automated_tests/flutter_test/ticker_test.dart +++ b/dev/automated_tests/flutter_test/ticker_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Does flutter_test catch leaking tickers?', (WidgetTester tester) async { - new Ticker((Duration duration) { })..start(); + Ticker((Duration duration) { })..start(); final ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused'); await BinaryMessages.handlePlatformMessage('flutter/lifecycle', message, (_) {}); diff --git a/dev/automated_tests/test_smoke_test/timeout_fail_test.dart b/dev/automated_tests/test_smoke_test/timeout_fail_test.dart index a425e09f6c..8cd70be8c6 100644 --- a/dev/automated_tests/test_smoke_test/timeout_fail_test.dart +++ b/dev/automated_tests/test_smoke_test/timeout_fail_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('flutter_test timeout logic - addTime - negative', (WidgetTester tester) async { await tester.runAsync(() async { - await new Future.delayed(const Duration(milliseconds: 3500)); + await Future.delayed(const Duration(milliseconds: 3500)); }, additionalTime: const Duration(milliseconds: 200)); }); } diff --git a/dev/automated_tests/test_smoke_test/timeout_pass_test.dart b/dev/automated_tests/test_smoke_test/timeout_pass_test.dart index fa50ba70fd..8aec967b94 100644 --- a/dev/automated_tests/test_smoke_test/timeout_pass_test.dart +++ b/dev/automated_tests/test_smoke_test/timeout_pass_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('flutter_test timeout logic - addTime - positive', (WidgetTester tester) async { await tester.runAsync(() async { - await new Future.delayed(const Duration(milliseconds: 2500)); // must be longer than default timeout. + await Future.delayed(const Duration(milliseconds: 2500)); // must be longer than default timeout. }, additionalTime: const Duration(milliseconds: 2000)); // default timeout is 2s, so this makes it 4s. }); } diff --git a/dev/benchmarks/complex_layout/lib/main.dart b/dev/benchmarks/complex_layout/lib/main.dart index cd22c16d02..9b95c744f9 100644 --- a/dev/benchmarks/complex_layout/lib/main.dart +++ b/dev/benchmarks/complex_layout/lib/main.dart @@ -7,7 +7,7 @@ import 'package:flutter/scheduler.dart' show timeDilation; void main() { runApp( - new ComplexLayoutApp() + ComplexLayoutApp() ); } @@ -15,7 +15,7 @@ enum ScrollMode { complex, tile } class ComplexLayoutApp extends StatefulWidget { @override - ComplexLayoutAppState createState() => new ComplexLayoutAppState(); + ComplexLayoutAppState createState() => ComplexLayoutAppState(); static ComplexLayoutAppState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher()); } @@ -23,8 +23,8 @@ class ComplexLayoutApp extends StatefulWidget { class ComplexLayoutAppState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - theme: lightTheme ? new ThemeData.light() : new ThemeData.dark(), + return MaterialApp( + theme: lightTheme ? ThemeData.light() : ThemeData.dark(), title: 'Advanced Layout', home: scrollMode == ScrollMode.complex ? const ComplexLayout() : const TileScrollLayout()); } @@ -57,18 +57,18 @@ class TileScrollLayout extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Tile Scrolling Layout')), - body: new ListView.builder( + return Scaffold( + appBar: AppBar(title: const Text('Tile Scrolling Layout')), + body: ListView.builder( key: const Key('tiles-scroll'), itemCount: 200, itemBuilder: (BuildContext context, int index) { - return new Padding( + return Padding( padding: const EdgeInsets.all(5.0), - child: new Material( + child: Material( elevation: (index % 5 + 1).toDouble(), color: Colors.white, - child: new IconBar(), + child: IconBar(), ), ); } @@ -82,7 +82,7 @@ class ComplexLayout extends StatefulWidget { const ComplexLayout({ Key key }) : super(key: key); @override - ComplexLayoutState createState() => new ComplexLayoutState(); + ComplexLayoutState createState() => ComplexLayoutState(); static ComplexLayoutState of(BuildContext context) => context.ancestorStateOfType(const TypeMatcher()); } @@ -90,34 +90,34 @@ class ComplexLayout extends StatefulWidget { class ComplexLayoutState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Advanced Layout'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.create), tooltip: 'Search', onPressed: () { print('Pressed search'); }, ), - new TopBarMenu() + TopBarMenu() ] ), - body: new Column( + body: Column( children: [ - new Expanded( - child: new ListView.builder( + Expanded( + child: ListView.builder( key: const Key('complex-scroll'), // this key is used by the driver test itemBuilder: (BuildContext context, int index) { if (index % 2 == 0) - return new FancyImageItem(index, key: new PageStorageKey(index)); + return FancyImageItem(index, key: PageStorageKey(index)); else - return new FancyGalleryItem(index, key: new PageStorageKey(index)); + return FancyGalleryItem(index, key: PageStorageKey(index)); }, ) ), - new BottomBar(), + BottomBar(), ], ), drawer: const GalleryDrawer(), @@ -128,7 +128,7 @@ class ComplexLayoutState extends State { class TopBarMenu extends StatelessWidget { @override Widget build(BuildContext context) { - return new PopupMenuButton( + return PopupMenuButton( onSelected: (String value) { print('Selected: $value'); }, itemBuilder: (BuildContext context) => >[ const PopupMenuItem( @@ -185,14 +185,14 @@ class MenuItemWithIcon extends StatelessWidget { @override Widget build(BuildContext context) { - return new Row( + return Row( children: [ - new Icon(icon), - new Padding( + Icon(icon), + Padding( padding: const EdgeInsets.only(left: 8.0, right: 8.0), - child: new Text(title) + child: Text(title) ), - new Text(subtitle, style: Theme.of(context).textTheme.caption) + Text(subtitle, style: Theme.of(context).textTheme.caption) ] ); } @@ -205,18 +205,18 @@ class FancyImageItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new ListBody( + return ListBody( children: [ - new UserHeader('Ali Connors $index'), - new ItemDescription(), - new ItemImageBox(), - new InfoBar(), + UserHeader('Ali Connors $index'), + ItemDescription(), + ItemImageBox(), + InfoBar(), const Padding( padding: EdgeInsets.symmetric(horizontal: 8.0), child: Divider() ), - new IconBar(), - new FatDivider() + IconBar(), + FatDivider() ] ); } @@ -228,17 +228,17 @@ class FancyGalleryItem extends StatelessWidget { final int index; @override Widget build(BuildContext context) { - return new ListBody( + return ListBody( children: [ const UserHeader('Ali Connors'), - new ItemGalleryBox(index), - new InfoBar(), + ItemGalleryBox(index), + InfoBar(), const Padding( padding: EdgeInsets.symmetric(horizontal: 8.0), child: Divider() ), - new IconBar(), - new FatDivider() + IconBar(), + FatDivider() ] ); } @@ -247,13 +247,13 @@ class FancyGalleryItem extends StatelessWidget { class InfoBar extends StatelessWidget { @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: const EdgeInsets.all(8.0), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ const MiniIconWithText(Icons.thumb_up, '42'), - new Text('3 Comments', style: Theme.of(context).textTheme.caption) + Text('3 Comments', style: Theme.of(context).textTheme.caption) ] ) ); @@ -263,9 +263,9 @@ class InfoBar extends StatelessWidget { class IconBar extends StatelessWidget { @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: const EdgeInsets.only(left: 16.0, right: 16.0), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: const [ IconWithText(Icons.thumb_up, 'Like'), @@ -285,14 +285,14 @@ class IconWithText extends StatelessWidget { @override Widget build(BuildContext context) { - return new Row( + return Row( mainAxisSize: MainAxisSize.min, children: [ - new IconButton( - icon: new Icon(icon), + IconButton( + icon: Icon(icon), onPressed: () { print('Pressed $title button'); } ), - new Text(title) + Text(title) ] ); } @@ -306,22 +306,22 @@ class MiniIconWithText extends StatelessWidget { @override Widget build(BuildContext context) { - return new Row( + return Row( mainAxisSize: MainAxisSize.min, children: [ - new Padding( + Padding( padding: const EdgeInsets.only(right: 8.0), - child: new Container( + child: Container( width: 16.0, height: 16.0, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: Theme.of(context).primaryColor, shape: BoxShape.circle ), - child: new Icon(icon, color: Colors.white, size: 12.0) + child: Icon(icon, color: Colors.white, size: 12.0) ) ), - new Text(title, style: Theme.of(context).textTheme.caption) + Text(title, style: Theme.of(context).textTheme.caption) ] ); } @@ -330,7 +330,7 @@ class MiniIconWithText extends StatelessWidget { class FatDivider extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( height: 8.0, color: Theme.of(context).dividerColor, ); @@ -344,9 +344,9 @@ class UserHeader extends StatelessWidget { @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: const EdgeInsets.all(8.0), - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Padding( @@ -357,29 +357,29 @@ class UserHeader extends StatelessWidget { height: 32.0 ) ), - new Expanded( - child: new Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new RichText(text: new TextSpan( + RichText(text: TextSpan( style: Theme.of(context).textTheme.body1, children: [ - new TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)), + TextSpan(text: userName, style: const TextStyle(fontWeight: FontWeight.bold)), const TextSpan(text: ' shared a new '), const TextSpan(text: 'photo', style: TextStyle(fontWeight: FontWeight.bold)) ] )), - new Row( + Row( children: [ - new Text('Yesterday at 11:55 • ', style: Theme.of(context).textTheme.caption), - new Icon(Icons.people, size: 16.0, color: Theme.of(context).textTheme.caption.color) + Text('Yesterday at 11:55 • ', style: Theme.of(context).textTheme.caption), + Icon(Icons.people, size: 16.0, color: Theme.of(context).textTheme.caption.color) ] ) ] ) ), - new TopBarMenu() + TopBarMenu() ] ) ); @@ -399,13 +399,13 @@ class ItemDescription extends StatelessWidget { class ItemImageBox extends StatelessWidget { @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: const EdgeInsets.all(8.0), - child: new Card( - child: new Column( + child: Card( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Stack( + Stack( children: [ const SizedBox( height: 230.0, @@ -413,29 +413,29 @@ class ItemImageBox extends StatelessWidget { image: AssetImage('packages/flutter_gallery_assets/places/india_chettinad_silk_maker.png') ) ), - new Theme( - data: new ThemeData.dark(), - child: new Row( + Theme( + data: ThemeData.dark(), + child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - new IconButton( + IconButton( icon: const Icon(Icons.edit), onPressed: () { print('Pressed edit button'); } ), - new IconButton( + IconButton( icon: const Icon(Icons.zoom_in), onPressed: () { print('Pressed zoom button'); } ), ] ) ), - new Positioned( + Positioned( bottom: 4.0, left: 4.0, - child: new Container( - decoration: new BoxDecoration( + child: Container( + decoration: BoxDecoration( color: Colors.black54, - borderRadius: new BorderRadius.circular(2.0) + borderRadius: BorderRadius.circular(2.0) ), padding: const EdgeInsets.all(4.0), child: const RichText( @@ -457,14 +457,14 @@ class ItemImageBox extends StatelessWidget { ] ) , - new Padding( + Padding( padding: const EdgeInsets.all(8.0), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Text('Artisans of Southern India', style: Theme.of(context).textTheme.body2), - new Text('Silk Spinners', style: Theme.of(context).textTheme.body1), - new Text('Sivaganga, Tamil Nadu', style: Theme.of(context).textTheme.caption) + Text('Artisans of Southern India', style: Theme.of(context).textTheme.body2), + Text('Silk Spinners', style: Theme.of(context).textTheme.body1), + Text('Sivaganga, Tamil Nadu', style: Theme.of(context).textTheme.caption) ] ) ) @@ -486,44 +486,44 @@ class ItemGalleryBox extends StatelessWidget { 'A', 'B', 'C', 'D' ]; - return new SizedBox( + return SizedBox( height: 200.0, - child: new DefaultTabController( + child: DefaultTabController( length: tabNames.length, - child: new Column( + child: Column( children: [ - new Expanded( - child: new TabBarView( + Expanded( + child: TabBarView( children: tabNames.map((String tabName) { - return new Container( - key: new PageStorageKey(tabName), - child: new Padding( + return Container( + key: PageStorageKey(tabName), + child: Padding( padding: const EdgeInsets.all(8.0), - child: new Card( - child: new Column( + child: Card( + child: Column( children: [ - new Expanded( - child: new Container( + Expanded( + child: Container( color: Theme.of(context).primaryColor, - child: new Center( - child: new Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white)), + child: Center( + child: Text(tabName, style: Theme.of(context).textTheme.headline.copyWith(color: Colors.white)), ) ) ), - new Row( + Row( children: [ - new IconButton( + IconButton( icon: const Icon(Icons.share), onPressed: () { print('Pressed share'); }, ), - new IconButton( + IconButton( icon: const Icon(Icons.event), onPressed: () { print('Pressed event'); }, ), - new Expanded( - child: new Padding( + Expanded( + child: Padding( padding: const EdgeInsets.only(left: 8.0), - child: new Text('This is item $tabName'), + child: Text('This is item $tabName'), ) ) ] @@ -536,7 +536,7 @@ class ItemGalleryBox extends StatelessWidget { }).toList() ) ), - new Container( + Container( child: const TabPageSelector() ) ] @@ -549,16 +549,16 @@ class ItemGalleryBox extends StatelessWidget { class BottomBar extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( - decoration: new BoxDecoration( - border: new Border( - top: new BorderSide( + return Container( + decoration: BoxDecoration( + border: Border( + top: BorderSide( color: Theme.of(context).dividerColor, width: 1.0 ) ) ), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: const [ BottomBarButton(Icons.new_releases, 'News'), @@ -580,15 +580,15 @@ class BottomBarButton extends StatelessWidget { @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: const EdgeInsets.all(8.0), - child: new Column( + child: Column( children: [ - new IconButton( - icon: new Icon(icon), + IconButton( + icon: Icon(icon), onPressed: () { print('Pressed: $title'); } ), - new Text(title, style: Theme.of(context).textTheme.caption) + Text(title, style: Theme.of(context).textTheme.caption) ] ) ); @@ -609,49 +609,49 @@ class GalleryDrawer extends StatelessWidget { @override Widget build(BuildContext context) { final ScrollMode currentMode = ComplexLayoutApp.of(context).scrollMode; - return new Drawer( + return Drawer( // Note: for real apps, see the Gallery material Drawer demo. More // typically, a drawer would have a fixed header with a scrolling body // below it. - child: new ListView( + child: ListView( key: const PageStorageKey('gallery-drawer'), padding: EdgeInsets.zero, children: [ - new FancyDrawerHeader(), - new ListTile( + FancyDrawerHeader(), + ListTile( key: const Key('scroll-switcher'), onTap: () { _changeScrollMode(context, currentMode == ScrollMode.complex ? ScrollMode.tile : ScrollMode.complex); }, - trailing: new Text(currentMode == ScrollMode.complex ? 'Tile' : 'Complex') + trailing: Text(currentMode == ScrollMode.complex ? 'Tile' : 'Complex') ), - new ListTile( + ListTile( leading: const Icon(Icons.brightness_5), title: const Text('Light'), onTap: () { _changeTheme(context, true); }, selected: ComplexLayoutApp.of(context).lightTheme, - trailing: new Radio( + trailing: Radio( value: true, groupValue: ComplexLayoutApp.of(context).lightTheme, onChanged: (bool value) { _changeTheme(context, value); } ), ), - new ListTile( + ListTile( leading: const Icon(Icons.brightness_7), title: const Text('Dark'), onTap: () { _changeTheme(context, false); }, selected: !ComplexLayoutApp.of(context).lightTheme, - trailing: new Radio( + trailing: Radio( value: false, groupValue: ComplexLayoutApp.of(context).lightTheme, onChanged: (bool value) { _changeTheme(context, value); }, ), ), const Divider(), - new ListTile( + ListTile( leading: const Icon(Icons.hourglass_empty), title: const Text('Animate Slowly'), selected: timeDilation != 1.0, onTap: () { ComplexLayoutApp.of(context).toggleAnimationSpeed(); }, - trailing: new Checkbox( + trailing: Checkbox( value: timeDilation != 1.0, onChanged: (bool value) { ComplexLayoutApp.of(context).toggleAnimationSpeed(); } ), @@ -665,7 +665,7 @@ class GalleryDrawer extends StatelessWidget { class FancyDrawerHeader extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.purple, height: 200.0, child: const SafeArea( diff --git a/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart b/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart index fb0243ca49..b6a5c6fa97 100644 --- a/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart +++ b/dev/benchmarks/complex_layout/test_driver/scroll_perf_test.dart @@ -25,7 +25,7 @@ void main() { // period of increased load on the device. Without this delay, the // benchmark has greater noise. // See: https://github.com/flutter/flutter/issues/19434 - await new Future.delayed(const Duration(milliseconds: 250)); + await Future.delayed(const Duration(milliseconds: 250)); final Timeline timeline = await driver.traceAction(() async { // Find the scrollable stock list final SerializableFinder list = find.byValueKey(listKey); @@ -34,17 +34,17 @@ void main() { // Scroll down for (int i = 0; i < 5; i += 1) { await driver.scroll(list, 0.0, -300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } // Scroll up for (int i = 0; i < 5; i += 1) { await driver.scroll(list, 0.0, 300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } }); - final TimelineSummary summary = new TimelineSummary.summarize(timeline); + final TimelineSummary summary = TimelineSummary.summarize(timeline); summary.writeSummaryToFile(summaryName, pretty: true); summary.writeTimelineToFile(summaryName, pretty: true); } diff --git a/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart b/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart index f216a8470d..9a5a78ab7a 100644 --- a/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart +++ b/dev/benchmarks/complex_layout/test_driver/semantics_perf_test.dart @@ -25,7 +25,7 @@ void main() { test('inital tree creation', () async { // Let app become fully idle. - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); final Timeline timeline = await driver.traceAction(() async { expect(await driver.setSemantics(true), isTrue); @@ -37,7 +37,7 @@ void main() { final Duration semanticsTreeCreation = semanticsEvents.first.duration; final String jsonEncoded = json.encode({'initialSemanticsTreeCreation': semanticsTreeCreation.inMilliseconds}); - new File(p.join(testOutputsDirectory, 'complex_layout_semantics_perf.json')).writeAsStringSync(jsonEncoded); + File(p.join(testOutputsDirectory, 'complex_layout_semantics_perf.json')).writeAsStringSync(jsonEncoded); }); }); } diff --git a/dev/benchmarks/complex_layout/test_memory/scroll_perf.dart b/dev/benchmarks/complex_layout/test_memory/scroll_perf.dart index c42f8b005b..98d2aeb0fa 100644 --- a/dev/benchmarks/complex_layout/test_memory/scroll_perf.dart +++ b/dev/benchmarks/complex_layout/test_memory/scroll_perf.dart @@ -20,16 +20,16 @@ const int maxIterations = 4; const Duration pauses = Duration(milliseconds: 500); Future main() async { - final Completer ready = new Completer(); - runApp(new GestureDetector( + final Completer ready = Completer(); + runApp(GestureDetector( onTap: () { debugPrint('Received tap.'); ready.complete(); }, behavior: HitTestBehavior.opaque, - child: new IgnorePointer( + child: IgnorePointer( ignoring: true, - child: new ComplexLayoutApp(), + child: ComplexLayoutApp(), ), )); await SchedulerBinding.instance.endOfFrame; @@ -37,35 +37,35 @@ Future main() async { /// Wait 50ms to allow the GPU thread to actually put up the frame. (The /// endOfFrame future ends when we send the data to the engine, before the GPU /// thread has had a chance to rasterize, etc.) - await new Future.delayed(const Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); debugPrint('==== MEMORY BENCHMARK ==== READY ===='); await ready.future; // waits for tap sent by devicelab task debugPrint('Continuing...'); // remove onTap handler, enable pointer events for app - runApp(new GestureDetector( - child: new IgnorePointer( + runApp(GestureDetector( + child: IgnorePointer( ignoring: false, - child: new ComplexLayoutApp(), + child: ComplexLayoutApp(), ), )); await SchedulerBinding.instance.endOfFrame; - final WidgetController controller = new LiveWidgetController(WidgetsBinding.instance); + final WidgetController controller = LiveWidgetController(WidgetsBinding.instance); // Scroll down for (int iteration = 0; iteration < maxIterations; iteration += 1) { debugPrint('Scroll down... $iteration/$maxIterations'); await controller.fling(find.byType(ListView), const Offset(0.0, -700.0), speed); - await new Future.delayed(pauses); + await Future.delayed(pauses); } // Scroll up for (int iteration = 0; iteration < maxIterations; iteration += 1) { debugPrint('Scroll up... $iteration/$maxIterations'); await controller.fling(find.byType(ListView), const Offset(0.0, 300.0), speed); - await new Future.delayed(pauses); + await Future.delayed(pauses); } debugPrint('==== MEMORY BENCHMARK ==== DONE ===='); diff --git a/dev/benchmarks/microbenchmarks/lib/common.dart b/dev/benchmarks/microbenchmarks/lib/common.dart index 2a75dc3814..399d015e4e 100644 --- a/dev/benchmarks/microbenchmarks/lib/common.dart +++ b/dev/benchmarks/microbenchmarks/lib/common.dart @@ -32,7 +32,7 @@ class BenchmarkResultPrinter { /// [name] is a computer-readable name of the result used as a key in the JSON /// serialization of the results. void addResult({ @required String description, @required double value, @required String unit, @required String name }) { - _results.add(new _BenchmarkResult(description, value, unit, name)); + _results.add(_BenchmarkResult(description, value, unit, name)); } /// Prints the results added via [addResult] to standard output, once as JSON @@ -58,7 +58,7 @@ class BenchmarkResultPrinter { } String _printPlainText() { - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); for (_BenchmarkResult result in _results) { buf.writeln('${result.description}: ${result.value.toStringAsFixed(1)} ${result.unit}'); } diff --git a/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart b/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart index 6c9cf68610..dd1d9a73cb 100644 --- a/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/gestures/velocity_tracker_bench.dart @@ -10,8 +10,8 @@ import 'data/velocity_tracker_data.dart'; const int _kNumIters = 10000; void main() { - final VelocityTracker tracker = new VelocityTracker(); - final Stopwatch watch = new Stopwatch(); + final VelocityTracker tracker = VelocityTracker(); + final Stopwatch watch = Stopwatch(); print('Velocity tracker benchmark...'); watch.start(); for (int i = 0; i < _kNumIters; i += 1) { @@ -24,7 +24,7 @@ void main() { } watch.stop(); - final BenchmarkResultPrinter printer = new BenchmarkResultPrinter(); + final BenchmarkResultPrinter printer = BenchmarkResultPrinter(); printer.addResult( description: 'Velocity tracker', value: watch.elapsedMicroseconds / _kNumIters, diff --git a/dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart b/dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart index 59fe86cc2b..566359a471 100644 --- a/dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/stocks/animation_bench.dart @@ -37,9 +37,9 @@ Future main() async { assert(false); // don't run this in checked mode! Use --release. stock_data.StockData.actuallyFetchData = false; - final Stopwatch wallClockWatch = new Stopwatch(); - final Stopwatch cpuWatch = new Stopwatch(); - new BenchmarkingBinding(cpuWatch); + final Stopwatch wallClockWatch = Stopwatch(); + final Stopwatch cpuWatch = Stopwatch(); + BenchmarkingBinding(cpuWatch); int totalOpenFrameElapsedMicroseconds = 0; int totalOpenIterationCount = 0; @@ -80,7 +80,7 @@ Future main() async { } }); - final BenchmarkResultPrinter printer = new BenchmarkResultPrinter(); + final BenchmarkResultPrinter printer = BenchmarkResultPrinter(); printer.addResult( description: 'Stock animation', value: wallClockWatch.elapsedMicroseconds / (1000 * 1000), diff --git a/dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart b/dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart index dafb6132c6..a5795104f7 100644 --- a/dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/stocks/build_bench.dart @@ -23,7 +23,7 @@ Future main() async { // the engine, so that the engine does not interfere with our timings. final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); - final Stopwatch watch = new Stopwatch(); + final Stopwatch watch = Stopwatch(); int iterations = 0; await benchmarkWidgets((WidgetTester tester) async { @@ -46,7 +46,7 @@ Future main() async { // frames are missed, etc. // We use Timer.run to ensure there's a microtask flush in between // the two calls below. - Timer.run(() { ui.window.onBeginFrame(new Duration(milliseconds: iterations * 16)); }); + Timer.run(() { ui.window.onBeginFrame(Duration(milliseconds: iterations * 16)); }); Timer.run(() { ui.window.onDrawFrame(); }); await tester.idle(); // wait until the frame has run (also uses Timer.run) iterations += 1; @@ -54,7 +54,7 @@ Future main() async { watch.stop(); }); - final BenchmarkResultPrinter printer = new BenchmarkResultPrinter(); + final BenchmarkResultPrinter printer = BenchmarkResultPrinter(); printer.addResult( description: 'Stock build', value: watch.elapsedMicroseconds / iterations, diff --git a/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart b/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart index c08031eb24..fe9c1c0625 100644 --- a/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart +++ b/dev/benchmarks/microbenchmarks/lib/stocks/layout_bench.dart @@ -22,7 +22,7 @@ Future main() async { // the engine, so that the engine does not interfere with our timings. final LiveTestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); - final Stopwatch watch = new Stopwatch(); + final Stopwatch watch = Stopwatch(); int iterations = 0; await benchmarkWidgets((WidgetTester tester) async { @@ -37,8 +37,8 @@ Future main() async { ui.window.onBeginFrame = null; ui.window.onDrawFrame = null; - final TestViewConfiguration big = new TestViewConfiguration(size: const Size(360.0, 640.0)); - final TestViewConfiguration small = new TestViewConfiguration(size: const Size(355.0, 635.0)); + final TestViewConfiguration big = TestViewConfiguration(size: const Size(360.0, 640.0)); + final TestViewConfiguration small = TestViewConfiguration(size: const Size(355.0, 635.0)); final RenderView renderView = WidgetsBinding.instance.renderView; binding.framePolicy = LiveTestWidgetsFlutterBindingFramePolicy.fullyLive; @@ -51,7 +51,7 @@ Future main() async { // frames are missed, etc. // We use Timer.run to ensure there's a microtask flush in between // the two calls below. - Timer.run(() { binding.handleBeginFrame(new Duration(milliseconds: iterations * 16)); }); + Timer.run(() { binding.handleBeginFrame(Duration(milliseconds: iterations * 16)); }); Timer.run(() { binding.handleDrawFrame(); }); await tester.idle(); // wait until the frame has run (also uses Timer.run) iterations += 1; @@ -59,7 +59,7 @@ Future main() async { watch.stop(); }); - final BenchmarkResultPrinter printer = new BenchmarkResultPrinter(); + final BenchmarkResultPrinter printer = BenchmarkResultPrinter(); printer.addResult( description: 'Stock layout', value: watch.elapsedMicroseconds / iterations, diff --git a/dev/bots/analyze-sample-code.dart b/dev/bots/analyze-sample-code.dart index 8662d33a0c..341e03e251 100644 --- a/dev/bots/analyze-sample-code.dart +++ b/dev/bots/analyze-sample-code.dart @@ -58,7 +58,7 @@ class Line { Line operator +(int count) { if (count == 0) return this; - return new Line(filename, line + count, indent); + return Line(filename, line + count, indent); } @override String toString([int column]) { @@ -87,7 +87,7 @@ class Section { } } List get lines { - final List result = new List.generate(code.length, (int index) => start + index); + final List result = List.generate(code.length, (int index) => start + index); if (preamble != null) result.insert(0, null); if (postamble != null) @@ -105,15 +105,15 @@ Future main(List arguments) async { bool keepMain = false; final List buffer = []; try { - final File mainDart = new File(path.join(tempDir.path, 'main.dart')); - final File pubSpec = new File(path.join(tempDir.path, 'pubspec.yaml')); - final File analysisOptions = new File(path.join(tempDir.path, 'analysis_options.yaml')); + final File mainDart = File(path.join(tempDir.path, 'main.dart')); + final File pubSpec = File(path.join(tempDir.path, 'pubspec.yaml')); + final File analysisOptions = File(path.join(tempDir.path, 'analysis_options.yaml')); Directory flutterPackage; if (arguments.length == 1) { // Used for testing. - flutterPackage = new Directory(arguments.single); + flutterPackage = Directory(arguments.single); } else { - flutterPackage = new Directory(path.join(_flutterRoot, 'packages', 'flutter', 'lib')); + flutterPackage = Directory(path.join(_flutterRoot, 'packages', 'flutter', 'lib')); } final List
sections =
[]; int sampleCodeSections = 0; @@ -161,7 +161,7 @@ Future main(List arguments) async { } } else if (trimmedLine == '/// ```dart') { assert(block.isEmpty); - startLine = new Line(file.path, lineNumber + 1, line.indexOf(kDartDocPrefixWithSpace) + kDartDocPrefixWithSpace.length); + startLine = Line(file.path, lineNumber + 1, line.indexOf(kDartDocPrefixWithSpace) + kDartDocPrefixWithSpace.length); inDart = true; foundDart = true; } @@ -170,7 +170,7 @@ Future main(List arguments) async { if (!inSampleSection) { if (line == '// Examples can assume:') { assert(block.isEmpty); - startLine = new Line(file.path, lineNumber + 1, 3); + startLine = Line(file.path, lineNumber + 1, 3); inPreamble = true; } else if (trimmedLine == '/// ## Sample code' || trimmedLine.startsWith('/// ## Sample code:') || @@ -199,7 +199,7 @@ Future main(List arguments) async { } } buffer.add(''); - final List lines = new List.filled(buffer.length, null, growable: true); + final List lines = List.filled(buffer.length, null, growable: true); for (Section section in sections) { buffer.addAll(section.strings); lines.addAll(section.lines); @@ -247,7 +247,7 @@ linter: errors.removeAt(0); int errorCount = 0; final String kBullet = Platform.isWindows ? ' - ' : ' • '; - final RegExp errorPattern = new RegExp('^ +([a-z]+)$kBullet(.+)$kBullet(.+):([0-9]+):([0-9]+)$kBullet([-a-z_]+)\$', caseSensitive: false); + final RegExp errorPattern = RegExp('^ +([a-z]+)$kBullet(.+)$kBullet(.+):([0-9]+):([0-9]+)$kBullet([-a-z_]+)\$', caseSensitive: false); for (String error in errors) { final Match parts = errorPattern.matchAsPrefix(error); if (parts != null) { @@ -315,7 +315,7 @@ linter: exit(exitCode); } -final RegExp _constructorRegExp = new RegExp(r'[A-Z][a-zA-Z0-9<>.]*\('); +final RegExp _constructorRegExp = RegExp(r'[A-Z][a-zA-Z0-9<>.]*\('); int _expressionId = 0; @@ -324,12 +324,12 @@ void processBlock(Line line, List block, List
sections) { throw '$line: Empty ```dart block in sample code.'; if (block.first.startsWith('new ') || block.first.startsWith('const ') || block.first.startsWith(_constructorRegExp)) { _expressionId += 1; - sections.add(new Section(line, 'dynamic expression$_expressionId = ', block.toList(), ';')); + sections.add(Section(line, 'dynamic expression$_expressionId = ', block.toList(), ';')); } else if (block.first.startsWith('await ')) { _expressionId += 1; - sections.add(new Section(line, 'Future expression$_expressionId() async { ', block.toList(), ' }')); + sections.add(Section(line, 'Future expression$_expressionId() async { ', block.toList(), ' }')); } else if (block.first.startsWith('class ') || block.first.startsWith('enum ')) { - sections.add(new Section(line, null, block.toList(), null)); + sections.add(Section(line, null, block.toList(), null)); } else { final List buffer = []; int subblocks = 0; @@ -354,7 +354,7 @@ void processBlock(Line line, List block, List
sections) { if (subline != null) processBlock(subline, buffer, sections); } else { - sections.add(new Section(line, null, block.toList(), null)); + sections.add(Section(line, null, block.toList(), null)); } } block.clear(); diff --git a/dev/bots/analyze.dart b/dev/bots/analyze.dart index 7ceeda1448..e9e8a7617f 100644 --- a/dev/bots/analyze.dart +++ b/dev/bots/analyze.dart @@ -94,7 +94,7 @@ Future _verifyInternationalizations() async { ); final String localizationsFile = path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'localizations.dart'); - final String expectedResult = await new File(localizationsFile).readAsString(); + final String expectedResult = await File(localizationsFile).readAsString(); if (genResult.stdout.trim() != expectedResult.trim()) { stderr @@ -153,7 +153,7 @@ Future _checkForTrailingSpaces() async { // Only include files that actually exist, so that we don't try and grep for // nonexistent files, which can occur when files are deleted or moved. final List changedFiles = changedFilesResult.stdout.split('\n').where((String filename) { - return new File(filename).existsSync(); + return File(filename).existsSync(); }).toList(); if (changedFiles.isNotEmpty) { await runCommand('grep', @@ -197,7 +197,7 @@ Future _evalCommand(String executable, List arguments, { } printProgress('RUNNING', relativeWorkingDir, commandDescription); - final DateTime start = new DateTime.now(); + final DateTime start = DateTime.now(); final Process process = await Process.start(executable, arguments, workingDirectory: workingDirectory, environment: environment, @@ -206,7 +206,7 @@ Future _evalCommand(String executable, List arguments, { final Future>> savedStdout = process.stdout.toList(); final Future>> savedStderr = process.stderr.toList(); final int exitCode = await process.exitCode; - final EvalResult result = new EvalResult( + final EvalResult result = EvalResult( stdout: utf8.decode((await savedStdout).expand((List ints) => ints).toList()), stderr: utf8.decode((await savedStderr).expand((List ints) => ints).toList()), exitCode: exitCode, @@ -240,7 +240,7 @@ Future _runFlutterAnalyze(String workingDirectory, { Future _verifyNoTestPackageImports(String workingDirectory) async { // TODO(ianh): Remove this whole test once https://github.com/dart-lang/matcher/issues/98 is fixed. final List shims = []; - final List errors = new Directory(workingDirectory) + final List errors = Directory(workingDirectory) .listSync(recursive: true) .where((FileSystemEntity entity) { return entity is File && entity.path.endsWith('.dart'); @@ -320,11 +320,11 @@ Future _verifyNoBadImportsInFlutter(String workingDirectory) async { final String libPath = path.join(workingDirectory, 'packages', 'flutter', 'lib'); final String srcPath = path.join(workingDirectory, 'packages', 'flutter', 'lib', 'src'); // Verify there's one libPath/*.dart for each srcPath/*/. - final List packages = new Directory(libPath).listSync() + final List packages = Directory(libPath).listSync() .where((FileSystemEntity entity) => entity is File && path.extension(entity.path) == '.dart') .map((FileSystemEntity entity) => path.basenameWithoutExtension(entity.path)) .toList()..sort(); - final List directories = new Directory(srcPath).listSync() + final List directories = Directory(srcPath).listSync() .whereType() .map((Directory entity) => path.basename(entity.path)) .toList()..sort(); @@ -384,14 +384,14 @@ bool _matches(List a, List b) { return true; } -final RegExp _importPattern = new RegExp(r"import 'package:flutter/([^.]+)\.dart'"); -final RegExp _importMetaPattern = new RegExp(r"import 'package:meta/meta.dart'"); +final RegExp _importPattern = RegExp(r"import 'package:flutter/([^.]+)\.dart'"); +final RegExp _importMetaPattern = RegExp(r"import 'package:meta/meta.dart'"); Set _findDependencies(String srcPath, List errors, { bool checkForMeta = false }) { - return new Directory(srcPath).listSync(recursive: true).where((FileSystemEntity entity) { + return Directory(srcPath).listSync(recursive: true).where((FileSystemEntity entity) { return entity is File && path.extension(entity.path) == '.dart'; }).map>((FileSystemEntity entity) { - final Set result = new Set(); + final Set result = Set(); final File file = entity; for (String line in file.readAsLinesSync()) { Match match = _importPattern.firstMatch(line); @@ -409,7 +409,7 @@ Set _findDependencies(String srcPath, List errors, { bool checkF } return result; }).reduce((Set value, Set element) { - value ??= new Set(); + value ??= Set(); value.addAll(element); return value; }); @@ -424,7 +424,7 @@ List _deepSearch(Map> map, T start, [ Set seen ]) { final List result = _deepSearch( map, key, - (seen == null ? new Set.from([start]) : new Set.from(seen))..add(key), + (seen == null ? Set.from([start]) : Set.from(seen))..add(key), ); if (result != null) { result.insert(0, start); @@ -441,7 +441,7 @@ List _deepSearch(Map> map, T start, [ Set seen ]) { Future _verifyNoBadImportsInFlutterTools(String workingDirectory) async { final List errors = []; - for (FileSystemEntity entity in new Directory(path.join(workingDirectory, 'packages', 'flutter_tools', 'lib')) + for (FileSystemEntity entity in Directory(path.join(workingDirectory, 'packages', 'flutter_tools', 'lib')) .listSync(recursive: true) .where((FileSystemEntity entity) => entity is File && path.extension(entity.path) == '.dart')) { final File file = entity; @@ -464,7 +464,7 @@ Future _verifyNoBadImportsInFlutterTools(String workingDirectory) async { } Future _verifyGeneratedPluginRegistrants(String flutterRoot) async { - final Directory flutterRootDir = new Directory(flutterRoot); + final Directory flutterRootDir = Directory(flutterRoot); final Map> packageToRegistrants = >{}; @@ -478,7 +478,7 @@ Future _verifyGeneratedPluginRegistrants(String flutterRoot) async { } } - final Set outOfDate = new Set(); + final Set outOfDate = Set(); for (String package in packageToRegistrants.keys) { final Map fileToContent = {}; @@ -510,11 +510,11 @@ Future _verifyGeneratedPluginRegistrants(String flutterRoot) async { String _getPackageFor(File entity, Directory flutterRootDir) { for (Directory dir = entity.parent; dir != flutterRootDir; dir = dir.parent) { - if (new File(path.join(dir.path, 'pubspec.yaml')).existsSync()) { + if (File(path.join(dir.path, 'pubspec.yaml')).existsSync()) { return dir.path; } } - throw new ArgumentError('$entity is not within a dart package.'); + throw ArgumentError('$entity is not within a dart package.'); } bool _isGeneratedPluginRegistrant(File file) { diff --git a/dev/bots/prepare_package.dart b/dev/bots/prepare_package.dart index cbaf1e2584..64f8ed6357 100644 --- a/dev/bots/prepare_package.dart +++ b/dev/bots/prepare_package.dart @@ -68,7 +68,7 @@ Branch fromBranchName(String name) { case 'release': return Branch.release; default: - throw new ArgumentError('Invalid branch name.'); + throw ArgumentError('Invalid branch name.'); } } @@ -82,7 +82,7 @@ class ProcessRunner { this.defaultWorkingDirectory, this.platform = const LocalPlatform(), }) : processManager = processManager ?? const LocalProcessManager() { - environment = new Map.from(platform.environment); + environment = Map.from(platform.environment); } /// The platform to use for a starting environment. @@ -119,8 +119,8 @@ class ProcessRunner { stderr.write('Running "${commandLine.join(' ')}" in ${workingDirectory.path}.\n'); } final List output = []; - final Completer stdoutComplete = new Completer(); - final Completer stderrComplete = new Completer(); + final Completer stdoutComplete = Completer(); + final Completer stderrComplete = Completer(); Process process; Future allComplete() async { await stderrComplete.future; @@ -156,19 +156,19 @@ class ProcessRunner { } on ProcessException catch (e) { final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} ' 'failed with:\n${e.toString()}'; - throw new ProcessRunnerException(message); + throw ProcessRunnerException(message); } on ArgumentError catch (e) { final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} ' 'failed with:\n${e.toString()}'; - throw new ProcessRunnerException(message); + throw ProcessRunnerException(message); } final int exitCode = await allComplete(); if (exitCode != 0 && !failOk) { final String message = 'Running "${commandLine.join(' ')}" in ${workingDirectory.path} failed'; - throw new ProcessRunnerException( + throw ProcessRunnerException( message, - new ProcessResult(0, exitCode, null, 'returned $exitCode'), + ProcessResult(0, exitCode, null, 'returned $exitCode'), ); } return utf8.decoder.convert(output).trim(); @@ -197,9 +197,9 @@ class ArchiveCreator { this.platform = const LocalPlatform(), HttpReader httpReader, }) : assert(revision.length == 40), - flutterRoot = new Directory(path.join(tempDir.path, 'flutter')), + flutterRoot = Directory(path.join(tempDir.path, 'flutter')), httpReader = httpReader ?? http.readBytes, - _processRunner = new ProcessRunner( + _processRunner = ProcessRunner( processManager: processManager, subprocessOutput: subprocessOutput, platform: platform, @@ -276,7 +276,7 @@ class ArchiveCreator { /// Performs all of the steps needed to create an archive. Future createArchive() async { assert(_version != null, 'Must run initializeRepo before createArchive'); - _outputFile = new File(path.join(outputDir.absolute.path, _archiveName)); + _outputFile = File(path.join(outputDir.absolute.path, _archiveName)); await _installMinGitIfNeeded(); await _populateCaches(); await _archiveFiles(_outputFile); @@ -308,11 +308,11 @@ class ArchiveCreator { return; } final Uint8List data = await httpReader(_minGitUri); - final File gitFile = new File(path.join(tempDir.absolute.path, 'mingit.zip')); + final File gitFile = File(path.join(tempDir.absolute.path, 'mingit.zip')); await gitFile.writeAsBytes(data, flush: true); final Directory minGitPath = - new Directory(path.join(flutterRoot.absolute.path, 'bin', 'mingit')); + Directory(path.join(flutterRoot.absolute.path, 'bin', 'mingit')); await minGitPath.create(recursive: true); await _unzipArchive(gitFile, workingDirectory: minGitPath); } @@ -367,7 +367,7 @@ class ArchiveCreator { /// Unpacks the given zip file into the currentDirectory (if set), or the /// same directory as the archive. Future _unzipArchive(File archive, {Directory workingDirectory}) { - workingDirectory ??= new Directory(path.dirname(archive.absolute.path)); + workingDirectory ??= Directory(path.dirname(archive.absolute.path)); List commandLine; if (platform.isWindows) { commandLine = [ @@ -407,7 +407,7 @@ class ArchiveCreator { } return _processRunner.runProcess( commandLine, - workingDirectory: new Directory(path.dirname(source.absolute.path)), + workingDirectory: Directory(path.dirname(source.absolute.path)), ); } @@ -418,7 +418,7 @@ class ArchiveCreator { 'cJf', output.absolute.path, path.basename(source.absolute.path), - ], workingDirectory: new Directory(path.dirname(source.absolute.path))); + ], workingDirectory: Directory(path.dirname(source.absolute.path))); } } @@ -435,7 +435,7 @@ class ArchivePublisher { }) : assert(revision.length == 40), platformName = platform.operatingSystem.toLowerCase(), metadataGsPath = '$gsReleaseFolder/${getMetadataFilename(platform)}', - _processRunner = new ProcessRunner( + _processRunner = ProcessRunner( processManager: processManager, subprocessOutput: subprocessOutput, ); @@ -475,7 +475,7 @@ class ArchivePublisher { newEntry['hash'] = revision; newEntry['channel'] = branchName; newEntry['version'] = version; - newEntry['release_date'] = new DateTime.now().toUtc().toIso8601String(); + newEntry['release_date'] = DateTime.now().toUtc().toIso8601String(); newEntry['archive'] = destinationArchivePath; // Search for any entries with the same hash and channel and remove them. @@ -502,20 +502,20 @@ class ArchivePublisher { // Windows wants to echo the commands that execute in gsutil.bat to the // stdout when we do that. So, we copy the file locally and then read it // back in. - final File metadataFile = new File( + final File metadataFile = File( path.join(tempDir.absolute.path, getMetadataFilename(platform)), ); await _runGsUtil(['cp', metadataGsPath, metadataFile.absolute.path]); final String currentMetadata = metadataFile.readAsStringSync(); if (currentMetadata.isEmpty) { - throw new ProcessRunnerException('Empty metadata received from server'); + throw ProcessRunnerException('Empty metadata received from server'); } Map jsonData; try { jsonData = json.decode(currentMetadata); } on FormatException catch (e) { - throw new ProcessRunnerException('Unable to parse JSON metadata received from cloud: $e'); + throw ProcessRunnerException('Unable to parse JSON metadata received from cloud: $e'); } jsonData = _addRelease(jsonData); @@ -570,7 +570,7 @@ class ArchivePublisher { /// Note that archives contain the executables and customizations for the /// platform that they are created on. Future main(List argList) async { - final ArgParser argParser = new ArgParser(); + final ArgParser argParser = ArgParser(); argParser.addOption( 'temp_dir', defaultsTo: null, @@ -643,7 +643,7 @@ Future main(List argList) async { tempDir = Directory.systemTemp.createTempSync('flutter_package.'); removeTempDir = true; } else { - tempDir = new Directory(args['temp_dir']); + tempDir = Directory(args['temp_dir']); if (!tempDir.existsSync()) { errorExit("Temporary directory ${args['temp_dir']} doesn't exist."); } @@ -653,21 +653,21 @@ Future main(List argList) async { if (args['output'] == null) { outputDir = tempDir; } else { - outputDir = new Directory(args['output']); + outputDir = Directory(args['output']); if (!outputDir.existsSync()) { outputDir.createSync(recursive: true); } } final Branch branch = fromBranchName(args['branch']); - final ArchiveCreator creator = new ArchiveCreator(tempDir, outputDir, revision, branch); + final ArchiveCreator creator = ArchiveCreator(tempDir, outputDir, revision, branch); int exitCode = 0; String message; try { final String version = await creator.initializeRepo(); final File outputFile = await creator.createArchive(); if (args['publish']) { - final ArchivePublisher publisher = new ArchivePublisher( + final ArchivePublisher publisher = ArchivePublisher( tempDir, revision, branch, diff --git a/dev/bots/run_command.dart b/dev/bots/run_command.dart index 5427741d31..539192c977 100644 --- a/dev/bots/run_command.dart +++ b/dev/bots/run_command.dart @@ -23,7 +23,7 @@ const String clock = '🕐'; const Duration _kLongTimeout = Duration(minutes: 45); String elapsedTime(DateTime start) { - return new DateTime.now().difference(start).toString(); + return DateTime.now().difference(start).toString(); } void printProgress(String action, String workingDir, String command) { @@ -48,7 +48,7 @@ Future runCommand(String executable, List arguments, { } printProgress('RUNNING', relativeWorkingDir, commandDescription); - final DateTime start = new DateTime.now(); + final DateTime start = DateTime.now(); final Process process = await Process.start(executable, arguments, workingDirectory: workingDirectory, environment: environment, diff --git a/dev/bots/test.dart b/dev/bots/test.dart index 6f58cc1f1d..983f796677 100644 --- a/dev/bots/test.dart +++ b/dev/bots/test.dart @@ -173,7 +173,7 @@ Future _runTests() async { } Future _runCoverage() async { - final File coverageFile = new File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info')); + final File coverageFile = File(path.join(flutterRoot, 'packages', 'flutter', 'coverage', 'lcov.info')); if (!coverageFile.existsSync()) { print('${red}Coverage file not found.$reset'); print('Expected to find: ${coverageFile.absolute}'); @@ -209,7 +209,7 @@ Future _pubRunTest( if (testPath != null) args.add(testPath); final Map pubEnvironment = {}; - if (new Directory(pubCache).existsSync()) { + if (Directory(pubCache).existsSync()) { pubEnvironment['PUB_CACHE'] = pubCache; } if (enableFlutterToolAsserts) { @@ -274,20 +274,20 @@ Future _runFlutterTest(String workingDirectory, { } Future _verifyVersion(String filename) async { - if (!new File(filename).existsSync()) { + if (!File(filename).existsSync()) { print('$redLine'); print('The version logic failed to create the Flutter version file.'); print('$redLine'); exit(1); } - final String version = await new File(filename).readAsString(); + final String version = await File(filename).readAsString(); if (version == '0.0.0-unknown') { print('$redLine'); print('The version logic failed to determine the Flutter version.'); print('$redLine'); exit(1); } - final RegExp pattern = new RegExp(r'^[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$'); + final RegExp pattern = RegExp(r'^[0-9]+\.[0-9]+\.[0-9]+(-pre\.[0-9]+)?$'); if (!version.contains(pattern)) { print('$redLine'); print('The version logic generated an invalid version string.'); diff --git a/dev/bots/test/analyze-sample-code_test.dart b/dev/bots/test/analyze-sample-code_test.dart index 8eb1f11b8f..7b50ad7fa6 100644 --- a/dev/bots/test/analyze-sample-code_test.dart +++ b/dev/bots/test/analyze-sample-code_test.dart @@ -15,10 +15,10 @@ void main() { ); final List stdout = await process.stdout.transform(utf8.decoder).transform(const LineSplitter()).toList(); final List stderr = await process.stderr.transform(utf8.decoder).transform(const LineSplitter()).toList(); - final Match line = new RegExp(r'^(.+)/main\.dart:[0-9]+:[0-9]+: .+$').matchAsPrefix(stdout[1]); + final Match line = RegExp(r'^(.+)/main\.dart:[0-9]+:[0-9]+: .+$').matchAsPrefix(stdout[1]); expect(line, isNot(isNull)); final String directory = line.group(1); - new Directory(directory).deleteSync(recursive: true); + Directory(directory).deleteSync(recursive: true); expect(await process.exitCode, 1); expect(stderr, isEmpty); expect(stdout, [ diff --git a/dev/bots/test/common.dart b/dev/bots/test/common.dart index 7638adba37..8348fa724b 100644 --- a/dev/bots/test/common.dart +++ b/dev/bots/test/common.dart @@ -13,7 +13,7 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; // TODO(ianh): Remove this file once https://github.com/dart-lang/matcher/issues/98 is fixed /// A matcher that compares the type of the actual value to the type argument T. -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that diff --git a/dev/bots/test/fake_process_manager.dart b/dev/bots/test/fake_process_manager.dart index 4b92bf32dd..719cf6eed1 100644 --- a/dev/bots/test/fake_process_manager.dart +++ b/dev/bots/test/fake_process_manager.dart @@ -36,7 +36,7 @@ class FakeProcessManager extends Mock implements ProcessManager { _fakeResults = >{}; for (String key in value.keys) { _fakeResults[key] = [] - ..addAll(value[key] ?? [new ProcessResult(0, 0, '', '')]); + ..addAll(value[key] ?? [ProcessResult(0, 0, '', '')]); } } @@ -63,11 +63,11 @@ class FakeProcessManager extends Mock implements ProcessManager { } FakeProcess _popProcess(List command) => - new FakeProcess(_popResult(command), stdinResults: stdinResults); + FakeProcess(_popResult(command), stdinResults: stdinResults); Future _nextProcess(Invocation invocation) async { invocations.add(invocation); - return new Future.value(_popProcess(invocation.positionalArguments[0])); + return Future.value(_popProcess(invocation.positionalArguments[0])); } ProcessResult _nextResultSync(Invocation invocation) { @@ -77,7 +77,7 @@ class FakeProcessManager extends Mock implements ProcessManager { Future _nextResult(Invocation invocation) async { invocations.add(invocation); - return new Future.value(_popResult(invocation.positionalArguments[0])); + return Future.value(_popResult(invocation.positionalArguments[0])); } void _setupMock() { @@ -118,10 +118,10 @@ class FakeProcessManager extends Mock implements ProcessManager { /// A fake process that can be used to interact with a process "started" by the FakeProcessManager. class FakeProcess extends Mock implements Process { FakeProcess(ProcessResult result, {void stdinResults(String input)}) - : stdoutStream = new Stream>.fromIterable(>[result.stdout.codeUnits]), - stderrStream = new Stream>.fromIterable(>[result.stderr.codeUnits]), + : stdoutStream = Stream>.fromIterable(>[result.stdout.codeUnits]), + stderrStream = Stream>.fromIterable(>[result.stderr.codeUnits]), desiredExitCode = result.exitCode, - stdinSink = new IOSink(new StringStreamConsumer(stdinResults)) { + stdinSink = IOSink(StringStreamConsumer(stdinResults)) { _setupMock(); } @@ -135,7 +135,7 @@ class FakeProcess extends Mock implements Process { } @override - Future get exitCode => new Future.value(desiredExitCode); + Future get exitCode => Future.value(desiredExitCode); @override int get pid => 0; @@ -167,14 +167,14 @@ class StringStreamConsumer implements StreamConsumer> { @override Future addStream(Stream> value) { streams.add(value); - completers.add(new Completer()); + completers.add(Completer()); subscriptions.add( value.listen((List data) { sendString(utf8.decode(data)); }), ); subscriptions.last.onDone(() => completers.last.complete(null)); - return new Future.value(null); + return Future.value(null); } @override @@ -185,6 +185,6 @@ class StringStreamConsumer implements StreamConsumer> { completers.clear(); streams.clear(); subscriptions.clear(); - return new Future.value(null); + return Future.value(null); } } diff --git a/dev/bots/test/fake_process_manager_test.dart b/dev/bots/test/fake_process_manager_test.dart index 884cf819f5..8dd8bd979e 100644 --- a/dev/bots/test/fake_process_manager_test.dart +++ b/dev/bots/test/fake_process_manager_test.dart @@ -19,7 +19,7 @@ void main() { } setUp(() async { - processManager = new FakeProcessManager(stdinResults: _captureStdin); + processManager = FakeProcessManager(stdinResults: _captureStdin); }); tearDown(() async {}); @@ -27,10 +27,10 @@ void main() { test('start works', () async { final Map> calls = >{ 'gsutil acl get gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output1', '') + ProcessResult(0, 0, 'output1', '') ], 'gsutil cat gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output2', '') + ProcessResult(0, 0, 'output2', '') ], }; processManager.fakeResults = calls; @@ -49,10 +49,10 @@ void main() { test('run works', () async { final Map> calls = >{ 'gsutil acl get gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output1', '') + ProcessResult(0, 0, 'output1', '') ], 'gsutil cat gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output2', '') + ProcessResult(0, 0, 'output2', '') ], }; processManager.fakeResults = calls; @@ -66,10 +66,10 @@ void main() { test('runSync works', () async { final Map> calls = >{ 'gsutil acl get gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output1', '') + ProcessResult(0, 0, 'output1', '') ], 'gsutil cat gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output2', '') + ProcessResult(0, 0, 'output2', '') ], }; processManager.fakeResults = calls; @@ -83,10 +83,10 @@ void main() { test('captures stdin', () async { final Map> calls = >{ 'gsutil acl get gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output1', '') + ProcessResult(0, 0, 'output1', '') ], 'gsutil cat gs://flutter_infra/releases/releases.json': [ - new ProcessResult(0, 0, 'output2', '') + ProcessResult(0, 0, 'output2', '') ], }; processManager.fakeResults = calls; diff --git a/dev/bots/test/prepare_package_test.dart b/dev/bots/test/prepare_package_test.dart index 1da66ea592..8e422d751f 100644 --- a/dev/bots/test/prepare_package_test.dart +++ b/dev/bots/test/prepare_package_test.dart @@ -20,7 +20,7 @@ void main() { test('Throws on missing executable', () async { // Uses a *real* process manager, since we want to know what happens if // it can't find an executable. - final ProcessRunner processRunner = new ProcessRunner(subprocessOutput: false); + final ProcessRunner processRunner = ProcessRunner(subprocessOutput: false); expect( expectAsync1((List commandLine) async { return processRunner.runProcess(commandLine); @@ -36,27 +36,27 @@ void main() { } }); for (String platformName in ['macos', 'linux', 'windows']) { - final FakePlatform platform = new FakePlatform( + final FakePlatform platform = FakePlatform( operatingSystem: platformName, environment: {}, ); group('ProcessRunner for $platform', () { test('Returns stdout', () async { - final FakeProcessManager fakeProcessManager = new FakeProcessManager(); + final FakeProcessManager fakeProcessManager = FakeProcessManager(); fakeProcessManager.fakeResults = >{ - 'echo test': [new ProcessResult(0, 0, 'output', 'error')], + 'echo test': [ProcessResult(0, 0, 'output', 'error')], }; - final ProcessRunner processRunner = new ProcessRunner( + final ProcessRunner processRunner = ProcessRunner( subprocessOutput: false, platform: platform, processManager: fakeProcessManager); final String output = await processRunner.runProcess(['echo', 'test']); expect(output, equals('output')); }); test('Throws on process failure', () async { - final FakeProcessManager fakeProcessManager = new FakeProcessManager(); + final FakeProcessManager fakeProcessManager = FakeProcessManager(); fakeProcessManager.fakeResults = >{ - 'echo test': [new ProcessResult(0, -1, 'output', 'error')], + 'echo test': [ProcessResult(0, -1, 'output', 'error')], }; - final ProcessRunner processRunner = new ProcessRunner( + final ProcessRunner processRunner = ProcessRunner( subprocessOutput: false, platform: platform, processManager: fakeProcessManager); expect( expectAsync1((List commandLine) async { @@ -75,17 +75,17 @@ void main() { String flutter; Future fakeHttpReader(Uri url, {Map headers}) { - return new Future.value(new Uint8List(0)); + return Future.value(Uint8List(0)); } setUp(() async { - processManager = new FakeProcessManager(); + processManager = FakeProcessManager(); args.clear(); namedArgs.clear(); tempDir = Directory.systemTemp.createTempSync('flutter_prepage_package_test.'); - flutterDir = new Directory(path.join(tempDir.path, 'flutter')); + flutterDir = Directory(path.join(tempDir.path, 'flutter')); flutterDir.createSync(recursive: true); - creator = new ArchiveCreator( + creator = ArchiveCreator( tempDir, tempDir, testRef, @@ -108,7 +108,7 @@ void main() { 'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, - 'git describe --tags --abbrev=0': [new ProcessResult(0, 0, 'v1.2.3', '')], + 'git describe --tags --abbrev=0': [ProcessResult(0, 0, 'v1.2.3', '')], }; if (platform.isWindows) { calls['7za x ${path.join(tempDir.path, 'mingit.zip')}'] = null; @@ -151,7 +151,7 @@ void main() { 'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': null, 'git reset --hard $testRef': null, 'git remote set-url origin https://github.com/flutter/flutter.git': null, - 'git describe --tags --abbrev=0': [new ProcessResult(0, 0, 'v1.2.3', '')], + 'git describe --tags --abbrev=0': [ProcessResult(0, 0, 'v1.2.3', '')], }; if (platform.isWindows) { calls['7za x ${path.join(tempDir.path, 'mingit.zip')}'] = null; @@ -176,7 +176,7 @@ void main() { calls['tar cJf $archiveName flutter'] = null; } processManager.fakeResults = calls; - creator = new ArchiveCreator( + creator = ArchiveCreator( tempDir, tempDir, testRef, @@ -194,8 +194,8 @@ void main() { test('throws when a command errors out', () async { final Map> calls = >{ 'git clone -b dev https://chromium.googlesource.com/external/github.com/flutter/flutter': - [new ProcessResult(0, 0, 'output1', '')], - 'git reset --hard $testRef': [new ProcessResult(0, -1, 'output2', '')], + [ProcessResult(0, 0, 'output1', '')], + 'git reset --hard $testRef': [ProcessResult(0, -1, 'output2', '')], }; processManager.fakeResults = calls; expect(expectAsync0(creator.initializeRepo), @@ -208,7 +208,7 @@ void main() { Directory tempDir; setUp(() async { - processManager = new FakeProcessManager(); + processManager = FakeProcessManager(); tempDir = Directory.systemTemp.createTempSync('flutter_prepage_package_test.'); }); @@ -255,7 +255,7 @@ void main() { ] } '''; - new File(jsonPath).writeAsStringSync(releasesJson); + File(jsonPath).writeAsStringSync(releasesJson); final Map> calls = >{ 'gsutil rm $gsArchivePath': null, 'gsutil -h Content-Type:$archiveMime cp $archivePath $gsArchivePath': null, @@ -264,9 +264,9 @@ void main() { 'gsutil -h Content-Type:application/json cp $jsonPath $gsJsonPath': null, }; processManager.fakeResults = calls; - final File outputFile = new File(path.join(tempDir.absolute.path, archiveName)); + final File outputFile = File(path.join(tempDir.absolute.path, archiveName)); assert(tempDir.existsSync()); - final ArchivePublisher publisher = new ArchivePublisher( + final ArchivePublisher publisher = ArchivePublisher( tempDir, testRef, Branch.release, @@ -279,7 +279,7 @@ void main() { assert(tempDir.existsSync()); await publisher.publishArchive(); processManager.verifyCalls(calls.keys.toList()); - final File releaseFile = new File(jsonPath); + final File releaseFile = File(jsonPath); expect(releaseFile.existsSync(), isTrue); final String contents = releaseFile.readAsStringSync(); // Make sure new data is added. @@ -299,7 +299,7 @@ void main() { // Make sure the new entry is first (and hopefully it takes less than a // minute to go from publishArchive above to this line!). expect( - new DateTime.now().difference(DateTime.parse(releases[0]['release_date'])), + DateTime.now().difference(DateTime.parse(releases[0]['release_date'])), lessThan(const Duration(minutes: 1)), ); const JsonEncoder encoder = JsonEncoder.withIndent(' '); diff --git a/dev/devicelab/bin/run.dart b/dev/devicelab/bin/run.dart index 387e53da92..0b2dc3ad8f 100644 --- a/dev/devicelab/bin/run.dart +++ b/dev/devicelab/bin/run.dart @@ -69,7 +69,7 @@ Future main(List rawArgs) async { } /// Command-line options for the `run.dart` command. -final ArgParser _argParser = new ArgParser() +final ArgParser _argParser = ArgParser() ..addMultiOption( 'task', abbr: 't', @@ -89,7 +89,7 @@ final ArgParser _argParser = new ArgParser() _taskNames.add(nameOrPath); } else if (!isDartFile || fragments.length != 3 || !_listsEqual(['bin', 'tasks'], fragments.take(2).toList())) { // Unsupported executable location - throw new FormatException('Invalid value for option -t (--task): $nameOrPath'); + throw FormatException('Invalid value for option -t (--task): $nameOrPath'); } else { _taskNames.add(path.withoutExtension(fragments.last)); } diff --git a/dev/devicelab/bin/tasks/commands_test.dart b/dev/devicelab/bin/tasks/commands_test.dart index 5df186b7db..f23f4b8e19 100644 --- a/dev/devicelab/bin/tasks/commands_test.dart +++ b/dev/devicelab/bin/tasks/commands_test.dart @@ -21,14 +21,14 @@ void main() { await device.unlock(); final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui')); await inDirectory(appDir, () async { - final Completer ready = new Completer(); + final Completer ready = Completer(); bool ok; print('run: starting...'); final Process run = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), ['run', '--verbose', '-d', device.deviceId, 'lib/commands.dart'], ); - final StreamController stdout = new StreamController.broadcast(); + final StreamController stdout = StreamController.broadcast(); run.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -56,9 +56,9 @@ void main() { if (!ok) throw 'Failed to run test app.'; - final VMServiceClient client = new VMServiceClient.connect('ws://localhost:$vmServicePort/ws'); + final VMServiceClient client = VMServiceClient.connect('ws://localhost:$vmServicePort/ws'); - final DriveHelper driver = new DriveHelper(vmServicePort); + final DriveHelper driver = DriveHelper(vmServicePort); await driver.drive('none'); print('test: pressing "p" to enable debugPaintSize...'); @@ -98,7 +98,7 @@ void main() { print('test: validating that the app has in fact closed...'); await client.done.timeout(const Duration(seconds: 5)); }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/complex_layout_scroll_perf__memory.dart b/dev/devicelab/bin/tasks/complex_layout_scroll_perf__memory.dart index 1729629efd..e59dc0857c 100644 --- a/dev/devicelab/bin/tasks/complex_layout_scroll_perf__memory.dart +++ b/dev/devicelab/bin/tasks/complex_layout_scroll_perf__memory.dart @@ -11,7 +11,7 @@ import 'package:flutter_devicelab/tasks/perf_tests.dart'; Future main() async { deviceOperatingSystem = DeviceOperatingSystem.android; - await task(new MemoryTest( + await task(MemoryTest( '${flutterDirectory.path}/dev/benchmarks/complex_layout', 'test_memory/scroll_perf.dart', 'com.yourcompany.complexLayout', diff --git a/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart b/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart index 028447a75d..cca05ea8ac 100644 --- a/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart +++ b/dev/devicelab/bin/tasks/complex_layout_semantics_perf.dart @@ -31,7 +31,7 @@ void main() { }); final String dataPath = p.join(complexLayoutPath, 'build', 'complex_layout_semantics_perf.json'); - return new TaskResult.successFromFile(file(dataPath), benchmarkScoreKeys: [ + return TaskResult.successFromFile(file(dataPath), benchmarkScoreKeys: [ 'initialSemanticsTreeCreation', ]); }); diff --git a/dev/devicelab/bin/tasks/dartdocs.dart b/dev/devicelab/bin/tasks/dartdocs.dart index 36ccf17ba7..bac9d9b0ff 100644 --- a/dev/devicelab/bin/tasks/dartdocs.dart +++ b/dev/devicelab/bin/tasks/dartdocs.dart @@ -12,7 +12,7 @@ import 'package:path/path.dart' as path; Future main() async { await task(() async { - final Stopwatch clock = new Stopwatch()..start(); + final Stopwatch clock = Stopwatch()..start(); final Process analysis = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), ['analyze', '--no-preamble', '--no-congratulate', '--flutter-repo', '--dartdocs'], @@ -47,16 +47,16 @@ Future main() async { final int result = await analysis.exitCode; clock.stop(); if (publicMembers == 0 && otherErrors == 0 && result != 0) - throw new Exception('flutter analyze exited with unexpected error code $result'); + throw Exception('flutter analyze exited with unexpected error code $result'); if (publicMembers != 0 && otherErrors != 0 && result == 0) - throw new Exception('flutter analyze exited with successful status code despite reporting errors'); + throw Exception('flutter analyze exited with successful status code despite reporting errors'); if (otherLines != 0) - throw new Exception('flutter analyze had unexpected output (we saw $otherLines unexpected line${ otherLines == 1 ? "" : "s" })'); + throw Exception('flutter analyze had unexpected output (we saw $otherLines unexpected line${ otherLines == 1 ? "" : "s" })'); final Map data = { 'members_missing_dartdocs': publicMembers, 'analysis_errors': otherErrors, 'elapsed_time_ms': clock.elapsedMilliseconds, }; - return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); + return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); }); } diff --git a/dev/devicelab/bin/tasks/flutter_attach_test.dart b/dev/devicelab/bin/tasks/flutter_attach_test.dart index 64c89902f8..3c6641f42a 100644 --- a/dev/devicelab/bin/tasks/flutter_attach_test.dart +++ b/dev/devicelab/bin/tasks/flutter_attach_test.dart @@ -13,11 +13,11 @@ import 'package:flutter_devicelab/framework/utils.dart'; Future testReload(Process process, { Future Function() onListening }) async { section('Testing hot reload, restart and quit'); - final Completer listening = new Completer(); - final Completer ready = new Completer(); - final Completer reloaded = new Completer(); - final Completer restarted = new Completer(); - final Completer finished = new Completer(); + final Completer listening = Completer(); + final Completer ready = Completer(); + final Completer reloaded = Completer(); + final Completer restarted = Completer(); + final Completer finished = Completer(); final List stdout = []; final List stderr = []; @@ -96,7 +96,7 @@ void main() { ['--suppress-analytics', 'build', 'apk', '--debug', 'lib/main.dart'], ); final String lastLine = buildStdout.split('\n').last; - final RegExp builtRegExp = new RegExp(r'Built (.+)( \(|\.$)'); + final RegExp builtRegExp = RegExp(r'Built (.+)( \(|\.$)'); final String apkPath = builtRegExp.firstMatch(lastLine)[1]; section('Installing $apkPath'); @@ -116,7 +116,7 @@ void main() { }); // Give the device the time to really shut down the app. - await new Future.delayed(const Duration(milliseconds: 200)); + await Future.delayed(const Duration(milliseconds: 200)); // After the delay, force-stopping it shouldn't do anything, but doesn't hurt. await device.shellExec('am', ['force-stop', kAppId]); @@ -128,7 +128,7 @@ void main() { // If the next line fails, your device may not support regexp search. final String observatoryLine = await device.adb(['logcat', '-e', 'Observatory listening on http:', '-m', '1', '-T', currentTime]); print('Found observatory line: $observatoryLine'); - final String observatoryPort = new RegExp(r'Observatory listening on http://.*:([0-9]+)').firstMatch(observatoryLine)[1]; + final String observatoryPort = RegExp(r'Observatory listening on http://.*:([0-9]+)').firstMatch(observatoryLine)[1]; print('Extracted observatory port: $observatoryPort'); section('Launching attach with given port'); @@ -144,6 +144,6 @@ void main() { await device.adb(['uninstall', kAppId]); } }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/flutter_gallery__back_button_memory.dart b/dev/devicelab/bin/tasks/flutter_gallery__back_button_memory.dart index f66573015a..78128759f0 100644 --- a/dev/devicelab/bin/tasks/flutter_gallery__back_button_memory.dart +++ b/dev/devicelab/bin/tasks/flutter_gallery__back_button_memory.dart @@ -35,7 +35,7 @@ class BackButtonMemoryTest extends MemoryTest { await receivedNextMessage; // Give Android time to settle (e.g. run GCs) after closing the app. - await new Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); // Relaunch the app, wait for it to launch. prepareForNextMessage('READY'); @@ -46,7 +46,7 @@ class BackButtonMemoryTest extends MemoryTest { await receivedNextMessage; // Wait for the Flutter app to settle (e.g. run GCs). - await new Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); } await recordEnd(); } @@ -54,5 +54,5 @@ class BackButtonMemoryTest extends MemoryTest { Future main() async { deviceOperatingSystem = DeviceOperatingSystem.android; - await task(new BackButtonMemoryTest().run); + await task(BackButtonMemoryTest().run); } diff --git a/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart b/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart index 8c2b301e97..9d5bed2b8a 100644 --- a/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart +++ b/dev/devicelab/bin/tasks/flutter_gallery__memory_nav.dart @@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/utils.dart'; import 'package:flutter_devicelab/tasks/perf_tests.dart'; Future main() async { - await task(new MemoryTest( + await task(MemoryTest( '${flutterDirectory.path}/examples/flutter_gallery', 'test_memory/memory_nav.dart', 'io.flutter.demo.gallery', diff --git a/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart b/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart index 27c61713cd..549ac49410 100644 --- a/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart +++ b/dev/devicelab/bin/tasks/flutter_gallery__transition_perf_with_semantics.dart @@ -24,6 +24,6 @@ Future main() async { benchmarkScoreKeys.add(deltaKey); } - return new TaskResult.success(data, benchmarkScoreKeys: benchmarkScoreKeys); + return TaskResult.success(data, benchmarkScoreKeys: benchmarkScoreKeys); }); } diff --git a/dev/devicelab/bin/tasks/flutter_gallery_instrumentation_test.dart b/dev/devicelab/bin/tasks/flutter_gallery_instrumentation_test.dart index 1434db5a0d..7dd0f80552 100644 --- a/dev/devicelab/bin/tasks/flutter_gallery_instrumentation_test.dart +++ b/dev/devicelab/bin/tasks/flutter_gallery_instrumentation_test.dart @@ -30,6 +30,6 @@ Future main() async { }); }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/flutter_test_performance.dart b/dev/devicelab/bin/tasks/flutter_test_performance.dart index 171e5c5648..2434680267 100644 --- a/dev/devicelab/bin/tasks/flutter_test_performance.dart +++ b/dev/devicelab/bin/tasks/flutter_test_performance.dart @@ -24,7 +24,7 @@ import 'package:flutter_devicelab/framework/framework.dart'; import 'package:flutter_devicelab/framework/utils.dart'; // Matches the output of the "test" package, e.g.: "00:01 +1 loading foo" -final RegExp testOutputPattern = new RegExp(r'^[0-9][0-9]:[0-9][0-9] \+[0-9]+: (.+?) *$'); +final RegExp testOutputPattern = RegExp(r'^[0-9][0-9]:[0-9][0-9] \+[0-9]+: (.+?) *$'); enum TestStep { starting, @@ -37,7 +37,7 @@ enum TestStep { } Future runTest() async { - final Stopwatch clock = new Stopwatch()..start(); + final Stopwatch clock = Stopwatch()..start(); final Process analysis = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), ['test', path.join('flutter_test', 'trivial_widget_test.dart')], @@ -83,18 +83,18 @@ Future runTest() async { final int result = await analysis.exitCode; clock.stop(); if (result != 0) - throw new Exception('flutter test failed with exit code $result'); + throw Exception('flutter test failed with exit code $result'); if (badLines > 0) - throw new Exception('flutter test renderered unexpected output ($badLines bad lines)'); + throw Exception('flutter test renderered unexpected output ($badLines bad lines)'); if (step != TestStep.testPassed) - throw new Exception('flutter test did not finish (only reached step $step)'); + throw Exception('flutter test did not finish (only reached step $step)'); print('elapsed time: ${clock.elapsedMilliseconds}ms'); return clock.elapsedMilliseconds; } void main() { task(() async { - final File nodeSourceFile = new File(path.join( + final File nodeSourceFile = File(path.join( flutterDirectory.path, 'packages', 'flutter', 'lib', 'src', 'foundation', 'node.dart', )); final String originalSource = await nodeSourceFile.readAsString(); @@ -118,7 +118,7 @@ void main() { 'implementation_change_elapsed_time_ms': implementationChange, 'interface_change_elapsed_time_ms': interfaceChange, }; - return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); + return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); } finally { await nodeSourceFile.writeAsString(originalSource); } diff --git a/dev/devicelab/bin/tasks/gradle_plugin_test.dart b/dev/devicelab/bin/tasks/gradle_plugin_test.dart index b258a1f244..32442d982e 100644 --- a/dev/devicelab/bin/tasks/gradle_plugin_test.dart +++ b/dev/devicelab/bin/tasks/gradle_plugin_test.dart @@ -42,7 +42,7 @@ Future main() async { javaHome = await findJavaHome(); if (javaHome == null) - return new TaskResult.failure('Could not find Java'); + return TaskResult.failure('Could not find Java'); print('\nUsing JAVA_HOME=$javaHome'); try { @@ -51,7 +51,7 @@ Future main() async { await project.runGradleTask('assembleDebug'); errorMessage = _validateSnapshotDependency(project, 'build/app.dill'); if (errorMessage != null) { - throw new TaskResult.failure(errorMessage); + throw TaskResult.failure(errorMessage); } }); @@ -125,15 +125,15 @@ Future main() async { section('gradlew assembleDebug on plugin example'); await pluginProject.runGradleTask('assembleDebug'); if (!pluginProject.hasDebugApk) - throw new TaskResult.failure( + throw TaskResult.failure( 'Gradle did not produce an apk file at the expected place'); }); - return new TaskResult.success(null); + return TaskResult.success(null); } on TaskResult catch (taskResult) { return taskResult; } catch (e) { - return new TaskResult.failure(e.toString()); + return TaskResult.failure(e.toString()); } }); } @@ -143,7 +143,7 @@ TaskResult _failure(String message, ProcessResult result) { print('Exit code: ${result.exitCode}'); print('Std out :\n${result.stdout}'); print('Std err :\n${result.stderr}'); - return new TaskResult.failure(message); + return TaskResult.failure(message); } bool _hasMultipleOccurrences(String text, Pattern pattern) { @@ -160,14 +160,14 @@ class FlutterProject { await inDirectory(directory, () async { await flutter('create', options: [name]); }); - return new FlutterProject(directory, name); + return FlutterProject(directory, name); } String get rootPath => path.join(parent.path, name); String get androidPath => path.join(rootPath, 'android'); Future addCustomBuildType(String name, {String initWith}) async { - final File buildScript = new File( + final File buildScript = File( path.join(androidPath, 'app', 'build.gradle'), ); @@ -184,7 +184,7 @@ android { } Future addProductFlavor(String name) async { - final File buildScript = new File( + final File buildScript = File( path.join(androidPath, 'app', 'build.gradle'), ); @@ -203,7 +203,7 @@ android { } Future introduceError() async { - final File buildScript = new File( + final File buildScript = File( path.join(androidPath, 'app', 'build.gradle'), ); await buildScript.writeAsString((await buildScript.readAsString()).replaceAll('buildTypes', 'builTypes')); @@ -236,7 +236,7 @@ class FlutterPluginProject { await inDirectory(directory, () async { await flutter('create', options: ['-t', 'plugin', name]); }); - return new FlutterPluginProject(directory, name); + return FlutterPluginProject(directory, name); } String get rootPath => path.join(parent.path, name); @@ -248,7 +248,7 @@ class FlutterPluginProject { return _runGradleTask(workingDirectory: exampleAndroidPath, task: task, options: options); } - bool get hasDebugApk => new File(debugApkPath).existsSync(); + bool get hasDebugApk => File(debugApkPath).existsSync(); } Future _runGradleTask({String workingDirectory, String task, List options}) async { @@ -284,12 +284,12 @@ class _Dependencies { String target; Set dependencies; _Dependencies(String depfilePath) { - final RegExp _separatorExpr = new RegExp(r'([^\\]) '); - final RegExp _escapeExpr = new RegExp(r'\\(.)'); + final RegExp _separatorExpr = RegExp(r'([^\\]) '); + final RegExp _escapeExpr = RegExp(r'\\(.)'); // Depfile format: // outfile1 outfile2 : file1.dart file2.dart file3.dart file\ 4.dart - final String contents = new File(depfilePath).readAsStringSync(); + final String contents = File(depfilePath).readAsStringSync(); final List colonSeparated = contents.split(': '); target = colonSeparated[0].trim(); dependencies = colonSeparated[1] @@ -305,7 +305,7 @@ class _Dependencies { /// Returns [null] if target matches [expectedTarget], otherwise returns an error message. String _validateSnapshotDependency(FlutterProject project, String expectedTarget) { - final _Dependencies deps = new _Dependencies( + final _Dependencies deps = _Dependencies( path.join(project.rootPath, 'build', 'app', 'intermediates', 'flutter', 'debug', 'snapshot_blob.bin.d')); return deps.target == expectedTarget ? null : diff --git a/dev/devicelab/bin/tasks/hello_world__memory.dart b/dev/devicelab/bin/tasks/hello_world__memory.dart index f3a99aebc6..74433f0779 100644 --- a/dev/devicelab/bin/tasks/hello_world__memory.dart +++ b/dev/devicelab/bin/tasks/hello_world__memory.dart @@ -27,13 +27,13 @@ class HelloWorldMemoryTest extends MemoryTest { '-d', device.deviceId, test, ]); - await new Future.delayed(const Duration(milliseconds: 1500)); + await Future.delayed(const Duration(milliseconds: 1500)); await recordStart(); - await new Future.delayed(const Duration(milliseconds: 3000)); + await Future.delayed(const Duration(milliseconds: 3000)); await recordEnd(); } } Future main() async { - await task(new HelloWorldMemoryTest().run); + await task(HelloWorldMemoryTest().run); } diff --git a/dev/devicelab/bin/tasks/module_test.dart b/dev/devicelab/bin/tasks/module_test.dart index 88a35fe8cd..858475e69b 100644 --- a/dev/devicelab/bin/tasks/module_test.dart +++ b/dev/devicelab/bin/tasks/module_test.dart @@ -18,7 +18,7 @@ Future main() async { final String javaHome = await findJavaHome(); if (javaHome == null) - return new TaskResult.failure('Could not find Java'); + return TaskResult.failure('Could not find Java'); print('\nUsing JAVA_HOME=$javaHome'); section('Create Flutter module project'); @@ -34,14 +34,14 @@ Future main() async { section('Add plugins'); - final File pubspec = new File(path.join(tempDir.path, 'hello', 'pubspec.yaml')); + final File pubspec = File(path.join(tempDir.path, 'hello', 'pubspec.yaml')); String content = await pubspec.readAsString(); content = content.replaceFirst( '\ndependencies:\n', '\ndependencies:\n battery:\n package_info:\n', ); await pubspec.writeAsString(content, flush: true); - await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async { + await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async { await flutter( 'packages', options: ['get'], @@ -50,7 +50,7 @@ Future main() async { section('Build Flutter module library archive'); - await inDirectory(new Directory(path.join(tempDir.path, 'hello', '.android')), () async { + await inDirectory(Directory(path.join(tempDir.path, 'hello', '.android')), () async { await exec( './gradlew', ['flutter:assembleDebug'], @@ -58,7 +58,7 @@ Future main() async { ); }); - final bool aarBuilt = exists(new File(path.join( + final bool aarBuilt = exists(File(path.join( tempDir.path, 'hello', '.android', @@ -70,19 +70,19 @@ Future main() async { ))); if (!aarBuilt) { - return new TaskResult.failure('Failed to build .aar'); + return TaskResult.failure('Failed to build .aar'); } section('Build ephemeral host app'); - await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async { + await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async { await flutter( 'build', options: ['apk'], ); }); - final bool ephemeralHostApkBuilt = exists(new File(path.join( + final bool ephemeralHostApkBuilt = exists(File(path.join( tempDir.path, 'hello', 'build', @@ -94,18 +94,18 @@ Future main() async { ))); if (!ephemeralHostApkBuilt) { - return new TaskResult.failure('Failed to build ephemeral host .apk'); + return TaskResult.failure('Failed to build ephemeral host .apk'); } section('Clean build'); - await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async { + await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async { await flutter('clean'); }); section('Materialize host app'); - await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async { + await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async { await flutter( 'materialize', options: ['android'], @@ -114,14 +114,14 @@ Future main() async { section('Build materialized host app'); - await inDirectory(new Directory(path.join(tempDir.path, 'hello')), () async { + await inDirectory(Directory(path.join(tempDir.path, 'hello')), () async { await flutter( 'build', options: ['apk'], ); }); - final bool materializedHostApkBuilt = exists(new File(path.join( + final bool materializedHostApkBuilt = exists(File(path.join( tempDir.path, 'hello', 'build', @@ -133,24 +133,24 @@ Future main() async { ))); if (!materializedHostApkBuilt) { - return new TaskResult.failure('Failed to build materialized host .apk'); + return TaskResult.failure('Failed to build materialized host .apk'); } section('Add to Android app'); - final Directory hostApp = new Directory(path.join(tempDir.path, 'hello_host_app')); + final Directory hostApp = Directory(path.join(tempDir.path, 'hello_host_app')); mkdir(hostApp); recursiveCopy( - new Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'android_host_app')), + Directory(path.join(flutterDirectory.path, 'dev', 'integration_tests', 'android_host_app')), hostApp, ); copy( - new File(path.join(tempDir.path, 'hello', '.android', 'gradlew')), + File(path.join(tempDir.path, 'hello', '.android', 'gradlew')), hostApp, ); copy( - new File(path.join(tempDir.path, 'hello', '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')), - new Directory(path.join(hostApp.path, 'gradle', 'wrapper')), + File(path.join(tempDir.path, 'hello', '.android', 'gradle', 'wrapper', 'gradle-wrapper.jar')), + Directory(path.join(hostApp.path, 'gradle', 'wrapper')), ); await inDirectory(hostApp, () async { @@ -161,7 +161,7 @@ Future main() async { ); }); - final bool existingAppBuilt = exists(new File(path.join( + final bool existingAppBuilt = exists(File(path.join( hostApp.path, 'app', 'build', @@ -172,11 +172,11 @@ Future main() async { ))); if (!existingAppBuilt) { - return new TaskResult.failure('Failed to build existing app .apk'); + return TaskResult.failure('Failed to build existing app .apk'); } - return new TaskResult.success(null); + return TaskResult.success(null); } catch (e) { - return new TaskResult.failure(e.toString()); + return TaskResult.failure(e.toString()); } finally { rmTree(tempDir); } diff --git a/dev/devicelab/bin/tasks/plugin_test.dart b/dev/devicelab/bin/tasks/plugin_test.dart index 7dadc8d0ce..0f263c4f14 100644 --- a/dev/devicelab/bin/tasks/plugin_test.dart +++ b/dev/devicelab/bin/tasks/plugin_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/framework.dart'; Future main() async { await task(combine([ - new PluginTest('apk', ['-a', 'java']), - new PluginTest('apk', ['-a', 'kotlin']), + PluginTest('apk', ['-a', 'java']), + PluginTest('apk', ['-a', 'kotlin']), ])); } diff --git a/dev/devicelab/bin/tasks/plugin_test_ios.dart b/dev/devicelab/bin/tasks/plugin_test_ios.dart index 5992dd3b1a..8b706c98ec 100644 --- a/dev/devicelab/bin/tasks/plugin_test_ios.dart +++ b/dev/devicelab/bin/tasks/plugin_test_ios.dart @@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/framework.dart'; Future main() async { await task(combine([ - new PluginTest('ios', ['-i', 'objc']), - new PluginTest('ios', ['-i', 'swift']), + PluginTest('ios', ['-i', 'objc']), + PluginTest('ios', ['-i', 'swift']), ])); } diff --git a/dev/devicelab/bin/tasks/plugin_test_win.dart b/dev/devicelab/bin/tasks/plugin_test_win.dart index 7dadc8d0ce..0f263c4f14 100644 --- a/dev/devicelab/bin/tasks/plugin_test_win.dart +++ b/dev/devicelab/bin/tasks/plugin_test_win.dart @@ -9,7 +9,7 @@ import 'package:flutter_devicelab/framework/framework.dart'; Future main() async { await task(combine([ - new PluginTest('apk', ['-a', 'java']), - new PluginTest('apk', ['-a', 'kotlin']), + PluginTest('apk', ['-a', 'java']), + PluginTest('apk', ['-a', 'kotlin']), ])); } diff --git a/dev/devicelab/bin/tasks/routing_test.dart b/dev/devicelab/bin/tasks/routing_test.dart index 51cb30e7ab..d001aa536f 100644 --- a/dev/devicelab/bin/tasks/routing_test.dart +++ b/dev/devicelab/bin/tasks/routing_test.dart @@ -29,7 +29,7 @@ void main() { }); section('TEST WHETHER `flutter run --route` WORKS'); await inDirectory(appDir, () async { - final Completer ready = new Completer(); + final Completer ready = Completer(); bool ok; print('run: starting...'); final Process run = await startProcess( @@ -86,6 +86,6 @@ void main() { if (result != 0) throw 'Received unexpected exit code $result from run process.'; }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart b/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart index 1704fcb08e..281048b8c2 100644 --- a/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart +++ b/dev/devicelab/bin/tasks/run_machine_concurrent_hot_reload.dart @@ -39,7 +39,7 @@ void main() { final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui')); await inDirectory(appDir, () async { - final Completer ready = new Completer(); + final Completer ready = Completer(); bool ok; print('run: starting...'); final Process run = await startProcess( @@ -54,7 +54,7 @@ void main() { ], ); final StreamController stdout = - new StreamController.broadcast(); + StreamController.broadcast(); transformToLines(run.stdout).listen((String line) { print('run:stdout: $line'); stdout.add(line); @@ -80,14 +80,14 @@ void main() { throw 'Failed to run test app.'; final VMServiceClient client = - new VMServiceClient.connect('ws://localhost:$vmServicePort/ws'); + VMServiceClient.connect('ws://localhost:$vmServicePort/ws'); int id = 1; Future> sendRequest( String method, dynamic params) async { final int requestId = id++; final Completer> response = - new Completer>(); + Completer>(); final StreamSubscription responseSubscription = stdout.stream.listen((String line) { final Map json = parseFlutterResponse(line); @@ -150,6 +150,6 @@ void main() { print('test: validating that the app has in fact closed...'); await client.done.timeout(const Duration(seconds: 5)); }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/run_release_test.dart b/dev/devicelab/bin/tasks/run_release_test.dart index 87094bc998..11efb96dd9 100644 --- a/dev/devicelab/bin/tasks/run_release_test.dart +++ b/dev/devicelab/bin/tasks/run_release_test.dart @@ -18,7 +18,7 @@ void main() { await device.unlock(); final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui')); await inDirectory(appDir, () async { - final Completer ready = new Completer(); + final Completer ready = Completer(); print('run: starting...'); final Process run = await startProcess( path.join(flutterDirectory.path, 'bin', 'flutter'), @@ -76,6 +76,6 @@ void main() { '${stdout.join('\n')}'; } }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/service_extensions_test.dart b/dev/devicelab/bin/tasks/service_extensions_test.dart index 966218efe7..dda1676dec 100644 --- a/dev/devicelab/bin/tasks/service_extensions_test.dart +++ b/dev/devicelab/bin/tasks/service_extensions_test.dart @@ -21,7 +21,7 @@ void main() { await device.unlock(); final Directory appDir = dir(path.join(flutterDirectory.path, 'dev/integration_tests/ui')); await inDirectory(appDir, () async { - final Completer ready = new Completer(); + final Completer ready = Completer(); bool ok; print('run: starting...'); final Process run = await startProcess( @@ -54,7 +54,7 @@ void main() { if (!ok) throw 'Failed to run test app.'; - final VMServiceClient client = new VMServiceClient.connect('ws://localhost:$vmServicePort/ws'); + final VMServiceClient client = VMServiceClient.connect('ws://localhost:$vmServicePort/ws'); final VM vm = await client.getVM(); final VMIsolateRef isolate = vm.isolates.first; final Stream frameEvents = isolate.onExtensionEvent.where( @@ -82,7 +82,7 @@ void main() { if (result != 0) throw 'Received unexpected exit code $result from run process.'; }); - return new TaskResult.success(null); + return TaskResult.success(null); }); } diff --git a/dev/devicelab/bin/tasks/smoke_test_failure.dart b/dev/devicelab/bin/tasks/smoke_test_failure.dart index 523429a22f..8a0328c174 100644 --- a/dev/devicelab/bin/tasks/smoke_test_failure.dart +++ b/dev/devicelab/bin/tasks/smoke_test_failure.dart @@ -9,6 +9,6 @@ import 'package:flutter_devicelab/framework/framework.dart'; /// Smoke test of a task that fails by returning an unsuccessful response. Future main() async { await task(() async { - return new TaskResult.failure('Failed'); + return TaskResult.failure('Failed'); }); } diff --git a/dev/devicelab/bin/tasks/smoke_test_success.dart b/dev/devicelab/bin/tasks/smoke_test_success.dart index 5602cbb758..b77cbaec3c 100644 --- a/dev/devicelab/bin/tasks/smoke_test_success.dart +++ b/dev/devicelab/bin/tasks/smoke_test_success.dart @@ -9,6 +9,6 @@ import 'package:flutter_devicelab/framework/framework.dart'; /// Smoke test of a successful task. Future main() async { await task(() async { - return new TaskResult.success({}); + return TaskResult.success({}); }); } diff --git a/dev/devicelab/bin/tasks/technical_debt__cost.dart b/dev/devicelab/bin/tasks/technical_debt__cost.dart index e4bdbeb58c..dc2d076f7a 100644 --- a/dev/devicelab/bin/tasks/technical_debt__cost.dart +++ b/dev/devicelab/bin/tasks/technical_debt__cost.dart @@ -18,10 +18,10 @@ const double skipCost = 2473.0; // 20 hours: 5 to fix the issue we're ignoring, const double ignoreForFileCost = 2477.0; // similar thinking as skipCost const double asDynamicCost = 2003.0; // same as ignoring analyzer warning -final RegExp todoPattern = new RegExp(r'(?://|#) *TODO'); -final RegExp ignorePattern = new RegExp(r'// *ignore:'); -final RegExp ignoreForFilePattern = new RegExp(r'// *ignore_for_file:'); -final RegExp asDynamicPattern = new RegExp(r'as dynamic'); +final RegExp todoPattern = RegExp(r'(?://|#) *TODO'); +final RegExp ignorePattern = RegExp(r'// *ignore:'); +final RegExp ignoreForFilePattern = RegExp(r'// *ignore_for_file:'); +final RegExp asDynamicPattern = RegExp(r'as dynamic'); Future findCostsForFile(File file) async { if (path.extension(file.path) == '.py') @@ -55,10 +55,10 @@ Future findCostsForRepo() async { ); double total = 0.0; await for (String entry in git.stdout.transform(utf8.decoder).transform(const LineSplitter())) - total += await findCostsForFile(new File(path.join(flutterDirectory.path, entry))); + total += await findCostsForFile(File(path.join(flutterDirectory.path, entry))); final int gitExitCode = await git.exitCode; if (gitExitCode != 0) - throw new Exception('git exit with unexpected error code $gitExitCode'); + throw Exception('git exit with unexpected error code $gitExitCode'); return total; } @@ -69,7 +69,7 @@ Future countDependencies() async { )).split('\n'); final int count = lines.where((String line) => line.contains('->')).length; if (count < 2) // we'll always have flutter and flutter_test, at least... - throw new Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}'); + throw Exception('"flutter update-packages --transitive-closure" returned bogus output:\n${lines.join("\n")}'); return count; } @@ -78,7 +78,7 @@ const String _kNumberOfDependenciesKey = 'dependencies_count'; Future main() async { await task(() async { - return new TaskResult.success( + return TaskResult.success( { _kCostBenchmarkKey: await findCostsForRepo(), _kNumberOfDependenciesKey: await countDependencies(), diff --git a/dev/devicelab/lib/framework/adb.dart b/dev/devicelab/lib/framework/adb.dart index 1e47885c16..8098d70911 100644 --- a/dev/devicelab/lib/framework/adb.dart +++ b/dev/devicelab/lib/framework/adb.dart @@ -13,7 +13,7 @@ import 'package:path/path.dart' as path; import 'utils.dart'; /// The root of the API for controlling devices. -DeviceDiscovery get devices => new DeviceDiscovery(); +DeviceDiscovery get devices => DeviceDiscovery(); /// Device operating system the test is configured to test. enum DeviceOperatingSystem { android, ios } @@ -26,11 +26,11 @@ abstract class DeviceDiscovery { factory DeviceDiscovery() { switch (deviceOperatingSystem) { case DeviceOperatingSystem.android: - return new AndroidDeviceDiscovery(); + return AndroidDeviceDiscovery(); case DeviceOperatingSystem.ios: - return new IosDeviceDiscovery(); + return IosDeviceDiscovery(); default: - throw new StateError('Unsupported device operating system: {config.deviceOperatingSystem}'); + throw StateError('Unsupported device operating system: {config.deviceOperatingSystem}'); } } @@ -103,12 +103,12 @@ class AndroidDeviceDiscovery implements DeviceDiscovery { // Parses information about a device. Example: // // 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper - static final RegExp _kDeviceRegex = new RegExp(r'^(\S+)\s+(\S+)(.*)'); + static final RegExp _kDeviceRegex = RegExp(r'^(\S+)\s+(\S+)(.*)'); static AndroidDeviceDiscovery _instance; factory AndroidDeviceDiscovery() { - return _instance ??= new AndroidDeviceDiscovery._(); + return _instance ??= AndroidDeviceDiscovery._(); } AndroidDeviceDiscovery._(); @@ -129,14 +129,14 @@ class AndroidDeviceDiscovery implements DeviceDiscovery { @override Future chooseWorkingDevice() async { final List allDevices = (await discoverDevices()) - .map((String id) => new AndroidDevice(deviceId: id)) + .map((String id) => AndroidDevice(deviceId: id)) .toList(); if (allDevices.isEmpty) throw 'No Android devices detected'; // TODO(yjbanov): filter out and warn about those with low battery level - _workingDevice = allDevices[new math.Random().nextInt(allDevices.length)]; + _workingDevice = allDevices[math.Random().nextInt(allDevices.length)]; } @override @@ -174,13 +174,13 @@ class AndroidDeviceDiscovery implements DeviceDiscovery { final Map results = {}; for (String deviceId in await discoverDevices()) { try { - final AndroidDevice device = new AndroidDevice(deviceId: deviceId); + final AndroidDevice device = AndroidDevice(deviceId: deviceId); // Just a smoke test that we can read wakefulness state // TODO(yjbanov): check battery level await device._getWakefulness(); - results['android-device-$deviceId'] = new HealthCheckResult.success(); + results['android-device-$deviceId'] = HealthCheckResult.success(); } catch (e, s) { - results['android-device-$deviceId'] = new HealthCheckResult.error(e, s); + results['android-device-$deviceId'] = HealthCheckResult.error(e, s); } } return results; @@ -278,7 +278,7 @@ class AndroidDevice implements Device { @override Future> getMemoryStats(String packageName) async { final String meminfo = await shellEval('dumpsys', ['meminfo', packageName]); - final Match match = new RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo); + final Match match = RegExp(r'TOTAL\s+(\d+)').firstMatch(meminfo); assert(match != null, 'could not parse dumpsys meminfo output'); return { 'total_kb': int.parse(match.group(1)), @@ -287,13 +287,13 @@ class AndroidDevice implements Device { @override Stream get logcat { - final Completer stdoutDone = new Completer(); - final Completer stderrDone = new Completer(); - final Completer processDone = new Completer(); - final Completer abort = new Completer(); + final Completer stdoutDone = Completer(); + final Completer stderrDone = Completer(); + final Completer processDone = Completer(); + final Completer abort = Completer(); bool aborted = false; StreamController stream; - stream = new StreamController( + stream = StreamController( onListen: () async { await adb(['logcat', '--clear']); final Process process = await startProcess(adbPath, ['-s', deviceId, 'logcat']); @@ -353,7 +353,7 @@ class IosDeviceDiscovery implements DeviceDiscovery { static IosDeviceDiscovery _instance; factory IosDeviceDiscovery() { - return _instance ??= new IosDeviceDiscovery._(); + return _instance ??= IosDeviceDiscovery._(); } IosDeviceDiscovery._(); @@ -374,14 +374,14 @@ class IosDeviceDiscovery implements DeviceDiscovery { @override Future chooseWorkingDevice() async { final List allDevices = (await discoverDevices()) - .map((String id) => new IosDevice(deviceId: id)) + .map((String id) => IosDevice(deviceId: id)) .toList(); if (allDevices.isEmpty) throw 'No iOS devices detected'; // TODO(yjbanov): filter out and warn about those with low battery level - _workingDevice = allDevices[new math.Random().nextInt(allDevices.length)]; + _workingDevice = allDevices[math.Random().nextInt(allDevices.length)]; } @override @@ -400,7 +400,7 @@ class IosDeviceDiscovery implements DeviceDiscovery { final Map results = {}; for (String deviceId in await discoverDevices()) { // TODO(ianh): do a more meaningful connectivity check than just recording the ID - results['ios-device-$deviceId'] = new HealthCheckResult.success(); + results['ios-device-$deviceId'] = HealthCheckResult.success(); } return results; } diff --git a/dev/devicelab/lib/framework/framework.dart b/dev/devicelab/lib/framework/framework.dart index fd0ec75249..5bf7edb66c 100644 --- a/dev/devicelab/lib/framework/framework.dart +++ b/dev/devicelab/lib/framework/framework.dart @@ -33,7 +33,7 @@ bool _isTaskRegistered = false; /// registered per Dart VM. Future task(TaskFunction task) { if (_isTaskRegistered) - throw new StateError('A task is already registered'); + throw StateError('A task is already registered'); _isTaskRegistered = true; @@ -43,13 +43,13 @@ Future task(TaskFunction task) { print('${rec.level.name}: ${rec.time}: ${rec.message}'); }); - final _TaskRunner runner = new _TaskRunner(task); + final _TaskRunner runner = _TaskRunner(task); runner.keepVmAliveUntilTaskRunRequested(); return runner.whenDone; } class _TaskRunner { - static final Logger logger = new Logger('TaskRunner'); + static final Logger logger = Logger('TaskRunner'); final TaskFunction task; @@ -58,20 +58,20 @@ class _TaskRunner { Timer _startTaskTimeout; bool _taskStarted = false; - final Completer _completer = new Completer(); + final Completer _completer = Completer(); _TaskRunner(this.task) { registerExtension('ext.cocoonRunTask', (String method, Map parameters) async { final Duration taskTimeout = parameters.containsKey('timeoutInMinutes') - ? new Duration(minutes: int.parse(parameters['timeoutInMinutes'])) + ? Duration(minutes: int.parse(parameters['timeoutInMinutes'])) : _kDefaultTaskTimeout; final TaskResult result = await run(taskTimeout); - return new ServiceExtensionResponse.result(json.encode(result.toJson())); + return ServiceExtensionResponse.result(json.encode(result.toJson())); }); registerExtension('ext.cocoonRunnerReady', (String method, Map parameters) async { - return new ServiceExtensionResponse.result('"ready"'); + return ServiceExtensionResponse.result('"ready"'); }); } @@ -87,7 +87,7 @@ class _TaskRunner { return result; } on TimeoutException catch (_) { print('Task timed out in framework.dart after $taskTimeout.'); - return new TaskResult.failure('Task timed out after $taskTimeout'); + return TaskResult.failure('Task timed out after $taskTimeout'); } finally { print('Cleaning up after task...'); await forceQuitRunningProcesses(); @@ -99,15 +99,15 @@ class _TaskRunner { /// received via the VM service protocol. void keepVmAliveUntilTaskRunRequested() { if (_taskStarted) - throw new StateError('Task already started.'); + throw StateError('Task already started.'); // Merely creating this port object will cause the VM to stay alive and keep // the VM service server running until the port is disposed of. - _keepAlivePort = new RawReceivePort(); + _keepAlivePort = RawReceivePort(); // Timeout if nothing bothers to connect and ask us to run the task. const Duration taskStartTimeout = Duration(seconds: 60); - _startTaskTimeout = new Timer(taskStartTimeout, () { + _startTaskTimeout = Timer(taskStartTimeout, () { if (!_taskStarted) { logger.severe('Task did not start in $taskStartTimeout.'); _closeKeepAlivePort(); @@ -123,7 +123,7 @@ class _TaskRunner { } Future _performTask() { - final Completer completer = new Completer(); + final Completer completer = Completer(); Chain.capture(() async { completer.complete(await task()); }, onError: (dynamic taskError, Chain taskErrorStack) { @@ -138,7 +138,7 @@ class _TaskRunner { // code. Our goal is to convert the failure into a readable message. // Propagating it further is not useful. if (!completer.isCompleted) - completer.complete(new TaskResult.failure(message)); + completer.complete(TaskResult.failure(message)); }); return completer.future; } @@ -167,7 +167,7 @@ class TaskResult { /// Constructs a successful result using JSON data stored in a file. factory TaskResult.successFromFile(File file, {List benchmarkScoreKeys}) { - return new TaskResult.success(json.decode(file.readAsStringSync()), + return TaskResult.success(json.decode(file.readAsStringSync()), benchmarkScoreKeys: benchmarkScoreKeys); } diff --git a/dev/devicelab/lib/framework/manifest.dart b/dev/devicelab/lib/framework/manifest.dart index 540c524d39..f5e28545a5 100644 --- a/dev/devicelab/lib/framework/manifest.dart +++ b/dev/devicelab/lib/framework/manifest.dart @@ -77,7 +77,7 @@ class ManifestError extends Error { // manually. It's not too much code and produces good error messages. Manifest _validateAndParseManifest(Map manifestYaml) { _checkKeys(manifestYaml, 'manifest', const ['tasks']); - return new Manifest._(_validateAndParseTasks(manifestYaml['tasks'])); + return Manifest._(_validateAndParseTasks(manifestYaml['tasks'])); } List _validateAndParseTasks(dynamic tasksYaml) { @@ -108,7 +108,7 @@ ManifestTask _validateAndParseTask(dynamic taskName, dynamic taskYaml) { } final List capabilities = _validateAndParseCapabilities(taskName, taskYaml['required_agent_capabilities']); - return new ManifestTask._( + return ManifestTask._( name: taskName, description: taskYaml['description'], stage: taskYaml['stage'], @@ -129,7 +129,7 @@ List _validateAndParseCapabilities(String taskName, dynamic capabilities void _checkType(bool isValid, dynamic value, String variableName, String typeName) { if (!isValid) { - throw new ManifestError( + throw ManifestError( '$variableName must be a $typeName but was ${value.runtimeType}: $value', ); } @@ -137,14 +137,14 @@ void _checkType(bool isValid, dynamic value, String variableName, String typeNam void _checkIsNotBlank(dynamic value, String variableName, String ownerName) { if (value == null || value.isEmpty) { - throw new ManifestError('$variableName must not be empty in $ownerName.'); + throw ManifestError('$variableName must not be empty in $ownerName.'); } } void _checkKeys(Map map, String variableName, List allowedKeys) { for (String key in map.keys) { if (!allowedKeys.contains(key)) { - throw new ManifestError( + throw ManifestError( 'Unrecognized property "$key" in $variableName. ' 'Allowed properties: ${allowedKeys.join(', ')}'); } diff --git a/dev/devicelab/lib/framework/runner.dart b/dev/devicelab/lib/framework/runner.dart index 7985e86a77..e836d9f570 100644 --- a/dev/devicelab/lib/framework/runner.dart +++ b/dev/devicelab/lib/framework/runner.dart @@ -41,7 +41,7 @@ Future> runTask(String taskName, { bool silent = false }) a runnerFinished = true; }); - final Completer port = new Completer(); + final Completer port = Completer(); final StreamSubscription stdoutSub = runner.stdout .transform(const Utf8Decoder()) @@ -90,14 +90,14 @@ Future> runTask(String taskName, { bool silent = false }) a Future _connectToRunnerIsolate(int vmServicePort) async { final String url = 'ws://localhost:$vmServicePort/ws'; - final DateTime started = new DateTime.now(); + final DateTime started = DateTime.now(); // TODO(yjbanov): due to lack of imagination at the moment the handshake with // the task process is very rudimentary and requires this small // delay to let the task process open up the VM service port. // Otherwise we almost always hit the non-ready case first and // wait a whole 1 second, which is annoying. - await new Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); while (true) { try { @@ -105,7 +105,7 @@ Future _connectToRunnerIsolate(int vmServicePort) async { await (await WebSocket.connect(url)).close(); // Look up the isolate. - final VMServiceClient client = new VMServiceClient.connect(url); + final VMServiceClient client = VMServiceClient.connect(url); final VM vm = await client.getVM(); final VMIsolateRef isolate = vm.isolates.single; final String response = await isolate.invokeExtension('ext.cocoonRunnerReady'); @@ -114,8 +114,8 @@ Future _connectToRunnerIsolate(int vmServicePort) async { return isolate; } catch (error) { const Duration connectionTimeout = Duration(seconds: 10); - if (new DateTime.now().difference(started) > connectionTimeout) { - throw new TimeoutException( + if (DateTime.now().difference(started) > connectionTimeout) { + throw TimeoutException( 'Failed to connect to the task runner process', connectionTimeout, ); @@ -123,7 +123,7 @@ Future _connectToRunnerIsolate(int vmServicePort) async { print('VM service not ready yet: $error'); const Duration pauseBetweenRetries = Duration(milliseconds: 200); print('Will retry in $pauseBetweenRetries.'); - await new Future.delayed(pauseBetweenRetries); + await Future.delayed(pauseBetweenRetries); } } } @@ -142,8 +142,8 @@ Future cleanupSystem() async { print('\nTelling Gradle to shut down (JAVA_HOME=$javaHome)'); final String gradlewBinaryName = Platform.isWindows ? 'gradlew.bat' : 'gradlew'; final Directory tempDir = Directory.systemTemp.createTempSync('flutter_devicelab_shutdown_gradle.'); - recursiveCopy(new Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir); - copy(new File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'create', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), new Directory(path.join(tempDir.path, 'gradle', 'wrapper'))); + recursiveCopy(Directory(path.join(flutterDirectory.path, 'bin', 'cache', 'artifacts', 'gradle_wrapper')), tempDir); + copy(File(path.join(path.join(flutterDirectory.path, 'packages', 'flutter_tools'), 'templates', 'create', 'android.tmpl', 'gradle', 'wrapper', 'gradle-wrapper.properties')), Directory(path.join(tempDir.path, 'gradle', 'wrapper'))); if (!Platform.isWindows) { await exec( 'chmod', diff --git a/dev/devicelab/lib/framework/utils.dart b/dev/devicelab/lib/framework/utils.dart index f4fffdbaa5..c90adf481e 100644 --- a/dev/devicelab/lib/framework/utils.dart +++ b/dev/devicelab/lib/framework/utils.dart @@ -24,7 +24,7 @@ ProcessManager _processManager = const LocalProcessManager(); class ProcessInfo { ProcessInfo(this.command, this.process); - final DateTime startTime = new DateTime.now(); + final DateTime startTime = DateTime.now(); final String command; final Process process; @@ -52,7 +52,7 @@ class HealthCheckResult { @override String toString() { - final StringBuffer buf = new StringBuffer(succeeded ? 'succeeded' : 'failed'); + final StringBuffer buf = StringBuffer(succeeded ? 'succeeded' : 'failed'); if (details != null && details.trim().isNotEmpty) { buf.writeln(); // Indent details by 4 spaces @@ -74,7 +74,7 @@ class BuildFailedError extends Error { } void fail(String message) { - throw new BuildFailedError(message); + throw BuildFailedError(message); } // Remove the given file or directory. @@ -98,9 +98,9 @@ void rmTree(FileSystemEntity entity) { List ls(Directory directory) => directory.listSync(); -Directory dir(String path) => new Directory(path); +Directory dir(String path) => Directory(path); -File file(String path) => new File(path); +File file(String path) => File(path); void copy(File sourceFile, Directory targetDirectory, {String name}) { final File target = file( @@ -115,9 +115,9 @@ void recursiveCopy(Directory source, Directory target) { for (FileSystemEntity entity in source.listSync(followLinks: false)) { final String name = path.basename(entity.path); if (entity is Directory) - recursiveCopy(entity, new Directory(path.join(target.path, name))); + recursiveCopy(entity, Directory(path.join(target.path, name))); else if (entity is File) { - final File dest = new File(path.join(target.path, name)); + final File dest = File(path.join(target.path, name)); dest.writeAsBytesSync(entity.readAsBytesSync()); } } @@ -187,7 +187,7 @@ Future getFlutterRepoCommitTimestamp(String commit) { commit, ]); final int secondsSinceEpoch = int.parse(unixTimestamp); - return new DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000); + return DateTime.fromMillisecondsSinceEpoch(secondsSinceEpoch * 1000); }); } @@ -232,7 +232,7 @@ Future startProcess( environment: environment, workingDirectory: workingDirectory ?? cwd, ); - final ProcessInfo processInfo = new ProcessInfo(command, process); + final ProcessInfo processInfo = ProcessInfo(command, process); _runningProcesses.add(processInfo); process.exitCode.then((int exitCode) { @@ -248,7 +248,7 @@ Future forceQuitRunningProcesses() async { return; // Give normally quitting processes a chance to report their exit code. - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Whatever's left, kill it. for (ProcessInfo p in _runningProcesses) { @@ -270,8 +270,8 @@ Future exec( }) async { final Process process = await startProcess(executable, arguments, environment: environment, workingDirectory: workingDirectory); - final Completer stdoutDone = new Completer(); - final Completer stderrDone = new Completer(); + final Completer stdoutDone = Completer(); + final Completer stderrDone = Completer(); process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -306,9 +306,9 @@ Future eval( }) async { final Process process = await startProcess(executable, arguments, environment: environment, workingDirectory: workingDirectory); - final StringBuffer output = new StringBuffer(); - final Completer stdoutDone = new Completer(); - final Completer stderrDone = new Completer(); + final StringBuffer output = StringBuffer(); + final Completer stdoutDone = Completer(); + final Completer stderrDone = Completer(); process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -496,7 +496,7 @@ Iterable grep(Pattern pattern, {@required String from}) { /// /// } Future runAndCaptureAsyncStacks(Future callback()) { - final Completer completer = new Completer(); + final Completer completer = Completer(); Chain.capture(() async { await callback(); completer.complete(); @@ -507,7 +507,7 @@ Future runAndCaptureAsyncStacks(Future callback()) { bool canRun(String path) => _processManager.canRun(path); String extractCloudAuthTokenArg(List rawArgs) { - final ArgParser argParser = new ArgParser()..addOption('cloud-auth-token'); + final ArgParser argParser = ArgParser()..addOption('cloud-auth-token'); ArgResults args; try { args = argParser.parse(rawArgs); @@ -536,7 +536,7 @@ int parseServicePort(String line, { bool multiLine = false, }) { // e.g. "An Observatory debugger and profiler on ... is available at: http://127.0.0.1:8100/" - final RegExp pattern = new RegExp('$prefix(\\S+:(\\d+)/\\S*)\$', multiLine: multiLine); + final RegExp pattern = RegExp('$prefix(\\S+:(\\d+)/\\S*)\$', multiLine: multiLine); final Match match = pattern.firstMatch(line); return match == null ? null : int.parse(match.group(2)); } diff --git a/dev/devicelab/lib/tasks/analysis.dart b/dev/devicelab/lib/tasks/analysis.dart index 8bf62cf230..495935895d 100644 --- a/dev/devicelab/lib/tasks/analysis.dart +++ b/dev/devicelab/lib/tasks/analysis.dart @@ -29,12 +29,12 @@ Future analyzerBenchmarkTask() async { }); final Map data = {}; - data.addAll((await _run(new _FlutterRepoBenchmark())).asMap('flutter_repo', 'batch')); - data.addAll((await _run(new _FlutterRepoBenchmark(watch: true))).asMap('flutter_repo', 'watch')); - data.addAll((await _run(new _MegaGalleryBenchmark())).asMap('mega_gallery', 'batch')); - data.addAll((await _run(new _MegaGalleryBenchmark(watch: true))).asMap('mega_gallery', 'watch')); + data.addAll((await _run(_FlutterRepoBenchmark())).asMap('flutter_repo', 'batch')); + data.addAll((await _run(_FlutterRepoBenchmark(watch: true))).asMap('flutter_repo', 'watch')); + data.addAll((await _run(_MegaGalleryBenchmark())).asMap('mega_gallery', 'batch')); + data.addAll((await _run(_MegaGalleryBenchmark(watch: true))).asMap('mega_gallery', 'watch')); - return new TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); + return TaskResult.success(data, benchmarkScoreKeys: data.keys.toList()); } class _BenchmarkResult { @@ -73,7 +73,7 @@ abstract class _Benchmark { Future execute(int iteration, int targetIterations) async { section('Analyze $title ${watch ? 'with watcher' : ''} - ${iteration + 1} / $targetIterations'); - final Stopwatch stopwatch = new Stopwatch(); + final Stopwatch stopwatch = Stopwatch(); await inDirectory(directory, () async { stopwatch.start(); await flutter('analyze', options: options); @@ -124,5 +124,5 @@ Future<_BenchmarkResult> _run(_Benchmark benchmark) async { 0.0, (double previousValue, double element) => previousValue + element, ); - return new _BenchmarkResult(sum / results.length, results.first, results.last); + return _BenchmarkResult(sum / results.length, results.first, results.last); } diff --git a/dev/devicelab/lib/tasks/gallery.dart b/dev/devicelab/lib/tasks/gallery.dart index c0c2edbbaf..98788de4d8 100644 --- a/dev/devicelab/lib/tasks/gallery.dart +++ b/dev/devicelab/lib/tasks/gallery.dart @@ -13,7 +13,7 @@ import '../framework/ios.dart'; import '../framework/utils.dart'; TaskFunction createGalleryTransitionTest({ bool semanticsEnabled = false }) { - return new GalleryTransitionTest(semanticsEnabled: semanticsEnabled); + return GalleryTransitionTest(semanticsEnabled: semanticsEnabled); } class GalleryTransitionTest { @@ -67,7 +67,7 @@ class GalleryTransitionTest { }; data.addAll(summary); - return new TaskResult.success(data, benchmarkScoreKeys: [ + return TaskResult.success(data, benchmarkScoreKeys: [ 'missed_transition_count', 'average_frame_build_time_millis', 'worst_frame_build_time_millis', diff --git a/dev/devicelab/lib/tasks/hot_mode_tests.dart b/dev/devicelab/lib/tasks/hot_mode_tests.dart index 452b27108e..c938318bde 100644 --- a/dev/devicelab/lib/tasks/hot_mode_tests.dart +++ b/dev/devicelab/lib/tasks/hot_mode_tests.dart @@ -43,8 +43,8 @@ TaskFunction createHotModeTest() { environment: null ); - final Completer stdoutDone = new Completer(); - final Completer stderrDone = new Completer(); + final Completer stdoutDone = Completer(); + final Completer stderrDone = Completer(); process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -96,8 +96,8 @@ TaskFunction createHotModeTest() { ['run']..addAll(options), environment: null ); - final Completer stdoutDone = new Completer(); - final Completer stderrDone = new Completer(); + final Completer stdoutDone = Completer(); + final Completer stderrDone = Completer(); process.stdout .transform(utf8.decoder) .transform(const LineSplitter()) @@ -130,7 +130,7 @@ TaskFunction createHotModeTest() { - return new TaskResult.success( + return TaskResult.success( { 'hotReloadInitialDevFSSyncMilliseconds': twoReloadsData['hotReloadInitialDevFSSyncMilliseconds'][0], 'hotRestartMillisecondsToFrame': twoReloadsData['hotRestartMillisecondsToFrame'][0], diff --git a/dev/devicelab/lib/tasks/integration_tests.dart b/dev/devicelab/lib/tasks/integration_tests.dart index ea991bde54..0064c1b5a4 100644 --- a/dev/devicelab/lib/tasks/integration_tests.dart +++ b/dev/devicelab/lib/tasks/integration_tests.dart @@ -10,21 +10,21 @@ import '../framework/ios.dart'; import '../framework/utils.dart'; TaskFunction createChannelsIntegrationTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/dev/integration_tests/channels', 'lib/main.dart', ); } TaskFunction createPlatformInteractionTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/dev/integration_tests/platform_interaction', 'lib/main.dart', ); } TaskFunction createFlavorsTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/dev/integration_tests/flavors', 'lib/main.dart', extraOptions: ['--flavor', 'paid'] @@ -32,28 +32,28 @@ TaskFunction createFlavorsTest() { } TaskFunction createExternalUiIntegrationTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/dev/integration_tests/external_ui', 'lib/main.dart', ); } TaskFunction createPlatformChannelSampleTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/examples/platform_channel', 'test_driver/button_tap.dart', ); } TaskFunction createEmbeddedAndroidViewsIntegrationTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/dev/integration_tests/android_views', 'lib/main.dart', ); } TaskFunction createAndroidSemanticsIntegrationTest() { - return new DriverTest( + return DriverTest( '${flutterDirectory.path}/dev/integration_tests/android_semantics_testing', 'lib/main.dart', ); @@ -91,7 +91,7 @@ class DriverTest { options.addAll(extraOptions); await flutter('drive', options: options); - return new TaskResult.success(null); + return TaskResult.success(null); }); } } diff --git a/dev/devicelab/lib/tasks/integration_ui.dart b/dev/devicelab/lib/tasks/integration_ui.dart index b9410d3d68..c40495ff08 100644 --- a/dev/devicelab/lib/tasks/integration_ui.dart +++ b/dev/devicelab/lib/tasks/integration_ui.dart @@ -33,5 +33,5 @@ Future runEndToEndTests() async { } }); - return new TaskResult.success({}); + return TaskResult.success({}); } diff --git a/dev/devicelab/lib/tasks/microbenchmarks.dart b/dev/devicelab/lib/tasks/microbenchmarks.dart index 2e7a8ea4d1..ae96483bd2 100644 --- a/dev/devicelab/lib/tasks/microbenchmarks.dart +++ b/dev/devicelab/lib/tasks/microbenchmarks.dart @@ -54,7 +54,7 @@ TaskFunction createMicrobenchmarkTask() { allResults.addAll(await _runMicrobench('lib/gestures/velocity_tracker_bench.dart')); allResults.addAll(await _runMicrobench('lib/stocks/animation_bench.dart')); - return new TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList()); + return TaskResult.success(allResults, benchmarkScoreKeys: allResults.keys.toList()); }; } @@ -74,8 +74,8 @@ Future> _readJsonResults(Process process) { const String jsonEnd = '================ FORMATTED =============='; const String jsonPrefix = ':::JSON:::'; bool jsonStarted = false; - final StringBuffer jsonBuf = new StringBuffer(); - final Completer> completer = new Completer>(); + final StringBuffer jsonBuf = StringBuffer(); + final Completer> completer = Completer>(); final StreamSubscription stderrSub = process.stderr .transform(const Utf8Decoder()) @@ -126,7 +126,7 @@ Future> _readJsonResults(Process process) { // Also send a kill signal in case the `q` above didn't work. process.kill(ProcessSignal.sigint); // ignore: deprecated_member_use try { - completer.complete(new Map.from(json.decode(jsonOutput))); + completer.complete(Map.from(json.decode(jsonOutput))); } catch (ex) { completer.completeError('Decoding JSON failed ($ex). JSON string was: $jsonOutput'); } diff --git a/dev/devicelab/lib/tasks/perf_tests.dart b/dev/devicelab/lib/tasks/perf_tests.dart index 3c3323a86d..c02cf44019 100644 --- a/dev/devicelab/lib/tasks/perf_tests.dart +++ b/dev/devicelab/lib/tasks/perf_tests.dart @@ -15,7 +15,7 @@ import '../framework/ios.dart'; import '../framework/utils.dart'; TaskFunction createComplexLayoutScrollPerfTest() { - return new PerfTest( + return PerfTest( '${flutterDirectory.path}/dev/benchmarks/complex_layout', 'test_driver/scroll_perf.dart', 'complex_layout_scroll_perf', @@ -23,7 +23,7 @@ TaskFunction createComplexLayoutScrollPerfTest() { } TaskFunction createTilesScrollPerfTest() { - return new PerfTest( + return PerfTest( '${flutterDirectory.path}/dev/benchmarks/complex_layout', 'test_driver/scroll_perf.dart', 'tiles_scroll_perf', @@ -31,38 +31,38 @@ TaskFunction createTilesScrollPerfTest() { } TaskFunction createFlutterGalleryStartupTest() { - return new StartupTest( + return StartupTest( '${flutterDirectory.path}/examples/flutter_gallery', ).run; } TaskFunction createComplexLayoutStartupTest() { - return new StartupTest( + return StartupTest( '${flutterDirectory.path}/dev/benchmarks/complex_layout', ).run; } TaskFunction createFlutterGalleryCompileTest() { - return new CompileTest('${flutterDirectory.path}/examples/flutter_gallery').run; + return CompileTest('${flutterDirectory.path}/examples/flutter_gallery').run; } TaskFunction createHelloWorldCompileTest() { - return new CompileTest('${flutterDirectory.path}/examples/hello_world', reportPackageContentSizes: true).run; + return CompileTest('${flutterDirectory.path}/examples/hello_world', reportPackageContentSizes: true).run; } TaskFunction createComplexLayoutCompileTest() { - return new CompileTest('${flutterDirectory.path}/dev/benchmarks/complex_layout').run; + return CompileTest('${flutterDirectory.path}/dev/benchmarks/complex_layout').run; } TaskFunction createFlutterViewStartupTest() { - return new StartupTest( + return StartupTest( '${flutterDirectory.path}/examples/flutter_view', reportMetrics: false, ).run; } TaskFunction createPlatformViewStartupTest() { - return new StartupTest( + return StartupTest( '${flutterDirectory.path}/examples/platform_view', reportMetrics: false, ).run; @@ -82,7 +82,7 @@ TaskFunction createBasicMaterialCompileTest() { if (!(await sampleDir.exists())) throw 'Failed to create default Flutter app in ${sampleDir.path}'; - return new CompileTest(sampleDir.path).run(); + return CompileTest(sampleDir.path).run(); }; } @@ -112,9 +112,9 @@ class StartupTest { final Map data = json.decode(file('$testDirectory/build/start_up_info.json').readAsStringSync()); if (!reportMetrics) - return new TaskResult.success(data); + return TaskResult.success(data); - return new TaskResult.success(data, benchmarkScoreKeys: [ + return TaskResult.success(data, benchmarkScoreKeys: [ 'timeToFirstFrameMicros', ]); }); @@ -152,13 +152,13 @@ class PerfTest { final Map data = json.decode(file('$testDirectory/build/$timelineFileName.timeline_summary.json').readAsStringSync()); if (data['frame_count'] < 5) { - return new TaskResult.failure( + return TaskResult.failure( 'Timeline contains too few frames: ${data['frame_count']}. Possibly ' 'trace events are not being captured.', ); } - return new TaskResult.success(data, benchmarkScoreKeys: [ + return TaskResult.success(data, benchmarkScoreKeys: [ 'average_frame_build_time_millis', 'worst_frame_build_time_millis', 'missed_frame_build_budget_count', @@ -190,14 +190,14 @@ class CompileTest { ..addAll(await _compileApp(reportPackageContentSizes: reportPackageContentSizes)) ..addAll(await _compileDebug()); - return new TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList()); + return TaskResult.success(metrics, benchmarkScoreKeys: metrics.keys.toList()); }); } static Future> _compileAot() async { // Generate blobs instead of assembly. await flutter('clean'); - final Stopwatch watch = new Stopwatch()..start(); + final Stopwatch watch = Stopwatch()..start(); final List options = [ 'aot', '-v', @@ -218,7 +218,7 @@ class CompileTest { final String compileLog = await evalFlutter('build', options: options); watch.stop(); - final RegExp metricExpression = new RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)'); + final RegExp metricExpression = RegExp(r'([a-zA-Z]+)\(CodeSize\)\: (\d+)'); final Map metrics = {}; for (Match m in metricExpression.allMatches(compileLog)) { metrics[_sdkNameToMetricName(m.group(1))] = int.parse(m.group(2)); @@ -233,7 +233,7 @@ class CompileTest { static Future> _compileApp({ bool reportPackageContentSizes = false }) async { await flutter('clean'); - final Stopwatch watch = new Stopwatch(); + final Stopwatch watch = Stopwatch(); int releaseSizeInBytes; final List options = ['--release']; setLocalEngineOptionIfNecessary(options); @@ -281,7 +281,7 @@ class CompileTest { static Future> _compileDebug() async { await flutter('clean'); - final Stopwatch watch = new Stopwatch(); + final Stopwatch watch = Stopwatch(); final List options = ['--debug']; setLocalEngineOptionIfNecessary(options); switch (deviceOperatingSystem) { @@ -327,8 +327,8 @@ class CompileTest { 'TARGET_BUILD_DIR': path.dirname(appPath), }); - final File appFramework = new File(path.join(appPath, 'Frameworks', 'App.framework', 'App')); - final File flutterFramework = new File(path.join(appPath, 'Frameworks', 'Flutter.framework', 'Flutter')); + final File appFramework = File(path.join(appPath, 'Frameworks', 'App.framework', 'App')); + final File flutterFramework = File(path.join(appPath, 'Frameworks', 'Flutter.framework', 'Flutter')); return { 'app_framework_uncompressed_bytes': await appFramework.length(), @@ -344,7 +344,7 @@ class CompileTest { // First three lines are header, last two lines are footer. for (int i = 3; i < lines.length - 2; i++) { - final _UnzipListEntry entry = new _UnzipListEntry.fromLine(lines[i]); + final _UnzipListEntry entry = _UnzipListEntry.fromLine(lines[i]); fileToMetadata[entry.path] = entry; } @@ -390,7 +390,7 @@ class MemoryTest { /// when `adb logcat` sees a log line with the given `message`. void prepareForNextMessage(String message) { _nextMessage = message; - _receivedNextMessage = new Completer(); + _receivedNextMessage = Completer(); } int get iterationCount => 15; @@ -427,14 +427,14 @@ class MemoryTest { assert(_diffMemory.length == iteration + 1); print('terminating...'); await device.stop(package); - await new Future.delayed(const Duration(milliseconds: 10)); + await Future.delayed(const Duration(milliseconds: 10)); } await adb.cancel(); - final ListStatistics startMemoryStatistics = new ListStatistics(_startMemory); - final ListStatistics endMemoryStatistics = new ListStatistics(_endMemory); - final ListStatistics diffMemoryStatistics = new ListStatistics(_diffMemory); + final ListStatistics startMemoryStatistics = ListStatistics(_startMemory); + final ListStatistics endMemoryStatistics = ListStatistics(_endMemory); + final ListStatistics diffMemoryStatistics = ListStatistics(_diffMemory); final Map memoryUsage = {}; memoryUsage.addAll(startMemoryStatistics.asMap('start')); @@ -446,7 +446,7 @@ class MemoryTest { _endMemory.clear(); _diffMemory.clear(); - return new TaskResult.success(memoryUsage, benchmarkScoreKeys: memoryUsage.keys.toList()); + return TaskResult.success(memoryUsage, benchmarkScoreKeys: memoryUsage.keys.toList()); }); } @@ -516,7 +516,7 @@ class ListStatistics { assert(data.isNotEmpty); assert(data.length % 2 == 1); final List sortedData = data.toList()..sort(); - return new ListStatistics._( + return ListStatistics._( sortedData.first, sortedData.last, sortedData[(sortedData.length - 1) ~/ 2], @@ -540,9 +540,9 @@ class ListStatistics { class _UnzipListEntry { factory _UnzipListEntry.fromLine(String line) { - final List data = line.trim().split(new RegExp('\\s+')); + final List data = line.trim().split(RegExp('\\s+')); assert(data.length == 8); - return new _UnzipListEntry._( + return _UnzipListEntry._( uncompressedSize: int.parse(data[0]), compressedSize: int.parse(data[2]), path: data[7], diff --git a/dev/devicelab/lib/tasks/plugin_tests.dart b/dev/devicelab/lib/tasks/plugin_tests.dart index 556d99c756..e0bd265c76 100644 --- a/dev/devicelab/lib/tasks/plugin_tests.dart +++ b/dev/devicelab/lib/tasks/plugin_tests.dart @@ -19,7 +19,7 @@ TaskFunction combine(List tasks) { return result; } } - return new TaskResult.success(null); + return TaskResult.success(null); }; } @@ -46,9 +46,9 @@ class PluginTest { } finally { await project.delete(); } - return new TaskResult.success(null); + return TaskResult.success(null); } catch (e) { - return new TaskResult.failure(e.toString()); + return TaskResult.failure(e.toString()); } finally { rmTree(tempDir); } @@ -68,13 +68,13 @@ class FlutterProject { options: ['--org', 'io.flutter.devicelab']..addAll(options)..add('plugintest') ); }); - return new FlutterProject(directory, 'plugintest'); + return FlutterProject(directory, 'plugintest'); } String get rootPath => path.join(parent.path, name); Future addPlugin(String plugin) async { - final File pubspec = new File(path.join(rootPath, 'pubspec.yaml')); + final File pubspec = File(path.join(rootPath, 'pubspec.yaml')); String content = await pubspec.readAsString(); content = content.replaceFirst( '\ndependencies:\n', @@ -84,7 +84,7 @@ class FlutterProject { } Future build(String target) async { - await inDirectory(new Directory(rootPath), () async { + await inDirectory(Directory(rootPath), () async { await flutter('build', options: [target]); }); } @@ -99,7 +99,7 @@ class FlutterProject { canFail: true, ); // TODO(ianh): Investigating if flakiness is timing dependent. - await new Future.delayed(const Duration(seconds: 10)); + await Future.delayed(const Duration(seconds: 10)); } rmTree(parent); } diff --git a/dev/devicelab/lib/tasks/sample_catalog_generator.dart b/dev/devicelab/lib/tasks/sample_catalog_generator.dart index 3d2175fd04..ef52a3d625 100644 --- a/dev/devicelab/lib/tasks/sample_catalog_generator.dart +++ b/dev/devicelab/lib/tasks/sample_catalog_generator.dart @@ -44,5 +44,5 @@ Future samplePageCatalogGenerator(String authorizationToken) async { ); }); - return new TaskResult.success(null); + return TaskResult.success(null); } diff --git a/dev/devicelab/lib/tasks/save_catalog_screenshots.dart b/dev/devicelab/lib/tasks/save_catalog_screenshots.dart index b21b773b00..727358bd19 100644 --- a/dev/devicelab/lib/tasks/save_catalog_screenshots.dart +++ b/dev/devicelab/lib/tasks/save_catalog_screenshots.dart @@ -42,19 +42,19 @@ class Upload { Duration get timeLimit { if (retryCount == 0) return const Duration(milliseconds: 1000); - random ??= new math.Random(); - return new Duration(milliseconds: random.nextInt(1000) + math.pow(2, retryCount) * 1000); + random ??= math.Random(); + return Duration(milliseconds: random.nextInt(1000) + math.pow(2, retryCount) * 1000); } Future save(HttpClient client, String name, List content) async { try { - final Uri uri = new Uri.https(uriAuthority, uriPath, { + final Uri uri = Uri.https(uriAuthority, uriPath, { 'uploadType': 'media', 'name': name, }); final HttpClientRequest request = await client.postUrl(uri); request - ..headers.contentType = new ContentType('image', 'png') + ..headers.contentType = ContentType('image', 'png') ..headers.add('Authorization', 'Bearer $authorizationToken') ..add(content); @@ -77,9 +77,9 @@ class Upload { Future run(HttpClient client) async { assert(!isComplete); if (retryCount > 2) - throw new UploadError('upload of "$fromPath" to "$largeName" and "$smallName" failed after 2 retries'); + throw UploadError('upload of "$fromPath" to "$largeName" and "$smallName" failed after 2 retries'); - largeImage ??= await new File(fromPath).readAsBytes(); + largeImage ??= await File(fromPath).readAsBytes(); smallImage ??= encodePng(copyResize(decodePng(largeImage), 300)); if (!largeImageSaved) @@ -97,12 +97,12 @@ Future saveScreenshots(List fromPaths, List largeNames, Li assert(fromPaths.length == largeNames.length); assert(fromPaths.length == smallNames.length); - List uploads = new List(fromPaths.length); + List uploads = List(fromPaths.length); for (int index = 0; index < uploads.length; index += 1) - uploads[index] = new Upload(fromPaths[index], largeNames[index], smallNames[index]); + uploads[index] = Upload(fromPaths[index], largeNames[index], smallNames[index]); while (uploads.any(Upload.isNotComplete)) { - final HttpClient client = new HttpClient(); + final HttpClient client = HttpClient(); uploads = uploads.where(Upload.isNotComplete).toList(); await Future.wait(uploads.map((Upload upload) => upload.run(client))); client.close(force: true); diff --git a/dev/devicelab/test/adb_test.dart b/dev/devicelab/test/adb_test.dart index e2ac66a265..525746fdfa 100644 --- a/dev/devicelab/test/adb_test.dart +++ b/dev/devicelab/test/adb_test.dart @@ -17,7 +17,7 @@ void main() { setUp(() { FakeDevice.resetLog(); device = null; - device = new FakeDevice(); + device = FakeDevice(); }); tearDown(() { @@ -115,7 +115,7 @@ CommandArgs cmd({ List arguments, Map environment, }) { - return new CommandArgs( + return CommandArgs( command: command, arguments: arguments, environment: environment, @@ -183,7 +183,7 @@ class FakeDevice extends AndroidDevice { @override Future shellEval(String command, List arguments, { Map environment }) async { - commandLog.add(new CommandArgs( + commandLog.add(CommandArgs( command: command, arguments: arguments, environment: environment, @@ -193,7 +193,7 @@ class FakeDevice extends AndroidDevice { @override Future shellExec(String command, List arguments, { Map environment }) async { - commandLog.add(new CommandArgs( + commandLog.add(CommandArgs( command: command, arguments: arguments, environment: environment, diff --git a/dev/devicelab/test/common.dart b/dev/devicelab/test/common.dart index b36d043b0a..75cf5c36eb 100644 --- a/dev/devicelab/test/common.dart +++ b/dev/devicelab/test/common.dart @@ -11,4 +11,4 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; // TODO(ianh): Remove this file once https://github.com/dart-lang/matcher/issues/98 is fixed /// A matcher that compares the type of the actual value to the type argument T. -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 diff --git a/dev/devicelab/test/manifest_test.dart b/dev/devicelab/test/manifest_test.dart index ebbe35c6e1..4fad8a7fe1 100644 --- a/dev/devicelab/test/manifest_test.dart +++ b/dev/devicelab/test/manifest_test.dart @@ -20,7 +20,7 @@ void main() { expect(task.requiredAgentCapabilities, ['linux/android']); for (ManifestTask task in manifest.tasks) { - final File taskFile = new File('bin/tasks/${task.name}.dart'); + final File taskFile = File('bin/tasks/${task.name}.dart'); expect(taskFile.existsSync(), true, reason: 'File ${taskFile.path} corresponding to manifest task "${task.name}" not found'); } diff --git a/dev/devicelab/test/utils_test.dart b/dev/devicelab/test/utils_test.dart index 3718af7b0a..10d17b1889 100644 --- a/dev/devicelab/test/utils_test.dart +++ b/dev/devicelab/test/utils_test.dart @@ -13,7 +13,7 @@ void main() { }); test('understands RegExp', () { - expect(grep(new RegExp('^b'), from: 'ab\nba'), ['ba']); + expect(grep(RegExp('^b'), from: 'ab\nba'), ['ba']); }); }); } diff --git a/dev/integration_tests/android_semantics_testing/lib/main.dart b/dev/integration_tests/android_semantics_testing/lib/main.dart index 27d2a1cd33..1b7bf656e5 100644 --- a/dev/integration_tests/android_semantics_testing/lib/main.dart +++ b/dev/integration_tests/android_semantics_testing/lib/main.dart @@ -23,7 +23,7 @@ const MethodChannel kSemanticsChannel = MethodChannel('semantics'); Future dataHandler(String message) async { if (message.contains('getSemanticsNode')) { - final Completer completer = new Completer(); + final Completer completer = Completer(); final int id = int.tryParse(message.split('#')[1]) ?? 0; Future completeSemantics([Object _]) async { final dynamic result = await kSemanticsChannel.invokeMethod('getSemanticsNode', { @@ -37,7 +37,7 @@ Future dataHandler(String message) async { completeSemantics(); return completer.future; } - throw new UnimplementedError(); + throw UnimplementedError(); } const List routes = [ @@ -50,18 +50,18 @@ class TestApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( routes: { - selectionControlsRoute: (BuildContext context) => new SelectionControlsPage(), - textFieldRoute: (BuildContext context) => new TextFieldPage(), + selectionControlsRoute: (BuildContext context) => SelectionControlsPage(), + textFieldRoute: (BuildContext context) => TextFieldPage(), }, - home: new Builder( + home: Builder( builder: (BuildContext context) { - return new Scaffold( - body: new ListView( + return Scaffold( + body: ListView( children: routes.map((String value) { - return new MaterialButton( - child: new Text(value), + return MaterialButton( + child: Text(value), onPressed: () { Navigator.of(context).pushNamed(value); }, diff --git a/dev/integration_tests/android_semantics_testing/lib/src/common.dart b/dev/integration_tests/android_semantics_testing/lib/src/common.dart index e993f82966..43b316d8f0 100644 --- a/dev/integration_tests/android_semantics_testing/lib/src/common.dart +++ b/dev/integration_tests/android_semantics_testing/lib/src/common.dart @@ -51,7 +51,7 @@ class AndroidSemanticsNode { /// ] /// } factory AndroidSemanticsNode.deserialize(String value) { - return new AndroidSemanticsNode._(json.decode(value)); + return AndroidSemanticsNode._(json.decode(value)); } final Map _values; @@ -129,7 +129,7 @@ class AndroidSemanticsNode { Rect getRect() { final Map rawRect = _values['rect']; final Map rect = rawRect.cast(); - return new Rect.fromLTRB( + return Rect.fromLTRB( rect['left'].toDouble(), rect['top'].toDouble(), rect['right'].toDouble(), @@ -140,7 +140,7 @@ class AndroidSemanticsNode { /// Gets a [Size] which defines the size of the semantics node. Size getSize() { final Rect rect = getRect(); - return new Size(rect.bottom - rect.top, rect.right - rect.left); + return Size(rect.bottom - rect.top, rect.right - rect.left); } /// Gets a list of [AndroidSemanticsActions] which are defined for the node. diff --git a/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart b/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart index 79d7310b12..55d44ba91e 100644 --- a/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart +++ b/dev/integration_tests/android_semantics_testing/lib/src/flutter_test_alternative.dart @@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher; export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; /// A matcher that compares the type of the actual value to the type argument T. -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 diff --git a/dev/integration_tests/android_semantics_testing/lib/src/matcher.dart b/dev/integration_tests/android_semantics_testing/lib/src/matcher.dart index a3ce3be86f..f45d250861 100644 --- a/dev/integration_tests/android_semantics_testing/lib/src/matcher.dart +++ b/dev/integration_tests/android_semantics_testing/lib/src/matcher.dart @@ -31,7 +31,7 @@ Matcher hasAndroidSemantics({ bool isPassword, bool isLongClickable, }) { - return new _AndroidSemanticsMatcher( + return _AndroidSemanticsMatcher( text: text, contentDescription: contentDescription, className: className, diff --git a/dev/integration_tests/android_semantics_testing/lib/src/tests/controls_page.dart b/dev/integration_tests/android_semantics_testing/lib/src/tests/controls_page.dart index c83034401f..c8362b81f8 100644 --- a/dev/integration_tests/android_semantics_testing/lib/src/tests/controls_page.dart +++ b/dev/integration_tests/android_semantics_testing/lib/src/tests/controls_page.dart @@ -11,7 +11,7 @@ export 'controls_constants.dart'; /// A test page with a checkbox, three radio buttons, and a switch. class SelectionControlsPage extends StatefulWidget { @override - State createState() => new _SelectionControlsPageState(); + State createState() => _SelectionControlsPageState(); } class _SelectionControlsPageState extends State { @@ -53,13 +53,13 @@ class _SelectionControlsPageState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(leading: const BackButton(key: ValueKey('back'))), - body: new Material( - child: new Column(children: [ - new Row( + return Scaffold( + appBar: AppBar(leading: const BackButton(key: ValueKey('back'))), + body: Material( + child: Column(children: [ + Row( children: [ - new Checkbox( + Checkbox( key: checkbox1Key, value: _isChecked, onChanged: _updateCheckbox, @@ -72,23 +72,23 @@ class _SelectionControlsPageState extends State { ], ), const Spacer(), - new Row(children: [ - new Radio(key: radio1Key, value: 0, groupValue: _radio, onChanged: _updateRadio), - new Radio(key: radio2Key, value: 1, groupValue: _radio, onChanged: _updateRadio), - new Radio(key: radio3Key, value: 2, groupValue: _radio, onChanged: _updateRadio), + Row(children: [ + Radio(key: radio1Key, value: 0, groupValue: _radio, onChanged: _updateRadio), + Radio(key: radio2Key, value: 1, groupValue: _radio, onChanged: _updateRadio), + Radio(key: radio3Key, value: 2, groupValue: _radio, onChanged: _updateRadio), ]), const Spacer(), - new Switch( + Switch( key: switchKey, value: _isOn, onChanged: _updateSwitch, ), const Spacer(), - new MergeSemantics( - child: new Row( + MergeSemantics( + child: Row( children: [ const Text(switchLabel), - new Switch( + Switch( key: labeledSwitchKey, value: _isLabeledOn, onChanged: _updateLabeledSwitch, diff --git a/dev/integration_tests/android_semantics_testing/lib/src/tests/text_field_page.dart b/dev/integration_tests/android_semantics_testing/lib/src/tests/text_field_page.dart index 2719265a50..dcce107a5c 100644 --- a/dev/integration_tests/android_semantics_testing/lib/src/tests/text_field_page.dart +++ b/dev/integration_tests/android_semantics_testing/lib/src/tests/text_field_page.dart @@ -11,28 +11,28 @@ export 'text_field_constants.dart'; /// A page with a normal text field and a password field. class TextFieldPage extends StatefulWidget { @override - State createState() => new _TextFieldPageState(); + State createState() => _TextFieldPageState(); } class _TextFieldPageState extends State { - final TextEditingController _normalController = new TextEditingController(); - final TextEditingController _passwordController = new TextEditingController(); + final TextEditingController _normalController = TextEditingController(); + final TextEditingController _passwordController = TextEditingController(); final Key normalTextFieldKey = const ValueKey(normalTextFieldKeyValue); final Key passwordTextFieldKey = const ValueKey(passwordTextFieldKeyValue); @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(leading: const BackButton(key: ValueKey('back'))), - body: new Material( - child: new Column(children: [ - new TextField( + return Scaffold( + appBar: AppBar(leading: const BackButton(key: ValueKey('back'))), + body: Material( + child: Column(children: [ + TextField( key: normalTextFieldKey, controller: _normalController, autofocus: false, ), const Spacer(), - new TextField( + TextField( key: passwordTextFieldKey, controller: _passwordController, obscureText: true, diff --git a/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart b/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart index 07172aa57f..2670eb03d2 100644 --- a/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart +++ b/dev/integration_tests/android_semantics_testing/test_driver/main_test.dart @@ -17,7 +17,7 @@ void main() { Future getSemantics(SerializableFinder finder) async { final int id = await driver.getSemanticsId(finder); final String data = await driver.requestData('getSemanticsNode#$id'); - return new AndroidSemanticsNode.deserialize(data); + return AndroidSemanticsNode.deserialize(data); } setUpAll(() async { diff --git a/dev/integration_tests/android_views/lib/main.dart b/dev/integration_tests/android_views/lib/main.dart index d1b03e689d..e1d0679a2d 100644 --- a/dev/integration_tests/android_views/lib/main.dart +++ b/dev/integration_tests/android_views/lib/main.dart @@ -23,7 +23,7 @@ const String kEventsFileName = 'touchEvents'; /// set by the app in which case the requestData call will only complete once the app is ready /// for it. class FutureDataHandler { - final Completer handlerCompleter = new Completer(); + final Completer handlerCompleter = Completer(); Future handleMessage(String message) async { final DataHandler handler = await handlerCompleter.future; @@ -31,20 +31,20 @@ class FutureDataHandler { } } -FutureDataHandler driverDataHandler = new FutureDataHandler(); +FutureDataHandler driverDataHandler = FutureDataHandler(); void main() { enableFlutterDriverExtension(handler: driverDataHandler.handleMessage); - runApp(new MyApp()); + runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Android Views Integration Test', - home: new Scaffold( - body: new PlatformViewPage(), + home: Scaffold( + body: PlatformViewPage(), ), ); } @@ -52,7 +52,7 @@ class MyApp extends StatelessWidget { class PlatformViewPage extends StatefulWidget { @override - State createState() => new PlatformViewState(); + State createState() => PlatformViewState(); } class PlatformViewState extends State { @@ -68,27 +68,27 @@ class PlatformViewState extends State { @override Widget build(BuildContext context) { - return new Column( + return Column( children: [ - new SizedBox( + SizedBox( height: 300.0, - child: new AndroidView( + child: AndroidView( viewType: 'simple_view', onPlatformViewCreated: onPlatformViewCreated), ), - new Expanded( - child: new ListView.builder( + Expanded( + child: ListView.builder( itemBuilder: buildEventTile, itemCount: flutterViewEvents.length, ), ), - new Row( + Row( children: [ - new RaisedButton( + RaisedButton( child: const Text('RECORD'), onPressed: listenToFlutterViewEvents, ), - new RaisedButton( + RaisedButton( child: const Text('CLEAR'), onPressed: () { setState(() { @@ -97,7 +97,7 @@ class PlatformViewState extends State { }); }, ), - new RaisedButton( + RaisedButton( child: const Text('SAVE'), onPressed: () { const StandardMessageCodec codec = StandardMessageCodec(); @@ -105,7 +105,7 @@ class PlatformViewState extends State { codec.encodeMessage(flutterViewEvents), context); }, ), - new RaisedButton( + RaisedButton( key: const ValueKey('play'), child: const Text('PLAY FILE'), onPressed: () { playEventsFile(); }, @@ -138,7 +138,7 @@ class PlatformViewState extends State { if (flutterViewEvents.length != embeddedViewEvents.length) return 'Synthesized ${flutterViewEvents.length} events but the embedded view received ${embeddedViewEvents.length} events'; - final StringBuffer diff = new StringBuffer(); + final StringBuffer diff = StringBuffer(); for (int i = 0; i < flutterViewEvents.length; ++i) { final String currentDiff = diffMotionEvents(flutterViewEvents[i], embeddedViewEvents[i]); if (currentDiff.isEmpty) @@ -168,7 +168,7 @@ class PlatformViewState extends State { try { final Directory outDir = await getExternalStorageDirectory(); // This test only runs on Android so we can assume path separator is '/'. - final File file = new File('${outDir.path}/$kEventsFileName'); + final File file = File('${outDir.path}/$kEventsFileName'); await file.writeAsBytes(data.buffer.asUint8List(0, data.lengthInBytes), flush: true); showMessage(context, 'Saved original events to ${file.path}'); } catch (e) { @@ -177,14 +177,14 @@ class PlatformViewState extends State { } void showMessage(BuildContext context, String message) { - Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text(message), + Scaffold.of(context).showSnackBar(SnackBar( + content: Text(message), duration: const Duration(seconds: 3), )); } void onPlatformViewCreated(int id) { - viewChannel = new MethodChannel('simple_view/$id'); + viewChannel = MethodChannel('simple_view/$id'); viewChannel.setMethodCallHandler(onViewMethodChannelCall); driverDataHandler.handlerCompleter.complete(handleDriverMessage); } @@ -192,7 +192,7 @@ class PlatformViewState extends State { void listenToFlutterViewEvents() { channel.invokeMethod('pipeFlutterViewEvents'); viewChannel.invokeMethod('pipeTouchEvents'); - new Timer(const Duration(seconds: 3), () { + Timer(const Duration(seconds: 3), () { channel.invokeMethod('stopFlutterViewEvents'); viewChannel.invokeMethod('stopTouchEvents'); }); @@ -216,7 +216,7 @@ class PlatformViewState extends State { setState(() {}); break; } - return new Future.sync(null); + return Future.sync(null); } Future onViewMethodChannelCall(MethodCall call) { @@ -229,14 +229,14 @@ class PlatformViewState extends State { setState(() {}); break; } - return new Future.sync(null); + return Future.sync(null); } Widget buildEventTile(BuildContext context, int index) { if (embeddedViewEvents.length > index) - return new TouchEventDiff( + return TouchEventDiff( flutterViewEvents[index], embeddedViewEvents[index]); - return new Text( + return Text( 'Unmatched event, action: ${flutterViewEvents[index]['action']}'); } } @@ -262,23 +262,23 @@ class TouchEventDiff extends StatelessWidget { color = Colors.red; msg = '[$actionName] $diff'; } - return new GestureDetector( + return GestureDetector( onLongPress: () { print('expected:'); prettyPrintEvent(originalEvent); print('\nactual:'); prettyPrintEvent(synthesizedEvent); }, - child: new Container( + child: Container( color: color, margin: const EdgeInsets.only(bottom: 2.0), - child: new Text(msg), + child: Text(msg), ), ); } void prettyPrintEvent(Map event) { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); final int action = event['action']; final int maskedAction = getActionMasked(action); final String actionName = getActionName(maskedAction, action); diff --git a/dev/integration_tests/android_views/lib/motion_event_diff.dart b/dev/integration_tests/android_views/lib/motion_event_diff.dart index ecd2c5238a..defe5d1cd3 100644 --- a/dev/integration_tests/android_views/lib/motion_event_diff.dart +++ b/dev/integration_tests/android_views/lib/motion_event_diff.dart @@ -19,7 +19,7 @@ String diffMotionEvents( Map originalEvent, Map synthesizedEvent, ) { - final StringBuffer diff = new StringBuffer(); + final StringBuffer diff = StringBuffer(); diffMaps(originalEvent, synthesizedEvent, diff, excludeKeys: const [ 'pointerProperties', // Compared separately. diff --git a/dev/integration_tests/android_views/test_driver/main_test.dart b/dev/integration_tests/android_views/test_driver/main_test.dart index 25f4096803..5e9315e30b 100644 --- a/dev/integration_tests/android_views/test_driver/main_test.dart +++ b/dev/integration_tests/android_views/test_driver/main_test.dart @@ -12,7 +12,7 @@ Future main() async { setUpAll(() async { print('Cloning goldens repository...'); - final GoldensClient goldensClient = new GoldensClient(); + final GoldensClient goldensClient = GoldensClient(); await goldensClient.prepare(); }); diff --git a/dev/integration_tests/channels/lib/main.dart b/dev/integration_tests/channels/lib/main.dart index 142a43c20f..9c95fbf26f 100644 --- a/dev/integration_tests/channels/lib/main.dart +++ b/dev/integration_tests/channels/lib/main.dart @@ -15,16 +15,16 @@ import 'src/test_step.dart'; void main() { enableFlutterDriverExtension(); - runApp(new TestApp()); + runApp(TestApp()); } class TestApp extends StatefulWidget { @override - _TestAppState createState() => new _TestAppState(); + _TestAppState createState() => _TestAppState(); } class _TestAppState extends State { - static final dynamic anUnknownValue = new DateTime.fromMillisecondsSinceEpoch(1520777802314); + static final dynamic anUnknownValue = DateTime.fromMillisecondsSinceEpoch(1520777802314); static final List aList = [ false, 0, @@ -43,24 +43,24 @@ class _TestAppState extends State { {'key': 42} ], }; - static final Uint8List someUint8s = new Uint8List.fromList([ + static final Uint8List someUint8s = Uint8List.fromList([ 0xBA, 0x5E, 0xBA, 0x11, ]); - static final Int32List someInt32s = new Int32List.fromList([ + static final Int32List someInt32s = Int32List.fromList([ -0x7fffffff - 1, 0, 0x7fffffff, ]); - static final Int64List someInt64s = new Int64List.fromList([ + static final Int64List someInt64s = Int64List.fromList([ -0x7fffffffffffffff - 1, 0, 0x7fffffffffffffff, ]); static final Float64List someFloat64s = - new Float64List.fromList([ + Float64List.fromList([ double.nan, double.negativeInfinity, -double.maxFinite, @@ -73,7 +73,7 @@ class _TestAppState extends State { ]); static final dynamic aCompoundUnknownValue = [ anUnknownValue, - new Pair(anUnknownValue, aList), + Pair(anUnknownValue, aList), ]; static final List steps = [ () => methodCallJsonSuccessHandshake(null), @@ -97,8 +97,8 @@ class _TestAppState extends State { () => methodCallStandardErrorHandshake('world'), () => methodCallStandardNotImplementedHandshake(), () => basicBinaryHandshake(null), - () => basicBinaryHandshake(new ByteData(0)), - () => basicBinaryHandshake(new ByteData(4)..setUint32(0, 0x12345678)), + () => basicBinaryHandshake(ByteData(0)), + () => basicBinaryHandshake(ByteData(4)..setUint32(0, 0x12345678)), () => basicStringHandshake('hello, world'), () => basicStringHandshake('hello \u263A \u{1f602} unicode'), () => basicStringHandshake(''), @@ -166,7 +166,7 @@ class _TestAppState extends State { if (_step < steps.length) _result = steps[_step++](); else - _result = new Future.value(TestStepResult.complete); + _result = Future.value(TestStepResult.complete); }); } @@ -174,25 +174,25 @@ class _TestAppState extends State { BuildContext context, AsyncSnapshot snapshot, ) { - return new TestStepResult.fromSnapshot(snapshot).asWidget(context); + return TestStepResult.fromSnapshot(snapshot).asWidget(context); } @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Channels Test', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Channels Test'), ), - body: new Padding( + body: Padding( padding: const EdgeInsets.all(20.0), - child: new FutureBuilder( + child: FutureBuilder( future: _result, builder: _buildTestResultWidget, ), ), - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( key: const ValueKey('step'), onPressed: _executeNextStep, child: const Icon(Icons.navigate_next), diff --git a/dev/integration_tests/channels/lib/src/basic_messaging.dart b/dev/integration_tests/channels/lib/src/basic_messaging.dart index 7343e73ec7..4bd80fcba8 100644 --- a/dev/integration_tests/channels/lib/src/basic_messaging.dart +++ b/dev/integration_tests/channels/lib/src/basic_messaging.dart @@ -33,9 +33,9 @@ class ExtendedStandardMessageCodec extends StandardMessageCodec { dynamic readValueOfType(int type, ReadBuffer buffer) { switch (type) { case _dateTime: - return new DateTime.fromMillisecondsSinceEpoch(buffer.getInt64()); + return DateTime.fromMillisecondsSinceEpoch(buffer.getInt64()); case _pair: - return new Pair(readValue(buffer), readValue(buffer)); + return Pair(readValue(buffer), readValue(buffer)); default: return super.readValueOfType(type, buffer); } } diff --git a/dev/integration_tests/channels/lib/src/method_calls.dart b/dev/integration_tests/channels/lib/src/method_calls.dart index 04a11c3696..5b81044108 100644 --- a/dev/integration_tests/channels/lib/src/method_calls.dart +++ b/dev/integration_tests/channels/lib/src/method_calls.dart @@ -89,7 +89,7 @@ Future _methodCallErrorHandshake( final List received = []; channel.setMethodCallHandler((MethodCall call) async { received.add(call.arguments); - throw new PlatformException( + throw PlatformException( code: 'error', message: null, details: arguments); }); dynamic errorDetails = nothing; @@ -118,7 +118,7 @@ Future _methodCallNotImplementedHandshake( final List received = []; channel.setMethodCallHandler((MethodCall call) async { received.add(call.arguments); - throw new MissingPluginException(); + throw MissingPluginException(); }); dynamic result = nothing; dynamic error = nothing; diff --git a/dev/integration_tests/channels/lib/src/test_step.dart b/dev/integration_tests/channels/lib/src/test_step.dart index 5368f35a1f..04394f2f7c 100644 --- a/dev/integration_tests/channels/lib/src/test_step.dart +++ b/dev/integration_tests/channels/lib/src/test_step.dart @@ -72,21 +72,21 @@ class TestStepResult { final dynamic error; Widget asWidget(BuildContext context) { - return new Column( + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Text('Step: $name', style: bold), - new Text(description), + Text('Step: $name', style: bold), + Text(description), const Text(' '), - new Text('Msg sent: ${_toString(messageSent)}'), - new Text('Msg rvcd: ${_toString(messageReceived)}'), - new Text('Reply echo: ${_toString(replyEcho)}'), - new Text('Msg echo: ${_toString(messageEcho)}'), - new Text('Error: ${_toString(error)}'), + Text('Msg sent: ${_toString(messageSent)}'), + Text('Msg rvcd: ${_toString(messageReceived)}'), + Text('Reply echo: ${_toString(replyEcho)}'), + Text('Msg echo: ${_toString(messageEcho)}'), + Text('Error: ${_toString(error)}'), const Text(' '), - new Text( + Text( status.toString().substring('TestStatus.'.length), - key: new ValueKey( + key: ValueKey( status == TestStatus.pending ? 'nostatus' : 'status'), style: bold, ), @@ -117,7 +117,7 @@ Future resultOfHandshake( } else { status = TestStatus.ok; } - return new TestStepResult( + return TestStepResult( name, description, status, diff --git a/dev/integration_tests/external_ui/lib/main.dart b/dev/integration_tests/external_ui/lib/main.dart index 13b98bbfd0..7090b6a806 100644 --- a/dev/integration_tests/external_ui/lib/main.dart +++ b/dev/integration_tests/external_ui/lib/main.dart @@ -11,12 +11,12 @@ import 'package:flutter_driver/driver_extension.dart'; void main() { enableFlutterDriverExtension(); debugPrint('Application starting...'); - runApp(new MyApp()); + runApp(MyApp()); } class MyApp extends StatefulWidget { @override - State createState() => new MyAppState(); + State createState() => MyAppState(); } const MethodChannel channel = MethodChannel('texture'); @@ -92,7 +92,7 @@ Widget builds: $_widgetBuilds'''; /// Measures Flutter's frame rate. Future _calibrate() async { debugPrint('Awaiting calm (3 second pause)...'); - await new Future.delayed(const Duration(milliseconds: 3000)); + await Future.delayed(const Duration(milliseconds: 3000)); debugPrint('Calibrating...'); DateTime startTime; int tickCount = 0; @@ -100,7 +100,7 @@ Widget builds: $_widgetBuilds'''; ticker = createTicker((Duration time) { tickCount += 1; if (tickCount == calibrationTickCount) { // about 10 seconds - final Duration elapsed = new DateTime.now().difference(startTime); + final Duration elapsed = DateTime.now().difference(startTime); ticker.stop(); ticker.dispose(); setState(() { @@ -118,7 +118,7 @@ Press play to produce texture frames.'''; } }); ticker.start(); - startTime = new DateTime.now(); + startTime = DateTime.now(); setState(() { _summary = 'Calibrating...'; _icon = null; @@ -128,23 +128,23 @@ Press play to produce texture frames.'''; @override Widget build(BuildContext context) { _widgetBuilds += 1; - return new MaterialApp( - home: new Scaffold( - body: new Center( - child: new Column( + return MaterialApp( + home: Scaffold( + body: Center( + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Container( + Container( width: 300.0, height: 200.0, child: const Texture(textureId: 0), ), - new Container( + Container( width: 300.0, height: 60.0, color: Colors.grey, - child: new Center( - child: new Text( + child: Center( + child: Text( _summary, key: const ValueKey('summary'), ), @@ -153,9 +153,9 @@ Press play to produce texture frames.'''; ], ), ), - floatingActionButton: _icon == null ? null : new FloatingActionButton( + floatingActionButton: _icon == null ? null : FloatingActionButton( key: const ValueKey('fab'), - child: new Icon(_icon), + child: Icon(_icon), onPressed: _nextState, ), ), diff --git a/dev/integration_tests/external_ui/test_driver/main_test.dart b/dev/integration_tests/external_ui/test_driver/main_test.dart index c4021d1c4e..856eab4deb 100644 --- a/dev/integration_tests/external_ui/test_driver/main_test.dart +++ b/dev/integration_tests/external_ui/test_driver/main_test.dart @@ -7,8 +7,8 @@ import 'dart:async'; import 'package:flutter_driver/flutter_driver.dart'; import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; -final RegExp calibrationRegExp = new RegExp('Flutter frame rate is (.*)fps'); -final RegExp statsRegExp = new RegExp('Produced: (.*)fps\nConsumed: (.*)fps\nWidget builds: (.*)'); +final RegExp calibrationRegExp = RegExp('Flutter frame rate is (.*)fps'); +final RegExp statsRegExp = RegExp('Produced: (.*)fps\nConsumed: (.*)fps\nWidget builds: (.*)'); const Duration samplingTime = Duration(seconds: 8); Future main() async { @@ -38,7 +38,7 @@ Future main() async { // Texture frame stats at 0.5x Flutter frame rate await driver.tap(fab); - await new Future.delayed(samplingTime); + await Future.delayed(samplingTime); await driver.tap(fab); final String statsSlow = await driver.getText(summary); @@ -50,7 +50,7 @@ Future main() async { // Texture frame stats at 2.0x Flutter frame rate await driver.tap(fab); - await new Future.delayed(samplingTime); + await Future.delayed(samplingTime); await driver.tap(fab); final String statsFast = await driver.getText(summary); diff --git a/dev/integration_tests/flavors/lib/main.dart b/dev/integration_tests/flavors/lib/main.dart index 716f4125c2..b838200623 100644 --- a/dev/integration_tests/flavors/lib/main.dart +++ b/dev/integration_tests/flavors/lib/main.dart @@ -4,12 +4,12 @@ import 'package:flutter_driver/driver_extension.dart'; void main() { enableFlutterDriverExtension(); - runApp(new Center(child: new Flavor())); + runApp(Center(child: Flavor())); } class Flavor extends StatefulWidget { @override - _FlavorState createState() => new _FlavorState(); + _FlavorState createState() => _FlavorState(); } class _FlavorState extends State { @@ -27,11 +27,11 @@ class _FlavorState extends State { @override Widget build(BuildContext context) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, child: _flavor == null ? const Text('Awaiting flavor...') - : new Text(_flavor, key: const ValueKey('flavor')), + : Text(_flavor, key: const ValueKey('flavor')), ); } } diff --git a/dev/integration_tests/platform_interaction/lib/main.dart b/dev/integration_tests/platform_interaction/lib/main.dart index 5a10cc9add..8341d53e40 100644 --- a/dev/integration_tests/platform_interaction/lib/main.dart +++ b/dev/integration_tests/platform_interaction/lib/main.dart @@ -12,12 +12,12 @@ import 'src/test_step.dart'; void main() { enableFlutterDriverExtension(); - runApp(new TestApp()); + runApp(TestApp()); } class TestApp extends StatefulWidget { @override - _TestAppState createState() => new _TestAppState(); + _TestAppState createState() => _TestAppState(); } class _TestAppState extends State { @@ -37,7 +37,7 @@ class _TestAppState extends State { if (_step < steps.length) _result = steps[_step++](); else - _result = new Future.value(TestStepResult.complete); + _result = Future.value(TestStepResult.complete); }); } @@ -45,25 +45,25 @@ class _TestAppState extends State { BuildContext context, AsyncSnapshot snapshot, ) { - return new TestStepResult.fromSnapshot(snapshot).asWidget(context); + return TestStepResult.fromSnapshot(snapshot).asWidget(context); } @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Platform Interaction Test', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Platform Interaction Test'), ), - body: new Padding( + body: Padding( padding: const EdgeInsets.all(20.0), - child: new FutureBuilder( + child: FutureBuilder( future: _result, builder: _buildTestResultWidget, ), ), - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( key: const ValueKey('step'), onPressed: _executeNextStep, child: const Icon(Icons.navigate_next), diff --git a/dev/integration_tests/platform_interaction/lib/src/system_navigation.dart b/dev/integration_tests/platform_interaction/lib/src/system_navigation.dart index 963245966c..228dcc3806 100644 --- a/dev/integration_tests/platform_interaction/lib/src/system_navigation.dart +++ b/dev/integration_tests/platform_interaction/lib/src/system_navigation.dart @@ -12,7 +12,7 @@ Future systemNavigatorPop() { StringCodec(), ); - final Completer completer = new Completer(); + final Completer completer = Completer(); channel.setMessageHandler((String message) async { completer.complete( diff --git a/dev/integration_tests/platform_interaction/lib/src/test_step.dart b/dev/integration_tests/platform_interaction/lib/src/test_step.dart index c1c1702c83..7313e578b8 100644 --- a/dev/integration_tests/platform_interaction/lib/src/test_step.dart +++ b/dev/integration_tests/platform_interaction/lib/src/test_step.dart @@ -46,15 +46,15 @@ class TestStepResult { final TestStatus status; Widget asWidget(BuildContext context) { - return new Column( + return Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Text('Step: $name', style: bold), - new Text(description), + Text('Step: $name', style: bold), + Text(description), const Text(' '), - new Text( + Text( status.toString().substring('TestStatus.'.length), - key: new ValueKey( + key: ValueKey( status == TestStatus.pending ? 'nostatus' : 'status'), style: bold, ), diff --git a/dev/integration_tests/ui/lib/commands.dart b/dev/integration_tests/ui/lib/commands.dart index 2e066408b7..e15bbad87d 100644 --- a/dev/integration_tests/ui/lib/commands.dart +++ b/dev/integration_tests/ui/lib/commands.dart @@ -15,7 +15,7 @@ void main() { await WidgetsBinding.instance.reassembleApplication(); return log; }); - runApp(new MaterialApp(home: const Test())); + runApp(MaterialApp(home: const Test())); } class Test extends SingleChildRenderObjectWidget { @@ -23,7 +23,7 @@ class Test extends SingleChildRenderObjectWidget { @override RenderTest createRenderObject(BuildContext context) { - return new RenderTest(); + return RenderTest(); } } diff --git a/dev/integration_tests/ui/lib/driver.dart b/dev/integration_tests/ui/lib/driver.dart index c82f5e6f3d..c88430048b 100644 --- a/dev/integration_tests/ui/lib/driver.dart +++ b/dev/integration_tests/ui/lib/driver.dart @@ -8,13 +8,13 @@ import 'package:flutter_driver/driver_extension.dart'; void main() { enableFlutterDriverExtension(); - runApp(new DriverTestApp()); + runApp(DriverTestApp()); } class DriverTestApp extends StatefulWidget { @override State createState() { - return new DriverTestAppState(); + return DriverTestAppState(); } } @@ -24,20 +24,20 @@ class DriverTestAppState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('FlutterDriver test'), ), - body: new ListView( + body: ListView( padding: const EdgeInsets.all(5.0), children: [ - new Row( + Row( children: [ - new Expanded( - child: new Text(present ? 'present' : 'absent'), + Expanded( + child: Text(present ? 'present' : 'absent'), ), - new RaisedButton( + RaisedButton( child: const Text( 'toggle', key: ValueKey('togglePresent'), @@ -50,12 +50,12 @@ class DriverTestAppState extends State { ), ], ), - new Row( + Row( children: [ const Expanded( child: Text('hit testability'), ), - new DropdownButton( + DropdownButton( key: const ValueKey('dropdown'), value: _selectedValue, onChanged: (Letter newValue) { diff --git a/dev/integration_tests/ui/lib/keyboard_resize.dart b/dev/integration_tests/ui/lib/keyboard_resize.dart index cfa023fb76..6c762d5a01 100644 --- a/dev/integration_tests/ui/lib/keyboard_resize.dart +++ b/dev/integration_tests/ui/lib/keyboard_resize.dart @@ -12,49 +12,49 @@ void main() { // TODO(cbernaschina): remove when test flakiness is resolved return 'keyboard_resize'; }); - runApp(new MyApp()); + runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Text Editing', - theme: new ThemeData(primarySwatch: Colors.blue), - home: new MyHomePage(), + theme: ThemeData(primarySwatch: Colors.blue), + home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { - final TextEditingController _controller = new TextEditingController(); + final TextEditingController _controller = TextEditingController(); @override Widget build(BuildContext context) { - final TextField textField = new TextField( + final TextField textField = TextField( key: const Key(keys.kDefaultTextField), controller: _controller, - focusNode: new FocusNode(), + focusNode: FocusNode(), ); - return new Scaffold( - body: new Stack( + return Scaffold( + body: Stack( fit: StackFit.expand, alignment: Alignment.bottomCenter, children: [ - new LayoutBuilder( + LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new Center(child: new Text('${constraints.biggest.height}', key: const Key(keys.kHeightText))); + return Center(child: Text('${constraints.biggest.height}', key: const Key(keys.kHeightText))); } ), textField, ], ), - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( key: const Key(keys.kUnfocusButton), onPressed: () { textField.focusNode.unfocus(); }, tooltip: 'Unfocus', diff --git a/dev/integration_tests/ui/lib/keyboard_textfield.dart b/dev/integration_tests/ui/lib/keyboard_textfield.dart index 57ef481fdd..2fa5e8f493 100644 --- a/dev/integration_tests/ui/lib/keyboard_textfield.dart +++ b/dev/integration_tests/ui/lib/keyboard_textfield.dart @@ -10,27 +10,27 @@ import 'keys.dart' as keys; void main() { enableFlutterDriverExtension(); - runApp(new MyApp()); + runApp(MyApp()); } class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Keyboard & TextField', - theme: new ThemeData(primarySwatch: Colors.blue), - home: new MyHomePage(), + theme: ThemeData(primarySwatch: Colors.blue), + home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { - final ScrollController _controller = new ScrollController(); + final ScrollController _controller = ScrollController(); double offset = 0.0; @override @@ -45,18 +45,18 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - body: new Column( + return Scaffold( + body: Column( children: [ - new Text('$offset', + Text('$offset', key: const ValueKey(keys.kOffsetText), ), - new Expanded( - child: new ListView( + Expanded( + child: ListView( key: const ValueKey(keys.kListView), controller: _controller, children: [ - new Container( + Container( height: MediaQuery.of(context).size.height, ), const TextField( diff --git a/dev/integration_tests/ui/lib/screenshot.dart b/dev/integration_tests/ui/lib/screenshot.dart index 34bdcbf0cc..045e6f9e57 100644 --- a/dev/integration_tests/ui/lib/screenshot.dart +++ b/dev/integration_tests/ui/lib/screenshot.dart @@ -12,12 +12,12 @@ import 'package:flutter_driver/driver_extension.dart'; void main() { enableFlutterDriverExtension(); - runApp(new Toggler()); + runApp(Toggler()); } class Toggler extends StatefulWidget { @override - State createState() => new TogglerState(); + State createState() => TogglerState(); } class TogglerState extends State { @@ -25,15 +25,15 @@ class TogglerState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('FlutterDriver test'), ), - body: new Material( - child: new Column( + body: Material( + child: Column( children: [ - new FlatButton( + FlatButton( key: const ValueKey('toggle'), child: const Text('Toggle visibility'), onPressed: () { @@ -42,8 +42,8 @@ class TogglerState extends State { }); }, ), - new Expanded( - child: new ListView( + Expanded( + child: ListView( children: _buildRows(_visible ? 10 : 0), ), ), @@ -56,8 +56,8 @@ class TogglerState extends State { } List _buildRows(int count) { - return new List.generate(count, (int i) { - return new Row( + return List.generate(count, (int i) { + return Row( children: _buildCells(i / count), ); }); @@ -66,12 +66,12 @@ List _buildRows(int count) { /// Builds cells that are known to take time to render causing a delay on the /// GPU thread. List _buildCells(double epsilon) { - return new List.generate(15, (int i) { - return new Expanded( - child: new Material( + return List.generate(15, (int i) { + return Expanded( + child: Material( // A magic color that the test will be looking for on the screenshot. color: const Color(0xffff0102), - borderRadius: new BorderRadius.all(new Radius.circular(i.toDouble() + epsilon)), + borderRadius: BorderRadius.all(Radius.circular(i.toDouble() + epsilon)), elevation: 5.0, child: const SizedBox(height: 10.0, width: 10.0), ), diff --git a/dev/integration_tests/ui/test_driver/driver_test.dart b/dev/integration_tests/ui/test_driver/driver_test.dart index e036a4a0d4..2aca6ee88e 100644 --- a/dev/integration_tests/ui/test_driver/driver_test.dart +++ b/dev/integration_tests/ui/test_driver/driver_test.dart @@ -36,14 +36,14 @@ void main() { test('waitForAbsent should resolve when text "present" disappears', () async { // Begin waiting for it to disappear - final Completer whenWaitForAbsentResolves = new Completer(); + final Completer whenWaitForAbsentResolves = Completer(); driver.waitForAbsent(presentText).then( whenWaitForAbsentResolves.complete, onError: whenWaitForAbsentResolves.completeError, ); // Wait 1 second then make it disappear - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); await driver.tap(find.byValueKey('togglePresent')); // Ensure waitForAbsent resolves @@ -61,14 +61,14 @@ void main() { test('waitFor should resolve when text "present" reappears', () async { // Begin waiting for it to reappear - final Completer whenWaitForResolves = new Completer(); + final Completer whenWaitForResolves = Completer(); driver.waitFor(presentText).then( whenWaitForResolves.complete, onError: whenWaitForResolves.completeError, ); // Wait 1 second then make it appear - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); await driver.tap(find.byValueKey('togglePresent')); // Ensure waitFor resolves diff --git a/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart b/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart index ae834a58f0..288f40b377 100644 --- a/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart +++ b/dev/integration_tests/ui/test_driver/keyboard_resize_test.dart @@ -33,7 +33,7 @@ void main() { final SerializableFinder defaultTextField = find.byValueKey(keys.kDefaultTextField); await driver.waitFor(defaultTextField); await driver.tap(defaultTextField); - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Measure the height with keyboard displayed. final String heightWithKeyboardShown = await driver.getText(heightText); @@ -43,7 +43,7 @@ void main() { final SerializableFinder unfocusButton = find.byValueKey(keys.kUnfocusButton); await driver.waitFor(unfocusButton); await driver.tap(unfocusButton); - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Measure the final height. final String endHeight = await driver.getText(heightText); diff --git a/dev/integration_tests/ui/test_driver/keyboard_textfield_test.dart b/dev/integration_tests/ui/test_driver/keyboard_textfield_test.dart index a2ee650b63..5869bd11d9 100644 --- a/dev/integration_tests/ui/test_driver/keyboard_textfield_test.dart +++ b/dev/integration_tests/ui/test_driver/keyboard_textfield_test.dart @@ -41,7 +41,7 @@ void main() { // Bring up keyboard await driver.tap(textFieldFinder); - await new Future.delayed(const Duration(seconds: 1)); + await Future.delayed(const Duration(seconds: 1)); // Ensure that TextField is visible again await driver.waitFor(textFieldFinder); diff --git a/dev/manual_tests/lib/animated_icons.dart b/dev/manual_tests/lib/animated_icons.dart index 216a97b335..718dba876d 100644 --- a/dev/manual_tests/lib/animated_icons.dart +++ b/dev/manual_tests/lib/animated_icons.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; class AnimatedIconsTestApp extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Animated Icons Test', home: const Scaffold( body: IconsList(), @@ -21,8 +21,8 @@ class IconsList extends StatelessWidget { @override Widget build(BuildContext context) { - return new ListView( - children: samples.map((IconSample s) => new IconSampleRow(s)).toList(), + return ListView( + children: samples.map((IconSample s) => IconSampleRow(s)).toList(), ); } } @@ -33,7 +33,7 @@ class IconSampleRow extends StatefulWidget { final IconSample sample; @override - State createState() => new IconSampleRowState(); + State createState() => IconSampleRowState(); } class IconSampleRowState extends State with SingleTickerProviderStateMixin { @@ -41,17 +41,17 @@ class IconSampleRowState extends State with SingleTickerProviderS @override Widget build(BuildContext context) { - return new ListTile( - leading: new InkWell( + return ListTile( + leading: InkWell( onTap: () { progress.forward(from: 0.0); }, - child: new AnimatedIcon( + child: AnimatedIcon( icon: widget.sample.icon, progress: progress, color: Colors.lightBlue, ), ), - title: new Text(widget.sample.description), - subtitle: new Slider( + title: Text(widget.sample.description), + subtitle: Slider( value: progress.value, onChanged: (double v) { progress.animateTo(v, duration: Duration.zero); }, ), @@ -61,7 +61,7 @@ class IconSampleRowState extends State with SingleTickerProviderS @override void initState() { super.initState(); - progress = new AnimationController(vsync: this, duration: const Duration(milliseconds: 300)); + progress = AnimationController(vsync: this, duration: const Duration(milliseconds: 300)); progress.addListener(_handleChange); } @@ -105,4 +105,4 @@ class IconSample { final String description; } -void main() => runApp(new AnimatedIconsTestApp()); +void main() => runApp(AnimatedIconsTestApp()); diff --git a/dev/manual_tests/lib/card_collection.dart b/dev/manual_tests/lib/card_collection.dart index 958fd57faf..896ec524d3 100644 --- a/dev/manual_tests/lib/card_collection.dart +++ b/dev/manual_tests/lib/card_collection.dart @@ -9,18 +9,18 @@ import 'package:flutter/rendering.dart' show debugDumpRenderTree; class CardModel { CardModel(this.value, this.height) { - textController = new TextEditingController(text: 'Item $value'); + textController = TextEditingController(text: 'Item $value'); } int value; double height; int get color => ((value % 9) + 1) * 100; TextEditingController textController; - Key get key => new ObjectKey(this); + Key get key => ObjectKey(this); } class CardCollection extends StatefulWidget { @override - CardCollectionState createState() => new CardCollectionState(); + CardCollectionState createState() => CardCollectionState(); } class CardCollectionState extends State { @@ -51,7 +51,7 @@ class CardCollectionState extends State { void _updateCardSizes() { if (_fixedSizeCards) return; - _cardModels = new List.generate( + _cardModels = List.generate( _cardModels.length, (int i) { _cardModels[i].height = _editable ? max(_cardHeights[i], 60.0) : _cardHeights[i]; @@ -61,17 +61,17 @@ class CardCollectionState extends State { } void _initVariableSizedCardModels() { - _cardModels = new List.generate( + _cardModels = List.generate( _cardHeights.length, - (int i) => new CardModel(i, _editable ? max(_cardHeights[i], 60.0) : _cardHeights[i]) + (int i) => CardModel(i, _editable ? max(_cardHeights[i], 60.0) : _cardHeights[i]) ); } void _initFixedSizedCardModels() { const int cardCount = 27; - _cardModels = new List.generate( + _cardModels = List.generate( cardCount, - (int i) => new CardModel(i, kFixedCardHeight), + (int i) => CardModel(i, kFixedCardHeight), ); } @@ -97,10 +97,10 @@ class CardCollectionState extends State { } Widget _buildDrawer() { - return new Drawer( - child: new IconTheme( + return Drawer( + child: IconTheme( data: const IconThemeData(color: Colors.black), - child: new ListView( + child: ListView( children: [ const DrawerHeader(child: Center(child: Text('Options'))), buildDrawerCheckbox('Make card labels editable', _editable, _toggleEditable), @@ -121,7 +121,7 @@ class CardCollectionState extends State { buildFontRadioItem('Center-align text', TextAlign.center, _textAlign, _changeTextAlign, icon: Icons.format_align_center, enabled: !_editable), buildFontRadioItem('Right-align text', TextAlign.right, _textAlign, _changeTextAlign, icon: Icons.format_align_right, enabled: !_editable), const Divider(), - new ListTile( + ListTile( leading: const Icon(Icons.dvr), onTap: () { debugDumpApp(); debugDumpRenderTree(); }, title: const Text('Dump App to Console'), @@ -182,10 +182,10 @@ class CardCollectionState extends State { } Widget buildDrawerCheckbox(String label, bool value, void callback(), { bool enabled = true }) { - return new ListTile( + return ListTile( onTap: enabled ? callback : null, - title: new Text(label), - trailing: new Checkbox( + title: Text(label), + trailing: Checkbox( value: value, onChanged: enabled ? (_) { callback(); } : null, ), @@ -193,11 +193,11 @@ class CardCollectionState extends State { } Widget buildDrawerColorRadioItem(String label, MaterialColor itemValue, MaterialColor currentValue, ValueChanged onChanged, { IconData icon, bool enabled = true }) { - return new ListTile( - leading: new Icon(icon), - title: new Text(label), + return ListTile( + leading: Icon(icon), + title: Text(label), onTap: enabled ? () { onChanged(itemValue); } : null, - trailing: new Radio( + trailing: Radio( value: itemValue, groupValue: currentValue, onChanged: enabled ? onChanged : null, @@ -206,11 +206,11 @@ class CardCollectionState extends State { } Widget buildDrawerDirectionRadioItem(String label, DismissDirection itemValue, DismissDirection currentValue, ValueChanged onChanged, { IconData icon, bool enabled = true }) { - return new ListTile( - leading: new Icon(icon), - title: new Text(label), + return ListTile( + leading: Icon(icon), + title: Text(label), onTap: enabled ? () { onChanged(itemValue); } : null, - trailing: new Radio( + trailing: Radio( value: itemValue, groupValue: currentValue, onChanged: enabled ? onChanged : null, @@ -219,11 +219,11 @@ class CardCollectionState extends State { } Widget buildFontRadioItem(String label, TextAlign itemValue, TextAlign currentValue, ValueChanged onChanged, { IconData icon, bool enabled = true }) { - return new ListTile( - leading: new Icon(icon), - title: new Text(label), + return ListTile( + leading: Icon(icon), + title: Text(label), onTap: enabled ? () { onChanged(itemValue); } : null, - trailing: new Radio( + trailing: Radio( value: itemValue, groupValue: currentValue, onChanged: enabled ? onChanged : null, @@ -232,34 +232,34 @@ class CardCollectionState extends State { } Widget _buildAppBar(BuildContext context) { - return new AppBar( + return AppBar( actions: [ - new Text(_dismissDirectionText(_dismissDirection)) + Text(_dismissDirectionText(_dismissDirection)) ], - flexibleSpace: new Container( + flexibleSpace: Container( padding: const EdgeInsets.only(left: 72.0), height: 128.0, alignment: const Alignment(-1.0, 0.5), - child: new Text('Swipe Away: ${_cardModels.length}', style: Theme.of(context).primaryTextTheme.title), + child: Text('Swipe Away: ${_cardModels.length}', style: Theme.of(context).primaryTextTheme.title), ), ); } Widget _buildCard(BuildContext context, int index) { final CardModel cardModel = _cardModels[index]; - final Widget card = new Dismissible( - key: new ObjectKey(cardModel), + final Widget card = Dismissible( + key: ObjectKey(cardModel), direction: _dismissDirection, onDismissed: (DismissDirection direction) { dismissCard(cardModel); }, - child: new Card( + child: Card( color: _primaryColor[cardModel.color], - child: new Container( + child: Container( height: cardModel.height, padding: const EdgeInsets.all(kCardMargins), child: _editable ? - new Center( - child: new TextField( - key: new GlobalObjectKey(cardModel), + Center( + child: TextField( + key: GlobalObjectKey(cardModel), controller: cardModel.textController, ), ) @@ -267,11 +267,11 @@ class CardCollectionState extends State { style: cardLabelStyle.copyWith( fontSize: _varyFontSizes ? 5.0 + index : null ), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text(cardModel.textController.text, textAlign: _textAlign), + Text(cardModel.textController.text, textAlign: _textAlign), ], ), ), @@ -297,12 +297,12 @@ class CardCollectionState extends State { // TODO(abarth): This icon is wrong in RTL. Widget leftArrowIcon = const Icon(Icons.arrow_back, size: 36.0); if (_dismissDirection == DismissDirection.startToEnd) - leftArrowIcon = new Opacity(opacity: 0.1, child: leftArrowIcon); + leftArrowIcon = Opacity(opacity: 0.1, child: leftArrowIcon); // TODO(abarth): This icon is wrong in RTL. Widget rightArrowIcon = const Icon(Icons.arrow_forward, size: 36.0); if (_dismissDirection == DismissDirection.endToStart) - rightArrowIcon = new Opacity(opacity: 0.1, child: rightArrowIcon); + rightArrowIcon = Opacity(opacity: 0.1, child: rightArrowIcon); final ThemeData theme = Theme.of(context); final TextStyle backgroundTextStyle = theme.primaryTextTheme.title; @@ -312,18 +312,18 @@ class CardCollectionState extends State { // size of the background,card Stack will be based only on the card. The // Viewport ensures that when the card's resize animation occurs, the // background (text and icons) will just be clipped, not resized. - final Widget background = new Positioned.fill( - child: new Container( + final Widget background = Positioned.fill( + child: Container( margin: const EdgeInsets.all(4.0), - child: new SingleChildScrollView( - child: new Container( + child: SingleChildScrollView( + child: Container( height: cardModel.height, color: theme.primaryColor, - child: new Row( + child: Row( children: [ leftArrowIcon, - new Expanded( - child: new Text(backgroundMessage, + Expanded( + child: Text(backgroundMessage, style: backgroundTextStyle, textAlign: TextAlign.center, ), @@ -336,10 +336,10 @@ class CardCollectionState extends State { ), ); - return new IconTheme( + return IconTheme( key: cardModel.key, data: const IconThemeData(color: Colors.white), - child: new Stack(children: [background, card]), + child: Stack(children: [background, card]), ); } @@ -355,32 +355,32 @@ class CardCollectionState extends State { @override Widget build(BuildContext context) { - Widget cardCollection = new ListView.builder( + Widget cardCollection = ListView.builder( itemExtent: _fixedSizeCards ? kFixedCardHeight : null, itemCount: _cardModels.length, itemBuilder: _buildCard, ); if (_sunshine) { - cardCollection = new Stack( + cardCollection = Stack( children: [ - new Column(children: [new Image.network(_sunshineURL)]), - new ShaderMask(child: cardCollection, shaderCallback: _createShader), + Column(children: [Image.network(_sunshineURL)]), + ShaderMask(child: cardCollection, shaderCallback: _createShader), ], ); } - final Widget body = new Container( + final Widget body = Container( padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), color: _primaryColor.shade50, child: cardCollection, ); - return new Theme( - data: new ThemeData( + return Theme( + data: ThemeData( primarySwatch: _primaryColor, ), - child: new Scaffold( + child: Scaffold( appBar: _buildAppBar(context), drawer: _buildDrawer(), body: body, @@ -390,8 +390,8 @@ class CardCollectionState extends State { } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Cards', - home: new CardCollection(), + home: CardCollection(), )); } diff --git a/dev/manual_tests/lib/color_testing_demo.dart b/dev/manual_tests/lib/color_testing_demo.dart index 31f2265e1b..9efc544d7a 100644 --- a/dev/manual_tests/lib/color_testing_demo.dart +++ b/dev/manual_tests/lib/color_testing_demo.dart @@ -11,20 +11,20 @@ class ColorTestingDemo extends StatelessWidget { static const String routeName = '/color_demo'; @override - Widget build(BuildContext context) => new ColorDemoHome(); + Widget build(BuildContext context) => ColorDemoHome(); } class ColorDemoHome extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Color Demo')), - body: new ListView( + return Scaffold( + appBar: AppBar(title: const Text('Color Demo')), + body: ListView( padding: const EdgeInsets.all(5.0), children: [ - new Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/gbr.png'), - new Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/tf.png'), - new Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/wide-gamut.png'), + Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/gbr.png'), + Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/tf.png'), + Image.network('https://flutter.github.io/assets-for-api-docs/assets/tests/colors/wide-gamut.png'), const GradientRow(leftColor: Color(0xFFFF0000), rightColor: Color(0xFF00FF00)), const GradientRow(leftColor: Color(0xFF0000FF), rightColor: Color(0xFFFFFF00)), const GradientRow(leftColor: Color(0xFFFF0000), rightColor: Color(0xFF0000FF)), @@ -58,10 +58,10 @@ class GradientRow extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( height: 100.0, - decoration: new BoxDecoration( - gradient: new LinearGradient( + decoration: BoxDecoration( + gradient: LinearGradient( begin: Alignment.topLeft, end: Alignment.bottomRight, colors: [ leftColor, rightColor ], @@ -78,7 +78,7 @@ class ColorRow extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( height: 100.0, color: color, ); @@ -86,8 +86,8 @@ class ColorRow extends StatelessWidget { } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Color Testing Demo', - home: new ColorDemoHome(), + home: ColorDemoHome(), )); } diff --git a/dev/manual_tests/lib/drag_and_drop.dart b/dev/manual_tests/lib/drag_and_drop.dart index 39cdeaecea..cc27bf7d8c 100644 --- a/dev/manual_tests/lib/drag_and_drop.dart +++ b/dev/manual_tests/lib/drag_and_drop.dart @@ -8,7 +8,7 @@ import 'package:flutter/material.dart'; class ExampleDragTarget extends StatefulWidget { @override - ExampleDragTargetState createState() => new ExampleDragTargetState(); + ExampleDragTargetState createState() => ExampleDragTargetState(); } class ExampleDragTargetState extends State { @@ -22,15 +22,15 @@ class ExampleDragTargetState extends State { @override Widget build(BuildContext context) { - return new DragTarget( + return DragTarget( onAccept: _handleAccept, builder: (BuildContext context, List data, List rejectedData) { - return new Container( + return Container( height: 100.0, margin: const EdgeInsets.all(10.0), - decoration: new BoxDecoration( + decoration: BoxDecoration( color: data.isEmpty ? _color : Colors.grey.shade200, - border: new Border.all( + border: Border.all( width: 3.0, color: data.isEmpty ? Colors.white : Colors.blue ), @@ -50,21 +50,21 @@ class Dot extends StatefulWidget { final bool tappable; @override - DotState createState() => new DotState(); + DotState createState() => DotState(); } class DotState extends State { int taps = 0; @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: widget.tappable ? () { setState(() { taps += 1; }); } : null, - child: new Container( + child: Container( width: widget.size, height: widget.size, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: widget.color, - border: new Border.all(width: taps.toDouble()), + border: Border.all(width: taps.toDouble()), shape: BoxShape.circle ), child: widget.child @@ -97,17 +97,17 @@ class ExampleDragSource extends StatelessWidget { if (heavy) size *= kHeavyMultiplier; - final Widget contents = new DefaultTextStyle( + final Widget contents = DefaultTextStyle( style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center, - child: new Dot( + child: Dot( color: color, size: size, - child: new Center(child: child) + child: Center(child: child) ) ); - Widget feedback = new Opacity( + Widget feedback = Opacity( opacity: 0.75, child: contents ); @@ -115,8 +115,8 @@ class ExampleDragSource extends StatelessWidget { Offset feedbackOffset; DragAnchor anchor; if (!under) { - feedback = new Transform( - transform: new Matrix4.identity() + feedback = Transform( + transform: Matrix4.identity() ..translate(-size / 2.0, -(size / 2.0 + kFingerSize)), child: feedback ); @@ -128,7 +128,7 @@ class ExampleDragSource extends StatelessWidget { } if (heavy) { - return new LongPressDraggable( + return LongPressDraggable( data: color, child: contents, feedback: feedback, @@ -136,7 +136,7 @@ class ExampleDragSource extends StatelessWidget { dragAnchor: anchor ); } else { - return new Draggable( + return Draggable( data: color, child: contents, feedback: feedback, @@ -158,11 +158,11 @@ class DashOutlineCirclePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final double radius = size.shortestSide / 2.0; - final Paint paint = new Paint() + final Paint paint = Paint() ..color = const Color(0xFF000000) ..style = PaintingStyle.stroke ..strokeWidth = radius / 10.0; - final Path path = new Path(); + final Path path = Path(); final Rect box = Offset.zero & size; for (double theta = 0.0; theta < math.pi * 2.0; theta += deltaTheta) path.addArc(box, theta + startOffset, segmentArc); @@ -180,15 +180,15 @@ class MovableBall extends StatelessWidget { final int ballPosition; final ValueChanged callback; - static final GlobalKey kBallKey = new GlobalKey(); + static final GlobalKey kBallKey = GlobalKey(); static const double kBallSize = 50.0; @override Widget build(BuildContext context) { - final Widget ball = new DefaultTextStyle( + final Widget ball = DefaultTextStyle( style: Theme.of(context).primaryTextTheme.body1, textAlign: TextAlign.center, - child: new Dot( + child: Dot( key: kBallKey, color: Colors.blue.shade700, size: kBallSize, @@ -196,7 +196,7 @@ class MovableBall extends StatelessWidget { child: const Center(child: Text('BALL')) ) ); - final Widget dashedBall = new Container( + final Widget dashedBall = Container( width: kBallSize, height: kBallSize, child: const CustomPaint( @@ -204,7 +204,7 @@ class MovableBall extends StatelessWidget { ) ); if (position == ballPosition) { - return new Draggable( + return Draggable( data: true, child: ball, childWhenDragging: dashedBall, @@ -212,7 +212,7 @@ class MovableBall extends StatelessWidget { maxSimultaneousDrags: 1 ); } else { - return new DragTarget( + return DragTarget( onAccept: (bool data) { callback(position); }, builder: (BuildContext context, List accepted, List rejected) { return dashedBall; @@ -224,7 +224,7 @@ class MovableBall extends StatelessWidget { class DragAndDropApp extends StatefulWidget { @override - DragAndDropAppState createState() => new DragAndDropAppState(); + DragAndDropAppState createState() => DragAndDropAppState(); } class DragAndDropAppState extends State { @@ -236,30 +236,30 @@ class DragAndDropAppState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Drag and Drop Flutter Demo') ), - body: new Column( + body: Column( children: [ - new Expanded( - child: new Row( + Expanded( + child: Row( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new ExampleDragSource( + ExampleDragSource( color: Colors.yellow.shade300, under: true, heavy: false, child: const Text('under') ), - new ExampleDragSource( + ExampleDragSource( color: Colors.green.shade300, under: false, heavy: true, child: const Text('long-press above') ), - new ExampleDragSource( + ExampleDragSource( color: Colors.indigo.shade300, under: false, heavy: false, @@ -268,23 +268,23 @@ class DragAndDropAppState extends State { ], ) ), - new Expanded( - child: new Row( + Expanded( + child: Row( children: [ - new Expanded(child: new ExampleDragTarget()), - new Expanded(child: new ExampleDragTarget()), - new Expanded(child: new ExampleDragTarget()), - new Expanded(child: new ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), + Expanded(child: ExampleDragTarget()), ] ) ), - new Expanded( - child: new Row( + Expanded( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new MovableBall(1, position, moveBall), - new MovableBall(2, position, moveBall), - new MovableBall(3, position, moveBall), + MovableBall(1, position, moveBall), + MovableBall(2, position, moveBall), + MovableBall(3, position, moveBall), ], ) ), @@ -295,8 +295,8 @@ class DragAndDropAppState extends State { } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Drag and Drop Flutter Demo', - home: new DragAndDropApp() + home: DragAndDropApp() )); } diff --git a/dev/manual_tests/lib/material_arc.dart b/dev/manual_tests/lib/material_arc.dart index d8aa5026f1..e4afb81b24 100644 --- a/dev/manual_tests/lib/material_arc.dart +++ b/dev/manual_tests/lib/material_arc.dart @@ -55,7 +55,7 @@ class _PointDemoPainter extends CustomPainter { final Animation _repaint; void drawPoint(Canvas canvas, Offset point, Color color) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color.withOpacity(0.25) ..style = PaintingStyle.fill; canvas.drawCircle(point, _kPointRadius, paint); @@ -68,7 +68,7 @@ class _PointDemoPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint(); + final Paint paint = Paint(); if (arc.center != null) drawPoint(canvas, arc.center, Colors.grey.shade400); @@ -108,11 +108,11 @@ class _PointDemo extends StatefulWidget { final AnimationController controller; @override - _PointDemoState createState() => new _PointDemoState(); + _PointDemoState createState() => _PointDemoState(); } class _PointDemoState extends State<_PointDemo> { - final GlobalKey _painterKey = new GlobalKey(); + final GlobalKey _painterKey = GlobalKey(); CurvedAnimation _animation; _DragTarget _dragTarget; @@ -123,7 +123,7 @@ class _PointDemoState extends State<_PointDemo> { @override void initState() { super.initState(); - _animation = new CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); + _animation = CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); } @override @@ -135,7 +135,7 @@ class _PointDemoState extends State<_PointDemo> { Drag _handleOnStart(Offset position) { // TODO(hansmuller): allow the user to drag both points at the same time. if (_dragTarget != null) - return new _IgnoreDrag(); + return _IgnoreDrag(); final RenderBox box = _painterKey.currentContext.findRenderObject(); final double startOffset = (box.localToGlobal(_begin) - position).distanceSquared; @@ -149,7 +149,7 @@ class _PointDemoState extends State<_PointDemo> { _dragTarget = null; }); - return new _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); + return _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); } void _handleDragUpdate(DragUpdateDetails details) { @@ -181,36 +181,36 @@ class _PointDemoState extends State<_PointDemo> { final Size screenSize = MediaQuery.of(context).size; if (_screenSize == null || _screenSize != screenSize) { _screenSize = screenSize; - _begin = new Offset(screenSize.width * 0.5, screenSize.height * 0.2); - _end = new Offset(screenSize.width * 0.1, screenSize.height * 0.4); + _begin = Offset(screenSize.width * 0.5, screenSize.height * 0.2); + _end = Offset(screenSize.width * 0.1, screenSize.height * 0.4); } - final MaterialPointArcTween arc = new MaterialPointArcTween(begin: _begin, end: _end); - return new RawGestureDetector( + final MaterialPointArcTween arc = MaterialPointArcTween(begin: _begin, end: _end); + return RawGestureDetector( behavior: _dragTarget == null ? HitTestBehavior.deferToChild : HitTestBehavior.opaque, gestures: { - ImmediateMultiDragGestureRecognizer: new GestureRecognizerFactoryWithHandlers( - () => new ImmediateMultiDragGestureRecognizer(), + ImmediateMultiDragGestureRecognizer: GestureRecognizerFactoryWithHandlers( + () => ImmediateMultiDragGestureRecognizer(), (ImmediateMultiDragGestureRecognizer instance) { instance ..onStart = _handleOnStart; }, ), }, - child: new ClipRect( - child: new CustomPaint( + child: ClipRect( + child: CustomPaint( key: _painterKey, - foregroundPainter: new _PointDemoPainter( + foregroundPainter: _PointDemoPainter( repaint: _animation, arc: arc ), // Watch out: if this IgnorePointer is left out, then gestures that // fail _PointDemoPainter.hitTest() will still be recognized because // they do overlap this child, which is as big as the CustomPaint. - child: new IgnorePointer( - child: new Padding( + child: IgnorePointer( + child: Padding( padding: const EdgeInsets.all(16.0), - child: new Text( + child: Text( 'Tap the refresh button to run the animation. Drag the green ' "and red points to change the animation's path.", style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0) @@ -233,7 +233,7 @@ class _RectangleDemoPainter extends CustomPainter { final Animation _repaint; void drawPoint(Canvas canvas, Offset p, Color color) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color.withOpacity(0.25) ..style = PaintingStyle.fill; canvas.drawCircle(p, _kPointRadius, paint); @@ -245,7 +245,7 @@ class _RectangleDemoPainter extends CustomPainter { } void drawRect(Canvas canvas, Rect rect, Color color) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color.withOpacity(0.25) ..strokeWidth = 4.0 ..style = PaintingStyle.stroke; @@ -276,11 +276,11 @@ class _RectangleDemo extends StatefulWidget { final AnimationController controller; @override - _RectangleDemoState createState() => new _RectangleDemoState(); + _RectangleDemoState createState() => _RectangleDemoState(); } class _RectangleDemoState extends State<_RectangleDemo> { - final GlobalKey _painterKey = new GlobalKey(); + final GlobalKey _painterKey = GlobalKey(); CurvedAnimation _animation; _DragTarget _dragTarget; @@ -291,7 +291,7 @@ class _RectangleDemoState extends State<_RectangleDemo> { @override void initState() { super.initState(); - _animation = new CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); + _animation = CurvedAnimation(parent: widget.controller, curve: Curves.fastOutSlowIn); } @override @@ -303,7 +303,7 @@ class _RectangleDemoState extends State<_RectangleDemo> { Drag _handleOnStart(Offset position) { // TODO(hansmuller): allow the user to drag both points at the same time. if (_dragTarget != null) - return new _IgnoreDrag(); + return _IgnoreDrag(); final RenderBox box = _painterKey.currentContext.findRenderObject(); final double startOffset = (box.localToGlobal(_begin.center) - position).distanceSquared; @@ -316,7 +316,7 @@ class _RectangleDemoState extends State<_RectangleDemo> { else _dragTarget = null; }); - return new _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); + return _DragHandler(_handleDragUpdate, _handleDragCancel, _handleDragEnd); } void _handleDragUpdate(DragUpdateDetails details) { @@ -348,42 +348,42 @@ class _RectangleDemoState extends State<_RectangleDemo> { final Size screenSize = MediaQuery.of(context).size; if (_screenSize == null || _screenSize != screenSize) { _screenSize = screenSize; - _begin = new Rect.fromLTWH( + _begin = Rect.fromLTWH( screenSize.width * 0.5, screenSize.height * 0.2, screenSize.width * 0.4, screenSize.height * 0.2 ); - _end = new Rect.fromLTWH( + _end = Rect.fromLTWH( screenSize.width * 0.1, screenSize.height * 0.4, screenSize.width * 0.3, screenSize.height * 0.3 ); } - final MaterialRectArcTween arc = new MaterialRectArcTween(begin: _begin, end: _end); - return new RawGestureDetector( + final MaterialRectArcTween arc = MaterialRectArcTween(begin: _begin, end: _end); + return RawGestureDetector( behavior: _dragTarget == null ? HitTestBehavior.deferToChild : HitTestBehavior.opaque, gestures: { - ImmediateMultiDragGestureRecognizer: new GestureRecognizerFactoryWithHandlers( - () => new ImmediateMultiDragGestureRecognizer(), + ImmediateMultiDragGestureRecognizer: GestureRecognizerFactoryWithHandlers( + () => ImmediateMultiDragGestureRecognizer(), (ImmediateMultiDragGestureRecognizer instance) { instance ..onStart = _handleOnStart; }, ), }, - child: new ClipRect( - child: new CustomPaint( + child: ClipRect( + child: CustomPaint( key: _painterKey, - foregroundPainter: new _RectangleDemoPainter( + foregroundPainter: _RectangleDemoPainter( repaint: _animation, arc: arc ), // Watch out: if this IgnorePointer is left out, then gestures that // fail _RectDemoPainter.hitTest() will still be recognized because // they do overlap this child, which is as big as the CustomPaint. - child: new IgnorePointer( - child: new Padding( + child: IgnorePointer( + child: Padding( padding: const EdgeInsets.all(16.0), - child: new Text( + child: Text( 'Tap the refresh button to run the animation. Drag the rectangles ' "to change the animation's path.", style: Theme.of(context).textTheme.caption.copyWith(fontSize: 16.0) @@ -400,8 +400,8 @@ typedef Widget _DemoBuilder(_ArcDemo demo); class _ArcDemo { _ArcDemo(this.title, this.builder, TickerProvider vsync) - : controller = new AnimationController(duration: const Duration(milliseconds: 500), vsync: vsync), - key = new GlobalKey(debugLabel: title); + : controller = AnimationController(duration: const Duration(milliseconds: 500), vsync: vsync), + key = GlobalKey(debugLabel: title); final String title; final _DemoBuilder builder; @@ -413,7 +413,7 @@ class AnimationDemo extends StatefulWidget { const AnimationDemo({ Key key }) : super(key: key); @override - _AnimationDemoState createState() => new _AnimationDemoState(); + _AnimationDemoState createState() => _AnimationDemoState(); } class _AnimationDemoState extends State with TickerProviderStateMixin { @@ -423,14 +423,14 @@ class _AnimationDemoState extends State with TickerProviderStateM void initState() { super.initState(); _allDemos = <_ArcDemo>[ - new _ArcDemo('POINT', (_ArcDemo demo) { - return new _PointDemo( + _ArcDemo('POINT', (_ArcDemo demo) { + return _PointDemo( key: demo.key, controller: demo.controller ); }, this), - new _ArcDemo('RECTANGLE', (_ArcDemo demo) { - return new _RectangleDemo( + _ArcDemo('RECTANGLE', (_ArcDemo demo) { + return _RectangleDemo( key: demo.key, controller: demo.controller ); @@ -446,18 +446,18 @@ class _AnimationDemoState extends State with TickerProviderStateM @override Widget build(BuildContext context) { - return new DefaultTabController( + return DefaultTabController( length: _allDemos.length, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('Animation'), - bottom: new TabBar( - tabs: _allDemos.map((_ArcDemo demo) => new Tab(text: demo.title)).toList(), + bottom: TabBar( + tabs: _allDemos.map((_ArcDemo demo) => Tab(text: demo.title)).toList(), ), ), - floatingActionButton: new Builder( + floatingActionButton: Builder( builder: (BuildContext context) { - return new FloatingActionButton( + return FloatingActionButton( child: const Icon(Icons.refresh), onPressed: () { _play(_allDemos[DefaultTabController.of(context).index]); @@ -465,7 +465,7 @@ class _AnimationDemoState extends State with TickerProviderStateM ); }, ), - body: new TabBarView( + body: TabBarView( children: _allDemos.map((_ArcDemo demo) => demo.builder(demo)).toList() ) ) @@ -474,7 +474,7 @@ class _AnimationDemoState extends State with TickerProviderStateM } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( home: const AnimationDemo(), )); } diff --git a/dev/manual_tests/lib/overlay_geometry.dart b/dev/manual_tests/lib/overlay_geometry.dart index be8a2f937f..e73cb75925 100644 --- a/dev/manual_tests/lib/overlay_geometry.dart +++ b/dev/manual_tests/lib/overlay_geometry.dart @@ -14,8 +14,8 @@ class CardModel { Color color; String get label => 'Card $value'; - Key get key => new ObjectKey(this); - GlobalKey get targetKey => new GlobalObjectKey(this); + Key get key => ObjectKey(this); + GlobalKey get targetKey => GlobalObjectKey(this); } enum MarkerType { topLeft, bottomRight, touch } @@ -31,21 +31,21 @@ class _MarkerPainter extends CustomPainter { @override void paint(Canvas canvas, _) { - final Paint paint = new Paint()..color = const Color(0x8000FF00); + final Paint paint = Paint()..color = const Color(0x8000FF00); final double r = size / 2.0; - canvas.drawCircle(new Offset(r, r), r, paint); + canvas.drawCircle(Offset(r, r), r, paint); paint ..color = const Color(0xFFFFFFFF) ..style = PaintingStyle.stroke ..strokeWidth = 1.0; if (type == MarkerType.topLeft) { - canvas.drawLine(new Offset(r, r), new Offset(r + r - 1.0, r), paint); - canvas.drawLine(new Offset(r, r), new Offset(r, r + r - 1.0), paint); + canvas.drawLine(Offset(r, r), Offset(r + r - 1.0, r), paint); + canvas.drawLine(Offset(r, r), Offset(r, r + r - 1.0), paint); } if (type == MarkerType.bottomRight) { - canvas.drawLine(new Offset(r, r), new Offset(1.0, r), paint); - canvas.drawLine(new Offset(r, r), new Offset(r, 1.0), paint); + canvas.drawLine(Offset(r, r), Offset(1.0, r), paint); + canvas.drawLine(Offset(r, r), Offset(r, 1.0), paint); } } @@ -70,14 +70,14 @@ class Marker extends StatelessWidget { @override Widget build(BuildContext context) { - return new Positioned( + return Positioned( left: position.dx - size / 2.0, top: position.dy - size / 2.0, width: size, height: size, - child: new IgnorePointer( - child: new CustomPaint( - painter: new _MarkerPainter( + child: IgnorePointer( + child: CustomPaint( + painter: _MarkerPainter( size: size, type: type, ), @@ -89,7 +89,7 @@ class Marker extends StatelessWidget { class OverlayGeometryApp extends StatefulWidget { @override - OverlayGeometryAppState createState() => new OverlayGeometryAppState(); + OverlayGeometryAppState createState() => OverlayGeometryAppState(); } typedef void CardTapCallback(GlobalKey targetKey, Offset globalPosition); @@ -108,16 +108,16 @@ class CardBuilder extends SliverChildDelegate { if (index >= cardModels.length) return null; final CardModel cardModel = cardModels[index]; - return new GestureDetector( + return GestureDetector( key: cardModel.key, onTapUp: (TapUpDetails details) { onTapUp(cardModel.targetKey, details.globalPosition); }, - child: new Card( + child: Card( key: cardModel.targetKey, color: cardModel.color, - child: new Container( + child: Container( height: cardModel.height, padding: const EdgeInsets.all(8.0), - child: new Center(child: new Text(cardModel.label, style: cardLabelStyle)), + child: Center(child: Text(cardModel.label, style: cardLabelStyle)), ), ), ); @@ -145,9 +145,9 @@ class OverlayGeometryAppState extends State { 48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0, 48.0, 63.0, 82.0, 146.0, 60.0, 55.0, 84.0, 96.0, 50.0, ]; - cardModels = new List.generate(cardHeights.length, (int i) { + cardModels = List.generate(cardHeights.length, (int i) { final Color color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardHeights.length); - return new CardModel(i, cardHeights[i], color); + return CardModel(i, cardHeights[i], color); }); } @@ -171,7 +171,7 @@ class OverlayGeometryAppState extends State { final RenderBox box = target.currentContext.findRenderObject(); markers[MarkerType.topLeft] = box.localToGlobal(const Offset(0.0, 0.0)); final Size size = box.size; - markers[MarkerType.bottomRight] = box.localToGlobal(new Offset(size.width, size.height)); + markers[MarkerType.bottomRight] = box.localToGlobal(Offset(size.width, size.height)); final ScrollableState scrollable = Scrollable.of(target.currentContext); markersScrollOffset = scrollable.position.pixels; }); @@ -180,14 +180,14 @@ class OverlayGeometryAppState extends State { @override Widget build(BuildContext context) { final List layers = [ - new Scaffold( - appBar: new AppBar(title: const Text('Tap a Card')), - body: new Container( + Scaffold( + appBar: AppBar(title: const Text('Tap a Card')), + body: Container( padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), - child: new NotificationListener( + child: NotificationListener( onNotification: handleScrollNotification, - child: new ListView.custom( - childrenDelegate: new CardBuilder( + child: ListView.custom( + childrenDelegate: CardBuilder( cardModels: cardModels, onTapUp: handleTapUp, ), @@ -197,19 +197,19 @@ class OverlayGeometryAppState extends State { ), ]; for (MarkerType type in markers.keys) - layers.add(new Marker(type: type, position: markers[type])); - return new Stack(children: layers); + layers.add(Marker(type: type, position: markers[type])); + return Stack(children: layers); } } void main() { - runApp(new MaterialApp( - theme: new ThemeData( + runApp(MaterialApp( + theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.blue, accentColor: Colors.redAccent, ), title: 'Cards', - home: new OverlayGeometryApp(), + home: OverlayGeometryApp(), )); } diff --git a/dev/manual_tests/lib/page_view.dart b/dev/manual_tests/lib/page_view.dart index 0730f4a23b..5487f084b6 100644 --- a/dev/manual_tests/lib/page_view.dart +++ b/dev/manual_tests/lib/page_view.dart @@ -10,12 +10,12 @@ class CardModel { Size size; Color color; String get label => 'Card $value'; - Key get key => new ObjectKey(this); + Key get key => ObjectKey(this); } class PageViewApp extends StatefulWidget { @override - PageViewAppState createState() => new PageViewAppState(); + PageViewAppState createState() => PageViewAppState(); } class PageViewAppState extends State { @@ -30,9 +30,9 @@ class PageViewAppState extends State { Size(300.0, 400.0), ]; - cardModels = new List.generate(cardSizes.length, (int i) { + cardModels = List.generate(cardSizes.length, (int i) { final Color color = Color.lerp(Colors.red.shade300, Colors.blue.shade900, i / cardSizes.length); - return new CardModel(i, cardSizes[i], color); + return CardModel(i, cardSizes[i], color); }); } @@ -45,24 +45,24 @@ class PageViewAppState extends State { bool itemsWrap = false; Widget buildCard(CardModel cardModel) { - final Widget card = new Card( + final Widget card = Card( color: cardModel.color, - child: new Container( + child: Container( width: cardModel.size.width, height: cardModel.size.height, padding: const EdgeInsets.all(8.0), - child: new Center(child: new Text(cardModel.label, style: cardLabelStyle)), + child: Center(child: Text(cardModel.label, style: cardLabelStyle)), ), ); final BoxConstraints constraints = (scrollDirection == Axis.vertical) - ? new BoxConstraints.tightFor(height: pageSize.height) - : new BoxConstraints.tightFor(width: pageSize.width); + ? BoxConstraints.tightFor(height: pageSize.height) + : BoxConstraints.tightFor(width: pageSize.width); - return new Container( + return Container( key: cardModel.key, constraints: constraints, - child: new Center(child: card), + child: Center(child: card), ); } @@ -81,27 +81,27 @@ class PageViewAppState extends State { } Widget _buildDrawer() { - return new Drawer( - child: new ListView( + return Drawer( + child: ListView( children: [ const DrawerHeader(child: Center(child: Text('Options'))), - new ListTile( + ListTile( leading: const Icon(Icons.more_horiz), selected: scrollDirection == Axis.horizontal, trailing: const Text('Horizontal Layout'), onTap: switchScrollDirection, ), - new ListTile( + ListTile( leading: const Icon(Icons.more_vert), selected: scrollDirection == Axis.vertical, trailing: const Text('Vertical Layout'), onTap: switchScrollDirection, ), - new ListTile( + ListTile( onTap: toggleItemsWrap, title: const Text('Scrolling wraps around'), // TODO(abarth): Actually make this checkbox change this value. - trailing: new Checkbox(value: itemsWrap, onChanged: null), + trailing: Checkbox(value: itemsWrap, onChanged: null), ), ], ), @@ -109,16 +109,16 @@ class PageViewAppState extends State { } Widget _buildAppBar() { - return new AppBar( + return AppBar( title: const Text('PageView'), actions: [ - new Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'), + Text(scrollDirection == Axis.horizontal ? 'horizontal' : 'vertical'), ], ); } Widget _buildBody(BuildContext context) { - return new PageView( + return PageView( children: cardModels.map(buildCard).toList(), // TODO(abarth): itemsWrap: itemsWrap, scrollDirection: scrollDirection, @@ -127,9 +127,9 @@ class PageViewAppState extends State { @override Widget build(BuildContext context) { - return new IconTheme( + return IconTheme( data: const IconThemeData(color: Colors.white), - child: new Scaffold( + child: Scaffold( appBar: _buildAppBar(), drawer: _buildDrawer(), body: _buildBody(context), @@ -139,13 +139,13 @@ class PageViewAppState extends State { } void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'PageView', - theme: new ThemeData( + theme: ThemeData( brightness: Brightness.light, primarySwatch: Colors.blue, accentColor: Colors.redAccent, ), - home: new PageViewApp(), + home: PageViewApp(), )); } diff --git a/dev/manual_tests/lib/raw_keyboard.dart b/dev/manual_tests/lib/raw_keyboard.dart index 69ccb052f4..cabbfe090e 100644 --- a/dev/manual_tests/lib/raw_keyboard.dart +++ b/dev/manual_tests/lib/raw_keyboard.dart @@ -6,10 +6,10 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Hardware Key Demo', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Hardware Key Demo'), ), body: const Center( @@ -23,11 +23,11 @@ class RawKeyboardDemo extends StatefulWidget { const RawKeyboardDemo({ Key key }) : super(key: key); @override - _HardwareKeyDemoState createState() => new _HardwareKeyDemoState(); + _HardwareKeyDemoState createState() => _HardwareKeyDemoState(); } class _HardwareKeyDemoState extends State { - final FocusNode _focusNode = new FocusNode(); + final FocusNode _focusNode = FocusNode(); RawKeyEvent _event; @override @@ -45,23 +45,23 @@ class _HardwareKeyDemoState extends State { @override Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).textTheme; - return new RawKeyboardListener( + return RawKeyboardListener( focusNode: _focusNode, onKey: _handleKeyEvent, - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: _focusNode, builder: (BuildContext context, Widget child) { if (!_focusNode.hasFocus) { - return new GestureDetector( + return GestureDetector( onTap: () { FocusScope.of(context).requestFocus(_focusNode); }, - child: new Text('Tap to focus', style: textTheme.display1), + child: Text('Tap to focus', style: textTheme.display1), ); } if (_event == null) - return new Text('Press a key', style: textTheme.display1); + return Text('Press a key', style: textTheme.display1); int codePoint; int keyCode; @@ -74,13 +74,13 @@ class _HardwareKeyDemoState extends State { codePoint = data.codePoint; hidUsage = data.hidUsage; } - return new Column( + return Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text('${_event.runtimeType}', style: textTheme.body2), - new Text('codePoint: $codePoint', style: textTheme.display4), - new Text('keyCode: $keyCode', style: textTheme.display4), - new Text('hidUsage: $hidUsage', style: textTheme.display4), + Text('${_event.runtimeType}', style: textTheme.body2), + Text('codePoint: $codePoint', style: textTheme.display4), + Text('keyCode: $keyCode', style: textTheme.display4), + Text('hidUsage: $hidUsage', style: textTheme.display4), ], ); }, diff --git a/dev/manual_tests/lib/text.dart b/dev/manual_tests/lib/text.dart index f9832dce48..938b532b02 100644 --- a/dev/manual_tests/lib/text.dart +++ b/dev/manual_tests/lib/text.dart @@ -12,16 +12,16 @@ import 'package:flutter/scheduler.dart'; int seed = 0; void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Text tester', home: const Home(), routes: { 'underlines': (BuildContext context) => const Underlines(), 'fallback': (BuildContext context) => const Fallback(), 'bidi': (BuildContext context) => const Bidi(), - 'fuzzer': (BuildContext context) => new Fuzzer(seed: seed), - 'zalgo': (BuildContext context) => new Zalgo(seed: seed), - 'painting': (BuildContext context) => new Painting(seed: seed), + 'fuzzer': (BuildContext context) => Fuzzer(seed: seed), + 'zalgo': (BuildContext context) => Zalgo(seed: seed), + 'painting': (BuildContext context) => Painting(seed: seed), }, )); } @@ -30,50 +30,50 @@ class Home extends StatefulWidget { const Home({ Key key }) : super(key: key); @override - _HomeState createState() => new _HomeState(); + _HomeState createState() => _HomeState(); } class _HomeState extends State { @override Widget build(BuildContext context) { - return new Material( - child: new Column( + return Material( + child: Column( children: [ - new Expanded( - child: new Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new FlatButton( + FlatButton( child: const Text('Test Underlines'), color: Colors.red.shade800, textColor: Colors.white, onPressed: () { Navigator.pushNamed(context, 'underlines'); }, ), - new FlatButton( + FlatButton( child: const Text('Test Font Fallback'), color: Colors.orange.shade700, textColor: Colors.white, onPressed: () { Navigator.pushNamed(context, 'fallback'); }, ), - new FlatButton( + FlatButton( child: const Text('Test Bidi Formatting'), color: Colors.yellow.shade700, textColor: Colors.black, onPressed: () { Navigator.pushNamed(context, 'bidi'); }, ), - new FlatButton( + FlatButton( child: const Text('TextSpan Fuzzer'), color: Colors.green.shade400, textColor: Colors.black, onPressed: () { Navigator.pushNamed(context, 'fuzzer'); }, ), - new FlatButton( + FlatButton( child: const Text('Diacritics Fuzzer'), color: Colors.blue.shade400, textColor: Colors.white, onPressed: () { Navigator.pushNamed(context, 'zalgo'); }, ), - new FlatButton( + FlatButton( child: const Text('Painting Fuzzer'), color: Colors.purple.shade200, textColor: Colors.black, @@ -82,9 +82,9 @@ class _HomeState extends State { ], ), ), - new Padding( + Padding( padding: const EdgeInsets.symmetric(horizontal: 20.0), - child: new Slider( + child: Slider( min: 0.0, max: 1024.0, value: seed.toDouble(), @@ -97,9 +97,9 @@ class _HomeState extends State { }, ), ), - new Padding( + Padding( padding: const EdgeInsets.only(bottom: 10.0), - child: new Text('Random seed for fuzzers: $seed'), + child: Text('Random seed for fuzzers: $seed'), ), ], ), @@ -113,7 +113,7 @@ class Fuzzer extends StatefulWidget { final int seed; @override - _FuzzerState createState() => new _FuzzerState(); + _FuzzerState createState() => _FuzzerState(); } class _FuzzerState extends State with SingleTickerProviderStateMixin { @@ -124,7 +124,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { @override void initState() { super.initState(); - _random = new math.Random(widget.seed); // providing a seed is important for reproducibility + _random = math.Random(widget.seed); // providing a seed is important for reproducibility _ticker = createTicker(_updateTextSpan)..start(); _updateTextSpan(null); } @@ -142,7 +142,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { } TextSpan _fiddleWith(TextSpan node) { - return new TextSpan( + return TextSpan( text: _fiddleWithText(node.text), style: _fiddleWithStyle(node.style), children: _fiddleWithChildren(node.children?.map((TextSpan child) => _fiddleWith(child))?.toList() ?? []), @@ -169,7 +169,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { } if (_random.nextInt(200) == 0) return null; - return new TextStyle( + return TextStyle( color: _fiddleWithColor(style.color), decoration: _fiddleWithDecoration(style.decoration), decorationColor: _fiddleWithColor(style.decorationColor), @@ -224,13 +224,13 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { case 30: return TextDecoration.overline; case 90: - return new TextDecoration.combine([TextDecoration.underline, TextDecoration.lineThrough]); + return TextDecoration.combine([TextDecoration.underline, TextDecoration.lineThrough]); case 91: - return new TextDecoration.combine([TextDecoration.underline, TextDecoration.overline]); + return TextDecoration.combine([TextDecoration.underline, TextDecoration.overline]); case 92: - return new TextDecoration.combine([TextDecoration.lineThrough, TextDecoration.overline]); + return TextDecoration.combine([TextDecoration.lineThrough, TextDecoration.overline]); case 93: - return new TextDecoration.combine([TextDecoration.underline, TextDecoration.lineThrough, TextDecoration.overline]); + return TextDecoration.combine([TextDecoration.underline, TextDecoration.lineThrough, TextDecoration.overline]); } return null; } @@ -338,7 +338,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { } TextSpan _createRandomTextSpan() { - return new TextSpan( + return TextSpan( text: _createRandomText(), ); } @@ -421,7 +421,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { case 49: return '𠜎𠜱𠝹𠱓𠱸𠲖𠳏𠳕𠴕𠵼𠵿𠸎𠸏𠹷𠺝𠺢𠻗𠻹𠻺𠼭𠼮𠽌𠾴𠾼𠿪𡁜𡁯𡁵𡁶𡁻𡃁𡃉𡇙𢃇𢞵𢫕𢭃𢯊𢱑𢱕𢳂𢴈𢵌𢵧𢺳𣲷𤓓𤶸𤷪𥄫𦉘𦟌𦧲𦧺𧨾𨅝𨈇𨋢𨳊𨳍𨳒𩶘'; // http://www.i18nguy.com/unicode/supplementary-test.html case 50: // any random character - return new String.fromCharCode(_random.nextInt(0x10FFFF + 1)); + return String.fromCharCode(_random.nextInt(0x10FFFF + 1)); case 51: return '\u00DF'; // SS case 52: @@ -443,10 +443,10 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { case 61: // random BMP character case 62: // random BMP character case 63: // random BMP character - return new String.fromCharCode(_random.nextInt(0xFFFF)); + return String.fromCharCode(_random.nextInt(0xFFFF)); case 64: // random emoji case 65: // random emoji - return new String.fromCharCode(0x1F000 + _random.nextInt(0x9FF)); + return String.fromCharCode(0x1F000 + _random.nextInt(0x9FF)); case 66: return 'Z{' + zalgo(_random, _random.nextInt(4) + 2) + '}Z'; case 67: @@ -472,7 +472,7 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { case 80: case 81: case 82: - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); final int targetLength = _random.nextInt(8) + 1; for (int index = 0; index < targetLength; index += 1) { if (_random.nextInt(20) > 0) { @@ -488,22 +488,22 @@ class _FuzzerState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: [ - new Expanded( - child: new SingleChildScrollView( - child: new SafeArea( - child: new Padding( + Expanded( + child: SingleChildScrollView( + child: SafeArea( + child: Padding( padding: const EdgeInsets.all(10.0), - child: new RichText(text: _textSpan), + child: RichText(text: _textSpan), ), ), ), ), - new Material( - child: new SwitchListTile( + Material( + child: SwitchListTile( title: const Text('Enable Fuzzer'), value: _ticker.isActive, onChanged: (bool value) { @@ -528,14 +528,14 @@ class Underlines extends StatefulWidget { const Underlines({ Key key }) : super(key: key); @override - _UnderlinesState createState() => new _UnderlinesState(); + _UnderlinesState createState() => _UnderlinesState(); } class _UnderlinesState extends State { String _text = 'i'; - final TextStyle _style = new TextStyle( + final TextStyle _style = TextStyle( inherit: false, color: Colors.yellow.shade200, fontSize: 48.0, @@ -544,12 +544,12 @@ class _UnderlinesState extends State { ); Widget _wrap(TextDecorationStyle style) { - return new Align( + return Align( alignment: Alignment.centerLeft, heightFactor: 1.0, - child: new Container( + child: Container( decoration: const BoxDecoration(color: Color(0xFF333333), border: Border(right: BorderSide(color: Colors.white, width: 0.0))), - child: new Text(_text, style: style != null ? _style.copyWith(decoration: TextDecoration.underline, decorationStyle: style) : _style), + child: Text(_text, style: style != null ? _style.copyWith(decoration: TextDecoration.underline, decorationStyle: style) : _style), ), ); } @@ -560,27 +560,27 @@ class _UnderlinesState extends State { for (TextDecorationStyle style in TextDecorationStyle.values) lines.add(_wrap(style)); final Size size = MediaQuery.of(context).size; - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: [ - new Expanded( - child: new SingleChildScrollView( - child: new Padding( - padding: new EdgeInsets.symmetric( + Expanded( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric( horizontal: size.width * 0.1, vertical: size.height * 0.1, ), - child: new ListBody( + child: ListBody( children: lines, ) ), ), ), - new Material( - child: new ButtonBar( + Material( + child: ButtonBar( children: [ - new FlatButton( + FlatButton( onPressed: () { setState(() { _text += 'i'; @@ -589,7 +589,7 @@ class _UnderlinesState extends State { color: Colors.yellow, child: const Text('ADD i'), ), - new FlatButton( + FlatButton( onPressed: () { setState(() { _text += 'w'; @@ -598,7 +598,7 @@ class _UnderlinesState extends State { color: Colors.yellow, child: const Text('ADD w'), ), - new FlatButton( + FlatButton( onPressed: _text == '' ? null : () { setState(() { _text = _text.substring(0, _text.length - 1); @@ -621,7 +621,7 @@ class Fallback extends StatefulWidget { const Fallback({ Key key }) : super(key: key); @override - _FallbackState createState() => new _FallbackState(); + _FallbackState createState() => _FallbackState(); } class _FallbackState extends State { @@ -649,23 +649,23 @@ class _FallbackState extends State { Widget build(BuildContext context) { final List lines = []; for (String font in androidFonts) - lines.add(new Text(multiScript, style: style.copyWith(fontFamily: font, fontSize: math.exp(_fontSize)))); + lines.add(Text(multiScript, style: style.copyWith(fontFamily: font, fontSize: math.exp(_fontSize)))); final Size size = MediaQuery.of(context).size; - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: [ - new Expanded( - child: new SingleChildScrollView( + Expanded( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: new SingleChildScrollView( - child: new Padding( - padding: new EdgeInsets.symmetric( + child: SingleChildScrollView( + child: Padding( + padding: EdgeInsets.symmetric( horizontal: size.width * 0.1, vertical: size.height * 0.1, ), - child: new IntrinsicWidth( - child: new ListBody( + child: IntrinsicWidth( + child: ListBody( children: lines, ), ) @@ -673,18 +673,18 @@ class _FallbackState extends State { ), ), ), - new Material( - child: new Padding( + Material( + child: Padding( padding: const EdgeInsets.only(left: 20.0, right: 20.0, bottom: 20.0), - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ const Padding( padding: EdgeInsets.only(bottom: 10.0), child: Text('Font size'), ), - new Expanded( - child: new Slider( + Expanded( + child: Slider( min: 2.0, max: 5.0, value: _fontSize, @@ -710,64 +710,64 @@ class Bidi extends StatefulWidget { const Bidi({ Key key }) : super(key: key); @override - _BidiState createState() => new _BidiState(); + _BidiState createState() => _BidiState(); } class _BidiState extends State { @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.black, - child: new ListView( + child: ListView( padding: const EdgeInsets.symmetric(vertical: 40.0, horizontal: 20.0), children: [ - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: [ - new TextSpan(text: 'abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), - new TextSpan(text: 'ghi', style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), - new TextSpan(text: 'mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), - new TextSpan(text: 'LKJ', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), - new TextSpan(text: 'FED', style: new TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), + TextSpan(text: 'abc', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), + TextSpan(text: 'ghi', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), + TextSpan(text: 'mno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), + TextSpan(text: 'LKJ', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), + TextSpan(text: 'FED', style: TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), ], ), textAlign: TextAlign.center, textDirection: TextDirection.ltr, ), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: [ - new TextSpan(text: '${Unicode.LRO}abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), - new TextSpan(text: '${Unicode.RLO}DEF', style: new TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), - new TextSpan(text: '${Unicode.LRO}ghi', style: new TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), - new TextSpan(text: '${Unicode.RLO}JKL', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), - new TextSpan(text: '${Unicode.LRO}mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), + TextSpan(text: '${Unicode.LRO}abc', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.blue.shade100)), + TextSpan(text: '${Unicode.RLO}DEF', style: TextStyle(fontWeight: FontWeight.w300, fontSize: 40.0, color: Colors.blue.shade300)), + TextSpan(text: '${Unicode.LRO}ghi', style: TextStyle(fontWeight: FontWeight.w400, fontSize: 40.0, color: Colors.blue.shade500)), + TextSpan(text: '${Unicode.RLO}JKL', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 40.0, color: Colors.blue.shade700)), + TextSpan(text: '${Unicode.LRO}mno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 40.0, color: Colors.blue.shade900)), ], ), textAlign: TextAlign.center, textDirection: TextDirection.ltr, ), const SizedBox(height: 40.0), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: [ - new TextSpan(text: '${Unicode.LRO}abc${Unicode.RLO}D', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), - new TextSpan(text: 'EF${Unicode.LRO}gh', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), - new TextSpan(text: 'i${Unicode.RLO}JKL${Unicode.LRO}mno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + TextSpan(text: '${Unicode.LRO}abc${Unicode.RLO}D', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + TextSpan(text: 'EF${Unicode.LRO}gh', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + TextSpan(text: 'i${Unicode.RLO}JKL${Unicode.LRO}mno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), ], ), textAlign: TextAlign.center, textDirection: TextDirection.ltr, ), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( children: [ - new TextSpan(text: 'abc', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), - new TextSpan(text: 'gh', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), - new TextSpan(text: 'imno', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), - new TextSpan(text: 'LKJ', style: new TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), - new TextSpan(text: 'FE', style: new TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), - new TextSpan(text: 'D', style: new TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + TextSpan(text: 'abc', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), + TextSpan(text: 'gh', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + TextSpan(text: 'imno', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + TextSpan(text: 'LKJ', style: TextStyle(fontWeight: FontWeight.w900, fontSize: 60.0, color: Colors.orange.shade900)), + TextSpan(text: 'FE', style: TextStyle(fontWeight: FontWeight.w500, fontSize: 50.0, color: Colors.orange.shade500)), + TextSpan(text: 'D', style: TextStyle(fontWeight: FontWeight.w100, fontSize: 40.0, color: Colors.orange.shade100)), ], ), textAlign: TextAlign.center, @@ -787,7 +787,7 @@ class Zalgo extends StatefulWidget { final int seed; @override - _ZalgoState createState() => new _ZalgoState(); + _ZalgoState createState() => _ZalgoState(); } class _ZalgoState extends State with SingleTickerProviderStateMixin { @@ -798,7 +798,7 @@ class _ZalgoState extends State with SingleTickerProviderStateMixin { @override void initState() { super.initState(); - _random = new math.Random(widget.seed); // providing a seed is important for reproducibility + _random = math.Random(widget.seed); // providing a seed is important for reproducibility _ticker = createTicker(_update)..start(); _update(null); } @@ -825,16 +825,16 @@ class _ZalgoState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( children: [ - new Expanded( - child: new Center( - child: new RichText( - text: new TextSpan( + Expanded( + child: Center( + child: RichText( + text: TextSpan( text: _text, - style: new TextStyle( + style: TextStyle( inherit: false, fontSize: 96.0, color: Colors.red.shade200, @@ -843,10 +843,10 @@ class _ZalgoState extends State with SingleTickerProviderStateMixin { ), ), ), - new Material( - child: new Column( + Material( + child: Column( children: [ - new SwitchListTile( + SwitchListTile( title: const Text('Enable Fuzzer'), value: _ticker.isActive, onChanged: (bool value) { @@ -859,23 +859,23 @@ class _ZalgoState extends State with SingleTickerProviderStateMixin { }); }, ), - new SwitchListTile( + SwitchListTile( title: const Text('Allow spacing combining marks'), value: _allowSpacing, onChanged: (bool value) { setState(() { _allowSpacing = value; - _random = new math.Random(widget.seed); // reset for reproducibility + _random = math.Random(widget.seed); // reset for reproducibility }); }, ), - new SwitchListTile( + SwitchListTile( title: const Text('Vary base character'), value: _varyBase, onChanged: (bool value) { setState(() { _varyBase = value; - _random = new math.Random(widget.seed); // reset for reproducibility + _random = math.Random(widget.seed); // reset for reproducibility }); }, ), @@ -894,7 +894,7 @@ class Painting extends StatefulWidget { final int seed; @override - _PaintingState createState() => new _PaintingState(); + _PaintingState createState() => _PaintingState(); } class _PaintingState extends State with SingleTickerProviderStateMixin { @@ -905,7 +905,7 @@ class _PaintingState extends State with SingleTickerProviderStateMixin @override void initState() { super.initState(); - _random = new math.Random(widget.seed); // providing a seed is important for reproducibility + _random = math.Random(widget.seed); // providing a seed is important for reproducibility _ticker = createTicker(_update)..start(); _update(null); } @@ -916,14 +916,14 @@ class _PaintingState extends State with SingleTickerProviderStateMixin super.dispose(); } - final GlobalKey intrinsicKey = new GlobalKey(); - final GlobalKey controlKey = new GlobalKey(); + final GlobalKey intrinsicKey = GlobalKey(); + final GlobalKey controlKey = GlobalKey(); bool _ellipsize = false; void _update(Duration duration) { setState(() { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); final int targetLength = _random.nextInt(20) + (_ellipsize ? MediaQuery.of(context).size.width.round() : 1); for (int index = 0; index < targetLength; index += 1) { if (_random.nextInt(5) > 0) { @@ -949,29 +949,29 @@ class _PaintingState extends State with SingleTickerProviderStateMixin @override Widget build(BuildContext context) { final Size size = MediaQuery.of(context).size; - return new Container( + return Container( color: Colors.black, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Expanded( - child: new Padding( - padding: new EdgeInsets.only(top: size.height * 0.1), - child: new Stack( + Expanded( + child: Padding( + padding: EdgeInsets.only(top: size.height * 0.1), + child: Stack( alignment: Alignment.center, children: [ - new Positioned( + Positioned( top: 0.0, left: 0.0, right: 0.0, - child: new Align( + child: Align( alignment: Alignment.topCenter, - child: new IntrinsicWidth( // to test shrink-wrap vs rendering - child: new RichText( + child: IntrinsicWidth( // to test shrink-wrap vs rendering + child: RichText( key: intrinsicKey, textAlign: TextAlign.center, overflow: _ellipsize ? TextOverflow.ellipsis : TextOverflow.clip, - text: new TextSpan( + text: TextSpan( text: _text, style: const TextStyle( inherit: false, @@ -983,15 +983,15 @@ class _PaintingState extends State with SingleTickerProviderStateMixin ), ), ), - new Positioned( + Positioned( top: 0.0, left: 0.0, right: 0.0, - child: new RichText( + child: RichText( key: controlKey, textAlign: TextAlign.center, overflow: _ellipsize ? TextOverflow.ellipsis : TextOverflow.clip, - text: new TextSpan( + text: TextSpan( text: _text, style: const TextStyle( inherit: false, @@ -1005,10 +1005,10 @@ class _PaintingState extends State with SingleTickerProviderStateMixin ), ), ), - new Material( - child: new Column( + Material( + child: Column( children: [ - new SwitchListTile( + SwitchListTile( title: const Text('Enable Fuzzer'), value: _ticker.isActive, onChanged: (bool value) { @@ -1021,13 +1021,13 @@ class _PaintingState extends State with SingleTickerProviderStateMixin }); }, ), - new SwitchListTile( + SwitchListTile( title: const Text('Enable Ellipses'), value: _ellipsize, onChanged: (bool value) { setState(() { _ellipsize = value; - _random = new math.Random(widget.seed); // reset for reproducibility + _random = math.Random(widget.seed); // reset for reproducibility if (!_ticker.isActive) _update(null); }); @@ -1036,13 +1036,13 @@ class _PaintingState extends State with SingleTickerProviderStateMixin const ListTile( title: Text('There should be no red visible.'), ), - new ButtonBar( + ButtonBar( children: [ - new FlatButton( + FlatButton( onPressed: _ticker.isActive ? null : () => _update(null), child: const Text('ITERATE'), ), - new FlatButton( + FlatButton( onPressed: _ticker.isActive ? null : () { print('The currently visible text is: $_text'); print(_text.runes.map((int value) => 'U+${value.toRadixString(16).padLeft(4, '0').toUpperCase()}').join(' ')); @@ -1382,7 +1382,7 @@ String zalgo(math.Random random, int targetLength, { bool includeSpacingCombinin 0x16F7E, 0x1D165, 0x1D166, 0x1D16D, 0x1D16E, 0x1D16F, 0x1D170, 0x1D171, 0x1D172, ]; - final Set these = new Set(); + final Set these = Set(); int combiningCount = enclosingCombiningMarks.length + nonspacingCombiningMarks.length; if (includeSpacingCombiningMarks) combiningCount += spacingCombiningMarks.length; @@ -1400,10 +1400,10 @@ String zalgo(math.Random random, int targetLength, { bool includeSpacingCombinin } } } - base ??= new String.fromCharCode(randomCharacter(random)); + base ??= String.fromCharCode(randomCharacter(random)); final List characters = []; characters.addAll(these); - return base + new String.fromCharCodes(characters); + return base + String.fromCharCodes(characters); } T pickFromList(math.Random random, List list) { diff --git a/dev/manual_tests/test/mock_image_http.dart b/dev/manual_tests/test/mock_image_http.dart index e9708ea49a..c0ece4c9ed 100644 --- a/dev/manual_tests/test/mock_image_http.dart +++ b/dev/manual_tests/test/mock_image_http.dart @@ -7,13 +7,13 @@ import '../../../packages/flutter/test/painting/image_data.dart'; // Returns a mock HTTP client that responds with an image to all requests. MockHttpClient createMockImageHttpClient(SecurityContext _) { - final MockHttpClient client = new MockHttpClient(); - final MockHttpClientRequest request = new MockHttpClientRequest(); - final MockHttpClientResponse response = new MockHttpClientResponse(); - final MockHttpHeaders headers = new MockHttpHeaders(); - when(client.getUrl(any)).thenAnswer((_) => new Future.value(request)); + final MockHttpClient client = MockHttpClient(); + final MockHttpClientRequest request = MockHttpClientRequest(); + final MockHttpClientResponse response = MockHttpClientResponse(); + final MockHttpHeaders headers = MockHttpHeaders(); + when(client.getUrl(any)).thenAnswer((_) => Future.value(request)); when(request.headers).thenReturn(headers); - when(request.close()).thenAnswer((_) => new Future.value(response)); + when(request.close()).thenAnswer((_) => Future.value(response)); when(response.contentLength).thenReturn(kTransparentImage.length); when(response.statusCode).thenReturn(HttpStatus.ok); when(response.listen(any)).thenAnswer((Invocation invocation) { @@ -21,7 +21,7 @@ MockHttpClient createMockImageHttpClient(SecurityContext _) { final void Function() onDone = invocation.namedArguments[#onDone]; final void Function(Object, [StackTrace]) onError = invocation.namedArguments[#onError]; final bool cancelOnError = invocation.namedArguments[#cancelOnError]; - return new Stream>.fromIterable(>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError); + return Stream>.fromIterable(>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError); }); return client; } diff --git a/dev/manual_tests/test/overlay_geometry_test.dart b/dev/manual_tests/test/overlay_geometry_test.dart index 5ef96171a0..6ca3aeda33 100644 --- a/dev/manual_tests/test/overlay_geometry_test.dart +++ b/dev/manual_tests/test/overlay_geometry_test.dart @@ -8,7 +8,7 @@ import 'package:manual_tests/overlay_geometry.dart' as overlay_geometry; void main() { testWidgets('Overlay geometry smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: new overlay_geometry.OverlayGeometryApp())); + await tester.pumpWidget(MaterialApp(home: overlay_geometry.OverlayGeometryApp())); expect(find.byType(overlay_geometry.Marker), findsNothing); await tester.tap(find.text('Card 3')); await tester.pump(); diff --git a/dev/tools/dartdoc.dart b/dev/tools/dartdoc.dart index c336dfbcba..20ca85d864 100644 --- a/dev/tools/dartdoc.dart +++ b/dev/tools/dartdoc.dart @@ -38,13 +38,13 @@ Future main(List arguments) async { Directory.current = Directory.current.parent.parent; final ProcessResult flutter = Process.runSync('flutter', []); - final File versionFile = new File('version'); + final File versionFile = File('version'); if (flutter.exitCode != 0 || !versionFile.existsSync()) - throw new Exception('Failed to determine Flutter version.'); + throw Exception('Failed to determine Flutter version.'); final String version = versionFile.readAsStringSync(); // Create the pubspec.yaml file. - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); buf.writeln('name: Flutter'); buf.writeln('homepage: https://flutter.io'); buf.writeln('version: $version'); @@ -57,17 +57,17 @@ Future main(List arguments) async { buf.writeln('dependency_overrides:'); buf.writeln(' platform_integration:'); buf.writeln(' path: platform_integration'); - new File('dev/docs/pubspec.yaml').writeAsStringSync(buf.toString()); + File('dev/docs/pubspec.yaml').writeAsStringSync(buf.toString()); // Create the library file. - final Directory libDir = new Directory('dev/docs/lib'); + final Directory libDir = Directory('dev/docs/lib'); libDir.createSync(); - final StringBuffer contents = new StringBuffer('library temp_doc;\n\n'); + final StringBuffer contents = StringBuffer('library temp_doc;\n\n'); for (String libraryRef in libraryRefs()) { contents.writeln('import \'package:$libraryRef\';'); } - new File('dev/docs/lib/temp_doc.dart').writeAsStringSync(contents.toString()); + File('dev/docs/lib/temp_doc.dart').writeAsStringSync(contents.toString()); final String flutterRoot = Directory.current.path; final Map pubEnvironment = { @@ -76,7 +76,7 @@ Future main(List arguments) async { // If there's a .pub-cache dir in the flutter root, use that. final String pubCachePath = '$flutterRoot/.pub-cache'; - if (new Directory(pubCachePath).existsSync()) { + if (Directory(pubCachePath).existsSync()) { pubEnvironment['PUB_CACHE'] = pubCachePath; } @@ -156,14 +156,14 @@ Future main(List arguments) async { ); printStream(process.stdout, prefix: args['json'] ? '' : 'dartdoc:stdout: ', filter: args['verbose'] ? const [] : [ - new RegExp(r'^generating docs for library '), // unnecessary verbosity - new RegExp(r'^pars'), // unnecessary verbosity + RegExp(r'^generating docs for library '), // unnecessary verbosity + RegExp(r'^pars'), // unnecessary verbosity ], ); printStream(process.stderr, prefix: args['json'] ? '' : 'dartdoc:stderr: ', filter: args['verbose'] ? const [] : [ - new RegExp(r'^[ ]+warning: generic type handled as HTML:'), // https://github.com/dart-lang/dartdoc/issues/1475 - new RegExp(r'^ warning: .+: \(.+/\.pub-cache/hosted/pub.dartlang.org/.+\)'), // packages outside our control + RegExp(r'^[ ]+warning: generic type handled as HTML:'), // https://github.com/dart-lang/dartdoc/issues/1475 + RegExp(r'^ warning: .+: \(.+/\.pub-cache/hosted/pub.dartlang.org/.+\)'), // packages outside our control ], ); final int exitCode = await process.exitCode; @@ -177,7 +177,7 @@ Future main(List arguments) async { } ArgParser _createArgsParser() { - final ArgParser parser = new ArgParser(); + final ArgParser parser = ArgParser(); parser.addFlag('help', abbr: 'h', negatable: false, help: 'Show command help.'); parser.addFlag('verbose', negatable: true, defaultsTo: true, @@ -193,7 +193,7 @@ ArgParser _createArgsParser() { return parser; } -final RegExp gitBranchRegexp = new RegExp(r'^## (.*)'); +final RegExp gitBranchRegexp = RegExp(r'^## (.*)'); void createFooter(String footerPath) { const int kGitRevisionLength = 10; @@ -212,9 +212,9 @@ void createFooter(String footerPath) { gitRevision = gitRevision.length > kGitRevisionLength ? gitRevision.substring(0, kGitRevisionLength) : gitRevision; - final String timestamp = new DateFormat('yyyy-MM-dd HH:mm').format(new DateTime.now()); + final String timestamp = DateFormat('yyyy-MM-dd HH:mm').format(DateTime.now()); - new File(footerPath).writeAsStringSync([ + File(footerPath).writeAsStringSync([ '• $timestamp', '• $gitRevision', gitBranchOut].join(' ')); @@ -232,8 +232,8 @@ void sanityCheckDocs() { '$kDocRoot/api/widgets/Widget-class.html', ]; for (String canary in canaries) { - if (!new File(canary).existsSync()) - throw new Exception('Missing "$canary", which probably means the documentation failed to build correctly.'); + if (!File(canary).existsSync()) + throw Exception('Missing "$canary", which probably means the documentation failed to build correctly.'); } } @@ -252,22 +252,22 @@ void createIndexAndCleanup() { void removeOldFlutterDocsDir() { try { - new Directory('$kDocRoot/flutter').deleteSync(recursive: true); + Directory('$kDocRoot/flutter').deleteSync(recursive: true); } on FileSystemException { // If the directory does not exist, that's OK. } } void renameApiDir() { - new Directory('$kDocRoot/api').renameSync('$kDocRoot/flutter'); + Directory('$kDocRoot/api').renameSync('$kDocRoot/flutter'); } void copyIndexToRootOfDocs() { - new File('$kDocRoot/flutter/index.html').copySync('$kDocRoot/index.html'); + File('$kDocRoot/flutter/index.html').copySync('$kDocRoot/index.html'); } void changePackageToSdkInTitlebar() { - final File indexFile = new File('$kDocRoot/index.html'); + final File indexFile = File('$kDocRoot/index.html'); String indexContents = indexFile.readAsStringSync(); indexContents = indexContents.replaceFirst( '
  • Flutter package
  • ', @@ -278,7 +278,7 @@ void changePackageToSdkInTitlebar() { } void addHtmlBaseToIndex() { - final File indexFile = new File('$kDocRoot/index.html'); + final File indexFile = File('$kDocRoot/index.html'); String indexContents = indexFile.readAsStringSync(); indexContents = indexContents.replaceFirst( '\n', @@ -298,7 +298,7 @@ void addHtmlBaseToIndex() { void putRedirectInOldIndexLocation() { const String metaTag = ''; - new File('$kDocRoot/flutter/index.html').writeAsStringSync(metaTag); + File('$kDocRoot/flutter/index.html').writeAsStringSync(metaTag); } List findPackageNames() { @@ -307,12 +307,12 @@ List findPackageNames() { /// Finds all packages in the Flutter SDK List findPackages() { - return new Directory('packages') + return Directory('packages') .listSync() .where((FileSystemEntity entity) { if (entity is! Directory) return false; - final File pubspec = new File('${entity.path}/pubspec.yaml'); + final File pubspec = File('${entity.path}/pubspec.yaml'); // TODO(ianh): Use a real YAML parser here return !pubspec.readAsStringSync().contains('nodoc: true'); }) @@ -326,7 +326,7 @@ List findPackages() { Iterable libraryRefs({ bool diskPath = false }) sync* { for (Directory dir in findPackages()) { final String dirName = path.basename(dir.path); - for (FileSystemEntity file in new Directory('${dir.path}/lib').listSync()) { + for (FileSystemEntity file in Directory('${dir.path}/lib').listSync()) { if (file is File && file.path.endsWith('.dart')) { if (diskPath) yield '$dirName/lib/${path.basename(file.path)}'; diff --git a/dev/tools/gen_date_localizations.dart b/dev/tools/gen_date_localizations.dart index 0d9333354e..6a72ced354 100644 --- a/dev/tools/gen_date_localizations.dart +++ b/dev/tools/gen_date_localizations.dart @@ -41,7 +41,7 @@ Future main(List rawArgs) async { final bool writeToFile = parseArgs(rawArgs).writeToFile; - final File dotPackagesFile = new File(path.join('packages', 'flutter_localizations', '.packages')); + final File dotPackagesFile = File(path.join('packages', 'flutter_localizations', '.packages')); final bool dotPackagesExists = dotPackagesFile.existsSync(); if (!dotPackagesExists) { @@ -64,12 +64,12 @@ Future main(List rawArgs) async { .split(':') .last; - final Directory dateSymbolsDirectory = new Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'symbols')); + final Directory dateSymbolsDirectory = Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'symbols')); final Map symbolFiles = _listIntlData(dateSymbolsDirectory); - final Directory datePatternsDirectory = new Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'patterns')); + final Directory datePatternsDirectory = Directory(path.join(pathToIntl, 'src', 'data', 'dates', 'patterns')); final Map patternFiles = _listIntlData(datePatternsDirectory); final List materialLocales = _materialLocales().toList(); - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.writeln( ''' @@ -108,7 +108,7 @@ Future main(List rawArgs) async { buffer.writeln('};'); if (writeToFile) { - final File dateLocalizationsFile = new File(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'date_localizations.dart')); + final File dateLocalizationsFile = File(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n', 'date_localizations.dart')); dateLocalizationsFile.writeAsStringSync(buffer.toString()); Process.runSync(path.join('bin', 'cache', 'dart-sdk', 'bin', 'dartfmt'), [ '-w', @@ -138,7 +138,7 @@ String _jsonToMap(dynamic json) { return '[${json.map(_jsonToMap).join(',')}]'; if (json is Map) { - final StringBuffer buffer = new StringBuffer('{'); + final StringBuffer buffer = StringBuffer('{'); json.forEach((String key, dynamic value) { buffer.writeln(_jsonToMapEntry(key, value)); }); @@ -150,8 +150,8 @@ String _jsonToMap(dynamic json) { } Iterable _materialLocales() sync* { - final RegExp filenameRE = new RegExp(r'material_(\w+)\.arb$'); - final Directory materialLocalizationsDirectory = new Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); + final RegExp filenameRE = RegExp(r'material_(\w+)\.arb$'); + final Directory materialLocalizationsDirectory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); for (FileSystemEntity entity in materialLocalizationsDirectory.listSync()) { final String filePath = entity.path; if (FileSystemEntity.isFileSync(filePath) && filenameRE.hasMatch(filePath)) @@ -171,5 +171,5 @@ Map _listIntlData(Directory directory) { final List locales = localeFiles.keys.toList(growable: false); locales.sort(); - return new Map.fromIterable(locales, value: (dynamic locale) => localeFiles[locale]); + return Map.fromIterable(locales, value: (dynamic locale) => localeFiles[locale]); } diff --git a/dev/tools/gen_localizations.dart b/dev/tools/gen_localizations.dart index ec4255620c..da4a34c144 100644 --- a/dev/tools/gen_localizations.dart +++ b/dev/tools/gen_localizations.dart @@ -86,7 +86,7 @@ String generateString(String s) { if (!s.contains("'")) return "r'$s'"; - final StringBuffer output = new StringBuffer(); + final StringBuffer output = StringBuffer(); bool started = false; // Have we started writing a raw string. for (int i = 0; i < s.length; i++) { if (s[i] == "'") { @@ -108,11 +108,11 @@ String generateString(String s) { /// This is the core of this script; it generates the code used for translations. String generateTranslationBundles() { - final StringBuffer output = new StringBuffer(); - final StringBuffer supportedLocales = new StringBuffer(); + final StringBuffer output = StringBuffer(); + final StringBuffer supportedLocales = StringBuffer(); final Map> languageToLocales = >{}; - final Set allResourceIdentifiers = new Set(); + final Set allResourceIdentifiers = Set(); for (String locale in localeToResources.keys.toList()..sort()) { final List codes = locale.split('_'); // [language, country] assert(codes.length == 1 || codes.length == 2); @@ -201,7 +201,7 @@ String generateTranslationBundles() { /// See also: /// /// * [getTranslation], whose documentation describes these values. -final Set kSupportedLanguages = new HashSet.from(const [ +final Set kSupportedLanguages = HashSet.from(const [ ${languageCodes.map((String value) => " '$value', // ${describeLocale(value)}").toList().join('\n')} ]); @@ -234,7 +234,7 @@ GlobalMaterialLocalizations getTranslation( if (languageToLocales[language].length == 1) { output.writeln(''' case '$language': - return new MaterialLocalization${camelCase(languageToLocales[language][0])}($arguments);'''); + return MaterialLocalization${camelCase(languageToLocales[language][0])}($arguments);'''); } else { output.writeln(''' case '$language': { @@ -246,11 +246,11 @@ GlobalMaterialLocalizations getTranslation( final String countryCode = localeName.substring(localeName.indexOf('_') + 1); output.writeln(''' case '$countryCode': - return new MaterialLocalization${camelCase(localeName)}($arguments);'''); + return MaterialLocalization${camelCase(localeName)}($arguments);'''); } output.writeln(''' } - return new MaterialLocalization${camelCase(language)}($arguments); + return MaterialLocalization${camelCase(language)}($arguments); }'''); } } @@ -323,7 +323,7 @@ String generateValue(String value, Map attributes) { switch (attributes['x-flutter-type']) { case 'icuShortTimePattern': if (!_icuTimeOfDayToEnum.containsKey(value)) { - throw new Exception( + throw Exception( '"$value" is not one of the ICU short time patterns supported ' 'by the material library. Here is the list of supported ' 'patterns:\n ' + _icuTimeOfDayToEnum.keys.join('\n ') @@ -399,11 +399,11 @@ Future main(List rawArgs) async { // is the 2nd command line argument, lc is a language code and cc is the country // code. In most cases both codes are just two characters. - final Directory directory = new Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); - final RegExp filenameRE = new RegExp(r'material_(\w+)\.arb$'); + final Directory directory = Directory(path.join('packages', 'flutter_localizations', 'lib', 'src', 'l10n')); + final RegExp filenameRE = RegExp(r'material_(\w+)\.arb$'); try { - validateEnglishLocalizations(new File(path.join(directory.path, 'material_en.arb'))); + validateEnglishLocalizations(File(path.join(directory.path, 'material_en.arb'))); } on ValidationError catch (exception) { exitWithError('$exception'); } @@ -413,7 +413,7 @@ Future main(List rawArgs) async { for (FileSystemEntity entity in directory.listSync()) { final String entityPath = entity.path; if (FileSystemEntity.isFileSync(entityPath) && filenameRE.hasMatch(entityPath)) { - processBundle(new File(entityPath), locale: filenameRE.firstMatch(entityPath)[1]); + processBundle(File(entityPath), locale: filenameRE.firstMatch(entityPath)[1]); } } @@ -423,12 +423,12 @@ Future main(List rawArgs) async { exitWithError('$exception'); } - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.writeln(outputHeader.replaceFirst('@(regenerate)', 'dart dev/tools/gen_localizations.dart --overwrite')); buffer.write(generateTranslationBundles()); if (options.writeToFile) { - final File localizationsFile = new File(path.join(directory.path, 'localizations.dart')); + final File localizationsFile = File(path.join(directory.path, 'localizations.dart')); localizationsFile.writeAsStringSync(buffer.toString()); } else { stdout.write(buffer.toString()); diff --git a/dev/tools/java_and_objc_doc.dart b/dev/tools/java_and_objc_doc.dart index 52a5acb236..82482651e5 100644 --- a/dev/tools/java_and_objc_doc.dart +++ b/dev/tools/java_and_objc_doc.dart @@ -13,7 +13,7 @@ const String kDocRoot = 'dev/docs/doc'; /// This script downloads an archive of Javadoc and objc doc for the engine from /// the artifact store and extracts them to the location used for Dartdoc. Future main(List args) async { - final String engineVersion = new File('bin/internal/engine.version').readAsStringSync().trim(); + final String engineVersion = File('bin/internal/engine.version').readAsStringSync().trim(); final String javadocUrl = 'https://storage.googleapis.com/flutter_infra/flutter/$engineVersion/android-javadoc.zip'; generateDocs(javadocUrl, 'javadoc', 'io/flutter/view/FlutterView.html'); @@ -25,21 +25,21 @@ Future main(List args) async { Future generateDocs(String url, String docName, String checkFile) async { final http.Response response = await http.get(url); - final Archive archive = new ZipDecoder().decodeBytes(response.bodyBytes); + final Archive archive = ZipDecoder().decodeBytes(response.bodyBytes); - final Directory output = new Directory('$kDocRoot/$docName'); + final Directory output = Directory('$kDocRoot/$docName'); print('Extracting $docName to ${output.path}'); output.createSync(recursive: true); for (ArchiveFile af in archive) { if (af.isFile) { - final File file = new File('${output.path}/${af.name}'); + final File file = File('${output.path}/${af.name}'); file.createSync(recursive: true); file.writeAsBytesSync(af.content); } } - final File testFile = new File('${output.path}/$checkFile'); + final File testFile = File('${output.path}/$checkFile'); if (!testFile.existsSync()) { print('Expected file ${testFile.path} not found'); exit(1); diff --git a/dev/tools/lib/roll_dev.dart b/dev/tools/lib/roll_dev.dart index 5196112fea..143db305bb 100644 --- a/dev/tools/lib/roll_dev.dart +++ b/dev/tools/lib/roll_dev.dart @@ -24,7 +24,7 @@ const String kHelp = 'help'; const String kUpstreamRemote = 'git@github.com:flutter/flutter.git'; void main(List args) { - final ArgParser argParser = new ArgParser(allowTrailingOptions: false); + final ArgParser argParser = ArgParser(allowTrailingOptions: false); argParser.addOption( kIncrement, help: 'Specifies which part of the x.y.z version number to increment. Required.', @@ -168,7 +168,7 @@ String getFullTag() { } Match parseFullTag(String version) { - final RegExp versionPattern = new RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$'); + final RegExp versionPattern = RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$'); return versionPattern.matchAsPrefix(version); } diff --git a/dev/tools/localizations_utils.dart b/dev/tools/localizations_utils.dart index 6c3e069740..bcfadd5951 100644 --- a/dev/tools/localizations_utils.dart +++ b/dev/tools/localizations_utils.dart @@ -16,7 +16,7 @@ void exitWithError(String errorMessage) { } void checkCwdIsRepoRoot(String commandName) { - final bool isRepoRoot = new Directory('.git').existsSync(); + final bool isRepoRoot = Directory('.git').existsSync(); if (!isRepoRoot) { exitWithError( @@ -34,7 +34,7 @@ String camelCase(String locale) { } GeneratorOptions parseArgs(List rawArgs) { - final argslib.ArgParser argParser = new argslib.ArgParser() + final argslib.ArgParser argParser = argslib.ArgParser() ..addFlag( 'overwrite', abbr: 'w', @@ -43,7 +43,7 @@ GeneratorOptions parseArgs(List rawArgs) { final argslib.ArgResults args = argParser.parse(rawArgs); final bool writeToFile = args['overwrite']; - return new GeneratorOptions(writeToFile: writeToFile); + return GeneratorOptions(writeToFile: writeToFile); } class GeneratorOptions { @@ -88,7 +88,7 @@ const String kParentheticalPrefix = ' ('; /// /// The data is obtained from the official IANA registry. Future precacheLanguageAndRegionTags() async { - final HttpClient client = new HttpClient(); + final HttpClient client = HttpClient(); final HttpClientRequest request = await client.getUrl(Uri.parse(registry)); final HttpClientResponse response = await request.close(); final String body = (await response.transform(utf8.decoder).toList()).join(''); diff --git a/dev/tools/localizations_validator.dart b/dev/tools/localizations_validator.dart index 230577d291..c7b03fbede 100644 --- a/dev/tools/localizations_validator.dart +++ b/dev/tools/localizations_validator.dart @@ -8,7 +8,7 @@ import 'dart:io'; // The first suffix in kPluralSuffixes must be "Other". "Other" is special // because it's the only one that is required. const List kPluralSuffixes = ['Other', 'Zero', 'One', 'Two', 'Few', 'Many']; -final RegExp kPluralRegexp = new RegExp(r'(\w*)(' + kPluralSuffixes.skip(1).join(r'|') + r')$'); +final RegExp kPluralRegexp = RegExp(r'(\w*)(' + kPluralSuffixes.skip(1).join(r'|') + r')$'); class ValidationError implements Exception { ValidationError(this. message); @@ -28,11 +28,11 @@ class ValidationError implements Exception { /// /// Throws an exception upon failure. void validateEnglishLocalizations(File file) { - final StringBuffer errorMessages = new StringBuffer(); + final StringBuffer errorMessages = StringBuffer(); if (!file.existsSync()) { errorMessages.writeln('English localizations do not exist: $file'); - throw new ValidationError(errorMessages.toString()); + throw ValidationError(errorMessages.toString()); } final Map bundle = json.decode(file.readAsStringSync()); @@ -83,7 +83,7 @@ void validateEnglishLocalizations(File file) { } if (errorMessages.isNotEmpty) - throw new ValidationError(errorMessages.toString()); + throw ValidationError(errorMessages.toString()); } /// Enforces the following invariants in our localizations: @@ -100,8 +100,8 @@ void validateLocalizations( Map> localeToAttributes, ) { final Map canonicalLocalizations = localeToResources['en']; - final Set canonicalKeys = new Set.from(canonicalLocalizations.keys); - final StringBuffer errorMessages = new StringBuffer(); + final Set canonicalKeys = Set.from(canonicalLocalizations.keys); + final StringBuffer errorMessages = StringBuffer(); bool explainMissingKeys = false; for (final String locale in localeToResources.keys) { final Map resources = localeToResources[locale]; @@ -119,7 +119,7 @@ void validateLocalizations( return resources.containsKey('${prefix}Other'); } - final Set keys = new Set.from( + final Set keys = Set.from( resources.keys.where((String key) => !isPluralVariation(key)) ); @@ -161,6 +161,6 @@ void validateLocalizations( ..writeln(' "notUsed": "Sindhi time format does not use a.m. indicator"') ..writeln('}'); } - throw new ValidationError(errorMessages.toString()); + throw ValidationError(errorMessages.toString()); } } diff --git a/dev/tools/mega_gallery.dart b/dev/tools/mega_gallery.dart index f0002fe32a..e6642a52a8 100644 --- a/dev/tools/mega_gallery.dart +++ b/dev/tools/mega_gallery.dart @@ -17,7 +17,7 @@ void main(List args) { if (path.basename(Directory.current.path) == 'tools') Directory.current = Directory.current.parent.parent; - final ArgParser argParser = new ArgParser(); + final ArgParser argParser = ArgParser(); argParser.addOption('out'); argParser.addOption('copies'); argParser.addFlag('delete', negatable: false); @@ -32,8 +32,8 @@ void main(List args) { exit(0); } - final Directory source = new Directory(_normalize('examples/flutter_gallery')); - final Directory out = new Directory(_normalize(results['out'])); + final Directory source = Directory(_normalize('examples/flutter_gallery')); + final Directory out = Directory(_normalize(results['out'])); if (results['delete']) { if (out.existsSync()) { @@ -61,8 +61,8 @@ void main(List args) { print('Making $copies copies of flutter_gallery.'); print(''); print('Stats:'); - print(' packages/flutter : ${getStatsFor(new Directory("packages/flutter"))}'); - print(' examples/flutter_gallery : ${getStatsFor(new Directory("examples/flutter_gallery"))}'); + print(' packages/flutter : ${getStatsFor(Directory("packages/flutter"))}'); + print(' examples/flutter_gallery : ${getStatsFor(Directory("examples/flutter_gallery"))}'); final Directory lib = _dir(out, 'lib'); if (lib.existsSync()) @@ -91,7 +91,7 @@ void main(List args) { // TODO(devoncarew): Create an entry-point that builds a UI with all `n` copies. void _createEntry(File mainFile, int copies) { - final StringBuffer imports = new StringBuffer(); + final StringBuffer imports = StringBuffer(); for (int i = 1; i < copies; i++) { imports.writeln('// ignore: unused_import'); @@ -137,18 +137,18 @@ void _copy(Directory source, Directory target) { if (entity is Directory) { if (name == 'build' || name.startsWith('.')) continue; - _copy(entity, new Directory(path.join(target.path, name))); + _copy(entity, Directory(path.join(target.path, name))); } else if (entity is File) { if (name == '.packages' || name == 'pubspec.lock') continue; - final File dest = new File(path.join(target.path, name)); + final File dest = File(path.join(target.path, name)); dest.writeAsBytesSync(entity.readAsBytesSync()); } } } -Directory _dir(Directory parent, String name) => new Directory(path.join(parent.path, name)); -File _file(Directory parent, String name) => new File(path.join(parent.path, name)); +Directory _dir(Directory parent, String name) => Directory(path.join(parent.path, name)); +File _file(Directory parent, String name) => File(path.join(parent.path, name)); String _normalize(String filePath) => path.normalize(path.absolute(filePath)); class SourceStats { @@ -160,7 +160,7 @@ class SourceStats { } SourceStats getStatsFor(Directory dir, [SourceStats stats]) { - stats ??= new SourceStats(); + stats ??= SourceStats(); for (FileSystemEntity entity in dir.listSync(recursive: false, followLinks: false)) { final String name = path.basename(entity.path); diff --git a/dev/tools/update_icons.dart b/dev/tools/update_icons.dart index 89e26c5368..43a1f795c9 100644 --- a/dev/tools/update_icons.dart +++ b/dev/tools/update_icons.dart @@ -71,7 +71,7 @@ const Map kIdentifierRewrites = { }; -final Set kMirroredIcons = new Set.from([ +final Set kMirroredIcons = Set.from([ // This list is obtained from: // http://google.github.io/material-design-icons/#icons-in-rtl 'arrow_back', @@ -152,18 +152,18 @@ void main(List args) { if (path.basename(Directory.current.path) == 'tools') Directory.current = Directory.current.parent.parent; - final ArgParser argParser = new ArgParser(); + final ArgParser argParser = ArgParser(); argParser.addOption(kOptionCodepointsPath, defaultsTo: kDefaultCodepointsPath); argParser.addOption(kOptionIconsPath, defaultsTo: kDefaultIconsPath); argParser.addFlag(kOptionDryRun, defaultsTo: false); final ArgResults argResults = argParser.parse(args); - final File iconFile = new File(path.absolute(argResults[kOptionIconsPath])); + final File iconFile = File(path.absolute(argResults[kOptionIconsPath])); if (!iconFile.existsSync()) { stderr.writeln('Icons file not found: ${iconFile.path}'); exit(1); } - final File codepointsFile = new File(path.absolute(argResults[kOptionCodepointsPath])); + final File codepointsFile = File(path.absolute(argResults[kOptionCodepointsPath])); if (!codepointsFile.existsSync()) { stderr.writeln('Codepoints file not found: ${codepointsFile.path}'); exit(1); @@ -180,7 +180,7 @@ void main(List args) { } String regenerateIconsFile(String iconData, String codepointData) { - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); bool generating = false; for (String line in LineSplitter.split(iconData)) { if (!generating) @@ -208,7 +208,7 @@ String generateIconDeclarations(String codepointData) { String getIconDeclaration(String line) { final List tokens = line.split(' '); if (tokens.length != 2) - throw new FormatException('Unexpected codepoint data: $line'); + throw FormatException('Unexpected codepoint data: $line'); final String name = tokens[0]; final String codepoint = tokens[1]; final String identifier = kIdentifierRewrites[name] ?? name; diff --git a/dev/tools/vitool/bin/main.dart b/dev/tools/vitool/bin/main.dart index cafeab3a01..b7b55bebda 100644 --- a/dev/tools/vitool/bin/main.dart +++ b/dev/tools/vitool/bin/main.dart @@ -12,7 +12,7 @@ const String kCodegenComment = '// This file was generated by vitool.\n'; void main(List args) { - final ArgParser parser = new ArgParser(); + final ArgParser parser = ArgParser(); parser.addFlag( 'help', @@ -70,10 +70,10 @@ void main(List args) { frames.add(data); } - final StringBuffer generatedSb = new StringBuffer(); + final StringBuffer generatedSb = StringBuffer(); if (argResults.wasParsed('header')) { - generatedSb.write(new File(argResults['header']).readAsStringSync()); + generatedSb.write(File(argResults['header']).readAsStringSync()); generatedSb.write('\n'); } @@ -83,10 +83,10 @@ void main(List args) { if (argResults.wasParsed('part-of')) generatedSb.write('part of ${argResults['part-of']};\n'); - final Animation animation = new Animation.fromFrameData(frames); + final Animation animation = Animation.fromFrameData(frames); generatedSb.write(animation.toDart('_AnimatedIconData', argResults['asset-name'])); - final File outFile = new File(argResults['output']); + final File outFile = File(argResults['output']); outFile.writeAsStringSync(generatedSb.toString()); } diff --git a/dev/tools/vitool/lib/vitool.dart b/dev/tools/vitool/lib/vitool.dart index 843509ced2..f89a93ac0b 100644 --- a/dev/tools/vitool/lib/vitool.dart +++ b/dev/tools/vitool/lib/vitool.dart @@ -23,9 +23,9 @@ class Animation { final Point size = frames[0].size; final List paths = []; for (int i = 0; i < frames[0].paths.length; i += 1) { - paths.add(new PathAnimation.fromFrameData(frames, i)); + paths.add(PathAnimation.fromFrameData(frames, i)); } - return new Animation(size, paths); + return Animation(size, paths); } /// The size of the animation (width, height) in pixels. @@ -40,13 +40,13 @@ class Animation { for (int i = 0; i < frames.length; i += 1) { final FrameData frame = frames[i]; if (size != frame.size) - throw new Exception( + throw Exception( 'All animation frames must have the same size,\n' 'first frame size was: (${size.x}, ${size.y})\n' 'frame $i size was: (${frame.size.x}, ${frame.size.y})' ); if (numPaths != frame.paths.length) - throw new Exception( + throw Exception( 'All animation frames must have the same number of paths,\n' 'first frame has $numPaths paths\n' 'frame $i has ${frame.paths.length} paths' @@ -55,7 +55,7 @@ class Animation { } String toDart(String className, String varName) { - final StringBuffer sb = new StringBuffer(); + final StringBuffer sb = StringBuffer(); sb.write('const $className $varName = const $className(\n'); sb.write('${kIndent}const Size(${size.x}, ${size.y}),\n'); sb.write('${kIndent}const <_PathFrames>[\n'); @@ -78,7 +78,7 @@ class PathAnimation { final List commands = []; for (int commandIdx = 0; commandIdx < frames[0].paths[pathIdx].commands.length; commandIdx += 1) { final int numPointsInCommand = frames[0].paths[pathIdx].commands[commandIdx].points.length; - final List>> points = new List>>(numPointsInCommand); + final List>> points = List>>(numPointsInCommand); for (int j = 0; j < numPointsInCommand; j += 1) points[j] = >[]; final String commandType = frames[0].paths[pathIdx].commands[commandIdx].type; @@ -86,7 +86,7 @@ class PathAnimation { final FrameData frame = frames[i]; final String currentCommandType = frame.paths[pathIdx].commands[commandIdx].type; if (commandType != currentCommandType) - throw new Exception( + throw Exception( 'Paths must be built from the same commands in all frames' 'command $commandIdx at frame 0 was of type \'$commandType\'' 'command $commandIdx at frame $i was of type \'$currentCommandType\'' @@ -94,13 +94,13 @@ class PathAnimation { for (int j = 0; j < numPointsInCommand; j += 1) points[j].add(frame.paths[pathIdx].commands[commandIdx].points[j]); } - commands.add(new PathCommandAnimation(commandType, points)); + commands.add(PathCommandAnimation(commandType, points)); } final List opacities = frames.map((FrameData d) => d.paths[pathIdx].opacity).toList(); - return new PathAnimation(commands, opacities: opacities); + return PathAnimation(commands, opacities: opacities); } /// List of commands for drawing the path. @@ -114,7 +114,7 @@ class PathAnimation { } String toDart() { - final StringBuffer sb = new StringBuffer(); + final StringBuffer sb = StringBuffer(); sb.write('${kIndent * 2}const _PathFrames(\n'); sb.write('${kIndent * 3}opacities: const [\n'); for (double opacity in opacities) @@ -162,9 +162,9 @@ class PathCommandAnimation { dartCommandClass = '_PathClose'; break; default: - throw new Exception('unsupported path command: $type'); + throw Exception('unsupported path command: $type'); } - final StringBuffer sb = new StringBuffer(); + final StringBuffer sb = StringBuffer(); sb.write('${kIndent * 4}const $dartCommandClass(\n'); for (List> pointFrames in points) { sb.write('${kIndent * 5}const [\n'); @@ -188,15 +188,15 @@ class PathCommandAnimation { /// support SVG files exported by a specific tool the motion design team is /// using. FrameData interpretSvg(String svgFilePath) { - final File file = new File(svgFilePath); + final File file = File(svgFilePath); final String fileData = file.readAsStringSync(); final XmlElement svgElement = _extractSvgElement(xml.parse(fileData)); final double width = parsePixels(_extractAttr(svgElement, 'width')).toDouble(); final double height = parsePixels(_extractAttr(svgElement, 'height')).toDouble(); final List paths = - _interpretSvgGroup(svgElement.children, new _Transform()); - return new FrameData(new Point(width, height), paths); + _interpretSvgGroup(svgElement.children, _Transform()); + return FrameData(Point(width, height), paths); } List _interpretSvgGroup(List children, _Transform transform) { @@ -220,7 +220,7 @@ List _interpretSvgGroup(List children, _Transform transform) { transformMatrix = transformMatrix.multiplied( _parseSvgTransform(_extractAttr(element, 'transform'))); - final _Transform subtreeTransform = new _Transform( + final _Transform subtreeTransform = _Transform( transformMatrix: transformMatrix, opacity: opacity ); @@ -238,7 +238,7 @@ List _interpretSvgGroup(List children, _Transform transform) { // group 3 will match "12.0, 12.0 23.0, 9.0" // // Commas are optional. -final RegExp _pointMatcher = new RegExp(r'^ *([\-\.0-9]+) *,? *([\-\.0-9]+)(.*)'); +final RegExp _pointMatcher = RegExp(r'^ *([\-\.0-9]+) *,? *([\-\.0-9]+)(.*)'); /// Parse a string with a list of points, e.g: /// '25.0, 1.0 12.0, 12.0 23.0, 9.0' will be parsed to: @@ -250,7 +250,7 @@ List> parsePoints(String points) { final List> result = >[]; while (unParsed.isNotEmpty && _pointMatcher.hasMatch(unParsed)) { final Match m = _pointMatcher.firstMatch(unParsed); - result.add(new Point( + result.add(Point( double.parse(m.group(1)), double.parse(m.group(2)) )); @@ -293,29 +293,29 @@ class SvgPath { final double opacity; static const String _pathCommandAtom = ' *([a-zA-Z]) *([\-\.0-9 ,]*)'; - static final RegExp _pathCommandValidator = new RegExp('^($_pathCommandAtom)*\$'); - static final RegExp _pathCommandMatcher = new RegExp(_pathCommandAtom); + static final RegExp _pathCommandValidator = RegExp('^($_pathCommandAtom)*\$'); + static final RegExp _pathCommandMatcher = RegExp(_pathCommandAtom); static SvgPath fromElement(XmlElement pathElement) { assert(pathElement.name.local == 'path'); final String id = _extractAttr(pathElement, 'id'); final String dAttr = _extractAttr(pathElement, 'd'); final List commands = []; - final SvgPathCommandBuilder commandsBuilder = new SvgPathCommandBuilder(); + final SvgPathCommandBuilder commandsBuilder = SvgPathCommandBuilder(); if (!_pathCommandValidator.hasMatch(dAttr)) - throw new Exception('illegal or unsupported path d expression: $dAttr'); + throw Exception('illegal or unsupported path d expression: $dAttr'); for (Match match in _pathCommandMatcher.allMatches(dAttr)) { final String commandType = match.group(1); final String pointStr = match.group(2); commands.add(commandsBuilder.build(commandType, parsePoints(pointStr))); } - return new SvgPath(id, commands); + return SvgPath(id, commands); } SvgPath applyTransform(_Transform transform) { final List transformedCommands = commands.map((SvgPathCommand c) => c.applyTransform(transform)).toList(); - return new SvgPath(id, transformedCommands, opacity: opacity * transform.opacity); + return SvgPath(id, transformedCommands, opacity: opacity * transform.opacity); } @override @@ -364,7 +364,7 @@ class SvgPathCommand { _pointsToVector3Array(points) ) ); - return new SvgPathCommand(type, transformedPoints); + return SvgPathCommand(type, transformedPoints); } @override @@ -411,7 +411,7 @@ class SvgPathCommandBuilder { else lastPoint = absPoints.last; - return new SvgPathCommand(type.toUpperCase(), absPoints); + return SvgPathCommand(type.toUpperCase(), absPoints); } static bool _isRelativeCommand(String type) { @@ -420,7 +420,7 @@ class SvgPathCommandBuilder { } List _pointsToVector3Array(List> points) { - final List result = new List(points.length * 3); + final List result = List(points.length * 3); for (int i = 0; i < points.length; i += 1) { result[i * 3] = points[i].x; result[i * 3 + 1] = points[i].y; @@ -431,9 +431,9 @@ List _pointsToVector3Array(List> points) { List> _vector3ArrayToPoints(List vector) { final int numPoints = (vector.length / 3).floor(); - final List> points = new List>(numPoints); + final List> points = List>(numPoints); for (int i = 0; i < numPoints; i += 1) { - points[i] = new Point(vector[i*3], vector[i*3 + 1]); + points[i] = Point(vector[i*3], vector[i*3 + 1]); } return points; } @@ -446,13 +446,13 @@ class _Transform { /// Constructs a new _Transform, default arguments create a no-op transform. _Transform({Matrix3 transformMatrix, this.opacity = 1.0}) : - this.transformMatrix = transformMatrix ?? new Matrix3.identity(); + this.transformMatrix = transformMatrix ?? Matrix3.identity(); final Matrix3 transformMatrix; final double opacity; _Transform applyTransform(_Transform transform) { - return new _Transform( + return _Transform( transformMatrix: transform.transformMatrix.multiplied(transformMatrix), opacity: transform.opacity * opacity, ); @@ -461,14 +461,14 @@ class _Transform { const String _transformCommandAtom = ' *([^(]+)\\(([^)]*)\\)'; -final RegExp _transformValidator = new RegExp('^($_transformCommandAtom)*\$'); -final RegExp _transformCommand = new RegExp(_transformCommandAtom); +final RegExp _transformValidator = RegExp('^($_transformCommandAtom)*\$'); +final RegExp _transformCommand = RegExp(_transformCommandAtom); Matrix3 _parseSvgTransform(String transform) { if (!_transformValidator.hasMatch(transform)) - throw new Exception('illegal or unsupported transform: $transform'); + throw Exception('illegal or unsupported transform: $transform'); final Iterable matches =_transformCommand.allMatches(transform).toList().reversed; - Matrix3 result = new Matrix3.identity(); + Matrix3 result = Matrix3.identity(); for (Match m in matches) { final String command = m.group(1); final String params = m.group(2); @@ -484,12 +484,12 @@ Matrix3 _parseSvgTransform(String transform) { result = _parseSvgRotate(params).multiplied(result); continue; } - throw new Exception('unimplemented transform: $command'); + throw Exception('unimplemented transform: $command'); } return result; } -final RegExp _valueSeparator = new RegExp('( *, *| +)'); +final RegExp _valueSeparator = RegExp('( *, *| +)'); Matrix3 _parseSvgTranslate(String paramsStr) { final List params = paramsStr.split(_valueSeparator); @@ -517,18 +517,18 @@ Matrix3 _parseSvgRotate(String paramsStr) { } Matrix3 _matrix(double a, double b, double c, double d, double e, double f) { - return new Matrix3(a, b, 0.0, c, d, 0.0, e, f, 1.0); + return Matrix3(a, b, 0.0, c, d, 0.0, e, f, 1.0); } // Matches a pixels expression e.g "14px". // First group is just the number. -final RegExp _pixelsExp = new RegExp('^([0-9]+)px\$'); +final RegExp _pixelsExp = RegExp('^([0-9]+)px\$'); /// Parses a pixel expression, e.g "14px", and returns the number. /// Throws an [ArgumentError] if the given string doesn't match the pattern. int parsePixels(String pixels) { if (!_pixelsExp.hasMatch(pixels)) - throw new ArgumentError( + throw ArgumentError( 'illegal pixels expression: \'$pixels\'' ' (the tool currently only support pixel units).'); return int.parse(_pixelsExp.firstMatch(pixels).group(1)); @@ -539,7 +539,7 @@ String _extractAttr(XmlElement element, String name) { return element.attributes.singleWhere((XmlAttribute x) => x.name.local == name) .value; } catch (e) { - throw new ArgumentError( + throw ArgumentError( 'Can\'t find a single \'$name\' attributes in ${element.name}, ' 'attributes were: ${element.attributes}' ); diff --git a/dev/tools/vitool/test/vitool_test.dart b/dev/tools/vitool/test/vitool_test.dart index 97d707db79..4f3cfe695a 100644 --- a/dev/tools/vitool/test/vitool_test.dart +++ b/dev/tools/vitool/test/vitool_test.dart @@ -224,7 +224,7 @@ void main() { ], ), ]; - expect(new PathAnimation.fromFrameData(frameData, 0), + expect(PathAnimation.fromFrameData(frameData, 0), const PathAnimationMatcher(PathAnimation( [ PathCommandAnimation('M', >>[ @@ -259,7 +259,7 @@ void main() { ], ), ]; - expect(new PathAnimation.fromFrameData(frameData, 0), + expect(PathAnimation.fromFrameData(frameData, 0), const PathAnimationMatcher(PathAnimation( [ PathCommandAnimation('M', >>[ @@ -270,7 +270,7 @@ void main() { )) ); - expect(new PathAnimation.fromFrameData(frameData, 1), + expect(PathAnimation.fromFrameData(frameData, 1), const PathAnimationMatcher(PathAnimation( [ PathCommandAnimation('M', >>[ @@ -308,7 +308,7 @@ void main() { ], ), ]; - expect(new PathAnimation.fromFrameData(frameData, 0), + expect(PathAnimation.fromFrameData(frameData, 0), const PathAnimationMatcher(PathAnimation( [ PathCommandAnimation('M', >>[ @@ -345,7 +345,7 @@ void main() { ], ), ]; - final Animation animation = new Animation.fromFrameData(frameData); + final Animation animation = Animation.fromFrameData(frameData); expect(animation.paths[0], const PathAnimationMatcher(PathAnimation( [ diff --git a/examples/catalog/bin/sample_page.dart b/examples/catalog/bin/sample_page.dart index 7f67d24603..42afe9288c 100644 --- a/examples/catalog/bin/sample_page.dart +++ b/examples/catalog/bin/sample_page.dart @@ -33,18 +33,18 @@ void logMessage(String s) { print(s); } void logError(String s) { print(s); } File inputFile(String dir, String name) { - return new File(dir + Platform.pathSeparator + name); + return File(dir + Platform.pathSeparator + name); } File outputFile(String name, [Directory directory]) { - return new File((directory ?? outputDirectory).path + Platform.pathSeparator + name); + return File((directory ?? outputDirectory).path + Platform.pathSeparator + name); } void initialize() { - outputDirectory = new Directory('.generated'); - sampleDirectory = new Directory('lib'); - testDirectory = new Directory('test'); - driverDirectory = new Directory('test_driver'); + outputDirectory = Directory('.generated'); + sampleDirectory = Directory('lib'); + testDirectory = Directory('test'); + driverDirectory = Directory('test_driver'); outputDirectory.createSync(); } @@ -52,10 +52,10 @@ void initialize() { // by values[foo]. String expandTemplate(String template, Map values) { // Matches @(foo), match[1] == 'foo' - final RegExp tokenRE = new RegExp(r'@\(([\w ]+)\)', multiLine: true); + final RegExp tokenRE = RegExp(r'@\(([\w ]+)\)', multiLine: true); return template.replaceAllMapped(tokenRE, (Match match) { if (match.groupCount != 1) - throw new SampleError('bad template keyword $match[0]'); + throw SampleError('bad template keyword $match[0]'); final String keyword = match[1]; return values[keyword] ?? ''; }); @@ -102,8 +102,8 @@ class SampleInfo { bool initialize() { final String contents = sourceFile.readAsStringSync(); - final RegExp startRE = new RegExp(r'^/\*\s+^Sample\s+Catalog', multiLine: true); - final RegExp endRE = new RegExp(r'^\*/', multiLine: true); + final RegExp startRE = RegExp(r'^/\*\s+^Sample\s+Catalog', multiLine: true); + final RegExp endRE = RegExp(r'^\*/', multiLine: true); final Match startMatch = startRE.firstMatch(contents); if (startMatch == null) return false; @@ -116,12 +116,12 @@ class SampleInfo { final String comment = contents.substring(startIndex, startIndex + endMatch.start); sourceCode = contents.substring(0, startMatch.start) + contents.substring(startIndex + endMatch.end); if (sourceCode.trim().isEmpty) - throw new SampleError('did not find any source code in $sourceFile'); + throw SampleError('did not find any source code in $sourceFile'); - final RegExp keywordsRE = new RegExp(sampleCatalogKeywords, multiLine: true); + final RegExp keywordsRE = RegExp(sampleCatalogKeywords, multiLine: true); final List keywordMatches = keywordsRE.allMatches(comment).toList(); if (keywordMatches.isEmpty) - throw new SampleError('did not find any keywords in the Sample Catalog comment in $sourceFile'); + throw SampleError('did not find any keywords in the Sample Catalog comment in $sourceFile'); commentValues = {}; for (int i = 0; i < keywordMatches.length; i += 1) { @@ -148,7 +148,7 @@ void generate(String commit) { final List samples = []; for (FileSystemEntity entity in sampleDirectory.listSync()) { if (entity is File && entity.path.endsWith('.dart')) { - final SampleInfo sample = new SampleInfo(entity, commit); + final SampleInfo sample = SampleInfo(entity, commit); if (sample.initialize()) // skip files that lack the Sample Catalog comment samples.add(sample); } diff --git a/examples/catalog/lib/animated_list.dart b/examples/catalog/lib/animated_list.dart index 31d173ab0f..4aab2a4a6c 100644 --- a/examples/catalog/lib/animated_list.dart +++ b/examples/catalog/lib/animated_list.dart @@ -7,11 +7,11 @@ import 'package:flutter/material.dart'; class AnimatedListSample extends StatefulWidget { @override - _AnimatedListSampleState createState() => new _AnimatedListSampleState(); + _AnimatedListSampleState createState() => _AnimatedListSampleState(); } class _AnimatedListSampleState extends State { - final GlobalKey _listKey = new GlobalKey(); + final GlobalKey _listKey = GlobalKey(); ListModel _list; int _selectedItem; int _nextItem; // The next item inserted when the user presses the '+' button. @@ -19,7 +19,7 @@ class _AnimatedListSampleState extends State { @override void initState() { super.initState(); - _list = new ListModel( + _list = ListModel( listKey: _listKey, initialItems: [0, 1, 2], removedItemBuilder: _buildRemovedItem, @@ -29,7 +29,7 @@ class _AnimatedListSampleState extends State { // Used to build list items that haven't been removed. Widget _buildItem(BuildContext context, int index, Animation animation) { - return new CardItem( + return CardItem( animation: animation, item: _list[index], selected: _selectedItem == _list[index], @@ -47,7 +47,7 @@ class _AnimatedListSampleState extends State { // The widget will be used by the [AnimatedListState.removeItem] method's // [AnimatedListRemovedItemBuilder] parameter. Widget _buildRemovedItem(int item, BuildContext context, Animation animation) { - return new CardItem( + return CardItem( animation: animation, item: item, selected: false, @@ -73,26 +73,26 @@ class _AnimatedListSampleState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('AnimatedList'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.add_circle), onPressed: _insert, tooltip: 'insert a new item', ), - new IconButton( + IconButton( icon: const Icon(Icons.remove_circle), onPressed: _remove, tooltip: 'remove the selected item', ), ], ), - body: new Padding( + body: Padding( padding: const EdgeInsets.all(16.0), - child: new AnimatedList( + child: AnimatedList( key: _listKey, initialItemCount: _list.length, itemBuilder: _buildItem, @@ -119,7 +119,7 @@ class ListModel { Iterable initialItems, }) : assert(listKey != null), assert(removedItemBuilder != null), - _items = new List.from(initialItems ?? []); + _items = List.from(initialItems ?? []); final GlobalKey listKey; final dynamic removedItemBuilder; @@ -173,20 +173,20 @@ class CardItem extends StatelessWidget { TextStyle textStyle = Theme.of(context).textTheme.display1; if (selected) textStyle = textStyle.copyWith(color: Colors.lightGreenAccent[400]); - return new Padding( + return Padding( padding: const EdgeInsets.all(2.0), - child: new SizeTransition( + child: SizeTransition( axis: Axis.vertical, sizeFactor: animation, - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: onTap, - child: new SizedBox( + child: SizedBox( height: 128.0, - child: new Card( + child: Card( color: Colors.primaries[item % Colors.primaries.length], - child: new Center( - child: new Text('Item $item', style: textStyle), + child: Center( + child: Text('Item $item', style: textStyle), ), ), ), @@ -197,7 +197,7 @@ class CardItem extends StatelessWidget { } void main() { - runApp(new AnimatedListSample()); + runApp(AnimatedListSample()); } /* diff --git a/examples/catalog/lib/app_bar_bottom.dart b/examples/catalog/lib/app_bar_bottom.dart index 06ca9b6a5b..fd6be4dd14 100644 --- a/examples/catalog/lib/app_bar_bottom.dart +++ b/examples/catalog/lib/app_bar_bottom.dart @@ -6,7 +6,7 @@ import 'package:flutter/material.dart'; class AppBarBottomSample extends StatefulWidget { @override - _AppBarBottomSampleState createState() => new _AppBarBottomSampleState(); + _AppBarBottomSampleState createState() => _AppBarBottomSampleState(); } class _AppBarBottomSampleState extends State with SingleTickerProviderStateMixin { @@ -15,7 +15,7 @@ class _AppBarBottomSampleState extends State with SingleTick @override void initState() { super.initState(); - _tabController = new TabController(vsync: this, length: choices.length); + _tabController = TabController(vsync: this, length: choices.length); } @override @@ -33,40 +33,40 @@ class _AppBarBottomSampleState extends State with SingleTick @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('AppBar Bottom Widget'), - leading: new IconButton( + leading: IconButton( tooltip: 'Previous choice', icon: const Icon(Icons.arrow_back), onPressed: () { _nextPage(-1); }, ), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.arrow_forward), tooltip: 'Next choice', onPressed: () { _nextPage(1); }, ), ], - bottom: new PreferredSize( + bottom: PreferredSize( preferredSize: const Size.fromHeight(48.0), - child: new Theme( + child: Theme( data: Theme.of(context).copyWith(accentColor: Colors.white), - child: new Container( + child: Container( height: 48.0, alignment: Alignment.center, - child: new TabPageSelector(controller: _tabController), + child: TabPageSelector(controller: _tabController), ), ), ), ), - body: new TabBarView( + body: TabBarView( controller: _tabController, children: choices.map((Choice choice) { - return new Padding( + return Padding( padding: const EdgeInsets.all(16.0), - child: new ChoiceCard(choice: choice), + child: ChoiceCard(choice: choice), ); }).toList(), ), @@ -98,15 +98,15 @@ class ChoiceCard extends StatelessWidget { @override Widget build(BuildContext context) { final TextStyle textStyle = Theme.of(context).textTheme.display1; - return new Card( + return Card( color: Colors.white, - child: new Center( - child: new Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Icon(choice.icon, size: 128.0, color: textStyle.color), - new Text(choice.title, style: textStyle), + Icon(choice.icon, size: 128.0, color: textStyle.color), + Text(choice.title, style: textStyle), ], ), ), @@ -115,7 +115,7 @@ class ChoiceCard extends StatelessWidget { } void main() { - runApp(new AppBarBottomSample()); + runApp(AppBarBottomSample()); } /* diff --git a/examples/catalog/lib/basic_app_bar.dart b/examples/catalog/lib/basic_app_bar.dart index f5c9a57e02..3638d64f60 100644 --- a/examples/catalog/lib/basic_app_bar.dart +++ b/examples/catalog/lib/basic_app_bar.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; // This app is a stateful, it tracks the user's current choice. class BasicAppBarSample extends StatefulWidget { @override - _BasicAppBarSampleState createState() => new _BasicAppBarSampleState(); + _BasicAppBarSampleState createState() => _BasicAppBarSampleState(); } class _BasicAppBarSampleState extends State { @@ -21,35 +21,35 @@ class _BasicAppBarSampleState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('Basic AppBar'), actions: [ - new IconButton( // action button - icon: new Icon(choices[0].icon), + IconButton( // action button + icon: Icon(choices[0].icon), onPressed: () { _select(choices[0]); }, ), - new IconButton( // action button - icon: new Icon(choices[1].icon), + IconButton( // action button + icon: Icon(choices[1].icon), onPressed: () { _select(choices[1]); }, ), - new PopupMenuButton( // overflow menu + PopupMenuButton( // overflow menu onSelected: _select, itemBuilder: (BuildContext context) { return choices.skip(2).map((Choice choice) { - return new PopupMenuItem( + return PopupMenuItem( value: choice, - child: new Text(choice.title), + child: Text(choice.title), ); }).toList(); }, ), ], ), - body: new Padding( + body: Padding( padding: const EdgeInsets.all(16.0), - child: new ChoiceCard(choice: _selectedChoice), + child: ChoiceCard(choice: _selectedChoice), ), ), ); @@ -79,15 +79,15 @@ class ChoiceCard extends StatelessWidget { @override Widget build(BuildContext context) { final TextStyle textStyle = Theme.of(context).textTheme.display1; - return new Card( + return Card( color: Colors.white, - child: new Center( - child: new Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Icon(choice.icon, size: 128.0, color: textStyle.color), - new Text(choice.title, style: textStyle), + Icon(choice.icon, size: 128.0, color: textStyle.color), + Text(choice.title, style: textStyle), ], ), ), @@ -96,7 +96,7 @@ class ChoiceCard extends StatelessWidget { } void main() { - runApp(new BasicAppBarSample()); + runApp(BasicAppBarSample()); } /* diff --git a/examples/catalog/lib/custom_a11y_traversal.dart b/examples/catalog/lib/custom_a11y_traversal.dart index bae1100464..3d0b286031 100644 --- a/examples/catalog/lib/custom_a11y_traversal.dart +++ b/examples/catalog/lib/custom_a11y_traversal.dart @@ -76,10 +76,10 @@ class RowColumnTraversal extends StatelessWidget { /// The resulting order is the same. @override Widget build(BuildContext context) { - return new Semantics( - sortKey: new OrdinalSortKey(columnOrder.toDouble()), - child: new Semantics( - sortKey: new OrdinalSortKey(rowOrder.toDouble()), + return Semantics( + sortKey: OrdinalSortKey(columnOrder.toDouble()), + child: Semantics( + sortKey: OrdinalSortKey(rowOrder.toDouble()), child: child, ), ); @@ -111,12 +111,12 @@ class SpinnerButton extends StatelessWidget { Widget build(BuildContext context) { final String label = '${increment ? 'Increment' : 'Decrement'} ${_fieldToName(field)}'; - return new RowColumnTraversal( + return RowColumnTraversal( rowOrder: rowOrder, columnOrder: columnOrder, - child: new Center( - child: new IconButton( - icon: new Icon(icon), + child: Center( + child: IconButton( + icon: Icon(icon), onPressed: onPressed, tooltip: label, ), @@ -151,17 +151,17 @@ class FieldWidget extends StatelessWidget { final String increasedValue = '${_fieldToName(field)} ${value + 1}'; final String decreasedValue = '${_fieldToName(field)} ${value - 1}'; - return new RowColumnTraversal( + return RowColumnTraversal( rowOrder: rowOrder, columnOrder: columnOrder, - child: new Center( - child: new Semantics( + child: Center( + child: Semantics( onDecrease: onDecrease, onIncrease: onIncrease, value: stringValue, increasedValue: increasedValue, decreasedValue: decreasedValue, - child: new ExcludeSemantics(child: new Text(value.toString())), + child: ExcludeSemantics(child: Text(value.toString())), ), ), ); @@ -190,7 +190,7 @@ String _fieldToName(Field field) { /// The top-level example widget that serves as the body of the app. class CustomTraversalExample extends StatefulWidget { @override - CustomTraversalExampleState createState() => new CustomTraversalExampleState(); + CustomTraversalExampleState createState() => CustomTraversalExampleState(); } /// The state object for the top level example widget. @@ -206,15 +206,15 @@ class CustomTraversalExampleState extends State { } Widget _makeFieldHeader(int rowOrder, int columnOrder, Field field) { - return new RowColumnTraversal( + return RowColumnTraversal( rowOrder: rowOrder, columnOrder: columnOrder, - child: new Text(_fieldToName(field)), + child: Text(_fieldToName(field)), ); } Widget _makeSpinnerButton(int rowOrder, int columnOrder, Field field, {bool increment = true}) { - return new SpinnerButton( + return SpinnerButton( rowOrder: rowOrder, columnOrder: columnOrder, icon: increment ? Icons.arrow_upward : Icons.arrow_downward, @@ -225,7 +225,7 @@ class CustomTraversalExampleState extends State { } Widget _makeEntryField(int rowOrder, int columnOrder, Field field) { - return new FieldWidget( + return FieldWidget( rowOrder: rowOrder, columnOrder: columnOrder, onIncrease: () => _addToField(field, 1), @@ -237,20 +237,20 @@ class CustomTraversalExampleState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('Pet Inventory'), ), - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new DefaultTextStyle( + return DefaultTextStyle( style: DefaultTextStyle.of(context).style.copyWith(fontSize: 21.0), - child: new Column( + child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Semantics( + Semantics( // Since this is the only sort key that the text has, it // will be compared with the 'column' OrdinalSortKeys of all the // fields, because the column sort keys are first in the other fields. @@ -262,7 +262,7 @@ class CustomTraversalExampleState extends State { ), ), const Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - new Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _makeFieldHeader(1, 0, Field.DOGS), @@ -270,7 +270,7 @@ class CustomTraversalExampleState extends State { _makeFieldHeader(1, 2, Field.FISH), ], ), - new Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _makeSpinnerButton(3, 0, Field.DOGS, increment: true), @@ -278,7 +278,7 @@ class CustomTraversalExampleState extends State { _makeSpinnerButton(3, 2, Field.FISH, increment: true), ], ), - new Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _makeEntryField(2, 0, Field.DOGS), @@ -286,7 +286,7 @@ class CustomTraversalExampleState extends State { _makeEntryField(2, 2, Field.FISH), ], ), - new Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ _makeSpinnerButton(4, 0, Field.DOGS, increment: false), @@ -295,14 +295,14 @@ class CustomTraversalExampleState extends State { ], ), const Padding(padding: EdgeInsets.symmetric(vertical: 10.0)), - new Semantics( + Semantics( // Since this is the only sort key that the reset button has, it // will be compared with the 'column' OrdinalSortKeys of all the // fields, because the column sort keys are first in the other fields. // // an ordinal of "5.0" means that it will be traversed after column 4. sortKey: const OrdinalSortKey(5.0), - child: new MaterialButton( + child: MaterialButton( child: const Text('RESET'), textTheme: ButtonTextTheme.normal, textColor: Colors.blue, @@ -324,7 +324,7 @@ class CustomTraversalExampleState extends State { } void main() { - runApp(new CustomTraversalExample()); + runApp(CustomTraversalExample()); } /* diff --git a/examples/catalog/lib/custom_semantics.dart b/examples/catalog/lib/custom_semantics.dart index dcd5ce6c27..f9dc9e4316 100644 --- a/examples/catalog/lib/custom_semantics.dart +++ b/examples/catalog/lib/custom_semantics.dart @@ -36,7 +36,7 @@ class AdjustableDropdownListTile extends StatelessWidget { final bool canIncrease = indexOfValue < items.length - 1; final bool canDecrease = indexOfValue > 0; - return new Semantics( + return Semantics( container: true, label: label, value: value, @@ -44,16 +44,16 @@ class AdjustableDropdownListTile extends StatelessWidget { decreasedValue: canDecrease ? _decreasedValue : null, onIncrease: canIncrease ? _performIncrease : null, onDecrease: canDecrease ? _performDecrease : null, - child: new ExcludeSemantics( - child: new ListTile( - title: new Text(label), - trailing: new DropdownButton( + child: ExcludeSemantics( + child: ListTile( + title: Text(label), + trailing: DropdownButton( value: value, onChanged: onChanged, items: items.map((String item) { - return new DropdownMenuItem( + return DropdownMenuItem( value: item, - child: new Text(item), + child: Text(item), ); }).toList(), ), @@ -81,7 +81,7 @@ class AdjustableDropdownListTile extends StatelessWidget { class AdjustableDropdownExample extends StatefulWidget { @override - AdjustableDropdownExampleState createState() => new AdjustableDropdownExampleState(); + AdjustableDropdownExampleState createState() => AdjustableDropdownExampleState(); } class AdjustableDropdownExampleState extends State { @@ -97,14 +97,14 @@ class AdjustableDropdownExampleState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('Adjustable DropDown'), ), - body: new ListView( + body: ListView( children: [ - new AdjustableDropdownListTile( + AdjustableDropdownListTile( label: 'Timeout', value: timeout ?? items[2], items: items, @@ -122,7 +122,7 @@ class AdjustableDropdownExampleState extends State { } void main() { - runApp(new AdjustableDropdownExample()); + runApp(AdjustableDropdownExample()); } /* diff --git a/examples/catalog/lib/expansion_tile_sample.dart b/examples/catalog/lib/expansion_tile_sample.dart index c3ca67d926..9e0264d030 100644 --- a/examples/catalog/lib/expansion_tile_sample.dart +++ b/examples/catalog/lib/expansion_tile_sample.dart @@ -7,13 +7,13 @@ import 'package:flutter/material.dart'; class ExpansionTileSample extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( title: const Text('ExpansionTile'), ), - body: new ListView.builder( - itemBuilder: (BuildContext context, int index) => new EntryItem(data[index]), + body: ListView.builder( + itemBuilder: (BuildContext context, int index) => EntryItem(data[index]), itemCount: data.length, ), ), @@ -30,35 +30,35 @@ class Entry { // The entire multilevel list displayed by this app. final List data = [ - new Entry('Chapter A', + Entry('Chapter A', [ - new Entry('Section A0', + Entry('Section A0', [ - new Entry('Item A0.1'), - new Entry('Item A0.2'), - new Entry('Item A0.3'), + Entry('Item A0.1'), + Entry('Item A0.2'), + Entry('Item A0.3'), ], ), - new Entry('Section A1'), - new Entry('Section A2'), + Entry('Section A1'), + Entry('Section A2'), ], ), - new Entry('Chapter B', + Entry('Chapter B', [ - new Entry('Section B0'), - new Entry('Section B1'), + Entry('Section B0'), + Entry('Section B1'), ], ), - new Entry('Chapter C', + Entry('Chapter C', [ - new Entry('Section C0'), - new Entry('Section C1'), - new Entry('Section C2', + Entry('Section C0'), + Entry('Section C1'), + Entry('Section C2', [ - new Entry('Item C2.0'), - new Entry('Item C2.1'), - new Entry('Item C2.2'), - new Entry('Item C2.3'), + Entry('Item C2.0'), + Entry('Item C2.1'), + Entry('Item C2.2'), + Entry('Item C2.3'), ], ), ], @@ -74,10 +74,10 @@ class EntryItem extends StatelessWidget { Widget _buildTiles(Entry root) { if (root.children.isEmpty) - return new ListTile(title: new Text(root.title)); - return new ExpansionTile( - key: new PageStorageKey(root), - title: new Text(root.title), + return ListTile(title: Text(root.title)); + return ExpansionTile( + key: PageStorageKey(root), + title: Text(root.title), children: root.children.map(_buildTiles).toList(), ); } @@ -89,7 +89,7 @@ class EntryItem extends StatelessWidget { } void main() { - runApp(new ExpansionTileSample()); + runApp(ExpansionTileSample()); } /* diff --git a/examples/catalog/lib/tabbed_app_bar.dart b/examples/catalog/lib/tabbed_app_bar.dart index 11c506a535..6bcfc1d326 100644 --- a/examples/catalog/lib/tabbed_app_bar.dart +++ b/examples/catalog/lib/tabbed_app_bar.dart @@ -7,27 +7,27 @@ import 'package:flutter/material.dart'; class TabbedAppBarSample extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( - home: new DefaultTabController( + return MaterialApp( + home: DefaultTabController( length: choices.length, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('Tabbed AppBar'), - bottom: new TabBar( + bottom: TabBar( isScrollable: true, tabs: choices.map((Choice choice) { - return new Tab( + return Tab( text: choice.title, - icon: new Icon(choice.icon), + icon: Icon(choice.icon), ); }).toList(), ), ), - body: new TabBarView( + body: TabBarView( children: choices.map((Choice choice) { - return new Padding( + return Padding( padding: const EdgeInsets.all(16.0), - child: new ChoiceCard(choice: choice), + child: ChoiceCard(choice: choice), ); }).toList(), ), @@ -60,15 +60,15 @@ class ChoiceCard extends StatelessWidget { @override Widget build(BuildContext context) { final TextStyle textStyle = Theme.of(context).textTheme.display1; - return new Card( + return Card( color: Colors.white, - child: new Center( - child: new Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Icon(choice.icon, size: 128.0, color: textStyle.color), - new Text(choice.title, style: textStyle), + Icon(choice.icon, size: 128.0, color: textStyle.color), + Text(choice.title, style: textStyle), ], ), ), @@ -77,7 +77,7 @@ class ChoiceCard extends StatelessWidget { } void main() { - runApp(new TabbedAppBarSample()); + runApp(TabbedAppBarSample()); } /* diff --git a/examples/flutter_gallery/lib/demo/animation/home.dart b/examples/flutter_gallery/lib/demo/animation/home.dart index 3abb74895f..4a0de2d54b 100644 --- a/examples/flutter_gallery/lib/demo/animation/home.dart +++ b/examples/flutter_gallery/lib/demo/animation/home.dart @@ -65,7 +65,7 @@ class _RenderStatusBarPaddingSliver extends RenderSliver { @override void performLayout() { final double height = (maxHeight - constraints.scrollOffset / scrollFactor).clamp(0.0, maxHeight); - geometry = new SliverGeometry( + geometry = SliverGeometry( paintExtent: math.min(height, constraints.remainingPaintExtent), scrollExtent: maxHeight, maxPaintExtent: maxHeight, @@ -87,7 +87,7 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { @override _RenderStatusBarPaddingSliver createRenderObject(BuildContext context) { - return new _RenderStatusBarPaddingSliver( + return _RenderStatusBarPaddingSliver( maxHeight: maxHeight, scrollFactor: scrollFactor, ); @@ -103,8 +103,8 @@ class _StatusBarPaddingSliver extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DoubleProperty('maxHeight', maxHeight)); - description.add(new DoubleProperty('scrollFactor', scrollFactor)); + description.add(DoubleProperty('maxHeight', maxHeight)); + description.add(DoubleProperty('scrollFactor', scrollFactor)); } } @@ -124,7 +124,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new SizedBox.expand(child: child); + return SizedBox.expand(child: child); } @override @@ -210,34 +210,34 @@ class _AllSectionsLayout extends MultiChildLayoutDelegate { for (int index = 0; index < cardCount; index++) { // Layout the card for index. - final Rect columnCardRect = new Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight); - final Rect rowCardRect = new Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height); + final Rect columnCardRect = Rect.fromLTWH(columnCardX, columnCardY, columnCardWidth, columnCardHeight); + final Rect rowCardRect = Rect.fromLTWH(rowCardX, 0.0, rowCardWidth, size.height); final Rect cardRect = _interpolateRect(columnCardRect, rowCardRect).shift(offset); final String cardId = 'card$index'; if (hasChild(cardId)) { - layoutChild(cardId, new BoxConstraints.tight(cardRect.size)); + layoutChild(cardId, BoxConstraints.tight(cardRect.size)); positionChild(cardId, cardRect.topLeft); } // Layout the title for index. - final Size titleSize = layoutChild('title$index', new BoxConstraints.loose(cardRect.size)); + final Size titleSize = layoutChild('title$index', BoxConstraints.loose(cardRect.size)); final double columnTitleY = columnCardRect.centerLeft.dy - titleSize.height / 2.0; final double rowTitleY = rowCardRect.centerLeft.dy - titleSize.height / 2.0; final double centeredRowTitleX = rowTitleX + (rowTitleWidth - titleSize.width) / 2.0; - final Offset columnTitleOrigin = new Offset(columnTitleX, columnTitleY); - final Offset rowTitleOrigin = new Offset(centeredRowTitleX, rowTitleY); + final Offset columnTitleOrigin = Offset(columnTitleX, columnTitleY); + final Offset rowTitleOrigin = Offset(centeredRowTitleX, rowTitleY); final Offset titleOrigin = _interpolatePoint(columnTitleOrigin, rowTitleOrigin); positionChild('title$index', titleOrigin + offset); // Layout the selection indicator for index. - final Size indicatorSize = layoutChild('indicator$index', new BoxConstraints.loose(cardRect.size)); + final Size indicatorSize = layoutChild('indicator$index', BoxConstraints.loose(cardRect.size)); final double columnIndicatorX = cardRect.centerRight.dx - indicatorSize.width - 16.0; final double columnIndicatorY = cardRect.bottomRight.dy - indicatorSize.height - 16.0; - final Offset columnIndicatorOrigin = new Offset(columnIndicatorX, columnIndicatorY); - final Rect titleRect = new Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin)); + final Offset columnIndicatorOrigin = Offset(columnIndicatorX, columnIndicatorY); + final Rect titleRect = Rect.fromPoints(titleOrigin, titleSize.bottomRight(titleOrigin)); final double centeredRowIndicatorX = rowIndicatorX + (rowIndicatorWidth - indicatorSize.width) / 2.0; final double rowIndicatorY = titleRect.bottomCenter.dy + 16.0; - final Offset rowIndicatorOrigin = new Offset(centeredRowIndicatorX, rowIndicatorY); + final Offset rowIndicatorOrigin = Offset(centeredRowIndicatorX, rowIndicatorY); final Offset indicatorOrigin = _interpolatePoint(columnIndicatorOrigin, rowIndicatorOrigin); positionChild('indicator$index', indicatorOrigin + offset); @@ -319,13 +319,13 @@ class _AllSectionsView extends AnimatedWidget { return 1.0 - _selectedIndexDelta(index) * tColumnToRow * 0.15; } - final List children = new List.from(sectionCards); + final List children = List.from(sectionCards); for (int index = 0; index < sections.length; index++) { final Section section = sections[index]; - children.add(new LayoutId( + children.add(LayoutId( id: 'title$index', - child: new SectionTitle( + child: SectionTitle( section: section, scale: _titleScale(index), opacity: _titleOpacity(index), @@ -334,17 +334,17 @@ class _AllSectionsView extends AnimatedWidget { } for (int index = 0; index < sections.length; index++) { - children.add(new LayoutId( + children.add(LayoutId( id: 'indicator$index', - child: new SectionIndicator( + child: SectionIndicator( opacity: _indicatorOpacity(index), ), )); } - return new CustomMultiChildLayout( - delegate: new _AllSectionsLayout( - translation: new Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0), + return CustomMultiChildLayout( + delegate: _AllSectionsLayout( + translation: Alignment((selectedIndex.value - sectionIndex) * 2.0 - 1.0, -1.0), tColumnToRow: tColumnToRow, tCollapsed: tCollapsed, cardCount: sections.length, @@ -356,7 +356,7 @@ class _AllSectionsView extends AnimatedWidget { @override Widget build(BuildContext context) { - return new LayoutBuilder(builder: _build); + return LayoutBuilder(builder: _build); } } @@ -374,17 +374,17 @@ class _SnappingScrollPhysics extends ClampingScrollPhysics { @override _SnappingScrollPhysics applyTo(ScrollPhysics ancestor) { - return new _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset); + return _SnappingScrollPhysics(parent: buildParent(ancestor), midScrollOffset: midScrollOffset); } Simulation _toMidScrollOffsetSimulation(double offset, double dragVelocity) { final double velocity = math.max(dragVelocity, minFlingVelocity); - return new ScrollSpringSimulation(spring, offset, midScrollOffset, velocity, tolerance: tolerance); + return ScrollSpringSimulation(spring, offset, midScrollOffset, velocity, tolerance: tolerance); } Simulation _toZeroScrollOffsetSimulation(double offset, double dragVelocity) { final double velocity = math.max(dragVelocity, minFlingVelocity); - return new ScrollSpringSimulation(spring, offset, 0.0, velocity, tolerance: tolerance); + return ScrollSpringSimulation(spring, offset, 0.0, velocity, tolerance: tolerance); } @override @@ -425,21 +425,21 @@ class AnimationDemoHome extends StatefulWidget { static const String routeName = '/animation'; @override - _AnimationDemoHomeState createState() => new _AnimationDemoHomeState(); + _AnimationDemoHomeState createState() => _AnimationDemoHomeState(); } class _AnimationDemoHomeState extends State { - final ScrollController _scrollController = new ScrollController(); - final PageController _headingPageController = new PageController(); - final PageController _detailsPageController = new PageController(); + final ScrollController _scrollController = ScrollController(); + final PageController _headingPageController = PageController(); + final PageController _detailsPageController = PageController(); ScrollPhysics _headingScrollPhysics = const NeverScrollableScrollPhysics(); - ValueNotifier selectedIndex = new ValueNotifier(0.0); + ValueNotifier selectedIndex = ValueNotifier(0.0); @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( backgroundColor: _kAppBackgroundColor, - body: new Builder( + body: Builder( // Insert an element so that _buildBody can find the PrimaryScrollController. builder: _buildBody, ), @@ -494,7 +494,7 @@ class _AnimationDemoHomeState extends State { Iterable _detailItemsFor(Section section) { final Iterable detailItems = section.details.map((SectionDetail detail) { - return new SectionDetailView(detail: detail); + return SectionDetailView(detail: detail); }); return ListTile.divideTiles(context: context, tiles: detailItems); } @@ -502,11 +502,11 @@ class _AnimationDemoHomeState extends State { Iterable _allHeadingItems(double maxHeight, double midScrollOffset) { final List sectionCards = []; for (int index = 0; index < allSections.length; index++) { - sectionCards.add(new LayoutId( + sectionCards.add(LayoutId( id: 'card$index', - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, - child: new SectionCard(section: allSections[index]), + child: SectionCard(section: allSections[index]), onTapUp: (TapUpDetails details) { final double xOffset = details.globalPosition.dx; setState(() { @@ -519,10 +519,10 @@ class _AnimationDemoHomeState extends State { final List headings = []; for (int index = 0; index < allSections.length; index++) { - headings.add(new Container( + headings.add(Container( color: _kAppBackgroundColor, - child: new ClipRect( - child: new _AllSectionsView( + child: ClipRect( + child: _AllSectionsView( sectionIndex: index, sections: allSections, selectedIndex: selectedIndex, @@ -547,33 +547,33 @@ class _AnimationDemoHomeState extends State { // The scroll offset that reveals the appBarMidHeight appbar. final double appBarMidScrollOffset = statusBarHeight + appBarMaxHeight - _kAppBarMidHeight; - return new SizedBox.expand( - child: new Stack( + return SizedBox.expand( + child: Stack( children: [ - new NotificationListener( + NotificationListener( onNotification: (ScrollNotification notification) { return _handleScrollNotification(notification, appBarMidScrollOffset); }, - child: new CustomScrollView( + child: CustomScrollView( controller: _scrollController, - physics: new _SnappingScrollPhysics(midScrollOffset: appBarMidScrollOffset), + physics: _SnappingScrollPhysics(midScrollOffset: appBarMidScrollOffset), slivers: [ // Start out below the status bar, gradually move to the top of the screen. - new _StatusBarPaddingSliver( + _StatusBarPaddingSliver( maxHeight: statusBarHeight, scrollFactor: 7.0, ), // Section Headings - new SliverPersistentHeader( + SliverPersistentHeader( pinned: true, - delegate: new _SliverAppBarDelegate( + delegate: _SliverAppBarDelegate( minHeight: _kAppBarMinHeight, maxHeight: appBarMaxHeight, - child: new NotificationListener( + child: NotificationListener( onNotification: (ScrollNotification notification) { return _handlePageNotification(notification, _headingPageController, _detailsPageController); }, - child: new PageView( + child: PageView( physics: _headingScrollPhysics, controller: _headingPageController, children: _allHeadingItems(appBarMaxHeight, appBarMidScrollOffset), @@ -582,17 +582,17 @@ class _AnimationDemoHomeState extends State { ), ), // Details - new SliverToBoxAdapter( - child: new SizedBox( + SliverToBoxAdapter( + child: SizedBox( height: 610.0, - child: new NotificationListener( + child: NotificationListener( onNotification: (ScrollNotification notification) { return _handlePageNotification(notification, _detailsPageController, _headingPageController); }, - child: new PageView( + child: PageView( controller: _detailsPageController, children: allSections.map((Section section) { - return new Column( + return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: _detailItemsFor(section).toList(), ); @@ -604,15 +604,15 @@ class _AnimationDemoHomeState extends State { ], ), ), - new Positioned( + Positioned( top: statusBarHeight, left: 0.0, - child: new IconTheme( + child: IconTheme( data: const IconThemeData(color: Colors.white), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new IconButton( + child: IconButton( icon: const BackButtonIcon(), tooltip: 'Back', onPressed: () { diff --git a/examples/flutter_gallery/lib/demo/animation/widgets.dart b/examples/flutter_gallery/lib/demo/animation/widgets.dart index a6f874d2de..6c82ec25fd 100644 --- a/examples/flutter_gallery/lib/demo/animation/widgets.dart +++ b/examples/flutter_gallery/lib/demo/animation/widgets.dart @@ -18,12 +18,12 @@ class SectionCard extends StatelessWidget { @override Widget build(BuildContext context) { - return new Semantics( + return Semantics( label: section.title, button: true, - child: new DecoratedBox( - decoration: new BoxDecoration( - gradient: new LinearGradient( + child: DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, colors: [ @@ -32,7 +32,7 @@ class SectionCard extends StatelessWidget { ], ), ), - child: new Image.asset( + child: Image.asset( section.backgroundAsset, package: section.backgroundAssetPackage, color: const Color.fromRGBO(255, 255, 255, 0.075), @@ -76,19 +76,19 @@ class SectionTitle extends StatelessWidget { @override Widget build(BuildContext context) { - return new IgnorePointer( - child: new Opacity( + return IgnorePointer( + child: Opacity( opacity: opacity, - child: new Transform( - transform: new Matrix4.identity()..scale(scale), + child: Transform( + transform: Matrix4.identity()..scale(scale), alignment: Alignment.center, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 4.0, - child: new Text(section.title, style: sectionTitleShadowStyle), + child: Text(section.title, style: sectionTitleShadowStyle), ), - new Text(section.title, style: sectionTitleStyle), + Text(section.title, style: sectionTitleStyle), ], ), ), @@ -105,8 +105,8 @@ class SectionIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return new IgnorePointer( - child: new Container( + return IgnorePointer( + child: Container( width: kSectionIndicatorWidth, height: 3.0, color: Colors.white.withOpacity(opacity), @@ -126,11 +126,11 @@ class SectionDetailView extends StatelessWidget { @override Widget build(BuildContext context) { - final Widget image = new DecoratedBox( - decoration: new BoxDecoration( - borderRadius: new BorderRadius.circular(6.0), - image: new DecorationImage( - image: new AssetImage( + final Widget image = DecoratedBox( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(6.0), + image: DecorationImage( + image: AssetImage( detail.imageAsset, package: detail.imageAssetPackage, ), @@ -142,25 +142,25 @@ class SectionDetailView extends StatelessWidget { Widget item; if (detail.title == null && detail.subtitle == null) { - item = new Container( + item = Container( height: 240.0, padding: const EdgeInsets.all(16.0), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, child: image, ), ); } else { - item = new ListTile( - title: new Text(detail.title), - subtitle: new Text(detail.subtitle), - leading: new SizedBox(width: 32.0, height: 32.0, child: image), + item = ListTile( + title: Text(detail.title), + subtitle: Text(detail.subtitle), + leading: SizedBox(width: 32.0, height: 32.0, child: image), ); } - return new DecoratedBox( - decoration: new BoxDecoration(color: Colors.grey.shade200), + return DecoratedBox( + decoration: BoxDecoration(color: Colors.grey.shade200), child: item, ); } diff --git a/examples/flutter_gallery/lib/demo/calculator/home.dart b/examples/flutter_gallery/lib/demo/calculator/home.dart index cacea78a80..2be02ecdbd 100644 --- a/examples/flutter_gallery/lib/demo/calculator/home.dart +++ b/examples/flutter_gallery/lib/demo/calculator/home.dart @@ -10,7 +10,7 @@ class Calculator extends StatefulWidget { const Calculator({Key key}) : super(key: key); @override - _CalculatorState createState() => new _CalculatorState(); + _CalculatorState createState() => _CalculatorState(); } class _CalculatorState extends State { @@ -18,7 +18,7 @@ class _CalculatorState extends State { /// keep a stack of previous expressions so we can return to earlier states /// when the user hits the DEL key. final List _expressionStack = []; - CalcExpression _expression = new CalcExpression.empty(); + CalcExpression _expression = CalcExpression.empty(); // Make `expression` the current expression and push the previous current // expression onto the stack. @@ -32,7 +32,7 @@ class _CalculatorState extends State { if (_expressionStack.isNotEmpty) { _expression = _expressionStack.removeLast(); } else { - _expression = new CalcExpression.empty(); + _expression = CalcExpression.empty(); } } @@ -113,23 +113,23 @@ class _CalculatorState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( backgroundColor: Theme.of(context).canvasColor, elevation: 0.0 ), - body: new Column( + body: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ // Give the key-pad 3/5 of the vertical space and the display 2/5. - new Expanded( + Expanded( flex: 2, - child: new CalcDisplay(content: _expression.toString()) + child: CalcDisplay(content: _expression.toString()) ), const Divider(height: 1.0), - new Expanded( + Expanded( flex: 3, - child: new KeyPad(calcState: this) + child: KeyPad(calcState: this) ) ] ) @@ -144,8 +144,8 @@ class CalcDisplay extends StatelessWidget { @override Widget build(BuildContext context) { - return new Center( - child: new Text( + return Center( + child: Text( content, style: const TextStyle(fontSize: 24.0) ) @@ -160,56 +160,56 @@ class KeyPad extends StatelessWidget { @override Widget build(BuildContext context) { - final ThemeData themeData = new ThemeData( + final ThemeData themeData = ThemeData( primarySwatch: Colors.purple, brightness: Brightness.dark, platform: Theme.of(context).platform, ); - return new Theme( + return Theme( data: themeData, - child: new Material( - child: new Row( + child: Material( + child: Row( children: [ - new Expanded( + Expanded( // We set flex equal to the number of columns so that the main keypad // and the op keypad have sizes proportional to their number of // columns. flex: 3, - child: new Column( + child: Column( children: [ - new KeyRow([ - new NumberKey(7, calcState), - new NumberKey(8, calcState), - new NumberKey(9, calcState) + KeyRow([ + NumberKey(7, calcState), + NumberKey(8, calcState), + NumberKey(9, calcState) ]), - new KeyRow([ - new NumberKey(4, calcState), - new NumberKey(5, calcState), - new NumberKey(6, calcState) + KeyRow([ + NumberKey(4, calcState), + NumberKey(5, calcState), + NumberKey(6, calcState) ]), - new KeyRow([ - new NumberKey(1, calcState), - new NumberKey(2, calcState), - new NumberKey(3, calcState) + KeyRow([ + NumberKey(1, calcState), + NumberKey(2, calcState), + NumberKey(3, calcState) ]), - new KeyRow([ - new CalcKey('.', calcState.handlePointTap), - new NumberKey(0, calcState), - new CalcKey('=', calcState.handleEqualsTap), + KeyRow([ + CalcKey('.', calcState.handlePointTap), + NumberKey(0, calcState), + CalcKey('=', calcState.handleEqualsTap), ]) ] ) ), - new Expanded( - child: new Material( + Expanded( + child: Material( color: themeData.backgroundColor, - child: new Column( + child: Column( children: [ - new CalcKey('\u232B', calcState.handleDelTap), - new CalcKey('\u00F7', calcState.handleDivTap), - new CalcKey('\u00D7', calcState.handleMultTap), - new CalcKey('-', calcState.handleMinusTap), - new CalcKey('+', calcState.handlePlusTap) + CalcKey('\u232B', calcState.handleDelTap), + CalcKey('\u00F7', calcState.handleDivTap), + CalcKey('\u00D7', calcState.handleMultTap), + CalcKey('-', calcState.handleMinusTap), + CalcKey('+', calcState.handlePlusTap) ] ) ) @@ -228,8 +228,8 @@ class KeyRow extends StatelessWidget { @override Widget build(BuildContext context) { - return new Expanded( - child: new Row( + return Expanded( + child: Row( mainAxisAlignment: MainAxisAlignment.center, children: keys ) @@ -246,13 +246,13 @@ class CalcKey extends StatelessWidget { @override Widget build(BuildContext context) { final Orientation orientation = MediaQuery.of(context).orientation; - return new Expanded( - child: new InkResponse( + return Expanded( + child: InkResponse( onTap: onTap, - child: new Center( - child: new Text( + child: Center( + child: Text( text, - style: new TextStyle( + style: TextStyle( fontSize: (orientation == Orientation.portrait) ? 32.0 : 24.0 ) ) diff --git a/examples/flutter_gallery/lib/demo/calculator/logic.dart b/examples/flutter_gallery/lib/demo/calculator/logic.dart index 266f12fee7..730544c837 100644 --- a/examples/flutter_gallery/lib/demo/calculator/logic.dart +++ b/examples/flutter_gallery/lib/demo/calculator/logic.dart @@ -138,7 +138,7 @@ class CalcExpression { /// in the calculator's display panel. @override String toString() { - final StringBuffer buffer = new StringBuffer(''); + final StringBuffer buffer = StringBuffer(''); buffer.writeAll(_list); return buffer.toString(); } @@ -153,29 +153,29 @@ class CalcExpression { switch (state) { case ExpressionState.Start: // Start a new number with digit. - newToken = new IntToken('$digit'); + newToken = IntToken('$digit'); break; case ExpressionState.LeadingNeg: // Replace the leading neg with a negative number starting with digit. outList.removeLast(); - newToken = new IntToken('-$digit'); + newToken = IntToken('-$digit'); break; case ExpressionState.Number: final ExpressionToken last = outList.removeLast(); - newToken = new IntToken('${last.stringRep}$digit'); + newToken = IntToken('${last.stringRep}$digit'); break; case ExpressionState.Point: case ExpressionState.NumberWithPoint: final ExpressionToken last = outList.removeLast(); newState = ExpressionState.NumberWithPoint; - newToken = new FloatToken('${last.stringRep}$digit'); + newToken = FloatToken('${last.stringRep}$digit'); break; case ExpressionState.Result: // Cannot enter a number now return null; } outList.add(newToken); - return new CalcExpression(outList, newState); + return CalcExpression(outList, newState); } /// Append a point to the current expression and return a new expression @@ -186,12 +186,12 @@ class CalcExpression { final List outList = _list.toList(); switch (state) { case ExpressionState.Start: - newToken = new FloatToken('.'); + newToken = FloatToken('.'); break; case ExpressionState.LeadingNeg: case ExpressionState.Number: final ExpressionToken last = outList.removeLast(); - newToken = new FloatToken(last.stringRep + '.'); + newToken = FloatToken(last.stringRep + '.'); break; case ExpressionState.Point: case ExpressionState.NumberWithPoint: @@ -200,7 +200,7 @@ class CalcExpression { return null; } outList.add(newToken); - return new CalcExpression(outList, ExpressionState.Point); + return CalcExpression(outList, ExpressionState.Point); } /// Append an operation symbol to the current expression and return a new @@ -219,8 +219,8 @@ class CalcExpression { break; } final List outList = _list.toList(); - outList.add(new OperationToken(op)); - return new CalcExpression(outList, ExpressionState.Start); + outList.add(OperationToken(op)); + return CalcExpression(outList, ExpressionState.Start); } /// Append a leading minus sign to the current expression and return a new @@ -239,8 +239,8 @@ class CalcExpression { return null; } final List outList = _list.toList(); - outList.add(new LeadingNegToken()); - return new CalcExpression(outList, ExpressionState.LeadingNeg); + outList.add(LeadingNegToken()); + return CalcExpression(outList, ExpressionState.LeadingNeg); } /// Append a minus sign to the current expression and return a new expression @@ -303,8 +303,8 @@ class CalcExpression { } } final List outList = []; - outList.add(new ResultToken(currentTermValue)); - return new CalcExpression(outList, ExpressionState.Result); + outList.add(ResultToken(currentTermValue)); + return CalcExpression(outList, ExpressionState.Result); } /// Removes the next "term" from `list` and returns its numeric value. diff --git a/examples/flutter_gallery/lib/demo/colors_demo.dart b/examples/flutter_gallery/lib/demo/colors_demo.dart index 703850920c..a38999ba2d 100644 --- a/examples/flutter_gallery/lib/demo/colors_demo.dart +++ b/examples/flutter_gallery/lib/demo/colors_demo.dart @@ -18,25 +18,25 @@ class Palette { } final List allPalettes = [ - new Palette(name: 'RED', primary: Colors.red, accent: Colors.redAccent, threshold: 300), - new Palette(name: 'PINK', primary: Colors.pink, accent: Colors.pinkAccent, threshold: 200), - new Palette(name: 'PURPLE', primary: Colors.purple, accent: Colors.purpleAccent, threshold: 200), - new Palette(name: 'DEEP PURPLE', primary: Colors.deepPurple, accent: Colors.deepPurpleAccent, threshold: 200), - new Palette(name: 'INDIGO', primary: Colors.indigo, accent: Colors.indigoAccent, threshold: 200), - new Palette(name: 'BLUE', primary: Colors.blue, accent: Colors.blueAccent, threshold: 400), - new Palette(name: 'LIGHT BLUE', primary: Colors.lightBlue, accent: Colors.lightBlueAccent, threshold: 500), - new Palette(name: 'CYAN', primary: Colors.cyan, accent: Colors.cyanAccent, threshold: 600), - new Palette(name: 'TEAL', primary: Colors.teal, accent: Colors.tealAccent, threshold: 400), - new Palette(name: 'GREEN', primary: Colors.green, accent: Colors.greenAccent, threshold: 500), - new Palette(name: 'LIGHT GREEN', primary: Colors.lightGreen, accent: Colors.lightGreenAccent, threshold: 600), - new Palette(name: 'LIME', primary: Colors.lime, accent: Colors.limeAccent, threshold: 800), - new Palette(name: 'YELLOW', primary: Colors.yellow, accent: Colors.yellowAccent), - new Palette(name: 'AMBER', primary: Colors.amber, accent: Colors.amberAccent), - new Palette(name: 'ORANGE', primary: Colors.orange, accent: Colors.orangeAccent, threshold: 700), - new Palette(name: 'DEEP ORANGE', primary: Colors.deepOrange, accent: Colors.deepOrangeAccent, threshold: 400), - new Palette(name: 'BROWN', primary: Colors.brown, threshold: 200), - new Palette(name: 'GREY', primary: Colors.grey, threshold: 500), - new Palette(name: 'BLUE GREY', primary: Colors.blueGrey, threshold: 500), + Palette(name: 'RED', primary: Colors.red, accent: Colors.redAccent, threshold: 300), + Palette(name: 'PINK', primary: Colors.pink, accent: Colors.pinkAccent, threshold: 200), + Palette(name: 'PURPLE', primary: Colors.purple, accent: Colors.purpleAccent, threshold: 200), + Palette(name: 'DEEP PURPLE', primary: Colors.deepPurple, accent: Colors.deepPurpleAccent, threshold: 200), + Palette(name: 'INDIGO', primary: Colors.indigo, accent: Colors.indigoAccent, threshold: 200), + Palette(name: 'BLUE', primary: Colors.blue, accent: Colors.blueAccent, threshold: 400), + Palette(name: 'LIGHT BLUE', primary: Colors.lightBlue, accent: Colors.lightBlueAccent, threshold: 500), + Palette(name: 'CYAN', primary: Colors.cyan, accent: Colors.cyanAccent, threshold: 600), + Palette(name: 'TEAL', primary: Colors.teal, accent: Colors.tealAccent, threshold: 400), + Palette(name: 'GREEN', primary: Colors.green, accent: Colors.greenAccent, threshold: 500), + Palette(name: 'LIGHT GREEN', primary: Colors.lightGreen, accent: Colors.lightGreenAccent, threshold: 600), + Palette(name: 'LIME', primary: Colors.lime, accent: Colors.limeAccent, threshold: 800), + Palette(name: 'YELLOW', primary: Colors.yellow, accent: Colors.yellowAccent), + Palette(name: 'AMBER', primary: Colors.amber, accent: Colors.amberAccent), + Palette(name: 'ORANGE', primary: Colors.orange, accent: Colors.orangeAccent, threshold: 700), + Palette(name: 'DEEP ORANGE', primary: Colors.deepOrange, accent: Colors.deepOrangeAccent, threshold: 400), + Palette(name: 'BROWN', primary: Colors.brown, threshold: 200), + Palette(name: 'GREY', primary: Colors.grey, threshold: 500), + Palette(name: 'BLUE GREY', primary: Colors.blueGrey, threshold: 500), ]; @@ -59,21 +59,21 @@ class ColorItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new Semantics( + return Semantics( container: true, - child: new Container( + child: Container( height: kColorItemHeight, padding: const EdgeInsets.symmetric(horizontal: 16.0), color: color, - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Text('$prefix$index'), - new Text(colorString()), + Text('$prefix$index'), + Text(colorString()), ], ), ), @@ -100,22 +100,22 @@ class PaletteTabView extends StatelessWidget { final TextStyle whiteTextStyle = textTheme.body1.copyWith(color: Colors.white); final TextStyle blackTextStyle = textTheme.body1.copyWith(color: Colors.black); final List colorItems = primaryKeys.map((int index) { - return new DefaultTextStyle( + return DefaultTextStyle( style: index > colors.threshold ? whiteTextStyle : blackTextStyle, - child: new ColorItem(index: index, color: colors.primary[index]), + child: ColorItem(index: index, color: colors.primary[index]), ); }).toList(); if (colors.accent != null) { colorItems.addAll(accentKeys.map((int index) { - return new DefaultTextStyle( + return DefaultTextStyle( style: index > colors.threshold ? whiteTextStyle : blackTextStyle, - child: new ColorItem(index: index, color: colors.accent[index], prefix: 'A'), + child: ColorItem(index: index, color: colors.accent[index], prefix: 'A'), ); }).toList()); } - return new ListView( + return ListView( itemExtent: kColorItemHeight, children: colorItems, ); @@ -127,20 +127,20 @@ class ColorsDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new DefaultTabController( + return DefaultTabController( length: allPalettes.length, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( elevation: 0.0, title: const Text('Colors'), - bottom: new TabBar( + bottom: TabBar( isScrollable: true, - tabs: allPalettes.map((Palette swatch) => new Tab(text: swatch.name)).toList(), + tabs: allPalettes.map((Palette swatch) => Tab(text: swatch.name)).toList(), ), ), - body: new TabBarView( + body: TabBarView( children: allPalettes.map((Palette colors) { - return new PaletteTabView(colors: colors); + return PaletteTabView(colors: colors); }).toList(), ), ), diff --git a/examples/flutter_gallery/lib/demo/contacts_demo.dart b/examples/flutter_gallery/lib/demo/contacts_demo.dart index e67eb4c158..3ff7e6f80d 100644 --- a/examples/flutter_gallery/lib/demo/contacts_demo.dart +++ b/examples/flutter_gallery/lib/demo/contacts_demo.dart @@ -14,25 +14,25 @@ class _ContactCategory extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData themeData = Theme.of(context); - return new Container( + return Container( padding: const EdgeInsets.symmetric(vertical: 16.0), - decoration: new BoxDecoration( - border: new Border(bottom: new BorderSide(color: themeData.dividerColor)) + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: themeData.dividerColor)) ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: Theme.of(context).textTheme.subhead, - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Container( + Container( padding: const EdgeInsets.symmetric(vertical: 24.0), width: 72.0, - child: new Icon(icon, color: themeData.primaryColor) + child: Icon(icon, color: themeData.primaryColor) ), - new Expanded(child: new Column(children: children)) + Expanded(child: Column(children: children)) ], ), ), @@ -54,31 +54,31 @@ class _ContactItem extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData themeData = Theme.of(context); - final List columnChildren = lines.sublist(0, lines.length - 1).map((String line) => new Text(line)).toList(); - columnChildren.add(new Text(lines.last, style: themeData.textTheme.caption)); + final List columnChildren = lines.sublist(0, lines.length - 1).map((String line) => Text(line)).toList(); + columnChildren.add(Text(lines.last, style: themeData.textTheme.caption)); final List rowChildren = [ - new Expanded( - child: new Column( + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: columnChildren ) ) ]; if (icon != null) { - rowChildren.add(new SizedBox( + rowChildren.add(SizedBox( width: 72.0, - child: new IconButton( - icon: new Icon(icon), + child: IconButton( + icon: Icon(icon), color: themeData.primaryColor, onPressed: onPressed ) )); } - return new MergeSemantics( - child: new Padding( + return MergeSemantics( + child: Padding( padding: const EdgeInsets.symmetric(vertical: 16.0), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: rowChildren ) @@ -91,36 +91,36 @@ class ContactsDemo extends StatefulWidget { static const String routeName = '/contacts'; @override - ContactsDemoState createState() => new ContactsDemoState(); + ContactsDemoState createState() => ContactsDemoState(); } enum AppBarBehavior { normal, pinned, floating, snapping } class ContactsDemoState extends State { - static final GlobalKey _scaffoldKey = new GlobalKey(); + static final GlobalKey _scaffoldKey = GlobalKey(); final double _appBarHeight = 256.0; AppBarBehavior _appBarBehavior = AppBarBehavior.pinned; @override Widget build(BuildContext context) { - return new Theme( - data: new ThemeData( + return Theme( + data: ThemeData( brightness: Brightness.light, primarySwatch: Colors.indigo, platform: Theme.of(context).platform, ), - child: new Scaffold( + child: Scaffold( key: _scaffoldKey, - body: new CustomScrollView( + body: CustomScrollView( slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: _appBarHeight, pinned: _appBarBehavior == AppBarBehavior.pinned, floating: _appBarBehavior == AppBarBehavior.floating || _appBarBehavior == AppBarBehavior.snapping, snap: _appBarBehavior == AppBarBehavior.snapping, actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.create), tooltip: 'Edit', onPressed: () { @@ -129,7 +129,7 @@ class ContactsDemoState extends State { )); }, ), - new PopupMenuButton( + PopupMenuButton( onSelected: (AppBarBehavior value) { setState(() { _appBarBehavior = value; @@ -155,12 +155,12 @@ class ContactsDemoState extends State { ], ), ], - flexibleSpace: new FlexibleSpaceBar( + flexibleSpace: FlexibleSpaceBar( title: const Text('Ali Connors'), - background: new Stack( + background: Stack( fit: StackFit.expand, children: [ - new Image.asset( + Image.asset( 'people/ali_landscape.png', package: 'flutter_gallery_assets', fit: BoxFit.cover, @@ -181,14 +181,14 @@ class ContactsDemoState extends State { ), ), ), - new SliverList( - delegate: new SliverChildListDelegate([ - new AnnotatedRegion( + SliverList( + delegate: SliverChildListDelegate([ + AnnotatedRegion( value: SystemUiOverlayStyle.dark, - child: new _ContactCategory( + child: _ContactCategory( icon: Icons.call, children: [ - new _ContactItem( + _ContactItem( icon: Icons.message, tooltip: 'Send message', onPressed: () { @@ -201,7 +201,7 @@ class ContactsDemoState extends State { 'Mobile', ], ), - new _ContactItem( + _ContactItem( icon: Icons.message, tooltip: 'Send message', onPressed: () { @@ -214,7 +214,7 @@ class ContactsDemoState extends State { 'Work', ], ), - new _ContactItem( + _ContactItem( icon: Icons.message, tooltip: 'Send message', onPressed: () { @@ -230,10 +230,10 @@ class ContactsDemoState extends State { ], ), ), - new _ContactCategory( + _ContactCategory( icon: Icons.contact_mail, children: [ - new _ContactItem( + _ContactItem( icon: Icons.email, tooltip: 'Send personal e-mail', onPressed: () { @@ -246,7 +246,7 @@ class ContactsDemoState extends State { 'Personal', ], ), - new _ContactItem( + _ContactItem( icon: Icons.email, tooltip: 'Send work e-mail', onPressed: () { @@ -261,10 +261,10 @@ class ContactsDemoState extends State { ), ], ), - new _ContactCategory( + _ContactCategory( icon: Icons.location_on, children: [ - new _ContactItem( + _ContactItem( icon: Icons.map, tooltip: 'Open map', onPressed: () { @@ -278,7 +278,7 @@ class ContactsDemoState extends State { 'Home', ], ), - new _ContactItem( + _ContactItem( icon: Icons.map, tooltip: 'Open map', onPressed: () { @@ -292,7 +292,7 @@ class ContactsDemoState extends State { 'Work', ], ), - new _ContactItem( + _ContactItem( icon: Icons.map, tooltip: 'Open map', onPressed: () { @@ -308,28 +308,28 @@ class ContactsDemoState extends State { ), ], ), - new _ContactCategory( + _ContactCategory( icon: Icons.today, children: [ - new _ContactItem( + _ContactItem( lines: const [ 'Birthday', 'January 9th, 1989', ], ), - new _ContactItem( + _ContactItem( lines: const [ 'Wedding anniversary', 'June 21st, 2014', ], ), - new _ContactItem( + _ContactItem( lines: const [ 'First day in office', 'January 20th, 2015', ], ), - new _ContactItem( + _ContactItem( lines: const [ 'Last day in office', 'August 9th, 2018', diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart index b1dbc741ea..d5efbbaebf 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_activity_indicator_demo.dart @@ -10,8 +10,8 @@ class CupertinoProgressIndicatorDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Cupertino Activity Indicator'), ), body: const Center( diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart index eca06c3045..137dc3dd8d 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_alert_demo.dart @@ -9,11 +9,11 @@ class CupertinoAlertDemo extends StatefulWidget { static const String routeName = '/cupertino/alert'; @override - _CupertinoAlertDemoState createState() => new _CupertinoAlertDemoState(); + _CupertinoAlertDemoState createState() => _CupertinoAlertDemoState(); } class _CupertinoAlertDemoState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); void showDemoDialog({BuildContext context, Widget child}) { showDialog( @@ -24,8 +24,8 @@ class _CupertinoAlertDemoState extends State { // The value passed to Navigator.pop() or null. if (value != null) { _scaffoldKey.currentState.showSnackBar( - new SnackBar( - content: new Text('You selected: $value'), + SnackBar( + content: Text('You selected: $value'), ), ); } @@ -39,8 +39,8 @@ class _CupertinoAlertDemoState extends State { ).then((T value) { if (value != null) { _scaffoldKey.currentState.showSnackBar( - new SnackBar( - content: new Text('You selected: $value'), + SnackBar( + content: Text('You selected: $value'), ), ); } @@ -49,31 +49,31 @@ class _CupertinoAlertDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Cupertino Alerts'), ), - body: new ListView( + body: ListView( padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0), children: [ - new CupertinoButton( + CupertinoButton( child: const Text('Alert'), color: CupertinoColors.activeBlue, onPressed: () { showDemoDialog( context: context, - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( title: const Text('Discard draft?'), actions: [ - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Discard'), isDestructiveAction: true, onPressed: () { Navigator.pop(context, 'Discard'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Cancel'), isDefaultAction: true, onPressed: () { @@ -86,25 +86,25 @@ class _CupertinoAlertDemoState extends State { }, ), const Padding(padding: EdgeInsets.all(8.0)), - new CupertinoButton( + CupertinoButton( child: const Text('Alert with Title'), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), onPressed: () { showDemoDialog( context: context, - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( title: const Text('Allow "Maps" to access your location while you are using the app?'), content: const Text('Your current location will be displayed on the map and used ' 'for directions, nearby search results, and estimated travel times.'), actions: [ - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Don\'t Allow'), onPressed: () { Navigator.pop(context, 'Disallow'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Allow'), onPressed: () { Navigator.pop(context, 'Allow'); @@ -116,7 +116,7 @@ class _CupertinoAlertDemoState extends State { }, ), const Padding(padding: EdgeInsets.all(8.0)), - new CupertinoButton( + CupertinoButton( child: const Text('Alert with Buttons'), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), @@ -133,7 +133,7 @@ class _CupertinoAlertDemoState extends State { }, ), const Padding(padding: EdgeInsets.all(8.0)), - new CupertinoButton( + CupertinoButton( child: const Text('Alert Buttons Only'), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), @@ -145,37 +145,37 @@ class _CupertinoAlertDemoState extends State { }, ), const Padding(padding: EdgeInsets.all(8.0)), - new CupertinoButton( + CupertinoButton( child: const Text('Action Sheet'), color: CupertinoColors.activeBlue, padding: const EdgeInsets.symmetric(vertical: 16.0, horizontal: 36.0), onPressed: () { showDemoActionSheet( context: context, - child: new CupertinoActionSheet( + child: CupertinoActionSheet( title: const Text('Favorite Dessert'), message: const Text('Please select the best dessert from the options below.'), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Profiteroles'), onPressed: () { Navigator.pop(context, 'Profiteroles'); }, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Cannolis'), onPressed: () { Navigator.pop(context, 'Cannolis'); }, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Trifle'), onPressed: () { Navigator.pop(context, 'Trifle'); }, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), isDefaultAction: true, onPressed: () { @@ -200,53 +200,53 @@ class CupertinoDessertDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: title, content: content, actions: [ - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Cheesecake'), onPressed: () { Navigator.pop(context, 'Cheesecake'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Tiramisu'), onPressed: () { Navigator.pop(context, 'Tiramisu'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Apple Pie'), onPressed: () { Navigator.pop(context, 'Apple Pie'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text("Devil's food cake"), onPressed: () { Navigator.pop(context, "Devil's food cake"); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Banana Split'), onPressed: () { Navigator.pop(context, 'Banana Split'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Oatmeal Cookie'), onPressed: () { Navigator.pop(context, 'Oatmeal Cookies'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Chocolate Brownie'), onPressed: () { Navigator.pop(context, 'Chocolate Brownies'); }, ), - new CupertinoDialogAction( + CupertinoDialogAction( child: const Text('Cancel'), isDestructiveAction: true, onPressed: () { diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart index ba6bc51ca7..6625fd518b 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_buttons_demo.dart @@ -9,7 +9,7 @@ class CupertinoButtonsDemo extends StatefulWidget { static const String routeName = '/cupertino/buttons'; @override - _CupertinoButtonDemoState createState() => new _CupertinoButtonDemoState(); + _CupertinoButtonDemoState createState() => _CupertinoButtonDemoState(); } class _CupertinoButtonDemoState extends State { @@ -17,11 +17,11 @@ class _CupertinoButtonDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Cupertino Buttons'), ), - body: new Column( + body: Column( children: [ const Padding( padding: EdgeInsets.all(16.0), @@ -30,20 +30,20 @@ class _CupertinoButtonDemoState extends State { 'only when necessary.' ), ), - new Expanded( - child: new Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text(_pressedCount > 0 + Text(_pressedCount > 0 ? 'Button pressed $_pressedCount time${_pressedCount == 1 ? "" : "s"}' : ' '), const Padding(padding: EdgeInsets.all(12.0)), - new Align( + Align( alignment: const Alignment(0.0, -0.2), - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, children: [ - new CupertinoButton( + CupertinoButton( child: const Text('Cupertino Button'), onPressed: () { setState(() { _pressedCount += 1; }); @@ -57,7 +57,7 @@ class _CupertinoButtonDemoState extends State { ), ), const Padding(padding: EdgeInsets.all(12.0)), - new CupertinoButton( + CupertinoButton( child: const Text('With Background'), color: CupertinoColors.activeBlue, onPressed: () { diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart index 4554480cda..fd32d73a16 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_navigation_demo.dart @@ -30,11 +30,11 @@ const List coolColorNames = [ class CupertinoNavigationDemo extends StatelessWidget { CupertinoNavigationDemo() - : colorItems = new List.generate(50, (int index) { - return coolColors[new math.Random().nextInt(coolColors.length)]; + : colorItems = List.generate(50, (int index) { + return coolColors[math.Random().nextInt(coolColors.length)]; }) , - colorNameItems = new List.generate(50, (int index) { - return coolColorNames[new math.Random().nextInt(coolColorNames.length)]; + colorNameItems = List.generate(50, (int index) { + return coolColorNames[math.Random().nextInt(coolColorNames.length)]; }); static const String routeName = '/cupertino/navigation'; @@ -44,17 +44,17 @@ class CupertinoNavigationDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new WillPopScope( + return WillPopScope( // Prevent swipe popping of this page. Use explicit exit buttons only. - onWillPop: () => new Future.value(true), - child: new DefaultTextStyle( + onWillPop: () => Future.value(true), + child: DefaultTextStyle( style: const TextStyle( fontFamily: '.SF UI Text', fontSize: 17.0, color: CupertinoColors.black, ), - child: new CupertinoTabScaffold( - tabBar: new CupertinoTabBar( + child: CupertinoTabScaffold( + tabBar: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: Icon(CupertinoIcons.home), @@ -74,9 +74,9 @@ class CupertinoNavigationDemo extends StatelessWidget { assert(index >= 0 && index <= 2); switch (index) { case 0: - return new CupertinoTabView( + return CupertinoTabView( builder: (BuildContext context) { - return new CupertinoDemoTab1( + return CupertinoDemoTab1( colorItems: colorItems, colorNameItems: colorNameItems ); @@ -85,13 +85,13 @@ class CupertinoNavigationDemo extends StatelessWidget { ); break; case 1: - return new CupertinoTabView( + return CupertinoTabView( builder: (BuildContext context) => CupertinoDemoTab2(), defaultTitle: 'Support Chat', ); break; case 2: - return new CupertinoTabView( + return CupertinoTabView( builder: (BuildContext context) => CupertinoDemoTab3(), defaultTitle: 'Account', ); @@ -110,7 +110,7 @@ class ExitButton extends StatelessWidget { @override Widget build(BuildContext context) { - return new CupertinoButton( + return CupertinoButton( padding: EdgeInsets.zero, child: const Tooltip( message: 'Back', @@ -133,13 +133,13 @@ class CupertinoDemoTab1 extends StatelessWidget { @override Widget build(BuildContext context) { - return new CupertinoPageScaffold( - child: new CustomScrollView( + return CupertinoPageScaffold( + child: CustomScrollView( slivers: [ const CupertinoSliverNavigationBar( trailing: ExitButton(), ), - new SliverPadding( + SliverPadding( // Top media padding consumed by CupertinoSliverNavigationBar. // Left/Right media padding consumed by Tab1RowItem. padding: MediaQuery.of(context).removePadding( @@ -147,10 +147,10 @@ class CupertinoDemoTab1 extends StatelessWidget { removeLeft: true, removeRight: true, ).padding, - sliver: new SliverList( - delegate: new SliverChildBuilderDelegate( + sliver: SliverList( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - return new Tab1RowItem( + return Tab1RowItem( index: index, lastItem: index == 49, color: colorItems[index], @@ -177,40 +177,40 @@ class Tab1RowItem extends StatelessWidget { @override Widget build(BuildContext context) { - final Widget row = new GestureDetector( + final Widget row = GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { - Navigator.of(context).push(new CupertinoPageRoute( + Navigator.of(context).push(CupertinoPageRoute( title: colorName, - builder: (BuildContext context) => new Tab1ItemPage( + builder: (BuildContext context) => Tab1ItemPage( color: color, colorName: colorName, index: index, ), )); }, - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new Padding( + child: Padding( padding: const EdgeInsets.only(left: 16.0, top: 8.0, bottom: 8.0, right: 8.0), - child: new Row( + child: Row( children: [ - new Container( + Container( height: 60.0, width: 60.0, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: color, - borderRadius: new BorderRadius.circular(8.0), + borderRadius: BorderRadius.circular(8.0), ), ), - new Expanded( - child: new Padding( + Expanded( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 12.0), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Text(colorName), + Text(colorName), const Padding(padding: EdgeInsets.only(top: 8.0)), const Text( 'Buy this cool color', @@ -224,7 +224,7 @@ class Tab1RowItem extends StatelessWidget { ), ), ), - new CupertinoButton( + CupertinoButton( padding: EdgeInsets.zero, child: const Icon(CupertinoIcons.plus_circled, color: CupertinoColors.activeBlue, @@ -232,7 +232,7 @@ class Tab1RowItem extends StatelessWidget { ), onPressed: () { }, ), - new CupertinoButton( + CupertinoButton( padding: EdgeInsets.zero, child: const Icon(CupertinoIcons.share, color: CupertinoColors.activeBlue, @@ -250,10 +250,10 @@ class Tab1RowItem extends StatelessWidget { return row; } - return new Column( + return Column( children: [ row, - new Container( + Container( height: 1.0, color: const Color(0xFFD9D9D9), ), @@ -270,16 +270,16 @@ class Tab1ItemPage extends StatefulWidget { final int index; @override - State createState() => new Tab1ItemPageState(); + State createState() => Tab1ItemPageState(); } class Tab1ItemPageState extends State { @override void initState() { super.initState(); - relatedColors = new List.generate(10, (int index) { - final math.Random random = new math.Random(); - return new Color.fromARGB( + relatedColors = List.generate(10, (int index) { + final math.Random random = math.Random(); + return Color.fromARGB( 255, (widget.color.red + random.nextInt(100) - 50).clamp(0, 255), (widget.color.green + random.nextInt(100) - 50).clamp(0, 255), @@ -292,41 +292,41 @@ class Tab1ItemPageState extends State { @override Widget build(BuildContext context) { - return new CupertinoPageScaffold( + return CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( trailing: ExitButton(), ), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new ListView( + child: ListView( children: [ const Padding(padding: EdgeInsets.only(top: 16.0)), - new Padding( + Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new Row( + child: Row( mainAxisSize: MainAxisSize.max, children: [ - new Container( + Container( height: 128.0, width: 128.0, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: widget.color, - borderRadius: new BorderRadius.circular(24.0), + borderRadius: BorderRadius.circular(24.0), ), ), const Padding(padding: EdgeInsets.only(left: 18.0)), - new Expanded( - child: new Column( + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: [ - new Text( + Text( widget.colorName, style: const TextStyle(fontSize: 24.0, fontWeight: FontWeight.bold), ), const Padding(padding: EdgeInsets.only(top: 6.0)), - new Text( + Text( 'Item number ${widget.index}', style: const TextStyle( color: Color(0xFF8E8E93), @@ -335,14 +335,14 @@ class Tab1ItemPageState extends State { ), ), const Padding(padding: EdgeInsets.only(top: 20.0)), - new Row( + Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new CupertinoButton( + CupertinoButton( color: CupertinoColors.activeBlue, minSize: 30.0, padding: const EdgeInsets.symmetric(horizontal: 24.0), - borderRadius: new BorderRadius.circular(32.0), + borderRadius: BorderRadius.circular(32.0), child: const Text( 'GET', style: TextStyle( @@ -353,11 +353,11 @@ class Tab1ItemPageState extends State { ), onPressed: () { }, ), - new CupertinoButton( + CupertinoButton( color: CupertinoColors.activeBlue, minSize: 30.0, padding: EdgeInsets.zero, - borderRadius: new BorderRadius.circular(32.0), + borderRadius: BorderRadius.circular(32.0), child: const Icon(CupertinoIcons.ellipsis, color: CupertinoColors.white), onPressed: () { }, ), @@ -381,22 +381,22 @@ class Tab1ItemPageState extends State { ), ), ), - new SizedBox( + SizedBox( height: 200.0, - child: new ListView.builder( + child: ListView.builder( scrollDirection: Axis.horizontal, itemCount: 10, itemExtent: 160.0, itemBuilder: (BuildContext context, int index) { - return new Padding( + return Padding( padding: const EdgeInsets.only(left: 16.0), - child: new Container( - decoration: new BoxDecoration( - borderRadius: new BorderRadius.circular(8.0), + child: Container( + decoration: BoxDecoration( + borderRadius: BorderRadius.circular(8.0), color: relatedColors[index], ), - child: new Center( - child: new CupertinoButton( + child: Center( + child: CupertinoButton( child: const Icon( CupertinoIcons.plus_circled, color: CupertinoColors.white, @@ -420,13 +420,13 @@ class Tab1ItemPageState extends State { class CupertinoDemoTab2 extends StatelessWidget { @override Widget build(BuildContext context) { - return new CupertinoPageScaffold( + return CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( trailing: ExitButton(), ), - child: new ListView( + child: ListView( children: [ - new Tab2Header(), + Tab2Header(), ]..addAll(buildTab2Conversation()), ), ); @@ -436,23 +436,23 @@ class CupertinoDemoTab2 extends StatelessWidget { class Tab2Header extends StatelessWidget { @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: const EdgeInsets.all(16.0), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new ClipRRect( + child: ClipRRect( borderRadius: const BorderRadius.all(Radius.circular(16.0)), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new Container( + Container( decoration: const BoxDecoration( color: Color(0xFFE5E5E5), ), - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: const [ Text( @@ -477,13 +477,13 @@ class Tab2Header extends StatelessWidget { ), ), ), - new Container( + Container( decoration: const BoxDecoration( color: Color(0xFFF3F3F3), ), - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 18.0, vertical: 12.0), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text( @@ -505,9 +505,9 @@ class Tab2Header extends StatelessWidget { ), ), const Padding(padding: EdgeInsets.only(top: 8.0)), - new Row( + Row( children: [ - new Container( + Container( width: 44.0, height: 44.0, decoration: const BoxDecoration( @@ -521,7 +521,7 @@ class Tab2Header extends StatelessWidget { ), ), const Padding(padding: EdgeInsets.only(left: 8.0)), - new Container( + Container( width: 44.0, height: 44.0, decoration: const BoxDecoration( @@ -567,8 +567,8 @@ class Tab2ConversationBubble extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( - decoration: new BoxDecoration( + return Container( + decoration: BoxDecoration( borderRadius: const BorderRadius.all(Radius.circular(18.0)), color: color == Tab2ConversationBubbleColor.blue ? CupertinoColors.activeBlue @@ -576,9 +576,9 @@ class Tab2ConversationBubble extends StatelessWidget { ), margin: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 8.0), padding: const EdgeInsets.symmetric(horizontal: 14.0, vertical: 10.0), - child: new Text( + child: Text( text, - style: new TextStyle( + style: TextStyle( color: color == Tab2ConversationBubbleColor.blue ? CupertinoColors.white : CupertinoColors.black, @@ -599,15 +599,15 @@ class Tab2ConversationAvatar extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( - decoration: new BoxDecoration( + return Container( + decoration: BoxDecoration( shape: BoxShape.circle, - gradient: new LinearGradient( + gradient: LinearGradient( begin: FractionalOffset.topCenter, end: FractionalOffset.bottomCenter, colors: [ color, - new Color.fromARGB( + Color.fromARGB( color.alpha, (color.red - 60).clamp(0, 255), (color.green - 60).clamp(0, 255), @@ -618,7 +618,7 @@ class Tab2ConversationAvatar extends StatelessWidget { ), margin: const EdgeInsets.only(left: 8.0, bottom: 8.0), padding: const EdgeInsets.all(12.0), - child: new Text( + child: Text( text, style: const TextStyle( color: CupertinoColors.white, @@ -644,15 +644,15 @@ class Tab2ConversationRow extends StatelessWidget { final bool isSelf = avatar == null; children.add( - new Tab2ConversationBubble( + Tab2ConversationBubble( text: text, color: isSelf ? Tab2ConversationBubbleColor.blue : Tab2ConversationBubbleColor.gray, ), ); - return new SafeArea( - child: new Row( + return SafeArea( + child: Row( mainAxisAlignment: isSelf ? MainAxisAlignment.end : MainAxisAlignment.start, mainAxisSize: MainAxisSize.min, crossAxisAlignment: isSelf ? CrossAxisAlignment.center : CrossAxisAlignment.end, @@ -703,25 +703,25 @@ List buildTab2Conversation() { class CupertinoDemoTab3 extends StatelessWidget { @override Widget build(BuildContext context) { - return new CupertinoPageScaffold( + return CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( trailing: ExitButton(), ), - child: new DecoratedBox( + child: DecoratedBox( decoration: const BoxDecoration(color: Color(0xFFEFEFF4)), - child: new ListView( + child: ListView( children: [ const Padding(padding: EdgeInsets.only(top: 32.0)), - new GestureDetector( + GestureDetector( onTap: () { Navigator.of(context, rootNavigator: true).push( - new CupertinoPageRoute( + CupertinoPageRoute( fullscreenDialog: true, - builder: (BuildContext context) => new Tab3Dialog(), + builder: (BuildContext context) => Tab3Dialog(), ), ); }, - child: new Container( + child: Container( decoration: const BoxDecoration( color: CupertinoColors.white, border: Border( @@ -730,12 +730,12 @@ class CupertinoDemoTab3 extends StatelessWidget { ), ), height: 44.0, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 8.0), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new Row( + child: Row( children: const [ Text( 'Sign in', @@ -757,9 +757,9 @@ class CupertinoDemoTab3 extends StatelessWidget { class Tab3Dialog extends StatelessWidget { @override Widget build(BuildContext context) { - return new CupertinoPageScaffold( - navigationBar: new CupertinoNavigationBar( - leading: new CupertinoButton( + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + leading: CupertinoButton( child: const Text('Cancel'), padding: EdgeInsets.zero, onPressed: () { @@ -767,8 +767,8 @@ class Tab3Dialog extends StatelessWidget { }, ), ), - child: new Center( - child: new Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, children: [ const Icon( @@ -777,7 +777,7 @@ class Tab3Dialog extends StatelessWidget { color: Color(0xFF646464), ), const Padding(padding: EdgeInsets.only(top: 18.0)), - new CupertinoButton( + CupertinoButton( color: CupertinoColors.activeBlue, child: const Text('Sign in'), onPressed: () { diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart index bc210f8871..7e36064e53 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_picker_demo.dart @@ -13,16 +13,16 @@ class CupertinoPickerDemo extends StatefulWidget { static const String routeName = '/cupertino/picker'; @override - _CupertinoPickerDemoState createState() => new _CupertinoPickerDemoState(); + _CupertinoPickerDemoState createState() => _CupertinoPickerDemoState(); } class _CupertinoPickerDemoState extends State { int _selectedColorIndex = 0; - Duration timer = new Duration(); + Duration timer = Duration(); Widget _buildMenu(List children) { - return new Container( + return Container( decoration: const BoxDecoration( color: CupertinoColors.white, border: Border( @@ -31,18 +31,18 @@ class _CupertinoPickerDemoState extends State { ), ), height: 44.0, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: const TextStyle( letterSpacing: -0.24, fontSize: 17.0, color: CupertinoColors.black, ), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: children, ), @@ -54,8 +54,8 @@ class _CupertinoPickerDemoState extends State { Widget _buildColorPicker() { final FixedExtentScrollController scrollController = - new FixedExtentScrollController(initialItem: _selectedColorIndex); - return new CupertinoPicker( + FixedExtentScrollController(initialItem: _selectedColorIndex); + return CupertinoPicker( scrollController: scrollController, itemExtent: _kPickerItemHeight, backgroundColor: CupertinoColors.white, @@ -64,27 +64,27 @@ class _CupertinoPickerDemoState extends State { _selectedColorIndex = index; }); }, - children: new List.generate(coolColorNames.length, (int index) { - return new Center(child: - new Text(coolColorNames[index]), + children: List.generate(coolColorNames.length, (int index) { + return Center(child: + Text(coolColorNames[index]), ); }), ); } Widget _buildBottomPicker(Widget picker) { - return new Container( + return Container( height: _kPickerSheetHeight, color: CupertinoColors.white, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: const TextStyle( color: CupertinoColors.black, fontSize: 22.0, ), - child: new GestureDetector( + child: GestureDetector( // Blocks taps from propagating to the modal sheet and popping. onTap: () {}, - child: new SafeArea( + child: SafeArea( child: picker, ), ), @@ -93,13 +93,13 @@ class _CupertinoPickerDemoState extends State { } Widget _buildCountdownTimerPicker(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { showCupertinoModalPopup( context: context, builder: (BuildContext context) { return _buildBottomPicker( - new CupertinoTimerPicker( + CupertinoTimerPicker( initialTimerDuration: timer, onTimerDurationChanged: (Duration newTimer) { setState(() { @@ -114,7 +114,7 @@ class _CupertinoPickerDemoState extends State { child: _buildMenu( [ const Text('Countdown Timer'), - new Text( + Text( '${timer.inHours}:' '${(timer.inMinutes % 60).toString().padLeft(2,'0')}:' '${(timer.inSeconds % 60).toString().padLeft(2,'0')}', @@ -127,22 +127,22 @@ class _CupertinoPickerDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Cupertino Picker'), ), - body: new DefaultTextStyle( + body: DefaultTextStyle( style: const TextStyle( fontFamily: '.SF UI Text', fontSize: 17.0, color: CupertinoColors.black, ), - child: new DecoratedBox( + child: DecoratedBox( decoration: const BoxDecoration(color: Color(0xFFEFEFF4)), - child: new ListView( + child: ListView( children: [ const Padding(padding: EdgeInsets.only(top: 32.0)), - new GestureDetector( + GestureDetector( onTap: () async { await showCupertinoModalPopup( context: context, @@ -154,7 +154,7 @@ class _CupertinoPickerDemoState extends State { child: _buildMenu( [ const Text('Favorite Color'), - new Text( + Text( coolColorNames[_selectedColorIndex], style: const TextStyle( color: CupertinoColors.inactiveGray diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart index d1fdc5e018..4eaf0e9476 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_refresh_demo.dart @@ -10,7 +10,7 @@ class CupertinoRefreshControlDemo extends StatefulWidget { static const String routeName = '/cupertino/refresh'; @override - _CupertinoRefreshControlDemoState createState() => new _CupertinoRefreshControlDemoState(); + _CupertinoRefreshControlDemoState createState() => _CupertinoRefreshControlDemoState(); } class _CupertinoRefreshControlDemoState extends State { @@ -23,8 +23,8 @@ class _CupertinoRefreshControlDemoState extends State>.generate( + final Random random = Random(); + randomizedContacts = List>.generate( 100, (int index) { return contacts[random.nextInt(contacts.length)] @@ -36,25 +36,25 @@ class _CupertinoRefreshControlDemoState extends State[ const CupertinoSliverNavigationBar( largeTitle: Text('Cupertino Refresh'), previousPageTitle: 'Cupertino', ), - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( onRefresh: () { - return new Future.delayed(const Duration(seconds: 2)) + return Future.delayed(const Duration(seconds: 2)) ..then((_) { if (mounted) { setState(() => repopulateList()); @@ -62,12 +62,12 @@ class _CupertinoRefreshControlDemoState extends State[ - new Container( + Container( width: 38.0, child: called ? const Align( @@ -167,22 +167,22 @@ class _ListItem extends StatelessWidget { ) : null, ), - new Expanded( - child: new Container( + Expanded( + child: Container( decoration: const BoxDecoration( border: Border( bottom: BorderSide(color: Color(0xFFBCBBC1), width: 0.0), ), ), padding: const EdgeInsets.only(left: 1.0, bottom: 9.0, right: 10.0), - child: new Row( + child: Row( children: [ - new Expanded( - child: new Column( + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new Text( + Text( name, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -191,7 +191,7 @@ class _ListItem extends StatelessWidget { letterSpacing: -0.18, ), ), - new Text( + Text( place, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -204,7 +204,7 @@ class _ListItem extends StatelessWidget { ], ), ), - new Text( + Text( date, style: const TextStyle( color: CupertinoColors.inactiveGray, diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart index 09e7c51b6f..5d35281ad5 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_segmented_control_demo.dart @@ -13,7 +13,7 @@ class CupertinoSegmentedControlDemo extends StatefulWidget { static const String routeName = 'cupertino/segmented_control'; @override - _CupertinoSegmentedControlDemoState createState() => new _CupertinoSegmentedControlDemoState(); + _CupertinoSegmentedControlDemoState createState() => _CupertinoSegmentedControlDemoState(); } class _CupertinoSegmentedControlDemoState extends State { @@ -48,18 +48,18 @@ class _CupertinoSegmentedControlDemoState extends State[ const Padding( padding: EdgeInsets.all(16.0), ), - new SizedBox( + SizedBox( width: 500.0, - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -69,20 +69,20 @@ class _CupertinoSegmentedControlDemoState extends State[ BoxShadow( offset: Offset(0.0, 3.0), diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_slider_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_slider_demo.dart index 5952489558..79ddb64d55 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_slider_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_slider_demo.dart @@ -9,7 +9,7 @@ class CupertinoSliderDemo extends StatefulWidget { static const String routeName = '/cupertino/slider'; @override - _CupertinoSliderDemoState createState() => new _CupertinoSliderDemoState(); + _CupertinoSliderDemoState createState() => _CupertinoSliderDemoState(); } class _CupertinoSliderDemoState extends State { @@ -18,18 +18,18 @@ class _CupertinoSliderDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Cupertino Sliders'), ), - body: new Center( - child: new Column( + body: Center( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new Column( + Column( mainAxisSize: MainAxisSize.min, children: [ - new CupertinoSlider( + CupertinoSlider( value: _value, min: 0.0, max: 100.0, @@ -39,13 +39,13 @@ class _CupertinoSliderDemoState extends State { }); } ), - new Text('Cupertino Continuous: ${_value.toStringAsFixed(1)}'), + Text('Cupertino Continuous: ${_value.toStringAsFixed(1)}'), ] ), - new Column( + Column( mainAxisSize: MainAxisSize.min, children: [ - new CupertinoSlider( + CupertinoSlider( value: _discreteValue, min: 0.0, max: 100.0, @@ -56,7 +56,7 @@ class _CupertinoSliderDemoState extends State { }); } ), - new Text('Cupertino Discrete: $_discreteValue'), + Text('Cupertino Discrete: $_discreteValue'), ] ), ], diff --git a/examples/flutter_gallery/lib/demo/cupertino/cupertino_switch_demo.dart b/examples/flutter_gallery/lib/demo/cupertino/cupertino_switch_demo.dart index 46b568ae16..81998c7a82 100644 --- a/examples/flutter_gallery/lib/demo/cupertino/cupertino_switch_demo.dart +++ b/examples/flutter_gallery/lib/demo/cupertino/cupertino_switch_demo.dart @@ -9,7 +9,7 @@ class CupertinoSwitchDemo extends StatefulWidget { static const String routeName = '/cupertino/switch'; @override - _CupertinoSwitchDemoState createState() => new _CupertinoSwitchDemoState(); + _CupertinoSwitchDemoState createState() => _CupertinoSwitchDemoState(); } class _CupertinoSwitchDemoState extends State { @@ -18,19 +18,19 @@ class _CupertinoSwitchDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Cupertino Switch'), ), - body: new Center( - child: new Column( + body: Center( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( children: [ - new CupertinoSwitch( + CupertinoSwitch( value: _switchValue, onChanged: (bool value) { setState(() { @@ -44,9 +44,9 @@ class _CupertinoSwitchDemoState extends State { ], ), ), - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( children: const [ CupertinoSwitch( value: true, @@ -58,9 +58,9 @@ class _CupertinoSwitchDemoState extends State { ], ), ), - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( children: const [ CupertinoSwitch( value: false, diff --git a/examples/flutter_gallery/lib/demo/images_demo.dart b/examples/flutter_gallery/lib/demo/images_demo.dart index da3fe77fdd..c214d2a3f7 100644 --- a/examples/flutter_gallery/lib/demo/images_demo.dart +++ b/examples/flutter_gallery/lib/demo/images_demo.dart @@ -7,28 +7,28 @@ class ImagesDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new TabbedComponentDemoScaffold( + return TabbedComponentDemoScaffold( title: 'Animated images', demos: [ - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'WEBP', description: '', exampleCodeTag: 'animated_image', - demoWidget: new Semantics( + demoWidget: Semantics( label: 'Example of animated WEBP', - child: new Image.asset( + child: Image.asset( 'animated_images/animated_flutter_stickers.webp', package: 'flutter_gallery_assets', ), ), ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'GIF', description: '', exampleCodeTag: 'animated_image', - demoWidget: new Semantics( + demoWidget: Semantics( label: 'Example of animated GIF', - child:new Image.asset( + child:Image.asset( 'animated_images/animated_flutter_lgtm.gif', package: 'flutter_gallery_assets', ), diff --git a/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart b/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart index 56a6485765..b0d6c0e7aa 100644 --- a/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/backdrop_demo.dart @@ -102,31 +102,31 @@ class CategoryView extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new ListView( - key: new PageStorageKey(category), + return ListView( + key: PageStorageKey(category), padding: const EdgeInsets.symmetric( vertical: 16.0, horizontal: 64.0, ), children: category.assets.map((String asset) { - return new Column( + return Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Card( - child: new Container( + Card( + child: Container( width: 144.0, alignment: Alignment.center, - child: new Column( + child: Column( children: [ - new Image.asset( + Image.asset( asset, package: 'flutter_gallery_assets', fit: BoxFit.contain, ), - new Container( + Container( padding: const EdgeInsets.only(bottom: 16.0), alignment: AlignmentDirectional.center, - child: new Text( + child: Text( asset, style: theme.textTheme.caption, ), @@ -164,27 +164,27 @@ class BackdropPanel extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Material( + return Material( elevation: 2.0, borderRadius: const BorderRadius.only( topLeft: Radius.circular(16.0), topRight: Radius.circular(16.0), ), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new GestureDetector( + GestureDetector( behavior: HitTestBehavior.opaque, onVerticalDragUpdate: onVerticalDragUpdate, onVerticalDragEnd: onVerticalDragEnd, onTap: onTap, - child: new Container( + child: Container( height: 48.0, padding: const EdgeInsetsDirectional.only(start: 16.0), alignment: AlignmentDirectional.centerStart, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: theme.textTheme.subhead, - child: new Tooltip( + child: Tooltip( message: 'Tap to dismiss', child: title, ), @@ -192,7 +192,7 @@ class BackdropPanel extends StatelessWidget { ), ), const Divider(height: 1.0), - new Expanded(child: child), + Expanded(child: child), ], ), ); @@ -209,21 +209,21 @@ class BackdropTitle extends AnimatedWidget { @override Widget build(BuildContext context) { final Animation animation = listenable; - return new DefaultTextStyle( + return DefaultTextStyle( style: Theme.of(context).primaryTextTheme.title, softWrap: false, overflow: TextOverflow.ellipsis, - child: new Stack( + child: Stack( children: [ - new Opacity( - opacity: new CurvedAnimation( - parent: new ReverseAnimation(animation), + Opacity( + opacity: CurvedAnimation( + parent: ReverseAnimation(animation), curve: const Interval(0.5, 1.0), ).value, child: const Text('Select a Category'), ), - new Opacity( - opacity: new CurvedAnimation( + Opacity( + opacity: CurvedAnimation( parent: animation, curve: const Interval(0.5, 1.0), ).value, @@ -240,18 +240,18 @@ class BackdropDemo extends StatefulWidget { static const String routeName = '/material/backdrop'; @override - _BackdropDemoState createState() => new _BackdropDemoState(); + _BackdropDemoState createState() => _BackdropDemoState(); } class _BackdropDemoState extends State with SingleTickerProviderStateMixin { - final GlobalKey _backdropKey = new GlobalKey(debugLabel: 'Backdrop'); + final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); AnimationController _controller; Category _category = allCategories[0]; @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(milliseconds: 300), value: 1.0, vsync: this, @@ -318,8 +318,8 @@ class _BackdropDemoState extends State with SingleTickerProviderSt final Size panelSize = constraints.biggest; final double panelTop = panelSize.height - panelTitleHeight; - final Animation panelAnimation = new RelativeRectTween( - begin: new RelativeRect.fromLTRB( + final Animation panelAnimation = RelativeRectTween( + begin: RelativeRect.fromLTRB( 0.0, panelTop - MediaQuery.of(context).padding.bottom, 0.0, @@ -327,7 +327,7 @@ class _BackdropDemoState extends State with SingleTickerProviderSt ), end: const RelativeRect.fromLTRB(0.0, 0.0, 0.0, 0.0), ).animate( - new CurvedAnimation( + CurvedAnimation( parent: _controller, curve: Curves.linear, ), @@ -336,15 +336,15 @@ class _BackdropDemoState extends State with SingleTickerProviderSt final ThemeData theme = Theme.of(context); final List backdropItems = allCategories.map((Category category) { final bool selected = category == _category; - return new Material( + return Material( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(4.0)), ), color: selected ? Colors.white.withOpacity(0.25) : Colors.transparent, - child: new ListTile( - title: new Text(category.title), + child: ListTile( + title: Text(category.title), selected: selected, onTap: () { _changeCategory(category); @@ -353,31 +353,31 @@ class _BackdropDemoState extends State with SingleTickerProviderSt ); }).toList(); - return new Container( + return Container( key: _backdropKey, color: theme.primaryColor, - child: new Stack( + child: Stack( children: [ - new ListTileTheme( + ListTileTheme( iconColor: theme.primaryIconTheme.color, textColor: theme.primaryTextTheme.title.color.withOpacity(0.6), selectedColor: theme.primaryTextTheme.title.color, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: backdropItems, ), ), ), - new PositionedTransition( + PositionedTransition( rect: panelAnimation, - child: new BackdropPanel( + child: BackdropPanel( onTap: _toggleBackdropPanelVisibility, onVerticalDragUpdate: _handleDragUpdate, onVerticalDragEnd: _handleDragEnd, - title: new Text(_category.title), - child: new CategoryView(category: _category), + title: Text(_category.title), + child: CategoryView(category: _category), ), ), ], @@ -387,23 +387,23 @@ class _BackdropDemoState extends State with SingleTickerProviderSt @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( elevation: 0.0, - title: new BackdropTitle( + title: BackdropTitle( listenable: _controller.view, ), actions: [ - new IconButton( + IconButton( onPressed: _toggleBackdropPanelVisibility, - icon: new AnimatedIcon( + icon: AnimatedIcon( icon: AnimatedIcons.close_menu, progress: _controller.view, ), ), ], ), - body: new LayoutBuilder( + body: LayoutBuilder( builder: _buildStack, ), ); diff --git a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart index d3d9576a01..0a68f87ee5 100644 --- a/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/bottom_app_bar_demo.dart @@ -8,7 +8,7 @@ class BottomAppBarDemo extends StatefulWidget { static const String routeName = '/material/bottom_app_bar'; @override - State createState() => new _BottomAppBarDemoState(); + State createState() => _BottomAppBarDemoState(); } // Flutter generally frowns upon abbrevation however this class uses two @@ -16,7 +16,7 @@ class BottomAppBarDemo extends StatefulWidget { // for bottom application bar. class _BottomAppBarDemoState extends State { - static final GlobalKey _scaffoldKey = new GlobalKey(); + static final GlobalKey _scaffoldKey = GlobalKey(); // FAB shape @@ -137,13 +137,13 @@ class _BottomAppBarDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Bottom app bar'), elevation: 0.0, actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sentiment_very_satisfied), onPressed: () { setState(() { @@ -153,38 +153,38 @@ class _BottomAppBarDemoState extends State { ), ], ), - body: new ListView( + body: ListView( padding: const EdgeInsets.only(bottom: 88.0), children: [ const _Heading('FAB Shape'), - new _RadioItem(kCircularFab, _fabShape, _onFabShapeChanged), - new _RadioItem(kDiamondFab, _fabShape, _onFabShapeChanged), - new _RadioItem(kNoFab, _fabShape, _onFabShapeChanged), + _RadioItem(kCircularFab, _fabShape, _onFabShapeChanged), + _RadioItem(kDiamondFab, _fabShape, _onFabShapeChanged), + _RadioItem(kNoFab, _fabShape, _onFabShapeChanged), const Divider(), const _Heading('Notch'), - new _RadioItem(kShowNotchTrue, _showNotch, _onShowNotchChanged), - new _RadioItem(kShowNotchFalse, _showNotch, _onShowNotchChanged), + _RadioItem(kShowNotchTrue, _showNotch, _onShowNotchChanged), + _RadioItem(kShowNotchFalse, _showNotch, _onShowNotchChanged), const Divider(), const _Heading('FAB Position'), - new _RadioItem(kFabEndDocked, _fabLocation, _onFabLocationChanged), - new _RadioItem(kFabCenterDocked, _fabLocation, _onFabLocationChanged), - new _RadioItem(kFabEndFloat, _fabLocation, _onFabLocationChanged), - new _RadioItem(kFabCenterFloat, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabEndDocked, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabCenterDocked, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabEndFloat, _fabLocation, _onFabLocationChanged), + _RadioItem(kFabCenterFloat, _fabLocation, _onFabLocationChanged), const Divider(), const _Heading('App bar color'), - new _ColorsItem(kBabColors, _babColor, _onBabColorChanged), + _ColorsItem(kBabColors, _babColor, _onBabColorChanged), ], ), floatingActionButton: _fabShape.value, floatingActionButtonLocation: _fabLocation.value, - bottomNavigationBar: new _DemoBottomAppBar( + bottomNavigationBar: _DemoBottomAppBar( color: _babColor, fabLocation: _fabLocation.value, shape: _selectNotch(), @@ -224,29 +224,29 @@ class _RadioItem extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Container( + return Container( height: 56.0, padding: const EdgeInsetsDirectional.only(start: 16.0), alignment: AlignmentDirectional.centerStart, - child: new MergeSemantics( - child: new Row( + child: MergeSemantics( + child: Row( children: [ - new Radio<_ChoiceValue>( + Radio<_ChoiceValue>( value: value, groupValue: groupValue, onChanged: onChanged, ), - new Expanded( - child: new Semantics( + Expanded( + child: Semantics( container: true, button: true, label: value.label, - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { onChanged(value); }, - child: new Text( + child: Text( value.title, style: theme.textTheme.subhead, ), @@ -276,10 +276,10 @@ class _ColorsItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new Row( + return Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: colors.map((_NamedColor namedColor) { - return new RawMaterialButton( + return RawMaterialButton( onPressed: () { onChanged(namedColor.color); }, @@ -288,13 +288,13 @@ class _ColorsItem extends StatelessWidget { height: 32.0, ), fillColor: namedColor.color, - shape: new CircleBorder( - side: new BorderSide( + shape: CircleBorder( + side: BorderSide( color: namedColor.color == selectedColor ? Colors.black : const Color(0xFFD5D7DA), width: 2.0, ), ), - child: new Semantics( + child: Semantics( value: namedColor.name, selected: namedColor.color == selectedColor, ), @@ -312,11 +312,11 @@ class _Heading extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Container( + return Container( height: 48.0, padding: const EdgeInsetsDirectional.only(start: 56.0), alignment: AlignmentDirectional.centerStart, - child: new Text( + child: Text( text, style: theme.textTheme.body1.copyWith( color: theme.primaryColor, @@ -345,7 +345,7 @@ class _DemoBottomAppBar extends StatelessWidget { @override Widget build(BuildContext context) { final List rowContents = [ - new IconButton( + IconButton( icon: const Icon(Icons.menu), onPressed: () { showModalBottomSheet( @@ -363,7 +363,7 @@ class _DemoBottomAppBar extends StatelessWidget { } rowContents.addAll( [ - new IconButton( + IconButton( icon: const Icon(Icons.search), onPressed: () { Scaffold.of(context).showSnackBar( @@ -371,8 +371,8 @@ class _DemoBottomAppBar extends StatelessWidget { ); }, ), - new IconButton( - icon: new Icon( + IconButton( + icon: Icon( Theme.of(context).platform == TargetPlatform.iOS ? Icons.more_horiz : Icons.more_vert, @@ -385,9 +385,9 @@ class _DemoBottomAppBar extends StatelessWidget { ), ]); - return new BottomAppBar( + return BottomAppBar( color: color, - child: new Row(children: rowContents), + child: Row(children: rowContents), shape: shape, ); } @@ -399,8 +399,8 @@ class _DemoDrawer extends StatelessWidget { @override Widget build(BuildContext context) { - return new Drawer( - child: new Column( + return Drawer( + child: Column( children: const [ ListTile( leading: Icon(Icons.search), @@ -428,16 +428,16 @@ class _DiamondFab extends StatelessWidget { @override Widget build(BuildContext context) { - return new Material( + return Material( shape: const _DiamondBorder(), color: Colors.orange, - child: new InkWell( + child: InkWell( onTap: onPressed, - child: new Container( + child: Container( width: 56.0, height: 56.0, child: IconTheme.merge( - data: new IconThemeData(color: Theme.of(context).accentIconTheme.color), + data: IconThemeData(color: Theme.of(context).accentIconTheme.color), child: child, ), ), @@ -453,7 +453,7 @@ class _DiamondNotchedRectangle implements NotchedShape { @override Path getOuterPath(Rect host, Rect guest) { if (!host.overlaps(guest)) - return new Path()..addRect(host); + return Path()..addRect(host); assert(guest.width > 0.0); final Rect intersection = guest.intersect(host); @@ -473,7 +473,7 @@ class _DiamondNotchedRectangle implements NotchedShape { intersection.height * (guest.height / 2.0) / (guest.width / 2.0); - return new Path() + return Path() ..moveTo(host.left, host.top) ..lineTo(guest.center.dx - notchToCenter, host.top) ..lineTo(guest.left + guest.width / 2.0, guest.bottom) @@ -500,7 +500,7 @@ class _DiamondBorder extends ShapeBorder { @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..moveTo(rect.left + rect.width / 2.0, rect.top) ..lineTo(rect.right, rect.top + rect.height / 2.0) ..lineTo(rect.left + rect.width / 2.0, rect.bottom) diff --git a/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart b/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart index fcaef9fdee..9264ff6b8d 100644 --- a/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/bottom_navigation_demo.dart @@ -14,17 +14,17 @@ class NavigationIconView { }) : _icon = icon, _color = color, _title = title, - item = new BottomNavigationBarItem( + item = BottomNavigationBarItem( icon: icon, activeIcon: activeIcon, - title: new Text(title), + title: Text(title), backgroundColor: color, ), - controller = new AnimationController( + controller = AnimationController( duration: kThemeAnimationDuration, vsync: vsync, ) { - _animation = new CurvedAnimation( + _animation = CurvedAnimation( parent: controller, curve: const Interval(0.5, 1.0, curve: Curves.fastOutSlowIn), ); @@ -48,19 +48,19 @@ class NavigationIconView { : themeData.accentColor; } - return new FadeTransition( + return FadeTransition( opacity: _animation, - child: new SlideTransition( - position: new Tween( + child: SlideTransition( + position: Tween( begin: const Offset(0.0, 0.02), // Slightly down. end: Offset.zero, ).animate(_animation), - child: new IconTheme( - data: new IconThemeData( + child: IconTheme( + data: IconThemeData( color: iconColor, size: 120.0, ), - child: new Semantics( + child: Semantics( label: 'Placeholder for $_title tab', child: _icon, ), @@ -74,7 +74,7 @@ class CustomIcon extends StatelessWidget { @override Widget build(BuildContext context) { final IconThemeData iconTheme = IconTheme.of(context); - return new Container( + return Container( margin: const EdgeInsets.all(4.0), width: iconTheme.size - 8.0, height: iconTheme.size - 8.0, @@ -87,12 +87,12 @@ class CustomInactiveIcon extends StatelessWidget { @override Widget build(BuildContext context) { final IconThemeData iconTheme = IconTheme.of(context); - return new Container( + return Container( margin: const EdgeInsets.all(4.0), width: iconTheme.size - 8.0, height: iconTheme.size - 8.0, - decoration: new BoxDecoration( - border: new Border.all(color: iconTheme.color, width: 2.0), + decoration: BoxDecoration( + border: Border.all(color: iconTheme.color, width: 2.0), ) ); } @@ -102,7 +102,7 @@ class BottomNavigationDemo extends StatefulWidget { static const String routeName = '/material/bottom_navigation'; @override - _BottomNavigationDemoState createState() => new _BottomNavigationDemoState(); + _BottomNavigationDemoState createState() => _BottomNavigationDemoState(); } class _BottomNavigationDemoState extends State @@ -115,34 +115,34 @@ class _BottomNavigationDemoState extends State void initState() { super.initState(); _navigationViews = [ - new NavigationIconView( + NavigationIconView( icon: const Icon(Icons.access_alarm), title: 'Alarm', color: Colors.deepPurple, vsync: this, ), - new NavigationIconView( - activeIcon: new CustomIcon(), - icon: new CustomInactiveIcon(), + NavigationIconView( + activeIcon: CustomIcon(), + icon: CustomInactiveIcon(), title: 'Box', color: Colors.deepOrange, vsync: this, ), - new NavigationIconView( + NavigationIconView( activeIcon: const Icon(Icons.cloud), icon: const Icon(Icons.cloud_queue), title: 'Cloud', color: Colors.teal, vsync: this, ), - new NavigationIconView( + NavigationIconView( activeIcon: const Icon(Icons.favorite), icon: const Icon(Icons.favorite_border), title: 'Favorites', color: Colors.indigo, vsync: this, ), - new NavigationIconView( + NavigationIconView( icon: const Icon(Icons.event_available), title: 'Event', color: Colors.pink, @@ -184,12 +184,12 @@ class _BottomNavigationDemoState extends State return aValue.compareTo(bValue); }); - return new Stack(children: transitions); + return Stack(children: transitions); } @override Widget build(BuildContext context) { - final BottomNavigationBar botNavBar = new BottomNavigationBar( + final BottomNavigationBar botNavBar = BottomNavigationBar( items: _navigationViews .map((NavigationIconView navigationView) => navigationView.item) .toList(), @@ -204,11 +204,11 @@ class _BottomNavigationDemoState extends State }, ); - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Bottom navigation'), actions: [ - new PopupMenuButton( + PopupMenuButton( onSelected: (BottomNavigationBarType value) { setState(() { _type = value; @@ -227,7 +227,7 @@ class _BottomNavigationDemoState extends State ) ], ), - body: new Center( + body: Center( child: _buildTransitionsStack() ), bottomNavigationBar: botNavBar, diff --git a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart index aacbbf78ec..01746cde1d 100644 --- a/examples/flutter_gallery/lib/demo/material/buttons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/buttons_demo.dart @@ -49,7 +49,7 @@ class ButtonsDemo extends StatefulWidget { static const String routeName = '/material/buttons'; @override - _ButtonsDemoState createState() => new _ButtonsDemoState(); + _ButtonsDemoState createState() => _ButtonsDemoState(); } class _ButtonsDemoState extends State { @@ -62,46 +62,46 @@ class _ButtonsDemoState extends State { ); final List demos = [ - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'RAISED', description: _raisedText, - demoWidget: new ButtonTheme.fromButtonThemeData( + demoWidget: ButtonTheme.fromButtonThemeData( data: buttonTheme, child: buildRaisedButton(), ), exampleCodeTag: _raisedCode, ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'FLAT', description: _flatText, - demoWidget: new ButtonTheme.fromButtonThemeData( + demoWidget: ButtonTheme.fromButtonThemeData( data: buttonTheme, child: buildFlatButton(), ), exampleCodeTag: _flatCode, ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'OUTLINE', description: _outlineText, - demoWidget: new ButtonTheme.fromButtonThemeData( + demoWidget: ButtonTheme.fromButtonThemeData( data: buttonTheme, child: buildOutlineButton(), ), exampleCodeTag: _outlineCode, ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'DROPDOWN', description: _dropdownText, demoWidget: buildDropdownButton(), exampleCodeTag: _dropdownCode, ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'ICON', description: _iconText, demoWidget: buildIconButton(), exampleCodeTag: _iconCode, ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'ACTION', description: _actionText, demoWidget: buildActionButton(), @@ -109,11 +109,11 @@ class _ButtonsDemoState extends State { ), ]; - return new TabbedComponentDemoScaffold( + return TabbedComponentDemoScaffold( title: 'Buttons', demos: demos, actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sentiment_very_satisfied), onPressed: () { setState(() { @@ -126,15 +126,15 @@ class _ButtonsDemoState extends State { } Widget buildRaisedButton() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new ButtonBar( + ButtonBar( mainAxisSize: MainAxisSize.min, children: [ - new RaisedButton( + RaisedButton( child: const Text('RAISED BUTTON'), onPressed: () { // Perform some action @@ -146,17 +146,17 @@ class _ButtonsDemoState extends State { ), ], ), - new ButtonBar( + ButtonBar( mainAxisSize: MainAxisSize.min, children: [ - new RaisedButton.icon( + RaisedButton.icon( icon: const Icon(Icons.add, size: 18.0), label: const Text('RAISED BUTTON'), onPressed: () { // Perform some action }, ), - new RaisedButton.icon( + RaisedButton.icon( icon: const Icon(Icons.add, size: 18.0), label: const Text('DISABLED'), onPressed: null, @@ -169,15 +169,15 @@ class _ButtonsDemoState extends State { } Widget buildFlatButton() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new ButtonBar( + ButtonBar( mainAxisSize: MainAxisSize.min, children: [ - new FlatButton( + FlatButton( child: const Text('FLAT BUTTON'), onPressed: () { // Perform some action @@ -189,17 +189,17 @@ class _ButtonsDemoState extends State { ), ], ), - new ButtonBar( + ButtonBar( mainAxisSize: MainAxisSize.min, children: [ - new FlatButton.icon( + FlatButton.icon( icon: const Icon(Icons.add_circle_outline, size: 18.0), label: const Text('FLAT BUTTON'), onPressed: () { // Perform some action }, ), - new FlatButton.icon( + FlatButton.icon( icon: const Icon(Icons.add_circle_outline, size: 18.0), label: const Text('DISABLED'), onPressed: null, @@ -212,15 +212,15 @@ class _ButtonsDemoState extends State { } Widget buildOutlineButton() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new ButtonBar( + ButtonBar( mainAxisSize: MainAxisSize.min, children: [ - new OutlineButton( + OutlineButton( child: const Text('OUTLINE BUTTON'), onPressed: () { // Perform some action @@ -232,17 +232,17 @@ class _ButtonsDemoState extends State { ), ], ), - new ButtonBar( + ButtonBar( mainAxisSize: MainAxisSize.min, children: [ - new OutlineButton.icon( + OutlineButton.icon( icon: const Icon(Icons.add, size: 18.0), label: const Text('OUTLINE BUTTON'), onPressed: () { // Perform some action }, ), - new OutlineButton.icon( + OutlineButton.icon( icon: const Icon(Icons.add, size: 18.0), label: const Text('DISABLED'), onPressed: null, @@ -260,14 +260,14 @@ class _ButtonsDemoState extends State { String dropdown3Value = 'Four'; Widget buildDropdownButton() { - return new Padding( + return Padding( padding: const EdgeInsets.all(24.0), - child: new Column( + child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - new ListTile( + ListTile( title: const Text('Simple dropdown:'), - trailing: new DropdownButton( + trailing: DropdownButton( value: dropdown1Value, onChanged: (String newValue) { setState(() { @@ -275,9 +275,9 @@ class _ButtonsDemoState extends State { }); }, items: ['One', 'Two', 'Free', 'Four'].map((String value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Text(value), + child: Text(value), ); }).toList(), ), @@ -285,9 +285,9 @@ class _ButtonsDemoState extends State { const SizedBox( height: 24.0, ), - new ListTile( + ListTile( title: const Text('Dropdown with a hint:'), - trailing: new DropdownButton( + trailing: DropdownButton( value: dropdown2Value, hint: const Text('Choose'), onChanged: (String newValue) { @@ -296,9 +296,9 @@ class _ButtonsDemoState extends State { }); }, items: ['One', 'Two', 'Free', 'Four'].map((String value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Text(value), + child: Text(value), ); }).toList(), ), @@ -306,9 +306,9 @@ class _ButtonsDemoState extends State { const SizedBox( height: 24.0, ), - new ListTile( + ListTile( title: const Text('Scrollable dropdown:'), - trailing: new DropdownButton( + trailing: DropdownButton( value: dropdown3Value, onChanged: (String newValue) { setState(() { @@ -320,9 +320,9 @@ class _ButtonsDemoState extends State { 'Bit', 'More', 'Five', 'Six', 'Seven', 'Eight', 'Nine', 'Ten' ] .map((String value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Text(value), + child: Text(value), ); }) .toList(), @@ -336,12 +336,12 @@ class _ButtonsDemoState extends State { bool iconButtonToggle = false; Widget buildIconButton() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, children: [ - new IconButton( + IconButton( icon: const Icon( Icons.thumb_up, semanticLabel: 'Thumbs up', @@ -359,16 +359,16 @@ class _ButtonsDemoState extends State { onPressed: null, ) ] - .map((Widget button) => new SizedBox(width: 64.0, height: 64.0, child: button)) + .map((Widget button) => SizedBox(width: 64.0, height: 64.0, child: button)) .toList(), ), ); } Widget buildActionButton() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new FloatingActionButton( + child: FloatingActionButton( child: const Icon(Icons.add), onPressed: () { // Perform some action diff --git a/examples/flutter_gallery/lib/demo/material/cards_demo.dart b/examples/flutter_gallery/lib/demo/material/cards_demo.dart index f7e17e4253..1d60ea4113 100644 --- a/examples/flutter_gallery/lib/demo/material/cards_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/cards_demo.dart @@ -61,37 +61,37 @@ class TravelDestinationItem extends StatelessWidget { final TextStyle titleStyle = theme.textTheme.headline.copyWith(color: Colors.white); final TextStyle descriptionStyle = theme.textTheme.subhead; - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Container( + child: Container( padding: const EdgeInsets.all(8.0), height: height, - child: new Card( + child: Card( shape: shape, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // photo and title - new SizedBox( + SizedBox( height: 184.0, - child: new Stack( + child: Stack( children: [ - new Positioned.fill( - child: new Image.asset( + Positioned.fill( + child: Image.asset( destination.assetName, package: destination.assetPackage, fit: BoxFit.cover, ), ), - new Positioned( + Positioned( bottom: 16.0, left: 16.0, right: 16.0, - child: new FittedBox( + child: FittedBox( fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, - child: new Text(destination.title, + child: Text(destination.title, style: titleStyle, ), ), @@ -100,42 +100,42 @@ class TravelDestinationItem extends StatelessWidget { ), ), // description and share/explore buttons - new Expanded( - child: new Padding( + Expanded( + child: Padding( padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 0.0), - child: new DefaultTextStyle( + child: DefaultTextStyle( softWrap: false, overflow: TextOverflow.ellipsis, style: descriptionStyle, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ // three line description - new Padding( + Padding( padding: const EdgeInsets.only(bottom: 8.0), - child: new Text( + child: Text( destination.description[0], style: descriptionStyle.copyWith(color: Colors.black54), ), ), - new Text(destination.description[1]), - new Text(destination.description[2]), + Text(destination.description[1]), + Text(destination.description[2]), ], ), ), ), ), // share, explore buttons - new ButtonTheme.bar( - child: new ButtonBar( + ButtonTheme.bar( + child: ButtonBar( alignment: MainAxisAlignment.start, children: [ - new FlatButton( + FlatButton( child: const Text('SHARE'), textColor: Colors.amber.shade500, onPressed: () { /* do nothing */ }, ), - new FlatButton( + FlatButton( child: const Text('EXPLORE'), textColor: Colors.amber.shade500, onPressed: () { /* do nothing */ }, @@ -156,7 +156,7 @@ class CardsDemo extends StatefulWidget { static const String routeName = '/material/cards'; @override - _CardsDemoState createState() => new _CardsDemoState(); + _CardsDemoState createState() => _CardsDemoState(); } class _CardsDemoState extends State { @@ -164,11 +164,11 @@ class _CardsDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Travel stream'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sentiment_very_satisfied), onPressed: () { setState(() { @@ -185,13 +185,13 @@ class _CardsDemoState extends State { ), ], ), - body: new ListView( + body: ListView( itemExtent: TravelDestinationItem.height, padding: const EdgeInsets.only(top: 8.0, left: 8.0, right: 8.0), children: destinations.map((TravelDestination destination) { - return new Container( + return Container( margin: const EdgeInsets.only(bottom: 8.0), - child: new TravelDestinationItem( + child: TravelDestinationItem( destination: destination, shape: _shape, ), diff --git a/examples/flutter_gallery/lib/demo/material/chip_demo.dart b/examples/flutter_gallery/lib/demo/material/chip_demo.dart index 55d5fb3465..77a259ebc3 100644 --- a/examples/flutter_gallery/lib/demo/material/chip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/chip_demo.dart @@ -53,19 +53,19 @@ const Map _avatars = { }; final Map> _toolActions = >{ - 'hammer': new Set()..addAll(['flake', 'fragment', 'splinter']), - 'chisel': new Set()..addAll(['flake', 'nick', 'splinter']), - 'fryer': new Set()..addAll(['fry']), - 'fabricator': new Set()..addAll(['solder']), - 'customer': new Set()..addAll(['cash in', 'eat']), + 'hammer': Set()..addAll(['flake', 'fragment', 'splinter']), + 'chisel': Set()..addAll(['flake', 'nick', 'splinter']), + 'fryer': Set()..addAll(['fry']), + 'fabricator': Set()..addAll(['solder']), + 'customer': Set()..addAll(['cash in', 'eat']), }; final Map> _materialActions = >{ - 'poker': new Set()..addAll(['cash in']), - 'tortilla': new Set()..addAll(['fry', 'eat']), - 'fish and': new Set()..addAll(['fry', 'eat']), - 'micro': new Set()..addAll(['solder', 'fragment']), - 'wood': new Set()..addAll(['flake', 'cut', 'splinter', 'nick']), + 'poker': Set()..addAll(['cash in']), + 'tortilla': Set()..addAll(['fry', 'eat']), + 'fish and': Set()..addAll(['fry', 'eat']), + 'micro': Set()..addAll(['solder', 'fragment']), + 'wood': Set()..addAll(['flake', 'cut', 'splinter', 'nick']), }; class _ChipsTile extends StatelessWidget { @@ -82,16 +82,16 @@ class _ChipsTile extends StatelessWidget { @override Widget build(BuildContext context) { final List cardChildren = [ - new Container( + Container( padding: const EdgeInsets.only(top: 16.0, bottom: 4.0), alignment: Alignment.center, - child: new Text(label, textAlign: TextAlign.start), + child: Text(label, textAlign: TextAlign.start), ), ]; if (children.isNotEmpty) { - cardChildren.add(new Wrap( + cardChildren.add(Wrap( children: children.map((Widget chip) { - return new Padding( + return Padding( padding: const EdgeInsets.all(2.0), child: chip, ); @@ -99,20 +99,20 @@ class _ChipsTile extends StatelessWidget { } else { final TextStyle textStyle = Theme.of(context).textTheme.caption.copyWith(fontStyle: FontStyle.italic); cardChildren.add( - new Semantics( + Semantics( container: true, - child: new Container( + child: Container( alignment: Alignment.center, constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0), padding: const EdgeInsets.all(8.0), - child: new Text('None', style: textStyle), + child: Text('None', style: textStyle), ), )); } - return new Card( + return Card( semanticContainer: false, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: cardChildren, ) @@ -124,7 +124,7 @@ class ChipDemo extends StatefulWidget { static const String routeName = '/material/chip'; @override - _ChipDemoState createState() => new _ChipDemoState(); + _ChipDemoState createState() => _ChipDemoState(); } class _ChipDemoState extends State { @@ -132,12 +132,12 @@ class _ChipDemoState extends State { _reset(); } - final Set _materials = new Set(); + final Set _materials = Set(); String _selectedMaterial = ''; String _selectedAction = ''; - final Set _tools = new Set(); - final Set _selectedTools = new Set(); - final Set _actions = new Set(); + final Set _tools = Set(); + final Set _selectedTools = Set(); + final Set _actions = Set(); bool _showShapeBorder = false; // Initialize members with the default data. @@ -180,12 +180,12 @@ class _ChipDemoState extends State { assert(name.length > 1); final int hash = name.hashCode & 0xffff; final double hue = (360.0 * hash / (1 << 15)) % 360.0; - return new HSVColor.fromAHSV(1.0, hue, 0.4, 0.90).toColor(); + return HSVColor.fromAHSV(1.0, hue, 0.4, 0.90).toColor(); } AssetImage _nameToAvatar(String name) { assert(_avatars.containsKey(name)); - return new AssetImage( + return AssetImage( _avatars[name], package: 'flutter_gallery_assets', ); @@ -201,10 +201,10 @@ class _ChipDemoState extends State { @override Widget build(BuildContext context) { final List chips = _materials.map((String name) { - return new Chip( - key: new ValueKey(name), + return Chip( + key: ValueKey(name), backgroundColor: _nameToColor(name), - label: new Text(_capitalize(name)), + label: Text(_capitalize(name)), onDeleted: () { setState(() { _removeMaterial(name); @@ -214,12 +214,12 @@ class _ChipDemoState extends State { }).toList(); final List inputChips = _tools.map((String name) { - return new InputChip( - key: new ValueKey(name), - avatar: new CircleAvatar( + return InputChip( + key: ValueKey(name), + avatar: CircleAvatar( backgroundImage: _nameToAvatar(name), ), - label: new Text(_capitalize(name)), + label: Text(_capitalize(name)), onDeleted: () { setState(() { _removeTool(name); @@ -228,10 +228,10 @@ class _ChipDemoState extends State { }).toList(); final List choiceChips = _materials.map((String name) { - return new ChoiceChip( - key: new ValueKey(name), + return ChoiceChip( + key: ValueKey(name), backgroundColor: _nameToColor(name), - label: new Text(_capitalize(name)), + label: Text(_capitalize(name)), selected: _selectedMaterial == name, onSelected: (bool value) { setState(() { @@ -242,9 +242,9 @@ class _ChipDemoState extends State { }).toList(); final List filterChips = _defaultTools.map((String name) { - return new FilterChip( - key: new ValueKey(name), - label: new Text(_capitalize(name)), + return FilterChip( + key: ValueKey(name), + label: Text(_capitalize(name)), selected: _tools.contains(name) ? _selectedTools.contains(name) : false, onSelected: !_tools.contains(name) ? null @@ -260,7 +260,7 @@ class _ChipDemoState extends State { ); }).toList(); - Set allowedActions = new Set(); + Set allowedActions = Set(); if (_selectedMaterial != null && _selectedMaterial.isNotEmpty) { for (String tool in _selectedTools) { allowedActions.addAll(_toolActions[tool]); @@ -269,8 +269,8 @@ class _ChipDemoState extends State { } final List actionChips = allowedActions.map((String name) { - return new ActionChip( - label: new Text(_capitalize(name)), + return ActionChip( + label: Text(_capitalize(name)), onPressed: () { setState(() { _selectedAction = name; @@ -282,16 +282,16 @@ class _ChipDemoState extends State { final ThemeData theme = Theme.of(context); final List tiles = [ const SizedBox(height: 8.0, width: 0.0), - new _ChipsTile(label: 'Available Materials (Chip)', children: chips), - new _ChipsTile(label: 'Available Tools (InputChip)', children: inputChips), - new _ChipsTile(label: 'Choose a Material (ChoiceChip)', children: choiceChips), - new _ChipsTile(label: 'Choose Tools (FilterChip)', children: filterChips), - new _ChipsTile(label: 'Perform Allowed Action (ActionChip)', children: actionChips), + _ChipsTile(label: 'Available Materials (Chip)', children: chips), + _ChipsTile(label: 'Available Tools (InputChip)', children: inputChips), + _ChipsTile(label: 'Choose a Material (ChoiceChip)', children: choiceChips), + _ChipsTile(label: 'Choose Tools (FilterChip)', children: filterChips), + _ChipsTile(label: 'Perform Allowed Action (ActionChip)', children: actionChips), const Divider(), - new Padding( + Padding( padding: const EdgeInsets.all(8.0), - child: new Center( - child: new Text( + child: Center( + child: Text( _createResult(), style: theme.textTheme.title, ), @@ -299,11 +299,11 @@ class _ChipDemoState extends State { ), ]; - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Chips'), actions: [ - new IconButton( + IconButton( onPressed: () { setState(() { _showShapeBorder = !_showShapeBorder; @@ -313,17 +313,17 @@ class _ChipDemoState extends State { ) ], ), - body: new ChipTheme( + body: ChipTheme( data: _showShapeBorder ? theme.chipTheme.copyWith( - shape: new BeveledRectangleBorder( + shape: BeveledRectangleBorder( side: const BorderSide(width: 0.66, style: BorderStyle.solid, color: Colors.grey), - borderRadius: new BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10.0), )) : theme.chipTheme, - child: new ListView(children: tiles), + child: ListView(children: tiles), ), - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( onPressed: () => setState(_reset), child: const Icon(Icons.refresh, semanticLabel: 'Reset chips'), ), diff --git a/examples/flutter_gallery/lib/demo/material/data_table_demo.dart b/examples/flutter_gallery/lib/demo/material/data_table_demo.dart index 7bfd0f7527..d14cd2564f 100644 --- a/examples/flutter_gallery/lib/demo/material/data_table_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/data_table_demo.dart @@ -21,60 +21,60 @@ class Dessert { class DessertDataSource extends DataTableSource { final List _desserts = [ - new Dessert('Frozen yogurt', 159, 6.0, 24, 4.0, 87, 14, 1), - new Dessert('Ice cream sandwich', 237, 9.0, 37, 4.3, 129, 8, 1), - new Dessert('Eclair', 262, 16.0, 24, 6.0, 337, 6, 7), - new Dessert('Cupcake', 305, 3.7, 67, 4.3, 413, 3, 8), - new Dessert('Gingerbread', 356, 16.0, 49, 3.9, 327, 7, 16), - new Dessert('Jelly bean', 375, 0.0, 94, 0.0, 50, 0, 0), - new Dessert('Lollipop', 392, 0.2, 98, 0.0, 38, 0, 2), - new Dessert('Honeycomb', 408, 3.2, 87, 6.5, 562, 0, 45), - new Dessert('Donut', 452, 25.0, 51, 4.9, 326, 2, 22), - new Dessert('KitKat', 518, 26.0, 65, 7.0, 54, 12, 6), + Dessert('Frozen yogurt', 159, 6.0, 24, 4.0, 87, 14, 1), + Dessert('Ice cream sandwich', 237, 9.0, 37, 4.3, 129, 8, 1), + Dessert('Eclair', 262, 16.0, 24, 6.0, 337, 6, 7), + Dessert('Cupcake', 305, 3.7, 67, 4.3, 413, 3, 8), + Dessert('Gingerbread', 356, 16.0, 49, 3.9, 327, 7, 16), + Dessert('Jelly bean', 375, 0.0, 94, 0.0, 50, 0, 0), + Dessert('Lollipop', 392, 0.2, 98, 0.0, 38, 0, 2), + Dessert('Honeycomb', 408, 3.2, 87, 6.5, 562, 0, 45), + Dessert('Donut', 452, 25.0, 51, 4.9, 326, 2, 22), + Dessert('KitKat', 518, 26.0, 65, 7.0, 54, 12, 6), - new Dessert('Frozen yogurt with sugar', 168, 6.0, 26, 4.0, 87, 14, 1), - new Dessert('Ice cream sandwich with sugar', 246, 9.0, 39, 4.3, 129, 8, 1), - new Dessert('Eclair with sugar', 271, 16.0, 26, 6.0, 337, 6, 7), - new Dessert('Cupcake with sugar', 314, 3.7, 69, 4.3, 413, 3, 8), - new Dessert('Gingerbread with sugar', 345, 16.0, 51, 3.9, 327, 7, 16), - new Dessert('Jelly bean with sugar', 364, 0.0, 96, 0.0, 50, 0, 0), - new Dessert('Lollipop with sugar', 401, 0.2, 100, 0.0, 38, 0, 2), - new Dessert('Honeycomb with sugar', 417, 3.2, 89, 6.5, 562, 0, 45), - new Dessert('Donut with sugar', 461, 25.0, 53, 4.9, 326, 2, 22), - new Dessert('KitKat with sugar', 527, 26.0, 67, 7.0, 54, 12, 6), + Dessert('Frozen yogurt with sugar', 168, 6.0, 26, 4.0, 87, 14, 1), + Dessert('Ice cream sandwich with sugar', 246, 9.0, 39, 4.3, 129, 8, 1), + Dessert('Eclair with sugar', 271, 16.0, 26, 6.0, 337, 6, 7), + Dessert('Cupcake with sugar', 314, 3.7, 69, 4.3, 413, 3, 8), + Dessert('Gingerbread with sugar', 345, 16.0, 51, 3.9, 327, 7, 16), + Dessert('Jelly bean with sugar', 364, 0.0, 96, 0.0, 50, 0, 0), + Dessert('Lollipop with sugar', 401, 0.2, 100, 0.0, 38, 0, 2), + Dessert('Honeycomb with sugar', 417, 3.2, 89, 6.5, 562, 0, 45), + Dessert('Donut with sugar', 461, 25.0, 53, 4.9, 326, 2, 22), + Dessert('KitKat with sugar', 527, 26.0, 67, 7.0, 54, 12, 6), - new Dessert('Frozen yogurt with honey', 223, 6.0, 36, 4.0, 87, 14, 1), - new Dessert('Ice cream sandwich with honey', 301, 9.0, 49, 4.3, 129, 8, 1), - new Dessert('Eclair with honey', 326, 16.0, 36, 6.0, 337, 6, 7), - new Dessert('Cupcake with honey', 369, 3.7, 79, 4.3, 413, 3, 8), - new Dessert('Gingerbread with honey', 420, 16.0, 61, 3.9, 327, 7, 16), - new Dessert('Jelly bean with honey', 439, 0.0, 106, 0.0, 50, 0, 0), - new Dessert('Lollipop with honey', 456, 0.2, 110, 0.0, 38, 0, 2), - new Dessert('Honeycomb with honey', 472, 3.2, 99, 6.5, 562, 0, 45), - new Dessert('Donut with honey', 516, 25.0, 63, 4.9, 326, 2, 22), - new Dessert('KitKat with honey', 582, 26.0, 77, 7.0, 54, 12, 6), + Dessert('Frozen yogurt with honey', 223, 6.0, 36, 4.0, 87, 14, 1), + Dessert('Ice cream sandwich with honey', 301, 9.0, 49, 4.3, 129, 8, 1), + Dessert('Eclair with honey', 326, 16.0, 36, 6.0, 337, 6, 7), + Dessert('Cupcake with honey', 369, 3.7, 79, 4.3, 413, 3, 8), + Dessert('Gingerbread with honey', 420, 16.0, 61, 3.9, 327, 7, 16), + Dessert('Jelly bean with honey', 439, 0.0, 106, 0.0, 50, 0, 0), + Dessert('Lollipop with honey', 456, 0.2, 110, 0.0, 38, 0, 2), + Dessert('Honeycomb with honey', 472, 3.2, 99, 6.5, 562, 0, 45), + Dessert('Donut with honey', 516, 25.0, 63, 4.9, 326, 2, 22), + Dessert('KitKat with honey', 582, 26.0, 77, 7.0, 54, 12, 6), - new Dessert('Frozen yogurt with milk', 262, 8.4, 36, 12.0, 194, 44, 1), - new Dessert('Ice cream sandwich with milk', 339, 11.4, 49, 12.3, 236, 38, 1), - new Dessert('Eclair with milk', 365, 18.4, 36, 14.0, 444, 36, 7), - new Dessert('Cupcake with milk', 408, 6.1, 79, 12.3, 520, 33, 8), - new Dessert('Gingerbread with milk', 459, 18.4, 61, 11.9, 434, 37, 16), - new Dessert('Jelly bean with milk', 478, 2.4, 106, 8.0, 157, 30, 0), - new Dessert('Lollipop with milk', 495, 2.6, 110, 8.0, 145, 30, 2), - new Dessert('Honeycomb with milk', 511, 5.6, 99, 14.5, 669, 30, 45), - new Dessert('Donut with milk', 555, 27.4, 63, 12.9, 433, 32, 22), - new Dessert('KitKat with milk', 621, 28.4, 77, 15.0, 161, 42, 6), + Dessert('Frozen yogurt with milk', 262, 8.4, 36, 12.0, 194, 44, 1), + Dessert('Ice cream sandwich with milk', 339, 11.4, 49, 12.3, 236, 38, 1), + Dessert('Eclair with milk', 365, 18.4, 36, 14.0, 444, 36, 7), + Dessert('Cupcake with milk', 408, 6.1, 79, 12.3, 520, 33, 8), + Dessert('Gingerbread with milk', 459, 18.4, 61, 11.9, 434, 37, 16), + Dessert('Jelly bean with milk', 478, 2.4, 106, 8.0, 157, 30, 0), + Dessert('Lollipop with milk', 495, 2.6, 110, 8.0, 145, 30, 2), + Dessert('Honeycomb with milk', 511, 5.6, 99, 14.5, 669, 30, 45), + Dessert('Donut with milk', 555, 27.4, 63, 12.9, 433, 32, 22), + Dessert('KitKat with milk', 621, 28.4, 77, 15.0, 161, 42, 6), - new Dessert('Coconut slice and frozen yogurt', 318, 21.0, 31, 5.5, 96, 14, 7), - new Dessert('Coconut slice and ice cream sandwich', 396, 24.0, 44, 5.8, 138, 8, 7), - new Dessert('Coconut slice and eclair', 421, 31.0, 31, 7.5, 346, 6, 13), - new Dessert('Coconut slice and cupcake', 464, 18.7, 74, 5.8, 422, 3, 14), - new Dessert('Coconut slice and gingerbread', 515, 31.0, 56, 5.4, 316, 7, 22), - new Dessert('Coconut slice and jelly bean', 534, 15.0, 101, 1.5, 59, 0, 6), - new Dessert('Coconut slice and lollipop', 551, 15.2, 105, 1.5, 47, 0, 8), - new Dessert('Coconut slice and honeycomb', 567, 18.2, 94, 8.0, 571, 0, 51), - new Dessert('Coconut slice and donut', 611, 40.0, 58, 6.4, 335, 2, 28), - new Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12), + Dessert('Coconut slice and frozen yogurt', 318, 21.0, 31, 5.5, 96, 14, 7), + Dessert('Coconut slice and ice cream sandwich', 396, 24.0, 44, 5.8, 138, 8, 7), + Dessert('Coconut slice and eclair', 421, 31.0, 31, 7.5, 346, 6, 13), + Dessert('Coconut slice and cupcake', 464, 18.7, 74, 5.8, 422, 3, 14), + Dessert('Coconut slice and gingerbread', 515, 31.0, 56, 5.4, 316, 7, 22), + Dessert('Coconut slice and jelly bean', 534, 15.0, 101, 1.5, 59, 0, 6), + Dessert('Coconut slice and lollipop', 551, 15.2, 105, 1.5, 47, 0, 8), + Dessert('Coconut slice and honeycomb', 567, 18.2, 94, 8.0, 571, 0, 51), + Dessert('Coconut slice and donut', 611, 40.0, 58, 6.4, 335, 2, 28), + Dessert('Coconut slice and KitKat', 677, 41.0, 72, 8.5, 63, 12, 12), ]; void _sort(Comparable getField(Dessert d), bool ascending) { @@ -99,7 +99,7 @@ class DessertDataSource extends DataTableSource { if (index >= _desserts.length) return null; final Dessert dessert = _desserts[index]; - return new DataRow.byIndex( + return DataRow.byIndex( index: index, selected: dessert.selected, onSelectChanged: (bool value) { @@ -111,14 +111,14 @@ class DessertDataSource extends DataTableSource { } }, cells: [ - new DataCell(new Text('${dessert.name}')), - new DataCell(new Text('${dessert.calories}')), - new DataCell(new Text('${dessert.fat.toStringAsFixed(1)}')), - new DataCell(new Text('${dessert.carbs}')), - new DataCell(new Text('${dessert.protein.toStringAsFixed(1)}')), - new DataCell(new Text('${dessert.sodium}')), - new DataCell(new Text('${dessert.calcium}%')), - new DataCell(new Text('${dessert.iron}%')), + DataCell(Text('${dessert.name}')), + DataCell(Text('${dessert.calories}')), + DataCell(Text('${dessert.fat.toStringAsFixed(1)}')), + DataCell(Text('${dessert.carbs}')), + DataCell(Text('${dessert.protein.toStringAsFixed(1)}')), + DataCell(Text('${dessert.sodium}')), + DataCell(Text('${dessert.calcium}%')), + DataCell(Text('${dessert.iron}%')), ] ); } @@ -144,14 +144,14 @@ class DataTableDemo extends StatefulWidget { static const String routeName = '/material/data-table'; @override - _DataTableDemoState createState() => new _DataTableDemoState(); + _DataTableDemoState createState() => _DataTableDemoState(); } class _DataTableDemoState extends State { int _rowsPerPage = PaginatedDataTable.defaultRowsPerPage; int _sortColumnIndex; bool _sortAscending = true; - final DessertDataSource _dessertsDataSource = new DessertDataSource(); + final DessertDataSource _dessertsDataSource = DessertDataSource(); void _sort(Comparable getField(Dessert d), int columnIndex, bool ascending) { _dessertsDataSource._sort(getField, ascending); @@ -163,12 +163,12 @@ class _DataTableDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Data tables')), - body: new ListView( + return Scaffold( + appBar: AppBar(title: const Text('Data tables')), + body: ListView( padding: const EdgeInsets.all(20.0), children: [ - new PaginatedDataTable( + PaginatedDataTable( header: const Text('Nutrition'), rowsPerPage: _rowsPerPage, onRowsPerPageChanged: (int value) { setState(() { _rowsPerPage = value; }); }, @@ -176,43 +176,43 @@ class _DataTableDemoState extends State { sortAscending: _sortAscending, onSelectAll: _dessertsDataSource._selectAll, columns: [ - new DataColumn( + DataColumn( label: const Text('Dessert (100g serving)'), onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.name, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Calories'), tooltip: 'The total amount of food energy in the given serving size.', numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.calories, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Fat (g)'), numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.fat, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Carbs (g)'), numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.carbs, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Protein (g)'), numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.protein, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Sodium (mg)'), numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.sodium, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Calcium (%)'), tooltip: 'The amount of calcium as a percentage of the recommended daily amount.', numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.calcium, columnIndex, ascending) ), - new DataColumn( + DataColumn( label: const Text('Iron (%)'), numeric: true, onSort: (int columnIndex, bool ascending) => _sort((Dessert d) => d.iron, columnIndex, ascending) diff --git a/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart b/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart index fe531b514b..c09d714218 100644 --- a/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/date_and_time_picker_demo.dart @@ -24,19 +24,19 @@ class _InputDropdown extends StatelessWidget { @override Widget build(BuildContext context) { - return new InkWell( + return InkWell( onTap: onPressed, - child: new InputDecorator( - decoration: new InputDecoration( + child: InputDecorator( + decoration: InputDecoration( labelText: labelText, ), baseStyle: valueStyle, - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, children: [ - new Text(valueText, style: valueStyle), - new Icon(Icons.arrow_drop_down, + Text(valueText, style: valueStyle), + Icon(Icons.arrow_drop_down, color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70 ), ], @@ -66,8 +66,8 @@ class _DateTimePicker extends StatelessWidget { final DateTime picked = await showDatePicker( context: context, initialDate: selectedDate, - firstDate: new DateTime(2015, 8), - lastDate: new DateTime(2101) + firstDate: DateTime(2015, 8), + lastDate: DateTime(2101) ); if (picked != null && picked != selectedDate) selectDate(picked); @@ -85,22 +85,22 @@ class _DateTimePicker extends StatelessWidget { @override Widget build(BuildContext context) { final TextStyle valueStyle = Theme.of(context).textTheme.title; - return new Row( + return Row( crossAxisAlignment: CrossAxisAlignment.end, children: [ - new Expanded( + Expanded( flex: 4, - child: new _InputDropdown( + child: _InputDropdown( labelText: labelText, - valueText: new DateFormat.yMMMd().format(selectedDate), + valueText: DateFormat.yMMMd().format(selectedDate), valueStyle: valueStyle, onPressed: () { _selectDate(context); }, ), ), const SizedBox(width: 12.0), - new Expanded( + Expanded( flex: 3, - child: new _InputDropdown( + child: _InputDropdown( valueText: selectedTime.format(context), valueStyle: valueStyle, onPressed: () { _selectTime(context); }, @@ -115,29 +115,29 @@ class DateAndTimePickerDemo extends StatefulWidget { static const String routeName = '/material/date-and-time-pickers'; @override - _DateAndTimePickerDemoState createState() => new _DateAndTimePickerDemoState(); + _DateAndTimePickerDemoState createState() => _DateAndTimePickerDemoState(); } class _DateAndTimePickerDemoState extends State { - DateTime _fromDate = new DateTime.now(); + DateTime _fromDate = DateTime.now(); TimeOfDay _fromTime = const TimeOfDay(hour: 7, minute: 28); - DateTime _toDate = new DateTime.now(); + DateTime _toDate = DateTime.now(); TimeOfDay _toTime = const TimeOfDay(hour: 7, minute: 28); final List _allActivities = ['hiking', 'swimming', 'boating', 'fishing']; String _activity = 'fishing'; @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Date and time pickers')), - body: new DropdownButtonHideUnderline( - child: new SafeArea( + return Scaffold( + appBar: AppBar(title: const Text('Date and time pickers')), + body: DropdownButtonHideUnderline( + child: SafeArea( top: false, bottom: false, - child: new ListView( + child: ListView( padding: const EdgeInsets.all(16.0), children: [ - new TextField( + TextField( enabled: true, decoration: const InputDecoration( labelText: 'Event name', @@ -145,13 +145,13 @@ class _DateAndTimePickerDemoState extends State { ), style: Theme.of(context).textTheme.display1, ), - new TextField( + TextField( decoration: const InputDecoration( labelText: 'Location', ), style: Theme.of(context).textTheme.display1.copyWith(fontSize: 20.0), ), - new _DateTimePicker( + _DateTimePicker( labelText: 'From', selectedDate: _fromDate, selectedTime: _fromTime, @@ -166,7 +166,7 @@ class _DateAndTimePickerDemoState extends State { }); }, ), - new _DateTimePicker( + _DateTimePicker( labelText: 'To', selectedDate: _toDate, selectedTime: _toTime, @@ -181,13 +181,13 @@ class _DateAndTimePickerDemoState extends State { }); }, ), - new InputDecorator( + InputDecorator( decoration: const InputDecoration( labelText: 'Activity', hintText: 'Choose an activity', ), isEmpty: _activity == null, - child: new DropdownButton( + child: DropdownButton( value: _activity, isDense: true, onChanged: (String newValue) { @@ -196,9 +196,9 @@ class _DateAndTimePickerDemoState extends State { }); }, items: _allActivities.map((String value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Text(value), + child: Text(value), ); }).toList(), ), diff --git a/examples/flutter_gallery/lib/demo/material/dialog_demo.dart b/examples/flutter_gallery/lib/demo/material/dialog_demo.dart index aa061c4219..09c7a02ec3 100644 --- a/examples/flutter_gallery/lib/demo/material/dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/dialog_demo.dart @@ -29,16 +29,16 @@ class DialogDemoItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new SimpleDialogOption( + return SimpleDialogOption( onPressed: onPressed, - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.start, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Icon(icon, size: 36.0, color: color), - new Padding( + Icon(icon, size: 36.0, color: color), + Padding( padding: const EdgeInsets.only(left: 16.0), - child: new Text(text), + child: Text(text), ), ], ), @@ -50,19 +50,19 @@ class DialogDemo extends StatefulWidget { static const String routeName = '/material/dialog'; @override - DialogDemoState createState() => new DialogDemoState(); + DialogDemoState createState() => DialogDemoState(); } class DialogDemoState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); TimeOfDay _selectedTime; @override void initState() { super.initState(); - final DateTime now = new DateTime.now(); - _selectedTime = new TimeOfDay(hour: now.hour, minute: now.minute); + final DateTime now = DateTime.now(); + _selectedTime = TimeOfDay(hour: now.hour, minute: now.minute); } void showDemoDialog({ BuildContext context, Widget child }) { @@ -72,8 +72,8 @@ class DialogDemoState extends State { ) .then((T value) { // The value passed to Navigator.pop() or null. if (value != null) { - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text('You selected: $value') + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text('You selected: $value') )); } }); @@ -84,30 +84,30 @@ class DialogDemoState extends State { final ThemeData theme = Theme.of(context); final TextStyle dialogTextStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color); - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Dialogs') ), - body: new ListView( + body: ListView( padding: const EdgeInsets.symmetric(vertical: 24.0, horizontal: 72.0), children: [ - new RaisedButton( + RaisedButton( child: const Text('ALERT'), onPressed: () { showDemoDialog( context: context, - child: new AlertDialog( - content: new Text( + child: AlertDialog( + content: Text( _alertWithoutTitleText, style: dialogTextStyle ), actions: [ - new FlatButton( + FlatButton( child: const Text('CANCEL'), onPressed: () { Navigator.pop(context, DialogDemoAction.cancel); } ), - new FlatButton( + FlatButton( child: const Text('DISCARD'), onPressed: () { Navigator.pop(context, DialogDemoAction.discard); } ) @@ -116,23 +116,23 @@ class DialogDemoState extends State { ); } ), - new RaisedButton( + RaisedButton( child: const Text('ALERT WITH TITLE'), onPressed: () { showDemoDialog( context: context, - child: new AlertDialog( + child: AlertDialog( title: const Text('Use Google\'s location service?'), - content: new Text( + content: Text( _alertWithTitleText, style: dialogTextStyle ), actions: [ - new FlatButton( + FlatButton( child: const Text('DISAGREE'), onPressed: () { Navigator.pop(context, DialogDemoAction.disagree); } ), - new FlatButton( + FlatButton( child: const Text('AGREE'), onPressed: () { Navigator.pop(context, DialogDemoAction.agree); } ) @@ -141,27 +141,27 @@ class DialogDemoState extends State { ); } ), - new RaisedButton( + RaisedButton( child: const Text('SIMPLE'), onPressed: () { showDemoDialog( context: context, - child: new SimpleDialog( + child: SimpleDialog( title: const Text('Set backup account'), children: [ - new DialogDemoItem( + DialogDemoItem( icon: Icons.account_circle, color: theme.primaryColor, text: 'username@gmail.com', onPressed: () { Navigator.pop(context, 'username@gmail.com'); } ), - new DialogDemoItem( + DialogDemoItem( icon: Icons.account_circle, color: theme.primaryColor, text: 'user02@gmail.com', onPressed: () { Navigator.pop(context, 'user02@gmail.com'); } ), - new DialogDemoItem( + DialogDemoItem( icon: Icons.add_circle, text: 'add account', color: theme.disabledColor @@ -171,7 +171,7 @@ class DialogDemoState extends State { ); } ), - new RaisedButton( + RaisedButton( child: const Text('CONFIRMATION'), onPressed: () { showTimePicker( @@ -181,18 +181,18 @@ class DialogDemoState extends State { .then((TimeOfDay value) { if (value != null && value != _selectedTime) { _selectedTime = value; - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text('You selected: ${value.format(context)}') + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text('You selected: ${value.format(context)}') )); } }); } ), - new RaisedButton( + RaisedButton( child: const Text('FULLSCREEN'), onPressed: () { - Navigator.push(context, new MaterialPageRoute( - builder: (BuildContext context) => new FullScreenDialogDemo(), + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) => FullScreenDialogDemo(), fullscreenDialog: true, )); } @@ -200,7 +200,7 @@ class DialogDemoState extends State { ] // Add a little space between the buttons .map((Widget button) { - return new Container( + return Container( padding: const EdgeInsets.symmetric(vertical: 8.0), child: button ); diff --git a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart index dfceb2540a..19bd0c545c 100644 --- a/examples/flutter_gallery/lib/demo/material/drawer_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/drawer_demo.dart @@ -13,11 +13,11 @@ class DrawerDemo extends StatefulWidget { static const String routeName = '/material/drawer'; @override - _DrawerDemoState createState() => new _DrawerDemoState(); + _DrawerDemoState createState() => _DrawerDemoState(); } class _DrawerDemoState extends State with TickerProviderStateMixin { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); static const List _drawerContents = [ 'A', 'B', 'C', 'D', 'E', @@ -31,18 +31,18 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( vsync: this, duration: const Duration(milliseconds: 200), ); - _drawerContentsOpacity = new CurvedAnimation( - parent: new ReverseAnimation(_controller), + _drawerContentsOpacity = CurvedAnimation( + parent: ReverseAnimation(_controller), curve: Curves.fastOutSlowIn, ); - _drawerDetailsPosition = new Tween( + _drawerDetailsPosition = Tween( begin: const Offset(0.0, -1.0), end: Offset.zero, - ).animate(new CurvedAnimation( + ).animate(CurvedAnimation( parent: _controller, curve: Curves.fastOutSlowIn, )); @@ -75,11 +75,11 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( - leading: new IconButton( - icon: new Icon(_backIcon()), + appBar: AppBar( + leading: IconButton( + icon: Icon(_backIcon()), alignment: Alignment.centerLeft, tooltip: 'Back', onPressed: () { @@ -88,10 +88,10 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { ), title: const Text('Navigation drawer'), ), - drawer: new Drawer( - child: new Column( + drawer: Drawer( + child: Column( children: [ - new UserAccountsDrawerHeader( + UserAccountsDrawerHeader( accountName: const Text('Trevor Widget'), accountEmail: const Text('trevor.widget@example.com'), currentAccountPicture: const CircleAvatar( @@ -101,11 +101,11 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { ), ), otherAccountsPictures: [ - new GestureDetector( + GestureDetector( onTap: () { _onOtherAccountsTap(context); }, - child: new Semantics( + child: Semantics( label: 'Switch to Account B', child: const CircleAvatar( backgroundImage: AssetImage( @@ -115,11 +115,11 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { ), ), ), - new GestureDetector( + GestureDetector( onTap: () { _onOtherAccountsTap(context); }, - child: new Semantics( + child: Semantics( label: 'Switch to Account C', child: const CircleAvatar( backgroundImage: AssetImage( @@ -139,46 +139,46 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { _controller.forward(); }, ), - new MediaQuery.removePadding( + MediaQuery.removePadding( context: context, // DrawerHeader consumes top MediaQuery padding. removeTop: true, - child: new Expanded( - child: new ListView( + child: Expanded( + child: ListView( padding: const EdgeInsets.only(top: 8.0), children: [ - new Stack( + Stack( children: [ // The initial contents of the drawer. - new FadeTransition( + FadeTransition( opacity: _drawerContentsOpacity, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: _drawerContents.map((String id) { - return new ListTile( - leading: new CircleAvatar(child: new Text(id)), - title: new Text('Drawer item $id'), + return ListTile( + leading: CircleAvatar(child: Text(id)), + title: Text('Drawer item $id'), onTap: _showNotImplementedMessage, ); }).toList(), ), ), // The drawer's "details" view. - new SlideTransition( + SlideTransition( position: _drawerDetailsPosition, - child: new FadeTransition( - opacity: new ReverseAnimation(_drawerContentsOpacity), - child: new Column( + child: FadeTransition( + opacity: ReverseAnimation(_drawerContentsOpacity), + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new ListTile( + ListTile( leading: const Icon(Icons.add), title: const Text('Add account'), onTap: _showNotImplementedMessage, ), - new ListTile( + ListTile( leading: const Icon(Icons.settings), title: const Text('Manage accounts'), onTap: _showNotImplementedMessage, @@ -196,19 +196,19 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { ], ), ), - body: new Center( - child: new InkWell( + body: Center( + child: InkWell( onTap: () { _scaffoldKey.currentState.openDrawer(); }, - child: new Semantics( + child: Semantics( button: true, label: 'Open drawer', excludeSemantics: true, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new Container( + Container( width: 100.0, height: 100.0, decoration: const BoxDecoration( @@ -221,9 +221,9 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { ), ), ), - new Padding( + Padding( padding: const EdgeInsets.only(top: 8.0), - child: new Text('Tap here to open the drawer', + child: Text('Tap here to open the drawer', style: Theme.of(context).textTheme.subhead, ), ), @@ -239,10 +239,10 @@ class _DrawerDemoState extends State with TickerProviderStateMixin { showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( + return AlertDialog( title: const Text('Account switching not implemented.'), actions: [ - new FlatButton( + FlatButton( child: const Text('OK'), onPressed: () { Navigator.pop(context); diff --git a/examples/flutter_gallery/lib/demo/material/elevation_demo.dart b/examples/flutter_gallery/lib/demo/material/elevation_demo.dart index 8f63dd60ee..986fc72d88 100644 --- a/examples/flutter_gallery/lib/demo/material/elevation_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/elevation_demo.dart @@ -24,15 +24,15 @@ class _ElevationDemoState extends State { ]; return elevations.map((double elevation) { - return new Center( - child: new Card( + return Center( + child: Card( margin: const EdgeInsets.all(20.0), elevation: _showElevation ? elevation : 0.0, - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Center( - child: new Text('${elevation.toStringAsFixed(0)} pt'), + child: Center( + child: Text('${elevation.toStringAsFixed(0)} pt'), ), ), ), @@ -42,11 +42,11 @@ class _ElevationDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Elevation'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sentiment_very_satisfied), onPressed: () { setState(() => _showElevation = !_showElevation); @@ -54,7 +54,7 @@ class _ElevationDemoState extends State { ) ], ), - body: new ListView( + body: ListView( children: buildCards(), ), ); diff --git a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart index 0363ffd782..15ec62fc06 100644 --- a/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/expansion_panels_demo.dart @@ -27,7 +27,7 @@ class DualHeaderWithHint extends StatelessWidget { final bool showHint; Widget _crossFade(Widget first, Widget second, bool isExpanded) { - return new AnimatedCrossFade( + return AnimatedCrossFade( firstChild: first, secondChild: second, firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), @@ -43,29 +43,29 @@ class DualHeaderWithHint extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return new Row( + return Row( children: [ - new Expanded( + Expanded( flex: 2, - child: new Container( + child: Container( margin: const EdgeInsets.only(left: 24.0), - child: new FittedBox( + child: FittedBox( fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, - child: new Text( + child: Text( name, style: textTheme.body1.copyWith(fontSize: 15.0), ), ), ), ), - new Expanded( + Expanded( flex: 3, - child: new Container( + child: Container( margin: const EdgeInsets.only(left: 24.0), child: _crossFade( - new Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), - new Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(value, style: textTheme.caption.copyWith(fontSize: 15.0)), + Text(hint, style: textTheme.caption.copyWith(fontSize: 15.0)), showHint ) ) @@ -93,30 +93,30 @@ class CollapsibleBody extends StatelessWidget { final ThemeData theme = Theme.of(context); final TextTheme textTheme = theme.textTheme; - return new Column( + return Column( children: [ - new Container( + Container( margin: const EdgeInsets.only( left: 24.0, right: 24.0, bottom: 24.0 ) - margin, - child: new Center( - child: new DefaultTextStyle( + child: Center( + child: DefaultTextStyle( style: textTheme.caption.copyWith(fontSize: 15.0), child: child ) ) ), const Divider(height: 1.0), - new Container( + Container( padding: const EdgeInsets.symmetric(vertical: 16.0), - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.end, children: [ - new Container( + Container( margin: const EdgeInsets.only(right: 8.0), - child: new FlatButton( + child: FlatButton( onPressed: onCancel, child: const Text('CANCEL', style: TextStyle( color: Colors.black54, @@ -125,9 +125,9 @@ class CollapsibleBody extends StatelessWidget { )) ) ), - new Container( + Container( margin: const EdgeInsets.only(right: 8.0), - child: new FlatButton( + child: FlatButton( onPressed: onSave, textTheme: ButtonTextTheme.accent, child: const Text('SAVE') @@ -148,7 +148,7 @@ class DemoItem { this.hint, this.builder, this.valueToString - }) : textController = new TextEditingController(text: valueToString(value)); + }) : textController = TextEditingController(text: valueToString(value)); final String name; final String hint; @@ -160,7 +160,7 @@ class DemoItem { ExpansionPanelHeaderBuilder get headerBuilder { return (BuildContext context, bool isExpanded) { - return new DualHeaderWithHint( + return DualHeaderWithHint( name: name, value: valueToString(value), hint: hint, @@ -176,7 +176,7 @@ class ExpansionPanelsDemo extends StatefulWidget { static const String routeName = '/material/expansion_panels'; @override - _ExpansionPanelsDemoState createState() => new _ExpansionPanelsDemoState(); + _ExpansionPanelsDemoState createState() => _ExpansionPanelsDemoState(); } class _ExpansionPanelsDemoState extends State { @@ -187,7 +187,7 @@ class _ExpansionPanelsDemoState extends State { super.initState(); _demoItems = >[ - new DemoItem( + DemoItem( name: 'Trip', value: 'Caribbean cruise', hint: 'Change trip name', @@ -199,18 +199,18 @@ class _ExpansionPanelsDemoState extends State { }); } - return new Form( - child: new Builder( + return Form( + child: Builder( builder: (BuildContext context) { - return new CollapsibleBody( + return CollapsibleBody( margin: const EdgeInsets.symmetric(horizontal: 16.0), onSave: () { Form.of(context).save(); close(); }, onCancel: () { Form.of(context).reset(); close(); }, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new TextFormField( + child: TextFormField( controller: item.textController, - decoration: new InputDecoration( + decoration: InputDecoration( hintText: item.hint, labelText: item.name, ), @@ -223,7 +223,7 @@ class _ExpansionPanelsDemoState extends State { ); }, ), - new DemoItem<_Location>( + DemoItem<_Location>( name: 'Location', value: _Location.Bahamas, hint: 'Select location', @@ -234,24 +234,24 @@ class _ExpansionPanelsDemoState extends State { item.isExpanded = false; }); } - return new Form( - child: new Builder( + return Form( + child: Builder( builder: (BuildContext context) { - return new CollapsibleBody( + return CollapsibleBody( onSave: () { Form.of(context).save(); close(); }, onCancel: () { Form.of(context).reset(); close(); }, - child: new FormField<_Location>( + child: FormField<_Location>( initialValue: item.value, onSaved: (_Location result) { item.value = result; }, builder: (FormFieldState<_Location> field) { - return new Column( + return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Row( + Row( mainAxisSize: MainAxisSize.min, children: [ - new Radio<_Location>( + Radio<_Location>( value: _Location.Bahamas, groupValue: field.value, onChanged: field.didChange, @@ -259,10 +259,10 @@ class _ExpansionPanelsDemoState extends State { const Text('Bahamas') ] ), - new Row( + Row( mainAxisSize: MainAxisSize.min, children: [ - new Radio<_Location>( + Radio<_Location>( value: _Location.Barbados, groupValue: field.value, onChanged: field.didChange, @@ -270,10 +270,10 @@ class _ExpansionPanelsDemoState extends State { const Text('Barbados') ] ), - new Row( + Row( mainAxisSize: MainAxisSize.min, children: [ - new Radio<_Location>( + Radio<_Location>( value: _Location.Bermuda, groupValue: field.value, onChanged: field.didChange, @@ -291,7 +291,7 @@ class _ExpansionPanelsDemoState extends State { ); } ), - new DemoItem( + DemoItem( name: 'Sun', value: 80.0, hint: 'Select sun level', @@ -303,17 +303,17 @@ class _ExpansionPanelsDemoState extends State { }); } - return new Form( - child: new Builder( + return Form( + child: Builder( builder: (BuildContext context) { - return new CollapsibleBody( + return CollapsibleBody( onSave: () { Form.of(context).save(); close(); }, onCancel: () { Form.of(context).reset(); close(); }, - child: new FormField( + child: FormField( initialValue: item.value, onSaved: (double value) { item.value = value; }, builder: (FormFieldState field) { - return new Slider( + return Slider( min: 0.0, max: 100.0, divisions: 5, @@ -335,22 +335,22 @@ class _ExpansionPanelsDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Expansion panels')), - body: new SingleChildScrollView( - child: new SafeArea( + return Scaffold( + appBar: AppBar(title: const Text('Expansion panels')), + body: SingleChildScrollView( + child: SafeArea( top: false, bottom: false, - child: new Container( + child: Container( margin: const EdgeInsets.all(24.0), - child: new ExpansionPanelList( + child: ExpansionPanelList( expansionCallback: (int index, bool isExpanded) { setState(() { _demoItems[index].isExpanded = !isExpanded; }); }, children: _demoItems.map((DemoItem item) { - return new ExpansionPanel( + return ExpansionPanel( isExpanded: item.isExpanded, headerBuilder: item.headerBuilder, body: item.build() diff --git a/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart b/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart index 396dfa7dda..99db465b16 100644 --- a/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/full_screen_dialog_demo.dart @@ -19,8 +19,8 @@ enum DismissDialogAction { class DateTimeItem extends StatelessWidget { DateTimeItem({ Key key, DateTime dateTime, @required this.onChanged }) : assert(onChanged != null), - date = new DateTime(dateTime.year, dateTime.month, dateTime.day), - time = new TimeOfDay(hour: dateTime.hour, minute: dateTime.minute), + date = DateTime(dateTime.year, dateTime.month, dateTime.day), + time = TimeOfDay(hour: dateTime.hour, minute: dateTime.minute), super(key: key); final DateTime date; @@ -31,17 +31,17 @@ class DateTimeItem extends StatelessWidget { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new DefaultTextStyle( + return DefaultTextStyle( style: theme.textTheme.subhead, - child: new Row( + child: Row( children: [ - new Expanded( - child: new Container( + Expanded( + child: Container( padding: const EdgeInsets.symmetric(vertical: 8.0), - decoration: new BoxDecoration( - border: new Border(bottom: new BorderSide(color: theme.dividerColor)) + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: theme.dividerColor)) ), - child: new InkWell( + child: InkWell( onTap: () { showDatePicker( context: context, @@ -51,26 +51,26 @@ class DateTimeItem extends StatelessWidget { ) .then((DateTime value) { if (value != null) - onChanged(new DateTime(value.year, value.month, value.day, time.hour, time.minute)); + onChanged(DateTime(value.year, value.month, value.day, time.hour, time.minute)); }); }, - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new Text(new DateFormat('EEE, MMM d yyyy').format(date)), + Text(DateFormat('EEE, MMM d yyyy').format(date)), const Icon(Icons.arrow_drop_down, color: Colors.black54), ] ) ) ) ), - new Container( + Container( margin: const EdgeInsets.only(left: 8.0), padding: const EdgeInsets.symmetric(vertical: 8.0), - decoration: new BoxDecoration( - border: new Border(bottom: new BorderSide(color: theme.dividerColor)) + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: theme.dividerColor)) ), - child: new InkWell( + child: InkWell( onTap: () { showTimePicker( context: context, @@ -78,12 +78,12 @@ class DateTimeItem extends StatelessWidget { ) .then((TimeOfDay value) { if (value != null) - onChanged(new DateTime(date.year, date.month, date.day, value.hour, value.minute)); + onChanged(DateTime(date.year, date.month, date.day, value.hour, value.minute)); }); }, - child: new Row( + child: Row( children: [ - new Text('${time.format(context)}'), + Text('${time.format(context)}'), const Icon(Icons.arrow_drop_down, color: Colors.black54), ] ) @@ -97,12 +97,12 @@ class DateTimeItem extends StatelessWidget { class FullScreenDialogDemo extends StatefulWidget { @override - FullScreenDialogDemoState createState() => new FullScreenDialogDemoState(); + FullScreenDialogDemoState createState() => FullScreenDialogDemoState(); } class FullScreenDialogDemoState extends State { - DateTime _fromDateTime = new DateTime.now(); - DateTime _toDateTime = new DateTime.now(); + DateTime _fromDateTime = DateTime.now(); + DateTime _toDateTime = DateTime.now(); bool _allDayValue = false; bool _saveNeeded = false; bool _hasLocation = false; @@ -120,19 +120,19 @@ class FullScreenDialogDemoState extends State { return await showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( - content: new Text( + return AlertDialog( + content: Text( 'Discard new event?', style: dialogTextStyle ), actions: [ - new FlatButton( + FlatButton( child: const Text('CANCEL'), onPressed: () { Navigator.of(context).pop(false); // Pops the confirmation dialog but not the page. } ), - new FlatButton( + FlatButton( child: const Text('DISCARD'), onPressed: () { Navigator.of(context).pop(true); // Returning true to _onWillPop will pop again. @@ -148,27 +148,27 @@ class FullScreenDialogDemoState extends State { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Scaffold( - appBar: new AppBar( - title: new Text(_hasName ? _eventName : 'Event Name TBD'), + return Scaffold( + appBar: AppBar( + title: Text(_hasName ? _eventName : 'Event Name TBD'), actions: [ - new FlatButton( - child: new Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)), + FlatButton( + child: Text('SAVE', style: theme.textTheme.body1.copyWith(color: Colors.white)), onPressed: () { Navigator.pop(context, DismissDialogAction.save); } ) ] ), - body: new Form( + body: Form( onWillPop: _onWillPop, - child: new ListView( + child: ListView( padding: const EdgeInsets.all(16.0), children: [ - new Container( + Container( padding: const EdgeInsets.symmetric(vertical: 8.0), alignment: Alignment.bottomLeft, - child: new TextField( + child: TextField( decoration: const InputDecoration( labelText: 'Event name', filled: true @@ -184,10 +184,10 @@ class FullScreenDialogDemoState extends State { } ) ), - new Container( + Container( padding: const EdgeInsets.symmetric(vertical: 8.0), alignment: Alignment.bottomLeft, - child: new TextField( + child: TextField( decoration: const InputDecoration( labelText: 'Location', hintText: 'Where is the event?', @@ -200,11 +200,11 @@ class FullScreenDialogDemoState extends State { } ) ), - new Column( + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Text('From', style: theme.textTheme.caption), - new DateTimeItem( + Text('From', style: theme.textTheme.caption), + DateTimeItem( dateTime: _fromDateTime, onChanged: (DateTime value) { setState(() { @@ -215,11 +215,11 @@ class FullScreenDialogDemoState extends State { ) ] ), - new Column( + Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Text('To', style: theme.textTheme.caption), - new DateTimeItem( + Text('To', style: theme.textTheme.caption), + DateTimeItem( dateTime: _toDateTime, onChanged: (DateTime value) { setState(() { @@ -231,13 +231,13 @@ class FullScreenDialogDemoState extends State { const Text('All-day'), ] ), - new Container( - decoration: new BoxDecoration( - border: new Border(bottom: new BorderSide(color: theme.dividerColor)) + Container( + decoration: BoxDecoration( + border: Border(bottom: BorderSide(color: theme.dividerColor)) ), - child: new Row( + child: Row( children: [ - new Checkbox( + Checkbox( value: _allDayValue, onChanged: (bool value) { setState(() { @@ -252,7 +252,7 @@ class FullScreenDialogDemoState extends State { ) ] .map((Widget child) { - return new Container( + return Container( padding: const EdgeInsets.symmetric(vertical: 8.0), height: 96.0, child: child diff --git a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart index 1f6ee00ff2..418e045d39 100644 --- a/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/grid_list_demo.dart @@ -41,7 +41,7 @@ class GridPhotoViewer extends StatefulWidget { final Photo photo; @override - _GridPhotoViewerState createState() => new _GridPhotoViewerState(); + _GridPhotoViewerState createState() => _GridPhotoViewerState(); } class _GridTitleText extends StatelessWidget { @@ -51,10 +51,10 @@ class _GridTitleText extends StatelessWidget { @override Widget build(BuildContext context) { - return new FittedBox( + return FittedBox( fit: BoxFit.scaleDown, alignment: Alignment.centerLeft, - child: new Text(text), + child: Text(text), ); } } @@ -70,7 +70,7 @@ class _GridPhotoViewerState extends State with SingleTickerProv @override void initState() { super.initState(); - _controller = new AnimationController(vsync: this) + _controller = AnimationController(vsync: this) ..addListener(_handleFlingAnimation); } @@ -84,8 +84,8 @@ class _GridPhotoViewerState extends State with SingleTickerProv // then the minimum offset value is w - _scale * w, h - _scale * h. Offset _clampOffset(Offset offset) { final Size size = context.size; - final Offset minOffset = new Offset(size.width, size.height) * (1.0 - _scale); - return new Offset(offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0)); + final Offset minOffset = Offset(size.width, size.height) * (1.0 - _scale); + return Offset(offset.dx.clamp(minOffset.dx, 0.0), offset.dy.clamp(minOffset.dy, 0.0)); } void _handleFlingAnimation() { @@ -117,7 +117,7 @@ class _GridPhotoViewerState extends State with SingleTickerProv return; final Offset direction = details.velocity.pixelsPerSecond / magnitude; final double distance = (Offset.zero & context.size).shortestSide; - _flingAnimation = new Tween( + _flingAnimation = Tween( begin: _offset, end: _clampOffset(_offset + direction * distance) ).animate(_controller); @@ -128,16 +128,16 @@ class _GridPhotoViewerState extends State with SingleTickerProv @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onScaleStart: _handleOnScaleStart, onScaleUpdate: _handleOnScaleUpdate, onScaleEnd: _handleOnScaleEnd, - child: new ClipRect( - child: new Transform( - transform: new Matrix4.identity() + child: ClipRect( + child: Transform( + transform: Matrix4.identity() ..translate(_offset.dx, _offset.dy) ..scale(_scale), - child: new Image.asset( + child: Image.asset( widget.photo.assetName, package: widget.photo.assetPackage, fit: BoxFit.cover, @@ -164,16 +164,16 @@ class GridDemoPhotoItem extends StatelessWidget { final BannerTapCallback onBannerTap; // User taps on the photo's header or footer. void showPhoto(BuildContext context) { - Navigator.push(context, new MaterialPageRoute( + Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { - return new Scaffold( - appBar: new AppBar( - title: new Text(photo.title) + return Scaffold( + appBar: AppBar( + title: Text(photo.title) ), - body: new SizedBox.expand( - child: new Hero( + body: SizedBox.expand( + child: Hero( tag: photo.tag, - child: new GridPhotoViewer(photo: photo), + child: GridPhotoViewer(photo: photo), ), ), ); @@ -183,12 +183,12 @@ class GridDemoPhotoItem extends StatelessWidget { @override Widget build(BuildContext context) { - final Widget image = new GestureDetector( + final Widget image = GestureDetector( onTap: () { showPhoto(context); }, - child: new Hero( - key: new Key(photo.assetName), + child: Hero( + key: Key(photo.assetName), tag: photo.tag, - child: new Image.asset( + child: Image.asset( photo.assetName, package: photo.assetPackage, fit: BoxFit.cover, @@ -203,13 +203,13 @@ class GridDemoPhotoItem extends StatelessWidget { return image; case GridDemoTileStyle.oneLine: - return new GridTile( - header: new GestureDetector( + return GridTile( + header: GestureDetector( onTap: () { onBannerTap(photo); }, - child: new GridTileBar( - title: new _GridTitleText(photo.title), + child: GridTileBar( + title: _GridTitleText(photo.title), backgroundColor: Colors.black45, - leading: new Icon( + leading: Icon( icon, color: Colors.white, ), @@ -219,14 +219,14 @@ class GridDemoPhotoItem extends StatelessWidget { ); case GridDemoTileStyle.twoLine: - return new GridTile( - footer: new GestureDetector( + return GridTile( + footer: GestureDetector( onTap: () { onBannerTap(photo); }, - child: new GridTileBar( + child: GridTileBar( backgroundColor: Colors.black45, - title: new _GridTitleText(photo.title), - subtitle: new _GridTitleText(photo.caption), - trailing: new Icon( + title: _GridTitleText(photo.title), + subtitle: _GridTitleText(photo.caption), + trailing: Icon( icon, color: Colors.white, ), @@ -246,80 +246,80 @@ class GridListDemo extends StatefulWidget { static const String routeName = '/material/grid-list'; @override - GridListDemoState createState() => new GridListDemoState(); + GridListDemoState createState() => GridListDemoState(); } class GridListDemoState extends State { GridDemoTileStyle _tileStyle = GridDemoTileStyle.twoLine; List photos = [ - new Photo( + Photo( assetName: 'places/india_chennai_flower_market.png', assetPackage: _kGalleryAssetsPackage, title: 'Chennai', caption: 'Flower Market', ), - new Photo( + Photo( assetName: 'places/india_tanjore_bronze_works.png', assetPackage: _kGalleryAssetsPackage, title: 'Tanjore', caption: 'Bronze Works', ), - new Photo( + Photo( assetName: 'places/india_tanjore_market_merchant.png', assetPackage: _kGalleryAssetsPackage, title: 'Tanjore', caption: 'Market', ), - new Photo( + Photo( assetName: 'places/india_tanjore_thanjavur_temple.png', assetPackage: _kGalleryAssetsPackage, title: 'Tanjore', caption: 'Thanjavur Temple', ), - new Photo( + Photo( assetName: 'places/india_tanjore_thanjavur_temple_carvings.png', assetPackage: _kGalleryAssetsPackage, title: 'Tanjore', caption: 'Thanjavur Temple', ), - new Photo( + Photo( assetName: 'places/india_pondicherry_salt_farm.png', assetPackage: _kGalleryAssetsPackage, title: 'Pondicherry', caption: 'Salt Farm', ), - new Photo( + Photo( assetName: 'places/india_chennai_highway.png', assetPackage: _kGalleryAssetsPackage, title: 'Chennai', caption: 'Scooters', ), - new Photo( + Photo( assetName: 'places/india_chettinad_silk_maker.png', assetPackage: _kGalleryAssetsPackage, title: 'Chettinad', caption: 'Silk Maker', ), - new Photo( + Photo( assetName: 'places/india_chettinad_produce.png', assetPackage: _kGalleryAssetsPackage, title: 'Chettinad', caption: 'Lunch Prep', ), - new Photo( + Photo( assetName: 'places/india_tanjore_market_technology.png', assetPackage: _kGalleryAssetsPackage, title: 'Tanjore', caption: 'Market', ), - new Photo( + Photo( assetName: 'places/india_pondicherry_beach.png', assetPackage: _kGalleryAssetsPackage, title: 'Pondicherry', caption: 'Beach', ), - new Photo( + Photo( assetName: 'places/india_pondicherry_fisherman.png', assetPackage: _kGalleryAssetsPackage, title: 'Pondicherry', @@ -336,11 +336,11 @@ class GridListDemoState extends State { @override Widget build(BuildContext context) { final Orientation orientation = MediaQuery.of(context).orientation; - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Grid list'), actions: [ - new PopupMenuButton( + PopupMenuButton( onSelected: changeTileStyle, itemBuilder: (BuildContext context) => >[ const PopupMenuItem( @@ -359,20 +359,20 @@ class GridListDemoState extends State { ), ], ), - body: new Column( + body: Column( children: [ - new Expanded( - child: new SafeArea( + Expanded( + child: SafeArea( top: false, bottom: false, - child: new GridView.count( + child: GridView.count( crossAxisCount: (orientation == Orientation.portrait) ? 2 : 3, mainAxisSpacing: 4.0, crossAxisSpacing: 4.0, padding: const EdgeInsets.all(4.0), childAspectRatio: (orientation == Orientation.portrait) ? 1.0 : 1.3, children: photos.map((Photo photo) { - return new GridDemoPhotoItem( + return GridDemoPhotoItem( photo: photo, tileStyle: _tileStyle, onBannerTap: (Photo photo) { diff --git a/examples/flutter_gallery/lib/demo/material/icons_demo.dart b/examples/flutter_gallery/lib/demo/material/icons_demo.dart index d5692f001c..60bd9c597e 100644 --- a/examples/flutter_gallery/lib/demo/material/icons_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/icons_demo.dart @@ -8,7 +8,7 @@ class IconsDemo extends StatefulWidget { static const String routeName = '/material/icons'; @override - IconsDemoState createState() => new IconsDemoState(); + IconsDemoState createState() => IconsDemoState(); } class IconsDemoState extends State { @@ -46,21 +46,21 @@ class IconsDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Icons') ), - body: new IconTheme( - data: new IconThemeData(color: iconColor), - child: new SafeArea( + body: IconTheme( + data: IconThemeData(color: iconColor), + child: SafeArea( top: false, bottom: false, - child: new ListView( + child: ListView( padding: const EdgeInsets.all(24.0), children: [ - new _IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon + _IconsDemoCard(handleIconButtonPress, Icons.face), // direction-agnostic icon const SizedBox(height: 24.0), - new _IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon + _IconsDemoCard(handleIconButtonPress, Icons.battery_unknown), // direction-aware icon ], ), ), @@ -76,8 +76,8 @@ class _IconsDemoCard extends StatelessWidget { final IconData icon; Widget _buildIconButton(double iconSize, IconData icon, bool enabled) { - return new IconButton( - icon: new Icon(icon), + return IconButton( + icon: Icon(icon), iconSize: iconSize, tooltip: "${enabled ? 'Enabled' : 'Disabled'} icon button", onPressed: enabled ? handleIconButtonPress : null @@ -85,14 +85,14 @@ class _IconsDemoCard extends StatelessWidget { } Widget _centeredText(String label) => - new Padding( + Padding( // Match the default padding of IconButton. padding: const EdgeInsets.all(8.0), - child: new Text(label, textAlign: TextAlign.center), + child: Text(label, textAlign: TextAlign.center), ); TableRow _buildIconRow(double size) { - return new TableRow( + return TableRow( children: [ _centeredText(size.floor().toString()), _buildIconButton(size, icon, true), @@ -105,15 +105,15 @@ class _IconsDemoCard extends StatelessWidget { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); final TextStyle textStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color); - return new Card( - child: new DefaultTextStyle( + return Card( + child: DefaultTextStyle( style: textStyle, - child: new Semantics( + child: Semantics( explicitChildNodes: true, - child: new Table( + child: Table( defaultVerticalAlignment: TableCellVerticalAlignment.middle, children: [ - new TableRow( + TableRow( children: [ _centeredText('Size'), _centeredText('Enabled'), diff --git a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart index d55c0c246d..d85b1e02b2 100644 --- a/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/leave_behind_demo.dart @@ -35,17 +35,17 @@ class LeaveBehindDemo extends StatefulWidget { static const String routeName = '/material/leave-behind'; @override - LeaveBehindDemoState createState() => new LeaveBehindDemoState(); + LeaveBehindDemoState createState() => LeaveBehindDemoState(); } class LeaveBehindDemoState extends State { - static final GlobalKey _scaffoldKey = new GlobalKey(); + static final GlobalKey _scaffoldKey = GlobalKey(); DismissDirection _dismissDirection = DismissDirection.horizontal; List leaveBehindItems; void initListItems() { - leaveBehindItems = new List.generate(16, (int index) { - return new LeaveBehindItem( + leaveBehindItems = List.generate(16, (int index) { + return LeaveBehindItem( index: index, name: 'Item $index Sender', subject: 'Subject: $index', @@ -90,9 +90,9 @@ class LeaveBehindDemoState extends State { setState(() { leaveBehindItems.remove(item); }); - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text('You archived item ${item.index}'), - action: new SnackBarAction( + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text('You archived item ${item.index}'), + action: SnackBarAction( label: 'UNDO', onPressed: () { handleUndo(item); } ) @@ -103,9 +103,9 @@ class LeaveBehindDemoState extends State { setState(() { leaveBehindItems.remove(item); }); - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text('You deleted item ${item.index}'), - action: new SnackBarAction( + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text('You deleted item ${item.index}'), + action: SnackBarAction( label: 'UNDO', onPressed: () { handleUndo(item); } ) @@ -116,16 +116,16 @@ class LeaveBehindDemoState extends State { Widget build(BuildContext context) { Widget body; if (leaveBehindItems.isEmpty) { - body = new Center( - child: new RaisedButton( + body = Center( + child: RaisedButton( onPressed: () => handleDemoAction(LeaveBehindDemoAction.reset), child: const Text('Reset the list'), ), ); } else { - body = new ListView( + body = ListView( children: leaveBehindItems.map((LeaveBehindItem item) { - return new _LeaveBehindListItem( + return _LeaveBehindListItem( item: item, onArchive: _handleArchive, onDelete: _handleDelete, @@ -135,12 +135,12 @@ class LeaveBehindDemoState extends State { ); } - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Swipe to dismiss'), actions: [ - new PopupMenuButton( + PopupMenuButton( onSelected: handleDemoAction, itemBuilder: (BuildContext context) => >[ const PopupMenuItem( @@ -148,17 +148,17 @@ class LeaveBehindDemoState extends State { child: Text('Reset the list') ), const PopupMenuDivider(), - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: LeaveBehindDemoAction.horizontalSwipe, checked: _dismissDirection == DismissDirection.horizontal, child: const Text('Horizontal swipe') ), - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: LeaveBehindDemoAction.leftSwipe, checked: _dismissDirection == DismissDirection.endToStart, child: const Text('Only swipe left') ), - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: LeaveBehindDemoAction.rightSwipe, checked: _dismissDirection == DismissDirection.startToEnd, child: const Text('Only swipe right') @@ -197,13 +197,13 @@ class _LeaveBehindListItem extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Semantics( + return Semantics( customSemanticsActions: { const CustomSemanticsAction(label: 'Archive'): _handleArchive, const CustomSemanticsAction(label: 'Delete'): _handleDelete, }, - child: new Dismissible( - key: new ObjectKey(item), + child: Dismissible( + key: ObjectKey(item), direction: dismissDirection, onDismissed: (DismissDirection direction) { if (direction == DismissDirection.endToStart) @@ -211,26 +211,26 @@ class _LeaveBehindListItem extends StatelessWidget { else _handleDelete(); }, - background: new Container( + background: Container( color: theme.primaryColor, child: const ListTile( leading: Icon(Icons.delete, color: Colors.white, size: 36.0) ) ), - secondaryBackground: new Container( + secondaryBackground: Container( color: theme.primaryColor, child: const ListTile( trailing: Icon(Icons.archive, color: Colors.white, size: 36.0) ) ), - child: new Container( - decoration: new BoxDecoration( + child: Container( + decoration: BoxDecoration( color: theme.canvasColor, - border: new Border(bottom: new BorderSide(color: theme.dividerColor)) + border: Border(bottom: BorderSide(color: theme.dividerColor)) ), - child: new ListTile( - title: new Text(item.name), - subtitle: new Text('${item.subject}\n${item.body}'), + child: ListTile( + title: Text(item.name), + subtitle: Text('${item.subject}\n${item.body}'), isThreeLine: true ), ), diff --git a/examples/flutter_gallery/lib/demo/material/list_demo.dart b/examples/flutter_gallery/lib/demo/material/list_demo.dart index ab5baf7ef7..2353f02b6b 100644 --- a/examples/flutter_gallery/lib/demo/material/list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/list_demo.dart @@ -24,11 +24,11 @@ class ListDemo extends StatefulWidget { static const String routeName = '/material/list'; @override - _ListDemoState createState() => new _ListDemoState(); + _ListDemoState createState() => _ListDemoState(); } class _ListDemoState extends State { - static final GlobalKey scaffoldKey = new GlobalKey(); + static final GlobalKey scaffoldKey = GlobalKey(); PersistentBottomSheetController _bottomSheet; _MaterialListType _itemType = _MaterialListType.threeLine; @@ -50,52 +50,52 @@ class _ListDemoState extends State { void _showConfigurationSheet() { final PersistentBottomSheetController bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) { - return new Container( + return Container( decoration: const BoxDecoration( border: Border(top: BorderSide(color: Colors.black26)), ), - child: new ListView( + child: ListView( shrinkWrap: true, primary: false, children: [ - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('One-line'), - trailing: new Radio<_MaterialListType>( + trailing: Radio<_MaterialListType>( value: _showAvatars ? _MaterialListType.oneLineWithAvatar : _MaterialListType.oneLine, groupValue: _itemType, onChanged: changeItemType, ) ), ), - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('Two-line'), - trailing: new Radio<_MaterialListType>( + trailing: Radio<_MaterialListType>( value: _MaterialListType.twoLine, groupValue: _itemType, onChanged: changeItemType, ) ), ), - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('Three-line'), - trailing: new Radio<_MaterialListType>( + trailing: Radio<_MaterialListType>( value: _MaterialListType.threeLine, groupValue: _itemType, onChanged: changeItemType, ), ), ), - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('Show avatar'), - trailing: new Checkbox( + trailing: Checkbox( value: _showAvatars, onChanged: (bool value) { setState(() { @@ -106,11 +106,11 @@ class _ListDemoState extends State { ), ), ), - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('Show icon'), - trailing: new Checkbox( + trailing: Checkbox( value: _showIcons, onChanged: (bool value) { setState(() { @@ -121,11 +121,11 @@ class _ListDemoState extends State { ), ), ), - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('Show dividers'), - trailing: new Checkbox( + trailing: Checkbox( value: _showDividers, onChanged: (bool value) { setState(() { @@ -136,11 +136,11 @@ class _ListDemoState extends State { ), ), ), - new MergeSemantics( - child: new ListTile( + MergeSemantics( + child: ListTile( dense: true, title: const Text('Dense layout'), - trailing: new Checkbox( + trailing: Checkbox( value: _dense, onChanged: (bool value) { setState(() { @@ -178,14 +178,14 @@ class _ListDemoState extends State { 'Even more additional list item information appears on line three.', ); } - return new MergeSemantics( - child: new ListTile( + return MergeSemantics( + child: ListTile( isThreeLine: _itemType == _MaterialListType.threeLine, dense: _dense, - leading: _showAvatars ? new ExcludeSemantics(child: new CircleAvatar(child: new Text(item))) : null, - title: new Text('This item represents $item.'), + leading: _showAvatars ? ExcludeSemantics(child: CircleAvatar(child: Text(item))) : null, + title: Text('This item represents $item.'), subtitle: secondary, - trailing: _showIcons ? new Icon(Icons.info, color: Theme.of(context).disabledColor) : null, + trailing: _showIcons ? Icon(Icons.info, color: Theme.of(context).disabledColor) : null, ), ); } @@ -211,12 +211,12 @@ class _ListDemoState extends State { if (_showDividers) listTiles = ListTile.divideTiles(context: context, tiles: listTiles); - return new Scaffold( + return Scaffold( key: scaffoldKey, - appBar: new AppBar( - title: new Text('Scrolling list\n$itemTypeText$layoutText'), + appBar: AppBar( + title: Text('Scrolling list\n$itemTypeText$layoutText'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sort_by_alpha), tooltip: 'Sort', onPressed: () { @@ -226,8 +226,8 @@ class _ListDemoState extends State { }); }, ), - new IconButton( - icon: new Icon( + IconButton( + icon: Icon( Theme.of(context).platform == TargetPlatform.iOS ? Icons.more_horiz : Icons.more_vert, @@ -237,9 +237,9 @@ class _ListDemoState extends State { ), ], ), - body: new Scrollbar( - child: new ListView( - padding: new EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0), + body: Scrollbar( + child: ListView( + padding: EdgeInsets.symmetric(vertical: _dense ? 4.0 : 8.0), children: listTiles.toList(), ), ), diff --git a/examples/flutter_gallery/lib/demo/material/menu_demo.dart b/examples/flutter_gallery/lib/demo/material/menu_demo.dart index 31bb74072a..3d0f4a3b84 100644 --- a/examples/flutter_gallery/lib/demo/material/menu_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/menu_demo.dart @@ -10,11 +10,11 @@ class MenuDemo extends StatefulWidget { static const String routeName = '/material/menu'; @override - MenuDemoState createState() => new MenuDemoState(); + MenuDemoState createState() => MenuDemoState(); } class MenuDemoState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); final String _simpleValue1 = 'Menu item value one'; final String _simpleValue2 = 'Menu item value two'; @@ -35,8 +35,8 @@ class MenuDemoState extends State { } void showInSnackBar(String value) { - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text(value) + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text(value) )); } @@ -59,12 +59,12 @@ class MenuDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Menus'), actions: [ - new PopupMenuButton( + PopupMenuButton( onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ const PopupMenuItem( @@ -83,19 +83,19 @@ class MenuDemoState extends State { ), ], ), - body: new ListView( + body: ListView( padding: kMaterialListPadding, children: [ // Pressing the PopupMenuButton on the right of this item shows // a simple menu with one disabled item. Typically the contents // of this "contextual menu" would reflect the app's state. - new ListTile( + ListTile( title: const Text('An item with a context menu button'), - trailing: new PopupMenuButton( + trailing: PopupMenuButton( padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + PopupMenuItem( value: _simpleValue1, child: const Text('Context menu item one') ), @@ -103,7 +103,7 @@ class MenuDemoState extends State { enabled: false, child: Text('A disabled menu item') ), - new PopupMenuItem( + PopupMenuItem( value: _simpleValue3, child: const Text('Context menu item three') ), @@ -113,9 +113,9 @@ class MenuDemoState extends State { // Pressing the PopupMenuButton on the right of this item shows // a menu whose items have text labels and icons and a divider // That separates the first three items from the last one. - new ListTile( + ListTile( title: const Text('An item with a sectioned menu'), - trailing: new PopupMenuButton( + trailing: PopupMenuButton( padding: EdgeInsets.zero, onSelected: showMenuSelection, itemBuilder: (BuildContext context) => >[ @@ -154,57 +154,57 @@ class MenuDemoState extends State { // This entire list item is a PopupMenuButton. Tapping anywhere shows // a menu whose current value is highlighted and aligned over the // list item's center line. - new PopupMenuButton( + PopupMenuButton( padding: EdgeInsets.zero, initialValue: _simpleValue, onSelected: showMenuSelection, - child: new ListTile( + child: ListTile( title: const Text('An item with a simple menu'), - subtitle: new Text(_simpleValue) + subtitle: Text(_simpleValue) ), itemBuilder: (BuildContext context) => >[ - new PopupMenuItem( + PopupMenuItem( value: _simpleValue1, - child: new Text(_simpleValue1) + child: Text(_simpleValue1) ), - new PopupMenuItem( + PopupMenuItem( value: _simpleValue2, - child: new Text(_simpleValue2) + child: Text(_simpleValue2) ), - new PopupMenuItem( + PopupMenuItem( value: _simpleValue3, - child: new Text(_simpleValue3) + child: Text(_simpleValue3) ) ] ), // Pressing the PopupMenuButton on the right of this item shows a menu // whose items have checked icons that reflect this app's state. - new ListTile( + ListTile( title: const Text('An item with a checklist menu'), - trailing: new PopupMenuButton( + trailing: PopupMenuButton( padding: EdgeInsets.zero, onSelected: showCheckedMenuSelections, itemBuilder: (BuildContext context) => >[ - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: _checkedValue1, checked: isChecked(_checkedValue1), - child: new Text(_checkedValue1) + child: Text(_checkedValue1) ), - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: _checkedValue2, enabled: false, checked: isChecked(_checkedValue2), - child: new Text(_checkedValue2) + child: Text(_checkedValue2) ), - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: _checkedValue3, checked: isChecked(_checkedValue3), - child: new Text(_checkedValue3) + child: Text(_checkedValue3) ), - new CheckedPopupMenuItem( + CheckedPopupMenuItem( value: _checkedValue4, checked: isChecked(_checkedValue4), - child: new Text(_checkedValue4) + child: Text(_checkedValue4) ) ] ) diff --git a/examples/flutter_gallery/lib/demo/material/modal_bottom_sheet_demo.dart b/examples/flutter_gallery/lib/demo/material/modal_bottom_sheet_demo.dart index 8fdbf41dd7..ce4f081d5f 100644 --- a/examples/flutter_gallery/lib/demo/material/modal_bottom_sheet_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/modal_bottom_sheet_demo.dart @@ -9,19 +9,19 @@ class ModalBottomSheetDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Modal bottom sheet')), - body: new Center( - child: new RaisedButton( + return Scaffold( + appBar: AppBar(title: const Text('Modal bottom sheet')), + body: Center( + child: RaisedButton( child: const Text('SHOW BOTTOM SHEET'), onPressed: () { showModalBottomSheet(context: context, builder: (BuildContext context) { - return new Container( - child: new Padding( + return Container( + child: Padding( padding: const EdgeInsets.all(32.0), - child: new Text('This is the modal bottom sheet. Tap anywhere to dismiss.', + child: Text('This is the modal bottom sheet. Tap anywhere to dismiss.', textAlign: TextAlign.center, - style: new TextStyle( + style: TextStyle( color: Theme.of(context).accentColor, fontSize: 24.0 ) diff --git a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart index 5e73d9770d..5b4939f893 100644 --- a/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/overscroll_demo.dart @@ -14,23 +14,23 @@ class OverscrollDemo extends StatefulWidget { static const String routeName = '/material/overscroll'; @override - OverscrollDemoState createState() => new OverscrollDemoState(); + OverscrollDemoState createState() => OverscrollDemoState(); } class OverscrollDemoState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); - final GlobalKey _refreshIndicatorKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); + final GlobalKey _refreshIndicatorKey = GlobalKey(); static final List _items = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N' ]; Future _handleRefresh() { - final Completer completer = new Completer(); - new Timer(const Duration(seconds: 3), () { completer.complete(null); }); + final Completer completer = Completer(); + Timer(const Duration(seconds: 3), () { completer.complete(null); }); return completer.future.then((_) { - _scaffoldKey.currentState?.showSnackBar(new SnackBar( + _scaffoldKey.currentState?.showSnackBar(SnackBar( content: const Text('Refresh complete'), - action: new SnackBarAction( + action: SnackBarAction( label: 'RETRY', onPressed: () { _refreshIndicatorKey.currentState.show(); @@ -42,12 +42,12 @@ class OverscrollDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Pull to refresh'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.refresh), tooltip: 'Refresh', onPressed: () { @@ -56,18 +56,18 @@ class OverscrollDemoState extends State { ), ] ), - body: new RefreshIndicator( + body: RefreshIndicator( key: _refreshIndicatorKey, onRefresh: _handleRefresh, - child: new ListView.builder( + child: ListView.builder( padding: kMaterialListPadding, itemCount: _items.length, itemBuilder: (BuildContext context, int index) { final String item = _items[index]; - return new ListTile( + return ListTile( isThreeLine: true, - leading: new CircleAvatar(child: new Text(item)), - title: new Text('This item represents $item.'), + leading: CircleAvatar(child: Text(item)), + title: Text('This item represents $item.'), subtitle: const Text('Even more additional list item information appears on line three.'), ); }, diff --git a/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart b/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart index 33dc588afc..2f3b67d37d 100644 --- a/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/page_selector_demo.dart @@ -19,23 +19,23 @@ class _PageSelector extends StatelessWidget { Widget build(BuildContext context) { final TabController controller = DefaultTabController.of(context); final Color color = Theme.of(context).accentColor; - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Column( + child: Column( children: [ - new Container( + Container( margin: const EdgeInsets.only(top: 16.0), - child: new Row( + child: Row( children: [ - new IconButton( + IconButton( icon: const Icon(Icons.chevron_left), color: color, onPressed: () { _handleArrowButtonPress(context, -1); }, tooltip: 'Page back' ), - new TabPageSelector(controller: controller), - new IconButton( + TabPageSelector(controller: controller), + IconButton( icon: const Icon(Icons.chevron_right), color: color, onPressed: () { _handleArrowButtonPress(context, 1); }, @@ -45,18 +45,18 @@ class _PageSelector extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.spaceBetween ) ), - new Expanded( - child: new IconTheme( - data: new IconThemeData( + Expanded( + child: IconTheme( + data: IconThemeData( size: 128.0, color: color, ), - child: new TabBarView( + child: TabBarView( children: icons.map((Icon icon) { - return new Container( + return Container( padding: const EdgeInsets.all(12.0), - child: new Card( - child: new Center( + child: Card( + child: Center( child: icon, ), ), @@ -84,11 +84,11 @@ class PageSelectorDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Page selector')), - body: new DefaultTabController( + return Scaffold( + appBar: AppBar(title: const Text('Page selector')), + body: DefaultTabController( length: icons.length, - child: new _PageSelector(icons: icons), + child: _PageSelector(icons: icons), ), ); } diff --git a/examples/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart b/examples/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart index 97ff8dfe40..090a4aee9b 100644 --- a/examples/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/persistent_bottom_sheet_demo.dart @@ -8,11 +8,11 @@ class PersistentBottomSheetDemo extends StatefulWidget { static const String routeName = '/material/persistent-bottom-sheet'; @override - _PersistentBottomSheetDemoState createState() => new _PersistentBottomSheetDemoState(); + _PersistentBottomSheetDemoState createState() => _PersistentBottomSheetDemoState(); } class _PersistentBottomSheetDemoState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); VoidCallback _showBottomSheetCallback; @@ -28,15 +28,15 @@ class _PersistentBottomSheetDemoState extends State { }); _scaffoldKey.currentState.showBottomSheet((BuildContext context) { final ThemeData themeData = Theme.of(context); - return new Container( - decoration: new BoxDecoration( - border: new Border(top: new BorderSide(color: themeData.disabledColor)) + return Container( + decoration: BoxDecoration( + border: Border(top: BorderSide(color: themeData.disabledColor)) ), - child: new Padding( + child: Padding( padding: const EdgeInsets.all(32.0), - child: new Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.', + child: Text('This is a Material persistent bottom sheet. Drag downwards to dismiss it.', textAlign: TextAlign.center, - style: new TextStyle( + style: TextStyle( color: themeData.accentColor, fontSize: 24.0 ) @@ -57,10 +57,10 @@ class _PersistentBottomSheetDemoState extends State { showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( + return AlertDialog( content: const Text('You tapped the floating action button.'), actions: [ - new FlatButton( + FlatButton( onPressed: () { Navigator.pop(context); }, @@ -74,10 +74,10 @@ class _PersistentBottomSheetDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar(title: const Text('Persistent bottom sheet')), - floatingActionButton: new FloatingActionButton( + appBar: AppBar(title: const Text('Persistent bottom sheet')), + floatingActionButton: FloatingActionButton( onPressed: _showMessage, backgroundColor: Colors.redAccent, child: const Icon( @@ -85,8 +85,8 @@ class _PersistentBottomSheetDemoState extends State { semanticLabel: 'Add', ), ), - body: new Center( - child: new RaisedButton( + body: Center( + child: RaisedButton( onPressed: _showBottomSheetCallback, child: const Text('SHOW BOTTOM SHEET') ) diff --git a/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart b/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart index 5a26eb8a15..2035739ed0 100644 --- a/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/progress_indicator_demo.dart @@ -8,7 +8,7 @@ class ProgressIndicatorDemo extends StatefulWidget { static const String routeName = '/material/progress-indicator'; @override - _ProgressIndicatorDemoState createState() => new _ProgressIndicatorDemoState(); + _ProgressIndicatorDemoState createState() => _ProgressIndicatorDemoState(); } class _ProgressIndicatorDemoState extends State with SingleTickerProviderStateMixin { @@ -18,13 +18,13 @@ class _ProgressIndicatorDemoState extends State with Sing @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(milliseconds: 1500), vsync: this, animationBehavior: AnimationBehavior.preserve, )..forward(); - _animation = new CurvedAnimation( + _animation = CurvedAnimation( parent: _controller, curve: const Interval(0.0, 0.9, curve: Curves.fastOutSlowIn), reverseCurve: Curves.fastOutSlowIn @@ -70,50 +70,50 @@ class _ProgressIndicatorDemoState extends State with Sing ), const LinearProgressIndicator(), const LinearProgressIndicator(), - new LinearProgressIndicator(value: _animation.value), - new Row( + LinearProgressIndicator(value: _animation.value), + Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ const CircularProgressIndicator(), - new SizedBox( + SizedBox( width: 20.0, height: 20.0, - child: new CircularProgressIndicator(value: _animation.value) + child: CircularProgressIndicator(value: _animation.value) ), - new SizedBox( + SizedBox( width: 100.0, height: 20.0, - child: new Text('${(_animation.value * 100.0).toStringAsFixed(1)}%', + child: Text('${(_animation.value * 100.0).toStringAsFixed(1)}%', textAlign: TextAlign.right ), ), ], ), ]; - return new Column( + return Column( children: indicators - .map((Widget c) => new Container(child: c, margin: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0))) + .map((Widget c) => Container(child: c, margin: const EdgeInsets.symmetric(vertical: 15.0, horizontal: 20.0))) .toList(), ); } @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Progress indicators')), - body: new Center( - child: new SingleChildScrollView( - child: new DefaultTextStyle( + return Scaffold( + appBar: AppBar(title: const Text('Progress indicators')), + body: Center( + child: SingleChildScrollView( + child: DefaultTextStyle( style: Theme.of(context).textTheme.title, - child: new GestureDetector( + child: GestureDetector( onTap: _handleTap, behavior: HitTestBehavior.opaque, - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new Container( + child: Container( padding: const EdgeInsets.symmetric(vertical: 12.0, horizontal: 8.0), - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: _animation, builder: _buildIndicators ), diff --git a/examples/flutter_gallery/lib/demo/material/reorderable_list_demo.dart b/examples/flutter_gallery/lib/demo/material/reorderable_list_demo.dart index 6762e541b9..f71666f24e 100644 --- a/examples/flutter_gallery/lib/demo/material/reorderable_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/reorderable_list_demo.dart @@ -23,7 +23,7 @@ class ReorderableListDemo extends StatefulWidget { static const String routeName = '/material/reorderable-list'; @override - _ListDemoState createState() => new _ListDemoState(); + _ListDemoState createState() => _ListDemoState(); } class _ListItem { @@ -35,14 +35,14 @@ class _ListItem { } class _ListDemoState extends State { - static final GlobalKey scaffoldKey = new GlobalKey(); + static final GlobalKey scaffoldKey = GlobalKey(); PersistentBottomSheetController _bottomSheet; _ReorderableListType _itemType = _ReorderableListType.threeLine; bool _reverseSort = false; final List<_ListItem> _items = [ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', - ].map((String item) => new _ListItem(item, false)).toList(); + ].map((String item) => _ListItem(item, false)).toList(); void changeItemType(_ReorderableListType type) { setState(() { @@ -57,29 +57,29 @@ class _ListDemoState extends State { void _showConfigurationSheet() { setState(() { _bottomSheet = scaffoldKey.currentState.showBottomSheet((BuildContext bottomSheetContext) { - return new DecoratedBox( + return DecoratedBox( decoration: const BoxDecoration( border: Border(top: BorderSide(color: Colors.black26)), ), - child: new ListView( + child: ListView( shrinkWrap: true, primary: false, children: [ - new RadioListTile<_ReorderableListType>( + RadioListTile<_ReorderableListType>( dense: true, title: const Text('Horizontal Avatars'), value: _ReorderableListType.horizontalAvatar, groupValue: _itemType, onChanged: changeItemType, ), - new RadioListTile<_ReorderableListType>( + RadioListTile<_ReorderableListType>( dense: true, title: const Text('Vertical Avatars'), value: _ReorderableListType.verticalAvatar, groupValue: _itemType, onChanged: changeItemType, ), - new RadioListTile<_ReorderableListType>( + RadioListTile<_ReorderableListType>( dense: true, title: const Text('Three-line'), value: _ReorderableListType.threeLine, @@ -109,8 +109,8 @@ class _ListDemoState extends State { Widget listTile; switch (_itemType) { case _ReorderableListType.threeLine: - listTile = new CheckboxListTile( - key: new Key(item.value), + listTile = CheckboxListTile( + key: Key(item.value), isThreeLine: true, value: item.checkState ?? false, onChanged: (bool newValue) { @@ -118,18 +118,18 @@ class _ListDemoState extends State { item.checkState = newValue; }); }, - title: new Text('This item represents ${item.value}.'), + title: Text('This item represents ${item.value}.'), subtitle: secondary, secondary: const Icon(Icons.drag_handle), ); break; case _ReorderableListType.horizontalAvatar: case _ReorderableListType.verticalAvatar: - listTile = new Container( - key: new Key(item.value), + listTile = Container( + key: Key(item.value), height: 100.0, width: 100.0, - child: new CircleAvatar(child: new Text(item.value), + child: CircleAvatar(child: Text(item.value), backgroundColor: Colors.green, ), ); @@ -152,12 +152,12 @@ class _ListDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Reorderable list'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sort_by_alpha), tooltip: 'Sort', onPressed: () { @@ -167,8 +167,8 @@ class _ListDemoState extends State { }); }, ), - new IconButton( - icon: new Icon( + IconButton( + icon: Icon( Theme.of(context).platform == TargetPlatform.iOS ? Icons.more_horiz : Icons.more_vert, @@ -178,12 +178,12 @@ class _ListDemoState extends State { ), ], ), - body: new Scrollbar( - child: new ReorderableListView( + body: Scrollbar( + child: ReorderableListView( header: _itemType != _ReorderableListType.threeLine - ? new Padding( + ? Padding( padding: const EdgeInsets.all(8.0), - child: new Text('Header of the list', style: Theme.of(context).textTheme.headline)) + child: Text('Header of the list', style: Theme.of(context).textTheme.headline)) : null, onReorder: _onReorder, scrollDirection: _itemType == _ReorderableListType.horizontalAvatar ? Axis.horizontal : Axis.vertical, diff --git a/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart b/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart index e6d0dd944c..38d6518127 100644 --- a/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/scrollable_tabs_demo.dart @@ -37,7 +37,7 @@ class ScrollableTabsDemo extends StatefulWidget { static const String routeName = '/material/scrollable-tabs'; @override - ScrollableTabsDemoState createState() => new ScrollableTabsDemoState(); + ScrollableTabsDemoState createState() => ScrollableTabsDemoState(); } class ScrollableTabsDemoState extends State with SingleTickerProviderStateMixin { @@ -48,7 +48,7 @@ class ScrollableTabsDemoState extends State with SingleTicke @override void initState() { super.initState(); - _controller = new TabController(vsync: this, length: _allPages.length); + _controller = TabController(vsync: this, length: _allPages.length); } @override @@ -69,7 +69,7 @@ class ScrollableTabsDemoState extends State with SingleTicke switch(_demoStyle) { case TabsDemoStyle.iconsAndText: - return new ShapeDecoration( + return ShapeDecoration( shape: const RoundedRectangleBorder( borderRadius: BorderRadius.all(Radius.circular(4.0)), side: BorderSide( @@ -86,7 +86,7 @@ class ScrollableTabsDemoState extends State with SingleTicke ); case TabsDemoStyle.iconsOnly: - return new ShapeDecoration( + return ShapeDecoration( shape: const CircleBorder( side: BorderSide( color: Colors.white24, @@ -101,7 +101,7 @@ class ScrollableTabsDemoState extends State with SingleTicke ); case TabsDemoStyle.textOnly: - return new ShapeDecoration( + return ShapeDecoration( shape: const StadiumBorder( side: BorderSide( color: Colors.white24, @@ -121,11 +121,11 @@ class ScrollableTabsDemoState extends State with SingleTicke @override Widget build(BuildContext context) { final Color iconColor = Theme.of(context).accentColor; - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Scrollable tabs'), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sentiment_very_satisfied), onPressed: () { setState(() { @@ -133,7 +133,7 @@ class ScrollableTabsDemoState extends State with SingleTicke }); }, ), - new PopupMenuButton( + PopupMenuButton( onSelected: changeDemoStyle, itemBuilder: (BuildContext context) => >[ const PopupMenuItem( @@ -151,7 +151,7 @@ class ScrollableTabsDemoState extends State with SingleTicke ], ), ], - bottom: new TabBar( + bottom: TabBar( controller: _controller, isScrollable: true, indicator: getIndicator(), @@ -159,28 +159,28 @@ class ScrollableTabsDemoState extends State with SingleTicke assert(_demoStyle != null); switch (_demoStyle) { case TabsDemoStyle.iconsAndText: - return new Tab(text: page.text, icon: new Icon(page.icon)); + return Tab(text: page.text, icon: Icon(page.icon)); case TabsDemoStyle.iconsOnly: - return new Tab(icon: new Icon(page.icon)); + return Tab(icon: Icon(page.icon)); case TabsDemoStyle.textOnly: - return new Tab(text: page.text); + return Tab(text: page.text); } return null; }).toList(), ), ), - body: new TabBarView( + body: TabBarView( controller: _controller, children: _allPages.map((_Page page) { - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Container( - key: new ObjectKey(page.icon), + child: Container( + key: ObjectKey(page.icon), padding: const EdgeInsets.all(12.0), - child: new Card( - child: new Center( - child: new Icon( + child: Card( + child: Center( + child: Icon( page.icon, color: iconColor, size: 128.0, diff --git a/examples/flutter_gallery/lib/demo/material/search_demo.dart b/examples/flutter_gallery/lib/demo/material/search_demo.dart index 8873abb47b..e22cb2670d 100644 --- a/examples/flutter_gallery/lib/demo/material/search_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/search_demo.dart @@ -8,23 +8,23 @@ class SearchDemo extends StatefulWidget { static const String routeName = '/material/search'; @override - _SearchDemoState createState() => new _SearchDemoState(); + _SearchDemoState createState() => _SearchDemoState(); } class _SearchDemoState extends State { - final _SearchDemoSearchDelegate _delegate = new _SearchDemoSearchDelegate(); - final GlobalKey _scaffoldKey = new GlobalKey(); + final _SearchDemoSearchDelegate _delegate = _SearchDemoSearchDelegate(); + final GlobalKey _scaffoldKey = GlobalKey(); int _lastIntegerSelected; @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( - leading: new IconButton( + appBar: AppBar( + leading: IconButton( tooltip: 'Navigation menu', - icon: new AnimatedIcon( + icon: AnimatedIcon( icon: AnimatedIcons.menu_arrow, color: Colors.white, progress: _delegate.transitionAnimation, @@ -35,7 +35,7 @@ class _SearchDemoState extends State { ), title: const Text('Numbers'), actions: [ - new IconButton( + IconButton( tooltip: 'Search', icon: const Icon(Icons.search), onPressed: () async { @@ -50,9 +50,9 @@ class _SearchDemoState extends State { } }, ), - new IconButton( + IconButton( tooltip: 'More (not implemented)', - icon: new Icon( + icon: Icon( Theme.of(context).platform == TargetPlatform.iOS ? Icons.more_horiz : Icons.more_vert, @@ -61,15 +61,15 @@ class _SearchDemoState extends State { ), ], ), - body: new Center( - child: new Column( + body: Center( + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new MergeSemantics( - child: new Column( + MergeSemantics( + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Row( + Row( mainAxisAlignment: MainAxisAlignment.center, children: const [ Text('Press the '), @@ -88,11 +88,11 @@ class _SearchDemoState extends State { ), ), const SizedBox(height: 64.0), - new Text('Last selected integer: ${_lastIntegerSelected ?? 'NONE' }.') + Text('Last selected integer: ${_lastIntegerSelected ?? 'NONE' }.') ], ), ), - floatingActionButton: new FloatingActionButton.extended( + floatingActionButton: FloatingActionButton.extended( tooltip: 'Back', // Tests depend on this label to exit the demo. onPressed: () { Navigator.of(context).pop(); @@ -100,8 +100,8 @@ class _SearchDemoState extends State { label: const Text('Close demo'), icon: const Icon(Icons.close), ), - drawer: new Drawer( - child: new Column( + drawer: Drawer( + child: Column( children: [ const UserAccountsDrawerHeader( accountName: Text('Peter Widget'), @@ -114,7 +114,7 @@ class _SearchDemoState extends State { ), margin: EdgeInsets.zero, ), - new MediaQuery.removePadding( + MediaQuery.removePadding( context: context, // DrawerHeader consumes top MediaQuery padding. removeTop: true, @@ -131,14 +131,14 @@ class _SearchDemoState extends State { } class _SearchDemoSearchDelegate extends SearchDelegate { - final List _data = new List.generate(100001, (int i) => i).reversed.toList(); + final List _data = List.generate(100001, (int i) => i).reversed.toList(); final List _history = [42607, 85604, 66374, 44, 174]; @override Widget buildLeading(BuildContext context) { - return new IconButton( + return IconButton( tooltip: 'Back', - icon: new AnimatedIcon( + icon: AnimatedIcon( icon: AnimatedIcons.menu_arrow, progress: transitionAnimation, ), @@ -155,7 +155,7 @@ class _SearchDemoSearchDelegate extends SearchDelegate { ? _history : _data.where((int i) => '$i'.startsWith(query)); - return new _SuggestionList( + return _SuggestionList( query: query, suggestions: suggestions.map((int i) => '$i').toList(), onSelected: (String suggestion) { @@ -169,27 +169,27 @@ class _SearchDemoSearchDelegate extends SearchDelegate { Widget buildResults(BuildContext context) { final int searched = int.tryParse(query); if (searched == null || !_data.contains(searched)) { - return new Center( - child: new Text( + return Center( + child: Text( '"$query"\n is not a valid integer between 0 and 100,000.\nTry again.', textAlign: TextAlign.center, ), ); } - return new ListView( + return ListView( children: [ - new _ResultCard( + _ResultCard( title: 'This integer', integer: searched, searchDelegate: this, ), - new _ResultCard( + _ResultCard( title: 'Next integer', integer: searched + 1, searchDelegate: this, ), - new _ResultCard( + _ResultCard( title: 'Previous integer', integer: searched - 1, searchDelegate: this, @@ -202,14 +202,14 @@ class _SearchDemoSearchDelegate extends SearchDelegate { List buildActions(BuildContext context) { return [ query.isEmpty - ? new IconButton( + ? IconButton( tooltip: 'Voice Search', icon: const Icon(Icons.mic), onPressed: () { query = 'TODO: implement voice input'; }, ) - : new IconButton( + : IconButton( tooltip: 'Clear', icon: const Icon(Icons.clear), onPressed: () { @@ -231,17 +231,17 @@ class _ResultCard extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new GestureDetector( + return GestureDetector( onTap: () { searchDelegate.close(context, integer); }, - child: new Card( - child: new Padding( + child: Card( + child: Padding( padding: const EdgeInsets.all(8.0), - child: new Column( + child: Column( children: [ - new Text(title), - new Text( + Text(title), + Text( '$integer', style: theme.textTheme.headline.copyWith(fontSize: 72.0), ), @@ -263,18 +263,18 @@ class _SuggestionList extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new ListView.builder( + return ListView.builder( itemCount: suggestions.length, itemBuilder: (BuildContext context, int i) { final String suggestion = suggestions[i]; - return new ListTile( + return ListTile( leading: query.isEmpty ? const Icon(Icons.history) : const Icon(null), - title: new RichText( - text: new TextSpan( + title: RichText( + text: TextSpan( text: suggestion.substring(0, query.length), style: theme.textTheme.subhead.copyWith(fontWeight: FontWeight.bold), children: [ - new TextSpan( + TextSpan( text: suggestion.substring(query.length), style: theme.textTheme.subhead, ), diff --git a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart index 201d04398d..a4919a3be2 100644 --- a/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/selection_controls_demo.dart @@ -31,26 +31,26 @@ class SelectionControlsDemo extends StatefulWidget { static const String routeName = '/material/selection-controls'; @override - _SelectionControlsDemoState createState() => new _SelectionControlsDemoState(); + _SelectionControlsDemoState createState() => _SelectionControlsDemoState(); } class _SelectionControlsDemoState extends State { @override Widget build(BuildContext context) { final List demos = [ - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'CHECKBOX', description: _checkboxText, demoWidget: buildCheckbox(), exampleCodeTag: _checkboxCode ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'RADIO', description: _radioText, demoWidget: buildRadio(), exampleCodeTag: _radioCode ), - new ComponentDemoTabData( + ComponentDemoTabData( tabName: 'SWITCH', description: _switchText, demoWidget: buildSwitch(), @@ -58,7 +58,7 @@ class _SelectionControlsDemoState extends State { ) ]; - return new TabbedComponentDemoScaffold( + return TabbedComponentDemoScaffold( title: 'Selection controls', demos: demos ); @@ -77,15 +77,15 @@ class _SelectionControlsDemoState extends State { } Widget buildCheckbox() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new Row( + Row( mainAxisSize: MainAxisSize.min, children: [ - new Checkbox( + Checkbox( value: checkboxValueA, onChanged: (bool value) { setState(() { @@ -93,7 +93,7 @@ class _SelectionControlsDemoState extends State { }); }, ), - new Checkbox( + Checkbox( value: checkboxValueB, onChanged: (bool value) { setState(() { @@ -101,7 +101,7 @@ class _SelectionControlsDemoState extends State { }); }, ), - new Checkbox( + Checkbox( value: checkboxValueC, tristate: true, onChanged: (bool value) { @@ -112,7 +112,7 @@ class _SelectionControlsDemoState extends State { ), ], ), - new Row( + Row( mainAxisSize: MainAxisSize.min, children: const [ // Disabled checkboxes @@ -127,25 +127,25 @@ class _SelectionControlsDemoState extends State { } Widget buildRadio() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new Row( + Row( mainAxisSize: MainAxisSize.min, children: [ - new Radio( + Radio( value: 0, groupValue: radioValue, onChanged: handleRadioValueChanged ), - new Radio( + Radio( value: 1, groupValue: radioValue, onChanged: handleRadioValueChanged ), - new Radio( + Radio( value: 2, groupValue: radioValue, onChanged: handleRadioValueChanged @@ -153,7 +153,7 @@ class _SelectionControlsDemoState extends State { ] ), // Disabled radio buttons - new Row( + Row( mainAxisSize: MainAxisSize.min, children: const [ Radio( @@ -179,12 +179,12 @@ class _SelectionControlsDemoState extends State { } Widget buildSwitch() { - return new Align( + return Align( alignment: const Alignment(0.0, -0.2), - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, children: [ - new Switch( + Switch( value: switchValue, onChanged: (bool value) { setState(() { diff --git a/examples/flutter_gallery/lib/demo/material/slider_demo.dart b/examples/flutter_gallery/lib/demo/material/slider_demo.dart index 7c8e8c1957..5a8d4ccd0a 100644 --- a/examples/flutter_gallery/lib/demo/material/slider_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/slider_demo.dart @@ -10,11 +10,11 @@ class SliderDemo extends StatefulWidget { static const String routeName = '/material/slider'; @override - _SliderDemoState createState() => new _SliderDemoState(); + _SliderDemoState createState() => _SliderDemoState(); } Path _triangle(double size, Offset thumbCenter, {bool invert = false}) { - final Path thumbPath = new Path(); + final Path thumbPath = Path(); final double height = math.sqrt(3.0) / 2.0; final double halfSide = size / 2.0; final double centerHeight = size * height / 3.0; @@ -35,7 +35,7 @@ class _CustomThumbShape extends SliderComponentShape { return isEnabled ? const Size.fromRadius(_thumbSize) : const Size.fromRadius(_disabledThumbSize); } - static final Tween sizeTween = new Tween( + static final Tween sizeTween = Tween( begin: _disabledThumbSize, end: _thumbSize, ); @@ -54,13 +54,13 @@ class _CustomThumbShape extends SliderComponentShape { double value, }) { final Canvas canvas = context.canvas; - final ColorTween colorTween = new ColorTween( + final ColorTween colorTween = ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.thumbColor, ); final double size = _thumbSize * sizeTween.evaluate(enableAnimation); final Path thumbPath = _triangle(size, thumbCenter); - canvas.drawPath(thumbPath, new Paint()..color = colorTween.evaluate(enableAnimation)); + canvas.drawPath(thumbPath, Paint()..color = colorTween.evaluate(enableAnimation)); } } @@ -71,10 +71,10 @@ class _CustomValueIndicatorShape extends SliderComponentShape { @override Size getPreferredSize(bool isEnabled, bool isDiscrete) { - return new Size.fromRadius(isEnabled ? _indicatorSize : _disabledIndicatorSize); + return Size.fromRadius(isEnabled ? _indicatorSize : _disabledIndicatorSize); } - static final Tween sizeTween = new Tween( + static final Tween sizeTween = Tween( begin: _disabledIndicatorSize, end: _indicatorSize, ); @@ -93,16 +93,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape { double value, }) { final Canvas canvas = context.canvas; - final ColorTween enableColor = new ColorTween( + final ColorTween enableColor = ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.valueIndicatorColor, ); - final Tween slideUpTween = new Tween( + final Tween slideUpTween = Tween( begin: 0.0, end: _slideUpHeight, ); final double size = _indicatorSize * sizeTween.evaluate(enableAnimation); - final Offset slideUpOffset = new Offset(0.0, -slideUpTween.evaluate(activationAnimation)); + final Offset slideUpOffset = Offset(0.0, -slideUpTween.evaluate(activationAnimation)); final Path thumbPath = _triangle( size, thumbCenter + slideUpOffset, @@ -111,16 +111,16 @@ class _CustomValueIndicatorShape extends SliderComponentShape { final Color paintColor = enableColor.evaluate(enableAnimation).withAlpha((255.0 * activationAnimation.value).round()); canvas.drawPath( thumbPath, - new Paint()..color = paintColor, + Paint()..color = paintColor, ); canvas.drawLine( thumbCenter, thumbCenter + slideUpOffset, - new Paint() + Paint() ..color = paintColor ..style = PaintingStyle.stroke ..strokeWidth = 2.0); - labelPainter.paint(canvas, thumbCenter + slideUpOffset + new Offset(-labelPainter.width / 2.0, -labelPainter.height - 4.0)); + labelPainter.paint(canvas, thumbCenter + slideUpOffset + Offset(-labelPainter.width / 2.0, -labelPainter.height - 4.0)); } } @@ -131,17 +131,17 @@ class _SliderDemoState extends State { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Scaffold( - appBar: new AppBar(title: const Text('Sliders')), - body: new Padding( + return Scaffold( + appBar: AppBar(title: const Text('Sliders')), + body: Padding( padding: const EdgeInsets.symmetric(horizontal: 40.0), - child: new Column( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new Column( + Column( mainAxisSize: MainAxisSize.min, children: [ - new Slider( + Slider( value: _value, min: 0.0, max: 100.0, @@ -154,17 +154,17 @@ class _SliderDemoState extends State { const Text('Continuous'), ], ), - new Column( + Column( mainAxisSize: MainAxisSize.min, children: const [ Slider(value: 0.25, onChanged: null), Text('Disabled'), ], ), - new Column( + Column( mainAxisSize: MainAxisSize.min, children: [ - new Slider( + Slider( value: _discreteValue, min: 0.0, max: 200.0, @@ -179,10 +179,10 @@ class _SliderDemoState extends State { const Text('Discrete'), ], ), - new Column( + Column( mainAxisSize: MainAxisSize.min, children: [ - new SliderTheme( + SliderTheme( data: theme.sliderTheme.copyWith( activeTrackColor: Colors.deepPurple, inactiveTrackColor: Colors.black26, @@ -191,11 +191,11 @@ class _SliderDemoState extends State { overlayColor: Colors.black12, thumbColor: Colors.deepPurple, valueIndicatorColor: Colors.deepPurpleAccent, - thumbShape: new _CustomThumbShape(), - valueIndicatorShape: new _CustomValueIndicatorShape(), + thumbShape: _CustomThumbShape(), + valueIndicatorShape: _CustomValueIndicatorShape(), valueIndicatorTextStyle: theme.accentTextTheme.body2.copyWith(color: Colors.black87), ), - child: new Slider( + child: Slider( value: _discreteValue, min: 0.0, max: 200.0, diff --git a/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart b/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart index f349cf1ec6..17fe78d6b2 100644 --- a/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/snack_bar_demo.dart @@ -22,33 +22,33 @@ class SnackBarDemo extends StatefulWidget { static const String routeName = '/material/snack-bar'; @override - _SnackBarDemoState createState() => new _SnackBarDemoState(); + _SnackBarDemoState createState() => _SnackBarDemoState(); } class _SnackBarDemoState extends State { int _snackBarIndex = 1; Widget buildBody(BuildContext context) { - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new ListView( + child: ListView( padding: const EdgeInsets.all(24.0), children: [ const Text(_text1), const Text(_text2), - new Center( - child: new RaisedButton( + Center( + child: RaisedButton( child: const Text('SHOW A SNACKBAR'), onPressed: () { final int thisSnackBarIndex = _snackBarIndex++; - Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text('This is snackbar #$thisSnackBarIndex.'), - action: new SnackBarAction( + Scaffold.of(context).showSnackBar(SnackBar( + content: Text('This is snackbar #$thisSnackBarIndex.'), + action: SnackBarAction( label: 'ACTION', onPressed: () { - Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text('You pressed snackbar $thisSnackBarIndex\'s action.') + Scaffold.of(context).showSnackBar(SnackBar( + content: Text('You pressed snackbar $thisSnackBarIndex\'s action.') )); } ), @@ -59,7 +59,7 @@ class _SnackBarDemoState extends State { const Text(_text3), ] .map((Widget child) { - return new Container( + return Container( margin: const EdgeInsets.symmetric(vertical: 12.0), child: child ); @@ -71,11 +71,11 @@ class _SnackBarDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Snackbar') ), - body: new Builder( + body: Builder( // Create an inner BuildContext so that the snackBar onPressed methods // can refer to the Scaffold with Scaffold.of(). builder: buildBody diff --git a/examples/flutter_gallery/lib/demo/material/tabs_demo.dart b/examples/flutter_gallery/lib/demo/material/tabs_demo.dart index ab60990fdb..f32cf8549e 100644 --- a/examples/flutter_gallery/lib/demo/material/tabs_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/tabs_demo.dart @@ -25,7 +25,7 @@ class _CardData { } final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{ - new _Page(label: 'HOME'): <_CardData>[ + _Page(label: 'HOME'): <_CardData>[ const _CardData( title: 'Flatwear', imageAsset: 'products/flatwear.png', @@ -72,7 +72,7 @@ final Map<_Page, List<_CardData>> _allPages = <_Page, List<_CardData>>{ imageAssetPackage: _kGalleryAssetsPackage, ), ], - new _Page(label: 'APPAREL'): <_CardData>[ + _Page(label: 'APPAREL'): <_CardData>[ const _CardData( title: 'Cloud-White Dress', imageAsset: 'products/dress.png', @@ -100,30 +100,30 @@ class _CardDataItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new Card( - child: new Padding( + return Card( + child: Padding( padding: const EdgeInsets.all(16.0), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, mainAxisAlignment: MainAxisAlignment.start, children: [ - new Align( + Align( alignment: page.id == 'H' ? Alignment.centerLeft : Alignment.centerRight, - child: new CircleAvatar(child: new Text('${page.id}')), + child: CircleAvatar(child: Text('${page.id}')), ), - new SizedBox( + SizedBox( width: 144.0, height: 144.0, - child: new Image.asset( + child: Image.asset( data.imageAsset, package: data.imageAssetPackage, fit: BoxFit.contain, ), ), - new Center( - child: new Text( + Center( + child: Text( data.title, style: Theme.of(context).textTheme.title, ), @@ -140,56 +140,56 @@ class TabsDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new DefaultTabController( + return DefaultTabController( length: _allPages.length, - child: new Scaffold( - body: new NestedScrollView( + child: Scaffold( + body: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ - new SliverOverlapAbsorber( + SliverOverlapAbsorber( handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), - child: new SliverAppBar( + child: SliverAppBar( title: const Text('Tabs and scrolling'), pinned: true, expandedHeight: 150.0, forceElevated: innerBoxIsScrolled, - bottom: new TabBar( + bottom: TabBar( tabs: _allPages.keys.map( - (_Page page) => new Tab(text: page.label), + (_Page page) => Tab(text: page.label), ).toList(), ), ), ), ]; }, - body: new TabBarView( + body: TabBarView( children: _allPages.keys.map((_Page page) { - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new CustomScrollView( - key: new PageStorageKey<_Page>(page), + return CustomScrollView( + key: PageStorageKey<_Page>(page), slivers: [ - new SliverOverlapInjector( + SliverOverlapInjector( handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), ), - new SliverPadding( + SliverPadding( padding: const EdgeInsets.symmetric( vertical: 8.0, horizontal: 16.0, ), - sliver: new SliverFixedExtentList( + sliver: SliverFixedExtentList( itemExtent: _CardDataItem.height, - delegate: new SliverChildBuilderDelegate( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { final _CardData data = _allPages[page][index]; - return new Padding( + return Padding( padding: const EdgeInsets.symmetric( vertical: 8.0, ), - child: new _CardDataItem( + child: _CardDataItem( page: page, data: data, ), diff --git a/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart b/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart index 62dc8c9ccc..f028601227 100644 --- a/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/tabs_fab_demo.dart @@ -20,27 +20,27 @@ class _Page { Color get labelColor => colors != null ? colors.shade300 : Colors.grey.shade300; bool get fabDefined => colors != null && icon != null; Color get fabColor => colors.shade400; - Icon get fabIcon => new Icon(icon); - Key get fabKey => new ValueKey(fabColor); + Icon get fabIcon => Icon(icon); + Key get fabKey => ValueKey(fabColor); } final List<_Page> _allPages = <_Page>[ - new _Page(label: 'Blue', colors: Colors.indigo, icon: Icons.add), - new _Page(label: 'Eco', colors: Colors.green, icon: Icons.create), - new _Page(label: 'No'), - new _Page(label: 'Teal', colors: Colors.teal, icon: Icons.add), - new _Page(label: 'Red', colors: Colors.red, icon: Icons.create), + _Page(label: 'Blue', colors: Colors.indigo, icon: Icons.add), + _Page(label: 'Eco', colors: Colors.green, icon: Icons.create), + _Page(label: 'No'), + _Page(label: 'Teal', colors: Colors.teal, icon: Icons.add), + _Page(label: 'Red', colors: Colors.red, icon: Icons.create), ]; class TabsFabDemo extends StatefulWidget { static const String routeName = '/material/tabs-fab'; @override - _TabsFabDemoState createState() => new _TabsFabDemoState(); + _TabsFabDemoState createState() => _TabsFabDemoState(); } class _TabsFabDemoState extends State with SingleTickerProviderStateMixin { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); TabController _controller; _Page _selectedPage; @@ -49,7 +49,7 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat @override void initState() { super.initState(); - _controller = new TabController(vsync: this, length: _allPages.length); + _controller = TabController(vsync: this, length: _allPages.length); _controller.addListener(_handleTabSelection); _selectedPage = _allPages[0]; } @@ -68,28 +68,28 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat void _showExplanatoryText() { _scaffoldKey.currentState.showBottomSheet((BuildContext context) { - return new Container( - decoration: new BoxDecoration( - border: new Border(top: new BorderSide(color: Theme.of(context).dividerColor)) + return Container( + decoration: BoxDecoration( + border: Border(top: BorderSide(color: Theme.of(context).dividerColor)) ), - child: new Padding( + child: Padding( padding: const EdgeInsets.all(32.0), - child: new Text(_explanatoryText, style: Theme.of(context).textTheme.subhead) + child: Text(_explanatoryText, style: Theme.of(context).textTheme.subhead) ) ); }); } Widget buildTabView(_Page page) { - return new Builder( + return Builder( builder: (BuildContext context) { - return new Container( - key: new ValueKey(page.label), + return Container( + key: ValueKey(page.label), padding: const EdgeInsets.fromLTRB(48.0, 48.0, 48.0, 96.0), - child: new Card( - child: new Center( - child: new Text(page.label, - style: new TextStyle( + child: Card( + child: Center( + child: Text(page.label, + style: TextStyle( color: page.labelColor, fontSize: 32.0 ), @@ -107,17 +107,17 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat return null; if (_extendedButtons) { - return new FloatingActionButton.extended( - key: new ValueKey(page.fabKey), + return FloatingActionButton.extended( + key: ValueKey(page.fabKey), tooltip: 'Show explanation', backgroundColor: page.fabColor, icon: page.fabIcon, - label: new Text(page.label.toUpperCase()), + label: Text(page.label.toUpperCase()), onPressed: _showExplanatoryText ); } - return new FloatingActionButton( + return FloatingActionButton( key: page.fabKey, tooltip: 'Show explanation', backgroundColor: page.fabColor, @@ -128,16 +128,16 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('FAB per tab'), - bottom: new TabBar( + bottom: TabBar( controller: _controller, - tabs: _allPages.map((_Page page) => new Tab(text: page.label.toUpperCase())).toList(), + tabs: _allPages.map((_Page page) => Tab(text: page.label.toUpperCase())).toList(), ), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.sentiment_very_satisfied), onPressed: () { setState(() { @@ -148,7 +148,7 @@ class _TabsFabDemoState extends State with SingleTickerProviderStat ], ), floatingActionButton: buildFloatingActionButton(_selectedPage), - body: new TabBarView( + body: TabBarView( controller: _controller, children: _allPages.map(buildTabView).toList() ), diff --git a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart index 457584f5a5..afa90243f0 100644 --- a/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/text_form_field_demo.dart @@ -13,7 +13,7 @@ class TextFormFieldDemo extends StatefulWidget { static const String routeName = '/material/text-form-field'; @override - TextFormFieldDemoState createState() => new TextFormFieldDemoState(); + TextFormFieldDemoState createState() => TextFormFieldDemoState(); } class PersonData { @@ -43,7 +43,7 @@ class PasswordField extends StatefulWidget { final ValueChanged onFieldSubmitted; @override - _PasswordFieldState createState() => new _PasswordFieldState(); + _PasswordFieldState createState() => _PasswordFieldState(); } class _PasswordFieldState extends State { @@ -51,26 +51,26 @@ class _PasswordFieldState extends State { @override Widget build(BuildContext context) { - return new TextFormField( + return TextFormField( key: widget.fieldKey, obscureText: _obscureText, maxLength: 8, onSaved: widget.onSaved, validator: widget.validator, onFieldSubmitted: widget.onFieldSubmitted, - decoration: new InputDecoration( + decoration: InputDecoration( border: const UnderlineInputBorder(), filled: true, hintText: widget.hintText, labelText: widget.labelText, helperText: widget.helperText, - suffixIcon: new GestureDetector( + suffixIcon: GestureDetector( onTap: () { setState(() { _obscureText = !_obscureText; }); }, - child: new Icon(_obscureText ? Icons.visibility : Icons.visibility_off), + child: Icon(_obscureText ? Icons.visibility : Icons.visibility_off), ), ), ); @@ -78,22 +78,22 @@ class _PasswordFieldState extends State { } class TextFormFieldDemoState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); - PersonData person = new PersonData(); + PersonData person = PersonData(); void showInSnackBar(String value) { - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text(value) + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text(value) )); } bool _autovalidate = false; bool _formWasEdited = false; - final GlobalKey _formKey = new GlobalKey(); - final GlobalKey> _passwordFieldKey = new GlobalKey>(); - final _UsNumberTextInputFormatter _phoneNumberFormatter = new _UsNumberTextInputFormatter(); + final GlobalKey _formKey = GlobalKey(); + final GlobalKey> _passwordFieldKey = GlobalKey>(); + final _UsNumberTextInputFormatter _phoneNumberFormatter = _UsNumberTextInputFormatter(); void _handleSubmitted() { final FormState form = _formKey.currentState; if (!form.validate()) { @@ -109,7 +109,7 @@ class TextFormFieldDemoState extends State { _formWasEdited = true; if (value.isEmpty) return 'Name is required.'; - final RegExp nameExp = new RegExp(r'^[A-Za-z ]+$'); + final RegExp nameExp = RegExp(r'^[A-Za-z ]+$'); if (!nameExp.hasMatch(value)) return 'Please enter only alphabetical characters.'; return null; @@ -117,7 +117,7 @@ class TextFormFieldDemoState extends State { String _validatePhoneNumber(String value) { _formWasEdited = true; - final RegExp phoneExp = new RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$'); + final RegExp phoneExp = RegExp(r'^\(\d\d\d\) \d\d\d\-\d\d\d\d$'); if (!phoneExp.hasMatch(value)) return '(###) ###-#### - Enter a US phone number.'; return null; @@ -141,15 +141,15 @@ class TextFormFieldDemoState extends State { return await showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( + return AlertDialog( title: const Text('This form has errors'), content: const Text('Really leave this form?'), actions: [ - new FlatButton( + FlatButton( child: const Text('YES'), onPressed: () { Navigator.of(context).pop(true); }, ), - new FlatButton( + FlatButton( child: const Text('NO'), onPressed: () { Navigator.of(context).pop(false); }, ), @@ -161,25 +161,25 @@ class TextFormFieldDemoState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Text fields'), ), - body: new SafeArea( + body: SafeArea( top: false, bottom: false, - child: new Form( + child: Form( key: _formKey, autovalidate: _autovalidate, onWillPop: _warnUserAboutInvalidData, - child: new SingleChildScrollView( + child: SingleChildScrollView( padding: const EdgeInsets.symmetric(horizontal: 16.0), - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ const SizedBox(height: 24.0), - new TextFormField( + TextFormField( textCapitalization: TextCapitalization.words, decoration: const InputDecoration( border: UnderlineInputBorder(), @@ -192,7 +192,7 @@ class TextFormFieldDemoState extends State { validator: _validateName, ), const SizedBox(height: 24.0), - new TextFormField( + TextFormField( decoration: const InputDecoration( border: UnderlineInputBorder(), filled: true, @@ -212,7 +212,7 @@ class TextFormFieldDemoState extends State { ], ), const SizedBox(height: 24.0), - new TextFormField( + TextFormField( decoration: const InputDecoration( border: UnderlineInputBorder(), filled: true, @@ -224,7 +224,7 @@ class TextFormFieldDemoState extends State { onSaved: (String value) { person.email = value; }, ), const SizedBox(height: 24.0), - new TextFormField( + TextFormField( decoration: const InputDecoration( border: OutlineInputBorder(), hintText: 'Tell us about yourself', @@ -234,7 +234,7 @@ class TextFormFieldDemoState extends State { maxLines: 3, ), const SizedBox(height: 24.0), - new TextFormField( + TextFormField( keyboardType: TextInputType.number, decoration: const InputDecoration( border: OutlineInputBorder(), @@ -246,7 +246,7 @@ class TextFormFieldDemoState extends State { maxLines: 1, ), const SizedBox(height: 24.0), - new PasswordField( + PasswordField( fieldKey: _passwordFieldKey, helperText: 'No more than 8 characters.', labelText: 'Password *', @@ -257,7 +257,7 @@ class TextFormFieldDemoState extends State { }, ), const SizedBox(height: 24.0), - new TextFormField( + TextFormField( enabled: person.password != null && person.password.isNotEmpty, decoration: const InputDecoration( border: UnderlineInputBorder(), @@ -269,14 +269,14 @@ class TextFormFieldDemoState extends State { validator: _validatePassword, ), const SizedBox(height: 24.0), - new Center( - child: new RaisedButton( + Center( + child: RaisedButton( child: const Text('SUBMIT'), onPressed: _handleSubmitted, ), ), const SizedBox(height: 24.0), - new Text( + Text( '* indicates required field', style: Theme.of(context).textTheme.caption ), @@ -300,7 +300,7 @@ class _UsNumberTextInputFormatter extends TextInputFormatter { final int newTextLength = newValue.text.length; int selectionIndex = newValue.selection.end; int usedSubstringIndex = 0; - final StringBuffer newText = new StringBuffer(); + final StringBuffer newText = StringBuffer(); if (newTextLength >= 1) { newText.write('('); if (newValue.selection.end >= 1) @@ -324,9 +324,9 @@ class _UsNumberTextInputFormatter extends TextInputFormatter { // Dump the rest. if (newTextLength >= usedSubstringIndex) newText.write(newValue.text.substring(usedSubstringIndex)); - return new TextEditingValue( + return TextEditingValue( text: newText.toString(), - selection: new TextSelection.collapsed(offset: selectionIndex), + selection: TextSelection.collapsed(offset: selectionIndex), ); } } diff --git a/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart b/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart index 448ef950c3..b2584097a8 100644 --- a/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/tooltip_demo.dart @@ -16,34 +16,34 @@ class TooltipDemo extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Tooltips') ), - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new ListView( + child: ListView( children: [ - new Text(_introText, style: theme.textTheme.subhead), - new Row( + Text(_introText, style: theme.textTheme.subhead), + Row( children: [ - new Text('Long press the ', style: theme.textTheme.subhead), - new Tooltip( + Text('Long press the ', style: theme.textTheme.subhead), + Tooltip( message: 'call icon', - child: new Icon( + child: Icon( Icons.call, size: 18.0, color: theme.iconTheme.color ) ), - new Text(' icon.', style: theme.textTheme.subhead) + Text(' icon.', style: theme.textTheme.subhead) ] ), - new Center( - child: new IconButton( + Center( + child: IconButton( iconSize: 48.0, icon: const Icon(Icons.call), color: theme.iconTheme.color, @@ -57,7 +57,7 @@ class TooltipDemo extends StatelessWidget { ) ] .map((Widget widget) { - return new Padding( + return Padding( padding: const EdgeInsets.only(top: 16.0, left: 16.0, right: 16.0), child: widget ); diff --git a/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart b/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart index effdd92ca9..3f8d9f3e87 100644 --- a/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart +++ b/examples/flutter_gallery/lib/demo/material/two_level_list_demo.dart @@ -9,12 +9,12 @@ class TwoLevelListDemo extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Expand/collapse list control')), - body: new ListView( + return Scaffold( + appBar: AppBar(title: const Text('Expand/collapse list control')), + body: ListView( children: [ const ListTile(title: Text('Top')), - new ExpansionTile( + ExpansionTile( title: const Text('Sublist'), backgroundColor: Theme.of(context).accentColor.withOpacity(0.025), children: const [ diff --git a/examples/flutter_gallery/lib/demo/pesto_demo.dart b/examples/flutter_gallery/lib/demo/pesto_demo.dart index bc16884887..fec72f7722 100644 --- a/examples/flutter_gallery/lib/demo/pesto_demo.dart +++ b/examples/flutter_gallery/lib/demo/pesto_demo.dart @@ -11,7 +11,7 @@ class PestoDemo extends StatelessWidget { static const String routeName = '/pesto'; @override - Widget build(BuildContext context) => new PestoHome(); + Widget build(BuildContext context) => PestoHome(); } @@ -21,9 +21,9 @@ const double _kAppBarHeight = 128.0; const double _kFabHalfSize = 28.0; // TODO(mpcomplete): needs to adapt to screen size const double _kRecipePageMaxWidth = 500.0; -final Set _favoriteRecipes = new Set(); +final Set _favoriteRecipes = Set(); -final ThemeData _kTheme = new ThemeData( +final ThemeData _kTheme = ThemeData( brightness: Brightness.light, primarySwatch: Colors.teal, accentColor: Colors.redAccent, @@ -39,7 +39,7 @@ class PestoHome extends StatelessWidget { class PestoFavorites extends StatelessWidget { @override Widget build(BuildContext context) { - return new RecipeGridPage(recipes: _favoriteRecipes.toList()); + return RecipeGridPage(recipes: _favoriteRecipes.toList()); } } @@ -69,20 +69,20 @@ class RecipeGridPage extends StatefulWidget { final List recipes; @override - _RecipeGridPageState createState() => new _RecipeGridPageState(); + _RecipeGridPageState createState() => _RecipeGridPageState(); } class _RecipeGridPageState extends State { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); @override Widget build(BuildContext context) { final double statusBarHeight = MediaQuery.of(context).padding.top; - return new Theme( + return Theme( data: _kTheme.copyWith(platform: Theme.of(context).platform), - child: new Scaffold( + child: Scaffold( key: scaffoldKey, - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( child: const Icon(Icons.edit), onPressed: () { scaffoldKey.currentState.showSnackBar(const SnackBar( @@ -90,7 +90,7 @@ class _RecipeGridPageState extends State { )); }, ), - body: new CustomScrollView( + body: CustomScrollView( slivers: [ _buildAppBar(context, statusBarHeight), _buildBody(context, statusBarHeight), @@ -101,11 +101,11 @@ class _RecipeGridPageState extends State { } Widget _buildAppBar(BuildContext context, double statusBarHeight) { - return new SliverAppBar( + return SliverAppBar( pinned: true, expandedHeight: _kAppBarHeight, actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.search), tooltip: 'Search', onPressed: () { @@ -115,20 +115,20 @@ class _RecipeGridPageState extends State { }, ), ], - flexibleSpace: new LayoutBuilder( + flexibleSpace: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final Size size = constraints.biggest; final double appBarHeight = size.height - statusBarHeight; final double t = (appBarHeight - kToolbarHeight) / (_kAppBarHeight - kToolbarHeight); - final double extraPadding = new Tween(begin: 10.0, end: 24.0).lerp(t); + final double extraPadding = Tween(begin: 10.0, end: 24.0).lerp(t); final double logoHeight = appBarHeight - 1.5 * extraPadding; - return new Padding( - padding: new EdgeInsets.only( + return Padding( + padding: EdgeInsets.only( top: statusBarHeight + 0.5 * extraPadding, bottom: extraPadding, ), - child: new Center( - child: new PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0)) + child: Center( + child: PestoLogo(height: logoHeight, t: t.clamp(0.0, 1.0)) ), ); }, @@ -138,24 +138,24 @@ class _RecipeGridPageState extends State { Widget _buildBody(BuildContext context, double statusBarHeight) { final EdgeInsets mediaPadding = MediaQuery.of(context).padding; - final EdgeInsets padding = new EdgeInsets.only( + final EdgeInsets padding = EdgeInsets.only( top: 8.0, left: 8.0 + mediaPadding.left, right: 8.0 + mediaPadding.right, bottom: 8.0 ); - return new SliverPadding( + return SliverPadding( padding: padding, - sliver: new SliverGrid( + sliver: SliverGrid( gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: _kRecipePageMaxWidth, crossAxisSpacing: 8.0, mainAxisSpacing: 8.0, ), - delegate: new SliverChildBuilderDelegate( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { final Recipe recipe = widget.recipes[index]; - return new RecipeCard( + return RecipeCard( recipe: recipe, onTap: () { showRecipePage(context, recipe); }, ); @@ -167,19 +167,19 @@ class _RecipeGridPageState extends State { } void showFavoritesPage(BuildContext context) { - Navigator.push(context, new MaterialPageRoute( + Navigator.push(context, MaterialPageRoute( settings: const RouteSettings(name: '/pesto/favorites'), - builder: (BuildContext context) => new PestoFavorites(), + builder: (BuildContext context) => PestoFavorites(), )); } void showRecipePage(BuildContext context, Recipe recipe) { - Navigator.push(context, new MaterialPageRoute( + Navigator.push(context, MaterialPageRoute( settings: const RouteSettings(name: '/pesto/recipe'), builder: (BuildContext context) { - return new Theme( + return Theme( data: _kTheme.copyWith(platform: Theme.of(context).platform), - child: new RecipePage(recipe: recipe), + child: RecipePage(recipe: recipe), ); }, )); @@ -193,7 +193,7 @@ class PestoLogo extends StatefulWidget { final double t; @override - _PestoLogoState createState() => new _PestoLogoState(); + _PestoLogoState createState() => _PestoLogoState(); } class _PestoLogoState extends State { @@ -203,41 +203,41 @@ class _PestoLogoState extends State { static const double kImageHeight = 108.0; static const double kTextHeight = 48.0; final TextStyle titleStyle = const PestoStyle(fontSize: kTextHeight, fontWeight: FontWeight.w900, color: Colors.white, letterSpacing: 3.0); - final RectTween _textRectTween = new RectTween( - begin: new Rect.fromLTWH(0.0, kLogoHeight, kLogoWidth, kTextHeight), - end: new Rect.fromLTWH(0.0, kImageHeight, kLogoWidth, kTextHeight) + final RectTween _textRectTween = RectTween( + begin: Rect.fromLTWH(0.0, kLogoHeight, kLogoWidth, kTextHeight), + end: Rect.fromLTWH(0.0, kImageHeight, kLogoWidth, kTextHeight) ); final Curve _textOpacity = const Interval(0.4, 1.0, curve: Curves.easeInOut); - final RectTween _imageRectTween = new RectTween( - begin: new Rect.fromLTWH(0.0, 0.0, kLogoWidth, kLogoHeight), - end: new Rect.fromLTWH(0.0, 0.0, kLogoWidth, kImageHeight), + final RectTween _imageRectTween = RectTween( + begin: Rect.fromLTWH(0.0, 0.0, kLogoWidth, kLogoHeight), + end: Rect.fromLTWH(0.0, 0.0, kLogoWidth, kImageHeight), ); @override Widget build(BuildContext context) { - return new Semantics( + return Semantics( namesRoute: true, - child: new Transform( - transform: new Matrix4.identity()..scale(widget.height / kLogoHeight), + child: Transform( + transform: Matrix4.identity()..scale(widget.height / kLogoHeight), alignment: Alignment.topCenter, - child: new SizedBox( + child: SizedBox( width: kLogoWidth, - child: new Stack( + child: Stack( overflow: Overflow.visible, children: [ - new Positioned.fromRect( + Positioned.fromRect( rect: _imageRectTween.lerp(widget.t), - child: new Image.asset( + child: Image.asset( _kSmallLogoImage, package: _kGalleryAssetsPackage, fit: BoxFit.contain, ), ), - new Positioned.fromRect( + Positioned.fromRect( rect: _textRectTween.lerp(widget.t), - child: new Opacity( + child: Opacity( opacity: _textOpacity.transform(widget.t), - child: new Text('PESTO', style: titleStyle, textAlign: TextAlign.center), + child: Text('PESTO', style: titleStyle, textAlign: TextAlign.center), ), ), ], @@ -260,13 +260,13 @@ class RecipeCard extends StatelessWidget { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: onTap, - child: new Card( - child: new Column( + child: Card( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Hero( + Hero( tag: 'packages/$_kGalleryAssetsPackage/${recipe.imagePath}', child: AspectRatio( aspectRatio: 4.0 / 3.0, @@ -278,25 +278,25 @@ class RecipeCard extends StatelessWidget { ), ), ), - new Expanded( - child: new Row( + Expanded( + child: Row( children: [ - new Padding( + Padding( padding: const EdgeInsets.all(16.0), - child: new Image.asset( + child: Image.asset( recipe.ingredientsImagePath, package: recipe.ingredientsImagePackage, width: 48.0, height: 48.0, ), ), - new Expanded( - child: new Column( + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text(recipe.name, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis), - new Text(recipe.author, style: authorStyle), + Text(recipe.name, style: titleStyle, softWrap: false, overflow: TextOverflow.ellipsis), + Text(recipe.author, style: authorStyle), ], ), ), @@ -317,11 +317,11 @@ class RecipePage extends StatefulWidget { final Recipe recipe; @override - _RecipePageState createState() => new _RecipePageState(); + _RecipePageState createState() => _RecipePageState(); } class _RecipePageState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); final TextStyle menuItemStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0); double _getAppBarHeight(BuildContext context) => MediaQuery.of(context).size.height * 0.3; @@ -335,31 +335,31 @@ class _RecipePageState extends State { final Size screenSize = MediaQuery.of(context).size; final bool fullWidth = screenSize.width < _kRecipePageMaxWidth; final bool isFavorite = _favoriteRecipes.contains(widget.recipe); - return new Scaffold( + return Scaffold( key: _scaffoldKey, - body: new Stack( + body: Stack( children: [ - new Positioned( + Positioned( top: 0.0, left: 0.0, right: 0.0, height: appBarHeight + _kFabHalfSize, - child: new Hero( + child: Hero( tag: 'packages/$_kGalleryAssetsPackage/${widget.recipe.imagePath}', - child: new Image.asset( + child: Image.asset( widget.recipe.imagePath, package: widget.recipe.imagePackage, fit: fullWidth ? BoxFit.fitWidth : BoxFit.cover, ), ), ), - new CustomScrollView( + CustomScrollView( slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: appBarHeight - _kFabHalfSize, backgroundColor: Colors.transparent, actions: [ - new PopupMenuButton( + PopupMenuButton( onSelected: (String item) {}, itemBuilder: (BuildContext context) => >[ _buildMenuItem(Icons.share, 'Tweet recipe'), @@ -381,18 +381,18 @@ class _RecipePageState extends State { ), ), ), - new SliverToBoxAdapter( - child: new Stack( + SliverToBoxAdapter( + child: Stack( children: [ - new Container( + Container( padding: const EdgeInsets.only(top: _kFabHalfSize), width: fullWidth ? null : _kRecipePageMaxWidth, - child: new RecipeSheet(recipe: widget.recipe), + child: RecipeSheet(recipe: widget.recipe), ), - new Positioned( + Positioned( right: 16.0, - child: new FloatingActionButton( - child: new Icon(isFavorite ? Icons.favorite : Icons.favorite_border), + child: FloatingActionButton( + child: Icon(isFavorite ? Icons.favorite : Icons.favorite_border), onPressed: _toggleFavorite, ), ), @@ -407,14 +407,14 @@ class _RecipePageState extends State { } PopupMenuItem _buildMenuItem(IconData icon, String label) { - return new PopupMenuItem( - child: new Row( + return PopupMenuItem( + child: Row( children: [ - new Padding( + Padding( padding: const EdgeInsets.only(right: 24.0), - child: new Icon(icon, color: Colors.black54) + child: Icon(icon, color: Colors.black54) ), - new Text(label, style: menuItemStyle), + Text(label, style: menuItemStyle), ], ), ); @@ -435,7 +435,7 @@ class RecipeSheet extends StatelessWidget { final TextStyle titleStyle = const PestoStyle(fontSize: 34.0); final TextStyle descriptionStyle = const PestoStyle(fontSize: 15.0, color: Colors.black54, height: 24.0/15.0); final TextStyle itemStyle = const PestoStyle(fontSize: 15.0, height: 24.0/15.0); - final TextStyle itemAmountStyle = new PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0); + final TextStyle itemAmountStyle = PestoStyle(fontSize: 15.0, color: _kTheme.primaryColor, height: 24.0/15.0); final TextStyle headingStyle = const PestoStyle(fontSize: 16.0, fontWeight: FontWeight.bold, height: 24.0/15.0); RecipeSheet({ Key key, this.recipe }) : super(key: key); @@ -444,22 +444,22 @@ class RecipeSheet extends StatelessWidget { @override Widget build(BuildContext context) { - return new Material( - child: new SafeArea( + return Material( + child: SafeArea( top: false, bottom: false, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 16.0, vertical: 40.0), - child: new Table( + child: Table( columnWidths: const { 0: FixedColumnWidth(64.0) }, children: [ - new TableRow( + TableRow( children: [ - new TableCell( + TableCell( verticalAlignment: TableCellVerticalAlignment.middle, - child: new Image.asset( + child: Image.asset( recipe.ingredientsImagePath, package: recipe.ingredientsImagePackage, width: 32.0, @@ -468,27 +468,27 @@ class RecipeSheet extends StatelessWidget { fit: BoxFit.scaleDown ) ), - new TableCell( + TableCell( verticalAlignment: TableCellVerticalAlignment.middle, - child: new Text(recipe.name, style: titleStyle) + child: Text(recipe.name, style: titleStyle) ), ] ), - new TableRow( + TableRow( children: [ const SizedBox(), - new Padding( + Padding( padding: const EdgeInsets.only(top: 8.0, bottom: 4.0), - child: new Text(recipe.description, style: descriptionStyle) + child: Text(recipe.description, style: descriptionStyle) ), ] ), - new TableRow( + TableRow( children: [ const SizedBox(), - new Padding( + Padding( padding: const EdgeInsets.only(top: 24.0, bottom: 4.0), - child: new Text('Ingredients', style: headingStyle) + child: Text('Ingredients', style: headingStyle) ), ] ), @@ -497,12 +497,12 @@ class RecipeSheet extends StatelessWidget { return _buildItemRow(ingredient.amount, ingredient.description); } ))..add( - new TableRow( + TableRow( children: [ const SizedBox(), - new Padding( + Padding( padding: const EdgeInsets.only(top: 24.0, bottom: 4.0), - child: new Text('Steps', style: headingStyle) + child: Text('Steps', style: headingStyle) ), ] ) @@ -518,15 +518,15 @@ class RecipeSheet extends StatelessWidget { } TableRow _buildItemRow(String left, String right) { - return new TableRow( + return TableRow( children: [ - new Padding( + Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), - child: new Text(left, style: itemAmountStyle), + child: Text(left, style: itemAmountStyle), ), - new Padding( + Padding( padding: const EdgeInsets.symmetric(vertical: 4.0), - child: new Text(right, style: itemStyle), + child: Text(right, style: itemStyle), ), ], ); diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart index a8f9e5f9d0..85dcce35bf 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_data.dart @@ -274,5 +274,5 @@ const List _allProducts = [ List allProducts() { assert(_allProducts.every((Product product) => product.isValid())); - return new List.unmodifiable(_allProducts); + return List.unmodifiable(_allProducts); } diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart index c9f6b40b17..6e30227b4a 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_home.dart @@ -16,7 +16,7 @@ import 'shrine_types.dart'; const double unitSize = kToolbarHeight; -final List _products = new List.from(allProducts()); +final List _products = List.from(allProducts()); final Map _shoppingCart = {}; const int _childrenPerBlock = 8; @@ -75,7 +75,7 @@ class _ShrineGridLayout extends SliverGridLayout { final int row = _rowAtIndex(index); final int column = _columnAtIndex(index); final int columnSpan = _columnSpanAtIndex(index); - return new SliverGridGeometry( + return SliverGridGeometry( scrollOffset: row * rowStride, crossAxisOffset: column * columnStride, mainAxisExtent: tileHeight, @@ -100,7 +100,7 @@ class _ShrineGridDelegate extends SliverGridDelegate { SliverGridLayout getLayout(SliverConstraints constraints) { final double tileWidth = (constraints.crossAxisExtent - _spacing) / 2.0; const double tileHeight = 40.0 + 144.0 + 40.0; - return new _ShrineGridLayout( + return _ShrineGridLayout( tileWidth: tileWidth, tileHeight: tileHeight, rowStride: tileHeight + _spacing, @@ -122,15 +122,15 @@ class _VendorItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new SizedBox( + return SizedBox( height: 24.0, - child: new Row( + child: Row( children: [ - new SizedBox( + SizedBox( width: 24.0, - child: new ClipRRect( - borderRadius: new BorderRadius.circular(12.0), - child: new Image.asset( + child: ClipRRect( + borderRadius: BorderRadius.circular(12.0), + child: Image.asset( vendor.avatarAsset, package: vendor.avatarAssetPackage, fit: BoxFit.cover, @@ -138,8 +138,8 @@ class _VendorItem extends StatelessWidget { ), ), const SizedBox(width: 8.0), - new Expanded( - child: new Text(vendor.name, style: ShrineTheme.of(context).vendorItemStyle), + Expanded( + child: Text(vendor.name, style: ShrineTheme.of(context).vendorItemStyle), ), ], ), @@ -159,12 +159,12 @@ abstract class _PriceItem extends StatelessWidget { Widget buildItem(BuildContext context, TextStyle style, EdgeInsets padding) { BoxDecoration decoration; if (_shoppingCart[product] != null) - decoration = new BoxDecoration(color: ShrineTheme.of(context).priceHighlightColor); + decoration = BoxDecoration(color: ShrineTheme.of(context).priceHighlightColor); - return new Container( + return Container( padding: padding, decoration: decoration, - child: new Text(product.priceString, style: style), + child: Text(product.priceString, style: style), ); } } @@ -206,34 +206,34 @@ class _HeadingLayout extends MultiChildLayoutDelegate { @override void performLayout(Size size) { - final Size priceSize = layoutChild(price, new BoxConstraints.loose(size)); - positionChild(price, new Offset(size.width - priceSize.width, 0.0)); + final Size priceSize = layoutChild(price, BoxConstraints.loose(size)); + positionChild(price, Offset(size.width - priceSize.width, 0.0)); final double halfWidth = size.width / 2.0; final double halfHeight = size.height / 2.0; const double halfUnit = unitSize / 2.0; const double margin = 16.0; - final Size imageSize = layoutChild(image, new BoxConstraints.loose(size)); + final Size imageSize = layoutChild(image, BoxConstraints.loose(size)); final double imageX = imageSize.width < halfWidth - halfUnit ? halfWidth / 2.0 - imageSize.width / 2.0 - halfUnit : halfWidth - imageSize.width; - positionChild(image, new Offset(imageX, halfHeight - imageSize.height / 2.0)); + positionChild(image, Offset(imageX, halfHeight - imageSize.height / 2.0)); final double maxTitleWidth = halfWidth + unitSize - margin; - final BoxConstraints titleBoxConstraints = new BoxConstraints(maxWidth: maxTitleWidth); + final BoxConstraints titleBoxConstraints = BoxConstraints(maxWidth: maxTitleWidth); final Size titleSize = layoutChild(title, titleBoxConstraints); final double titleX = halfWidth - unitSize; final double titleY = halfHeight - titleSize.height; - positionChild(title, new Offset(titleX, titleY)); + positionChild(title, Offset(titleX, titleY)); final Size descriptionSize = layoutChild(description, titleBoxConstraints); final double descriptionY = titleY + titleSize.height + margin; - positionChild(description, new Offset(titleX, descriptionY)); + positionChild(description, Offset(titleX, descriptionY)); layoutChild(vendor, titleBoxConstraints); final double vendorY = descriptionY + descriptionSize.height + margin; - positionChild(vendor, new Offset(titleX, vendorY)); + positionChild(vendor, Offset(titleX, vendorY)); } @override @@ -254,42 +254,42 @@ class _Heading extends StatelessWidget { Widget build(BuildContext context) { final Size screenSize = MediaQuery.of(context).size; final ShrineTheme theme = ShrineTheme.of(context); - return new MergeSemantics( - child: new SizedBox( + return MergeSemantics( + child: SizedBox( height: screenSize.width > screenSize.height ? (screenSize.height - kToolbarHeight) * 0.85 : (screenSize.height - kToolbarHeight) * 0.70, - child: new Container( - decoration: new BoxDecoration( + child: Container( + decoration: BoxDecoration( color: theme.cardBackgroundColor, - border: new Border(bottom: new BorderSide(color: theme.dividerColor)), + border: Border(bottom: BorderSide(color: theme.dividerColor)), ), - child: new CustomMultiChildLayout( - delegate: new _HeadingLayout(), + child: CustomMultiChildLayout( + delegate: _HeadingLayout(), children: [ - new LayoutId( + LayoutId( id: _HeadingLayout.price, - child: new _FeaturePriceItem(product: product), + child: _FeaturePriceItem(product: product), ), - new LayoutId( + LayoutId( id: _HeadingLayout.image, - child: new Image.asset( + child: Image.asset( product.imageAsset, package: product.imageAssetPackage, fit: BoxFit.cover, ), ), - new LayoutId( + LayoutId( id: _HeadingLayout.title, - child: new Text(product.featureTitle, style: theme.featureTitleStyle), + child: Text(product.featureTitle, style: theme.featureTitleStyle), ), - new LayoutId( + LayoutId( id: _HeadingLayout.description, - child: new Text(product.featureDescription, style: theme.featureStyle), + child: Text(product.featureDescription, style: theme.featureStyle), ), - new LayoutId( + LayoutId( id: _HeadingLayout.vendor, - child: new _VendorItem(vendor: product.vendor), + child: _VendorItem(vendor: product.vendor), ), ], ), @@ -311,38 +311,38 @@ class _ProductItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new MergeSemantics( - child: new Card( - child: new Stack( + return MergeSemantics( + child: Card( + child: Stack( children: [ - new Column( + Column( children: [ - new Align( + Align( alignment: Alignment.centerRight, - child: new _ProductPriceItem(product: product), + child: _ProductPriceItem(product: product), ), - new Container( + Container( width: 144.0, height: 144.0, padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new Hero( + child: Hero( tag: product.tag, - child: new Image.asset( + child: Image.asset( product.imageAsset, package: product.imageAssetPackage, fit: BoxFit.contain, ), ), ), - new Padding( + Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new _VendorItem(vendor: product.vendor), + child: _VendorItem(vendor: product.vendor), ), ], ), - new Material( + Material( type: MaterialType.transparency, - child: new InkWell(onTap: onPressed), + child: InkWell(onTap: onPressed), ), ], ), @@ -355,19 +355,19 @@ class _ProductItem extends StatelessWidget { // of the product items. class ShrineHome extends StatefulWidget { @override - _ShrineHomeState createState() => new _ShrineHomeState(); + _ShrineHomeState createState() => _ShrineHomeState(); } class _ShrineHomeState extends State { - static final GlobalKey _scaffoldKey = new GlobalKey(debugLabel: 'Shrine Home'); - static final _ShrineGridDelegate gridDelegate = new _ShrineGridDelegate(); + static final GlobalKey _scaffoldKey = GlobalKey(debugLabel: 'Shrine Home'); + static final _ShrineGridDelegate gridDelegate = _ShrineGridDelegate(); Future _showOrderPage(Product product) async { - final Order order = _shoppingCart[product] ?? new Order(product: product); - final Order completedOrder = await Navigator.push(context, new ShrineOrderRoute( + final Order order = _shoppingCart[product] ?? Order(product: product); + final Order completedOrder = await Navigator.push(context, ShrineOrderRoute( order: order, builder: (BuildContext context) { - return new OrderPage( + return OrderPage( order: order, products: _products, shoppingCart: _shoppingCart, @@ -382,21 +382,21 @@ class _ShrineHomeState extends State { @override Widget build(BuildContext context) { final Product featured = _products.firstWhere((Product product) => product.featureDescription != null); - return new ShrinePage( + return ShrinePage( scaffoldKey: _scaffoldKey, products: _products, shoppingCart: _shoppingCart, - body: new CustomScrollView( + body: CustomScrollView( slivers: [ - new SliverToBoxAdapter(child: new _Heading(product: featured)), - new SliverSafeArea( + SliverToBoxAdapter(child: _Heading(product: featured)), + SliverSafeArea( top: false, minimum: const EdgeInsets.all(16.0), - sliver: new SliverGrid( + sliver: SliverGrid( gridDelegate: gridDelegate, - delegate: new SliverChildListDelegate( + delegate: SliverChildListDelegate( _products.map((Product product) { - return new _ProductItem( + return _ProductItem( product: product, onPressed: () { _showOrderPage(product); }, ); diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart index 5b49cebbda..453b16e9b5 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_order.dart @@ -28,30 +28,30 @@ class _ProductItem extends StatelessWidget { @override Widget build(BuildContext context) { final ShrineTheme theme = ShrineTheme.of(context); - return new Column( + return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Text(product.name, style: theme.featureTitleStyle), + Text(product.name, style: theme.featureTitleStyle), const SizedBox(height: 24.0), - new Text(product.description, style: theme.featureStyle), + Text(product.description, style: theme.featureStyle), const SizedBox(height: 16.0), - new Padding( + Padding( padding: const EdgeInsets.only(top: 8.0, bottom: 8.0, right: 88.0), - child: new DropdownButtonHideUnderline( - child: new Container( - decoration: new BoxDecoration( - border: new Border.all( + child: DropdownButtonHideUnderline( + child: Container( + decoration: BoxDecoration( + border: Border.all( color: const Color(0xFFD9D9D9), ), ), - child: new DropdownButton( + child: DropdownButton( items: [0, 1, 2, 3, 4, 5].map((int value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Padding( + child: Padding( padding: const EdgeInsets.only(left: 8.0), - child: new Text('Quantity $value', style: theme.quantityMenuStyle), + child: Text('Quantity $value', style: theme.quantityMenuStyle), ), ); }).toList(), @@ -77,19 +77,19 @@ class _VendorItem extends StatelessWidget { @override Widget build(BuildContext context) { final ShrineTheme theme = ShrineTheme.of(context); - return new Column( + return Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new SizedBox( + SizedBox( height: 24.0, - child: new Align( + child: Align( alignment: Alignment.bottomLeft, - child: new Text(vendor.name, style: theme.vendorTitleStyle), + child: Text(vendor.name, style: theme.vendorTitleStyle), ), ), const SizedBox(height: 16.0), - new Text(vendor.description, style: theme.vendorStyle), + Text(vendor.description, style: theme.vendorStyle), ], ); } @@ -110,26 +110,26 @@ class _HeadingLayout extends MultiChildLayoutDelegate { const double margin = 56.0; final bool landscape = size.width > size.height; final double imageWidth = (landscape ? size.width / 2.0 : size.width) - margin * 2.0; - final BoxConstraints imageConstraints = new BoxConstraints(maxHeight: 224.0, maxWidth: imageWidth); + final BoxConstraints imageConstraints = BoxConstraints(maxHeight: 224.0, maxWidth: imageWidth); final Size imageSize = layoutChild(image, imageConstraints); const double imageY = 0.0; positionChild(image, const Offset(margin, imageY)); final double productWidth = landscape ? size.width / 2.0 : size.width - margin; - final BoxConstraints productConstraints = new BoxConstraints(maxWidth: productWidth); + final BoxConstraints productConstraints = BoxConstraints(maxWidth: productWidth); final Size productSize = layoutChild(product, productConstraints); final double productX = landscape ? size.width / 2.0 : margin; final double productY = landscape ? 0.0 : imageY + imageSize.height + 16.0; - positionChild(product, new Offset(productX, productY)); + positionChild(product, Offset(productX, productY)); - final Size iconSize = layoutChild(icon, new BoxConstraints.loose(size)); - positionChild(icon, new Offset(productX - iconSize.width - 16.0, productY + 8.0)); + final Size iconSize = layoutChild(icon, BoxConstraints.loose(size)); + positionChild(icon, Offset(productX - iconSize.width - 16.0, productY + 8.0)); final double vendorWidth = landscape ? size.width - margin : productWidth; - layoutChild(vendor, new BoxConstraints(maxWidth: vendorWidth)); + layoutChild(vendor, BoxConstraints(maxWidth: vendorWidth)); final double vendorX = landscape ? margin : productX; final double vendorY = productY + productSize.height + 16.0; - positionChild(vendor, new Offset(vendorX, vendorY)); + positionChild(vendor, Offset(vendorX, vendorY)); } @override @@ -155,21 +155,21 @@ class _Heading extends StatelessWidget { @override Widget build(BuildContext context) { final Size screenSize = MediaQuery.of(context).size; - return new SizedBox( + return SizedBox( height: (screenSize.height - kToolbarHeight) * 1.35, - child: new Material( + child: Material( type: MaterialType.card, elevation: 0.0, - child: new Padding( + child: Padding( padding: const EdgeInsets.only(left: 16.0, top: 18.0, right: 16.0, bottom: 24.0), - child: new CustomMultiChildLayout( - delegate: new _HeadingLayout(), + child: CustomMultiChildLayout( + delegate: _HeadingLayout(), children: [ - new LayoutId( + LayoutId( id: _HeadingLayout.image, - child: new Hero( + child: Hero( tag: product.tag, - child: new Image.asset( + child: Image.asset( product.imageAsset, package: product.imageAssetPackage, fit: BoxFit.contain, @@ -177,7 +177,7 @@ class _Heading extends StatelessWidget { ), ), ), - new LayoutId( + LayoutId( id: _HeadingLayout.icon, child: const Icon( Icons.info_outline, @@ -185,17 +185,17 @@ class _Heading extends StatelessWidget { color: Color(0xFFFFE0E0), ), ), - new LayoutId( + LayoutId( id: _HeadingLayout.product, - child: new _ProductItem( + child: _ProductItem( product: product, quantity: quantity, onChanged: quantityChanged, ), ), - new LayoutId( + LayoutId( id: _HeadingLayout.vendor, - child: new _VendorItem(vendor: product.vendor), + child: _VendorItem(vendor: product.vendor), ), ], ), @@ -221,7 +221,7 @@ class OrderPage extends StatefulWidget { final Map shoppingCart; @override - _OrderPageState createState() => new _OrderPageState(); + _OrderPageState createState() => _OrderPageState(); } // Displays a product's heading above photos of all of the other products @@ -233,7 +233,7 @@ class _OrderPageState extends State { @override void initState() { super.initState(); - scaffoldKey = new GlobalKey(debugLabel: 'Shrine Order ${widget.order}'); + scaffoldKey = GlobalKey(debugLabel: 'Shrine Order ${widget.order}'); } Order get currentOrder => ShrineOrderRoute.of(context).order; @@ -253,16 +253,16 @@ class _OrderPageState extends State { } void showSnackBarMessage(String message) { - scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(message))); + scaffoldKey.currentState.showSnackBar(SnackBar(content: Text(message))); } @override Widget build(BuildContext context) { - return new ShrinePage( + return ShrinePage( scaffoldKey: scaffoldKey, products: widget.products, shoppingCart: widget.shoppingCart, - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( onPressed: () { updateOrder(inCart: true); final int n = currentOrder.quantity; @@ -277,31 +277,31 @@ class _OrderPageState extends State { color: Colors.black, ), ), - body: new CustomScrollView( + body: CustomScrollView( slivers: [ - new SliverToBoxAdapter( - child: new _Heading( + SliverToBoxAdapter( + child: _Heading( product: widget.order.product, quantity: currentOrder.quantity, quantityChanged: (int value) { updateOrder(quantity: value); }, ), ), - new SliverSafeArea( + SliverSafeArea( top: false, minimum: const EdgeInsets.fromLTRB(8.0, 32.0, 8.0, 8.0), - sliver: new SliverGrid( + sliver: SliverGrid( gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 248.0, mainAxisSpacing: 8.0, crossAxisSpacing: 8.0, ), - delegate: new SliverChildListDelegate( + delegate: SliverChildListDelegate( widget.products .where((Product product) => product != widget.order.product) .map((Product product) { - return new Card( + return Card( elevation: 1.0, - child: new Image.asset( + child: Image.asset( product.imageAsset, package: product.imageAssetPackage, fit: BoxFit.contain, diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart index f920f60899..b31cb3ddcc 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_page.dart @@ -32,7 +32,7 @@ class ShrinePage extends StatefulWidget { final Map shoppingCart; @override - ShrinePageState createState() => new ShrinePageState(); + ShrinePageState createState() => ShrinePageState(); } /// Defines the Scaffold, AppBar, etc that the demo pages have in common. @@ -57,13 +57,13 @@ class ShrinePageState extends State { child: Text('The shopping cart is empty') ); } - return new ListView( + return ListView( padding: kMaterialListPadding, children: widget.shoppingCart.values.map((Order order) { - return new ListTile( - title: new Text(order.product.name), - leading: new Text('${order.quantity}'), - subtitle: new Text(order.product.vendor.name) + return ListTile( + title: Text(order.product.name), + leading: Text('${order.quantity}'), + subtitle: Text(order.product.vendor.name) ); }).toList(), ); @@ -86,29 +86,29 @@ class ShrinePageState extends State { @override Widget build(BuildContext context) { final ShrineTheme theme = ShrineTheme.of(context); - return new Scaffold( + return Scaffold( key: widget.scaffoldKey, - appBar: new AppBar( + appBar: AppBar( elevation: _appBarElevation, backgroundColor: theme.appBarBackgroundColor, iconTheme: Theme.of(context).iconTheme, brightness: Brightness.light, - flexibleSpace: new Container( - decoration: new BoxDecoration( - border: new Border( - bottom: new BorderSide(color: theme.dividerColor) + flexibleSpace: Container( + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(color: theme.dividerColor) ) ) ), - title: new Text('SHRINE', style: ShrineTheme.of(context).appBarTitleStyle), + title: Text('SHRINE', style: ShrineTheme.of(context).appBarTitleStyle), centerTitle: true, actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.shopping_cart), tooltip: 'Shopping cart', onPressed: _showShoppingCart ), - new PopupMenuButton( + PopupMenuButton( itemBuilder: (BuildContext context) => >[ const PopupMenuItem( value: ShrineAction.sortByPrice, @@ -140,7 +140,7 @@ class ShrinePageState extends State { ] ), floatingActionButton: widget.floatingActionButton, - body: new NotificationListener( + body: NotificationListener( onNotification: _handleScrollNotification, child: widget.body ) diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_theme.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_theme.dart index c95b0f94a9..8e14634870 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_theme.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_theme.dart @@ -12,15 +12,15 @@ class ShrineStyle extends TextStyle { : super(inherit: false, color: color, fontFamily: 'AbrilFatface', fontSize: size, fontWeight: weight, textBaseline: TextBaseline.alphabetic); } -TextStyle robotoRegular12(Color color) => new ShrineStyle.roboto(12.0, FontWeight.w500, color); -TextStyle robotoLight12(Color color) => new ShrineStyle.roboto(12.0, FontWeight.w300, color); -TextStyle robotoRegular14(Color color) => new ShrineStyle.roboto(14.0, FontWeight.w500, color); -TextStyle robotoMedium14(Color color) => new ShrineStyle.roboto(14.0, FontWeight.w600, color); -TextStyle robotoLight14(Color color) => new ShrineStyle.roboto(14.0, FontWeight.w300, color); -TextStyle robotoRegular16(Color color) => new ShrineStyle.roboto(16.0, FontWeight.w500, color); -TextStyle robotoRegular20(Color color) => new ShrineStyle.roboto(20.0, FontWeight.w500, color); -TextStyle abrilFatfaceRegular24(Color color) => new ShrineStyle.abrilFatface(24.0, FontWeight.w500, color); -TextStyle abrilFatfaceRegular34(Color color) => new ShrineStyle.abrilFatface(34.0, FontWeight.w500, color); +TextStyle robotoRegular12(Color color) => ShrineStyle.roboto(12.0, FontWeight.w500, color); +TextStyle robotoLight12(Color color) => ShrineStyle.roboto(12.0, FontWeight.w300, color); +TextStyle robotoRegular14(Color color) => ShrineStyle.roboto(14.0, FontWeight.w500, color); +TextStyle robotoMedium14(Color color) => ShrineStyle.roboto(14.0, FontWeight.w600, color); +TextStyle robotoLight14(Color color) => ShrineStyle.roboto(14.0, FontWeight.w300, color); +TextStyle robotoRegular16(Color color) => ShrineStyle.roboto(16.0, FontWeight.w500, color); +TextStyle robotoRegular20(Color color) => ShrineStyle.roboto(20.0, FontWeight.w500, color); +TextStyle abrilFatfaceRegular24(Color color) => ShrineStyle.abrilFatface(24.0, FontWeight.w500, color); +TextStyle abrilFatfaceRegular34(Color color) => ShrineStyle.abrilFatface(34.0, FontWeight.w500, color); /// The TextStyles and Colors used for titles, labels, and descriptions. This /// InheritedWidget is shared by all of the routes and widgets created for diff --git a/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart b/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart index e87aebab78..884e64618e 100644 --- a/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart +++ b/examples/flutter_gallery/lib/demo/shrine/shrine_types.dart @@ -80,7 +80,7 @@ class Order { final bool inCart; Order copyWith({ Product product, int quantity, bool inCart }) { - return new Order( + return Order( product: product ?? this.product, quantity: quantity ?? this.quantity, inCart: inCart ?? this.inCart diff --git a/examples/flutter_gallery/lib/demo/shrine_demo.dart b/examples/flutter_gallery/lib/demo/shrine_demo.dart index cf21c63300..24cd2d8206 100644 --- a/examples/flutter_gallery/lib/demo/shrine_demo.dart +++ b/examples/flutter_gallery/lib/demo/shrine_demo.dart @@ -11,13 +11,13 @@ import 'shrine/shrine_theme.dart' show ShrineTheme; // used by the ShrineDemo and by each route pushed from there because this // isn't a standalone app with its own main() and MaterialApp. Widget buildShrine(BuildContext context, Widget child) { - return new Theme( - data: new ThemeData( + return Theme( + data: ThemeData( primarySwatch: Colors.grey, iconTheme: const IconThemeData(color: Color(0xFF707070)), platform: Theme.of(context).platform, ), - child: new ShrineTheme(child: child) + child: ShrineTheme(child: child) ); } @@ -38,5 +38,5 @@ class ShrineDemo extends StatelessWidget { static const String routeName = '/shrine'; // Used by the Gallery app. @override - Widget build(BuildContext context) => buildShrine(context, new ShrineHome()); + Widget build(BuildContext context) => buildShrine(context, ShrineHome()); } diff --git a/examples/flutter_gallery/lib/demo/typography_demo.dart b/examples/flutter_gallery/lib/demo/typography_demo.dart index 3a63ea3266..fd2013d520 100644 --- a/examples/flutter_gallery/lib/demo/typography_demo.dart +++ b/examples/flutter_gallery/lib/demo/typography_demo.dart @@ -23,17 +23,17 @@ class TextStyleItem extends StatelessWidget { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); final TextStyle nameStyle = theme.textTheme.caption.copyWith(color: theme.textTheme.caption.color); - return new Padding( + return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 16.0), - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new SizedBox( + SizedBox( width: 72.0, - child: new Text(name, style: nameStyle) + child: Text(name, style: nameStyle) ), - new Expanded( - child: new Text(text, style: style.copyWith(height: 1.0)) + Expanded( + child: Text(text, style: style.copyWith(height: 1.0)) ) ] ) @@ -48,32 +48,32 @@ class TypographyDemo extends StatelessWidget { Widget build(BuildContext context) { final TextTheme textTheme = Theme.of(context).textTheme; final List styleItems = [ - new TextStyleItem(name: 'Display 3', style: textTheme.display3, text: 'Regular 56sp'), - new TextStyleItem(name: 'Display 2', style: textTheme.display2, text: 'Regular 45sp'), - new TextStyleItem(name: 'Display 1', style: textTheme.display1, text: 'Regular 34sp'), - new TextStyleItem(name: 'Headline', style: textTheme.headline, text: 'Regular 24sp'), - new TextStyleItem(name: 'Title', style: textTheme.title, text: 'Medium 20sp'), - new TextStyleItem(name: 'Subheading', style: textTheme.subhead, text: 'Regular 16sp'), - new TextStyleItem(name: 'Body 2', style: textTheme.body2, text: 'Medium 14sp'), - new TextStyleItem(name: 'Body 1', style: textTheme.body1, text: 'Regular 14sp'), - new TextStyleItem(name: 'Caption', style: textTheme.caption, text: 'Regular 12sp'), - new TextStyleItem(name: 'Button', style: textTheme.button, text: 'MEDIUM (ALL CAPS) 14sp') + TextStyleItem(name: 'Display 3', style: textTheme.display3, text: 'Regular 56sp'), + TextStyleItem(name: 'Display 2', style: textTheme.display2, text: 'Regular 45sp'), + TextStyleItem(name: 'Display 1', style: textTheme.display1, text: 'Regular 34sp'), + TextStyleItem(name: 'Headline', style: textTheme.headline, text: 'Regular 24sp'), + TextStyleItem(name: 'Title', style: textTheme.title, text: 'Medium 20sp'), + TextStyleItem(name: 'Subheading', style: textTheme.subhead, text: 'Regular 16sp'), + TextStyleItem(name: 'Body 2', style: textTheme.body2, text: 'Medium 14sp'), + TextStyleItem(name: 'Body 1', style: textTheme.body1, text: 'Regular 14sp'), + TextStyleItem(name: 'Caption', style: textTheme.caption, text: 'Regular 12sp'), + TextStyleItem(name: 'Button', style: textTheme.button, text: 'MEDIUM (ALL CAPS) 14sp') ]; if (MediaQuery.of(context).size.width > 500.0) { - styleItems.insert(0, new TextStyleItem( + styleItems.insert(0, TextStyleItem( name: 'Display 4', style: textTheme.display4, text: 'Light 112sp' )); } - return new Scaffold( - appBar: new AppBar(title: const Text('Typography')), - body: new SafeArea( + return Scaffold( + appBar: AppBar(title: const Text('Typography')), + body: SafeArea( top: false, bottom: false, - child: new ListView(children: styleItems), + child: ListView(children: styleItems), ), ); } diff --git a/examples/flutter_gallery/lib/demo/video_demo.dart b/examples/flutter_gallery/lib/demo/video_demo.dart index 124e309c93..ef4b9ff28b 100644 --- a/examples/flutter_gallery/lib/demo/video_demo.dart +++ b/examples/flutter_gallery/lib/demo/video_demo.dart @@ -22,14 +22,14 @@ class VideoCard extends StatelessWidget { : super(key: key); Widget _buildInlineVideo() { - return new Padding( + return Padding( padding: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 30.0), - child: new Center( - child: new AspectRatio( + child: Center( + child: AspectRatio( aspectRatio: 3 / 2, - child: new Hero( + child: Hero( tag: controller, - child: new VideoPlayerLoading(controller), + child: VideoPlayerLoading(controller), ), ), ), @@ -37,16 +37,16 @@ class VideoCard extends StatelessWidget { } Widget _buildFullScreenVideo() { - return new Scaffold( - appBar: new AppBar( - title: new Text(title), + return Scaffold( + appBar: AppBar( + title: Text(title), ), - body: new Center( - child: new AspectRatio( + body: Center( + child: AspectRatio( aspectRatio: 3 / 2, - child: new Hero( + child: Hero( tag: controller, - child: new VideoPlayPause(controller), + child: VideoPlayPause(controller), ), ), ), @@ -61,8 +61,8 @@ class VideoCard extends StatelessWidget { } void pushFullScreenWidget() { - final TransitionRoute route = new PageRouteBuilder( - settings: new RouteSettings(name: title, isInitialRoute: false), + final TransitionRoute route = PageRouteBuilder( + settings: RouteSettings(name: title, isInitialRoute: false), pageBuilder: fullScreenRoutePageBuilder, ); @@ -74,14 +74,14 @@ class VideoCard extends StatelessWidget { Navigator.of(context).push(route); } - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Card( - child: new Column( + child: Card( + child: Column( children: [ - new ListTile(title: new Text(title), subtitle: new Text(subtitle)), - new GestureDetector( + ListTile(title: Text(title), subtitle: Text(subtitle)), + GestureDetector( onTap: pushFullScreenWidget, child: _buildInlineVideo(), ), @@ -98,7 +98,7 @@ class VideoPlayerLoading extends StatefulWidget { const VideoPlayerLoading(this.controller); @override - _VideoPlayerLoadingState createState() => new _VideoPlayerLoadingState(); + _VideoPlayerLoadingState createState() => _VideoPlayerLoadingState(); } class _VideoPlayerLoadingState extends State { @@ -124,11 +124,11 @@ class _VideoPlayerLoadingState extends State { @override Widget build(BuildContext context) { if (_initialized) { - return new VideoPlayer(widget.controller); + return VideoPlayer(widget.controller); } - return new Stack( + return Stack( children: [ - new VideoPlayer(widget.controller), + VideoPlayer(widget.controller), const Center(child: CircularProgressIndicator()), ], fit: StackFit.expand, @@ -142,7 +142,7 @@ class VideoPlayPause extends StatefulWidget { const VideoPlayPause(this.controller); @override - State createState() => new _VideoPlayPauseState(); + State createState() => _VideoPlayPauseState(); } class _VideoPlayPauseState extends State { @@ -172,12 +172,12 @@ class _VideoPlayPauseState extends State { @override Widget build(BuildContext context) { - return new Stack( + return Stack( alignment: Alignment.bottomCenter, fit: StackFit.expand, children: [ - new GestureDetector( - child: new VideoPlayerLoading(controller), + GestureDetector( + child: VideoPlayerLoading(controller), onTap: () { if (!controller.value.initialized) { return; @@ -195,7 +195,7 @@ class _VideoPlayPauseState extends State { } }, ), - new Center(child: imageFadeAnimation), + Center(child: imageFadeAnimation), ], ); } @@ -211,7 +211,7 @@ class FadeAnimation extends StatefulWidget { }); @override - _FadeAnimationState createState() => new _FadeAnimationState(); + _FadeAnimationState createState() => _FadeAnimationState(); } class _FadeAnimationState extends State @@ -221,7 +221,7 @@ class _FadeAnimationState extends State @override void initState() { super.initState(); - animationController = new AnimationController( + animationController = AnimationController( duration: widget.duration, vsync: this, ); @@ -256,11 +256,11 @@ class _FadeAnimationState extends State @override Widget build(BuildContext context) { return animationController.isAnimating - ? new Opacity( + ? Opacity( opacity: 1.0 - animationController.value, child: widget.child, ) - : new Container(); + : Container(); } } @@ -276,7 +276,7 @@ class ConnectivityOverlay extends StatefulWidget { }); @override - _ConnectivityOverlayState createState() => new _ConnectivityOverlayState(); + _ConnectivityOverlayState createState() => _ConnectivityOverlayState(); } class _ConnectivityOverlayState extends State { @@ -294,7 +294,7 @@ class _ConnectivityOverlayState extends State { ); Stream connectivityStream() async* { - final Connectivity connectivity = new Connectivity(); + final Connectivity connectivity = Connectivity(); ConnectivityResult previousResult = await connectivity.checkConnectivity(); yield previousResult; await for (ConnectivityResult result @@ -341,10 +341,10 @@ class VideoDemo extends StatefulWidget { static const String routeName = '/video'; @override - _VideoDemoState createState() => new _VideoDemoState(); + _VideoDemoState createState() => _VideoDemoState(); } -final DeviceInfoPlugin deviceInfoPlugin = new DeviceInfoPlugin(); +final DeviceInfoPlugin deviceInfoPlugin = DeviceInfoPlugin(); Future isIOSSimulator() async { return Platform.isIOS && !(await deviceInfoPlugin.iosInfo).isPhysicalDevice; @@ -353,16 +353,16 @@ Future isIOSSimulator() async { class _VideoDemoState extends State with SingleTickerProviderStateMixin { final VideoPlayerController butterflyController = - new VideoPlayerController.asset( + VideoPlayerController.asset( 'videos/butterfly.mp4', package: 'flutter_gallery_assets', ); - final VideoPlayerController beeController = new VideoPlayerController.network( + final VideoPlayerController beeController = VideoPlayerController.network( beeUri, ); - final GlobalKey scaffoldKey = new GlobalKey(); - final Completer connectedCompleter = new Completer(); + final GlobalKey scaffoldKey = GlobalKey(); + final Completer connectedCompleter = Completer(); bool isSupported = true; @override @@ -395,21 +395,21 @@ class _VideoDemoState extends State @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: scaffoldKey, - appBar: new AppBar( + appBar: AppBar( title: const Text('Videos'), ), body: isSupported - ? new ConnectivityOverlay( - child: new ListView( + ? ConnectivityOverlay( + child: ListView( children: [ - new VideoCard( + VideoCard( title: 'Butterfly', subtitle: '… flutters by', controller: butterflyController, ), - new VideoCard( + VideoCard( title: 'Bee', subtitle: '… gently buzzing', controller: beeController, diff --git a/examples/flutter_gallery/lib/gallery/about.dart b/examples/flutter_gallery/lib/gallery/about.dart index 141d7b3064..7a09a20cf9 100644 --- a/examples/flutter_gallery/lib/gallery/about.dart +++ b/examples/flutter_gallery/lib/gallery/about.dart @@ -26,7 +26,7 @@ class _LinkTextSpan extends TextSpan { _LinkTextSpan({ TextStyle style, String url, String text }) : super( style: style, text: text ?? url, - recognizer: new TapGestureRecognizer()..onTap = () { + recognizer: TapGestureRecognizer()..onTap = () { launch(url, forceSafariVC: false); } ); @@ -43,12 +43,12 @@ void showGalleryAboutDialog(BuildContext context) { applicationIcon: const FlutterLogo(), applicationLegalese: '© 2017 The Chromium Authors', children: [ - new Padding( + Padding( padding: const EdgeInsets.only(top: 24.0), - child: new RichText( - text: new TextSpan( + child: RichText( + text: TextSpan( children: [ - new TextSpan( + TextSpan( style: aboutTextStyle, text: 'Flutter is an early-stage, open-source project to help developers ' 'build high-performance, high-fidelity, mobile apps for ' @@ -57,20 +57,20 @@ void showGalleryAboutDialog(BuildContext context) { "Flutter's many widgets, behaviors, animations, layouts, " 'and more. Learn more about Flutter at ' ), - new _LinkTextSpan( + _LinkTextSpan( style: linkStyle, url: 'https://flutter.io', ), - new TextSpan( + TextSpan( style: aboutTextStyle, text: '.\n\nTo see the source code for this app, please visit the ', ), - new _LinkTextSpan( + _LinkTextSpan( style: linkStyle, url: 'https://goo.gl/iv1p4G', text: 'flutter github repo', ), - new TextSpan( + TextSpan( style: aboutTextStyle, text: '.', ), diff --git a/examples/flutter_gallery/lib/gallery/app.dart b/examples/flutter_gallery/lib/gallery/app.dart index 8eba99612b..f1c6d7129d 100644 --- a/examples/flutter_gallery/lib/gallery/app.dart +++ b/examples/flutter_gallery/lib/gallery/app.dart @@ -36,7 +36,7 @@ class GalleryApp extends StatefulWidget { final bool testMode; @override - _GalleryAppState createState() => new _GalleryAppState(); + _GalleryAppState createState() => _GalleryAppState(); } class _GalleryAppState extends State { @@ -47,7 +47,7 @@ class _GalleryAppState extends State { // For a different example of how to set up an application routing table // using named routes, consider the example in the Navigator class documentation: // https://docs.flutter.io/flutter/widgets/Navigator-class.html - return new Map.fromIterable( + return Map.fromIterable( kAllGalleryDemos, key: (dynamic demo) => '${demo.routeName}', value: (dynamic demo) => demo.buildRoute, @@ -57,7 +57,7 @@ class _GalleryAppState extends State { @override void initState() { super.initState(); - _options = new GalleryOptions( + _options = GalleryOptions( theme: kLightGalleryTheme, textScaleFactor: kAllGalleryTextScaleValues[0], timeDilation: timeDilation, @@ -81,7 +81,7 @@ class _GalleryAppState extends State { // We delay the time dilation change long enough that the user can see // that UI has started reacting and then we slam on the brakes so that // they see that the time is in fact now dilated. - _timeDilationTimer = new Timer(const Duration(milliseconds: 150), () { + _timeDilationTimer = Timer(const Duration(milliseconds: 150), () { timeDilation = newOptions.timeDilation; }); } else { @@ -94,9 +94,9 @@ class _GalleryAppState extends State { } Widget _applyTextScaleFactor(Widget child) { - return new Builder( + return Builder( builder: (BuildContext context) { - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith( textScaleFactor: _options.textScaleFactor.scale, ), @@ -108,9 +108,9 @@ class _GalleryAppState extends State { @override Widget build(BuildContext context) { - Widget home = new GalleryHome( + Widget home = GalleryHome( testMode: widget.testMode, - optionsPage: new GalleryOptionsPage( + optionsPage: GalleryOptionsPage( options: _options, onOptionsChanged: _handleOptionsChanged, onSendFeedback: widget.onSendFeedback ?? () { @@ -120,13 +120,13 @@ class _GalleryAppState extends State { ); if (widget.updateUrlFetcher != null) { - home = new Updater( + home = Updater( updateUrlFetcher: widget.updateUrlFetcher, child: home, ); } - return new MaterialApp( + return MaterialApp( theme: _options.theme.data.copyWith(platform: _options.platform), title: 'Flutter Gallery', color: Colors.grey, @@ -135,7 +135,7 @@ class _GalleryAppState extends State { checkerboardRasterCacheImages: _options.showRasterCacheImagesCheckerboard, routes: _buildRoutes(), builder: (BuildContext context, Widget child) { - return new Directionality( + return Directionality( textDirection: _options.textDirection, child: _applyTextScaleFactor(child), ); diff --git a/examples/flutter_gallery/lib/gallery/backdrop.dart b/examples/flutter_gallery/lib/gallery/backdrop.dart index cea460bd53..92074f604e 100644 --- a/examples/flutter_gallery/lib/gallery/backdrop.dart +++ b/examples/flutter_gallery/lib/gallery/backdrop.dart @@ -12,7 +12,7 @@ const double _kFrontClosedHeight = 92.0; // front layer height when closed const double _kBackAppBarHeight = 56.0; // back layer (options) appbar height // The size of the front layer heading's left and right beveled corners. -final Tween _kFrontHeadingBevelRadius = new BorderRadiusTween( +final Tween _kFrontHeadingBevelRadius = BorderRadiusTween( begin: const BorderRadius.only( topLeft: Radius.circular(12.0), topRight: Radius.circular(12.0), @@ -35,7 +35,7 @@ class _TappableWhileStatusIs extends StatefulWidget { final Widget child; @override - _TappableWhileStatusIsState createState() => new _TappableWhileStatusIsState(); + _TappableWhileStatusIsState createState() => _TappableWhileStatusIsState(); } class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { @@ -65,7 +65,7 @@ class _TappableWhileStatusIsState extends State<_TappableWhileStatusIs> { @override Widget build(BuildContext context) { - return new AbsorbPointer( + return AbsorbPointer( absorbing: !_active, child: widget.child, ); @@ -89,30 +89,30 @@ class _CrossFadeTransition extends AnimatedWidget { Widget build(BuildContext context) { final Animation progress = listenable; - final double opacity1 = new CurvedAnimation( - parent: new ReverseAnimation(progress), + final double opacity1 = CurvedAnimation( + parent: ReverseAnimation(progress), curve: const Interval(0.5, 1.0), ).value; - final double opacity2 = new CurvedAnimation( + final double opacity2 = CurvedAnimation( parent: progress, curve: const Interval(0.5, 1.0), ).value; - return new Stack( + return Stack( alignment: alignment, children: [ - new Opacity( + Opacity( opacity: opacity1, - child: new Semantics( + child: Semantics( scopesRoute: true, explicitChildNodes: true, child: child1, ), ), - new Opacity( + Opacity( opacity: opacity2, - child: new Semantics( + child: Semantics( scopesRoute: true, explicitChildNodes: true, child: child0, @@ -138,19 +138,19 @@ class _BackAppBar extends StatelessWidget { @override Widget build(BuildContext context) { final List children = [ - new Container( + Container( alignment: Alignment.center, width: 56.0, child: leading, ), - new Expanded( + Expanded( child: title, ), ]; if (trailing != null) { children.add( - new Container( + Container( alignment: Alignment.center, width: 56.0, child: trailing, @@ -162,11 +162,11 @@ class _BackAppBar extends StatelessWidget { return IconTheme.merge( data: theme.primaryIconTheme, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: theme.primaryTextTheme.title, - child: new SizedBox( + child: SizedBox( height: _kBackAppBarHeight, - child: new Row(children: children), + child: Row(children: children), ), ), ); @@ -191,26 +191,26 @@ class Backdrop extends StatefulWidget { final Widget backLayer; @override - _BackdropState createState() => new _BackdropState(); + _BackdropState createState() => _BackdropState(); } class _BackdropState extends State with SingleTickerProviderStateMixin { - final GlobalKey _backdropKey = new GlobalKey(debugLabel: 'Backdrop'); + final GlobalKey _backdropKey = GlobalKey(debugLabel: 'Backdrop'); AnimationController _controller; Animation _frontOpacity; @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(milliseconds: 300), value: 1.0, vsync: this, ); _frontOpacity = - new Tween(begin: 0.2, end: 1.0).animate( - new CurvedAnimation( + Tween(begin: 0.2, end: 1.0).animate( + CurvedAnimation( parent: _controller, curve: const Interval(0.0, 0.4, curve: Curves.easeInOut), ), @@ -254,35 +254,35 @@ class _BackdropState extends State with SingleTickerProviderStateMixin } Widget _buildStack(BuildContext context, BoxConstraints constraints) { - final Animation frontRelativeRect = new RelativeRectTween( - begin: new RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0), + final Animation frontRelativeRect = RelativeRectTween( + begin: RelativeRect.fromLTRB(0.0, constraints.biggest.height - _kFrontClosedHeight, 0.0, 0.0), end: const RelativeRect.fromLTRB(0.0, _kBackAppBarHeight, 0.0, 0.0), ).animate(_controller); final List layers = [ // Back layer - new Column( + Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new _BackAppBar( + _BackAppBar( leading: widget.frontAction, - title: new _CrossFadeTransition( + title: _CrossFadeTransition( progress: _controller, alignment: AlignmentDirectional.centerStart, - child0: new Semantics(namesRoute: true, child: widget.frontTitle), - child1: new Semantics(namesRoute: true, child: widget.backTitle), + child0: Semantics(namesRoute: true, child: widget.frontTitle), + child1: Semantics(namesRoute: true, child: widget.backTitle), ), - trailing: new IconButton( + trailing: IconButton( onPressed: _toggleFrontLayer, tooltip: 'Toggle options page', - icon: new AnimatedIcon( + icon: AnimatedIcon( icon: AnimatedIcons.close_menu, progress: _controller, ), ), ), - new Expanded( - child: new Visibility( + Expanded( + child: Visibility( child: widget.backLayer, visible: _controller.status != AnimationStatus.completed, maintainState: true, @@ -291,16 +291,16 @@ class _BackdropState extends State with SingleTickerProviderStateMixin ], ), // Front layer - new PositionedTransition( + PositionedTransition( rect: frontRelativeRect, - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: _controller, builder: (BuildContext context, Widget child) { - return new PhysicalShape( + return PhysicalShape( elevation: 12.0, color: Theme.of(context).canvasColor, - clipper: new ShapeBorderClipper( - shape: new BeveledRectangleBorder( + clipper: ShapeBorderClipper( + shape: BeveledRectangleBorder( borderRadius: _kFrontHeadingBevelRadius.lerp(_controller.value), ), ), @@ -308,10 +308,10 @@ class _BackdropState extends State with SingleTickerProviderStateMixin child: child, ); }, - child: new _TappableWhileStatusIs( + child: _TappableWhileStatusIs( AnimationStatus.completed, controller: _controller, - child: new FadeTransition( + child: FadeTransition( opacity: _frontOpacity, child: widget.frontLayer, ), @@ -326,12 +326,12 @@ class _BackdropState extends State with SingleTickerProviderStateMixin // with a tap. It may obscure part of the front layer's topmost child. if (widget.frontHeading != null) { layers.add( - new PositionedTransition( + PositionedTransition( rect: frontRelativeRect, - child: new ExcludeSemantics( - child: new Container( + child: ExcludeSemantics( + child: Container( alignment: Alignment.topLeft, - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: _toggleFrontLayer, onVerticalDragUpdate: _handleDragUpdate, @@ -344,7 +344,7 @@ class _BackdropState extends State with SingleTickerProviderStateMixin ); } - return new Stack( + return Stack( key: _backdropKey, children: layers, ); @@ -352,6 +352,6 @@ class _BackdropState extends State with SingleTickerProviderStateMixin @override Widget build(BuildContext context) { - return new LayoutBuilder(builder: _buildStack); + return LayoutBuilder(builder: _buildStack); } } diff --git a/examples/flutter_gallery/lib/gallery/demo.dart b/examples/flutter_gallery/lib/gallery/demo.dart index 40424a63a0..67cc019c46 100644 --- a/examples/flutter_gallery/lib/gallery/demo.dart +++ b/examples/flutter_gallery/lib/gallery/demo.dart @@ -46,24 +46,24 @@ class TabbedComponentDemoScaffold extends StatelessWidget { void _showExampleCode(BuildContext context) { final String tag = demos[DefaultTabController.of(context).index].exampleCodeTag; if (tag != null) { - Navigator.push(context, new MaterialPageRoute( - builder: (BuildContext context) => new FullScreenCodeDialog(exampleCodeTag: tag) + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) => FullScreenCodeDialog(exampleCodeTag: tag) )); } } @override Widget build(BuildContext context) { - return new DefaultTabController( + return DefaultTabController( length: demos.length, - child: new Scaffold( - appBar: new AppBar( - title: new Text(title), + child: Scaffold( + appBar: AppBar( + title: Text(title), actions: (actions ?? [])..addAll( [ - new Builder( + Builder( builder: (BuildContext context) { - return new IconButton( + return IconButton( icon: const Icon(Icons.code), tooltip: 'Show example code', onPressed: () { @@ -74,25 +74,25 @@ class TabbedComponentDemoScaffold extends StatelessWidget { ) ], ), - bottom: new TabBar( + bottom: TabBar( isScrollable: true, - tabs: demos.map((ComponentDemoTabData data) => new Tab(text: data.tabName)).toList(), + tabs: demos.map((ComponentDemoTabData data) => Tab(text: data.tabName)).toList(), ), ), - body: new TabBarView( + body: TabBarView( children: demos.map((ComponentDemoTabData demo) { - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Column( + child: Column( children: [ - new Padding( + Padding( padding: const EdgeInsets.all(16.0), - child: new Text(demo.description, + child: Text(demo.description, style: Theme.of(context).textTheme.subhead ) ), - new Expanded(child: demo.demoWidget) + Expanded(child: demo.demoWidget) ], ), ); @@ -109,7 +109,7 @@ class FullScreenCodeDialog extends StatefulWidget { final String exampleCodeTag; @override - FullScreenCodeDialogState createState() => new FullScreenCodeDialogState(); + FullScreenCodeDialogState createState() => FullScreenCodeDialogState(); } class FullScreenCodeDialogState extends State { @@ -140,14 +140,14 @@ class FullScreenCodeDialogState extends State { child: CircularProgressIndicator() ); } else { - body = new SingleChildScrollView( - child: new Padding( + body = SingleChildScrollView( + child: Padding( padding: const EdgeInsets.all(16.0), - child: new RichText( - text: new TextSpan( + child: RichText( + text: TextSpan( style: const TextStyle(fontFamily: 'monospace', fontSize: 10.0), children: [ - new DartSyntaxHighlighter(style).format(_exampleCode) + DartSyntaxHighlighter(style).format(_exampleCode) ] ) ) @@ -155,9 +155,9 @@ class FullScreenCodeDialogState extends State { ); } - return new Scaffold( - appBar: new AppBar( - leading: new IconButton( + return Scaffold( + appBar: AppBar( + leading: IconButton( icon: const Icon( Icons.clear, semanticLabel: 'Close', diff --git a/examples/flutter_gallery/lib/gallery/demos.dart b/examples/flutter_gallery/lib/gallery/demos.dart index 338efa36fb..ee7eeea021 100644 --- a/examples/flutter_gallery/lib/gallery/demos.dart +++ b/examples/flutter_gallery/lib/gallery/demos.dart @@ -85,23 +85,23 @@ class GalleryDemo { List _buildGalleryDemos() { final List galleryDemos = [ // Demos - new GalleryDemo( + GalleryDemo( title: 'Shrine', subtitle: 'Basic shopping app', icon: GalleryIcons.shrine, category: _kDemos, routeName: ShrineDemo.routeName, - buildRoute: (BuildContext context) => new ShrineDemo(), + buildRoute: (BuildContext context) => ShrineDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Contact profile', subtitle: 'Address book entry with a flexible appbar', icon: GalleryIcons.account_box, category: _kDemos, routeName: ContactsDemo.routeName, - buildRoute: (BuildContext context) => new ContactsDemo(), + buildRoute: (BuildContext context) => ContactsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Animation', subtitle: 'Section organizer', icon: GalleryIcons.animation, @@ -111,138 +111,138 @@ List _buildGalleryDemos() { ), // Style - new GalleryDemo( + GalleryDemo( title: 'Colors', subtitle: 'All of the predefined colors', icon: GalleryIcons.colors, category: _kStyle, routeName: ColorsDemo.routeName, - buildRoute: (BuildContext context) => new ColorsDemo(), + buildRoute: (BuildContext context) => ColorsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Typography', subtitle: 'All of the predefined text styles', icon: GalleryIcons.custom_typography, category: _kStyle, routeName: TypographyDemo.routeName, - buildRoute: (BuildContext context) => new TypographyDemo(), + buildRoute: (BuildContext context) => TypographyDemo(), ), // Material Components - new GalleryDemo( + GalleryDemo( title: 'Backdrop', subtitle: 'Select a front layer from back layer', icon: GalleryIcons.backdrop, category: _kMaterialComponents, routeName: BackdropDemo.routeName, - buildRoute: (BuildContext context) => new BackdropDemo(), + buildRoute: (BuildContext context) => BackdropDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Bottom app bar', subtitle: 'Optional floating action button notch', icon: GalleryIcons.bottom_app_bar, category: _kMaterialComponents, routeName: BottomAppBarDemo.routeName, - buildRoute: (BuildContext context) => new BottomAppBarDemo(), + buildRoute: (BuildContext context) => BottomAppBarDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Bottom navigation', subtitle: 'Bottom navigation with cross-fading views', icon: GalleryIcons.bottom_navigation, category: _kMaterialComponents, routeName: BottomNavigationDemo.routeName, - buildRoute: (BuildContext context) => new BottomNavigationDemo(), + buildRoute: (BuildContext context) => BottomNavigationDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Bottom sheet: Modal', subtitle: 'A dismissable bottom sheet', icon: GalleryIcons.bottom_sheets, category: _kMaterialComponents, routeName: ModalBottomSheetDemo.routeName, - buildRoute: (BuildContext context) => new ModalBottomSheetDemo(), + buildRoute: (BuildContext context) => ModalBottomSheetDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Bottom sheet: Persistent', subtitle: 'A bottom sheet that sticks around', icon: GalleryIcons.bottom_sheet_persistent, category: _kMaterialComponents, routeName: PersistentBottomSheetDemo.routeName, - buildRoute: (BuildContext context) => new PersistentBottomSheetDemo(), + buildRoute: (BuildContext context) => PersistentBottomSheetDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Buttons', subtitle: 'Flat, raised, dropdown, and more', icon: GalleryIcons.generic_buttons, category: _kMaterialComponents, routeName: ButtonsDemo.routeName, - buildRoute: (BuildContext context) => new ButtonsDemo(), + buildRoute: (BuildContext context) => ButtonsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Buttons: Floating Action Button', subtitle: 'FAB with transitions', icon: GalleryIcons.buttons, category: _kMaterialComponents, routeName: TabsFabDemo.routeName, - buildRoute: (BuildContext context) => new TabsFabDemo(), + buildRoute: (BuildContext context) => TabsFabDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Cards', subtitle: 'Baseline cards with rounded corners', icon: GalleryIcons.cards, category: _kMaterialComponents, routeName: CardsDemo.routeName, - buildRoute: (BuildContext context) => new CardsDemo(), + buildRoute: (BuildContext context) => CardsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Chips', subtitle: 'Labeled with delete buttons and avatars', icon: GalleryIcons.chips, category: _kMaterialComponents, routeName: ChipDemo.routeName, - buildRoute: (BuildContext context) => new ChipDemo(), + buildRoute: (BuildContext context) => ChipDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Data tables', subtitle: 'Rows and columns', icon: GalleryIcons.data_table, category: _kMaterialComponents, routeName: DataTableDemo.routeName, - buildRoute: (BuildContext context) => new DataTableDemo(), + buildRoute: (BuildContext context) => DataTableDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Dialogs', subtitle: 'Simple, alert, and fullscreen', icon: GalleryIcons.dialogs, category: _kMaterialComponents, routeName: DialogDemo.routeName, - buildRoute: (BuildContext context) => new DialogDemo(), + buildRoute: (BuildContext context) => DialogDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Elevations', subtitle: 'Shadow values on cards', // TODO(larche): Change to custom icon for elevations when one exists. icon: GalleryIcons.cupertino_progress, category: _kMaterialComponents, routeName: ElevationDemo.routeName, - buildRoute: (BuildContext context) => new ElevationDemo(), + buildRoute: (BuildContext context) => ElevationDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Expand/collapse list control', subtitle: 'A list with one sub-list level', icon: GalleryIcons.expand_all, category: _kMaterialComponents, routeName: TwoLevelListDemo.routeName, - buildRoute: (BuildContext context) => new TwoLevelListDemo(), + buildRoute: (BuildContext context) => TwoLevelListDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Expansion panels', subtitle: 'List of expanding panels', icon: GalleryIcons.expand_all, category: _kMaterialComponents, routeName: ExpansionPanelsDemo.routeName, - buildRoute: (BuildContext context) => new ExpansionPanelsDemo(), + buildRoute: (BuildContext context) => ExpansionPanelsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Grid', subtitle: 'Row and column layout', icon: GalleryIcons.grid_on, @@ -250,15 +250,15 @@ List _buildGalleryDemos() { routeName: GridListDemo.routeName, buildRoute: (BuildContext context) => const GridListDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Icons', subtitle: 'Enabled and disabled icons with opacity', icon: GalleryIcons.sentiment_very_satisfied, category: _kMaterialComponents, routeName: IconsDemo.routeName, - buildRoute: (BuildContext context) => new IconsDemo(), + buildRoute: (BuildContext context) => IconsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Lists', subtitle: 'Scrolling list layouts', icon: GalleryIcons.list_alt, @@ -266,7 +266,7 @@ List _buildGalleryDemos() { routeName: ListDemo.routeName, buildRoute: (BuildContext context) => const ListDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Lists: leave-behind list items', subtitle: 'List items with hidden actions', icon: GalleryIcons.lists_leave_behind, @@ -274,7 +274,7 @@ List _buildGalleryDemos() { routeName: LeaveBehindDemo.routeName, buildRoute: (BuildContext context) => const LeaveBehindDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Lists: reorderable', subtitle: 'Reorderable lists', icon: GalleryIcons.list_alt, @@ -282,7 +282,7 @@ List _buildGalleryDemos() { routeName: ReorderableListDemo.routeName, buildRoute: (BuildContext context) => const ReorderableListDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Menus', subtitle: 'Menu buttons and simple menus', icon: GalleryIcons.more_vert, @@ -290,39 +290,39 @@ List _buildGalleryDemos() { routeName: MenuDemo.routeName, buildRoute: (BuildContext context) => const MenuDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Navigation drawer', subtitle: 'Navigation drawer with standard header', icon: GalleryIcons.menu, category: _kMaterialComponents, routeName: DrawerDemo.routeName, - buildRoute: (BuildContext context) => new DrawerDemo(), + buildRoute: (BuildContext context) => DrawerDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Pagination', subtitle: 'PageView with indicator', icon: GalleryIcons.page_control, category: _kMaterialComponents, routeName: PageSelectorDemo.routeName, - buildRoute: (BuildContext context) => new PageSelectorDemo(), + buildRoute: (BuildContext context) => PageSelectorDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Pickers', subtitle: 'Date and time selection widgets', icon: GalleryIcons.event, category: _kMaterialComponents, routeName: DateAndTimePickerDemo.routeName, - buildRoute: (BuildContext context) => new DateAndTimePickerDemo(), + buildRoute: (BuildContext context) => DateAndTimePickerDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Progress indicators', subtitle: 'Linear, circular, indeterminate', icon: GalleryIcons.progress_activity, category: _kMaterialComponents, routeName: ProgressIndicatorDemo.routeName, - buildRoute: (BuildContext context) => new ProgressIndicatorDemo(), + buildRoute: (BuildContext context) => ProgressIndicatorDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Pull to refresh', subtitle: 'Refresh indicators', icon: GalleryIcons.refresh, @@ -330,31 +330,31 @@ List _buildGalleryDemos() { routeName: OverscrollDemo.routeName, buildRoute: (BuildContext context) => const OverscrollDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Search', subtitle: 'Expandable search', icon: Icons.search, category: _kMaterialComponents, routeName: SearchDemo.routeName, - buildRoute: (BuildContext context) => new SearchDemo(), + buildRoute: (BuildContext context) => SearchDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Selection controls', subtitle: 'Checkboxes, radio buttons, and switches', icon: GalleryIcons.check_box, category: _kMaterialComponents, routeName: SelectionControlsDemo.routeName, - buildRoute: (BuildContext context) => new SelectionControlsDemo(), + buildRoute: (BuildContext context) => SelectionControlsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Sliders', subtitle: 'Widgets for selecting a value by swiping', icon: GalleryIcons.sliders, category: _kMaterialComponents, routeName: SliderDemo.routeName, - buildRoute: (BuildContext context) => new SliderDemo(), + buildRoute: (BuildContext context) => SliderDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Snackbar', subtitle: 'Temporary messaging', icon: GalleryIcons.snackbar, @@ -362,23 +362,23 @@ List _buildGalleryDemos() { routeName: SnackBarDemo.routeName, buildRoute: (BuildContext context) => const SnackBarDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Tabs', subtitle: 'Tabs with independently scrollable views', icon: GalleryIcons.tabs, category: _kMaterialComponents, routeName: TabsDemo.routeName, - buildRoute: (BuildContext context) => new TabsDemo(), + buildRoute: (BuildContext context) => TabsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Tabs: Scrolling', subtitle: 'Tab bar that scrolls', category: _kMaterialComponents, icon: GalleryIcons.tabs, routeName: ScrollableTabsDemo.routeName, - buildRoute: (BuildContext context) => new ScrollableTabsDemo(), + buildRoute: (BuildContext context) => ScrollableTabsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Text fields', subtitle: 'Single line of editable text and numbers', icon: GalleryIcons.text_fields_alt, @@ -386,90 +386,90 @@ List _buildGalleryDemos() { routeName: TextFormFieldDemo.routeName, buildRoute: (BuildContext context) => const TextFormFieldDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Tooltips', subtitle: 'Short message displayed on long-press', icon: GalleryIcons.tooltip, category: _kMaterialComponents, routeName: TooltipDemo.routeName, - buildRoute: (BuildContext context) => new TooltipDemo(), + buildRoute: (BuildContext context) => TooltipDemo(), ), // Cupertino Components - new GalleryDemo( + GalleryDemo( title: 'Activity Indicator', icon: GalleryIcons.cupertino_progress, category: _kCupertinoComponents, routeName: CupertinoProgressIndicatorDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoProgressIndicatorDemo(), + buildRoute: (BuildContext context) => CupertinoProgressIndicatorDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Alerts', icon: GalleryIcons.dialogs, category: _kCupertinoComponents, routeName: CupertinoAlertDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoAlertDemo(), + buildRoute: (BuildContext context) => CupertinoAlertDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Buttons', icon: GalleryIcons.generic_buttons, category: _kCupertinoComponents, routeName: CupertinoButtonsDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoButtonsDemo(), + buildRoute: (BuildContext context) => CupertinoButtonsDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Navigation', icon: GalleryIcons.bottom_navigation, category: _kCupertinoComponents, routeName: CupertinoNavigationDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoNavigationDemo(), + buildRoute: (BuildContext context) => CupertinoNavigationDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Pickers', icon: GalleryIcons.event, category: _kCupertinoComponents, routeName: CupertinoPickerDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoPickerDemo(), + buildRoute: (BuildContext context) => CupertinoPickerDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Pull to refresh', icon: GalleryIcons.cupertino_pull_to_refresh, category: _kCupertinoComponents, routeName: CupertinoRefreshControlDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoRefreshControlDemo(), + buildRoute: (BuildContext context) => CupertinoRefreshControlDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Segmented Control', icon: GalleryIcons.tabs, category: _kCupertinoComponents, routeName: CupertinoSegmentedControlDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoSegmentedControlDemo(), + buildRoute: (BuildContext context) => CupertinoSegmentedControlDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Sliders', icon: GalleryIcons.sliders, category: _kCupertinoComponents, routeName: CupertinoSliderDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoSliderDemo(), + buildRoute: (BuildContext context) => CupertinoSliderDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Switches', icon: GalleryIcons.cupertino_switch, category: _kCupertinoComponents, routeName: CupertinoSwitchDemo.routeName, - buildRoute: (BuildContext context) => new CupertinoSwitchDemo(), + buildRoute: (BuildContext context) => CupertinoSwitchDemo(), ), // Media - new GalleryDemo( + GalleryDemo( title: 'Animated images', subtitle: 'GIF and WebP animations', icon: GalleryIcons.animation, category: _kMedia, routeName: ImagesDemo.routeName, - buildRoute: (BuildContext context) => new ImagesDemo(), + buildRoute: (BuildContext context) => ImagesDemo(), ), - new GalleryDemo( + GalleryDemo( title: 'Video', subtitle: 'Video playback', icon: GalleryIcons.drive_video, @@ -483,7 +483,7 @@ List _buildGalleryDemos() { // in (release builds) the performance tests. assert(() { galleryDemos.insert(0, - new GalleryDemo( + GalleryDemo( title: 'Pesto', subtitle: 'Simple recipe browser', icon: Icons.adjust, @@ -504,7 +504,7 @@ final Set kAllGalleryDemoCategories = kAllGalleryDemos.map((GalleryDemo demo) => demo.category).toSet(); final Map> kGalleryCategoryToDemos = - new Map>.fromIterable( + Map>.fromIterable( kAllGalleryDemoCategories, value: (dynamic category) { return kAllGalleryDemos.where((GalleryDemo demo) => demo.category == category).toList(); diff --git a/examples/flutter_gallery/lib/gallery/example_code.dart b/examples/flutter_gallery/lib/gallery/example_code.dart index c4de62ec91..595b149f9a 100644 --- a/examples/flutter_gallery/lib/gallery/example_code.dart +++ b/examples/flutter_gallery/lib/gallery/example_code.dart @@ -15,7 +15,7 @@ class ButtonsDemo { // START buttons_raised // Create a raised button. -new RaisedButton( +RaisedButton( child: const Text('BUTTON TITLE'), onPressed: () { // Perform some action @@ -32,7 +32,7 @@ const RaisedButton( // Create a button with an icon and a // title. -new RaisedButton.icon( +RaisedButton.icon( icon: const Icon(Icons.add, size: 18.0), label: const Text('BUTTON TITLE'), onPressed: () { @@ -43,7 +43,7 @@ new RaisedButton.icon( // START buttons_outline // Create an outline button. -new OutlineButton( +OutlineButton( child: const Text('BUTTON TITLE'), onPressed: () { // Perform some action @@ -60,7 +60,7 @@ const OutlineButton( // Create a button with an icon and a // title. -new OutlineButton.icon( +OutlineButton.icon( icon: const Icon(Icons.add, size: 18.0), label: const Text('BUTTON TITLE'), onPressed: () { @@ -71,7 +71,7 @@ new OutlineButton.icon( // START buttons_flat // Create a flat button. -new FlatButton( +FlatButton( child: const Text('BUTTON TITLE'), onPressed: () { // Perform some action @@ -93,7 +93,7 @@ const FlatButton( String dropdownValue; // Dropdown button with string values. -new DropdownButton( +DropdownButton( value: dropdownValue, onChanged: (String newValue) { // null indicates the user didn't select a @@ -105,9 +105,9 @@ new DropdownButton( }, items: ['One', 'Two', 'Free', 'Four'] .map((String value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Text(value)); + child: Text(value)); }) .toList() ); @@ -119,7 +119,7 @@ new DropdownButton( bool value; // Toggleable icon button. -new IconButton( +IconButton( icon: const Icon(Icons.thumb_up), onPressed: () { setState(() => value = !value); @@ -131,8 +131,8 @@ new IconButton( // START buttons_action // Floating action button in Scaffold. -new Scaffold( - appBar: new AppBar( +Scaffold( + appBar: AppBar( title: const Text('Demo') ), floatingActionButton: const FloatingActionButton( @@ -155,7 +155,7 @@ class SelectionControls { bool checkboxValue = false; // Create a checkbox. -new Checkbox( +Checkbox( value: checkboxValue, onChanged: (bool value) { setState(() { @@ -165,7 +165,7 @@ new Checkbox( ); // Create a tristate checkbox. -new Checkbox( +Checkbox( tristate: true, value: checkboxValue, onChanged: (bool value) { @@ -194,19 +194,19 @@ void handleRadioValueChanged(int value) { } // Creates a set of radio buttons. -new Row( +Row( children: [ - new Radio( + Radio( value: 0, groupValue: radioValue, onChanged: handleRadioValueChanged ), - new Radio( + Radio( value: 1, groupValue: radioValue, onChanged: handleRadioValueChanged ), - new Radio( + Radio( value: 2, groupValue: radioValue, onChanged: handleRadioValueChanged @@ -228,7 +228,7 @@ const Radio( bool switchValue = false; // Create a switch. -new Switch( +Switch( value: switchValue, onChanged: (bool value) { setState(() { @@ -251,7 +251,7 @@ class GridLists { // START gridlists // Creates a scrollable grid list with images // loaded from the web. -new GridView.count( +GridView.count( crossAxisCount: 3, childAspectRatio: 1.0, padding: const EdgeInsets.all(4.0), @@ -264,11 +264,11 @@ new GridView.count( '...', 'https://example.com/image-n.jpg' ].map((String url) { - return new GridTile( - footer: new GridTileBar( - title: new Text(url) + return GridTile( + footer: GridTileBar( + title: Text(url) ), - child: new Image.network(url, fit: BoxFit.cover) + child: Image.network(url, fit: BoxFit.cover) ); }).toList(), ); @@ -280,7 +280,7 @@ new GridView.count( class AnimatedImage { void animatedImage() { // START animated_image -new Image.network('https://example.com/animated-image.gif'); +Image.network('https://example.com/animated-image.gif'); // END } } diff --git a/examples/flutter_gallery/lib/gallery/home.dart b/examples/flutter_gallery/lib/gallery/home.dart index 7ec60da9d2..8d156f2070 100644 --- a/examples/flutter_gallery/lib/gallery/home.dart +++ b/examples/flutter_gallery/lib/gallery/home.dart @@ -22,8 +22,8 @@ class _FlutterLogo extends StatelessWidget { @override Widget build(BuildContext context) { - return new Center( - child: new Container( + return Center( + child: Container( width: 34.0, height: 34.0, decoration: const BoxDecoration( @@ -56,29 +56,29 @@ class _CategoryItem extends StatelessWidget { // This repaint boundary prevents the entire _CategoriesPage from being // repainted when the button's ink splash animates. - return new RepaintBoundary( - child: new RawMaterialButton( + return RepaintBoundary( + child: RawMaterialButton( padding: EdgeInsets.zero, splashColor: theme.primaryColor.withOpacity(0.12), highlightColor: Colors.transparent, onPressed: onTap, - child: new Column( + child: Column( mainAxisAlignment: MainAxisAlignment.end, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Padding( + Padding( padding: const EdgeInsets.all(6.0), - child: new Icon( + child: Icon( category.icon, size: 60.0, color: isDark ? Colors.white : _kFlutterBlue, ), ), const SizedBox(height: 10.0), - new Container( + Container( height: 48.0, alignment: Alignment.center, - child: new Text( + child: Text( category.name, textAlign: TextAlign.center, style: theme.textTheme.subhead.copyWith( @@ -110,14 +110,14 @@ class _CategoriesPage extends StatelessWidget { final List categoriesList = categories.toList(); final int columnCount = (MediaQuery.of(context).orientation == Orientation.portrait) ? 2 : 3; - return new Semantics( + return Semantics( scopesRoute: true, namesRoute: true, label: 'categories', explicitChildNodes: true, - child: new SingleChildScrollView( + child: SingleChildScrollView( key: const PageStorageKey('categories'), - child: new LayoutBuilder( + child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { final double columnWidth = constraints.biggest.width / columnCount.toDouble(); final double rowHeight = math.min(225.0, columnWidth * aspectRatio); @@ -126,24 +126,24 @@ class _CategoriesPage extends StatelessWidget { // This repaint boundary prevents the inner contents of the front layer // from repainting when the backdrop toggle triggers a repaint on the // LayoutBuilder. - return new RepaintBoundary( - child: new Column( + return RepaintBoundary( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, - children: new List.generate(rowCount, (int rowIndex) { + children: List.generate(rowCount, (int rowIndex) { final int columnCountForRow = rowIndex == rowCount - 1 ? categories.length - columnCount * math.max(0, rowCount - 1) : columnCount; - return new Row( - children: new List.generate(columnCountForRow, (int columnIndex) { + return Row( + children: List.generate(columnCountForRow, (int columnIndex) { final int index = rowIndex * columnCount + columnIndex; final GalleryDemoCategory category = categoriesList[index]; - return new SizedBox( + return SizedBox( width: columnWidth, height: rowHeight, - child: new _CategoryItem( + child: _CategoryItem( category: category, onTap: () { onCategoryTap(category); @@ -184,7 +184,7 @@ class _DemoItem extends StatelessWidget { final double textScaleFactor = MediaQuery.textScaleFactorOf(context); final List titleChildren = [ - new Text( + Text( demo.title, style: theme.textTheme.subhead.copyWith( color: isDark ? Colors.white : const Color(0xFF202124), @@ -193,7 +193,7 @@ class _DemoItem extends StatelessWidget { ]; if (demo.subtitle != null) { titleChildren.add( - new Text( + Text( demo.subtitle, style: theme.textTheme.body1.copyWith( color: isDark ? Colors.white : const Color(0xFF60646B) @@ -202,29 +202,29 @@ class _DemoItem extends StatelessWidget { ); } - return new RawMaterialButton( + return RawMaterialButton( padding: EdgeInsets.zero, splashColor: theme.primaryColor.withOpacity(0.12), highlightColor: Colors.transparent, onPressed: () { _launchDemo(context); }, - child: new Container( - constraints: new BoxConstraints(minHeight: _kDemoItemHeight * textScaleFactor), - child: new Row( + child: Container( + constraints: BoxConstraints(minHeight: _kDemoItemHeight * textScaleFactor), + child: Row( children: [ - new Container( + Container( width: 56.0, height: 56.0, alignment: Alignment.center, - child: new Icon( + child: Icon( demo.icon, size: 24.0, color: isDark ? Colors.white : _kFlutterBlue, ), ), - new Expanded( - child: new Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.stretch, children: titleChildren, @@ -248,18 +248,18 @@ class _DemosPage extends StatelessWidget { // When overriding ListView.padding, it is necessary to manually handle // safe areas. final double windowBottomPadding = MediaQuery.of(context).padding.bottom; - return new KeyedSubtree( + return KeyedSubtree( key: const ValueKey('GalleryDemoList'), // So the tests can find this ListView - child: new Semantics( + child: Semantics( scopesRoute: true, namesRoute: true, label: category.name, explicitChildNodes: true, - child: new ListView( - key: new PageStorageKey(category.name), - padding: new EdgeInsets.only(top: 8.0, bottom: windowBottomPadding), + child: ListView( + key: PageStorageKey(category.name), + padding: EdgeInsets.only(top: 8.0, bottom: windowBottomPadding), children: kGalleryCategoryToDemos[category].map((GalleryDemo demo) { - return new _DemoItem(demo: demo); + return _DemoItem(demo: demo); }).toList(), ), ), @@ -282,11 +282,11 @@ class GalleryHome extends StatefulWidget { final bool testMode; @override - _GalleryHomeState createState() => new _GalleryHomeState(); + _GalleryHomeState createState() => _GalleryHomeState(); } class _GalleryHomeState extends State with SingleTickerProviderStateMixin { - static final GlobalKey _scaffoldKey = new GlobalKey(); + static final GlobalKey _scaffoldKey = GlobalKey(); AnimationController _controller; GalleryDemoCategory _category; @@ -294,7 +294,7 @@ class _GalleryHomeState extends State with SingleTickerProviderStat List children = previousChildren; if (currentChild != null) children = children.toList()..add(currentChild); - return new Stack( + return Stack( children: children, alignment: Alignment.topCenter, ); @@ -305,7 +305,7 @@ class _GalleryHomeState extends State with SingleTickerProviderStat @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(milliseconds: 600), debugLabel: 'preview banner', vsync: this, @@ -328,50 +328,50 @@ class _GalleryHomeState extends State with SingleTickerProviderStat const Curve switchOutCurve = Interval(0.4, 1.0, curve: Curves.fastOutSlowIn); const Curve switchInCurve = Interval(0.4, 1.0, curve: Curves.fastOutSlowIn); - Widget home = new Scaffold( + Widget home = Scaffold( key: _scaffoldKey, backgroundColor: isDark ? _kFlutterBlue : theme.primaryColor, - body: new SafeArea( + body: SafeArea( bottom: false, - child: new WillPopScope( + child: WillPopScope( onWillPop: () { // Pop the category page if Android back button is pressed. if (_category != null) { setState(() => _category = null); - return new Future.value(false); + return Future.value(false); } - return new Future.value(true); + return Future.value(true); }, - child: new Backdrop( + child: Backdrop( backTitle: const Text('Options'), backLayer: widget.optionsPage, - frontAction: new AnimatedSwitcher( + frontAction: AnimatedSwitcher( duration: _kFrontLayerSwitchDuration, switchOutCurve: switchOutCurve, switchInCurve: switchInCurve, child: _category == null ? const _FlutterLogo() - : new IconButton( + : IconButton( icon: const BackButtonIcon(), tooltip: 'Back', onPressed: () => setState(() => _category = null), ), ), - frontTitle: new AnimatedSwitcher( + frontTitle: AnimatedSwitcher( duration: _kFrontLayerSwitchDuration, child: _category == null ? const Text('Flutter gallery') - : new Text(_category.name), + : Text(_category.name), ), - frontHeading: widget.testMode ? null : new Container(height: 24.0), - frontLayer: new AnimatedSwitcher( + frontHeading: widget.testMode ? null : Container(height: 24.0), + frontLayer: AnimatedSwitcher( duration: _kFrontLayerSwitchDuration, switchOutCurve: switchOutCurve, switchInCurve: switchInCurve, layoutBuilder: centerHome ? _centerHomeLayout : _topHomeLayout, child: _category != null - ? new _DemosPage(_category) - : new _CategoriesPage( + ? _DemosPage(_category) + : _CategoriesPage( categories: kAllGalleryDemoCategories, onCategoryTap: (GalleryDemoCategory category) { setState(() => _category = category); @@ -389,12 +389,12 @@ class _GalleryHomeState extends State with SingleTickerProviderStat }()); if (GalleryHome.showPreviewBanner) { - home = new Stack( + home = Stack( fit: StackFit.expand, children: [ home, - new FadeTransition( - opacity: new CurvedAnimation(parent: _controller, curve: Curves.easeInOut), + FadeTransition( + opacity: CurvedAnimation(parent: _controller, curve: Curves.easeInOut), child: const Banner( message: 'PREVIEW', location: BannerLocation.topEnd, @@ -403,7 +403,7 @@ class _GalleryHomeState extends State with SingleTickerProviderStat ] ); } - home = new AnnotatedRegion( + home = AnnotatedRegion( child: home, value: SystemUiOverlayStyle.light ); diff --git a/examples/flutter_gallery/lib/gallery/options.dart b/examples/flutter_gallery/lib/gallery/options.dart index 9463066531..29e09f2c4e 100644 --- a/examples/flutter_gallery/lib/gallery/options.dart +++ b/examples/flutter_gallery/lib/gallery/options.dart @@ -39,7 +39,7 @@ class GalleryOptions { bool showRasterCacheImagesCheckerboard, bool showOffscreenLayersCheckerboard, }) { - return new GalleryOptions( + return GalleryOptions( theme: theme ?? this.theme, textScaleFactor: textScaleFactor ?? this.textScaleFactor, textDirection: textDirection ?? this.textDirection, @@ -95,16 +95,16 @@ class _OptionsItem extends StatelessWidget { Widget build(BuildContext context) { final double textScaleFactor = MediaQuery.textScaleFactorOf(context); - return new MergeSemantics( - child: new Container( - constraints: new BoxConstraints(minHeight: _kItemHeight * textScaleFactor), + return MergeSemantics( + child: Container( + constraints: BoxConstraints(minHeight: _kItemHeight * textScaleFactor), padding: _kItemPadding, alignment: AlignmentDirectional.centerStart, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: DefaultTextStyle.of(context).style, maxLines: 2, overflow: TextOverflow.fade, - child: new IconTheme( + child: IconTheme( data: Theme.of(context).primaryIconTheme, child: child, ), @@ -126,11 +126,11 @@ class _BooleanItem extends StatelessWidget { @override Widget build(BuildContext context) { final bool isDark = Theme.of(context).brightness == Brightness.dark; - return new _OptionsItem( - child: new Row( + return _OptionsItem( + child: Row( children: [ - new Expanded(child: new Text(title)), - new Switch( + Expanded(child: Text(title)), + Switch( key: switchKey, value: value, onChanged: onChanged, @@ -151,10 +151,10 @@ class _ActionItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new _OptionsItem( - child: new _FlatButton( + return _OptionsItem( + child: _FlatButton( onPressed: onTap, - child: new Text(text), + child: Text(text), ), ); } @@ -168,10 +168,10 @@ class _FlatButton extends StatelessWidget { @override Widget build(BuildContext context) { - return new FlatButton( + return FlatButton( padding: EdgeInsets.zero, onPressed: onPressed, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: Theme.of(context).primaryTextTheme.subhead, child: child, ), @@ -187,14 +187,14 @@ class _Heading extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new _OptionsItem( - child: new DefaultTextStyle( + return _OptionsItem( + child: DefaultTextStyle( style: theme.textTheme.body1.copyWith( fontFamily: 'GoogleSans', color: theme.accentColor, ), - child: new Semantics( - child: new Text(text), + child: Semantics( + child: Text(text), header: true, ), ), @@ -210,7 +210,7 @@ class _ThemeItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new _BooleanItem( + return _BooleanItem( 'Dark Theme', options.theme == kDarkGalleryTheme, (bool value) { @@ -233,29 +233,29 @@ class _TextScaleFactorItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new _OptionsItem( - child: new Row( + return _OptionsItem( + child: Row( children: [ - new Expanded( - child: new Column( + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text('Text size'), - new Text( + Text( '${options.textScaleFactor.label}', style: Theme.of(context).primaryTextTheme.body1, ), ], ), ), - new PopupMenuButton( + PopupMenuButton( padding: const EdgeInsetsDirectional.only(end: 16.0), icon: const Icon(Icons.arrow_drop_down), itemBuilder: (BuildContext context) { return kAllGalleryTextScaleValues.map((GalleryTextScaleValue scaleValue) { - return new PopupMenuItem( + return PopupMenuItem( value: scaleValue, - child: new Text(scaleValue.label), + child: Text(scaleValue.label), ); }).toList(); }, @@ -279,7 +279,7 @@ class _TextDirectionItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new _BooleanItem( + return _BooleanItem( 'Force RTL', options.textDirection == TextDirection.rtl, (bool value) { @@ -302,7 +302,7 @@ class _TimeDilationItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new _BooleanItem( + return _BooleanItem( 'Slow motion', options.timeDilation != 1.0, (bool value) { @@ -338,29 +338,29 @@ class _PlatformItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new _OptionsItem( - child: new Row( + return _OptionsItem( + child: Row( children: [ - new Expanded( - child: new Column( + Expanded( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ const Text('Platform mechanics'), - new Text( + Text( '${_platformLabel(options.platform)}', style: Theme.of(context).primaryTextTheme.body1, ), ], ), ), - new PopupMenuButton( + PopupMenuButton( padding: const EdgeInsetsDirectional.only(end: 16.0), icon: const Icon(Icons.arrow_drop_down), itemBuilder: (BuildContext context) { return TargetPlatform.values.map((TargetPlatform platform) { - return new PopupMenuItem( + return PopupMenuItem( value: platform, - child: new Text(_platformLabel(platform)), + child: Text(_platformLabel(platform)), ); }).toList(); }, @@ -403,7 +403,7 @@ class GalleryOptionsPage extends StatelessWidget { if (options.showOffscreenLayersCheckerboard != null) { items.add( - new _BooleanItem( + _BooleanItem( 'Highlight offscreen layers', options.showOffscreenLayersCheckerboard, (bool value) { @@ -414,7 +414,7 @@ class GalleryOptionsPage extends StatelessWidget { } if (options.showRasterCacheImagesCheckerboard != null) { items.add( - new _BooleanItem( + _BooleanItem( 'Highlight raster cache images', options.showRasterCacheImagesCheckerboard, (bool value) { @@ -425,7 +425,7 @@ class GalleryOptionsPage extends StatelessWidget { } if (options.showPerformanceOverlay != null) { items.add( - new _BooleanItem( + _BooleanItem( 'Show performance overlay', options.showPerformanceOverlay, (bool value) { @@ -442,29 +442,29 @@ class GalleryOptionsPage extends StatelessWidget { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new DefaultTextStyle( + return DefaultTextStyle( style: theme.primaryTextTheme.subhead, - child: new ListView( + child: ListView( padding: const EdgeInsets.only(bottom: 124.0), children: [ const _Heading('Display'), - new _ThemeItem(options, onOptionsChanged), - new _TextScaleFactorItem(options, onOptionsChanged), - new _TextDirectionItem(options, onOptionsChanged), - new _TimeDilationItem(options, onOptionsChanged), + _ThemeItem(options, onOptionsChanged), + _TextScaleFactorItem(options, onOptionsChanged), + _TextDirectionItem(options, onOptionsChanged), + _TimeDilationItem(options, onOptionsChanged), const Divider(), const _Heading('Platform mechanics'), - new _PlatformItem(options, onOptionsChanged), + _PlatformItem(options, onOptionsChanged), ]..addAll( _enabledDiagnosticItems(), )..addAll( [ const Divider(), const _Heading('Flutter gallery'), - new _ActionItem('About Flutter Gallery', () { + _ActionItem('About Flutter Gallery', () { showGalleryAboutDialog(context); }), - new _ActionItem('Send feedback', onSendFeedback), + _ActionItem('Send feedback', onSendFeedback), ], ), ), diff --git a/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart b/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart index aef052f3fe..9f9d8dfe66 100644 --- a/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart +++ b/examples/flutter_gallery/lib/gallery/syntax_highlighter.dart @@ -18,7 +18,7 @@ class SyntaxHighlighterStyle { }); static SyntaxHighlighterStyle lightThemeStyle() { - return new SyntaxHighlighterStyle( + return SyntaxHighlighterStyle( baseStyle: const TextStyle(color: Color(0xFF000000)), numberStyle: const TextStyle(color: Color(0xFF1565C0)), commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), @@ -31,7 +31,7 @@ class SyntaxHighlighterStyle { } static SyntaxHighlighterStyle darkThemeStyle() { - return new SyntaxHighlighterStyle( + return SyntaxHighlighterStyle( baseStyle: const TextStyle(color: Color(0xFFFFFFFF)), numberStyle: const TextStyle(color: Color(0xFF1565C0)), commentStyle: const TextStyle(color: Color(0xFF9E9E9E)), @@ -87,7 +87,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { @override TextSpan format(String src) { _src = src; - _scanner = new StringScanner(_src); + _scanner = StringScanner(_src); if (_generateSpans()) { // Successfully parsed the code @@ -96,20 +96,20 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { for (_HighlightSpan span in _spans) { if (currentPosition != span.start) - formattedText.add(new TextSpan(text: _src.substring(currentPosition, span.start))); + formattedText.add(TextSpan(text: _src.substring(currentPosition, span.start))); - formattedText.add(new TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); + formattedText.add(TextSpan(style: span.textStyle(_style), text: span.textForSpan(_src))); currentPosition = span.end; } if (currentPosition != _src.length) - formattedText.add(new TextSpan(text: _src.substring(currentPosition, _src.length))); + formattedText.add(TextSpan(text: _src.substring(currentPosition, _src.length))); - return new TextSpan(style: _style.baseStyle, children: formattedText); + return TextSpan(style: _style.baseStyle, children: formattedText); } else { // Parsing failed, return with only basic formatting - return new TextSpan(style: _style.baseStyle, text: src); + return TextSpan(style: _style.baseStyle, text: src); } } @@ -118,11 +118,11 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { while (!_scanner.isDone) { // Skip White space - _scanner.scan(new RegExp(r'\s+')); + _scanner.scan(RegExp(r'\s+')); // Block comments - if (_scanner.scan(new RegExp(r'/\*(.|\n)*\*/'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'/\*(.|\n)*\*/'))) { + _spans.add(_HighlightSpan( _HighlightType.comment, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -136,14 +136,14 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { bool eof = false; int endComment; - if (_scanner.scan(new RegExp(r'.*\n'))) { + if (_scanner.scan(RegExp(r'.*\n'))) { endComment = _scanner.lastMatch.end - 1; } else { eof = true; endComment = _src.length; } - _spans.add(new _HighlightSpan( + _spans.add(_HighlightSpan( _HighlightType.comment, startComment, endComment @@ -156,8 +156,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Raw r"String" - if (_scanner.scan(new RegExp(r'r".*"'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'r".*"'))) { + _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -166,8 +166,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Raw r'String' - if (_scanner.scan(new RegExp(r"r'.*'"))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r"r'.*'"))) { + _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -176,8 +176,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Multiline """String""" - if (_scanner.scan(new RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'"""(?:[^"\\]|\\(.|\n))*"""'))) { + _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -186,8 +186,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Multiline '''String''' - if (_scanner.scan(new RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r"'''(?:[^'\\]|\\(.|\n))*'''"))) { + _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -196,8 +196,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // "String" - if (_scanner.scan(new RegExp(r'"(?:[^"\\]|\\.)*"'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'"(?:[^"\\]|\\.)*"'))) { + _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -206,8 +206,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // 'String' - if (_scanner.scan(new RegExp(r"'(?:[^'\\]|\\.)*'"))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r"'(?:[^'\\]|\\.)*'"))) { + _spans.add(_HighlightSpan( _HighlightType.string, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -216,8 +216,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Double - if (_scanner.scan(new RegExp(r'\d+\.\d+'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'\d+\.\d+'))) { + _spans.add(_HighlightSpan( _HighlightType.number, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -226,8 +226,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Integer - if (_scanner.scan(new RegExp(r'\d+'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'\d+'))) { + _spans.add(_HighlightSpan( _HighlightType.number, _scanner.lastMatch.start, _scanner.lastMatch.end) @@ -236,8 +236,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Punctuation - if (_scanner.scan(new RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'[\[\]{}().!=<>&\|\?\+\-\*/%\^~;:,]'))) { + _spans.add(_HighlightSpan( _HighlightType.punctuation, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -246,8 +246,8 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Meta data - if (_scanner.scan(new RegExp(r'@\w+'))) { - _spans.add(new _HighlightSpan( + if (_scanner.scan(RegExp(r'@\w+'))) { + _spans.add(_HighlightSpan( _HighlightType.keyword, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -256,7 +256,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { } // Words - if (_scanner.scan(new RegExp(r'\w+'))) { + if (_scanner.scan(RegExp(r'\w+'))) { _HighlightType type; String word = _scanner.lastMatch[0]; @@ -273,7 +273,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { type = _HighlightType.constant; if (type != null) { - _spans.add(new _HighlightSpan( + _spans.add(_HighlightSpan( type, _scanner.lastMatch.start, _scanner.lastMatch.end @@ -296,7 +296,7 @@ class DartSyntaxHighlighter extends SyntaxHighlighter { void _simplify() { for (int i = _spans.length - 2; i >= 0; i -= 1) { if (_spans[i].type == _spans[i + 1].type && _spans[i].end == _spans[i + 1].start) { - _spans[i] = new _HighlightSpan( + _spans[i] = _HighlightSpan( _spans[i].type, _spans[i].start, _spans[i + 1].end diff --git a/examples/flutter_gallery/lib/gallery/themes.dart b/examples/flutter_gallery/lib/gallery/themes.dart index ea69898bce..5cadd159cc 100644 --- a/examples/flutter_gallery/lib/gallery/themes.dart +++ b/examples/flutter_gallery/lib/gallery/themes.dart @@ -11,8 +11,8 @@ class GalleryTheme { final ThemeData data; } -final GalleryTheme kDarkGalleryTheme = new GalleryTheme._('Dark', _buildDarkTheme()); -final GalleryTheme kLightGalleryTheme = new GalleryTheme._('Light', _buildLightTheme()); +final GalleryTheme kDarkGalleryTheme = GalleryTheme._('Dark', _buildDarkTheme()); +final GalleryTheme kLightGalleryTheme = GalleryTheme._('Light', _buildLightTheme()); TextTheme _buildTextTheme(TextTheme base) { return base.copyWith( @@ -24,7 +24,7 @@ TextTheme _buildTextTheme(TextTheme base) { ThemeData _buildDarkTheme() { const Color primaryColor = Color(0xFF0175c2); - final ThemeData base = new ThemeData.dark(); + final ThemeData base = ThemeData.dark(); return base.copyWith( primaryColor: primaryColor, buttonColor: primaryColor, @@ -45,7 +45,7 @@ ThemeData _buildDarkTheme() { ThemeData _buildLightTheme() { const Color primaryColor = Color(0xFF0175c2); - final ThemeData base = new ThemeData.light(); + final ThemeData base = ThemeData.light(); return base.copyWith( primaryColor: primaryColor, buttonColor: primaryColor, diff --git a/examples/flutter_gallery/lib/gallery/updater.dart b/examples/flutter_gallery/lib/gallery/updater.dart index 7356038ed9..6eac7cd9f3 100644 --- a/examples/flutter_gallery/lib/gallery/updater.dart +++ b/examples/flutter_gallery/lib/gallery/updater.dart @@ -19,7 +19,7 @@ class Updater extends StatefulWidget { final Widget child; @override - State createState() => new UpdaterState(); + State createState() => UpdaterState(); } class UpdaterState extends State { @@ -33,10 +33,10 @@ class UpdaterState extends State { Future _checkForUpdates() async { // Only prompt once a day if (_lastUpdateCheck != null && - new DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) { + DateTime.now().difference(_lastUpdateCheck) < const Duration(days: 1)) { return null; // We already checked for updates recently } - _lastUpdateCheck = new DateTime.now(); + _lastUpdateCheck = DateTime.now(); final String updateUrl = await widget.updateUrlFetcher(); if (updateUrl != null) { @@ -50,17 +50,17 @@ class UpdaterState extends State { final ThemeData theme = Theme.of(context); final TextStyle dialogTextStyle = theme.textTheme.subhead.copyWith(color: theme.textTheme.caption.color); - return new AlertDialog( + return AlertDialog( title: const Text('Update Flutter Gallery?'), - content: new Text('A newer version is available.', style: dialogTextStyle), + content: Text('A newer version is available.', style: dialogTextStyle), actions: [ - new FlatButton( + FlatButton( child: const Text('NO THANKS'), onPressed: () { Navigator.pop(context, false); }, ), - new FlatButton( + FlatButton( child: const Text('UPDATE'), onPressed: () { Navigator.pop(context, true); diff --git a/examples/flutter_gallery/test/accessibility_test.dart b/examples/flutter_gallery/test/accessibility_test.dart index da2f916f85..c9cbd083f3 100644 --- a/examples/flutter_gallery/test/accessibility_test.dart +++ b/examples/flutter_gallery/test/accessibility_test.dart @@ -6,231 +6,231 @@ void main() { group('All material demos meet recommended tap target sizes', () { testWidgets('backdrop_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new BackdropDemo())); + await tester.pumpWidget(MaterialApp(home: BackdropDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('bottom_app_bar_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new BottomAppBarDemo())); + await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('bottom_navigation_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new BottomNavigationDemo())); + await tester.pumpWidget(MaterialApp(home: BottomNavigationDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('buttons_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ButtonsDemo())); + await tester.pumpWidget(MaterialApp(home: ButtonsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('cards_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new CardsDemo())); + await tester.pumpWidget(MaterialApp(home: CardsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('chip_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ChipDemo())); + await tester.pumpWidget(MaterialApp(home: ChipDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('data_table_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DataTableDemo())); + await tester.pumpWidget(MaterialApp(home: DataTableDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('date_and_time_picker_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DateAndTimePickerDemo())); + await tester.pumpWidget(MaterialApp(home: DateAndTimePickerDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21578 testWidgets('dialog_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DialogDemo())); + await tester.pumpWidget(MaterialApp(home: DialogDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('drawer_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DrawerDemo())); + await tester.pumpWidget(MaterialApp(home: DrawerDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('elevation_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ElevationDemo())); + await tester.pumpWidget(MaterialApp(home: ElevationDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('expansion_panels_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ExpansionPanelsDemo())); + await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('grid_list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const GridListDemo())); + await tester.pumpWidget(MaterialApp(home: const GridListDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('icons_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new IconsDemo())); + await tester.pumpWidget(MaterialApp(home: IconsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('leave_behind_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const LeaveBehindDemo())); + await tester.pumpWidget(MaterialApp(home: const LeaveBehindDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const ListDemo())); + await tester.pumpWidget(MaterialApp(home: const ListDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('menu_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const MenuDemo())); + await tester.pumpWidget(MaterialApp(home: const MenuDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ModalBottomSheetDemo())); + await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('overscroll_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const OverscrollDemo())); + await tester.pumpWidget(MaterialApp(home: const OverscrollDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('page_selector_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new PageSelectorDemo())); + await tester.pumpWidget(MaterialApp(home: PageSelectorDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new PersistentBottomSheetDemo())); + await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('progress_indicator_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ProgressIndicatorDemo())); + await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('reorderable_list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const ReorderableListDemo())); + await tester.pumpWidget(MaterialApp(home: const ReorderableListDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('scrollable_tabs_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ScrollableTabsDemo())); + await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('search_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new SearchDemo())); + await tester.pumpWidget(MaterialApp(home: SearchDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('selection_controls_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new SelectionControlsDemo())); + await tester.pumpWidget(MaterialApp(home: SelectionControlsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('slider_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new SliderDemo())); + await tester.pumpWidget(MaterialApp(home: SliderDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('snack_bar_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const SnackBarDemo())); + await tester.pumpWidget(MaterialApp(home: const SnackBarDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('tabs_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TabsDemo())); + await tester.pumpWidget(MaterialApp(home: TabsDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('tabs_fab_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TabsFabDemo())); + await tester.pumpWidget(MaterialApp(home: TabsFabDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('text_form_field_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo())); + await tester.pumpWidget(MaterialApp(home: const TextFormFieldDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('tooltip_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TooltipDemo())); + await tester.pumpWidget(MaterialApp(home: TooltipDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); testWidgets('two_level_list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TwoLevelListDemo())); + await tester.pumpWidget(MaterialApp(home: TwoLevelListDemo())); expect(tester, meetsGuideline(androidTapTargetGuideline)); handle.dispose(); }); @@ -239,231 +239,231 @@ void main() { group('All material demos meet text contrast guidelines', () { testWidgets('backdrop_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new BackdropDemo())); + await tester.pumpWidget(MaterialApp(home: BackdropDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('bottom_app_bar_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new BottomAppBarDemo())); + await tester.pumpWidget(MaterialApp(home: BottomAppBarDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21651 testWidgets('bottom_navigation_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new BottomNavigationDemo())); + await tester.pumpWidget(MaterialApp(home: BottomNavigationDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('buttons_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ButtonsDemo())); + await tester.pumpWidget(MaterialApp(home: ButtonsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21647 testWidgets('cards_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new CardsDemo())); + await tester.pumpWidget(MaterialApp(home: CardsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21651 testWidgets('chip_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ChipDemo())); + await tester.pumpWidget(MaterialApp(home: ChipDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21647 testWidgets('data_table_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DataTableDemo())); + await tester.pumpWidget(MaterialApp(home: DataTableDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21647 testWidgets('date_and_time_picker_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DateAndTimePickerDemo())); + await tester.pumpWidget(MaterialApp(home: DateAndTimePickerDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21647 testWidgets('dialog_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DialogDemo())); + await tester.pumpWidget(MaterialApp(home: DialogDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('drawer_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new DrawerDemo())); + await tester.pumpWidget(MaterialApp(home: DrawerDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('elevation_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ElevationDemo())); + await tester.pumpWidget(MaterialApp(home: ElevationDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('expansion_panels_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ExpansionPanelsDemo())); + await tester.pumpWidget(MaterialApp(home: ExpansionPanelsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('grid_list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const GridListDemo())); + await tester.pumpWidget(MaterialApp(home: const GridListDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('icons_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new IconsDemo())); + await tester.pumpWidget(MaterialApp(home: IconsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21647 testWidgets('leave_behind_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const LeaveBehindDemo())); + await tester.pumpWidget(MaterialApp(home: const LeaveBehindDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const ListDemo())); + await tester.pumpWidget(MaterialApp(home: const ListDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('menu_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const MenuDemo())); + await tester.pumpWidget(MaterialApp(home: const MenuDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('modal_bottom_sheet_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ModalBottomSheetDemo())); + await tester.pumpWidget(MaterialApp(home: ModalBottomSheetDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('overscroll_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const OverscrollDemo())); + await tester.pumpWidget(MaterialApp(home: const OverscrollDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('page_selector_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new PageSelectorDemo())); + await tester.pumpWidget(MaterialApp(home: PageSelectorDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('persistent_bottom_sheet_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new PersistentBottomSheetDemo())); + await tester.pumpWidget(MaterialApp(home: PersistentBottomSheetDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('progress_indicator_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ProgressIndicatorDemo())); + await tester.pumpWidget(MaterialApp(home: ProgressIndicatorDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('reorderable_list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const ReorderableListDemo())); + await tester.pumpWidget(MaterialApp(home: const ReorderableListDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('scrollable_tabs_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new ScrollableTabsDemo())); + await tester.pumpWidget(MaterialApp(home: ScrollableTabsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('search_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new SearchDemo())); + await tester.pumpWidget(MaterialApp(home: SearchDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }, skip: true); // https://github.com/flutter/flutter/issues/21651 testWidgets('selection_controls_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new SelectionControlsDemo())); + await tester.pumpWidget(MaterialApp(home: SelectionControlsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('slider_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new SliderDemo())); + await tester.pumpWidget(MaterialApp(home: SliderDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('snack_bar_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const SnackBarDemo())); + await tester.pumpWidget(MaterialApp(home: const SnackBarDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('tabs_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TabsDemo())); + await tester.pumpWidget(MaterialApp(home: TabsDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('tabs_fab_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TabsFabDemo())); + await tester.pumpWidget(MaterialApp(home: TabsFabDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('text_form_field_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo())); + await tester.pumpWidget(MaterialApp(home: const TextFormFieldDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('tooltip_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TooltipDemo())); + await tester.pumpWidget(MaterialApp(home: TooltipDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); testWidgets('two_level_list_demo', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp(home: new TwoLevelListDemo())); + await tester.pumpWidget(MaterialApp(home: TwoLevelListDemo())); await expectLater(tester, meetsGuideline(textContrastGuideline)); handle.dispose(); }); diff --git a/examples/flutter_gallery/test/calculator/logic.dart b/examples/flutter_gallery/test/calculator/logic.dart index 472b0060ad..692bf74ade 100644 --- a/examples/flutter_gallery/test/calculator/logic.dart +++ b/examples/flutter_gallery/test/calculator/logic.dart @@ -8,7 +8,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { test('Test order of operations: 12 + 3 * 4 = 24', () { - CalcExpression expression = new CalcExpression.empty(); + CalcExpression expression = CalcExpression.empty(); expression = expression.appendDigit(1); expression = expression.appendDigit(2); expression = expression.appendOperation(Operation.Addition); @@ -21,7 +21,7 @@ void main() { }); test('Test floating point 0.1 + 0.2 = 0.3', () { - CalcExpression expression = new CalcExpression.empty(); + CalcExpression expression = CalcExpression.empty(); expression = expression.appendDigit(0); expression = expression.appendPoint(); expression = expression.appendDigit(1); @@ -35,7 +35,7 @@ void main() { }); test('Test floating point 1.0/10.0 = 0.1', () { - CalcExpression expression = new CalcExpression.empty(); + CalcExpression expression = CalcExpression.empty(); expression = expression.appendDigit(1); expression = expression.appendPoint(); expression = expression.appendDigit(0); @@ -50,7 +50,7 @@ void main() { }); test('Test 1/0 = Infinity', () { - CalcExpression expression = new CalcExpression.empty(); + CalcExpression expression = CalcExpression.empty(); expression = expression.appendDigit(1); expression = expression.appendOperation(Operation.Division); expression = expression.appendDigit(0); @@ -60,7 +60,7 @@ void main() { }); test('Test use result in next calculation: 1 + 1 = 2 + 1 = 3 + 1 = 4', () { - CalcExpression expression = new CalcExpression.empty(); + CalcExpression expression = CalcExpression.empty(); expression = expression.appendDigit(1); expression = expression.appendOperation(Operation.Addition); expression = expression.appendDigit(1); @@ -76,7 +76,7 @@ void main() { }); test('Test minus -3 - -2 = -1', () { - CalcExpression expression = new CalcExpression.empty(); + CalcExpression expression = CalcExpression.empty(); expression = expression.appendMinus(); expression = expression.appendDigit(3); expression = expression.appendMinus(); diff --git a/examples/flutter_gallery/test/calculator/smoke_test.dart b/examples/flutter_gallery/test/calculator/smoke_test.dart index d13b98616b..177ac3d2e1 100644 --- a/examples/flutter_gallery/test/calculator/smoke_test.dart +++ b/examples/flutter_gallery/test/calculator/smoke_test.dart @@ -14,7 +14,7 @@ void main() { // We press the "1" and the "2" buttons and check that the display // reads "12". testWidgets('Flutter calculator app smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: const CalculatorDemo())); + await tester.pumpWidget(MaterialApp(home: const CalculatorDemo())); final Finder oneButton = find.widgetWithText(InkResponse, '1'); expect(oneButton, findsOneWidget); diff --git a/examples/flutter_gallery/test/demo/material/chip_demo_test.dart b/examples/flutter_gallery/test/demo/material/chip_demo_test.dart index bb1b98c5ce..ef0b6d1338 100644 --- a/examples/flutter_gallery/test/demo/material/chip_demo_test.dart +++ b/examples/flutter_gallery/test/demo/material/chip_demo_test.dart @@ -9,9 +9,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Chip demo has semantic labels', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new ChipDemo(), + await tester.pumpWidget(MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: ChipDemo(), )); expect(tester.getSemanticsData(find.byIcon(Icons.vignette)), matchesSemanticsData( diff --git a/examples/flutter_gallery/test/demo/material/drawer_demo_test.dart b/examples/flutter_gallery/test/demo/material/drawer_demo_test.dart index 0f99a6e01b..8e84fb59de 100644 --- a/examples/flutter_gallery/test/demo/material/drawer_demo_test.dart +++ b/examples/flutter_gallery/test/demo/material/drawer_demo_test.dart @@ -8,9 +8,9 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Drawer header does not scroll', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new DrawerDemo(), + await tester.pumpWidget(MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: DrawerDemo(), )); await tester.tap(find.text('Tap here to open the drawer')); diff --git a/examples/flutter_gallery/test/demo/material/text_form_field_demo_test.dart b/examples/flutter_gallery/test/demo/material/text_form_field_demo_test.dart index 38ecea0f4c..8ca1a276f9 100644 --- a/examples/flutter_gallery/test/demo/material/text_form_field_demo_test.dart +++ b/examples/flutter_gallery/test/demo/material/text_form_field_demo_test.dart @@ -8,7 +8,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('validates name field correctly', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: const TextFormFieldDemo())); + await tester.pumpWidget(MaterialApp(home: const TextFormFieldDemo())); final Finder submitButton = find.widgetWithText(RaisedButton, 'SUBMIT'); expect(submitButton, findsOneWidget); diff --git a/examples/flutter_gallery/test/drawer_test.dart b/examples/flutter_gallery/test/drawer_test.dart index c3941faac1..afe4bdc6e3 100644 --- a/examples/flutter_gallery/test/drawer_test.dart +++ b/examples/flutter_gallery/test/drawer_test.dart @@ -16,7 +16,7 @@ void main() { bool hasFeedback = false; await tester.pumpWidget( - new GalleryApp( + GalleryApp( testMode: true, onSendFeedback: () { hasFeedback = true; diff --git a/examples/flutter_gallery/test/example_code_parser_test.dart b/examples/flutter_gallery/test/example_code_parser_test.dart index 2b4476c4b0..dbc637094e 100644 --- a/examples/flutter_gallery/test/example_code_parser_test.dart +++ b/examples/flutter_gallery/test/example_code_parser_test.dart @@ -11,7 +11,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('Flutter gallery example code parser test', () async { - final TestAssetBundle bundle = new TestAssetBundle(); + final TestAssetBundle bundle = TestAssetBundle(); final String codeSnippet0 = await getExampleCode('test_0', bundle); expect(codeSnippet0, 'test 0 0\ntest 0 1'); @@ -46,7 +46,7 @@ class TestAssetBundle extends AssetBundle { @override Future loadString(String key, { bool cache = true }) { if (key == 'lib/gallery/example_code.dart') - return new Future.value(testCodeFile); + return Future.value(testCodeFile); return null; } diff --git a/examples/flutter_gallery/test/live_smoketest.dart b/examples/flutter_gallery/test/live_smoketest.dart index 36f95c8900..8bab93de9c 100644 --- a/examples/flutter_gallery/test/live_smoketest.dart +++ b/examples/flutter_gallery/test/live_smoketest.dart @@ -44,14 +44,14 @@ Future main() async { // Verify that _kUnsynchronizedDemos and _kSkippedDemos identify // demos that actually exist. final List allDemoTitles = kAllGalleryDemos.map((GalleryDemo demo) => demo.title).toList(); - if (!new Set.from(allDemoTitles).containsAll(_kUnsynchronizedDemoTitles)) + if (!Set.from(allDemoTitles).containsAll(_kUnsynchronizedDemoTitles)) fail('Unrecognized demo titles in _kUnsynchronizedDemosTitles: $_kUnsynchronizedDemoTitles'); - if (!new Set.from(allDemoTitles).containsAll(_kSkippedDemoTitles)) + if (!Set.from(allDemoTitles).containsAll(_kSkippedDemoTitles)) fail('Unrecognized demo names in _kSkippedDemoTitles: $_kSkippedDemoTitles'); print('Starting app...'); runApp(const GalleryApp(testMode: true)); - final _LiveWidgetController controller = new _LiveWidgetController(WidgetsBinding.instance); + final _LiveWidgetController controller = _LiveWidgetController(WidgetsBinding.instance); for (GalleryDemoCategory category in kAllGalleryDemoCategories) { print('Tapping "${category.name}" section...'); await controller.tap(find.text(category.name)); @@ -90,7 +90,7 @@ class _LiveWidgetController extends LiveWidgetController { /// Waits until at the end of a frame the provided [condition] is [true]. Future _waitUntilFrame(bool condition(), [Completer completer]) { - completer ??= new Completer(); + completer ??= Completer(); if (!condition()) { SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) { _waitUntilFrame(condition, completer); diff --git a/examples/flutter_gallery/test/smoke_test.dart b/examples/flutter_gallery/test/smoke_test.dart index 7d9a3c63df..df480fce7d 100644 --- a/examples/flutter_gallery/test/smoke_test.dart +++ b/examples/flutter_gallery/test/smoke_test.dart @@ -137,7 +137,7 @@ Future smokeGallery(WidgetTester tester) async { bool sendFeedbackButtonPressed = false; await tester.pumpWidget( - new GalleryApp( + GalleryApp( testMode: true, onSendFeedback: () { sendFeedbackButtonPressed = true; // see smokeOptionsPage() diff --git a/examples/flutter_gallery/test/update_test.dart b/examples/flutter_gallery/test/update_test.dart index bbd11b37a9..c7e756826f 100644 --- a/examples/flutter_gallery/test/update_test.dart +++ b/examples/flutter_gallery/test/update_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_gallery/gallery/app.dart' show GalleryApp; Future mockUpdateUrlFetcher() { // A real implementation would connect to the network to retrieve this value - return new Future.value('http://www.example.com/'); + return Future.value('http://www.example.com/'); } void main() { diff --git a/examples/flutter_gallery/test_driver/scroll_perf_test.dart b/examples/flutter_gallery/test_driver/scroll_perf_test.dart index 0f70b1bd6c..07a0b7f6a3 100644 --- a/examples/flutter_gallery/test_driver/scroll_perf_test.dart +++ b/examples/flutter_gallery/test_driver/scroll_perf_test.dart @@ -31,17 +31,17 @@ void main() { // Scroll down for (int i = 0; i < 5; i++) { await driver.scroll(demoList, 0.0, -300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } // Scroll up for (int i = 0; i < 5; i++) { await driver.scroll(demoList, 0.0, 300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } }); - new TimelineSummary.summarize(timeline) + TimelineSummary.summarize(timeline) ..writeSummaryToFile('home_scroll_perf', pretty: true) ..writeTimelineToFile('home_scroll_perf', pretty: true); }); diff --git a/examples/flutter_gallery/test_driver/transitions_perf_test.dart b/examples/flutter_gallery/test_driver/transitions_perf_test.dart index 8e534ef3a9..df1c9252a3 100644 --- a/examples/flutter_gallery/test_driver/transitions_perf_test.dart +++ b/examples/flutter_gallery/test_driver/transitions_perf_test.dart @@ -86,7 +86,7 @@ Future saveDurationsHistogram(List> events, String ou }); if (unexpectedValueCounts.isNotEmpty) { - final StringBuffer error = new StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n'); + final StringBuffer error = StringBuffer('Some routes recorded wrong number of values (expected 2 values/route):\n\n'); unexpectedValueCounts.forEach((String routeName, int count) { error.writeln(' - $routeName recorded $count values.'); }); @@ -183,7 +183,7 @@ void main([List args = const []]) { } // See _handleMessages() in transitions_perf.dart. - _allDemos = new List.from(const JsonDecoder().convert(await driver.requestData('demoNames'))); + _allDemos = List.from(const JsonDecoder().convert(await driver.requestData('demoNames'))); if (_allDemos.isEmpty) throw 'no demo names found'; }); @@ -209,15 +209,15 @@ void main([List args = const []]) { // Save the duration (in microseconds) of the first timeline Frame event // that follows a 'Start Transition' event. The Gallery app adds a // 'Start Transition' event when a demo is launched (see GalleryItem). - final TimelineSummary summary = new TimelineSummary.summarize(timeline); + final TimelineSummary summary = TimelineSummary.summarize(timeline); await summary.writeSummaryToFile('transitions', pretty: true); final String histogramPath = path.join(testOutputsDirectory, 'transition_durations.timeline.json'); await saveDurationsHistogram( - new List>.from(timeline.json['traceEvents']), + List>.from(timeline.json['traceEvents']), histogramPath); // Execute the remaining tests. - final Set unprofiledDemos = new Set.from(_allDemos)..removeAll(kProfiledDemos); + final Set unprofiledDemos = Set.from(_allDemos)..removeAll(kProfiledDemos); await runDemos(unprofiledDemos.toList(), driver); }, timeout: const Timeout(Duration(minutes: 5))); diff --git a/examples/flutter_gallery/test_memory/back_button.dart b/examples/flutter_gallery/test_memory/back_button.dart index bbd06602a6..c8f2e1163e 100644 --- a/examples/flutter_gallery/test_memory/back_button.dart +++ b/examples/flutter_gallery/test_memory/back_button.dart @@ -30,7 +30,7 @@ class LifecycleObserver extends WidgetsBindingObserver { Future main() async { runApp(const GalleryApp()); await endOfAnimation(); - await new Future.delayed(const Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); debugPrint('==== MEMORY BENCHMARK ==== READY ===='); - WidgetsBinding.instance.addObserver(new LifecycleObserver()); + WidgetsBinding.instance.addObserver(LifecycleObserver()); } diff --git a/examples/flutter_gallery/test_memory/memory_nav.dart b/examples/flutter_gallery/test_memory/memory_nav.dart index 81ad906c11..fc64fda5f8 100644 --- a/examples/flutter_gallery/test_memory/memory_nav.dart +++ b/examples/flutter_gallery/test_memory/memory_nav.dart @@ -23,8 +23,8 @@ Rect boundsFor(WidgetController controller, Finder item) { } Future main() async { - final Completer ready = new Completer(); - runApp(new GestureDetector( + final Completer ready = Completer(); + runApp(GestureDetector( onTap: () { debugPrint('Received tap.'); ready.complete(); @@ -36,14 +36,14 @@ Future main() async { ), )); await SchedulerBinding.instance.endOfFrame; - await new Future.delayed(const Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); debugPrint('==== MEMORY BENCHMARK ==== READY ===='); await ready.future; debugPrint('Continuing...'); // remove onTap handler, enable pointer events for app - runApp(new GestureDetector( + runApp(GestureDetector( child: const IgnorePointer( ignoring: false, child: GalleryApp(testMode: true), @@ -51,16 +51,16 @@ Future main() async { )); await SchedulerBinding.instance.endOfFrame; - final WidgetController controller = new LiveWidgetController(WidgetsBinding.instance); + final WidgetController controller = LiveWidgetController(WidgetsBinding.instance); debugPrint('Navigating...'); await controller.tap(find.text('Material')); - await new Future.delayed(const Duration(milliseconds: 150)); + await Future.delayed(const Duration(milliseconds: 150)); final Finder demoList = find.byKey(const Key('GalleryDemoList')); final Finder demoItem = find.text('Text fields'); do { await controller.drag(demoList, const Offset(0.0, -300.0)); - await new Future.delayed(const Duration(milliseconds: 20)); + await Future.delayed(const Duration(milliseconds: 20)); } while (!demoItem.precache()); // Ensure that the center of the "Text fields" item is visible @@ -68,7 +68,7 @@ Future main() async { final Rect demoItemBounds = boundsFor(controller, demoItem); final Rect demoListBounds = boundsFor(controller, demoList); if (!demoListBounds.contains(demoItemBounds.center)) { - await controller.drag(demoList, new Offset(0.0, demoListBounds.center.dy - demoItemBounds.center.dy)); + await controller.drag(demoList, Offset(0.0, demoListBounds.center.dy - demoItemBounds.center.dy)); await endOfAnimation(); } diff --git a/examples/flutter_view/lib/main.dart b/examples/flutter_view/lib/main.dart index b20e646960..6e03a8387a 100644 --- a/examples/flutter_view/lib/main.dart +++ b/examples/flutter_view/lib/main.dart @@ -7,26 +7,26 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { - runApp(new FlutterView()); + runApp(FlutterView()); } class FlutterView extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Flutter View', - theme: new ThemeData( + theme: ThemeData( primarySwatch: Colors.grey, ), - home: new MyHomePage(), + home: MyHomePage(), ); } } class MyHomePage extends StatefulWidget { @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @@ -57,29 +57,29 @@ class _MyHomePageState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - body: new Column( + return Scaffold( + body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Expanded( - child: new Center( - child: new Text( + Expanded( + child: Center( + child: Text( 'Platform button tapped $_counter time${ _counter == 1 ? '' : 's' }.', style: const TextStyle(fontSize: 17.0)) ), ), - new Container( + Container( padding: const EdgeInsets.only(bottom: 15.0, left: 5.0), - child: new Row( + child: Row( children: [ - new Image.asset('assets/flutter-mark-square-64.png', scale: 1.5), + Image.asset('assets/flutter-mark-square-64.png', scale: 1.5), const Text('Flutter', style: TextStyle(fontSize: 30.0)), ], ), ), ], ), - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( onPressed: _sendFlutterIncrement, child: const Icon(Icons.add), ), diff --git a/examples/layers/raw/canvas.dart b/examples/layers/raw/canvas.dart index 6173a4ce1e..bd5d586480 100644 --- a/examples/layers/raw/canvas.dart +++ b/examples/layers/raw/canvas.dart @@ -13,17 +13,17 @@ ui.Picture paint(ui.Rect paintBounds) { // First we create a PictureRecorder to record the commands we're going to // feed in the canvas. The PictureRecorder will eventually produce a Picture, // which is an immutable record of those commands. - final ui.PictureRecorder recorder = new ui.PictureRecorder(); + final ui.PictureRecorder recorder = ui.PictureRecorder(); // Next, we create a canvas from the recorder. The canvas is an interface // which can receive drawing commands. The canvas interface is modeled after // the SkCanvas interface from Skia. The paintBounds establishes a "cull rect" // for the canvas, which lets the implementation discard any commands that // are entirely outside this rectangle. - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); - final ui.Paint paint = new ui.Paint(); - canvas.drawPaint(new ui.Paint()..color = const ui.Color(0xFFFFFFFF)); + final ui.Paint paint = ui.Paint(); + canvas.drawPaint(ui.Paint()..color = const ui.Color(0xFFFFFFFF)); final ui.Size size = paintBounds.size; final ui.Offset mid = size.center(ui.Offset.zero); @@ -34,22 +34,22 @@ ui.Picture paint(ui.Rect paintBounds) { canvas.save(); canvas.translate(-mid.dx / 2.0, logicalSize.height * 2.0); - canvas.clipRect(new ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius)); + canvas.clipRect(ui.Rect.fromLTRB(0.0, -logicalSize.height, logicalSize.width, radius)); canvas.translate(mid.dx, mid.dy); paint.color = const ui.Color.fromARGB(128, 255, 0, 255); canvas.rotate(math.pi/4.0); - final ui.Gradient yellowBlue = new ui.Gradient.linear( - new ui.Offset(-radius, -radius), + final ui.Gradient yellowBlue = ui.Gradient.linear( + ui.Offset(-radius, -radius), const ui.Offset(0.0, 0.0), [const ui.Color(0xFFFFFF00), const ui.Color(0xFF0000FF)], ); - canvas.drawRect(new ui.Rect.fromLTRB(-radius, -radius, radius, radius), - new ui.Paint()..shader = yellowBlue); + canvas.drawRect(ui.Rect.fromLTRB(-radius, -radius, radius, radius), + ui.Paint()..shader = yellowBlue); // Scale x and y by 0.5. - final Float64List scaleMatrix = new Float64List.fromList([ + final Float64List scaleMatrix = Float64List.fromList([ 0.5, 0.0, 0.0, 0.0, 0.0, 0.5, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, @@ -72,12 +72,12 @@ ui.Picture paint(ui.Rect paintBounds) { ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { final double devicePixelRatio = ui.window.devicePixelRatio; - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 ..[15] = 1.0; - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop(); diff --git a/examples/layers/raw/hello_world.dart b/examples/layers/raw/hello_world.dart index 83d3bb577e..7a9294ab2f 100644 --- a/examples/layers/raw/hello_world.dart +++ b/examples/layers/raw/hello_world.dart @@ -11,24 +11,24 @@ void beginFrame(Duration timeStamp) { final double devicePixelRatio = ui.window.devicePixelRatio; final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio; - final ui.ParagraphBuilder paragraphBuilder = new ui.ParagraphBuilder( - new ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), + final ui.ParagraphBuilder paragraphBuilder = ui.ParagraphBuilder( + ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), ) ..addText('Hello, world.'); final ui.Paragraph paragraph = paragraphBuilder.build() - ..layout(new ui.ParagraphConstraints(width: logicalSize.width)); + ..layout(ui.ParagraphConstraints(width: logicalSize.width)); final ui.Rect physicalBounds = ui.Offset.zero & (logicalSize * devicePixelRatio); - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final ui.Canvas canvas = new ui.Canvas(recorder, physicalBounds); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder, physicalBounds); canvas.scale(devicePixelRatio, devicePixelRatio); - canvas.drawParagraph(paragraph, new ui.Offset( + canvas.drawParagraph(paragraph, ui.Offset( (logicalSize.width - paragraph.maxIntrinsicWidth) / 2.0, (logicalSize.height - paragraph.height) / 2.0 )); final ui.Picture picture = recorder.endRecording(); - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() // TODO(abarth): We should be able to add a picture without pushing a // container layer first. ..pushClipRect(physicalBounds) diff --git a/examples/layers/raw/spinning_square.dart b/examples/layers/raw/spinning_square.dart index 1bc64c6066..adcbb8dbf4 100644 --- a/examples/layers/raw/spinning_square.dart +++ b/examples/layers/raw/spinning_square.dart @@ -20,8 +20,8 @@ void beginFrame(Duration timeStamp) { // PAINT final ui.Rect paintBounds = ui.Offset.zero & (ui.window.physicalSize / ui.window.devicePixelRatio); - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); canvas.translate(paintBounds.width / 2.0, paintBounds.height / 2.0); // Here we determine the rotation according to the timeStamp given to us by @@ -29,19 +29,19 @@ void beginFrame(Duration timeStamp) { final double t = timeStamp.inMicroseconds / Duration.microsecondsPerMillisecond / 1800.0; canvas.rotate(math.pi * (t % 1.0)); - canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), - new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); + canvas.drawRect(ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), + ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); final ui.Picture picture = recorder.endRecording(); // COMPOSITE final double devicePixelRatio = ui.window.devicePixelRatio; - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 ..[15] = 1.0; - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop(); diff --git a/examples/layers/raw/text.dart b/examples/layers/raw/text.dart index 6320822ef5..a54b90483e 100644 --- a/examples/layers/raw/text.dart +++ b/examples/layers/raw/text.dart @@ -12,31 +12,31 @@ import 'dart:ui' as ui; ui.Paragraph paragraph; ui.Picture paint(ui.Rect paintBounds) { - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); final double devicePixelRatio = ui.window.devicePixelRatio; final ui.Size logicalSize = ui.window.physicalSize / devicePixelRatio; canvas.translate(logicalSize.width / 2.0, logicalSize.height / 2.0); - canvas.drawRect(new ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), - new ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); + canvas.drawRect(ui.Rect.fromLTRB(-100.0, -100.0, 100.0, 100.0), + ui.Paint()..color = const ui.Color.fromARGB(255, 0, 255, 0)); // The paint method of Paragraph draws the contents of the paragraph onto the // given canvas. - canvas.drawParagraph(paragraph, new ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0)); + canvas.drawParagraph(paragraph, ui.Offset(-paragraph.width / 2.0, (paragraph.width / 2.0) - 125.0)); return recorder.endRecording(); } ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { final double devicePixelRatio = ui.window.devicePixelRatio; - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 ..[15] = 1.0; - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop(); @@ -52,18 +52,18 @@ void beginFrame(Duration timeStamp) { void main() { // To create a paragraph of text, we use ParagraphBuilder. - final ui.ParagraphBuilder builder = new ui.ParagraphBuilder( + final ui.ParagraphBuilder builder = ui.ParagraphBuilder( // The text below has a primary direction of left-to-right. // The embedded text has other directions. // If this was TextDirection.rtl, the "Hello, world" text would end up on // the other side of the right-to-left text. - new ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), + ui.ParagraphStyle(textDirection: ui.TextDirection.ltr), ) // We first push a style that turns the text blue. - ..pushStyle(new ui.TextStyle(color: const ui.Color(0xFF0000FF))) + ..pushStyle(ui.TextStyle(color: const ui.Color(0xFF0000FF))) ..addText('Hello, ') // The next run of text will be bold. - ..pushStyle(new ui.TextStyle(fontWeight: ui.FontWeight.bold)) + ..pushStyle(ui.TextStyle(fontWeight: ui.FontWeight.bold)) ..addText('world. ') // The pop() command signals the end of the bold styling. ..pop() @@ -84,7 +84,7 @@ void main() { // Next, we supply a width that the text is permitted to occupy and we ask // the paragraph to the visual position of each its glyphs as well as its // overall size, subject to its sizing constraints. - ..layout(new ui.ParagraphConstraints(width: 180.0)); + ..layout(ui.ParagraphConstraints(width: 180.0)); // Finally, we register our beginFrame callback and kick off the first frame. ui.window.onBeginFrame = beginFrame; diff --git a/examples/layers/raw/touch_input.dart b/examples/layers/raw/touch_input.dart index 05cf21e04f..52932b104d 100644 --- a/examples/layers/raw/touch_input.dart +++ b/examples/layers/raw/touch_input.dart @@ -14,21 +14,21 @@ ui.Picture paint(ui.Rect paintBounds) { // First we create a PictureRecorder to record the commands we're going to // feed in the canvas. The PictureRecorder will eventually produce a Picture, // which is an immutable record of those commands. - final ui.PictureRecorder recorder = new ui.PictureRecorder(); + final ui.PictureRecorder recorder = ui.PictureRecorder(); // Next, we create a canvas from the recorder. The canvas is an interface // which can receive drawing commands. The canvas interface is modeled after // the SkCanvas interface from Skia. The paintBounds establishes a "cull rect" // for the canvas, which lets the implementation discard any commands that // are entirely outside this rectangle. - final ui.Canvas canvas = new ui.Canvas(recorder, paintBounds); + final ui.Canvas canvas = ui.Canvas(recorder, paintBounds); // The commands draw a circle in the center of the screen. final ui.Size size = paintBounds.size; canvas.drawCircle( size.center(ui.Offset.zero), size.shortestSide * 0.45, - new ui.Paint()..color = color + ui.Paint()..color = color ); // When we're done issuing painting commands, we end the recording an receive @@ -46,7 +46,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { final double devicePixelRatio = ui.window.devicePixelRatio; // This transform scales the x and y coordinates by the devicePixelRatio. - final Float64List deviceTransform = new Float64List(16) + final Float64List deviceTransform = Float64List(16) ..[0] = devicePixelRatio ..[5] = devicePixelRatio ..[10] = 1.0 @@ -56,7 +56,7 @@ ui.Scene composite(ui.Picture picture, ui.Rect paintBounds) { // transform that scale its children by the device pixel ratio. This transform // lets us paint in "logical" pixels which are converted to device pixels by // this scaling operation. - final ui.SceneBuilder sceneBuilder = new ui.SceneBuilder() + final ui.SceneBuilder sceneBuilder = ui.SceneBuilder() ..pushTransform(deviceTransform) ..addPicture(ui.Offset.zero, picture) ..pop(); diff --git a/examples/layers/rendering/custom_coordinate_systems.dart b/examples/layers/rendering/custom_coordinate_systems.dart index c1dd8ceb37..208bcf1c05 100644 --- a/examples/layers/rendering/custom_coordinate_systems.dart +++ b/examples/layers/rendering/custom_coordinate_systems.dart @@ -9,17 +9,17 @@ import 'package:flutter/rendering.dart'; import 'src/sector_layout.dart'; RenderBox buildSectorExample() { - final RenderSectorRing rootCircle = new RenderSectorRing(padding: 20.0); - rootCircle.add(new RenderSolidColor(const Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15)); - rootCircle.add(new RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4)); - final RenderSectorSlice stack = new RenderSectorSlice(padding: 2.0); - stack.add(new RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.0)); - stack.add(new RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20.0)); - stack.add(new RenderSolidColor(const Color(0xFF00FF00))); + final RenderSectorRing rootCircle = RenderSectorRing(padding: 20.0); + rootCircle.add(RenderSolidColor(const Color(0xFF00FFFF), desiredDeltaTheta: kTwoPi * 0.15)); + rootCircle.add(RenderSolidColor(const Color(0xFF0000FF), desiredDeltaTheta: kTwoPi * 0.4)); + final RenderSectorSlice stack = RenderSectorSlice(padding: 2.0); + stack.add(RenderSolidColor(const Color(0xFFFFFF00), desiredDeltaRadius: 20.0)); + stack.add(RenderSolidColor(const Color(0xFFFF9000), desiredDeltaRadius: 20.0)); + stack.add(RenderSolidColor(const Color(0xFF00FF00))); rootCircle.add(stack); - return new RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle); + return RenderBoxToRenderSectorAdapter(innerRadius: 50.0, child: rootCircle); } void main() { - new RenderingFlutterBinding(root: buildSectorExample()); + RenderingFlutterBinding(root: buildSectorExample()); } diff --git a/examples/layers/rendering/flex_layout.dart b/examples/layers/rendering/flex_layout.dart index 3ed89fec04..5965520bcf 100644 --- a/examples/layers/rendering/flex_layout.dart +++ b/examples/layers/rendering/flex_layout.dart @@ -10,42 +10,42 @@ import 'package:flutter/rendering.dart'; import 'src/solid_color_box.dart'; void main() { - final RenderFlex table = new RenderFlex(direction: Axis.vertical, textDirection: TextDirection.ltr); + final RenderFlex table = RenderFlex(direction: Axis.vertical, textDirection: TextDirection.ltr); void addAlignmentRow(CrossAxisAlignment crossAxisAlignment) { TextStyle style = const TextStyle(color: Color(0xFF000000)); - final RenderParagraph paragraph = new RenderParagraph( - new TextSpan(style: style, text: '$crossAxisAlignment'), + final RenderParagraph paragraph = RenderParagraph( + TextSpan(style: style, text: '$crossAxisAlignment'), textDirection: TextDirection.ltr, ); - table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); - final RenderFlex row = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); + table.add(RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); + final RenderFlex row = RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); style = const TextStyle(fontSize: 15.0, color: Color(0xFF000000)); - row.add(new RenderDecoratedBox( + row.add(RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0x7FFFCCCC)), - child: new RenderParagraph( - new TextSpan(style: style, text: 'foo foo foo'), + child: RenderParagraph( + TextSpan(style: style, text: 'foo foo foo'), textDirection: TextDirection.ltr, ), )); style = const TextStyle(fontSize: 10.0, color: Color(0xFF000000)); - row.add(new RenderDecoratedBox( + row.add(RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0x7FCCFFCC)), - child: new RenderParagraph( - new TextSpan(style: style, text: 'foo foo foo'), + child: RenderParagraph( + TextSpan(style: style, text: 'foo foo foo'), textDirection: TextDirection.ltr, ), )); - final RenderFlex subrow = new RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); + final RenderFlex subrow = RenderFlex(crossAxisAlignment: crossAxisAlignment, textBaseline: TextBaseline.alphabetic, textDirection: TextDirection.ltr); style = const TextStyle(fontSize: 25.0, color: Color(0xFF000000)); - subrow.add(new RenderDecoratedBox( + subrow.add(RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0x7FCCCCFF)), - child: new RenderParagraph( - new TextSpan(style: style, text: 'foo foo foo foo'), + child: RenderParagraph( + TextSpan(style: style, text: 'foo foo foo foo'), textDirection: TextDirection.ltr, ), )); - subrow.add(new RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0))); + subrow.add(RenderSolidColorBox(const Color(0x7FCCFFFF), desiredSize: const Size(30.0, 40.0))); row.add(subrow); table.add(row); final FlexParentData rowParentData = row.parentData; @@ -60,15 +60,15 @@ void main() { void addJustificationRow(MainAxisAlignment justify) { const TextStyle style = TextStyle(color: Color(0xFF000000)); - final RenderParagraph paragraph = new RenderParagraph( - new TextSpan(style: style, text: '$justify'), + final RenderParagraph paragraph = RenderParagraph( + TextSpan(style: style, text: '$justify'), textDirection: TextDirection.ltr, ); - table.add(new RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); - final RenderFlex row = new RenderFlex(direction: Axis.horizontal, textDirection: TextDirection.ltr); - row.add(new RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: const Size(80.0, 60.0))); - row.add(new RenderSolidColorBox(const Color(0xFFCCFFCC), desiredSize: const Size(64.0, 60.0))); - row.add(new RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0))); + table.add(RenderPadding(child: paragraph, padding: const EdgeInsets.only(top: 20.0))); + final RenderFlex row = RenderFlex(direction: Axis.horizontal, textDirection: TextDirection.ltr); + row.add(RenderSolidColorBox(const Color(0xFFFFCCCC), desiredSize: const Size(80.0, 60.0))); + row.add(RenderSolidColorBox(const Color(0xFFCCFFCC), desiredSize: const Size(64.0, 60.0))); + row.add(RenderSolidColorBox(const Color(0xFFCCCCFF), desiredSize: const Size(160.0, 60.0))); row.mainAxisAlignment = justify; table.add(row); final FlexParentData rowParentData = row.parentData; @@ -81,10 +81,10 @@ void main() { addJustificationRow(MainAxisAlignment.spaceBetween); addJustificationRow(MainAxisAlignment.spaceAround); - final RenderDecoratedBox root = new RenderDecoratedBox( + final RenderDecoratedBox root = RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0xFFFFFFFF)), - child: new RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0)), + child: RenderPadding(child: table, padding: const EdgeInsets.symmetric(vertical: 50.0)), ); - new RenderingFlutterBinding(root: root); + RenderingFlutterBinding(root: root); } diff --git a/examples/layers/rendering/hello_world.dart b/examples/layers/rendering/hello_world.dart index 8480158014..1f49ca71c4 100644 --- a/examples/layers/rendering/hello_world.dart +++ b/examples/layers/rendering/hello_world.dart @@ -9,14 +9,14 @@ import 'package:flutter/rendering.dart'; void main() { // We use RenderingFlutterBinding to attach the render tree to the window. - new RenderingFlutterBinding( + RenderingFlutterBinding( // The root of our render tree is a RenderPositionedBox, which centers its // child both vertically and horizontally. - root: new RenderPositionedBox( + root: RenderPositionedBox( alignment: Alignment.center, // We use a RenderParagraph to display the text 'Hello, world.' without // any explicit styling. - child: new RenderParagraph( + child: RenderParagraph( const TextSpan(text: 'Hello, world.'), // The text is in English so we specify the text direction as // left-to-right. If the text had been in Hebrew or Arabic, we would diff --git a/examples/layers/rendering/spinning_square.dart b/examples/layers/rendering/spinning_square.dart index a611dfac1d..52f6afb80c 100644 --- a/examples/layers/rendering/spinning_square.dart +++ b/examples/layers/rendering/spinning_square.dart @@ -14,17 +14,17 @@ import 'package:flutter/scheduler.dart'; class NonStopVSync implements TickerProvider { const NonStopVSync(); @override - Ticker createTicker(TickerCallback onTick) => new Ticker(onTick); + Ticker createTicker(TickerCallback onTick) => Ticker(onTick); } void main() { // We first create a render object that represents a green box. - final RenderBox green = new RenderDecoratedBox( + final RenderBox green = RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0xFF00FF00)) ); // Second, we wrap that green box in a render object that forces the green box // to have a specific size. - final RenderBox square = new RenderConstrainedBox( + final RenderBox square = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0), child: green ); @@ -32,29 +32,29 @@ void main() { // transform before painting its child. Each frame of the animation, we'll // update the transform of this render object to cause the green square to // spin. - final RenderTransform spin = new RenderTransform( - transform: new Matrix4.identity(), + final RenderTransform spin = RenderTransform( + transform: Matrix4.identity(), alignment: Alignment.center, child: square ); // Finally, we center the spinning green square... - final RenderBox root = new RenderPositionedBox( + final RenderBox root = RenderPositionedBox( alignment: Alignment.center, child: spin ); // and attach it to the window. - new RenderingFlutterBinding(root: root); + RenderingFlutterBinding(root: root); // To make the square spin, we use an animation that repeats every 1800 // milliseconds. - final AnimationController animation = new AnimationController( + final AnimationController animation = AnimationController( duration: const Duration(milliseconds: 1800), vsync: const NonStopVSync(), )..repeat(); // The animation will produce a value between 0.0 and 1.0 each frame, but we // want to rotate the square using a value between 0.0 and math.pi. To change // the range of the animation, we use a Tween. - final Tween tween = new Tween(begin: 0.0, end: math.pi); + final Tween tween = Tween(begin: 0.0, end: math.pi); // We add a listener to the animation, which will be called every time the // animation ticks. animation.addListener(() { @@ -63,6 +63,6 @@ void main() { // of the animation. Setting this value will mark a number of dirty bits // inside the render tree, which cause the render tree to repaint with the // new transform value this frame. - spin.transform = new Matrix4.rotationZ(tween.evaluate(animation)); + spin.transform = Matrix4.rotationZ(tween.evaluate(animation)); }); } diff --git a/examples/layers/rendering/src/sector_layout.dart b/examples/layers/rendering/src/sector_layout.dart index 214089a608..0cbf123726 100644 --- a/examples/layers/rendering/src/sector_layout.dart +++ b/examples/layers/rendering/src/sector_layout.dart @@ -60,7 +60,7 @@ class SectorDimensions { SectorConstraints constraints, { double deltaRadius = 0.0, double deltaTheta = 0.0 } ) { - return new SectorDimensions( + return SectorDimensions( deltaRadius: constraints.constrainDeltaRadius(deltaRadius), deltaTheta: constraints.constrainDeltaTheta(deltaTheta) ); @@ -80,7 +80,7 @@ abstract class RenderSector extends RenderObject { @override void setupParentData(RenderObject child) { if (child.parentData is! SectorParentData) - child.parentData = new SectorParentData(); + child.parentData = SectorParentData(); } // RenderSectors always use SectorParentData subclasses, as they need to be @@ -89,7 +89,7 @@ abstract class RenderSector extends RenderObject { SectorParentData get parentData => super.parentData; SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { - return new SectorDimensions.withConstraints(constraints); + return SectorDimensions.withConstraints(constraints); } @override @@ -124,17 +124,17 @@ abstract class RenderSector extends RenderObject { } @override - Rect get paintBounds => new Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius); + Rect get paintBounds => Rect.fromLTWH(0.0, 0.0, 2.0 * deltaRadius, 2.0 * deltaRadius); @override - Rect get semanticBounds => new Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius); + Rect get semanticBounds => Rect.fromLTWH(-deltaRadius, -deltaRadius, 2.0 * deltaRadius, 2.0 * deltaRadius); bool hitTest(HitTestResult result, { double radius, double theta }) { if (radius < parentData.radius || radius >= parentData.radius + deltaRadius || theta < parentData.theta || theta >= parentData.theta + deltaTheta) return false; hitTestChildren(result, radius: radius, theta: theta); - result.add(new HitTestEntry(this)); + result.add(HitTestEntry(this)); return true; } void hitTestChildren(HitTestResult result, { double radius, double theta }) { } @@ -168,13 +168,13 @@ abstract class RenderDecoratedSector extends RenderSector { if (_decoration.color != null) { final Canvas canvas = context.canvas; - final Paint paint = new Paint()..color = _decoration.color; - final Path path = new Path(); + final Paint paint = Paint()..color = _decoration.color; + final Path path = Path(); final double outerRadius = parentData.radius + deltaRadius; - final Rect outerBounds = new Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius); + final Rect outerBounds = Rect.fromLTRB(offset.dx-outerRadius, offset.dy-outerRadius, offset.dx+outerRadius, offset.dy+outerRadius); path.arcTo(outerBounds, parentData.theta, deltaTheta, true); final double innerRadius = parentData.radius; - final Rect innerBounds = new Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius); + final Rect innerBounds = Rect.fromLTRB(offset.dx-innerRadius, offset.dy-innerRadius, offset.dx+innerRadius, offset.dy+innerRadius); path.arcTo(innerBounds, parentData.theta + deltaTheta, -deltaTheta, false); path.close(); canvas.drawPath(path, paint); @@ -248,7 +248,7 @@ class RenderSectorRing extends RenderSectorWithChildren { void setupParentData(RenderObject child) { // TODO(ianh): avoid code duplication if (child.parentData is! SectorChildListParentData) - child.parentData = new SectorChildListParentData(); + child.parentData = SectorChildListParentData(); } @override @@ -261,7 +261,7 @@ class RenderSectorRing extends RenderSectorWithChildren { double remainingDeltaTheta = math.max(0.0, constraints.maxDeltaTheta - (innerTheta + paddingTheta)); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: innerDeltaRadius, maxDeltaTheta: remainingDeltaTheta ); @@ -275,7 +275,7 @@ class RenderSectorRing extends RenderSectorWithChildren { remainingDeltaTheta -= paddingTheta; } } - return new SectorDimensions.withConstraints(constraints, + return SectorDimensions.withConstraints(constraints, deltaRadius: outerDeltaRadius, deltaTheta: innerTheta); } @@ -292,7 +292,7 @@ class RenderSectorRing extends RenderSectorWithChildren { double remainingDeltaTheta = constraints.maxDeltaTheta - (innerTheta + paddingTheta); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: innerDeltaRadius, maxDeltaTheta: remainingDeltaTheta ); @@ -362,7 +362,7 @@ class RenderSectorSlice extends RenderSectorWithChildren { void setupParentData(RenderObject child) { // TODO(ianh): avoid code duplication if (child.parentData is! SectorChildListParentData) - child.parentData = new SectorChildListParentData(); + child.parentData = SectorChildListParentData(); } @override @@ -375,7 +375,7 @@ class RenderSectorSlice extends RenderSectorWithChildren { double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: remainingDeltaRadius, maxDeltaTheta: innerDeltaTheta ); @@ -387,7 +387,7 @@ class RenderSectorSlice extends RenderSectorWithChildren { childRadius += padding; remainingDeltaRadius -= padding; } - return new SectorDimensions.withConstraints(constraints, + return SectorDimensions.withConstraints(constraints, deltaRadius: childRadius - parentData.radius, deltaTheta: outerDeltaTheta); } @@ -404,7 +404,7 @@ class RenderSectorSlice extends RenderSectorWithChildren { double remainingDeltaRadius = constraints.maxDeltaRadius - (padding * 2.0); RenderSector child = firstChild; while (child != null) { - final SectorConstraints innerConstraints = new SectorConstraints( + final SectorConstraints innerConstraints = SectorConstraints( maxDeltaRadius: remainingDeltaRadius, maxDeltaTheta: innerDeltaTheta ); @@ -455,7 +455,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil @override void setupParentData(RenderObject child) { if (child.parentData is! SectorParentData) - child.parentData = new SectorParentData(); + child.parentData = SectorParentData(); } @override @@ -497,9 +497,9 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil if (!width.isFinite && !height.isFinite) return Size.zero; final double maxChildDeltaRadius = math.max(0.0, math.min(width, height) / 2.0 - innerRadius); - final SectorDimensions childDimensions = child.getIntrinsicDimensions(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius); + final SectorDimensions childDimensions = child.getIntrinsicDimensions(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), innerRadius); final double dimension = (innerRadius + childDimensions.deltaRadius) * 2.0; - return new Size.square(dimension); + return Size.square(dimension); } @override @@ -513,9 +513,9 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil final double maxChildDeltaRadius = math.min(constraints.maxWidth, constraints.maxHeight) / 2.0 - innerRadius; child.parentData.radius = innerRadius; child.parentData.theta = 0.0; - child.layout(new SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true); + child.layout(SectorConstraints(maxDeltaRadius: maxChildDeltaRadius), parentUsesSize: true); final double dimension = (innerRadius + child.deltaRadius) * 2.0; - size = constraints.constrain(new Size(dimension, dimension)); + size = constraints.constrain(Size(dimension, dimension)); } @override @@ -547,7 +547,7 @@ class RenderBoxToRenderSectorAdapter extends RenderBox with RenderObjectWithChil if (theta > child.deltaTheta) return false; child.hitTest(result, radius: radius, theta: theta); - result.add(new BoxHitTestEntry(this, position)); + result.add(BoxHitTestEntry(this, position)); return true; } @@ -557,7 +557,7 @@ class RenderSolidColor extends RenderDecoratedSector { RenderSolidColor(this.backgroundColor, { this.desiredDeltaRadius = double.infinity, this.desiredDeltaTheta = kTwoPi - }) : super(new BoxDecoration(color: backgroundColor)); + }) : super(BoxDecoration(color: backgroundColor)); double desiredDeltaRadius; double desiredDeltaTheta; @@ -565,7 +565,7 @@ class RenderSolidColor extends RenderDecoratedSector { @override SectorDimensions getIntrinsicDimensions(SectorConstraints constraints, double radius) { - return new SectorDimensions.withConstraints(constraints, deltaTheta: desiredDeltaTheta); + return SectorDimensions.withConstraints(constraints, deltaTheta: desiredDeltaTheta); } @override @@ -579,7 +579,7 @@ class RenderSolidColor extends RenderDecoratedSector { if (event is PointerDownEvent) { decoration = const BoxDecoration(color: Color(0xFFFF0000)); } else if (event is PointerUpEvent) { - decoration = new BoxDecoration(color: backgroundColor); + decoration = BoxDecoration(color: backgroundColor); } } } diff --git a/examples/layers/rendering/src/solid_color_box.dart b/examples/layers/rendering/src/solid_color_box.dart index b34faac16c..419d181273 100644 --- a/examples/layers/rendering/src/solid_color_box.dart +++ b/examples/layers/rendering/src/solid_color_box.dart @@ -10,7 +10,7 @@ class RenderSolidColorBox extends RenderDecoratedBox { final Color backgroundColor; RenderSolidColorBox(this.backgroundColor, { this.desiredSize = Size.infinite }) - : super(decoration: new BoxDecoration(color: backgroundColor)); + : super(decoration: BoxDecoration(color: backgroundColor)); @override double computeMinIntrinsicWidth(double height) { @@ -42,7 +42,7 @@ class RenderSolidColorBox extends RenderDecoratedBox { if (event is PointerDownEvent) { decoration = const BoxDecoration(color: Color(0xFFFF0000)); } else if (event is PointerUpEvent) { - decoration = new BoxDecoration(color: backgroundColor); + decoration = BoxDecoration(color: backgroundColor); } } } diff --git a/examples/layers/rendering/touch_input.dart b/examples/layers/rendering/touch_input.dart index d766a5ee37..aa914b93c3 100644 --- a/examples/layers/rendering/touch_input.dart +++ b/examples/layers/rendering/touch_input.dart @@ -20,7 +20,7 @@ List _kColors = [ /// A simple model object for a dot that reacts to pointer pressure. class Dot { - Dot({ Color color }) : _paint = new Paint()..color = color; + Dot({ Color color }) : _paint = Paint()..color = color; final Paint _paint; Offset position = Offset.zero; @@ -66,7 +66,7 @@ class RenderDots extends RenderBox { void handleEvent(PointerEvent event, BoxHitTestEntry entry) { if (event is PointerDownEvent) { final Color color = _kColors[event.pointer.remainder(_kColors.length)]; - _dots[event.pointer] = new Dot(color: color)..update(event); + _dots[event.pointer] = Dot(color: color)..update(event); // We call markNeedsPaint to indicate that our painting commands have // changed and that paint needs to be called before displaying a new frame // to the user. It's harmless to call markNeedsPaint multiple times @@ -91,7 +91,7 @@ class RenderDots extends RenderBox { // Passing offset during the render tree's paint walk is an optimization to // avoid having to change the origin of the canvas's coordinate system too // often. - canvas.drawRect(offset & size, new Paint()..color = const Color(0xFFFFFFFF)); + canvas.drawRect(offset & size, Paint()..color = const Color(0xFFFFFFFF)); // We iterate through our model and paint each dot. for (Dot dot in _dots.values) @@ -101,7 +101,7 @@ class RenderDots extends RenderBox { void main() { // Create some styled text to tell the user to interact with the app. - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan( style: TextStyle(color: Colors.black87), text: 'Touch me!', @@ -111,10 +111,10 @@ void main() { // A stack is a render object that layers its children on top of each other. // The bottom later is our RenderDots object, and on top of that we show the // text. - final RenderStack stack = new RenderStack( + final RenderStack stack = RenderStack( textDirection: TextDirection.ltr, children: [ - new RenderDots(), + RenderDots(), paragraph, ], ); @@ -132,5 +132,5 @@ void main() { ..left = 20.0; // Finally, we attach the render tree we've built to the screen. - new RenderingFlutterBinding(root: stack); + RenderingFlutterBinding(root: stack); } diff --git a/examples/layers/services/isolate.dart b/examples/layers/services/isolate.dart index c4c7fd2700..0536aeedde 100644 --- a/examples/layers/services/isolate.dart +++ b/examples/layers/services/isolate.dart @@ -36,7 +36,7 @@ class Calculator { // Run the computation associated with this Calculator. void run() { int i = 0; - final JsonDecoder decoder = new JsonDecoder( + final JsonDecoder decoder = JsonDecoder( (dynamic key, dynamic value) { if (key is int && i++ % _NOTIFY_INTERVAL == 0) onProgressListener(i.toDouble(), _NUM_ITEMS.toDouble()); @@ -54,7 +54,7 @@ class Calculator { } static String _replicateJson(String data, int count) { - final StringBuffer buffer = new StringBuffer()..write('['); + final StringBuffer buffer = StringBuffer()..write('['); for (int i = 0; i < count; i++) { buffer.write(data); if (i < count - 1) @@ -88,7 +88,7 @@ class CalculationManager { CalculationManager({ @required this.onProgressListener, @required this.onResultListener }) : assert(onProgressListener != null), assert(onResultListener != null), - _receivePort = new ReceivePort() { + _receivePort = ReceivePort() { _receivePort.listen(_handleMessage); } @@ -138,7 +138,7 @@ class CalculationManager { // loaded. rootBundle.loadString('services/data.json').then((String data) { if (isRunning) { - final CalculationMessage message = new CalculationMessage(data, _receivePort.sendPort); + final CalculationMessage message = CalculationMessage(data, _receivePort.sendPort); // Spawn an isolate to JSON-parse the file contents. The JSON parsing // is synchronous, so if done in the main isolate, the UI would block. Isolate.spawn(_calculate, message).then((Isolate isolate) { @@ -178,7 +178,7 @@ class CalculationManager { // in a separate memory space. static void _calculate(CalculationMessage message) { final SendPort sender = message.sendPort; - final Calculator calculator = new Calculator( + final Calculator calculator = Calculator( onProgressListener: (double completed, double total) { sender.send([ completed, total ]); }, @@ -199,7 +199,7 @@ class CalculationManager { // the AnimationController for the running animation. class IsolateExampleWidget extends StatefulWidget { @override - IsolateExampleState createState() => new IsolateExampleState(); + IsolateExampleState createState() => IsolateExampleState(); } // Main application state. @@ -215,11 +215,11 @@ class IsolateExampleState extends State with SingleTickerProvide @override void initState() { super.initState(); - _animation = new AnimationController( + _animation = AnimationController( duration: const Duration(milliseconds: 3600), vsync: this, )..repeat(); - _calculationManager = new CalculationManager( + _calculationManager = CalculationManager( onProgressListener: _handleProgressUpdate, onResultListener: _handleResult ); @@ -233,32 +233,32 @@ class IsolateExampleState extends State with SingleTickerProvide @override Widget build(BuildContext context) { - return new Material( - child: new Column( + return Material( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new RotationTransition( + RotationTransition( turns: _animation, - child: new Container( + child: Container( width: 120.0, height: 120.0, color: const Color(0xFF882222), ) ), - new Opacity( + Opacity( opacity: _calculationManager.isRunning ? 1.0 : 0.0, - child: new CircularProgressIndicator( + child: CircularProgressIndicator( value: _progress ) ), - new Text(_status), - new Center( - child: new RaisedButton( - child: new Text(_label), + Text(_status), + Center( + child: RaisedButton( + child: Text(_label), onPressed: _handleButtonPressed ) ), - new Text(_result) + Text(_result) ] ) ); @@ -303,5 +303,5 @@ class IsolateExampleState extends State with SingleTickerProvide } void main() { - runApp(new MaterialApp(home: new IsolateExampleWidget())); + runApp(MaterialApp(home: IsolateExampleWidget())); } diff --git a/examples/layers/services/lifecycle.dart b/examples/layers/services/lifecycle.dart index 36f3c50877..ab3bda2b40 100644 --- a/examples/layers/services/lifecycle.dart +++ b/examples/layers/services/lifecycle.dart @@ -8,7 +8,7 @@ class LifecycleWatcher extends StatefulWidget { const LifecycleWatcher({ Key key }) : super(key: key); @override - _LifecycleWatcherState createState() => new _LifecycleWatcherState(); + _LifecycleWatcherState createState() => _LifecycleWatcherState(); } class _LifecycleWatcherState extends State @@ -38,7 +38,7 @@ class _LifecycleWatcherState extends State Widget build(BuildContext context) { if (_lastLifecycleState == null) return const Text('This widget has not observed any lifecycle changes.'); - return new Text('The most recent lifecycle state this widget observed was: $_lastLifecycleState.'); + return Text('The most recent lifecycle state this widget observed was: $_lastLifecycleState.'); } } diff --git a/examples/layers/test/gestures_test.dart b/examples/layers/test/gestures_test.dart index 902385a43c..c37b1d2c81 100644 --- a/examples/layers/test/gestures_test.dart +++ b/examples/layers/test/gestures_test.dart @@ -9,9 +9,9 @@ import '../widgets/gestures.dart'; void main() { testWidgets('Tap on center change color', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new GestureDemo(), + child: GestureDemo(), )); final Finder finder = find.byType(GestureDemo); diff --git a/examples/layers/test/sector_test.dart b/examples/layers/test/sector_test.dart index 3903e9d924..0207f18d7e 100644 --- a/examples/layers/test/sector_test.dart +++ b/examples/layers/test/sector_test.dart @@ -13,6 +13,6 @@ void main() { }); testWidgets('Sector Sixes', (WidgetTester tester) async { - await tester.pumpWidget(new SectorApp()); + await tester.pumpWidget(SectorApp()); }); } diff --git a/examples/layers/widgets/custom_render_box.dart b/examples/layers/widgets/custom_render_box.dart index cd7c78b13b..2a5f832869 100644 --- a/examples/layers/widgets/custom_render_box.dart +++ b/examples/layers/widgets/custom_render_box.dart @@ -28,9 +28,9 @@ class RenderDots extends RenderConstrainedBox { @override void paint(PaintingContext context, Offset offset) { final Canvas canvas = context.canvas; - canvas.drawRect(offset & size, new Paint()..color = const Color(0xFF0000FF)); + canvas.drawRect(offset & size, Paint()..color = const Color(0xFF0000FF)); - final Paint paint = new Paint()..color = const Color(0xFF00FF00); + final Paint paint = Paint()..color = const Color(0xFF00FF00); for (Offset point in _dots.values) canvas.drawCircle(point, 50.0, paint); @@ -42,7 +42,7 @@ class Dots extends SingleChildRenderObjectWidget { const Dots({ Key key, Widget child }) : super(key: key, child: child); @override - RenderDots createRenderObject(BuildContext context) => new RenderDots(); + RenderDots createRenderObject(BuildContext context) => RenderDots(); } void main() { diff --git a/examples/layers/widgets/gestures.dart b/examples/layers/widgets/gestures.dart index c751399f11..1e884a9061 100644 --- a/examples/layers/widgets/gestures.dart +++ b/examples/layers/widgets/gestures.dart @@ -29,12 +29,12 @@ class _GesturePainter extends CustomPainter { void paint(Canvas canvas, Size size) { final Offset center = size.center(Offset.zero) * zoom + offset; final double radius = size.width / 2.0 * zoom; - final Gradient gradient = new RadialGradient( + final Gradient gradient = RadialGradient( colors: forward ? [swatch.shade50, swatch.shade900] : [swatch.shade900, swatch.shade50] ); - final Paint paint = new Paint() - ..shader = gradient.createShader(new Rect.fromCircle( + final Paint paint = Paint() + ..shader = gradient.createShader(Rect.fromCircle( center: center, radius: radius, )); @@ -56,7 +56,7 @@ class _GesturePainter extends CustomPainter { class GestureDemo extends StatefulWidget { @override - GestureDemoState createState() => new GestureDemoState(); + GestureDemoState createState() => GestureDemoState(); } class GestureDemoState extends State { @@ -141,17 +141,17 @@ class GestureDemoState extends State { @override Widget build(BuildContext context) { - return new Stack( + return Stack( fit: StackFit.expand, children: [ - new GestureDetector( + GestureDetector( onScaleStart: _scaleEnabled ? _handleScaleStart : null, onScaleUpdate: _scaleEnabled ? _handleScaleUpdate : null, onTap: _tapEnabled ? _handleColorChange : null, onDoubleTap: _doubleTapEnabled ? _handleScaleReset : null, onLongPress: _longPressEnabled ? _handleDirectionChange : null, - child: new CustomPaint( - painter: new _GesturePainter( + child: CustomPaint( + painter: _GesturePainter( zoom: _zoom, offset: _offset, swatch: swatch, @@ -163,44 +163,44 @@ class GestureDemoState extends State { ) ) ), - new Positioned( + Positioned( bottom: 0.0, left: 0.0, - child: new Card( - child: new Container( + child: Card( + child: Container( padding: const EdgeInsets.all(4.0), - child: new Column( + child: Column( children: [ - new Row( + Row( children: [ - new Checkbox( + Checkbox( value: _scaleEnabled, onChanged: (bool value) { setState(() { _scaleEnabled = value; }); } ), const Text('Scale'), ] ), - new Row( + Row( children: [ - new Checkbox( + Checkbox( value: _tapEnabled, onChanged: (bool value) { setState(() { _tapEnabled = value; }); } ), const Text('Tap'), ] ), - new Row( + Row( children: [ - new Checkbox( + Checkbox( value: _doubleTapEnabled, onChanged: (bool value) { setState(() { _doubleTapEnabled = value; }); } ), const Text('Double Tap'), ] ), - new Row( + Row( children: [ - new Checkbox( + Checkbox( value: _longPressEnabled, onChanged: (bool value) { setState(() { _longPressEnabled = value; }); } ), @@ -219,11 +219,11 @@ class GestureDemoState extends State { } void main() { - runApp(new MaterialApp( - theme: new ThemeData.dark(), - home: new Scaffold( - appBar: new AppBar(title: const Text('Gestures Demo')), - body: new GestureDemo() + runApp(MaterialApp( + theme: ThemeData.dark(), + home: Scaffold( + appBar: AppBar(title: const Text('Gestures Demo')), + body: GestureDemo() ) )); } diff --git a/examples/layers/widgets/media_query.dart b/examples/layers/widgets/media_query.dart index ef929b80b0..69ed7f3497 100644 --- a/examples/layers/widgets/media_query.dart +++ b/examples/layers/widgets/media_query.dart @@ -11,15 +11,15 @@ class AdaptedListItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new Row( + return Row( children: [ - new Container( + Container( width: 32.0, height: 32.0, margin: const EdgeInsets.all(8.0), color: Colors.lightBlueAccent.shade100, ), - new Text(name) + Text(name) ] ); } @@ -32,20 +32,20 @@ class AdaptedGridItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new Card( - child: new Column( + return Card( + child: Column( children: [ - new Expanded( - child: new Container( + Expanded( + child: Container( color: Colors.lightBlueAccent.shade100, ) ), - new Container( + Container( margin: const EdgeInsets.only(left: 8.0), - child: new Row( + child: Row( children: [ - new Expanded( - child: new Text(name) + Expanded( + child: Text(name) ), const IconButton( icon: Icon(Icons.more_vert), @@ -72,14 +72,14 @@ class AdaptiveContainer extends StatelessWidget { @override Widget build(BuildContext context) { if (MediaQuery.of(context).size.width < _kGridViewBreakpoint) { - return new ListView( + return ListView( itemExtent: _kListItemExtent, - children: names.map((String name) => new AdaptedListItem(name: name)).toList(), + children: names.map((String name) => AdaptedListItem(name: name)).toList(), ); } else { - return new GridView.extent( + return GridView.extent( maxCrossAxisExtent: _kMaxTileWidth, - children: names.map((String name) => new AdaptedGridItem(name: name)).toList(), + children: names.map((String name) => AdaptedGridItem(name: name)).toList(), ); } } @@ -95,13 +95,13 @@ List _initNames() { final List _kNames = _initNames(); void main() { - runApp(new MaterialApp( + runApp(MaterialApp( title: 'Media Query Example', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Media Query Example') ), - body: new Material(child: new AdaptiveContainer(names: _kNames)) + body: Material(child: AdaptiveContainer(names: _kNames)) ) )); } diff --git a/examples/layers/widgets/sectors.dart b/examples/layers/widgets/sectors.dart index 85e7de4752..b8fae26c00 100644 --- a/examples/layers/widgets/sectors.dart +++ b/examples/layers/widgets/sectors.dart @@ -10,21 +10,21 @@ import 'package:flutter/rendering.dart'; import '../rendering/src/sector_layout.dart'; RenderBox initCircle() { - return new RenderBoxToRenderSectorAdapter( + return RenderBoxToRenderSectorAdapter( innerRadius: 25.0, - child: new RenderSectorRing(padding: 0.0) + child: RenderSectorRing(padding: 0.0) ); } class SectorApp extends StatefulWidget { @override - SectorAppState createState() => new SectorAppState(); + SectorAppState createState() => SectorAppState(); } class SectorAppState extends State { final RenderBoxToRenderSectorAdapter sectors = initCircle(); - final math.Random rand = new math.Random(1); + final math.Random rand = math.Random(1); List wantedSectorSizes = []; List actualSectorSizes = []; @@ -60,19 +60,19 @@ class SectorAppState extends State { actualSectorSizes.removeLast(); } while (index < wantedSectorSizes.length) { - final Color color = new Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); - ring.add(new RenderSolidColor(color, desiredDeltaTheta: wantedSectorSizes[index])); + final Color color = Color(((0xFF << 24) + rand.nextInt(0xFFFFFF)) | 0x808080); + ring.add(RenderSolidColor(color, desiredDeltaTheta: wantedSectorSizes[index])); actualSectorSizes.add(wantedSectorSizes[index]); index += 1; } } static RenderBox initSector(Color color) { - final RenderSectorRing ring = new RenderSectorRing(padding: 1.0); - ring.add(new RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); - ring.add(new RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); - ring.add(new RenderSolidColor(color, desiredDeltaTheta: kTwoPi * 0.2)); - return new RenderBoxToRenderSectorAdapter( + final RenderSectorRing ring = RenderSectorRing(padding: 1.0); + ring.add(RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); + ring.add(RenderSolidColor(const Color(0xFF909090), desiredDeltaTheta: kTwoPi * 0.15)); + ring.add(RenderSolidColor(color, desiredDeltaTheta: kTwoPi * 0.2)); + return RenderBoxToRenderSectorAdapter( innerRadius: 5.0, child: ring ); @@ -90,36 +90,36 @@ class SectorAppState extends State { } Widget buildBody() { - return new Column( + return Column( children: [ - new Container( + Container( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 25.0), - child: new Row( + child: Row( children: [ - new RaisedButton( + RaisedButton( onPressed: _enabledAdd ? addSector : null, - child: new IntrinsicWidth( - child: new Row( + child: IntrinsicWidth( + child: Row( children: [ - new Container( + Container( padding: const EdgeInsets.all(4.0), margin: const EdgeInsets.only(right: 10.0), - child: new WidgetToRenderBoxAdapter(renderBox: sectorAddIcon) + child: WidgetToRenderBoxAdapter(renderBox: sectorAddIcon) ), const Text('ADD SECTOR'), ] ) ) ), - new RaisedButton( + RaisedButton( onPressed: _enabledRemove ? removeSector : null, - child: new IntrinsicWidth( - child: new Row( + child: IntrinsicWidth( + child: Row( children: [ - new Container( + Container( padding: const EdgeInsets.all(4.0), margin: const EdgeInsets.only(right: 10.0), - child: new WidgetToRenderBoxAdapter(renderBox: sectorRemoveIcon) + child: WidgetToRenderBoxAdapter(renderBox: sectorRemoveIcon) ), const Text('REMOVE SECTOR'), ] @@ -130,14 +130,14 @@ class SectorAppState extends State { mainAxisAlignment: MainAxisAlignment.spaceAround ) ), - new Expanded( - child: new Container( + Expanded( + child: Container( margin: const EdgeInsets.all(8.0), - decoration: new BoxDecoration( - border: new Border.all() + decoration: BoxDecoration( + border: Border.all() ), padding: const EdgeInsets.all(8.0), - child: new WidgetToRenderBoxAdapter( + child: WidgetToRenderBoxAdapter( renderBox: sectors, onBuild: doUpdates ) @@ -150,11 +150,11 @@ class SectorAppState extends State { @override Widget build(BuildContext context) { - return new MaterialApp( - theme: new ThemeData.light(), + return MaterialApp( + theme: ThemeData.light(), title: 'Sector Layout', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Sector Layout in a Widget Tree') ), body: buildBody() @@ -164,5 +164,5 @@ class SectorAppState extends State { } void main() { - runApp(new SectorApp()); + runApp(SectorApp()); } diff --git a/examples/layers/widgets/spinning_mixed.dart b/examples/layers/widgets/spinning_mixed.dart index aaf4eb6fc2..4801ac7dd4 100644 --- a/examples/layers/widgets/spinning_mixed.dart +++ b/examples/layers/widgets/spinning_mixed.dart @@ -9,7 +9,7 @@ import '../rendering/src/solid_color_box.dart'; // Solid colour, RenderObject version void addFlexChildSolidColor(RenderFlex parent, Color backgroundColor, { int flex = 0 }) { - final RenderSolidColorBox child = new RenderSolidColorBox(backgroundColor); + final RenderSolidColorBox child = RenderSolidColorBox(backgroundColor); parent.add(child); final FlexParentData childParentData = child.parentData; childParentData.flex = flex; @@ -23,8 +23,8 @@ class Rectangle extends StatelessWidget { @override Widget build(BuildContext context) { - return new Expanded( - child: new Container( + return Expanded( + child: Container( color: color, ) ); @@ -33,27 +33,27 @@ class Rectangle extends StatelessWidget { double value; RenderObjectToWidgetElement element; -BuildOwner owner = new BuildOwner(); +BuildOwner owner = BuildOwner(); void attachWidgetTreeToRenderTree(RenderProxyBox container) { - element = new RenderObjectToWidgetAdapter( + element = RenderObjectToWidgetAdapter( container: container, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new Container( + child: Container( height: 300.0, - child: new Column( + child: Column( children: [ const Rectangle(Color(0xFF00FFFF)), - new Material( - child: new Container( + Material( + child: Container( padding: const EdgeInsets.all(10.0), margin: const EdgeInsets.all(10.0), - child: new Row( + child: Row( children: [ - new RaisedButton( - child: new Row( + RaisedButton( + child: Row( children: [ - new Image.network('https://flutter.io/images/favicon.png'), + Image.network('https://flutter.io/images/favicon.png'), const Text('PRESS ME'), ], ), @@ -62,7 +62,7 @@ void attachWidgetTreeToRenderTree(RenderProxyBox container) { attachWidgetTreeToRenderTree(container); }, ), - new CircularProgressIndicator(value: value), + CircularProgressIndicator(value: value), ], mainAxisAlignment: MainAxisAlignment.spaceAround, ), @@ -92,16 +92,16 @@ void rotate(Duration timeStamp) { void main() { final WidgetsBinding binding = WidgetsFlutterBinding.ensureInitialized(); - final RenderProxyBox proxy = new RenderProxyBox(); + final RenderProxyBox proxy = RenderProxyBox(); attachWidgetTreeToRenderTree(proxy); - final RenderFlex flexRoot = new RenderFlex(direction: Axis.vertical); + final RenderFlex flexRoot = RenderFlex(direction: Axis.vertical); addFlexChildSolidColor(flexRoot, const Color(0xFFFF00FF), flex: 1); flexRoot.add(proxy); addFlexChildSolidColor(flexRoot, const Color(0xFF0000FF), flex: 1); - transformBox = new RenderTransform(child: flexRoot, transform: new Matrix4.identity(), alignment: Alignment.center); - final RenderPadding root = new RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox); + transformBox = RenderTransform(child: flexRoot, transform: Matrix4.identity(), alignment: Alignment.center); + final RenderPadding root = RenderPadding(padding: const EdgeInsets.all(80.0), child: transformBox); binding.renderView.child = root; binding.addPersistentFrameCallback(rotate); diff --git a/examples/layers/widgets/spinning_square.dart b/examples/layers/widgets/spinning_square.dart index 81312d6109..6539ffc3a4 100644 --- a/examples/layers/widgets/spinning_square.dart +++ b/examples/layers/widgets/spinning_square.dart @@ -6,7 +6,7 @@ import 'package:flutter/widgets.dart'; class SpinningSquare extends StatefulWidget { @override - _SpinningSquareState createState() => new _SpinningSquareState(); + _SpinningSquareState createState() => _SpinningSquareState(); } class _SpinningSquareState extends State with SingleTickerProviderStateMixin { @@ -18,7 +18,7 @@ class _SpinningSquareState extends State with SingleTickerProvid // We use 3600 milliseconds instead of 1800 milliseconds because 0.0 -> 1.0 // represents an entire turn of the square whereas in the other examples // we used 0.0 -> math.pi, which is only half a turn. - _animation = new AnimationController( + _animation = AnimationController( duration: const Duration(milliseconds: 3600), vsync: this, )..repeat(); @@ -32,9 +32,9 @@ class _SpinningSquareState extends State with SingleTickerProvid @override Widget build(BuildContext context) { - return new RotationTransition( + return RotationTransition( turns: _animation, - child: new Container( + child: Container( width: 200.0, height: 200.0, color: const Color(0xFF00FF00), @@ -44,5 +44,5 @@ class _SpinningSquareState extends State with SingleTickerProvid } void main() { - runApp(new Center(child: new SpinningSquare())); + runApp(Center(child: SpinningSquare())); } diff --git a/examples/layers/widgets/styled_text.dart b/examples/layers/widgets/styled_text.dart index e8cf81cdf3..0694aa2859 100644 --- a/examples/layers/widgets/styled_text.dart +++ b/examples/layers/widgets/styled_text.dart @@ -23,8 +23,8 @@ final List> _kNameLines = _kDialogText .map((String line) => line.split(':')) .toList(); -final TextStyle _kDaveStyle = new TextStyle(color: Colors.indigo.shade400, height: 1.8); -final TextStyle _kHalStyle = new TextStyle(color: Colors.red.shade400, fontFamily: 'monospace'); +final TextStyle _kDaveStyle = TextStyle(color: Colors.indigo.shade400, height: 1.8); +final TextStyle _kHalStyle = TextStyle(color: Colors.red.shade400, fontFamily: 'monospace'); const TextStyle _kBold = TextStyle(fontWeight: FontWeight.bold); const TextStyle _kUnderline = TextStyle( decoration: TextDecoration.underline, @@ -34,33 +34,33 @@ const TextStyle _kUnderline = TextStyle( Widget toStyledText(String name, String text) { final TextStyle lineStyle = (name == 'Dave') ? _kDaveStyle : _kHalStyle; - return new RichText( - key: new Key(text), - text: new TextSpan( + return RichText( + key: Key(text), + text: TextSpan( style: lineStyle, children: [ - new TextSpan( + TextSpan( style: _kBold, children: [ - new TextSpan( + TextSpan( style: _kUnderline, text: name ), const TextSpan(text: ':') ] ), - new TextSpan(text: text) + TextSpan(text: text) ] ) ); } -Widget toPlainText(String name, String text) => new Text(name + ':' + text); +Widget toPlainText(String name, String text) => Text(name + ':' + text); class SpeakerSeparator extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( constraints: const BoxConstraints.expand(height: 0.0), margin: const EdgeInsets.symmetric(vertical: 10.0, horizontal: 64.0), decoration: const BoxDecoration( @@ -74,7 +74,7 @@ class SpeakerSeparator extends StatelessWidget { class StyledTextDemo extends StatefulWidget { @override - _StyledTextDemoState createState() => new _StyledTextDemoState(); + _StyledTextDemoState createState() => _StyledTextDemoState(); } class _StyledTextDemoState extends State { @@ -102,14 +102,14 @@ class _StyledTextDemoState extends State { for (Widget line in lines) { children.add(line); if (line != lines.last) - children.add(new SpeakerSeparator()); + children.add(SpeakerSeparator()); } - return new GestureDetector( + return GestureDetector( onTap: _handleTap, - child: new Container( + child: Container( padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new Column( + child: Column( children: children, mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start @@ -120,15 +120,15 @@ class _StyledTextDemoState extends State { } void main() { - runApp(new MaterialApp( - theme: new ThemeData.light(), - home: new Scaffold( - appBar: new AppBar( + runApp(MaterialApp( + theme: ThemeData.light(), + home: Scaffold( + appBar: AppBar( title: const Text('Hal and Dave') ), - body: new Material( + body: Material( color: Colors.grey.shade50, - child: new StyledTextDemo() + child: StyledTextDemo() ) ) )); diff --git a/examples/platform_channel/lib/main.dart b/examples/platform_channel/lib/main.dart index 41129cc11f..8739a010d8 100644 --- a/examples/platform_channel/lib/main.dart +++ b/examples/platform_channel/lib/main.dart @@ -9,7 +9,7 @@ import 'package:flutter/services.dart'; class PlatformChannel extends StatefulWidget { @override - _PlatformChannelState createState() => new _PlatformChannelState(); + _PlatformChannelState createState() => _PlatformChannelState(); } class _PlatformChannelState extends State { @@ -55,24 +55,24 @@ class _PlatformChannelState extends State { @override Widget build(BuildContext context) { - return new Material( - child: new Column( + return Material( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new Column( + Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text(_batteryLevel, key: const Key('Battery level label')), - new Padding( + Text(_batteryLevel, key: const Key('Battery level label')), + Padding( padding: const EdgeInsets.all(16.0), - child: new RaisedButton( + child: RaisedButton( child: const Text('Refresh'), onPressed: _getBatteryLevel, ), ), ], ), - new Text(_chargingStatus), + Text(_chargingStatus), ], ), ); @@ -80,5 +80,5 @@ class _PlatformChannelState extends State { } void main() { - runApp(new MaterialApp(home: new PlatformChannel())); + runApp(MaterialApp(home: PlatformChannel())); } diff --git a/examples/platform_channel_swift/lib/main.dart b/examples/platform_channel_swift/lib/main.dart index 41129cc11f..8739a010d8 100644 --- a/examples/platform_channel_swift/lib/main.dart +++ b/examples/platform_channel_swift/lib/main.dart @@ -9,7 +9,7 @@ import 'package:flutter/services.dart'; class PlatformChannel extends StatefulWidget { @override - _PlatformChannelState createState() => new _PlatformChannelState(); + _PlatformChannelState createState() => _PlatformChannelState(); } class _PlatformChannelState extends State { @@ -55,24 +55,24 @@ class _PlatformChannelState extends State { @override Widget build(BuildContext context) { - return new Material( - child: new Column( + return Material( + child: Column( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new Column( + Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text(_batteryLevel, key: const Key('Battery level label')), - new Padding( + Text(_batteryLevel, key: const Key('Battery level label')), + Padding( padding: const EdgeInsets.all(16.0), - child: new RaisedButton( + child: RaisedButton( child: const Text('Refresh'), onPressed: _getBatteryLevel, ), ), ], ), - new Text(_chargingStatus), + Text(_chargingStatus), ], ), ); @@ -80,5 +80,5 @@ class _PlatformChannelState extends State { } void main() { - runApp(new MaterialApp(home: new PlatformChannel())); + runApp(MaterialApp(home: PlatformChannel())); } diff --git a/examples/platform_view/lib/main.dart b/examples/platform_view/lib/main.dart index aba8cb94e8..9a66c01b7b 100644 --- a/examples/platform_view/lib/main.dart +++ b/examples/platform_view/lib/main.dart @@ -8,15 +8,15 @@ import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { - runApp(new PlatformView()); + runApp(PlatformView()); } class PlatformView extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( title: 'Platform View', - theme: new ThemeData( + theme: ThemeData( primarySwatch: Colors.grey, ), home: const MyHomePage(title: 'Platform View'), @@ -30,7 +30,7 @@ class MyHomePage extends StatefulWidget { final String title; @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State { @@ -54,25 +54,25 @@ class _MyHomePageState extends State { } @override - Widget build(BuildContext context) => new Scaffold( - appBar: new AppBar( - title: new Text(widget.title), + Widget build(BuildContext context) => Scaffold( + appBar: AppBar( + title: Text(widget.title), ), - body: new Column( + body: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Expanded( - child: new Center( - child: new Column( + Expanded( + child: Center( + child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ - new Text( + Text( 'Button tapped $_counter time${ _counter == 1 ? '' : 's' }.', style: const TextStyle(fontSize: 17.0), ), - new Padding( + Padding( padding: const EdgeInsets.all(18.0), - child: new RaisedButton( + child: RaisedButton( child: Platform.isIOS ? const Text('Continue in iOS view') : const Text('Continue in Android view'), @@ -82,11 +82,11 @@ class _MyHomePageState extends State { ), ), ), - new Container( + Container( padding: const EdgeInsets.only(bottom: 15.0, left: 5.0), - child: new Row( + child: Row( children: [ - new Image.asset('assets/flutter-mark-square-64.png', + Image.asset('assets/flutter-mark-square-64.png', scale: 1.5), const Text( 'Flutter', @@ -97,7 +97,7 @@ class _MyHomePageState extends State { ), ], ), - floatingActionButton: new FloatingActionButton( + floatingActionButton: FloatingActionButton( onPressed: _incrementCounter, tooltip: 'Increment', child: const Icon(Icons.add), diff --git a/examples/stocks/lib/main.dart b/examples/stocks/lib/main.dart index cab5c17a11..469e3bb3b7 100644 --- a/examples/stocks/lib/main.dart +++ b/examples/stocks/lib/main.dart @@ -35,13 +35,13 @@ class _StocksLocalizationsDelegate extends LocalizationsDelegate { class StocksApp extends StatefulWidget { @override - StocksAppState createState() => new StocksAppState(); + StocksAppState createState() => StocksAppState(); } class StocksAppState extends State { StockData stocks; - StockConfiguration _configuration = new StockConfiguration( + StockConfiguration _configuration = StockConfiguration( stockMode: StockMode.optimistic, backupMode: BackupMode.enabled, debugShowGrid: false, @@ -57,7 +57,7 @@ class StocksAppState extends State { @override void initState() { super.initState(); - stocks = new StockData(); + stocks = StockData(); } void configurationUpdater(StockConfiguration value) { @@ -69,12 +69,12 @@ class StocksAppState extends State { ThemeData get theme { switch (_configuration.stockMode) { case StockMode.optimistic: - return new ThemeData( + return ThemeData( brightness: Brightness.light, primarySwatch: Colors.purple ); case StockMode.pessimistic: - return new ThemeData( + return ThemeData( brightness: Brightness.dark, accentColor: Colors.redAccent ); @@ -100,9 +100,9 @@ class StocksAppState extends State { // Extract the symbol part of "stock:..." and return a route // for that symbol. final String symbol = path[1].substring(6); - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, - builder: (BuildContext context) => new StockSymbolPage(symbol: symbol, stocks: stocks), + builder: (BuildContext context) => StockSymbolPage(symbol: symbol, stocks: stocks), ); } // The other paths we support are in the routes table. @@ -119,11 +119,11 @@ class StocksAppState extends State { debugRepaintRainbowEnabled = _configuration.debugShowRainbow; return true; }()); - return new MaterialApp( + return MaterialApp( title: 'Stocks', theme: theme, localizationsDelegates: >[ - new _StocksLocalizationsDelegate(), + _StocksLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, GlobalWidgetsLocalizations.delegate, ], @@ -135,8 +135,8 @@ class StocksAppState extends State { showPerformanceOverlay: _configuration.showPerformanceOverlay, showSemanticsDebugger: _configuration.showSemanticsDebugger, routes: { - '/': (BuildContext context) => new StockHome(stocks, _configuration, configurationUpdater), - '/settings': (BuildContext context) => new StockSettings(_configuration, configurationUpdater) + '/': (BuildContext context) => StockHome(stocks, _configuration, configurationUpdater), + '/settings': (BuildContext context) => StockSettings(_configuration, configurationUpdater) }, onGenerateRoute: _getRoute, ); @@ -144,5 +144,5 @@ class StocksAppState extends State { } void main() { - runApp(new StocksApp()); + runApp(StocksApp()); } diff --git a/examples/stocks/lib/stock_arrow.dart b/examples/stocks/lib/stock_arrow.dart index 7f72e43c67..cbd78f09da 100644 --- a/examples/stocks/lib/stock_arrow.dart +++ b/examples/stocks/lib/stock_arrow.dart @@ -14,7 +14,7 @@ class StockArrowPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint()..color = color; + final Paint paint = Paint()..color = color; paint.strokeWidth = 1.0; const double padding = 2.0; assert(padding > paint.strokeWidth / 2.0); // make sure the circle remains inside the box @@ -32,7 +32,7 @@ class StockArrowPainter extends CustomPainter { } else { arrowY = centerX - 1.0; } - final Path path = new Path(); + final Path path = Path(); path.moveTo(centerX, arrowY - h); // top of the arrow path.lineTo(centerX + w, arrowY + h); path.lineTo(centerX - w, arrowY + h); @@ -42,7 +42,7 @@ class StockArrowPainter extends CustomPainter { // Draw a circle that circumscribes the arrow. paint.style = PaintingStyle.stroke; - canvas.drawCircle(new Offset(centerX, centerY), r, paint); + canvas.drawCircle(Offset(centerX, centerY), r, paint); } @override @@ -71,12 +71,12 @@ class StockArrow extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( width: 40.0, height: 40.0, margin: const EdgeInsets.symmetric(horizontal: 5.0), - child: new CustomPaint( - painter: new StockArrowPainter( + child: CustomPaint( + painter: StockArrowPainter( // TODO(jackson): This should change colors with the theme color: _colorForPercentChange(percentChange), percentChange: percentChange diff --git a/examples/stocks/lib/stock_data.dart b/examples/stocks/lib/stock_data.dart index 682223eac0..be28ad1efb 100644 --- a/examples/stocks/lib/stock_data.dart +++ b/examples/stocks/lib/stock_data.dart @@ -13,7 +13,7 @@ import 'dart:math' as math; import 'package:flutter/foundation.dart'; import 'package:http/http.dart' as http; -final math.Random _rng = new math.Random(); +final math.Random _rng = math.Random(); class Stock { String symbol; @@ -41,7 +41,7 @@ class Stock { class StockData extends ChangeNotifier { StockData() { if (actuallyFetchData) { - _httpClient = new http.Client(); + _httpClient = http.Client(); _fetchNextChunk(); } } @@ -57,7 +57,7 @@ class StockData extends ChangeNotifier { void add(List data) { for (List fields in data) { - final Stock stock = new Stock.fromFields(fields.cast()); + final Stock stock = Stock.fromFields(fields.cast()); _symbols.add(stock.symbol); _stocks[stock.symbol] = stock; } diff --git a/examples/stocks/lib/stock_home.dart b/examples/stocks/lib/stock_home.dart index 65daf3fd52..2f3e71c560 100644 --- a/examples/stocks/lib/stock_home.dart +++ b/examples/stocks/lib/stock_home.dart @@ -19,26 +19,26 @@ enum StockHomeTab { market, portfolio } class _NotImplementedDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return new AlertDialog( + return AlertDialog( title: const Text('Not Implemented'), content: const Text('This feature has not yet been implemented.'), actions: [ - new FlatButton( + FlatButton( onPressed: debugDumpApp, - child: new Row( + child: Row( children: [ const Icon( Icons.dvr, size: 18.0, ), - new Container( + Container( width: 8.0, ), const Text('DUMP APP TO CONSOLE'), ], ), ), - new FlatButton( + FlatButton( onPressed: () { Navigator.pop(context, false); }, @@ -57,17 +57,17 @@ class StockHome extends StatefulWidget { final ValueChanged updater; @override - StockHomeState createState() => new StockHomeState(); + StockHomeState createState() => StockHomeState(); } class StockHomeState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); - final TextEditingController _searchQuery = new TextEditingController(); + final GlobalKey _scaffoldKey = GlobalKey(); + final TextEditingController _searchQuery = TextEditingController(); bool _isSearching = false; bool _autorefresh = false; void _handleSearchBegin() { - ModalRoute.of(context).addLocalHistoryEntry(new LocalHistoryEntry( + ModalRoute.of(context).addLocalHistoryEntry(LocalHistoryEntry( onRemove: () { setState(() { _isSearching = false; @@ -95,7 +95,7 @@ class StockHomeState extends State { case _StockMenuItem.refresh: showDialog( context: context, - builder: (BuildContext context) => new _NotImplementedDialog(), + builder: (BuildContext context) => _NotImplementedDialog(), ); break; case _StockMenuItem.speedUp: @@ -108,8 +108,8 @@ class StockHomeState extends State { } Widget _buildDrawer(BuildContext context) { - return new Drawer( - child: new ListView( + return Drawer( + child: ListView( children: [ const DrawerHeader(child: Center(child: Text('Stocks'))), const ListTile( @@ -122,7 +122,7 @@ class StockHomeState extends State { title: Text('Account Balance'), enabled: false, ), - new ListTile( + ListTile( leading: const Icon(Icons.dvr), title: const Text('Dump App to Console'), onTap: () { @@ -137,10 +137,10 @@ class StockHomeState extends State { }, ), const Divider(), - new ListTile( + ListTile( leading: const Icon(Icons.thumb_up), title: const Text('Optimistic'), - trailing: new Radio( + trailing: Radio( value: StockMode.optimistic, groupValue: widget.configuration.stockMode, onChanged: _handleStockModeChange, @@ -149,10 +149,10 @@ class StockHomeState extends State { _handleStockModeChange(StockMode.optimistic); }, ), - new ListTile( + ListTile( leading: const Icon(Icons.thumb_down), title: const Text('Pessimistic'), - trailing: new Radio( + trailing: Radio( value: StockMode.pessimistic, groupValue: widget.configuration.stockMode, onChanged: _handleStockModeChange, @@ -162,12 +162,12 @@ class StockHomeState extends State { }, ), const Divider(), - new ListTile( + ListTile( leading: const Icon(Icons.settings), title: const Text('Settings'), onTap: _handleShowSettings, ), - new ListTile( + ListTile( leading: const Icon(Icons.help), title: const Text('About'), onTap: _handleShowAbout, @@ -186,19 +186,19 @@ class StockHomeState extends State { } Widget buildAppBar() { - return new AppBar( + return AppBar( elevation: 0.0, - title: new Text(StockStrings.of(context).title()), + title: Text(StockStrings.of(context).title()), actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.search), onPressed: _handleSearchBegin, tooltip: 'Search', ), - new PopupMenuButton<_StockMenuItem>( + PopupMenuButton<_StockMenuItem>( onSelected: (_StockMenuItem value) { _handleStockMenu(context, value); }, itemBuilder: (BuildContext context) => >[ - new CheckedPopupMenuItem<_StockMenuItem>( + CheckedPopupMenuItem<_StockMenuItem>( value: _StockMenuItem.autorefresh, checked: _autorefresh, child: const Text('Autorefresh'), @@ -218,10 +218,10 @@ class StockHomeState extends State { ], ), ], - bottom: new TabBar( + bottom: TabBar( tabs: [ - new Tab(text: StockStrings.of(context).market()), - new Tab(text: StockStrings.of(context).portfolio()), + Tab(text: StockStrings.of(context).market()), + Tab(text: StockStrings.of(context).portfolio()), ], ), ); @@ -235,7 +235,7 @@ class StockHomeState extends State { Iterable _filterBySearchQuery(Iterable stocks) { if (_searchQuery.text.isEmpty) return stocks; - final RegExp regexp = new RegExp(_searchQuery.text, caseSensitive: false); + final RegExp regexp = RegExp(_searchQuery.text, caseSensitive: false); return stocks.where((Stock stock) => stock.symbol.contains(regexp)); } @@ -244,9 +244,9 @@ class StockHomeState extends State { stock.percentChange = 100.0 * (1.0 / stock.lastSale); stock.lastSale += 1.0; }); - _scaffoldKey.currentState.showSnackBar(new SnackBar( - content: new Text('Purchased ${stock.symbol} for ${stock.lastSale}'), - action: new SnackBarAction( + _scaffoldKey.currentState.showSnackBar(SnackBar( + content: Text('Purchased ${stock.symbol} for ${stock.lastSale}'), + action: SnackBarAction( label: 'BUY MORE', onPressed: () { _buyStock(stock); @@ -256,22 +256,22 @@ class StockHomeState extends State { } Widget _buildStockList(BuildContext context, Iterable stocks, StockHomeTab tab) { - return new StockList( + return StockList( stocks: stocks.toList(), onAction: _buyStock, onOpen: (Stock stock) { Navigator.pushNamed(context, '/stock:${stock.symbol}'); }, onShow: (Stock stock) { - _scaffoldKey.currentState.showBottomSheet((BuildContext context) => new StockSymbolBottomSheet(stock: stock)); + _scaffoldKey.currentState.showBottomSheet((BuildContext context) => StockSymbolBottomSheet(stock: stock)); }, ); } Widget _buildStockTab(BuildContext context, StockHomeTab tab, List stockSymbols) { - return new AnimatedBuilder( - key: new ValueKey(tab), - animation: new Listenable.merge([_searchQuery, widget.stocks]), + return AnimatedBuilder( + key: ValueKey(tab), + animation: Listenable.merge([_searchQuery, widget.stocks]), builder: (BuildContext context, Widget child) { return _buildStockList(context, _filterBySearchQuery(_getStockList(widget.stocks, stockSymbols)).toList(), tab); }, @@ -281,11 +281,11 @@ class StockHomeState extends State { static const List portfolioSymbols = ['AAPL','FIZZ', 'FIVE', 'FLAT', 'ZINC', 'ZNGA']; Widget buildSearchBar() { - return new AppBar( - leading: new BackButton( + return AppBar( + leading: BackButton( color: Theme.of(context).accentColor, ), - title: new TextField( + title: TextField( controller: _searchQuery, autofocus: true, decoration: const InputDecoration( @@ -299,12 +299,12 @@ class StockHomeState extends State { void _handleCreateCompany() { showModalBottomSheet( context: context, - builder: (BuildContext context) => new _CreateCompanySheet(), + builder: (BuildContext context) => _CreateCompanySheet(), ); } Widget buildFloatingActionButton() { - return new FloatingActionButton( + return FloatingActionButton( tooltip: 'Create company', child: const Icon(Icons.add), backgroundColor: Theme.of(context).accentColor, @@ -314,14 +314,14 @@ class StockHomeState extends State { @override Widget build(BuildContext context) { - return new DefaultTabController( + return DefaultTabController( length: 2, - child: new Scaffold( + child: Scaffold( key: _scaffoldKey, appBar: _isSearching ? buildSearchBar() : buildAppBar(), floatingActionButton: buildFloatingActionButton(), drawer: _buildDrawer(context), - body: new TabBarView( + body: TabBarView( children: [ _buildStockTab(context, StockHomeTab.market, widget.stocks.allSymbols), _buildStockTab(context, StockHomeTab.portfolio, portfolioSymbols), @@ -335,7 +335,7 @@ class StockHomeState extends State { class _CreateCompanySheet extends StatelessWidget { @override Widget build(BuildContext context) { - return new Column( + return Column( children: const [ TextField( autofocus: true, diff --git a/examples/stocks/lib/stock_list.dart b/examples/stocks/lib/stock_list.dart index e9fc311138..d61c0c3421 100644 --- a/examples/stocks/lib/stock_list.dart +++ b/examples/stocks/lib/stock_list.dart @@ -17,12 +17,12 @@ class StockList extends StatelessWidget { @override Widget build(BuildContext context) { - return new ListView.builder( + return ListView.builder( key: const ValueKey('stock-list'), itemExtent: StockRow.kHeight, itemCount: stocks.length, itemBuilder: (BuildContext context, int index) { - return new StockRow( + return StockRow( stock: stocks[index], onPressed: onOpen, onDoubleTap: onShow, diff --git a/examples/stocks/lib/stock_row.dart b/examples/stocks/lib/stock_row.dart index f22c5be4ae..00e8843f40 100644 --- a/examples/stocks/lib/stock_row.dart +++ b/examples/stocks/lib/stock_row.dart @@ -15,7 +15,7 @@ class StockRow extends StatelessWidget { this.onPressed, this.onDoubleTap, this.onLongPressed - }) : super(key: new ObjectKey(stock)); + }) : super(key: ObjectKey(stock)); final Stock stock; final StockRowActionCallback onPressed; @@ -34,43 +34,43 @@ class StockRow extends StatelessWidget { String changeInPrice = '${stock.percentChange.toStringAsFixed(2)}%'; if (stock.percentChange > 0) changeInPrice = '+' + changeInPrice; - return new InkWell( + return InkWell( onTap: _getHandler(onPressed), onDoubleTap: _getHandler(onDoubleTap), onLongPress: _getHandler(onLongPressed), - child: new Container( + child: Container( padding: const EdgeInsets.fromLTRB(16.0, 16.0, 16.0, 20.0), - decoration: new BoxDecoration( - border: new Border( - bottom: new BorderSide(color: Theme.of(context).dividerColor) + decoration: BoxDecoration( + border: Border( + bottom: BorderSide(color: Theme.of(context).dividerColor) ) ), - child: new Row( + child: Row( children: [ - new Container( + Container( margin: const EdgeInsets.only(right: 5.0), - child: new Hero( + child: Hero( tag: stock, - child: new StockArrow(percentChange: stock.percentChange) + child: StockArrow(percentChange: stock.percentChange) ) ), - new Expanded( - child: new Row( + Expanded( + child: Row( children: [ - new Expanded( + Expanded( flex: 2, - child: new Text( + child: Text( stock.symbol ) ), - new Expanded( - child: new Text( + Expanded( + child: Text( lastSale, textAlign: TextAlign.right ) ), - new Expanded( - child: new Text( + Expanded( + child: Text( changeInPrice, textAlign: TextAlign.right ) diff --git a/examples/stocks/lib/stock_settings.dart b/examples/stocks/lib/stock_settings.dart index 7390d12060..3919096e05 100644 --- a/examples/stocks/lib/stock_settings.dart +++ b/examples/stocks/lib/stock_settings.dart @@ -13,7 +13,7 @@ class StockSettings extends StatefulWidget { final ValueChanged updater; @override - StockSettingsState createState() => new StockSettingsState(); + StockSettingsState createState() => StockSettingsState(); } class StockSettingsState extends State { @@ -68,17 +68,17 @@ class StockSettingsState extends State { showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( + return AlertDialog( title: const Text('Change mode?'), content: const Text('Optimistic mode means everything is awesome. Are you sure you can handle that?'), actions: [ - new FlatButton( + FlatButton( child: const Text('NO THANKS'), onPressed: () { Navigator.pop(context, false); } ), - new FlatButton( + FlatButton( child: const Text('AGREE'), onPressed: () { Navigator.pop(context, true); @@ -98,45 +98,45 @@ class StockSettingsState extends State { } Widget buildAppBar(BuildContext context) { - return new AppBar( + return AppBar( title: const Text('Settings') ); } Widget buildSettingsPane(BuildContext context) { final List rows = [ - new ListTile( + ListTile( leading: const Icon(Icons.thumb_up), title: const Text('Everything is awesome'), onTap: _confirmOptimismChange, - trailing: new Checkbox( + trailing: Checkbox( value: widget.configuration.stockMode == StockMode.optimistic, onChanged: (bool value) => _confirmOptimismChange(), ), ), - new ListTile( + ListTile( leading: const Icon(Icons.backup), title: const Text('Back up stock list to the cloud'), onTap: () { _handleBackupChanged(!(widget.configuration.backupMode == BackupMode.enabled)); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.backupMode == BackupMode.enabled, onChanged: _handleBackupChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.picture_in_picture), title: const Text('Show rendering performance overlay'), onTap: () { _handleShowPerformanceOverlayChanged(!widget.configuration.showPerformanceOverlay); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.showPerformanceOverlay, onChanged: _handleShowPerformanceOverlayChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.accessibility), title: const Text('Show semantics overlay'), onTap: () { _handleShowSemanticsDebuggerChanged(!widget.configuration.showSemanticsDebugger); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.showSemanticsDebugger, onChanged: _handleShowSemanticsDebuggerChanged, ), @@ -145,56 +145,56 @@ class StockSettingsState extends State { assert(() { // material grid and size construction lines are only available in checked mode rows.addAll([ - new ListTile( + ListTile( leading: const Icon(Icons.border_clear), title: const Text('Show material grid (for debugging)'), onTap: () { _handleShowGridChanged(!widget.configuration.debugShowGrid); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.debugShowGrid, onChanged: _handleShowGridChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.border_all), title: const Text('Show construction lines (for debugging)'), onTap: () { _handleShowSizesChanged(!widget.configuration.debugShowSizes); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.debugShowSizes, onChanged: _handleShowSizesChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.format_color_text), title: const Text('Show baselines (for debugging)'), onTap: () { _handleShowBaselinesChanged(!widget.configuration.debugShowBaselines); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.debugShowBaselines, onChanged: _handleShowBaselinesChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.filter_none), title: const Text('Show layer boundaries (for debugging)'), onTap: () { _handleShowLayersChanged(!widget.configuration.debugShowLayers); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.debugShowLayers, onChanged: _handleShowLayersChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.mouse), title: const Text('Show pointer hit-testing (for debugging)'), onTap: () { _handleShowPointersChanged(!widget.configuration.debugShowPointers); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.debugShowPointers, onChanged: _handleShowPointersChanged, ), ), - new ListTile( + ListTile( leading: const Icon(Icons.gradient), title: const Text('Show repaint rainbow (for debugging)'), onTap: () { _handleShowRainbowChanged(!widget.configuration.debugShowRainbow); }, - trailing: new Switch( + trailing: Switch( value: widget.configuration.debugShowRainbow, onChanged: _handleShowRainbowChanged, ), @@ -202,7 +202,7 @@ class StockSettingsState extends State { ]); return true; }()); - return new ListView( + return ListView( padding: const EdgeInsets.symmetric(vertical: 20.0), children: rows, ); @@ -210,7 +210,7 @@ class StockSettingsState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( appBar: buildAppBar(context), body: buildSettingsPane(context) ); diff --git a/examples/stocks/lib/stock_strings.dart b/examples/stocks/lib/stock_strings.dart index 344db8a37e..136d079263 100644 --- a/examples/stocks/lib/stock_strings.dart +++ b/examples/stocks/lib/stock_strings.dart @@ -20,7 +20,7 @@ class StockStrings { static Future load(Locale locale) { return initializeMessages(locale.toString()) .then((Object _) { - return new StockStrings(locale); + return StockStrings(locale); }); } diff --git a/examples/stocks/lib/stock_symbol_viewer.dart b/examples/stocks/lib/stock_symbol_viewer.dart index b77cc828f0..e1f069c0a7 100644 --- a/examples/stocks/lib/stock_symbol_viewer.dart +++ b/examples/stocks/lib/stock_symbol_viewer.dart @@ -22,13 +22,13 @@ class _StockSymbolView extends StatelessWidget { changeInPrice = '+' + changeInPrice; final TextStyle headings = Theme.of(context).textTheme.body2; - return new Container( + return Container( padding: const EdgeInsets.all(20.0), - child: new Column( + child: Column( children: [ - new Row( + Row( children: [ - new Text( + Text( '${stock.symbol}', style: Theme.of(context).textTheme.display2 ), @@ -36,18 +36,18 @@ class _StockSymbolView extends StatelessWidget { ], mainAxisAlignment: MainAxisAlignment.spaceBetween ), - new Text('Last Sale', style: headings), - new Text('$lastSale ($changeInPrice)'), - new Container( + Text('Last Sale', style: headings), + Text('$lastSale ($changeInPrice)'), + Container( height: 8.0 ), - new Text('Market Cap', style: headings), - new Text('${stock.marketCap}'), - new Container( + Text('Market Cap', style: headings), + Text('${stock.marketCap}'), + Container( height: 8.0 ), - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( style: DefaultTextStyle.of(context).style.merge(const TextStyle(fontSize: 8.0)), text: 'Prices may be delayed by ', children: const [ @@ -71,34 +71,34 @@ class StockSymbolPage extends StatelessWidget { @override Widget build(BuildContext context) { - return new AnimatedBuilder( + return AnimatedBuilder( animation: stocks, builder: (BuildContext context, Widget child) { final Stock stock = stocks[symbol]; - return new Scaffold( - appBar: new AppBar( - title: new Text(stock?.name ?? symbol) + return Scaffold( + appBar: AppBar( + title: Text(stock?.name ?? symbol) ), - body: new SingleChildScrollView( - child: new Container( + body: SingleChildScrollView( + child: Container( margin: const EdgeInsets.all(20.0), - child: new Card( - child: new AnimatedCrossFade( + child: Card( + child: AnimatedCrossFade( duration: const Duration(milliseconds: 300), firstChild: const Padding( padding: EdgeInsets.all(20.0), child: Center(child: CircularProgressIndicator()), ), secondChild: stock != null - ? new _StockSymbolView( + ? _StockSymbolView( stock: stock, - arrow: new Hero( + arrow: Hero( tag: stock, - child: new StockArrow(percentChange: stock.percentChange), + child: StockArrow(percentChange: stock.percentChange), ), - ) : new Padding( + ) : Padding( padding: const EdgeInsets.all(20.0), - child: new Center(child: new Text('$symbol not found')), + child: Center(child: Text('$symbol not found')), ), crossFadeState: stock == null && stocks.loading ? CrossFadeState.showFirst : CrossFadeState.showSecond, ), @@ -118,14 +118,14 @@ class StockSymbolBottomSheet extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( padding: const EdgeInsets.all(10.0), decoration: const BoxDecoration( border: Border(top: BorderSide(color: Colors.black26)) ), - child: new _StockSymbolView( + child: _StockSymbolView( stock: stock, - arrow: new StockArrow(percentChange: stock.percentChange) + arrow: StockArrow(percentChange: stock.percentChange) ) ); } diff --git a/examples/stocks/lib/stock_types.dart b/examples/stocks/lib/stock_types.dart index 163628e7a8..7ffe63e343 100644 --- a/examples/stocks/lib/stock_types.dart +++ b/examples/stocks/lib/stock_types.dart @@ -53,7 +53,7 @@ class StockConfiguration { bool showPerformanceOverlay, bool showSemanticsDebugger }) { - return new StockConfiguration( + return StockConfiguration( stockMode: stockMode ?? this.stockMode, backupMode: backupMode ?? this.backupMode, debugShowGrid: debugShowGrid ?? this.debugShowGrid, diff --git a/examples/stocks/test/icon_color_test.dart b/examples/stocks/test/icon_color_test.dart index 74a73214bf..a3ba3fd64d 100644 --- a/examples/stocks/test/icon_color_test.dart +++ b/examples/stocks/test/icon_color_test.dart @@ -35,7 +35,7 @@ Element findElementOfExactWidgetTypeGoingUp(Element node, Type targetType) { return result; } -final RegExp materialIconAssetNameColorExtractor = new RegExp(r'[^/]+/ic_.+_(white|black)_[0-9]+dp\.png'); +final RegExp materialIconAssetNameColorExtractor = RegExp(r'[^/]+/ic_.+_(white|black)_[0-9]+dp\.png'); void checkIconColor(WidgetTester tester, String label, Color color) { final Element listTile = findElementOfExactWidgetTypeGoingUp(tester.element(find.text(label)), ListTile); @@ -61,8 +61,8 @@ void main() { expect(find.text('Account Balance'), findsNothing); // drag the drawer out - final Offset left = new Offset(0.0, (ui.window.physicalSize / ui.window.devicePixelRatio).height / 2.0); - final Offset right = new Offset((ui.window.physicalSize / ui.window.devicePixelRatio).width, left.dy); + final Offset left = Offset(0.0, (ui.window.physicalSize / ui.window.devicePixelRatio).height / 2.0); + final Offset right = Offset((ui.window.physicalSize / ui.window.devicePixelRatio).width, left.dy); final TestGesture gesture = await tester.startGesture(left); await tester.pump(); await gesture.moveTo(right); diff --git a/examples/stocks/test_driver/scroll_perf_test.dart b/examples/stocks/test_driver/scroll_perf_test.dart index 8c5f0ca853..e8a85911cb 100644 --- a/examples/stocks/test_driver/scroll_perf_test.dart +++ b/examples/stocks/test_driver/scroll_perf_test.dart @@ -29,17 +29,17 @@ void main() { // Scroll down for (int i = 0; i < 5; i++) { await driver.scroll(stockList, 0.0, -300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } // Scroll up for (int i = 0; i < 5; i++) { await driver.scroll(stockList, 0.0, 300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } }); - final TimelineSummary summary = new TimelineSummary.summarize(timeline); + final TimelineSummary summary = TimelineSummary.summarize(timeline); summary.writeSummaryToFile('stocks_scroll_perf', pretty: true); summary.writeTimelineToFile('stocks_scroll_perf', pretty: true); }); diff --git a/packages/flutter/lib/src/animation/animation_controller.dart b/packages/flutter/lib/src/animation/animation_controller.dart index f4b4311bd2..a1cd6c3300 100644 --- a/packages/flutter/lib/src/animation/animation_controller.dart +++ b/packages/flutter/lib/src/animation/animation_controller.dart @@ -28,7 +28,7 @@ enum _AnimationDirection { reverse, } -final SpringDescription _kFlingSpringDescription = new SpringDescription.withDampingRatio( +final SpringDescription _kFlingSpringDescription = SpringDescription.withDampingRatio( mass: 1.0, stiffness: 500.0, ratio: 1.0, @@ -339,7 +339,7 @@ class AnimationController extends Animation TickerFuture forward({ double from }) { assert(() { if (duration == null) { - throw new FlutterError( + throw FlutterError( 'AnimationController.forward() called with no default Duration.\n' 'The "duration" property should be set, either in the constructor or later, before ' 'calling the forward() function.' @@ -367,7 +367,7 @@ class AnimationController extends Animation TickerFuture reverse({ double from }) { assert(() { if (duration == null) { - throw new FlutterError( + throw FlutterError( 'AnimationController.reverse() called with no default Duration.\n' 'The "duration" property should be set, either in the constructor or later, before ' 'calling the reverse() function.' @@ -417,7 +417,7 @@ class AnimationController extends Animation if (simulationDuration == null) { assert(() { if (this.duration == null) { - throw new FlutterError( + throw FlutterError( 'AnimationController.animateTo() called with no explicit Duration and no default Duration.\n' 'Either the "duration" argument to the animateTo() method should be provided, or the ' '"duration" property should be set, either in the constructor or later, before ' @@ -443,11 +443,11 @@ class AnimationController extends Animation AnimationStatus.completed : AnimationStatus.dismissed; _checkStatusChanged(); - return new TickerFuture.complete(); + return TickerFuture.complete(); } assert(simulationDuration > Duration.zero); assert(!isAnimating); - return _startSimulation(new _InterpolationSimulation(_value, target, simulationDuration, curve, scale)); + return _startSimulation(_InterpolationSimulation(_value, target, simulationDuration, curve, scale)); } /// Starts running this animation in the forward direction, and @@ -467,7 +467,7 @@ class AnimationController extends Animation period ??= duration; assert(() { if (period == null) { - throw new FlutterError( + throw FlutterError( 'AnimationController.repeat() called without an explicit period and with no default Duration.\n' 'Either the "period" argument to the repeat() method should be provided, or the ' '"duration" property should be set, either in the constructor or later, before ' @@ -476,7 +476,7 @@ class AnimationController extends Animation } return true; }()); - return animateWith(new _RepeatingSimulation(min, max, period)); + return animateWith(_RepeatingSimulation(min, max, period)); } /// Drives the animation with a critically damped spring (within [lowerBound] @@ -507,7 +507,7 @@ class AnimationController extends Animation break; } } - final Simulation simulation = new SpringSimulation(_kFlingSpringDescription, value, target, velocity * scale) + final Simulation simulation = SpringSimulation(_kFlingSpringDescription, value, target, velocity * scale) ..tolerance = _kFlingTolerance; return animateWith(simulation); } @@ -571,7 +571,7 @@ class AnimationController extends Animation void dispose() { assert(() { if (_ticker == null) { - throw new FlutterError( + throw FlutterError( 'AnimationController.dispose() called more than once.\n' 'A given $runtimeType cannot be disposed more than once.\n' 'The following $runtimeType object was disposed multiple times:\n' diff --git a/packages/flutter/lib/src/animation/animations.dart b/packages/flutter/lib/src/animation/animations.dart index 78c3c706aa..d0d6672e8b 100644 --- a/packages/flutter/lib/src/animation/animations.dart +++ b/packages/flutter/lib/src/animation/animations.dart @@ -402,7 +402,7 @@ class CurvedAnimation extends Animation with AnimationWithParentMixin new FlippedCurve(this); + Curve get flipped => FlippedCurve(this); @override String toString() { diff --git a/packages/flutter/lib/src/animation/listener_helpers.dart b/packages/flutter/lib/src/animation/listener_helpers.dart index d75d99ad00..c51ec02d9b 100644 --- a/packages/flutter/lib/src/animation/listener_helpers.dart +++ b/packages/flutter/lib/src/animation/listener_helpers.dart @@ -79,7 +79,7 @@ abstract class AnimationLocalListenersMixin extends _ListenerMixin { // extended directly. factory AnimationLocalListenersMixin._() => null; - final ObserverList _listeners = new ObserverList(); + final ObserverList _listeners = ObserverList(); /// Calls the listener every time the value of the animation changes. /// @@ -102,13 +102,13 @@ abstract class AnimationLocalListenersMixin extends _ListenerMixin { /// If listeners are added or removed during this function, the modifications /// will not change which listeners are called during this iteration. void notifyListeners() { - final List localListeners = new List.from(_listeners); + final List localListeners = List.from(_listeners); for (VoidCallback listener in localListeners) { try { if (_listeners.contains(listener)) listener(); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'animation library', @@ -131,7 +131,7 @@ abstract class AnimationLocalStatusListenersMixin extends _ListenerMixin { // extended directly. factory AnimationLocalStatusListenersMixin._() => null; - final ObserverList _statusListeners = new ObserverList(); + final ObserverList _statusListeners = ObserverList(); /// Calls listener every time the status of the animation changes. /// @@ -154,13 +154,13 @@ abstract class AnimationLocalStatusListenersMixin extends _ListenerMixin { /// If listeners are added or removed during this function, the modifications /// will not change which listeners are called during this iteration. void notifyStatusListeners(AnimationStatus status) { - final List localListeners = new List.from(_statusListeners); + final List localListeners = List.from(_statusListeners); for (AnimationStatusListener listener in localListeners) { try { if (_statusListeners.contains(listener)) listener(status); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'animation library', diff --git a/packages/flutter/lib/src/animation/tween.dart b/packages/flutter/lib/src/animation/tween.dart index 02e74aff5f..23f4100316 100644 --- a/packages/flutter/lib/src/animation/tween.dart +++ b/packages/flutter/lib/src/animation/tween.dart @@ -26,13 +26,13 @@ abstract class Animatable { /// Returns a new Animation that is driven by the given animation but that /// takes on values determined by this object. Animation animate(Animation parent) { - return new _AnimatedEvaluation(parent, this); + return _AnimatedEvaluation(parent, this); } /// Returns a new Animatable whose value is determined by first evaluating /// the given parent and then evaluating this object. Animatable chain(Animatable parent) { - return new _ChainedEvaluation(parent, this); + return _ChainedEvaluation(parent, this); } } @@ -67,7 +67,7 @@ class _ChainedEvaluation extends Animatable { @override T evaluate(Animation animation) { final double value = _parent.evaluate(animation); - return _evaluatable.evaluate(new AlwaysStoppedAnimation(value)); + return _evaluatable.evaluate(AlwaysStoppedAnimation(value)); } @override diff --git a/packages/flutter/lib/src/animation/tween_sequence.dart b/packages/flutter/lib/src/animation/tween_sequence.dart index ce079b8c1f..cb2b1de491 100644 --- a/packages/flutter/lib/src/animation/tween_sequence.dart +++ b/packages/flutter/lib/src/animation/tween_sequence.dart @@ -56,7 +56,7 @@ class TweenSequence extends Animatable { double start = 0.0; for (int i = 0; i < _items.length; i += 1) { final double end = i == _items.length - 1 ? 1.0 : start + _items[i].weight / totalWeight; - _intervals.add(new _Interval(start, end)); + _intervals.add(_Interval(start, end)); start = end; } } @@ -67,7 +67,7 @@ class TweenSequence extends Animatable { T _evaluateAt(double t, int index) { final TweenSequenceItem element = _items[index]; final double tInterval = _intervals[index].value(t); - return element.tween.evaluate(new AlwaysStoppedAnimation(tInterval)); + return element.tween.evaluate(AlwaysStoppedAnimation(tInterval)); } @override diff --git a/packages/flutter/lib/src/cupertino/action_sheet.dart b/packages/flutter/lib/src/cupertino/action_sheet.dart index 662361f674..b29c6a6da6 100644 --- a/packages/flutter/lib/src/cupertino/action_sheet.dart +++ b/packages/flutter/lib/src/cupertino/action_sheet.dart @@ -151,17 +151,17 @@ class CupertinoActionSheet extends StatelessWidget { Widget _buildContent() { final List content = []; if (title != null || message != null) { - final Widget titleSection = new _CupertinoAlertContentSection( + final Widget titleSection = _CupertinoAlertContentSection( title: title, message: message, scrollController: messageScrollController, ); - content.add(new Flexible(child: titleSection)); + content.add(Flexible(child: titleSection)); } - return new Container( + return Container( color: _kBackgroundColor, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: content, @@ -171,12 +171,12 @@ class CupertinoActionSheet extends StatelessWidget { Widget _buildActions() { if (actions == null || actions.isEmpty) { - return new Container( + return Container( height: 0.0, ); } - return new Container( - child: new _CupertinoAlertActionSection( + return Container( + child: _CupertinoAlertActionSection( children: actions, scrollController: actionScrollController, hasCancelButton: cancelButton != null, @@ -188,8 +188,8 @@ class CupertinoActionSheet extends StatelessWidget { final double cancelPadding = (actions != null || message != null || title != null) ? _kCancelButtonPadding : 0.0; return Padding( - padding: new EdgeInsets.only(top: cancelPadding), - child: new _CupertinoActionSheetCancelButton( + padding: EdgeInsets.only(top: cancelPadding), + child: _CupertinoActionSheetCancelButton( child: cancelButton, ), ); @@ -198,13 +198,13 @@ class CupertinoActionSheet extends StatelessWidget { @override Widget build(BuildContext context) { final List children = [ - new Flexible(child: new ClipRRect( - borderRadius: new BorderRadius.circular(12.0), - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: _kBlurAmount, sigmaY: _kBlurAmount), - child: new Container( + Flexible(child: ClipRRect( + borderRadius: BorderRadius.circular(12.0), + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: _kBlurAmount, sigmaY: _kBlurAmount), + child: Container( decoration: _kAlertBlurOverlayDecoration, - child: new _CupertinoAlertRenderWidget( + child: _CupertinoAlertRenderWidget( contentSection: _buildContent(), actionsSection: _buildActions(), ), @@ -228,19 +228,19 @@ class CupertinoActionSheet extends StatelessWidget { actionSheetWidth = MediaQuery.of(context).size.height - (_kEdgeHorizontalPadding * 2); } - return new SafeArea( - child: new Semantics( + return SafeArea( + child: Semantics( namesRoute: true, scopesRoute: true, explicitChildNodes: true, label: 'Alert', - child: new Container( + child: Container( width: actionSheetWidth, margin: const EdgeInsets.symmetric( horizontal: _kEdgeHorizontalPadding, vertical: _kEdgeVerticalPadding, ), - child: new Column( + child: Column( children: children, mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, @@ -301,22 +301,22 @@ class CupertinoActionSheetAction extends StatelessWidget { style = style.copyWith(color: CupertinoColors.destructiveRed); } - return new GestureDetector( + return GestureDetector( onTap: onPressed, behavior: HitTestBehavior.opaque, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints( minHeight: _kButtonHeight, ), - child: new Semantics( + child: Semantics( button: true, - child: new Container( + child: Container( alignment: Alignment.center, padding: const EdgeInsets.symmetric( vertical: 16.0, horizontal: 10.0, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: style, child: child, textAlign: TextAlign.center, @@ -369,15 +369,15 @@ class _CupertinoActionSheetCancelButtonState extends State<_CupertinoActionSheet @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( excludeFromSemantics: true, onTapDown: _onTapDown, onTapUp: _onTapUp, onTapCancel: _onTapCancel, - child: new Container( - decoration: new BoxDecoration( + child: Container( + decoration: BoxDecoration( color: _backgroundColor, - borderRadius: new BorderRadius.circular(_kCornerRadius), + borderRadius: BorderRadius.circular(_kCornerRadius), ), child: widget.child, ), @@ -397,7 +397,7 @@ class _CupertinoAlertRenderWidget extends RenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderCupertinoAlert( + return _RenderCupertinoAlert( dividerThickness: _kDividerThickness / MediaQuery.of(context).devicePixelRatio, ); } @@ -548,7 +548,7 @@ class _RenderCupertinoAlert extends RenderBox { final double _dividerThickness; - final Paint _dividerPaint = new Paint() + final Paint _dividerPaint = Paint() ..color = _kButtonDividerColor ..style = PaintingStyle.fill; @@ -587,7 +587,7 @@ class _RenderCupertinoAlert extends RenderBox { @override void setupParentData(RenderBox child) { if (child.parentData is! MultiChildLayoutParentData) { - child.parentData = new MultiChildLayoutParentData(); + child.parentData = MultiChildLayoutParentData(); } } @@ -661,14 +661,14 @@ class _RenderCupertinoAlert extends RenderBox { // Size alert content. contentSection.layout( - constraints.deflate(new EdgeInsets.only(bottom: minActionsHeight + dividerThickness)), + constraints.deflate(EdgeInsets.only(bottom: minActionsHeight + dividerThickness)), parentUsesSize: true, ); final Size contentSize = contentSection.size; // Size alert actions. actionsSection.layout( - constraints.deflate(new EdgeInsets.only(top: contentSize.height + dividerThickness)), + constraints.deflate(EdgeInsets.only(top: contentSize.height + dividerThickness)), parentUsesSize: true, ); final Size actionsSize = actionsSection.size; @@ -677,13 +677,13 @@ class _RenderCupertinoAlert extends RenderBox { final double actionSheetHeight = contentSize.height + dividerThickness + actionsSize.height; // Set our size now that layout calculations are complete. - size = new Size(constraints.maxWidth, actionSheetHeight); + size = Size(constraints.maxWidth, actionSheetHeight); // Set the position of the actions box to sit at the bottom of the alert. // The content box defaults to the top left, which is where we want it. assert(actionsSection.parentData is MultiChildLayoutParentData); final MultiChildLayoutParentData actionParentData = actionsSection.parentData; - actionParentData.offset = new Offset(0.0, contentSize.height + dividerThickness); + actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness); } @override @@ -770,14 +770,14 @@ class _CupertinoAlertContentSection extends StatelessWidget { Widget build(BuildContext context) { final List titleContentGroup = []; if (title != null) { - titleContentGroup.add(new Padding( + titleContentGroup.add(Padding( padding: const EdgeInsets.only( left: _kContentHorizontalPadding, right: _kContentHorizontalPadding, bottom: _kContentVerticalPadding, top: _kContentVerticalPadding, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: message == null ? _kActionSheetContentStyle : _kActionSheetContentStyle.copyWith(fontWeight: FontWeight.w600), textAlign: TextAlign.center, @@ -788,14 +788,14 @@ class _CupertinoAlertContentSection extends StatelessWidget { if (message != null) { titleContentGroup.add( - new Padding( - padding: new EdgeInsets.only( + Padding( + padding: EdgeInsets.only( left: _kContentHorizontalPadding, right: _kContentHorizontalPadding, bottom: title == null ? _kContentVerticalPadding : 22.0, top: title == null ? _kContentVerticalPadding : 0.0, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: title == null ? _kActionSheetContentStyle.copyWith(fontWeight: FontWeight.w600) : _kActionSheetContentStyle, textAlign: TextAlign.center, @@ -806,9 +806,9 @@ class _CupertinoAlertContentSection extends StatelessWidget { } if (titleContentGroup.isEmpty) { - return new SingleChildScrollView( + return SingleChildScrollView( controller: scrollController, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -820,10 +820,10 @@ class _CupertinoAlertContentSection extends StatelessWidget { titleContentGroup.insert(1, const Padding(padding: EdgeInsets.only(top: 8.0))); } - return new CupertinoScrollbar( - child: new SingleChildScrollView( + return CupertinoScrollbar( + child: SingleChildScrollView( controller: scrollController, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.stretch, children: titleContentGroup, @@ -858,7 +858,7 @@ class _CupertinoAlertActionSection extends StatefulWidget { final bool hasCancelButton; @override - _CupertinoAlertActionSectionState createState() => new _CupertinoAlertActionSectionState(); + _CupertinoAlertActionSectionState createState() => _CupertinoAlertActionSectionState(); } class _CupertinoAlertActionSectionState extends State<_CupertinoAlertActionSection> { @@ -869,16 +869,16 @@ class _CupertinoAlertActionSectionState extends State<_CupertinoAlertActionSecti final List interactiveButtons = []; for (int i = 0; i < widget.children.length; i += 1) { interactiveButtons.add( - new _PressableActionButton( + _PressableActionButton( child: widget.children[i], ), ); } - return new CupertinoScrollbar( - child: new SingleChildScrollView( + return CupertinoScrollbar( + child: SingleChildScrollView( controller: widget.scrollController, - child: new _CupertinoAlertActionsRenderWidget( + child: _CupertinoAlertActionsRenderWidget( actionButtons: interactiveButtons, dividerThickness: _kDividerThickness / devicePixelRatio, hasCancelButton: widget.hasCancelButton, @@ -901,7 +901,7 @@ class _PressableActionButton extends StatefulWidget { final Widget child; @override - _PressableActionButtonState createState() => new _PressableActionButtonState(); + _PressableActionButtonState createState() => _PressableActionButtonState(); } class _PressableActionButtonState extends State<_PressableActionButton> { @@ -909,10 +909,10 @@ class _PressableActionButtonState extends State<_PressableActionButton> { @override Widget build(BuildContext context) { - return new _ActionButtonParentDataWidget( + return _ActionButtonParentDataWidget( isPressed: _isPressed, // TODO(mattcarroll): Button press dynamics need overhaul for iOS: https://github.com/flutter/flutter/issues/19786 - child: new GestureDetector( + child: GestureDetector( excludeFromSemantics: true, behavior: HitTestBehavior.opaque, onTapDown: (TapDownDetails details) => setState(() => _isPressed = true), @@ -984,7 +984,7 @@ class _CupertinoAlertActionsRenderWidget extends MultiChildRenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderCupertinoAlertActions( + return _RenderCupertinoAlertActions( dividerThickness: _dividerThickness, hasCancelButton: _hasCancelButton, ); @@ -1050,22 +1050,22 @@ class _RenderCupertinoAlertActions extends RenderBox markNeedsLayout(); } - final Paint _buttonBackgroundPaint = new Paint() + final Paint _buttonBackgroundPaint = Paint() ..color = _kBackgroundColor ..style = PaintingStyle.fill; - final Paint _pressedButtonBackgroundPaint = new Paint() + final Paint _pressedButtonBackgroundPaint = Paint() ..color = _kPressedColor ..style = PaintingStyle.fill; - final Paint _dividerPaint = new Paint() + final Paint _dividerPaint = Paint() ..color = _kButtonDividerColor ..style = PaintingStyle.fill; @override void setupParentData(RenderBox child) { if (child.parentData is! _ActionButtonParentData) - child.parentData = new _ActionButtonParentData(); + child.parentData = _ActionButtonParentData(); } @override @@ -1156,7 +1156,7 @@ class _RenderCupertinoAlertActions extends RenderBox assert(child.parentData is MultiChildLayoutParentData); final MultiChildLayoutParentData parentData = child.parentData; - parentData.offset = new Offset(0.0, verticalOffset); + parentData.offset = Offset(0.0, verticalOffset); verticalOffset += child.size.height; if (index < childCount - 1) { @@ -1169,7 +1169,7 @@ class _RenderCupertinoAlertActions extends RenderBox } size = constraints.constrain( - new Size(constraints.maxWidth, verticalOffset) + Size(constraints.maxWidth, verticalOffset) ); } @@ -1181,15 +1181,15 @@ class _RenderCupertinoAlertActions extends RenderBox } void _drawButtonBackgroundsAndDividersStacked(Canvas canvas, Offset offset) { - final Offset dividerOffset = new Offset(0.0, dividerThickness); + final Offset dividerOffset = Offset(0.0, dividerThickness); - final Path backgroundFillPath = new Path() + final Path backgroundFillPath = Path() ..fillType = PathFillType.evenOdd ..addRect(Rect.largest); - final Path pressedBackgroundFillPath = new Path(); + final Path pressedBackgroundFillPath = Path(); - final Path dividersPath = new Path(); + final Path dividersPath = Path(); Offset accumulatingOffset = offset; @@ -1210,14 +1210,14 @@ class _RenderCupertinoAlertActions extends RenderBox final bool isDividerPresent = child != firstChild; final bool isDividerPainted = isDividerPresent && !(isButtonPressed || isPrevButtonPressed); - final Rect dividerRect = new Rect.fromLTWH( + final Rect dividerRect = Rect.fromLTWH( accumulatingOffset.dx, accumulatingOffset.dy, size.width, _dividerThickness, ); - final Rect buttonBackgroundRect = new Rect.fromLTWH( + final Rect buttonBackgroundRect = Rect.fromLTWH( accumulatingOffset.dx, accumulatingOffset.dy + (isDividerPresent ? dividerThickness : 0.0), size.width, @@ -1240,7 +1240,7 @@ class _RenderCupertinoAlertActions extends RenderBox } accumulatingOffset += (isDividerPresent ? dividerOffset : Offset.zero) - + new Offset(0.0, child.size.height); + + Offset(0.0, child.size.height); prevChild = child; child = childAfter(child); diff --git a/packages/flutter/lib/src/cupertino/activity_indicator.dart b/packages/flutter/lib/src/cupertino/activity_indicator.dart index 7277d45e36..5482aa9f0f 100644 --- a/packages/flutter/lib/src/cupertino/activity_indicator.dart +++ b/packages/flutter/lib/src/cupertino/activity_indicator.dart @@ -37,7 +37,7 @@ class CupertinoActivityIndicator extends StatefulWidget { final double radius; @override - _CupertinoActivityIndicatorState createState() => new _CupertinoActivityIndicatorState(); + _CupertinoActivityIndicatorState createState() => _CupertinoActivityIndicatorState(); } @@ -47,7 +47,7 @@ class _CupertinoActivityIndicatorState extends State @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(seconds: 1), vsync: this, ); @@ -75,11 +75,11 @@ class _CupertinoActivityIndicatorState extends State @override Widget build(BuildContext context) { - return new SizedBox( + return SizedBox( height: widget.radius * 2, width: widget.radius * 2, - child: new CustomPaint( - painter: new _CupertinoActivityIndicatorPainter( + child: CustomPaint( + painter: _CupertinoActivityIndicatorPainter( position: _controller, radius: widget.radius, ), @@ -98,7 +98,7 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter { _CupertinoActivityIndicatorPainter({ this.position, double radius, - }) : tickFundamentalRRect = new RRect.fromLTRBXY( + }) : tickFundamentalRRect = RRect.fromLTRBXY( -radius, 1.0 * radius / _kDefaultIndicatorRadius, -radius / 2.0, @@ -113,7 +113,7 @@ class _CupertinoActivityIndicatorPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint(); + final Paint paint = Paint(); canvas.save(); canvas.translate(size.width / 2.0, size.height / 2.0); diff --git a/packages/flutter/lib/src/cupertino/app.dart b/packages/flutter/lib/src/cupertino/app.dart index 4718f8e0bd..1bb7d6a268 100644 --- a/packages/flutter/lib/src/cupertino/app.dart +++ b/packages/flutter/lib/src/cupertino/app.dart @@ -303,7 +303,7 @@ class CupertinoApp extends StatefulWidget { final bool debugShowCheckedModeBanner; @override - _CupertinoAppState createState() => new _CupertinoAppState(); + _CupertinoAppState createState() => _CupertinoAppState(); } class _AlwaysCupertinoScrollBehavior extends ScrollBehavior { @@ -348,7 +348,7 @@ class _CupertinoAppState extends State { assert(child == null); if (_haveNavigator) { // Reuse CupertinoTabView which creates a routing Navigator for us. - final Widget navigator = new CupertinoTabView( + final Widget navigator = CupertinoTabView( builder: widget.home != null ? (BuildContext context) => widget.home : null, @@ -370,10 +370,10 @@ class _CupertinoAppState extends State { @override Widget build(BuildContext context) { - return new ScrollConfiguration( - behavior: new _AlwaysCupertinoScrollBehavior(), - child: new WidgetsApp( - key: new GlobalObjectKey(this), + return ScrollConfiguration( + behavior: _AlwaysCupertinoScrollBehavior(), + child: WidgetsApp( + key: GlobalObjectKey(this), // We're passing in a builder and nothing else that the WidgetsApp uses // to build its own Navigator because we're building a Navigator with // routes in this class. @@ -392,7 +392,7 @@ class _CupertinoAppState extends State { showSemanticsDebugger: widget.showSemanticsDebugger, debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner, inspectorSelectButtonBuilder: (BuildContext context, VoidCallback onPressed) { - return new CupertinoButton( + return CupertinoButton( child: const Icon( CupertinoIcons.search, size: 28.0, diff --git a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart index ac25cd5a49..ab50764bd6 100644 --- a/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart +++ b/packages/flutter/lib/src/cupertino/bottom_tab_bar.dart @@ -99,8 +99,8 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { @override Widget build(BuildContext context) { final double bottomPadding = MediaQuery.of(context).padding.bottom; - Widget result = new DecoratedBox( - decoration: new BoxDecoration( + Widget result = DecoratedBox( + decoration: BoxDecoration( border: const Border( top: BorderSide( color: _kDefaultTabBarBorderColor, @@ -111,24 +111,24 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { color: backgroundColor, ), // TODO(xster): allow icons-only versions of the tab bar too. - child: new SizedBox( + child: SizedBox( height: _kTabBarHeight + bottomPadding, child: IconTheme.merge( // Default with the inactive state. - data: new IconThemeData( + data: IconThemeData( color: inactiveColor, size: iconSize, ), - child: new DefaultTextStyle( // Default with the inactive state. - style: new TextStyle( + child: DefaultTextStyle( // Default with the inactive state. + style: TextStyle( fontFamily: '.SF UI Text', fontSize: 10.0, letterSpacing: 0.1, fontWeight: FontWeight.w400, color: inactiveColor, ), - child: new Padding( - padding: new EdgeInsets.only(bottom: bottomPadding), - child: new Row( + child: Padding( + padding: EdgeInsets.only(bottom: bottomPadding), + child: Row( // Align bottom since we want the labels to be aligned. crossAxisAlignment: CrossAxisAlignment.end, children: _buildTabItems(), @@ -141,9 +141,9 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { if (!opaque) { // For non-opaque backgrounds, apply a blur effect. - result = new ClipRect( - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + result = ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: result, ), ); @@ -159,20 +159,20 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { final bool active = index == currentIndex; result.add( _wrapActiveItem( - new Expanded( - child: new Semantics( + Expanded( + child: Semantics( selected: active, // TODO(xster): This needs localization support. https://github.com/flutter/flutter/issues/13452 hint: 'tab, ${index + 1} of ${items.length}', - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: onTap == null ? null : () { onTap(index); }, - child: new Padding( + child: Padding( padding: const EdgeInsets.only(bottom: 4.0), - child: new Column( + child: Column( mainAxisAlignment: MainAxisAlignment.end, children: [ - new Expanded(child: new Center(child: items[index].icon)), + Expanded(child: Center(child: items[index].icon)), items[index].title, ], ), @@ -194,9 +194,9 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { return item; return IconTheme.merge( - data: new IconThemeData(color: activeColor), + data: IconThemeData(color: activeColor), child: DefaultTextStyle.merge( - style: new TextStyle(color: activeColor), + style: TextStyle(color: activeColor), child: item, ), ); @@ -214,7 +214,7 @@ class CupertinoTabBar extends StatelessWidget implements PreferredSizeWidget { int currentIndex, ValueChanged onTap, }) { - return new CupertinoTabBar( + return CupertinoTabBar( key: key ?? this.key, items: items ?? this.items, backgroundColor: backgroundColor ?? this.backgroundColor, diff --git a/packages/flutter/lib/src/cupertino/button.dart b/packages/flutter/lib/src/cupertino/button.dart index 3496bd9cac..817b6f0e63 100644 --- a/packages/flutter/lib/src/cupertino/button.dart +++ b/packages/flutter/lib/src/cupertino/button.dart @@ -112,12 +112,12 @@ class CupertinoButton extends StatefulWidget { bool get enabled => onPressed != null; @override - _CupertinoButtonState createState() => new _CupertinoButtonState(); + _CupertinoButtonState createState() => _CupertinoButtonState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); + properties.add(FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); } } @@ -130,7 +130,7 @@ class _CupertinoButtonState extends State with SingleTickerProv AnimationController _animationController; void _setTween() { - _opacityTween = new Tween( + _opacityTween = Tween( begin: 1.0, end: widget.pressedOpacity ?? 1.0, ); @@ -139,7 +139,7 @@ class _CupertinoButtonState extends State with SingleTickerProv @override void initState() { super.initState(); - _animationController = new AnimationController( + _animationController = AnimationController( duration: const Duration(milliseconds: 200), value: 0.0, vsync: this, @@ -201,41 +201,41 @@ class _CupertinoButtonState extends State with SingleTickerProv final bool enabled = widget.enabled; final Color backgroundColor = widget.color; - return new GestureDetector( + return GestureDetector( behavior: HitTestBehavior.opaque, onTapDown: enabled ? _handleTapDown : null, onTapUp: enabled ? _handleTapUp : null, onTapCancel: enabled ? _handleTapCancel : null, onTap: widget.onPressed, - child: new Semantics( + child: Semantics( button: true, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: widget.minSize == null ? const BoxConstraints() - : new BoxConstraints( + : BoxConstraints( minWidth: widget.minSize, minHeight: widget.minSize, ), - child: new FadeTransition( - opacity: _opacityTween.animate(new CurvedAnimation( + child: FadeTransition( + opacity: _opacityTween.animate(CurvedAnimation( parent: _animationController, curve: Curves.decelerate, )), - child: new DecoratedBox( - decoration: new BoxDecoration( + child: DecoratedBox( + decoration: BoxDecoration( borderRadius: widget.borderRadius, color: backgroundColor != null && !enabled ? widget.disabledColor ?? _kDisabledBackground : backgroundColor, ), - child: new Padding( + child: Padding( padding: widget.padding ?? (backgroundColor != null ? _kBackgroundButtonPadding : _kButtonPadding), - child: new Center( + child: Center( widthFactor: 1.0, heightFactor: 1.0, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: backgroundColor != null ? _kBackgroundButtonTextStyle : enabled diff --git a/packages/flutter/lib/src/cupertino/date_picker.dart b/packages/flutter/lib/src/cupertino/date_picker.dart index 2d83920a55..f7c3be1f2b 100644 --- a/packages/flutter/lib/src/cupertino/date_picker.dart +++ b/packages/flutter/lib/src/cupertino/date_picker.dart @@ -97,7 +97,7 @@ class CupertinoTimerPicker extends StatefulWidget { final ValueChanged onTimerDurationChanged; @override - State createState() => new _CupertinoTimerPickerState(); + State createState() => _CupertinoTimerPickerState(); } class _CupertinoTimerPickerState extends State { @@ -129,7 +129,7 @@ class _CupertinoTimerPickerState extends State { // Builds a text label with customized scale factor and font weight. Widget _buildLabel(String text) { - return new Text( + return Text( text, textScaleFactor: 0.8, style: const TextStyle(fontWeight: FontWeight.w600), @@ -148,8 +148,8 @@ class _CupertinoTimerPickerState extends State { } Widget _buildHourPicker() { - return new CupertinoPicker( - scrollController: new FixedExtentScrollController(initialItem: selectedHour), + return CupertinoPicker( + scrollController: FixedExtentScrollController(initialItem: selectedHour), offAxisFraction: -0.5 * textDirectionFactor, itemExtent: _kItemExtent, backgroundColor: _kBackgroundColor, @@ -157,13 +157,13 @@ class _CupertinoTimerPickerState extends State { setState(() { selectedHour = index; widget.onTimerDurationChanged( - new Duration( + Duration( hours: selectedHour, minutes: selectedMinute, seconds: selectedSecond ?? 0)); }); }, - children: new List.generate(24, (int index) { + children: List.generate(24, (int index) { final double hourLabelWidth = widget.mode == CupertinoTimerPickerMode.hm ? _kPickerWidth / 4 : _kPickerWidth / 6; @@ -171,19 +171,19 @@ class _CupertinoTimerPickerState extends State { ? localizations.timerPickerHour(index) + localizations.timerPickerHourLabel(index) : localizations.timerPickerHourLabel(index) + localizations.timerPickerHour(index); - return new Semantics( + return Semantics( label: semanticsLabel, excludeSemantics: true, - child: new Container( + child: Container( alignment: alignCenterRight, padding: textDirectionFactor == 1 - ? new EdgeInsets.only(right: hourLabelWidth) - : new EdgeInsets.only(left: hourLabelWidth), - child: new Container( + ? EdgeInsets.only(right: hourLabelWidth) + : EdgeInsets.only(left: hourLabelWidth), + child: Container( alignment: alignCenterRight, // Adds some spaces between words. padding: const EdgeInsets.symmetric(horizontal: 2.0), - child: new Text(localizations.timerPickerHour(index)), + child: Text(localizations.timerPickerHour(index)), ), ), ); @@ -192,10 +192,10 @@ class _CupertinoTimerPickerState extends State { } Widget _buildHourColumn() { - final Widget hourLabel = new IgnorePointer( - child: new Container( + final Widget hourLabel = IgnorePointer( + child: Container( alignment: alignCenterRight, - child: new Container( + child: Container( alignment: alignCenterLeft, // Adds some spaces between words. padding: const EdgeInsets.symmetric(horizontal: 2.0), @@ -207,7 +207,7 @@ class _CupertinoTimerPickerState extends State { ), ); - return new Stack( + return Stack( children: [ _buildHourPicker(), hourLabel, @@ -224,8 +224,8 @@ class _CupertinoTimerPickerState extends State { else offAxisFraction = -0.5 * textDirectionFactor; - return new CupertinoPicker( - scrollController: new FixedExtentScrollController( + return CupertinoPicker( + scrollController: FixedExtentScrollController( initialItem: selectedMinute ~/ widget.minuteInterval, ), offAxisFraction: offAxisFraction, @@ -235,13 +235,13 @@ class _CupertinoTimerPickerState extends State { setState(() { selectedMinute = index; widget.onTimerDurationChanged( - new Duration( + Duration( hours: selectedHour ?? 0, minutes: selectedMinute, seconds: selectedSecond ?? 0)); }); }, - children: new List.generate(60 ~/ widget.minuteInterval, (int index) { + children: List.generate(60 ~/ widget.minuteInterval, (int index) { final int minute = index * widget.minuteInterval; final String semanticsLabel = textDirectionFactor == 1 @@ -249,36 +249,36 @@ class _CupertinoTimerPickerState extends State { : localizations.timerPickerMinuteLabel(minute) + localizations.timerPickerMinute(minute); if (widget.mode == CupertinoTimerPickerMode.ms) { - return new Semantics( + return Semantics( label: semanticsLabel, excludeSemantics: true, - child: new Container( + child: Container( alignment: alignCenterRight, padding: textDirectionFactor == 1 ? const EdgeInsets.only(right: _kPickerWidth / 4) : const EdgeInsets.only(left: _kPickerWidth / 4), - child: new Container( + child: Container( alignment: alignCenterRight, padding: const EdgeInsets.symmetric(horizontal: 2.0), - child: new Text(localizations.timerPickerMinute(minute)), + child: Text(localizations.timerPickerMinute(minute)), ), ), ); } else - return new Semantics( + return Semantics( label: semanticsLabel, excludeSemantics: true, - child: new Container( + child: Container( alignment: alignCenterLeft, - child: new Container( + child: Container( alignment: alignCenterRight, width: widget.mode == CupertinoTimerPickerMode.hm ? _kPickerWidth / 10 : _kPickerWidth / 6, // Adds some spaces between words. padding: const EdgeInsets.symmetric(horizontal: 2.0), - child: new Text(localizations.timerPickerMinute(minute)), + child: Text(localizations.timerPickerMinute(minute)), ), ), ); @@ -290,13 +290,13 @@ class _CupertinoTimerPickerState extends State { Widget minuteLabel; if (widget.mode == CupertinoTimerPickerMode.hm) { - minuteLabel = new IgnorePointer( - child: new Container( + minuteLabel = IgnorePointer( + child: Container( alignment: alignCenterLeft, padding: textDirectionFactor == 1 ? const EdgeInsets.only(left: _kPickerWidth / 10) : const EdgeInsets.only(right: _kPickerWidth / 10), - child: new Container( + child: Container( alignment: alignCenterLeft, // Adds some spaces between words. padding: const EdgeInsets.symmetric(horizontal: 2.0), @@ -306,10 +306,10 @@ class _CupertinoTimerPickerState extends State { ); } else { - minuteLabel = new IgnorePointer( - child: new Container( + minuteLabel = IgnorePointer( + child: Container( alignment: alignCenterRight, - child: new Container( + child: Container( alignment: alignCenterLeft, width: widget.mode == CupertinoTimerPickerMode.ms ? _kPickerWidth / 4 @@ -337,8 +337,8 @@ class _CupertinoTimerPickerState extends State { final double secondPickerWidth = widget.mode == CupertinoTimerPickerMode.ms ? _kPickerWidth / 10 : _kPickerWidth / 6; - return new CupertinoPicker( - scrollController: new FixedExtentScrollController( + return CupertinoPicker( + scrollController: FixedExtentScrollController( initialItem: selectedSecond ~/ widget.secondInterval, ), offAxisFraction: offAxisFraction, @@ -348,30 +348,30 @@ class _CupertinoTimerPickerState extends State { setState(() { selectedSecond = index; widget.onTimerDurationChanged( - new Duration( + Duration( hours: selectedHour ?? 0, minutes: selectedMinute, seconds: selectedSecond)); }); }, - children: new List.generate(60 ~/ widget.secondInterval, (int index) { + children: List.generate(60 ~/ widget.secondInterval, (int index) { final int second = index * widget.secondInterval; final String semanticsLabel = textDirectionFactor == 1 ? localizations.timerPickerSecond(second) + localizations.timerPickerSecondLabel(second) : localizations.timerPickerSecondLabel(second) + localizations.timerPickerSecond(second); - return new Semantics( + return Semantics( label: semanticsLabel, excludeSemantics: true, - child: new Container( + child: Container( alignment: alignCenterLeft, - child: new Container( + child: Container( alignment: alignCenterRight, // Adds some spaces between words. padding: const EdgeInsets.symmetric(horizontal: 2.0), width: secondPickerWidth, - child: new Text(localizations.timerPickerSecond(second)), + child: Text(localizations.timerPickerSecond(second)), ), ), ); @@ -383,13 +383,13 @@ class _CupertinoTimerPickerState extends State { final double secondPickerWidth = widget.mode == CupertinoTimerPickerMode.ms ? _kPickerWidth / 10 : _kPickerWidth / 6; - final Widget secondLabel = new IgnorePointer( - child: new Container( + final Widget secondLabel = IgnorePointer( + child: Container( alignment: alignCenterLeft, padding: textDirectionFactor == 1 - ? new EdgeInsets.only(left: secondPickerWidth) - : new EdgeInsets.only(right: secondPickerWidth), - child: new Container( + ? EdgeInsets.only(left: secondPickerWidth) + : EdgeInsets.only(right: secondPickerWidth), + child: Container( alignment: alignCenterLeft, // Adds some spaces between words. padding: const EdgeInsets.symmetric(horizontal: 2.0), @@ -414,35 +414,35 @@ class _CupertinoTimerPickerState extends State { Widget picker; if (widget.mode == CupertinoTimerPickerMode.hm) { - picker = new Row( + picker = Row( children: [ - new Expanded(child: _buildHourColumn()), - new Expanded(child: _buildMinuteColumn()), + Expanded(child: _buildHourColumn()), + Expanded(child: _buildMinuteColumn()), ], ); } else if (widget.mode == CupertinoTimerPickerMode.ms) { - picker = new Row( + picker = Row( children: [ - new Expanded(child: _buildMinuteColumn()), - new Expanded(child: _buildSecondColumn()), + Expanded(child: _buildMinuteColumn()), + Expanded(child: _buildSecondColumn()), ], ); } else { - picker = new Row( + picker = Row( children: [ - new Expanded(child: _buildHourColumn()), - new Container( + Expanded(child: _buildHourColumn()), + Container( width: _kPickerWidth / 3, child: _buildMinuteColumn(), ), - new Expanded(child: _buildSecondColumn()), + Expanded(child: _buildSecondColumn()), ], ); } - return new MediaQuery( + return MediaQuery( data: const MediaQueryData( // The native iOS picker's text scaling is fixed, so we will also fix it // as well in our picker. diff --git a/packages/flutter/lib/src/cupertino/dialog.dart b/packages/flutter/lib/src/cupertino/dialog.dart index 314744ec0e..092beb0a14 100644 --- a/packages/flutter/lib/src/cupertino/dialog.dart +++ b/packages/flutter/lib/src/cupertino/dialog.dart @@ -185,17 +185,17 @@ class CupertinoAlertDialog extends StatelessWidget { final List children = []; if (title != null || content != null) { - final Widget titleSection = new _CupertinoAlertContentSection( + final Widget titleSection = _CupertinoAlertContentSection( title: title, content: content, scrollController: scrollController, ); - children.add(new Flexible(flex: 3, child: titleSection)); + children.add(Flexible(flex: 3, child: titleSection)); } - return new Container( + return Container( color: _kDialogColor, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: children, @@ -204,11 +204,11 @@ class CupertinoAlertDialog extends StatelessWidget { } Widget _buildActions() { - Widget actionSection = new Container( + Widget actionSection = Container( height: 0.0, ); if (actions.isNotEmpty) { - actionSection = new _CupertinoAlertActionSection( + actionSection = _CupertinoAlertActionSection( children: actions, scrollController: actionScrollController, ); @@ -223,27 +223,27 @@ class CupertinoAlertDialog extends StatelessWidget { ?? const DefaultCupertinoLocalizations(); final bool isInAccessibilityMode = _isInAccessibilityMode(context); final double textScaleFactor = MediaQuery.of(context).textScaleFactor; - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith( // iOS does not shrink dialog content below a 1.0 scale factor textScaleFactor: math.max(textScaleFactor, 1.0), ), - child: new LayoutBuilder( + child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new Center( - child: new Container( + return Center( + child: Container( margin: const EdgeInsets.symmetric(vertical: _kEdgePadding), width: isInAccessibilityMode ? _kAccessibilityCupertinoDialogWidth : _kCupertinoDialogWidth, - child: new CupertinoPopupSurface( + child: CupertinoPopupSurface( isSurfacePainted: false, - child: new Semantics( + child: Semantics( namesRoute: true, scopesRoute: true, explicitChildNodes: true, label: localizations.alertDialogLabel, - child: new _CupertinoDialogRenderWidget( + child: _CupertinoDialogRenderWidget( contentSection: _buildContent(), actionsSection: _buildActions(), ), @@ -284,10 +284,10 @@ class CupertinoDialog extends StatelessWidget { @override Widget build(BuildContext context) { - return new Center( - child: new SizedBox( + return Center( + child: SizedBox( width: _kCupertinoDialogWidth, - child: new CupertinoPopupSurface( + child: CupertinoPopupSurface( child: child, ), ), @@ -332,13 +332,13 @@ class CupertinoPopupSurface extends StatelessWidget { @override Widget build(BuildContext context) { - return new ClipRRect( + return ClipRRect( borderRadius: BorderRadius.circular(_kDialogCornerRadius), - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: _kBlurAmount, sigmaY: _kBlurAmount), - child: new Container( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: _kBlurAmount, sigmaY: _kBlurAmount), + child: Container( decoration: _kCupertinoDialogBlurOverlayDecoration, - child: new Container( + child: Container( color: isSurfacePainted ? _kDialogColor : null, child: child, ), @@ -364,7 +364,7 @@ class _CupertinoDialogRenderWidget extends RenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderCupertinoDialog( + return _RenderCupertinoDialog( dividerThickness: _kDividerThickness / MediaQuery.of(context).devicePixelRatio, isInAccessibilityMode: _isInAccessibilityMode(context), ); @@ -536,7 +536,7 @@ class _RenderCupertinoDialog extends RenderBox { final double _dividerThickness; - final Paint _dividerPaint = new Paint() + final Paint _dividerPaint = Paint() ..color = _kButtonDividerColor ..style = PaintingStyle.fill; @@ -575,7 +575,7 @@ class _RenderCupertinoDialog extends RenderBox { @override void setupParentData(RenderBox child) { if (child.parentData is! BoxParentData) { - child.parentData = new BoxParentData(); + child.parentData = BoxParentData(); } } @@ -658,14 +658,14 @@ class _RenderCupertinoDialog extends RenderBox { // Size alert dialog content. contentSection.layout( - constraints.deflate(new EdgeInsets.only(bottom: minActionsHeight + dividerThickness)), + constraints.deflate(EdgeInsets.only(bottom: minActionsHeight + dividerThickness)), parentUsesSize: true, ); final Size contentSize = contentSection.size; // Size alert dialog actions. actionsSection.layout( - constraints.deflate(new EdgeInsets.only(top: contentSize.height + dividerThickness)), + constraints.deflate(EdgeInsets.only(top: contentSize.height + dividerThickness)), parentUsesSize: true, ); final Size actionsSize = actionsSection.size; @@ -675,14 +675,14 @@ class _RenderCupertinoDialog extends RenderBox { // Set our size now that layout calculations are complete. size = constraints.constrain( - new Size(_dialogWidth, dialogHeight) + Size(_dialogWidth, dialogHeight) ); // Set the position of the actions box to sit at the bottom of the dialog. // The content box defaults to the top left, which is where we want it. assert(actionsSection.parentData is BoxParentData); final BoxParentData actionParentData = actionsSection.parentData; - actionParentData.offset = new Offset(0.0, contentSize.height + dividerThickness); + actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness); } void performAccessibilityLayout() { @@ -703,14 +703,14 @@ class _RenderCupertinoDialog extends RenderBox { // Size alert dialog actions. actionsSection.layout( - constraints.deflate(new EdgeInsets.only(top: constraints.maxHeight / 2.0)), + constraints.deflate(EdgeInsets.only(top: constraints.maxHeight / 2.0)), parentUsesSize: true, ); actionsSize = actionsSection.size; // Size alert dialog content. contentSection.layout( - constraints.deflate(new EdgeInsets.only(bottom: actionsSize.height + dividerThickness)), + constraints.deflate(EdgeInsets.only(bottom: actionsSize.height + dividerThickness)), parentUsesSize: true, ); contentSize = contentSection.size; @@ -726,7 +726,7 @@ class _RenderCupertinoDialog extends RenderBox { // Size alert dialog actions. actionsSection.layout( - constraints.deflate(new EdgeInsets.only(top: contentSize.height)), + constraints.deflate(EdgeInsets.only(top: contentSize.height)), parentUsesSize: true, ); actionsSize = actionsSection.size; @@ -737,14 +737,14 @@ class _RenderCupertinoDialog extends RenderBox { // Set our size now that layout calculations are complete. size = constraints.constrain( - new Size(_dialogWidth, dialogHeight) + Size(_dialogWidth, dialogHeight) ); // Set the position of the actions box to sit at the bottom of the dialog. // The content box defaults to the top left, which is where we want it. assert(actionsSection.parentData is BoxParentData); final BoxParentData actionParentData = actionsSection.parentData; - actionParentData.offset = new Offset(0.0, contentSize.height + dividerThickness); + actionParentData.offset = Offset(0.0, contentSize.height + dividerThickness); } @override @@ -831,14 +831,14 @@ class _CupertinoAlertContentSection extends StatelessWidget { final double textScaleFactor = MediaQuery.of(context).textScaleFactor; final List titleContentGroup = []; if (title != null) { - titleContentGroup.add(new Padding( - padding: new EdgeInsets.only( + titleContentGroup.add(Padding( + padding: EdgeInsets.only( left: _kEdgePadding, right: _kEdgePadding, bottom: content == null ? _kEdgePadding : 1.0, top: _kEdgePadding * textScaleFactor, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kCupertinoDialogTitleStyle, textAlign: TextAlign.center, child: title, @@ -848,14 +848,14 @@ class _CupertinoAlertContentSection extends StatelessWidget { if (content != null) { titleContentGroup.add( - new Padding( - padding: new EdgeInsets.only( + Padding( + padding: EdgeInsets.only( left: _kEdgePadding, right: _kEdgePadding, bottom: _kEdgePadding * textScaleFactor, top: title == null ? _kEdgePadding : 1.0, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kCupertinoDialogContentStyle, textAlign: TextAlign.center, child: content, @@ -865,16 +865,16 @@ class _CupertinoAlertContentSection extends StatelessWidget { } if (titleContentGroup.isEmpty) { - return new SingleChildScrollView( + return SingleChildScrollView( controller: scrollController, - child: new Container(width: 0.0, height: 0.0), + child: Container(width: 0.0, height: 0.0), ); } - return new CupertinoScrollbar( - child: new SingleChildScrollView( + return CupertinoScrollbar( + child: SingleChildScrollView( controller: scrollController, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.max, crossAxisAlignment: CrossAxisAlignment.stretch, children: titleContentGroup, @@ -906,7 +906,7 @@ class _CupertinoAlertActionSection extends StatefulWidget { final ScrollController scrollController; @override - _CupertinoAlertActionSectionState createState() => new _CupertinoAlertActionSectionState(); + _CupertinoAlertActionSectionState createState() => _CupertinoAlertActionSectionState(); } class _CupertinoAlertActionSectionState extends State<_CupertinoAlertActionSection> { @@ -917,16 +917,16 @@ class _CupertinoAlertActionSectionState extends State<_CupertinoAlertActionSecti final List interactiveButtons = []; for (int i = 0; i < widget.children.length; i += 1) { interactiveButtons.add( - new _PressableActionButton( + _PressableActionButton( child: widget.children[i], ), ); } - return new CupertinoScrollbar( - child: new SingleChildScrollView( + return CupertinoScrollbar( + child: SingleChildScrollView( controller: widget.scrollController, - child: new _CupertinoDialogActionsRenderWidget( + child: _CupertinoDialogActionsRenderWidget( actionButtons: interactiveButtons, dividerThickness: _kDividerThickness / devicePixelRatio, ), @@ -948,7 +948,7 @@ class _PressableActionButton extends StatefulWidget { final Widget child; @override - _PressableActionButtonState createState() => new _PressableActionButtonState(); + _PressableActionButtonState createState() => _PressableActionButtonState(); } class _PressableActionButtonState extends State<_PressableActionButton> { @@ -956,11 +956,11 @@ class _PressableActionButtonState extends State<_PressableActionButton> { @override Widget build(BuildContext context) { - return new _ActionButtonParentDataWidget( + return _ActionButtonParentDataWidget( isPressed: _isPressed, - child: new MergeSemantics( + child: MergeSemantics( // TODO(mattcarroll): Button press dynamics need overhaul for iOS: https://github.com/flutter/flutter/issues/19786 - child: new GestureDetector( + child: GestureDetector( excludeFromSemantics: true, behavior: HitTestBehavior.opaque, onTapDown: (TapDownDetails details) => setState(() { @@ -1094,19 +1094,19 @@ class CupertinoDialogAction extends StatelessWidget { final double fontSizeRatio = (textScaleFactor * textStyle.fontSize) / _kMinButtonFontSize; final double padding = _calculatePadding(context); - return new IntrinsicHeight( - child: new SizedBox( + return IntrinsicHeight( + child: SizedBox( width: double.infinity, - child: new FittedBox( + child: FittedBox( fit: BoxFit.scaleDown, - child: new ConstrainedBox( - constraints: new BoxConstraints( + child: ConstrainedBox( + constraints: BoxConstraints( maxWidth: fontSizeRatio * (dialogWidth - (2 * padding)), ), - child: new Semantics( + child: Semantics( button: true, onTap: onPressed, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: textStyle, textAlign: TextAlign.center, overflow: TextOverflow.ellipsis, @@ -1127,7 +1127,7 @@ class CupertinoDialogAction extends StatelessWidget { @required TextStyle textStyle, @required Widget content, }) { - return new DefaultTextStyle( + return DefaultTextStyle( style: textStyle, textAlign: TextAlign.center, child: content, @@ -1164,17 +1164,17 @@ class CupertinoDialogAction extends StatelessWidget { content: child, ); - return new GestureDetector( + return GestureDetector( excludeFromSemantics: true, onTap: onPressed, behavior: HitTestBehavior.opaque, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints( minHeight: _kMinButtonHeight, ), - child: new Container( + child: Container( alignment: Alignment.center, - padding: new EdgeInsets.all(_calculatePadding(context)), + padding: EdgeInsets.all(_calculatePadding(context)), child: sizedContent, ), ), @@ -1201,7 +1201,7 @@ class _CupertinoDialogActionsRenderWidget extends MultiChildRenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderCupertinoDialogActions( + return _RenderCupertinoDialogActions( dialogWidth: _isInAccessibilityMode(context) ? _kAccessibilityCupertinoDialogWidth : _kCupertinoDialogWidth, @@ -1283,15 +1283,15 @@ class _RenderCupertinoDialogActions extends RenderBox } } - final Paint _buttonBackgroundPaint = new Paint() + final Paint _buttonBackgroundPaint = Paint() ..color = _kDialogColor ..style = PaintingStyle.fill; - final Paint _pressedButtonBackgroundPaint = new Paint() + final Paint _pressedButtonBackgroundPaint = Paint() ..color = _kDialogPressedColor ..style = PaintingStyle.fill; - final Paint _dividerPaint = new Paint() + final Paint _dividerPaint = Paint() ..color = _kButtonDividerColor ..style = PaintingStyle.fill; @@ -1323,7 +1323,7 @@ class _RenderCupertinoDialogActions extends RenderBox @override void setupParentData(RenderBox child) { if (child.parentData is! _ActionButtonParentData) - child.parentData = new _ActionButtonParentData(); + child.parentData = _ActionButtonParentData(); } @override @@ -1461,11 +1461,11 @@ class _RenderCupertinoDialogActions extends RenderBox ); size = constraints.constrain( - new Size(dialogWidth, firstChild.size.height) + Size(dialogWidth, firstChild.size.height) ); } else { // Each button gets half the available width, minus a single divider. - final BoxConstraints perButtonConstraints = new BoxConstraints( + final BoxConstraints perButtonConstraints = BoxConstraints( minWidth: (constraints.minWidth - dividerThickness) / 2.0, maxWidth: (constraints.maxWidth - dividerThickness) / 2.0, minHeight: 0.0, @@ -1485,11 +1485,11 @@ class _RenderCupertinoDialogActions extends RenderBox // The 2nd button needs to be offset to the right. assert(lastChild.parentData is MultiChildLayoutParentData); final MultiChildLayoutParentData secondButtonParentData = lastChild.parentData; - secondButtonParentData.offset = new Offset(firstChild.size.width + dividerThickness, 0.0); + secondButtonParentData.offset = Offset(firstChild.size.width + dividerThickness, 0.0); // Calculate our size based on the button sizes. size = constraints.constrain( - new Size( + Size( dialogWidth, math.max( firstChild.size.height, @@ -1516,7 +1516,7 @@ class _RenderCupertinoDialogActions extends RenderBox assert(child.parentData is MultiChildLayoutParentData); final MultiChildLayoutParentData parentData = child.parentData; - parentData.offset = new Offset(0.0, verticalOffset); + parentData.offset = Offset(0.0, verticalOffset); verticalOffset += child.size.height; if (index < childCount - 1) { @@ -1530,7 +1530,7 @@ class _RenderCupertinoDialogActions extends RenderBox // Our height is the accumulated height of all buttons and dividers. size = constraints.constrain( - new Size(dialogWidth, verticalOffset) + Size(dialogWidth, verticalOffset) ); } } @@ -1553,7 +1553,7 @@ class _RenderCupertinoDialogActions extends RenderBox // the dialog has 2 buttons). The vertical divider is hidden if either the // left or right button is pressed. final Rect verticalDivider = childCount == 2 && !_isButtonPressed - ? new Rect.fromLTWH( + ? Rect.fromLTWH( offset.dx + firstChild.size.width, offset.dy, dividerThickness, @@ -1567,7 +1567,7 @@ class _RenderCupertinoDialogActions extends RenderBox final List pressedButtonRects = _pressedButtons.map((RenderBox pressedButton) { final MultiChildLayoutParentData buttonParentData = pressedButton.parentData; - return new Rect.fromLTWH( + return Rect.fromLTWH( offset.dx + buttonParentData.offset.dx, offset.dy + buttonParentData.offset.dy, pressedButton.size.width, @@ -1576,7 +1576,7 @@ class _RenderCupertinoDialogActions extends RenderBox }).toList(); // Create the button backgrounds path and paint it. - final Path backgroundFillPath = new Path() + final Path backgroundFillPath = Path() ..fillType = PathFillType.evenOdd ..addRect(Rect.largest) ..addRect(verticalDivider); @@ -1591,7 +1591,7 @@ class _RenderCupertinoDialogActions extends RenderBox ); // Create the pressed buttons background path and paint it. - final Path pressedBackgroundFillPath = new Path(); + final Path pressedBackgroundFillPath = Path(); for (int i = 0; i < pressedButtonRects.length; i += 1) { pressedBackgroundFillPath.addRect(pressedButtonRects[i]); } @@ -1602,7 +1602,7 @@ class _RenderCupertinoDialogActions extends RenderBox ); // Create the dividers path and paint it. - final Path dividersPath = new Path() + final Path dividersPath = Path() ..addRect(verticalDivider); canvas.drawPath( @@ -1612,15 +1612,15 @@ class _RenderCupertinoDialogActions extends RenderBox } void _drawButtonBackgroundsAndDividersStacked(Canvas canvas, Offset offset) { - final Offset dividerOffset = new Offset(0.0, dividerThickness); + final Offset dividerOffset = Offset(0.0, dividerThickness); - final Path backgroundFillPath = new Path() + final Path backgroundFillPath = Path() ..fillType = PathFillType.evenOdd ..addRect(Rect.largest); - final Path pressedBackgroundFillPath = new Path(); + final Path pressedBackgroundFillPath = Path(); - final Path dividersPath = new Path(); + final Path dividersPath = Path(); Offset accumulatingOffset = offset; @@ -1641,14 +1641,14 @@ class _RenderCupertinoDialogActions extends RenderBox final bool isDividerPresent = child != firstChild; final bool isDividerPainted = isDividerPresent && !(isButtonPressed || isPrevButtonPressed); - final Rect dividerRect = new Rect.fromLTWH( + final Rect dividerRect = Rect.fromLTWH( accumulatingOffset.dx, accumulatingOffset.dy, size.width, dividerThickness, ); - final Rect buttonBackgroundRect = new Rect.fromLTWH( + final Rect buttonBackgroundRect = Rect.fromLTWH( accumulatingOffset.dx, accumulatingOffset.dy + (isDividerPresent ? dividerThickness : 0.0), size.width, @@ -1671,7 +1671,7 @@ class _RenderCupertinoDialogActions extends RenderBox } accumulatingOffset += (isDividerPresent ? dividerOffset : Offset.zero) - + new Offset(0.0, child.size.height); + + Offset(0.0, child.size.height); prevChild = child; child = childAfter(child); diff --git a/packages/flutter/lib/src/cupertino/localizations.dart b/packages/flutter/lib/src/cupertino/localizations.dart index 0d231766bf..92317be246 100644 --- a/packages/flutter/lib/src/cupertino/localizations.dart +++ b/packages/flutter/lib/src/cupertino/localizations.dart @@ -263,7 +263,7 @@ class DefaultCupertinoLocalizations implements CupertinoLocalizations { /// /// This method is typically used to create a [LocalizationsDelegate]. static Future load(Locale locale) { - return new SynchronousFuture(const DefaultCupertinoLocalizations()); + return SynchronousFuture(const DefaultCupertinoLocalizations()); } /// A [LocalizationsDelegate] that uses [DefaultCupertinoLocalizations.load] diff --git a/packages/flutter/lib/src/cupertino/nav_bar.dart b/packages/flutter/lib/src/cupertino/nav_bar.dart index f51c518e45..104df40fe4 100644 --- a/packages/flutter/lib/src/cupertino/nav_bar.dart +++ b/packages/flutter/lib/src/cupertino/nav_bar.dart @@ -75,7 +75,7 @@ class _HeroTag { } TextStyle _navBarItemStyle(Color color) { - return new TextStyle( + return TextStyle( fontFamily: '.SF UI Text', fontSize: 17.0, letterSpacing: -0.24, @@ -100,14 +100,14 @@ Widget _wrapWithBackground({ final SystemUiOverlayStyle overlayStyle = darkBackground ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; - result = new AnnotatedRegion( + result = AnnotatedRegion( value: overlayStyle, sized: true, child: result, ); } - final DecoratedBox childWithBackground = new DecoratedBox( - decoration: new BoxDecoration( + final DecoratedBox childWithBackground = DecoratedBox( + decoration: BoxDecoration( border: border, color: backgroundColor, ), @@ -117,9 +117,9 @@ Widget _wrapWithBackground({ if (backgroundColor.alpha == 0xFF) return childWithBackground; - return new ClipRect( - child: new BackdropFilter( - filter: new ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), + return ClipRect( + child: BackdropFilter( + filter: ImageFilter.blur(sigmaX: 10.0, sigmaY: 10.0), child: childWithBackground, ), ); @@ -342,7 +342,7 @@ class CupertinoNavigationBar extends StatefulWidget implements ObstructingPrefer @override _CupertinoNavigationBarState createState() { - return new _CupertinoNavigationBarState(); + return _CupertinoNavigationBarState(); } } @@ -355,12 +355,12 @@ class _CupertinoNavigationBarState extends State { @override void initState() { super.initState(); - keys = new _NavigationBarStaticComponentsKeys(); + keys = _NavigationBarStaticComponentsKeys(); } @override Widget build(BuildContext context) { - final _NavigationBarStaticComponents components = new _NavigationBarStaticComponents( + final _NavigationBarStaticComponents components = _NavigationBarStaticComponents( keys: keys, route: ModalRoute.of(context), userLeading: widget.leading, @@ -378,7 +378,7 @@ class _CupertinoNavigationBarState extends State { final Widget navBar = _wrapWithBackground( border: widget.border, backgroundColor: widget.backgroundColor, - child: new _PersistentNavigationBar( + child: _PersistentNavigationBar( components: components, padding: widget.padding, ), @@ -388,12 +388,12 @@ class _CupertinoNavigationBarState extends State { return navBar; } - return new Hero( + return Hero( tag: widget.heroTag, createRectTween: _linearTranslateWithLargestRectSizeTween, placeholderBuilder: _navBarHeroLaunchPadBuilder, flightShuttleBuilder: _navBarHeroFlightShuttleBuilder, - child: new _TransitionableNavigationBar( + child: _TransitionableNavigationBar( componentsKeys: keys, backgroundColor: widget.backgroundColor, actionsForegroundColor: widget.actionsForegroundColor, @@ -558,7 +558,7 @@ class CupertinoSliverNavigationBar extends StatefulWidget { bool get opaque => backgroundColor.alpha == 0xFF; @override - _CupertinoSliverNavigationBarState createState() => new _CupertinoSliverNavigationBarState(); + _CupertinoSliverNavigationBarState createState() => _CupertinoSliverNavigationBarState(); } // A state class exists for the nav bar so that the keys of its sub-components @@ -570,12 +570,12 @@ class _CupertinoSliverNavigationBarState extends State[ - new Positioned( + Positioned( top: persistentHeight, left: 0.0, right: 0.0, bottom: 0.0, - child: new ClipRect( + child: ClipRect( // The large title starts at the persistent bar. // It's aligned with the bottom of the sliver and expands clipped // and behind the persistent bar. - child: new OverflowBox( + child: OverflowBox( minHeight: 0.0, maxHeight: double.infinity, alignment: AlignmentDirectional.bottomStart, - child: new Padding( + child: Padding( padding: const EdgeInsetsDirectional.only( start: _kNavBarEdgePadding, bottom: 8.0, // Bottom has a different padding. ), - child: new SafeArea( + child: SafeArea( top: false, bottom: false, - child: new AnimatedOpacity( + child: AnimatedOpacity( opacity: showLargeTitle ? 1.0 : 0.0, duration: _kNavBarTitleFadeDuration, - child: new Semantics( + child: Semantics( header: true, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kLargeTitleTextStyle, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -703,7 +703,7 @@ class _LargeTitleNavigationBarSliverDelegate ), ), ), - new Positioned( + Positioned( left: 0.0, right: 0.0, top: 0.0, @@ -717,7 +717,7 @@ class _LargeTitleNavigationBarSliverDelegate return navBar; } - return new Hero( + return Hero( tag: heroTag, createRectTween: _linearTranslateWithLargestRectSizeTween, flightShuttleBuilder: _navBarHeroFlightShuttleBuilder, @@ -725,7 +725,7 @@ class _LargeTitleNavigationBarSliverDelegate // This is all the way down here instead of being at the top level of // CupertinoSliverNavigationBar like CupertinoNavigationBar because it // needs to wrap the top level RenderBox rather than a RenderSliver. - child: new _TransitionableNavigationBar( + child: _TransitionableNavigationBar( componentsKeys: keys, backgroundColor: backgroundColor, actionsForegroundColor: actionsForegroundColor, @@ -777,15 +777,15 @@ class _PersistentNavigationBar extends StatelessWidget { Widget middle = components.middle; if (middle != null) { - middle = new DefaultTextStyle( + middle = DefaultTextStyle( style: _kMiddleTitleTextStyle, - child: new Semantics(header: true, child: middle), + child: Semantics(header: true, child: middle), ); // When the middle's visibility can change on the fly like with large title // slivers, wrap with animated opacity. middle = middleVisible == null ? middle - : new AnimatedOpacity( + : AnimatedOpacity( opacity: middleVisible ? 1.0 : 0.0, duration: _kNavBarTitleFadeDuration, child: middle, @@ -797,14 +797,14 @@ class _PersistentNavigationBar extends StatelessWidget { final Widget backLabel = components.backLabel; if (leading == null && backChevron != null && backLabel != null) { - leading = new CupertinoNavigationBarBackButton._assemble( + leading = CupertinoNavigationBarBackButton._assemble( backChevron, backLabel, components.actionsForegroundColor, ); } - Widget paddedToolbar = new NavigationToolbar( + Widget paddedToolbar = NavigationToolbar( leading: leading, middle: middle, trailing: components.trailing, @@ -813,7 +813,7 @@ class _PersistentNavigationBar extends StatelessWidget { ); if (padding != null) { - paddedToolbar = new Padding( + paddedToolbar = Padding( padding: EdgeInsets.only( top: padding.top, bottom: padding.bottom, @@ -822,9 +822,9 @@ class _PersistentNavigationBar extends StatelessWidget { ); } - return new SizedBox( + return SizedBox( height: _kNavBarPersistentHeight + MediaQuery.of(context).padding.top, - child: new SafeArea( + child: SafeArea( bottom: false, child: paddedToolbar, ), @@ -841,13 +841,13 @@ class _PersistentNavigationBar extends StatelessWidget { @immutable class _NavigationBarStaticComponentsKeys { _NavigationBarStaticComponentsKeys() - : navBarBoxKey = new GlobalKey(debugLabel: 'Navigation bar render box'), - leadingKey = new GlobalKey(debugLabel: 'Leading'), - backChevronKey = new GlobalKey(debugLabel: 'Back chevron'), - backLabelKey = new GlobalKey(debugLabel: 'Back label'), - middleKey = new GlobalKey(debugLabel: 'Middle'), - trailingKey = new GlobalKey(debugLabel: 'Trailing'), - largeTitleKey = new GlobalKey(debugLabel: 'Large title'); + : navBarBoxKey = GlobalKey(debugLabel: 'Navigation bar render box'), + leadingKey = GlobalKey(debugLabel: 'Leading'), + backChevronKey = GlobalKey(debugLabel: 'Back chevron'), + backLabelKey = GlobalKey(debugLabel: 'Back label'), + middleKey = GlobalKey(debugLabel: 'Middle'), + trailingKey = GlobalKey(debugLabel: 'Trailing'), + largeTitleKey = GlobalKey(debugLabel: 'Large title'); final GlobalKey navBarBoxKey; final GlobalKey leadingKey; @@ -928,7 +928,7 @@ class _NavigationBarStaticComponents { if (automaticallyImplyTitle && currentRoute is CupertinoPageRoute && currentRoute.title != null) { - return new Text(currentRoute.title); + return Text(currentRoute.title); } return null; @@ -955,7 +955,7 @@ class _NavigationBarStaticComponents { route.canPop && route.fullscreenDialog ) { - leadingContent = new CupertinoButton( + leadingContent = CupertinoButton( child: const Text('Close'), padding: EdgeInsets.zero, onPressed: () { route.navigator.maybePop(); }, @@ -966,16 +966,16 @@ class _NavigationBarStaticComponents { return null; } - return new KeyedSubtree( + return KeyedSubtree( key: leadingKey, - child: new Padding( - padding: new EdgeInsetsDirectional.only( + child: Padding( + padding: EdgeInsetsDirectional.only( start: padding?.start ?? _kNavBarEdgePadding, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _navBarItemStyle(actionsForegroundColor), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: actionsForegroundColor, size: 32.0, ), @@ -1003,7 +1003,7 @@ class _NavigationBarStaticComponents { return null; } - return new KeyedSubtree(key: backChevronKey, child: const _BackChevron()); + return KeyedSubtree(key: backChevronKey, child: const _BackChevron()); } /// This widget is not decorated with a font since the font style could @@ -1026,9 +1026,9 @@ class _NavigationBarStaticComponents { return null; } - return new KeyedSubtree( + return KeyedSubtree( key: backLabelKey, - child: new _BackLabel( + child: _BackLabel( specifiedPreviousTitle: previousPageTitle, route: route, ), @@ -1061,7 +1061,7 @@ class _NavigationBarStaticComponents { return null; } - return new KeyedSubtree( + return KeyedSubtree( key: middleKey, child: middleContent, ); @@ -1078,16 +1078,16 @@ class _NavigationBarStaticComponents { return null; } - return new KeyedSubtree( + return KeyedSubtree( key: trailingKey, - child: new Padding( - padding: new EdgeInsetsDirectional.only( + child: Padding( + padding: EdgeInsetsDirectional.only( end: padding?.end ?? _kNavBarEdgePadding, ), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _navBarItemStyle(actionsForegroundColor), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: actionsForegroundColor, size: 32.0, ), @@ -1122,7 +1122,7 @@ class _NavigationBarStaticComponents { 'largeTitle was not provided and there was no title from the route.', ); - return new KeyedSubtree( + return KeyedSubtree( key: largeTitleKey, child: largeTitleContent, ); @@ -1181,25 +1181,25 @@ class CupertinoNavigationBarBackButton extends StatelessWidget { 'CupertinoNavigationBarBackButton should only be used in routes that can be popped', ); - return new CupertinoButton( - child: new Semantics( + return CupertinoButton( + child: Semantics( container: true, excludeSemantics: true, label: 'Back', button: true, child: ConstrainedBox( constraints: const BoxConstraints(minWidth: _kNavBarBackButtonTapWidth), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _navBarItemStyle(color), - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.start, children: [ const Padding(padding: EdgeInsetsDirectional.only(start: 8.0)), _backChevron ?? const _BackChevron(), const Padding(padding: EdgeInsetsDirectional.only(start: 6.0)), - new Flexible( - child: _backLabel ?? new _BackLabel( + Flexible( + child: _backLabel ?? _BackLabel( specifiedPreviousTitle: previousPageTitle, route: currentRoute, ), @@ -1226,10 +1226,10 @@ class _BackChevron extends StatelessWidget { // Replicate the Icon logic here to get a tightly sized icon and add // custom non-square padding. - Widget iconWidget = new Text.rich( - new TextSpan( - text: new String.fromCharCode(CupertinoIcons.back.codePoint), - style: new TextStyle( + Widget iconWidget = Text.rich( + TextSpan( + text: String.fromCharCode(CupertinoIcons.back.codePoint), + style: TextStyle( inherit: false, color: textStyle.color, fontSize: 34.0, @@ -1240,8 +1240,8 @@ class _BackChevron extends StatelessWidget { ); switch (textDirection) { case TextDirection.rtl: - iconWidget = new Transform( - transform: new Matrix4.identity()..scale(-1.0, 1.0, 1.0), + iconWidget = Transform( + transform: Matrix4.identity()..scale(-1.0, 1.0, 1.0), alignment: Alignment.center, transformHitTests: false, child: iconWidget, @@ -1275,7 +1275,7 @@ class _BackLabel extends StatelessWidget { return const SizedBox(height: 0.0, width: 0.0); } - Text textWidget = new Text( + Text textWidget = Text( previousTitle, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -1285,7 +1285,7 @@ class _BackLabel extends StatelessWidget { textWidget = const Text('Back'); } - return new Align( + return Align( alignment: AlignmentDirectional.centerStart, widthFactor: 1.0, child: textWidget, @@ -1301,7 +1301,7 @@ class _BackLabel extends StatelessWidget { // There is no timing issue because the previousTitle Listenable changes // happen during route modifications before the ValueListenableBuilder // is built. - return new ValueListenableBuilder( + return ValueListenableBuilder( valueListenable: cupertinoRoute.previousTitle, builder: _buildPreviousTitleWidget, ); @@ -1402,19 +1402,19 @@ class _NavigationBarTransition extends StatelessWidget { @required this.animation, @required _TransitionableNavigationBar topNavBar, @required _TransitionableNavigationBar bottomNavBar, - }) : heightTween = new Tween( + }) : heightTween = Tween( begin: bottomNavBar.renderBox.size.height, end: topNavBar.renderBox.size.height, ), - backgroundTween = new ColorTween( + backgroundTween = ColorTween( begin: bottomNavBar.backgroundColor, end: topNavBar.backgroundColor, ), - borderTween = new BorderTween( + borderTween = BorderTween( begin: bottomNavBar.border, end: topNavBar.border, ), - componentsTransition = new _NavigationBarComponentsTransition( + componentsTransition = _NavigationBarComponentsTransition( animation: animation, bottomNavBar: bottomNavBar, topNavBar: topNavBar, @@ -1440,7 +1440,7 @@ class _NavigationBarTransition extends StatelessWidget { updateSystemUiOverlay: false, backgroundColor: backgroundTween.evaluate(animation), border: borderTween.evaluate(animation), - child: new SizedBox( + child: SizedBox( height: heightTween.evaluate(animation), width: double.infinity, ), @@ -1469,10 +1469,10 @@ class _NavigationBarTransition extends StatelessWidget { // navigation bars. It's not a direct Rect lerp because some components // can actually be outside the linearly lerp'ed Rect in the middle of // the animation, such as the topLargeTitle. - return new SizedBox( + return SizedBox( height: math.max(heightTween.begin, heightTween.end) + MediaQuery.of(context).padding.top, width: double.infinity, - child: new Stack( + child: Stack( children: children, ), ); @@ -1520,11 +1520,11 @@ class _NavigationBarComponentsTransition { // paintBounds are based on offset zero so it's ok to expand the Rects. bottomNavBar.renderBox.paintBounds.expandToInclude(topNavBar.renderBox.paintBounds); - static final Tween fadeOut = new Tween( + static final Tween fadeOut = Tween( begin: 1.0, end: 0.0, ); - static final Tween fadeIn = new Tween( + static final Tween fadeIn = Tween( begin: 0.0, end: 1.0, ); @@ -1559,7 +1559,7 @@ class _NavigationBarComponentsTransition { final RenderBox componentBox = key.currentContext.findRenderObject(); assert(componentBox.attached); - return new RelativeRect.fromRect( + return RelativeRect.fromRect( componentBox.localToGlobal(Offset.zero, ancestor: from) & componentBox.size, transitionBox, ); @@ -1594,21 +1594,21 @@ class _NavigationBarComponentsTransition { - fromBox.size.height / 2 + toBox.size.height / 2 ) & fromBox.size; // Keep the from render object's size. - return new RelativeRectTween( + return RelativeRectTween( begin: fromRect, - end: new RelativeRect.fromRect(toRect, transitionBox), + end: RelativeRect.fromRect(toRect, transitionBox), ); } Animation fadeInFrom(double t, { Curve curve = Curves.easeIn }) { return fadeIn.animate( - new CurvedAnimation(curve: new Interval(t, 1.0, curve: curve), parent: animation), + CurvedAnimation(curve: Interval(t, 1.0, curve: curve), parent: animation), ); } Animation fadeOutBy(double t, { Curve curve = Curves.easeOut }) { return fadeOut.animate( - new CurvedAnimation(curve: new Interval(0.0, t, curve: curve), parent: animation), + CurvedAnimation(curve: Interval(0.0, t, curve: curve), parent: animation), ); } @@ -1619,9 +1619,9 @@ class _NavigationBarComponentsTransition { return null; } - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: positionInTransitionBox(bottomComponents.leadingKey, from: bottomNavBarBox), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(0.4), child: bottomLeading.child, ), @@ -1635,11 +1635,11 @@ class _NavigationBarComponentsTransition { return null; } - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: positionInTransitionBox(bottomComponents.backChevronKey, from: bottomNavBarBox), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(0.6), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: bottomActionsStyle, child: bottomBackChevron.child, ), @@ -1657,16 +1657,16 @@ class _NavigationBarComponentsTransition { final RelativeRect from = positionInTransitionBox(bottomComponents.backLabelKey, from: bottomNavBarBox); // Transition away by sliding horizontally to the left off of the screen. - final RelativeRectTween positionTween = new RelativeRectTween( + final RelativeRectTween positionTween = RelativeRectTween( begin: from, - end: from.shift(new Offset(-bottomNavBarBox.size.width / 2.0, 0.0)), + end: from.shift(Offset(-bottomNavBarBox.size.width / 2.0, 0.0)), ); - return new PositionedTransition( + return PositionedTransition( rect: positionTween.animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(0.2), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: bottomActionsStyle, child: bottomBackLabel.child, ), @@ -1686,21 +1686,21 @@ class _NavigationBarComponentsTransition { } if (bottomMiddle != null && topBackLabel != null) { - return new PositionedTransition( + return PositionedTransition( rect: slideFromLeadingEdge( fromKey: bottomComponents.middleKey, fromNavBarBox: bottomNavBarBox, toKey: topComponents.backLabelKey, toNavBarBox: topNavBarBox, ).animate(animation), - child: new FadeTransition( + child: FadeTransition( // A custom middle widget like a segmented control fades away faster. opacity: fadeOutBy(bottomHasUserMiddle ? 0.4 : 0.7), - child: new Align( + child: Align( // As the text shrinks, make sure it's still anchored to the leading // edge of a constantly sized outer box. alignment: AlignmentDirectional.centerStart, - child: new DefaultTextStyleTransition( + child: DefaultTextStyleTransition( style: TextStyleTween( begin: _kMiddleTitleTextStyle, end: topActionsStyle, @@ -1715,12 +1715,12 @@ class _NavigationBarComponentsTransition { // When the top page has a leading widget override, don't move the bottom // middle widget. if (bottomMiddle != null && topLeading != null) { - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: positionInTransitionBox(bottomComponents.middleKey, from: bottomNavBarBox), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(bottomHasUserMiddle ? 0.4 : 0.7), // Keep the font when transitioning into a non-back label leading. - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kMiddleTitleTextStyle, child: bottomMiddle.child, ), @@ -1741,20 +1741,20 @@ class _NavigationBarComponentsTransition { } if (bottomLargeTitle != null && topBackLabel != null) { - return new PositionedTransition( + return PositionedTransition( rect: slideFromLeadingEdge( fromKey: bottomComponents.largeTitleKey, fromNavBarBox: bottomNavBarBox, toKey: topComponents.backLabelKey, toNavBarBox: topNavBarBox, ).animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(0.6), - child: new Align( + child: Align( // As the text shrinks, make sure it's still anchored to the leading // edge of a constantly sized outer box. alignment: AlignmentDirectional.centerStart, - child: new DefaultTextStyleTransition( + child: DefaultTextStyleTransition( style: TextStyleTween( begin: _kLargeTitleTextStyle, end: topActionsStyle, @@ -1771,19 +1771,19 @@ class _NavigationBarComponentsTransition { if (bottomLargeTitle != null && topLeading != null) { final RelativeRect from = positionInTransitionBox(bottomComponents.largeTitleKey, from: bottomNavBarBox); - final RelativeRectTween positionTween = new RelativeRectTween( + final RelativeRectTween positionTween = RelativeRectTween( begin: from, - end: from.shift(new Offset(bottomNavBarBox.size.width / 4.0, 0.0)), + end: from.shift(Offset(bottomNavBarBox.size.width / 4.0, 0.0)), ); // Just shift slightly towards the right instead of moving to the back // label position. - return new PositionedTransition( + return PositionedTransition( rect: positionTween.animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(0.4), // Keep the font when transitioning into a non-back-label leading. - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kLargeTitleTextStyle, child: bottomLargeTitle.child, ), @@ -1801,9 +1801,9 @@ class _NavigationBarComponentsTransition { return null; } - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: positionInTransitionBox(bottomComponents.trailingKey, from: bottomNavBarBox), - child: new FadeTransition( + child: FadeTransition( opacity: fadeOutBy(0.6), child: bottomTrailing.child, ), @@ -1817,9 +1817,9 @@ class _NavigationBarComponentsTransition { return null; } - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: positionInTransitionBox(topComponents.leadingKey, from: topNavBarBox), - child: new FadeTransition( + child: FadeTransition( opacity: fadeInFrom(0.6), child: topLeading.child, ), @@ -1841,19 +1841,19 @@ class _NavigationBarComponentsTransition { // right. if (bottomBackChevron == null) { final RenderBox topBackChevronBox = topComponents.backChevronKey.currentContext.findRenderObject(); - from = to.shift(new Offset(topBackChevronBox.size.width * 2.0, 0.0)); + from = to.shift(Offset(topBackChevronBox.size.width * 2.0, 0.0)); } - final RelativeRectTween positionTween = new RelativeRectTween( + final RelativeRectTween positionTween = RelativeRectTween( begin: from, end: to, ); - return new PositionedTransition( + return PositionedTransition( rect: positionTween.animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: fadeInFrom(bottomBackChevron == null ? 0.7 : 0.4), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: topActionsStyle, child: topBackChevron.child, ), @@ -1877,7 +1877,7 @@ class _NavigationBarComponentsTransition { Animation midClickOpacity; if (topBackLabelOpacity != null && topBackLabelOpacity.opacity.value < 1.0) { - midClickOpacity = new Tween( + midClickOpacity = Tween( begin: 0.0, end: topBackLabelOpacity.opacity.value, ).animate(animation); @@ -1892,16 +1892,16 @@ class _NavigationBarComponentsTransition { topBackLabel != null && bottomLargeExpanded ) { - return new PositionedTransition( + return PositionedTransition( rect: slideFromLeadingEdge( fromKey: bottomComponents.largeTitleKey, fromNavBarBox: bottomNavBarBox, toKey: topComponents.backLabelKey, toNavBarBox: topNavBarBox, ).animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: midClickOpacity ?? fadeInFrom(0.4), - child: new DefaultTextStyleTransition( + child: DefaultTextStyleTransition( style: TextStyleTween( begin: _kLargeTitleTextStyle, end: topActionsStyle, @@ -1917,16 +1917,16 @@ class _NavigationBarComponentsTransition { // The topBackLabel always comes from the large title first if available // and expanded instead of middle. if (bottomMiddle != null && topBackLabel != null) { - return new PositionedTransition( + return PositionedTransition( rect: slideFromLeadingEdge( fromKey: bottomComponents.middleKey, fromNavBarBox: bottomNavBarBox, toKey: topComponents.backLabelKey, toNavBarBox: topNavBarBox, ).animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: midClickOpacity ?? fadeInFrom(0.3), - child: new DefaultTextStyleTransition( + child: DefaultTextStyleTransition( style: TextStyleTween( begin: _kMiddleTitleTextStyle, end: topActionsStyle, @@ -1956,16 +1956,16 @@ class _NavigationBarComponentsTransition { final RelativeRect to = positionInTransitionBox(topComponents.middleKey, from: topNavBarBox); // Shift in from the trailing edge of the screen. - final RelativeRectTween positionTween = new RelativeRectTween( - begin: to.shift(new Offset(topNavBarBox.size.width / 2.0, 0.0)), + final RelativeRectTween positionTween = RelativeRectTween( + begin: to.shift(Offset(topNavBarBox.size.width / 2.0, 0.0)), end: to, ); - return new PositionedTransition( + return PositionedTransition( rect: positionTween.animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: fadeInFrom(0.25), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kMiddleTitleTextStyle, child: topMiddle.child, ), @@ -1980,9 +1980,9 @@ class _NavigationBarComponentsTransition { return null; } - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: positionInTransitionBox(topComponents.trailingKey, from: topNavBarBox), - child: new FadeTransition( + child: FadeTransition( opacity: fadeInFrom(0.4), child: topTrailing.child, ), @@ -1999,16 +1999,16 @@ class _NavigationBarComponentsTransition { final RelativeRect to = positionInTransitionBox(topComponents.largeTitleKey, from: topNavBarBox); // Shift in from the trailing edge of the screen. - final RelativeRectTween positionTween = new RelativeRectTween( - begin: to.shift(new Offset(topNavBarBox.size.width, 0.0)), + final RelativeRectTween positionTween = RelativeRectTween( + begin: to.shift(Offset(topNavBarBox.size.width, 0.0)), end: to, ); - return new PositionedTransition( + return PositionedTransition( rect: positionTween.animate(animation), - child: new FadeTransition( + child: FadeTransition( opacity: fadeInFrom(0.3), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: _kLargeTitleTextStyle, maxLines: 1, overflow: TextOverflow.ellipsis, @@ -2022,11 +2022,11 @@ class _NavigationBarComponentsTransition { /// Navigation bars' hero rect tween that will move between the static bars /// but keep a constant size that's the bigger of both navigation bars. CreateRectTween _linearTranslateWithLargestRectSizeTween = (Rect begin, Rect end) { - final Size largestSize = new Size( + final Size largestSize = Size( math.max(begin.size.width, end.size.width), math.max(begin.size.height, end.size.height), ); - return new RectTween( + return RectTween( begin: begin.topLeft & largestSize, end: end.topLeft & largestSize, ); @@ -2048,7 +2048,7 @@ final TransitionBuilder _navBarHeroLaunchPadBuilder = ( // This is ok performance-wise because static nav bars are generally cheap to // build and layout but expensive to GPU render (due to clips and blurs) which // we're skipping here. - return new Visibility( + return Visibility( maintainSize: true, maintainAnimation: true, maintainState: true, @@ -2095,14 +2095,14 @@ final HeroFlightShuttleBuilder _navBarHeroFlightShuttleBuilder = ( switch (flightDirection) { case HeroFlightDirection.push: - return new _NavigationBarTransition( + return _NavigationBarTransition( animation: animation, bottomNavBar: fromNavBar, topNavBar: toNavBar, ); break; case HeroFlightDirection.pop: - return new _NavigationBarTransition( + return _NavigationBarTransition( animation: animation, bottomNavBar: toNavBar, topNavBar: fromNavBar, diff --git a/packages/flutter/lib/src/cupertino/page_scaffold.dart b/packages/flutter/lib/src/cupertino/page_scaffold.dart index 88f095a550..5086876cf1 100644 --- a/packages/flutter/lib/src/cupertino/page_scaffold.dart +++ b/packages/flutter/lib/src/cupertino/page_scaffold.dart @@ -82,19 +82,19 @@ class CupertinoPageScaffold extends StatelessWidget { // down. If translucent, let main content draw behind navigation bar but hint the // obstructed area. if (navigationBar.fullObstruction) { - paddedContent = new Padding( - padding: new EdgeInsets.only(top: topPadding, bottom: bottomPadding), + paddedContent = Padding( + padding: EdgeInsets.only(top: topPadding, bottom: bottomPadding), child: child, ); } else { - paddedContent = new MediaQuery( + paddedContent = MediaQuery( data: existingMediaQuery.copyWith( padding: existingMediaQuery.padding.copyWith( top: topPadding, ), ), - child: new Padding( - padding: new EdgeInsets.only(bottom: bottomPadding), + child: Padding( + padding: EdgeInsets.only(bottom: bottomPadding), child: child, ), ); @@ -105,7 +105,7 @@ class CupertinoPageScaffold extends StatelessWidget { stacked.add(paddedContent); if (navigationBar != null) { - stacked.add(new Positioned( + stacked.add(Positioned( top: 0.0, left: 0.0, right: 0.0, @@ -113,9 +113,9 @@ class CupertinoPageScaffold extends StatelessWidget { )); } - return new DecoratedBox( - decoration: new BoxDecoration(color: backgroundColor), - child: new Stack( + return DecoratedBox( + decoration: BoxDecoration(color: backgroundColor), + child: Stack( children: stacked, ), ); diff --git a/packages/flutter/lib/src/cupertino/picker.dart b/packages/flutter/lib/src/cupertino/picker.dart index 3d1f39ab22..0b42bb3098 100644 --- a/packages/flutter/lib/src/cupertino/picker.dart +++ b/packages/flutter/lib/src/cupertino/picker.dart @@ -62,8 +62,8 @@ class CupertinoPicker extends StatefulWidget { assert(itemExtent != null), assert(itemExtent > 0), childDelegate = looping - ? new ListWheelChildLoopingListDelegate(children: children) - : new ListWheelChildListDelegate(children: children), + ? ListWheelChildLoopingListDelegate(children: children) + : ListWheelChildListDelegate(children: children), super(key: key); /// Creates a picker from an [IndexedWidgetBuilder] callback where the builder @@ -101,7 +101,7 @@ class CupertinoPicker extends StatefulWidget { assert(magnification > 0), assert(itemExtent != null), assert(itemExtent > 0), - childDelegate = new ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount), + childDelegate = ListWheelChildBuilderDelegate(builder: itemBuilder, childCount: childCount), super(key: key); /// Relative ratio between this picker's height and the simulated cylinder's diameter. @@ -154,7 +154,7 @@ class CupertinoPicker extends StatefulWidget { final ListWheelChildDelegate childDelegate; @override - State createState() => new _CupertinoPickerState(); + State createState() => _CupertinoPickerState(); } class _CupertinoPickerState extends State { @@ -176,9 +176,9 @@ class _CupertinoPickerState extends State { /// Makes the fade to white edge gradients. Widget _buildGradientScreen() { - return new Positioned.fill( - child: new IgnorePointer( - child: new Container( + return Positioned.fill( + child: IgnorePointer( + child: Container( decoration: const BoxDecoration( gradient: LinearGradient( colors: [ @@ -210,27 +210,27 @@ class _CupertinoPickerState extends State { (widget.backgroundColor.alpha * _kForegroundScreenOpacityFraction).toInt() ); - return new IgnorePointer( - child: new Column( + return IgnorePointer( + child: Column( children: [ - new Expanded( - child: new Container( + Expanded( + child: Container( color: foreground, ), ), - new Container( + Container( decoration: const BoxDecoration( border: Border( top: BorderSide(width: 0.0, color: _kHighlighterBorder), bottom: BorderSide(width: 0.0, color: _kHighlighterBorder), ) ), - constraints: new BoxConstraints.expand( + constraints: BoxConstraints.expand( height: widget.itemExtent * widget.magnification, ), ), - new Expanded( - child: new Container( + Expanded( + child: Container( color: foreground, ), ), @@ -241,10 +241,10 @@ class _CupertinoPickerState extends State { @override Widget build(BuildContext context) { - Widget result = new Stack( + Widget result = Stack( children: [ - new Positioned.fill( - child: new ListWheelScrollView.useDelegate( + Positioned.fill( + child: ListWheelScrollView.useDelegate( controller: widget.scrollController, physics: const FixedExtentScrollPhysics(), diameterRatio: widget.diameterRatio, @@ -261,8 +261,8 @@ class _CupertinoPickerState extends State { ], ); if (widget.backgroundColor != null) { - result = new DecoratedBox( - decoration: new BoxDecoration( + result = DecoratedBox( + decoration: BoxDecoration( color: widget.backgroundColor, ), child: result, diff --git a/packages/flutter/lib/src/cupertino/refresh.dart b/packages/flutter/lib/src/cupertino/refresh.dart index 5ef44efd7b..6f53e3a100 100644 --- a/packages/flutter/lib/src/cupertino/refresh.dart +++ b/packages/flutter/lib/src/cupertino/refresh.dart @@ -34,7 +34,7 @@ class _CupertinoSliverRefresh extends SingleChildRenderObjectWidget { @override _RenderCupertinoSliverRefresh createRenderObject(BuildContext context) { - return new _RenderCupertinoSliverRefresh( + return _RenderCupertinoSliverRefresh( refreshIndicatorExtent: refreshIndicatorLayoutExtent, hasLayoutExtent: hasLayoutExtent, ); @@ -113,7 +113,7 @@ class _RenderCupertinoSliverRefresh extends RenderSliver // layoutExtent will take that value (on the next performLayout run). Shift // the scroll offset first so it doesn't make the scroll position suddenly jump. if (layoutExtent != layoutExtentOffsetCompensation) { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollOffsetCorrection: layoutExtent - layoutExtentOffsetCompensation, ); layoutExtentOffsetCompensation = layoutExtent; @@ -140,7 +140,7 @@ class _RenderCupertinoSliverRefresh extends RenderSliver parentUsesSize: true, ); if (active) { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: layoutExtent, paintOrigin: -overscrolledExtent - constraints.scrollOffset, paintExtent: max( @@ -359,12 +359,12 @@ class CupertinoSliverRefreshControl extends StatefulWidget { double refreshIndicatorExtent, ) { const Curve opacityCurve = Interval(0.4, 0.8, curve: Curves.easeInOut); - return new Align( + return Align( alignment: Alignment.bottomCenter, - child: new Padding( + child: Padding( padding: const EdgeInsets.only(bottom: 16.0), child: refreshState == RefreshIndicatorMode.drag - ? new Opacity( + ? Opacity( opacity: opacityCurve.transform( min(pulledExtent / refreshTriggerPullDistance, 1.0) ), @@ -374,7 +374,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget { size: 36.0, ), ) - : new Opacity( + : Opacity( opacity: opacityCurve.transform( min(pulledExtent / refreshIndicatorExtent, 1.0) ), @@ -385,7 +385,7 @@ class CupertinoSliverRefreshControl extends StatefulWidget { } @override - _CupertinoSliverRefreshControlState createState() => new _CupertinoSliverRefreshControlState(); + _CupertinoSliverRefreshControlState createState() => _CupertinoSliverRefreshControlState(); } class _CupertinoSliverRefreshControlState extends State { @@ -510,12 +510,12 @@ class _CupertinoSliverRefreshControlState extends State _kRightMiddleTween = new Tween( +final Tween _kRightMiddleTween = Tween( begin: const Offset(1.0, 0.0), end: Offset.zero, ); // Offset from fully on screen to 1/3 offscreen to the left. -final Tween _kMiddleLeftTween = new Tween( +final Tween _kMiddleLeftTween = Tween( begin: Offset.zero, end: const Offset(-1.0/3.0, 0.0), ); // Offset from offscreen below to fully on screen. -final Tween _kBottomUpTween = new Tween( +final Tween _kBottomUpTween = Tween( begin: const Offset(0.0, 1.0), end: Offset.zero, ); // Custom decoration from no shadow to page shadow mimicking iOS page // transitions using gradients. -final DecorationTween _kGradientShadowTween = new DecorationTween( +final DecorationTween _kGradientShadowTween = DecorationTween( begin: _CupertinoEdgeShadowDecoration.none, // No decoration initially. end: const _CupertinoEdgeShadowDecoration( edgeGradient: LinearGradient( @@ -141,7 +141,7 @@ class CupertinoPageRoute extends PageRoute { ? previousRoute.title : null; if (_previousTitle == null) { - _previousTitle = new ValueNotifier(previousTitleString); + _previousTitle = ValueNotifier(previousTitleString); } else { _previousTitle.value = previousTitleString; } @@ -186,7 +186,7 @@ class CupertinoPageRoute extends PageRoute { assert(() { if (hostRoute == null) return true; - throw new FlutterError( + throw FlutterError( 'Cannot install a subsidiary route (one with a hostRoute).\n' 'This route ($this) cannot be installed, because it has a host route ($hostRoute).' ); @@ -273,7 +273,7 @@ class CupertinoPageRoute extends PageRoute { assert(!popGestureInProgress); assert(popGestureEnabled); final PageRoute route = hostRoute ?? this; - _backGestureController = new _CupertinoBackGestureController( + _backGestureController = _CupertinoBackGestureController( navigator: route.navigator, controller: route.controller, onEnded: _endPopGesture, @@ -290,14 +290,14 @@ class CupertinoPageRoute extends PageRoute { @override Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { - final Widget result = new Semantics( + final Widget result = Semantics( scopesRoute: true, explicitChildNodes: true, child: builder(context), ); assert(() { if (result == null) { - throw new FlutterError( + throw FlutterError( 'The builder for route "${settings.name}" returned null.\n' 'Route builders must never return null.' ); @@ -310,18 +310,18 @@ class CupertinoPageRoute extends PageRoute { @override Widget buildTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { if (fullscreenDialog) { - return new CupertinoFullscreenDialogTransition( + return CupertinoFullscreenDialogTransition( animation: animation, child: child, ); } else { - return new CupertinoPageTransition( + return CupertinoPageTransition( primaryRouteAnimation: animation, secondaryRouteAnimation: secondaryAnimation, // In the middle of a back gesture drag, let the transition be linear to // match finger motions. linearTransition: popGestureInProgress, - child: new _CupertinoBackGestureDetector( + child: _CupertinoBackGestureDetector( enabledCallback: () => popGestureEnabled, onStartPopGesture: _startPopGesture, child: child, @@ -357,21 +357,21 @@ class CupertinoPageTransition extends StatelessWidget { _primaryPositionAnimation = linearTransition ? _kRightMiddleTween.animate(primaryRouteAnimation) : _kRightMiddleTween.animate( - new CurvedAnimation( + CurvedAnimation( parent: primaryRouteAnimation, curve: Curves.easeOut, reverseCurve: Curves.easeIn, ) ), _secondaryPositionAnimation = _kMiddleLeftTween.animate( - new CurvedAnimation( + CurvedAnimation( parent: secondaryRouteAnimation, curve: Curves.easeOut, reverseCurve: Curves.easeIn, ) ), _primaryShadowAnimation = _kGradientShadowTween.animate( - new CurvedAnimation( + CurvedAnimation( parent: primaryRouteAnimation, curve: Curves.easeOut, ) @@ -393,13 +393,13 @@ class CupertinoPageTransition extends StatelessWidget { final TextDirection textDirection = Directionality.of(context); // TODO(ianh): tell the transform to be un-transformed for hit testing // but not while being controlled by a gesture. - return new SlideTransition( + return SlideTransition( position: _secondaryPositionAnimation, textDirection: textDirection, - child: new SlideTransition( + child: SlideTransition( position: _primaryPositionAnimation, textDirection: textDirection, - child: new DecoratedBoxTransition( + child: DecoratedBoxTransition( decoration: _primaryShadowAnimation, child: child, ), @@ -419,7 +419,7 @@ class CupertinoFullscreenDialogTransition extends StatelessWidget { @required Animation animation, @required this.child, }) : _positionAnimation = _kBottomUpTween.animate( - new CurvedAnimation( + CurvedAnimation( parent: animation, curve: Curves.easeInOut, ) @@ -433,7 +433,7 @@ class CupertinoFullscreenDialogTransition extends StatelessWidget { @override Widget build(BuildContext context) { - return new SlideTransition( + return SlideTransition( position: _positionAnimation, child: child, ); @@ -469,7 +469,7 @@ class _CupertinoBackGestureDetector extends StatefulWidget { final ValueGetter<_CupertinoBackGestureController> onStartPopGesture; @override - _CupertinoBackGestureDetectorState createState() => new _CupertinoBackGestureDetectorState(); + _CupertinoBackGestureDetectorState createState() => _CupertinoBackGestureDetectorState(); } class _CupertinoBackGestureDetectorState extends State<_CupertinoBackGestureDetector> { @@ -480,7 +480,7 @@ class _CupertinoBackGestureDetectorState extends State<_CupertinoBackGestureD @override void initState() { super.initState(); - _recognizer = new HorizontalDragGestureRecognizer(debugOwner: this) + _recognizer = HorizontalDragGestureRecognizer(debugOwner: this) ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd @@ -538,16 +538,16 @@ class _CupertinoBackGestureDetectorState extends State<_CupertinoBackGestureD @override Widget build(BuildContext context) { assert(debugCheckHasDirectionality(context)); - return new Stack( + return Stack( fit: StackFit.passthrough, children: [ widget.child, - new PositionedDirectional( + PositionedDirectional( start: 0.0, width: _kBackGestureWidth, top: 0.0, bottom: 0.0, - child: new Listener( + child: Listener( onPointerDown: _handlePointerDown, behavior: HitTestBehavior.translucent, ), @@ -685,7 +685,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration { assert(t != null); if (a == null && b == null) return null; - return new _CupertinoEdgeShadowDecoration( + return _CupertinoEdgeShadowDecoration( edgeGradient: LinearGradient.lerp(a?.edgeGradient, b?.edgeGradient, t), ); } @@ -706,7 +706,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration { @override _CupertinoEdgeShadowPainter createBoxPainter([VoidCallback onChanged]) { - return new _CupertinoEdgeShadowPainter(this, onChanged); + return _CupertinoEdgeShadowPainter(this, onChanged); } @override @@ -723,7 +723,7 @@ class _CupertinoEdgeShadowDecoration extends Decoration { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('edgeGradient', edgeGradient)); + properties.add(DiagnosticsProperty('edgeGradient', edgeGradient)); } } @@ -756,7 +756,7 @@ class _CupertinoEdgeShadowPainter extends BoxPainter { break; } final Rect rect = (offset & configuration.size).translate(deltaX, 0.0); - final Paint paint = new Paint() + final Paint paint = Paint() ..shader = gradient.createShader(rect, textDirection: textDirection); canvas.drawRect(rect, paint); @@ -794,12 +794,12 @@ class _CupertinoModalPopupRoute extends PopupRoute { @override Animation createAnimation() { assert(_animation == null); - _animation = new CurvedAnimation( + _animation = CurvedAnimation( parent: super.createAnimation(), curve: Curves.ease, reverseCurve: Curves.ease.flipped, ); - _offsetTween = new Tween( + _offsetTween = Tween( begin: const Offset(0.0, 1.0), end: const Offset(0.0, 0.0), ); @@ -813,9 +813,9 @@ class _CupertinoModalPopupRoute extends PopupRoute { @override Widget buildTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { - return new Align( + return Align( alignment: Alignment.bottomCenter, - child: new FractionalTranslation( + child: FractionalTranslation( translation: _offsetTween.evaluate(_animation), child: child, ), @@ -852,7 +852,7 @@ Future showCupertinoModalPopup({ @required WidgetBuilder builder, }) { return Navigator.of(context, rootNavigator: true).push( - new _CupertinoModalPopupRoute( + _CupertinoModalPopupRoute( builder: builder, barrierLabel: 'Dismiss', ), @@ -860,25 +860,25 @@ Future showCupertinoModalPopup({ } Widget _buildCupertinoDialogTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { - final CurvedAnimation fadeAnimation = new CurvedAnimation( + final CurvedAnimation fadeAnimation = CurvedAnimation( parent: animation, curve: Curves.easeInOut, ); if (animation.status == AnimationStatus.reverse) { - return new FadeTransition( + return FadeTransition( opacity: fadeAnimation, child: child, ); } - return new FadeTransition( + return FadeTransition( opacity: fadeAnimation, child: ScaleTransition( child: child, - scale: new Tween( + scale: Tween( begin: 1.2, end: 1.0, ).animate( - new CurvedAnimation( + CurvedAnimation( parent: animation, curve: Curves.fastOutSlowIn, ), diff --git a/packages/flutter/lib/src/cupertino/scrollbar.dart b/packages/flutter/lib/src/cupertino/scrollbar.dart index 6ed79ddbda..90173d8636 100644 --- a/packages/flutter/lib/src/cupertino/scrollbar.dart +++ b/packages/flutter/lib/src/cupertino/scrollbar.dart @@ -48,7 +48,7 @@ class CupertinoScrollbar extends StatefulWidget { final Widget child; @override - _CupertinoScrollbarState createState() => new _CupertinoScrollbarState(); + _CupertinoScrollbarState createState() => _CupertinoScrollbarState(); } class _CupertinoScrollbarState extends State with TickerProviderStateMixin { @@ -62,11 +62,11 @@ class _CupertinoScrollbarState extends State with TickerProv @override void initState() { super.initState(); - _fadeoutAnimationController = new AnimationController( + _fadeoutAnimationController = AnimationController( vsync: this, duration: _kScrollbarFadeDuration, ); - _fadeoutOpacityAnimation = new CurvedAnimation( + _fadeoutOpacityAnimation = CurvedAnimation( parent: _fadeoutAnimationController, curve: Curves.fastOutSlowIn ); @@ -81,7 +81,7 @@ class _CupertinoScrollbarState extends State with TickerProv /// Returns a [ScrollbarPainter] visually styled like the iOS scrollbar. ScrollbarPainter _buildCupertinoScrollbarPainter() { - return new ScrollbarPainter( + return ScrollbarPainter( color: _kScrollbarColor, textDirection: _textDirection, thickness: _kScrollbarThickness, @@ -108,7 +108,7 @@ class _CupertinoScrollbarState extends State with TickerProv // On iOS, the scrollbar can only go away once the user lifted the finger. _fadeoutTimer?.cancel(); - _fadeoutTimer = new Timer(_kScrollbarTimeToFade, () { + _fadeoutTimer = Timer(_kScrollbarTimeToFade, () { _fadeoutAnimationController.reverse(); _fadeoutTimer = null; }); @@ -126,12 +126,12 @@ class _CupertinoScrollbarState extends State with TickerProv @override Widget build(BuildContext context) { - return new NotificationListener( + return NotificationListener( onNotification: _handleScrollNotification, - child: new RepaintBoundary( - child: new CustomPaint( + child: RepaintBoundary( + child: CustomPaint( foregroundPainter: _painter, - child: new RepaintBoundary( + child: RepaintBoundary( child: widget.child, ), ), diff --git a/packages/flutter/lib/src/cupertino/segmented_control.dart b/packages/flutter/lib/src/cupertino/segmented_control.dart index 7b9a880d15..1a25579b55 100644 --- a/packages/flutter/lib/src/cupertino/segmented_control.dart +++ b/packages/flutter/lib/src/cupertino/segmented_control.dart @@ -212,15 +212,15 @@ class _SegmentedControlState extends State> @override void initState() { super.initState(); - _forwardBackgroundColorTween = new ColorTween( + _forwardBackgroundColorTween = ColorTween( begin: widget.pressedColor, end: widget.selectedColor, ); - _reverseBackgroundColorTween = new ColorTween( + _reverseBackgroundColorTween = ColorTween( begin: widget.unselectedColor, end: widget.selectedColor, ); - _textColorTween = new ColorTween( + _textColorTween = ColorTween( begin: widget.selectedColor, end: widget.unselectedColor, ); @@ -238,7 +238,7 @@ class _SegmentedControlState extends State> } AnimationController createAnimationController() { - return new AnimationController( + return AnimationController( duration: _kFadeDuration, vsync: this, )..addListener(() { @@ -344,15 +344,15 @@ class _SegmentedControlState extends State> final TextStyle textStyle = DefaultTextStyle.of(context).style.copyWith( color: getTextColor(index, currentKey), ); - final IconThemeData iconTheme = new IconThemeData( + final IconThemeData iconTheme = IconThemeData( color: getTextColor(index, currentKey), ); - Widget child = new Center( + Widget child = Center( child: widget.children[currentKey], ); - child = new GestureDetector( + child = GestureDetector( onTapDown: (TapDownDetails event) { _onTapDown(currentKey); }, @@ -360,11 +360,11 @@ class _SegmentedControlState extends State> onTap: () { _onTap(currentKey); }, - child: new IconTheme( + child: IconTheme( data: iconTheme, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: textStyle, - child: new Semantics( + child: Semantics( button: true, inMutuallyExclusiveGroup: true, selected: widget.groupValue == currentKey, @@ -379,7 +379,7 @@ class _SegmentedControlState extends State> index += 1; } - final Widget box = new _SegmentedControlRenderWidget( + final Widget box = _SegmentedControlRenderWidget( children: _gestureChildren, selectedIndex: selectedIndex, pressedIndex: pressedIndex, @@ -387,9 +387,9 @@ class _SegmentedControlState extends State> borderColor: widget.borderColor, ); - return new Padding( + return Padding( padding: _kHorizontalItemPadding.resolve(Directionality.of(context)), - child: new UnconstrainedBox( + child: UnconstrainedBox( constrainedAxis: Axis.horizontal, child: box, ), @@ -417,7 +417,7 @@ class _SegmentedControlRenderWidget extends MultiChildRenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderSegmentedControl( + return _RenderSegmentedControl( textDirection: Directionality.of(context), selectedIndex: selectedIndex, pressedIndex: pressedIndex, @@ -572,7 +572,7 @@ class _RenderSegmentedControl extends RenderBox @override void setupParentData(RenderBox child) { if (child.parentData is! _SegmentedControlContainerBoxParentData) { - child.parentData = new _SegmentedControlContainerBoxParentData(); + child.parentData = _SegmentedControlContainerBoxParentData(); } } @@ -581,18 +581,18 @@ class _RenderSegmentedControl extends RenderBox double start = 0.0; while (child != null) { final _SegmentedControlContainerBoxParentData childParentData = child.parentData; - final Offset childOffset = new Offset(start, 0.0); + final Offset childOffset = Offset(start, 0.0); childParentData.offset = childOffset; - final Rect childRect = new Rect.fromLTWH(start, 0.0, child.size.width, child.size.height); + final Rect childRect = Rect.fromLTWH(start, 0.0, child.size.width, child.size.height); RRect rChildRect; if (child == leftChild) { - rChildRect = new RRect.fromRectAndCorners(childRect, topLeft: const Radius.circular(3.0), + rChildRect = RRect.fromRectAndCorners(childRect, topLeft: const Radius.circular(3.0), bottomLeft: const Radius.circular(3.0)); } else if (child == rightChild) { - rChildRect = new RRect.fromRectAndCorners(childRect, topRight: const Radius.circular(3.0), + rChildRect = RRect.fromRectAndCorners(childRect, topRight: const Radius.circular(3.0), bottomRight: const Radius.circular(3.0)); } else { - rChildRect = new RRect.fromRectAndCorners(childRect); + rChildRect = RRect.fromRectAndCorners(childRect); } childParentData.surroundingRect = rChildRect; start += child.size.width; @@ -619,7 +619,7 @@ class _RenderSegmentedControl extends RenderBox constraints.constrainHeight(maxHeight); - final BoxConstraints childConstraints = new BoxConstraints.tightFor( + final BoxConstraints childConstraints = BoxConstraints.tightFor( width: childWidth, height: maxHeight, ); @@ -647,7 +647,7 @@ class _RenderSegmentedControl extends RenderBox break; } - size = constraints.constrain(new Size(childWidth * childCount, maxHeight)); + size = constraints.constrain(Size(childWidth * childCount, maxHeight)); } @override @@ -668,13 +668,13 @@ class _RenderSegmentedControl extends RenderBox context.canvas.drawRRect( childParentData.surroundingRect.shift(offset), - new Paint() + Paint() ..color = backgroundColors[childIndex] ..style = PaintingStyle.fill, ); context.canvas.drawRRect( childParentData.surroundingRect.shift(offset), - new Paint() + Paint() ..color = borderColor ..strokeWidth = 1.0 ..style = PaintingStyle.stroke, diff --git a/packages/flutter/lib/src/cupertino/slider.dart b/packages/flutter/lib/src/cupertino/slider.dart index 62b54f88ef..892111fe76 100644 --- a/packages/flutter/lib/src/cupertino/slider.dart +++ b/packages/flutter/lib/src/cupertino/slider.dart @@ -190,14 +190,14 @@ class CupertinoSlider extends StatefulWidget { final Color activeColor; @override - _CupertinoSliderState createState() => new _CupertinoSliderState(); + _CupertinoSliderState createState() => _CupertinoSliderState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('value', value)); - properties.add(new DoubleProperty('min', min)); - properties.add(new DoubleProperty('max', max)); + properties.add(DoubleProperty('value', value)); + properties.add(DoubleProperty('min', min)); + properties.add(DoubleProperty('max', max)); } } @@ -222,7 +222,7 @@ class _CupertinoSliderState extends State with TickerProviderSt @override Widget build(BuildContext context) { - return new _CupertinoSliderRenderObjectWidget( + return _CupertinoSliderRenderObjectWidget( value: (widget.value - widget.min) / (widget.max - widget.min), divisions: widget.divisions, activeColor: widget.activeColor ?? CupertinoColors.activeBlue, @@ -256,7 +256,7 @@ class _CupertinoSliderRenderObjectWidget extends LeafRenderObjectWidget { @override _RenderCupertinoSlider createRenderObject(BuildContext context) { - return new _RenderCupertinoSlider( + return _RenderCupertinoSlider( value: value, divisions: divisions, activeColor: activeColor, @@ -309,11 +309,11 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { _onChanged = onChanged, _textDirection = textDirection, super(additionalConstraints: const BoxConstraints.tightFor(width: _kSliderWidth, height: _kSliderHeight)) { - _drag = new HorizontalDragGestureRecognizer() + _drag = HorizontalDragGestureRecognizer() ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd; - _position = new AnimationController( + _position = AnimationController( value: value, duration: _kDiscreteTransitionDuration, vsync: vsync, @@ -454,7 +454,7 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { _drag.addPointer(event); } - final CupertinoThumbPainter _thumbPainter = new CupertinoThumbPainter(); + final CupertinoThumbPainter _thumbPainter = CupertinoThumbPainter(); @override void paint(PaintingContext context, Offset offset) { @@ -482,20 +482,20 @@ class _RenderCupertinoSlider extends RenderConstrainedBox { final double trackActive = offset.dx + _thumbCenter; final Canvas canvas = context.canvas; - final Paint paint = new Paint(); + final Paint paint = Paint(); if (visualPosition > 0.0) { paint.color = rightColor; - canvas.drawRRect(new RRect.fromLTRBXY(trackLeft, trackTop, trackActive, trackBottom, 1.0, 1.0), paint); + canvas.drawRRect(RRect.fromLTRBXY(trackLeft, trackTop, trackActive, trackBottom, 1.0, 1.0), paint); } if (visualPosition < 1.0) { paint.color = leftColor; - canvas.drawRRect(new RRect.fromLTRBXY(trackActive, trackTop, trackRight, trackBottom, 1.0, 1.0), paint); + canvas.drawRRect(RRect.fromLTRBXY(trackActive, trackTop, trackRight, trackBottom, 1.0, 1.0), paint); } - final Offset thumbCenter = new Offset(trackActive, trackCenter); - _thumbPainter.paint(canvas, new Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius)); + final Offset thumbCenter = Offset(trackActive, trackCenter); + _thumbPainter.paint(canvas, Rect.fromCircle(center: thumbCenter, radius: CupertinoThumbPainter.radius)); } @override diff --git a/packages/flutter/lib/src/cupertino/switch.dart b/packages/flutter/lib/src/cupertino/switch.dart index 69cc68c96a..dffa483d23 100644 --- a/packages/flutter/lib/src/cupertino/switch.dart +++ b/packages/flutter/lib/src/cupertino/switch.dart @@ -87,20 +87,20 @@ class CupertinoSwitch extends StatefulWidget { final Color activeColor; @override - _CupertinoSwitchState createState() => new _CupertinoSwitchState(); + _CupertinoSwitchState createState() => _CupertinoSwitchState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('value', value: value, ifTrue: 'on', ifFalse: 'off', showName: true)); - properties.add(new ObjectFlagProperty>('onChanged', onChanged, ifNull: 'disabled')); + properties.add(FlagProperty('value', value: value, ifTrue: 'on', ifFalse: 'off', showName: true)); + properties.add(ObjectFlagProperty>('onChanged', onChanged, ifNull: 'disabled')); } } class _CupertinoSwitchState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - return new _CupertinoSwitchRenderObjectWidget( + return _CupertinoSwitchRenderObjectWidget( value: widget.value, activeColor: widget.activeColor ?? CupertinoColors.activeGreen, onChanged: widget.onChanged, @@ -125,7 +125,7 @@ class _CupertinoSwitchRenderObjectWidget extends LeafRenderObjectWidget { @override _RenderCupertinoSwitch createRenderObject(BuildContext context) { - return new _RenderCupertinoSwitch( + return _RenderCupertinoSwitch( value: value, activeColor: activeColor, onChanged: onChanged, @@ -174,30 +174,30 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { _textDirection = textDirection, _vsync = vsync, super(additionalConstraints: const BoxConstraints.tightFor(width: _kSwitchWidth, height: _kSwitchHeight)) { - _tap = new TapGestureRecognizer() + _tap = TapGestureRecognizer() ..onTapDown = _handleTapDown ..onTap = _handleTap ..onTapUp = _handleTapUp ..onTapCancel = _handleTapCancel; - _drag = new HorizontalDragGestureRecognizer() + _drag = HorizontalDragGestureRecognizer() ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd; - _positionController = new AnimationController( + _positionController = AnimationController( duration: _kToggleDuration, value: value ? 1.0 : 0.0, vsync: vsync, ); - _position = new CurvedAnimation( + _position = CurvedAnimation( parent: _positionController, curve: Curves.linear, )..addListener(markNeedsPaint) ..addStatusListener(_handlePositionStateChanged); - _reactionController = new AnimationController( + _reactionController = AnimationController( duration: _kReactionDuration, vsync: vsync, ); - _reaction = new CurvedAnimation( + _reaction = CurvedAnimation( parent: _reactionController, curve: Curves.ease, )..addListener(markNeedsPaint); @@ -387,7 +387,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { config.isToggled = _value; } - final CupertinoThumbPainter _thumbPainter = new CupertinoThumbPainter(); + final CupertinoThumbPainter _thumbPainter = CupertinoThumbPainter(); @override void paint(PaintingContext context, Offset offset) { @@ -409,17 +409,17 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { final Color trackColor = _value ? activeColor : _kTrackColor; final double borderThickness = 1.5 + (_kTrackRadius - 1.5) * math.max(currentReactionValue, currentValue); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = trackColor; - final Rect trackRect = new Rect.fromLTWH( + final Rect trackRect = Rect.fromLTWH( offset.dx + (size.width - _kTrackWidth) / 2.0, offset.dy + (size.height - _kTrackHeight) / 2.0, _kTrackWidth, _kTrackHeight ); - final RRect outerRRect = new RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius)); - final RRect innerRRect = new RRect.fromRectAndRadius(trackRect.deflate(borderThickness), const Radius.circular(_kTrackRadius)); + final RRect outerRRect = RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius)); + final RRect innerRRect = RRect.fromRectAndRadius(trackRect.deflate(borderThickness), const Radius.circular(_kTrackRadius)); canvas.drawDRRect(outerRRect, innerRRect, paint); final double currentThumbExtension = CupertinoThumbPainter.extension * currentReactionValue; @@ -435,7 +435,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { ); final double thumbCenterY = offset.dy + size.height / 2.0; - _thumbPainter.paint(canvas, new Rect.fromLTRB( + _thumbPainter.paint(canvas, Rect.fromLTRB( thumbLeft, thumbCenterY - CupertinoThumbPainter.radius, thumbRight, @@ -446,7 +446,7 @@ class _RenderCupertinoSwitch extends RenderConstrainedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new FlagProperty('value', value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true)); - description.add(new FlagProperty('isInteractive', value: isInteractive, ifTrue: 'enabled', ifFalse: 'disabled', showName: true, defaultValue: true)); + description.add(FlagProperty('value', value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true)); + description.add(FlagProperty('isInteractive', value: isInteractive, ifTrue: 'enabled', ifFalse: 'disabled', showName: true, defaultValue: true)); } } diff --git a/packages/flutter/lib/src/cupertino/tab_scaffold.dart b/packages/flutter/lib/src/cupertino/tab_scaffold.dart index 7f80de0398..dcc36ce8a5 100644 --- a/packages/flutter/lib/src/cupertino/tab_scaffold.dart +++ b/packages/flutter/lib/src/cupertino/tab_scaffold.dart @@ -137,7 +137,7 @@ class CupertinoTabScaffold extends StatefulWidget { final IndexedWidgetBuilder tabBuilder; @override - _CupertinoTabScaffoldState createState() => new _CupertinoTabScaffoldState(); + _CupertinoTabScaffoldState createState() => _CupertinoTabScaffoldState(); } class _CupertinoTabScaffoldState extends State { @@ -161,7 +161,7 @@ class _CupertinoTabScaffoldState extends State { Widget build(BuildContext context) { final List stacked = []; - Widget content = new _TabSwitchingView( + Widget content = _TabSwitchingView( currentTabIndex: _currentPage, tabNumber: widget.tabBar.items.length, tabBuilder: widget.tabBuilder, @@ -179,12 +179,12 @@ class _CupertinoTabScaffoldState extends State { // translucent, let main content draw behind the tab bar but hint the // obstructed area. if (widget.tabBar.opaque) { - content = new Padding( - padding: new EdgeInsets.only(bottom: bottomPadding), + content = Padding( + padding: EdgeInsets.only(bottom: bottomPadding), child: content, ); } else { - content = new MediaQuery( + content = MediaQuery( data: existingMediaQuery.copyWith( padding: existingMediaQuery.padding.copyWith( bottom: bottomPadding, @@ -199,7 +199,7 @@ class _CupertinoTabScaffoldState extends State { stacked.add(content); if (widget.tabBar != null) { - stacked.add(new Align( + stacked.add(Align( alignment: Alignment.bottomCenter, // Override the tab bar's currentIndex to the current tab and hook in // our own listener to update the _currentPage on top of a possibly user @@ -218,7 +218,7 @@ class _CupertinoTabScaffoldState extends State { )); } - return new Stack( + return Stack( children: stacked, ); } @@ -240,7 +240,7 @@ class _TabSwitchingView extends StatefulWidget { final IndexedWidgetBuilder tabBuilder; @override - _TabSwitchingViewState createState() => new _TabSwitchingViewState(); + _TabSwitchingViewState createState() => _TabSwitchingViewState(); } class _TabSwitchingViewState extends State<_TabSwitchingView> { @@ -250,10 +250,10 @@ class _TabSwitchingViewState extends State<_TabSwitchingView> { @override void initState() { super.initState(); - tabs = new List(widget.tabNumber); - tabFocusNodes = new List.generate( + tabs = List(widget.tabNumber); + tabFocusNodes = List.generate( widget.tabNumber, - (int index) => new FocusScopeNode(), + (int index) => FocusScopeNode(), ); } @@ -283,22 +283,22 @@ class _TabSwitchingViewState extends State<_TabSwitchingView> { @override Widget build(BuildContext context) { - return new Stack( + return Stack( fit: StackFit.expand, - children: new List.generate(widget.tabNumber, (int index) { + children: List.generate(widget.tabNumber, (int index) { final bool active = index == widget.currentTabIndex; if (active || tabs[index] != null) { tabs[index] = widget.tabBuilder(context, index); } - return new Offstage( + return Offstage( offstage: !active, - child: new TickerMode( + child: TickerMode( enabled: active, - child: new FocusScope( + child: FocusScope( node: tabFocusNodes[index], - child: tabs[index] ?? new Container(), + child: tabs[index] ?? Container(), ), ), ); diff --git a/packages/flutter/lib/src/cupertino/tab_view.dart b/packages/flutter/lib/src/cupertino/tab_view.dart index 81a3d17e56..d27a86cd9c 100644 --- a/packages/flutter/lib/src/cupertino/tab_view.dart +++ b/packages/flutter/lib/src/cupertino/tab_view.dart @@ -103,7 +103,7 @@ class CupertinoTabView extends StatefulWidget { @override _CupertinoTabViewState createState() { - return new _CupertinoTabViewState(); + return _CupertinoTabViewState(); } } @@ -114,7 +114,7 @@ class _CupertinoTabViewState extends State { @override void initState() { super.initState(); - _heroController = new HeroController(); // Linear tweening. + _heroController = HeroController(); // Linear tweening. _updateObservers(); } @@ -126,13 +126,13 @@ class _CupertinoTabViewState extends State { void _updateObservers() { _navigatorObservers = - new List.from(widget.navigatorObservers) + List.from(widget.navigatorObservers) ..add(_heroController); } @override Widget build(BuildContext context) { - return new Navigator( + return Navigator( onGenerateRoute: _onGenerateRoute, onUnknownRoute: _onUnknownRoute, observers: _navigatorObservers, @@ -150,7 +150,7 @@ class _CupertinoTabViewState extends State { else if (widget.routes != null) routeBuilder = widget.routes[name]; if (routeBuilder != null) { - return new CupertinoPageRoute( + return CupertinoPageRoute( builder: routeBuilder, title: title, settings: settings, @@ -164,7 +164,7 @@ class _CupertinoTabViewState extends State { Route _onUnknownRoute(RouteSettings settings) { assert(() { if (widget.onUnknownRoute == null) { - throw new FlutterError( + throw FlutterError( 'Could not find a generator for route $settings in the $runtimeType.\n' 'Generators for routes are searched for in the following order:\n' ' 1. For the "/" route, the "builder" property, if non-null, is used.\n' @@ -181,7 +181,7 @@ class _CupertinoTabViewState extends State { final Route result = widget.onUnknownRoute(settings); assert(() { if (result == null) { - throw new FlutterError( + throw FlutterError( 'The onUnknownRoute callback returned null.\n' 'When the $runtimeType requested the route $settings from its ' 'onUnknownRoute callback, the callback returned null. Such callbacks ' diff --git a/packages/flutter/lib/src/cupertino/text_selection.dart b/packages/flutter/lib/src/cupertino/text_selection.dart index ef89a623e0..cc0b6a6976 100644 --- a/packages/flutter/lib/src/cupertino/text_selection.dart +++ b/packages/flutter/lib/src/cupertino/text_selection.dart @@ -39,10 +39,10 @@ const TextStyle _kToolbarButtonFontStyle = TextStyle( class _TextSelectionToolbarNotchPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = _kToolbarBackgroundColor ..style = PaintingStyle.fill; - final Path triangle = new Path() + final Path triangle = Path() ..lineTo(_kToolbarTriangleSize.width / 2, 0.0) ..lineTo(0.0, _kToolbarTriangleSize.height) ..lineTo(-(_kToolbarTriangleSize.width / 2), 0.0) @@ -73,7 +73,7 @@ class _TextSelectionToolbar extends StatelessWidget { Widget build(BuildContext context) { final List items = []; final Widget onePhysicalPixelVerticalDivider = - new SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio); + SizedBox(width: 1.0 / MediaQuery.of(context).devicePixelRatio); if (handleCut != null) items.add(_buildToolbarButton('Cut', handleCut)); @@ -96,23 +96,23 @@ class _TextSelectionToolbar extends StatelessWidget { items.add(_buildToolbarButton('Select All', handleSelectAll)); } - final Widget triangle = new SizedBox.fromSize( + final Widget triangle = SizedBox.fromSize( size: _kToolbarTriangleSize, - child: new CustomPaint( - painter: new _TextSelectionToolbarNotchPainter(), + child: CustomPaint( + painter: _TextSelectionToolbarNotchPainter(), ) ); - return new Column( + return Column( mainAxisSize: MainAxisSize.min, children: [ - new ClipRRect( + ClipRRect( borderRadius: _kToolbarBorderRadius, - child: new DecoratedBox( + child: DecoratedBox( decoration: const BoxDecoration( color: _kToolbarDividerColor, ), - child: new Row(mainAxisSize: MainAxisSize.min, children: items), + child: Row(mainAxisSize: MainAxisSize.min, children: items), ), ), // TODO(xster): Position the triangle based on the layout delegate, and @@ -125,8 +125,8 @@ class _TextSelectionToolbar extends StatelessWidget { /// Builds a themed [CupertinoButton] for the toolbar. CupertinoButton _buildToolbarButton(String text, VoidCallback onPressed) { - return new CupertinoButton( - child: new Text(text, style: _kToolbarButtonFontStyle), + return CupertinoButton( + child: Text(text, style: _kToolbarButtonFontStyle), color: _kToolbarBackgroundColor, minSize: _kToolbarHeight, padding: _kToolbarButtonPadding, @@ -175,7 +175,7 @@ class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate { else if (y + childSize.height > screenSize.height - _kToolbarScreenPadding) y = screenSize.height - childSize.height - _kToolbarScreenPadding; - return new Offset(x, y); + return Offset(x, y); } @override @@ -198,7 +198,7 @@ class _TextSelectionHandlePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = _kHandlesColor ..strokeWidth = 2.0; // Draw circle below the origin that slightly overlaps the bar. @@ -226,15 +226,15 @@ class _CupertinoTextSelectionControls extends TextSelectionControls { @override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position, TextSelectionDelegate delegate) { assert(debugCheckHasMediaQuery(context)); - return new ConstrainedBox( - constraints: new BoxConstraints.tight(globalEditableRegion.size), - child: new CustomSingleChildLayout( - delegate: new _TextSelectionToolbarLayout( + return ConstrainedBox( + constraints: BoxConstraints.tight(globalEditableRegion.size), + child: CustomSingleChildLayout( + delegate: _TextSelectionToolbarLayout( MediaQuery.of(context).size, globalEditableRegion, position, ), - child: new _TextSelectionToolbar( + child: _TextSelectionToolbar( handleCut: canCut(delegate) ? () => handleCut(delegate) : null, handleCopy: canCopy(delegate) ? () => handleCopy(delegate) : null, handlePaste: canPaste(delegate) ? () => handlePaste(delegate) : null, @@ -249,21 +249,21 @@ class _CupertinoTextSelectionControls extends TextSelectionControls { Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textLineHeight) { // We want a size that's a vertical line the height of the text plus a 18.0 // padding in every direction that will constitute the selection drag area. - final Size desiredSize = new Size( + final Size desiredSize = Size( 2.0 * _kHandlesPadding, textLineHeight + 2.0 * _kHandlesPadding ); - final Widget handle = new SizedBox.fromSize( + final Widget handle = SizedBox.fromSize( size: desiredSize, - child: new CustomPaint( - painter: new _TextSelectionHandlePainter( + child: CustomPaint( + painter: _TextSelectionHandlePainter( // We give the painter a point of origin that's at the bottom baseline // of the selection cursor position. // // We give it in the form of an offset from the top left of the // SizedBox. - origin: new Offset(_kHandlesPadding, textLineHeight + _kHandlesPadding), + origin: Offset(_kHandlesPadding, textLineHeight + _kHandlesPadding), ), ), ); @@ -273,14 +273,14 @@ class _CupertinoTextSelectionControls extends TextSelectionControls { // on top of the text selection endpoints. switch (type) { case TextSelectionHandleType.left: // The left handle is upside down on iOS. - return new Transform( - transform: new Matrix4.rotationZ(math.pi) + return Transform( + transform: Matrix4.rotationZ(math.pi) ..translate(-_kHandlesPadding, -_kHandlesPadding), child: handle ); case TextSelectionHandleType.right: - return new Transform( - transform: new Matrix4.translationValues( + return Transform( + transform: Matrix4.translationValues( -_kHandlesPadding, -(textLineHeight + _kHandlesPadding), 0.0 @@ -288,7 +288,7 @@ class _CupertinoTextSelectionControls extends TextSelectionControls { child: handle ); case TextSelectionHandleType.collapsed: // iOS doesn't draw anything for collapsed selections. - return new Container(); + return Container(); } assert(type != null); return null; @@ -296,4 +296,4 @@ class _CupertinoTextSelectionControls extends TextSelectionControls { } /// Text selection controls that follows iOS design conventions. -final TextSelectionControls cupertinoTextSelectionControls = new _CupertinoTextSelectionControls(); +final TextSelectionControls cupertinoTextSelectionControls = _CupertinoTextSelectionControls(); diff --git a/packages/flutter/lib/src/cupertino/thumb_painter.dart b/packages/flutter/lib/src/cupertino/thumb_painter.dart index f65c7410eb..030c8ab495 100644 --- a/packages/flutter/lib/src/cupertino/thumb_painter.dart +++ b/packages/flutter/lib/src/cupertino/thumb_painter.dart @@ -14,7 +14,7 @@ class CupertinoThumbPainter { CupertinoThumbPainter({ this.color = CupertinoColors.white, this.shadowColor = const Color(0x2C000000), - }) : _shadowPaint = new BoxShadow( + }) : _shadowPaint = BoxShadow( color: shadowColor, blurRadius: 1.0, ).toPaint(); @@ -39,13 +39,13 @@ class CupertinoThumbPainter { /// Consider using [radius] and [extension] when deciding how large a /// rectangle to use for the thumb. void paint(Canvas canvas, Rect rect) { - final RRect rrect = new RRect.fromRectAndRadius( + final RRect rrect = RRect.fromRectAndRadius( rect, - new Radius.circular(rect.shortestSide / 2.0), + Radius.circular(rect.shortestSide / 2.0), ); canvas.drawRRect(rrect, _shadowPaint); canvas.drawRRect(rrect.shift(const Offset(0.0, 3.0)), _shadowPaint); - canvas.drawRRect(rrect, new Paint()..color = color); + canvas.drawRRect(rrect, Paint()..color = color); } } diff --git a/packages/flutter/lib/src/foundation/assertions.dart b/packages/flutter/lib/src/foundation/assertions.dart index c4a50ceab5..ec92613e97 100644 --- a/packages/flutter/lib/src/foundation/assertions.dart +++ b/packages/flutter/lib/src/foundation/assertions.dart @@ -143,7 +143,7 @@ class FlutterErrorDetails { @override String toString() { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); if ((library != null && library != '') || (context != null && context != '')) { if (library != null && library != '') { buffer.write('Error caught by $library'); @@ -297,13 +297,13 @@ class FlutterError extends AssertionError { final List stackList = stackLines.take(2).toList(); if (stackList.length >= 2) { // TODO(ianh): This has bitrotted and is no longer matching. https://github.com/flutter/flutter/issues/4021 - final RegExp throwPattern = new RegExp(r'^#0 +_AssertionError._throwNew \(dart:.+\)$'); - final RegExp assertPattern = new RegExp(r'^#1 +[^(]+ \((.+?):([0-9]+)(?::[0-9]+)?\)$'); + final RegExp throwPattern = RegExp(r'^#0 +_AssertionError._throwNew \(dart:.+\)$'); + final RegExp assertPattern = RegExp(r'^#1 +[^(]+ \((.+?):([0-9]+)(?::[0-9]+)?\)$'); if (throwPattern.hasMatch(stackList[0])) { final Match assertMatch = assertPattern.firstMatch(stackList[1]); if (assertMatch != null) { assert(assertMatch.groupCount == 2); - final RegExp ourLibraryPattern = new RegExp(r'^package:flutter/'); + final RegExp ourLibraryPattern = RegExp(r'^package:flutter/'); ourFault = ourLibraryPattern.hasMatch(assertMatch.group(1)); } } @@ -328,7 +328,7 @@ class FlutterError extends AssertionError { debugPrint(line, wrapWidth: wrapWidth); } if (details.informationCollector != null) { - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); details.informationCollector(information); debugPrint('\n${information.toString().trimRight()}', wrapWidth: wrapWidth); } @@ -361,8 +361,8 @@ class FlutterError extends AssertionError { '_FakeAsync', '_FrameCallbackEntry', ]; - final RegExp stackParser = new RegExp(r'^#[0-9]+ +([^.]+).* \(([^/\\]*)[/\\].+:[0-9]+(?::[0-9]+)?\)$'); - final RegExp packageParser = new RegExp(r'^([^:]+):(.+)$'); + final RegExp stackParser = RegExp(r'^#[0-9]+ +([^.]+).* \(([^/\\]*)[/\\].+:[0-9]+(?::[0-9]+)?\)$'); + final RegExp packageParser = RegExp(r'^([^:]+):(.+)$'); final List result = []; final List skipped = []; for (String line in frames) { @@ -388,7 +388,7 @@ class FlutterError extends AssertionError { if (skipped.length == 1) { result.add('(elided one frame from ${skipped.single})'); } else if (skipped.length > 1) { - final List where = new Set.from(skipped).toList()..sort(); + final List where = Set.from(skipped).toList()..sort(); if (where.length > 1) where[where.length - 1] = 'and ${where.last}'; if (where.length > 2) { diff --git a/packages/flutter/lib/src/foundation/basic_types.dart b/packages/flutter/lib/src/foundation/basic_types.dart index 7c8b16213f..9837907230 100644 --- a/packages/flutter/lib/src/foundation/basic_types.dart +++ b/packages/flutter/lib/src/foundation/basic_types.dart @@ -194,42 +194,42 @@ class CachingIterable extends IterableBase { @override Iterator get iterator { - return new _LazyListIterator(this); + return _LazyListIterator(this); } @override Iterable map(T f(E e)) { - return new CachingIterable(super.map(f).iterator); + return CachingIterable(super.map(f).iterator); } @override Iterable where(bool test(E element)) { - return new CachingIterable(super.where(test).iterator); + return CachingIterable(super.where(test).iterator); } @override Iterable expand(Iterable f(E element)) { - return new CachingIterable(super.expand(f).iterator); + return CachingIterable(super.expand(f).iterator); } @override Iterable take(int count) { - return new CachingIterable(super.take(count).iterator); + return CachingIterable(super.take(count).iterator); } @override Iterable takeWhile(bool test(E value)) { - return new CachingIterable(super.takeWhile(test).iterator); + return CachingIterable(super.takeWhile(test).iterator); } @override Iterable skip(int count) { - return new CachingIterable(super.skip(count).iterator); + return CachingIterable(super.skip(count).iterator); } @override Iterable skipWhile(bool test(E value)) { - return new CachingIterable(super.skipWhile(test).iterator); + return CachingIterable(super.skipWhile(test).iterator); } @override @@ -241,7 +241,7 @@ class CachingIterable extends IterableBase { @override List toList({ bool growable = true }) { _precacheEntireList(); - return new List.from(_results, growable: growable); + return List.from(_results, growable: growable); } void _precacheEntireList() { diff --git a/packages/flutter/lib/src/foundation/binding.dart b/packages/flutter/lib/src/foundation/binding.dart index e9bbb58e0c..03b194f8ef 100644 --- a/packages/flutter/lib/src/foundation/binding.dart +++ b/packages/flutter/lib/src/foundation/binding.dart @@ -114,7 +114,7 @@ abstract class BindingBase { ); registerSignalServiceExtension( name: 'frameworkPresent', - callback: () => new Future.value(), + callback: () => Future.value(), ); assert(() { registerServiceExtension( @@ -231,7 +231,7 @@ abstract class BindingBase { @protected Future performReassemble() { FlutterError.resetErrorCount(); - return new Future.value(); + return Future.value(); } /// Registers a service extension method with the given name (full @@ -382,7 +382,7 @@ abstract class BindingBase { // breaks many assertions. As such, we ensure they we run the callbacks // on the outer event loop here. await debugInstrumentAction('Wait for outer event loop', () { - return new Future.delayed(Duration.zero); + return Future.delayed(Duration.zero); }); dynamic caughtException; @@ -397,14 +397,14 @@ abstract class BindingBase { if (caughtException == null) { result['type'] = '_extensionType'; result['method'] = method; - return new developer.ServiceExtensionResponse.result(json.encode(result)); + return developer.ServiceExtensionResponse.result(json.encode(result)); } else { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: caughtException, stack: caughtStack, context: 'during a service extension callback for "$method"' )); - return new developer.ServiceExtensionResponse.error( + return developer.ServiceExtensionResponse.error( developer.ServiceExtensionResponse.extensionError, json.encode({ 'exception': caughtException.toString(), diff --git a/packages/flutter/lib/src/foundation/change_notifier.dart b/packages/flutter/lib/src/foundation/change_notifier.dart index 88f9abcab9..707612f01c 100644 --- a/packages/flutter/lib/src/foundation/change_notifier.dart +++ b/packages/flutter/lib/src/foundation/change_notifier.dart @@ -53,12 +53,12 @@ abstract class ValueListenable extends Listenable { /// /// * [ValueNotifier], which is a [ChangeNotifier] that wraps a single value. class ChangeNotifier extends Listenable { - ObserverList _listeners = new ObserverList(); + ObserverList _listeners = ObserverList(); bool _debugAssertNotDisposed() { assert(() { if (_listeners == null) { - throw new FlutterError( + throw FlutterError( 'A $runtimeType was used after being disposed.\n' 'Once you have called dispose() on a $runtimeType, it can no longer be used.' ); @@ -154,13 +154,13 @@ class ChangeNotifier extends Listenable { void notifyListeners() { assert(_debugAssertNotDisposed()); if (_listeners != null) { - final List localListeners = new List.from(_listeners); + final List localListeners = List.from(_listeners); for (VoidCallback listener in localListeners) { try { if (_listeners.contains(listener)) listener(); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'foundation library', diff --git a/packages/flutter/lib/src/foundation/consolidate_response.dart b/packages/flutter/lib/src/foundation/consolidate_response.dart index f28e39cda0..146ca250c8 100644 --- a/packages/flutter/lib/src/foundation/consolidate_response.dart +++ b/packages/flutter/lib/src/foundation/consolidate_response.dart @@ -13,14 +13,14 @@ Future consolidateHttpClientResponseBytes(HttpClientResponse response // response.contentLength is not trustworthy when GZIP is involved // or other cases where an intermediate transformer has been applied // to the stream. - final Completer completer = new Completer.sync(); + final Completer completer = Completer.sync(); final List> chunks = >[]; int contentLength = 0; response.listen((List chunk) { chunks.add(chunk); contentLength += chunk.length; }, onDone: () { - final Uint8List bytes = new Uint8List(contentLength); + final Uint8List bytes = Uint8List(contentLength); int offset = 0; for (List chunk in chunks) { bytes.setRange(offset, offset + chunk.length, chunk); diff --git a/packages/flutter/lib/src/foundation/debug.dart b/packages/flutter/lib/src/foundation/debug.dart index f3c7ec613d..b8e526cd5d 100644 --- a/packages/flutter/lib/src/foundation/debug.dart +++ b/packages/flutter/lib/src/foundation/debug.dart @@ -25,7 +25,7 @@ bool debugAssertAllFoundationVarsUnset(String reason, { DebugPrintCallback debug assert(() { if (debugPrint != debugPrintOverride || debugDefaultTargetPlatformOverride != null) - throw new FlutterError(reason); + throw FlutterError(reason); return true; }()); return true; @@ -53,7 +53,7 @@ Future debugInstrumentAction(String description, Future action()) { bool instrument = false; assert(() { instrument = debugInstrumentationEnabled; return true; }()); if (instrument) { - final Stopwatch stopwatch = new Stopwatch()..start(); + final Stopwatch stopwatch = Stopwatch()..start(); return action().whenComplete(() { stopwatch.stop(); debugPrint('Action "$description" took ${stopwatch.elapsed}'); diff --git a/packages/flutter/lib/src/foundation/diagnostics.dart b/packages/flutter/lib/src/foundation/diagnostics.dart index d59983310d..ee12ad0968 100644 --- a/packages/flutter/lib/src/foundation/diagnostics.dart +++ b/packages/flutter/lib/src/foundation/diagnostics.dart @@ -310,7 +310,7 @@ class TextTreeConfiguration { /// See also: /// /// * [DiagnosticsTreeStyle.sparse] -final TextTreeConfiguration sparseTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration sparseTextConfiguration = TextTreeConfiguration( prefixLineOne: '├─', prefixOtherLines: ' ', prefixLastChildLineOne: '└─', @@ -364,7 +364,7 @@ final TextTreeConfiguration sparseTextConfiguration = new TextTreeConfiguration( /// See also: /// /// * [DiagnosticsTreeStyle.offstage], uses this style for ASCII art display. -final TextTreeConfiguration dashedTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration dashedTextConfiguration = TextTreeConfiguration( prefixLineOne: '╎╌', prefixLastChildLineOne: '└╌', prefixOtherLines: ' ', @@ -388,7 +388,7 @@ final TextTreeConfiguration dashedTextConfiguration = new TextTreeConfiguration( /// See also: /// /// * [DiagnosticsTreeStyle.dense] -final TextTreeConfiguration denseTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration denseTextConfiguration = TextTreeConfiguration( propertySeparator: ', ', beforeProperties: '(', afterProperties: ')', @@ -427,7 +427,7 @@ final TextTreeConfiguration denseTextConfiguration = new TextTreeConfiguration( /// /// See also: /// /// * [DiagnosticsTreeStyle.transition] -final TextTreeConfiguration transitionTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration transitionTextConfiguration = TextTreeConfiguration( prefixLineOne: '╞═╦══ ', prefixLastChildLineOne: '╘═╦══ ', prefixOtherLines: ' ║ ', @@ -474,7 +474,7 @@ final TextTreeConfiguration transitionTextConfiguration = new TextTreeConfigurat /// See also: /// /// * [DiagnosticsTreeStyle.whitespace] -final TextTreeConfiguration whitespaceTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration whitespaceTextConfiguration = TextTreeConfiguration( prefixLineOne: '', prefixLastChildLineOne: '', prefixOtherLines: ' ', @@ -498,7 +498,7 @@ final TextTreeConfiguration whitespaceTextConfiguration = new TextTreeConfigurat /// See also: /// /// * [DiagnosticsTreeStyle.singleLine] -final TextTreeConfiguration singleLineTextConfiguration = new TextTreeConfiguration( +final TextTreeConfiguration singleLineTextConfiguration = TextTreeConfiguration( propertySeparator: ', ', beforeProperties: '(', afterProperties: ')', @@ -534,7 +534,7 @@ class _PrefixedStringBuilder { /// subsequent lines will be added with the modified prefix. String prefixOtherLines; - final StringBuffer _buffer = new StringBuffer(); + final StringBuffer _buffer = StringBuffer(); bool _atLineStart = true; bool _hasMultipleLines = false; @@ -664,7 +664,7 @@ abstract class DiagnosticsNode { }) { assert(style != null); assert(level != null); - return new DiagnosticsProperty( + return DiagnosticsProperty( '', null, description: message, @@ -866,7 +866,7 @@ abstract class DiagnosticsNode { if (prefixOtherLines.isEmpty) prefixOtherLines += config.prefixOtherLinesRootNode; - final _PrefixedStringBuilder builder = new _PrefixedStringBuilder( + final _PrefixedStringBuilder builder = _PrefixedStringBuilder( prefixLineOne, prefixOtherLines, ); @@ -1970,7 +1970,7 @@ class DiagnosticableNode extends DiagnosticsNode { DiagnosticPropertiesBuilder get _builder { if (_cachedBuilder == null) { - _cachedBuilder = new DiagnosticPropertiesBuilder(); + _cachedBuilder = DiagnosticPropertiesBuilder(); value?.debugFillProperties(_cachedBuilder); } return _cachedBuilder; @@ -2131,7 +2131,7 @@ abstract class Diagnosticable { /// relationship between the parent and the node. For example, pass /// [DiagnosticsTreeStyle.offstage] to indicate that a node is offstage. DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { - return new DiagnosticableNode( + return DiagnosticableNode( name: name, value: this, style: style, @@ -2385,10 +2385,10 @@ abstract class DiagnosticableTree extends Diagnosticable { String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug, }) { - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); result.write(toString()); result.write(joiner); - final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); + final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); debugFillProperties(builder); result.write( builder.properties.where((DiagnosticsNode n) => !n.isFiltered(minLevel)).join(joiner), @@ -2427,7 +2427,7 @@ abstract class DiagnosticableTree extends Diagnosticable { @override DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { - return new _DiagnosticableTreeNode( + return _DiagnosticableTreeNode( name: name, value: this, style: style, @@ -2475,10 +2475,10 @@ abstract class DiagnosticableTreeMixin implements DiagnosticableTree { String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug, }) { - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); result.write(toStringShort()); result.write(joiner); - final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); + final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); debugFillProperties(builder); result.write( builder.properties.where((DiagnosticsNode n) => !n.isFiltered(minLevel)).join(joiner), @@ -2500,7 +2500,7 @@ abstract class DiagnosticableTreeMixin implements DiagnosticableTree { @override DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) { - return new _DiagnosticableTreeNode( + return _DiagnosticableTreeNode( name: name, value: this, style: style, diff --git a/packages/flutter/lib/src/foundation/isolates.dart b/packages/flutter/lib/src/foundation/isolates.dart index a7c988b61c..6eec08039a 100644 --- a/packages/flutter/lib/src/foundation/isolates.dart +++ b/packages/flutter/lib/src/foundation/isolates.dart @@ -48,11 +48,11 @@ Future compute(ComputeCallback callback, Q message, { String debu profile(() { debugLabel ??= callback.toString(); }); final Flow flow = Flow.begin(); Timeline.startSync('$debugLabel: start', flow: flow); - final ReceivePort resultPort = new ReceivePort(); + final ReceivePort resultPort = ReceivePort(); Timeline.finishSync(); final Isolate isolate = await Isolate.spawn( _spawn, - new _IsolateConfiguration( + _IsolateConfiguration( callback, message, resultPort.sendPort, diff --git a/packages/flutter/lib/src/foundation/key.dart b/packages/flutter/lib/src/foundation/key.dart index 6293f1c009..886e478ccf 100644 --- a/packages/flutter/lib/src/foundation/key.dart +++ b/packages/flutter/lib/src/foundation/key.dart @@ -77,7 +77,7 @@ class ValueKey extends LocalKey { final String valueString = T == String ? '<\'$value\'>' : '<$value>'; // The crazy on the next line is a workaround for // https://github.com/dart-lang/sdk/issues/33297 - if (runtimeType == new _TypeLiteral>().type) + if (runtimeType == _TypeLiteral>().type) return '[$valueString]'; return '[$T $valueString]'; } diff --git a/packages/flutter/lib/src/foundation/licenses.dart b/packages/flutter/lib/src/foundation/licenses.dart index 316307c48e..48544a1c9a 100644 --- a/packages/flutter/lib/src/foundation/licenses.dart +++ b/packages/flutter/lib/src/foundation/licenses.dart @@ -154,7 +154,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry { LicenseParagraph getParagraph() { assert(lines.isNotEmpty); assert(currentParagraphIndentation != null); - final LicenseParagraph result = new LicenseParagraph(lines.join(' '), currentParagraphIndentation); + final LicenseParagraph result = LicenseParagraph(lines.join(' '), currentParagraphIndentation); assert(result.text.trimLeft() == result.text); assert(result.text.isNotEmpty); lines.clear(); diff --git a/packages/flutter/lib/src/foundation/observer_list.dart b/packages/flutter/lib/src/foundation/observer_list.dart index 28ad46c933..dced3f842c 100644 --- a/packages/flutter/lib/src/foundation/observer_list.dart +++ b/packages/flutter/lib/src/foundation/observer_list.dart @@ -38,7 +38,7 @@ class ObserverList extends Iterable { if (_isDirty) { if (_set == null) { - _set = new HashSet.from(_list); + _set = HashSet.from(_list); } else { _set.clear(); _set.addAll(_list); diff --git a/packages/flutter/lib/src/foundation/platform.dart b/packages/flutter/lib/src/foundation/platform.dart index 44b1c8c9dd..cb27ae11b8 100644 --- a/packages/flutter/lib/src/foundation/platform.dart +++ b/packages/flutter/lib/src/foundation/platform.dart @@ -64,7 +64,7 @@ TargetPlatform get defaultTargetPlatform { if (debugDefaultTargetPlatformOverride != null) result = debugDefaultTargetPlatformOverride; if (result == null) { - throw new FlutterError( + throw FlutterError( 'Unknown platform.\n' '${Platform.operatingSystem} was not recognized as a target platform. ' 'Consider updating the list of TargetPlatforms to include this platform.' diff --git a/packages/flutter/lib/src/foundation/print.dart b/packages/flutter/lib/src/foundation/print.dart index ce0f412a0e..c60d3cb4ab 100644 --- a/packages/flutter/lib/src/foundation/print.dart +++ b/packages/flutter/lib/src/foundation/print.dart @@ -52,8 +52,8 @@ void debugPrintThrottled(String message, { int wrapWidth }) { int _debugPrintedCharacters = 0; const int _kDebugPrintCapacity = 12 * 1024; const Duration _kDebugPrintPauseTime = Duration(seconds: 1); -final Queue _debugPrintBuffer = new Queue(); -final Stopwatch _debugPrintStopwatch = new Stopwatch(); +final Queue _debugPrintBuffer = Queue(); +final Stopwatch _debugPrintStopwatch = Stopwatch(); Completer _debugPrintCompleter; bool _debugPrintScheduled = false; void _debugPrintTask() { @@ -71,8 +71,8 @@ void _debugPrintTask() { if (_debugPrintBuffer.isNotEmpty) { _debugPrintScheduled = true; _debugPrintedCharacters = 0; - new Timer(_kDebugPrintPauseTime, _debugPrintTask); - _debugPrintCompleter ??= new Completer(); + Timer(_kDebugPrintPauseTime, _debugPrintTask); + _debugPrintCompleter ??= Completer(); } else { _debugPrintStopwatch.start(); _debugPrintCompleter?.complete(); @@ -83,9 +83,9 @@ void _debugPrintTask() { /// A Future that resolves when there is no longer any buffered content being /// printed by [debugPrintThrottled] (which is the default implementation for /// [debugPrint], which is used to report errors to the console). -Future get debugPrintDone => _debugPrintCompleter?.future ?? new Future.value(); +Future get debugPrintDone => _debugPrintCompleter?.future ?? Future.value(); -final RegExp _indentPattern = new RegExp('^ *(?:[-+*] |[0-9]+[.):] )?'); +final RegExp _indentPattern = RegExp('^ *(?:[-+*] |[0-9]+[.):] )?'); enum _WordWrapParseMode { inSpace, inWord, atBreak } /// Wraps the given string at the given width. /// diff --git a/packages/flutter/lib/src/foundation/serialization.dart b/packages/flutter/lib/src/foundation/serialization.dart index 213c18c5d0..82d10d9c78 100644 --- a/packages/flutter/lib/src/foundation/serialization.dart +++ b/packages/flutter/lib/src/foundation/serialization.dart @@ -15,8 +15,8 @@ import 'package:typed_data/typed_buffers.dart' show Uint8Buffer; class WriteBuffer { /// Creates an interface for incrementally building a [ByteData] instance. WriteBuffer() { - _buffer = new Uint8Buffer(); - _eightBytes = new ByteData(8); + _buffer = Uint8Buffer(); + _eightBytes = ByteData(8); _eightBytesAsList = _eightBytes.buffer.asUint8List(); } diff --git a/packages/flutter/lib/src/foundation/synchronous_future.dart b/packages/flutter/lib/src/foundation/synchronous_future.dart index b24ce08930..40d47675e5 100644 --- a/packages/flutter/lib/src/foundation/synchronous_future.dart +++ b/packages/flutter/lib/src/foundation/synchronous_future.dart @@ -24,26 +24,26 @@ class SynchronousFuture implements Future { @override Stream asStream() { - final StreamController controller = new StreamController(); + final StreamController controller = StreamController(); controller.add(_value); controller.close(); return controller.stream; } @override - Future catchError(Function onError, { bool test(dynamic error) }) => new Completer().future; + Future catchError(Function onError, { bool test(dynamic error) }) => Completer().future; @override Future then(dynamic f(T value), { Function onError }) { final dynamic result = f(_value); if (result is Future) return result; - return new SynchronousFuture(result); + return SynchronousFuture(result); } @override Future timeout(Duration timeLimit, { dynamic onTimeout() }) { - return new Future.value(_value).timeout(timeLimit, onTimeout: onTimeout); + return Future.value(_value).timeout(timeLimit, onTimeout: onTimeout); } @override @@ -54,7 +54,7 @@ class SynchronousFuture implements Future { return result.then((dynamic value) => _value); return this; } catch (e, stack) { - return new Future.error(e, stack); + return Future.error(e, stack); } } } diff --git a/packages/flutter/lib/src/gestures/arena.dart b/packages/flutter/lib/src/gestures/arena.dart index 1b3e6433cc..47187a8560 100644 --- a/packages/flutter/lib/src/gestures/arena.dart +++ b/packages/flutter/lib/src/gestures/arena.dart @@ -72,7 +72,7 @@ class _GestureArena { @override String toString() { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); if (members.isEmpty) { buffer.write(''); } else { @@ -106,11 +106,11 @@ class GestureArenaManager { GestureArenaEntry add(int pointer, GestureArenaMember member) { final _GestureArena state = _arenas.putIfAbsent(pointer, () { assert(_debugLogDiagnostic(pointer, '★ Opening new gesture arena.')); - return new _GestureArena(); + return _GestureArena(); }); state.add(member); assert(_debugLogDiagnostic(pointer, 'Adding: $member')); - return new GestureArenaEntry._(this, pointer, member); + return GestureArenaEntry._(this, pointer, member); } /// Prevents new members from entering the arena. diff --git a/packages/flutter/lib/src/gestures/binding.dart b/packages/flutter/lib/src/gestures/binding.dart index a7a4928763..090a0f35d7 100644 --- a/packages/flutter/lib/src/gestures/binding.dart +++ b/packages/flutter/lib/src/gestures/binding.dart @@ -38,7 +38,7 @@ abstract class GestureBinding extends BindingBase with HitTestable, HitTestDispa static GestureBinding get instance => _instance; static GestureBinding _instance; - final Queue _pendingPointerEvents = new Queue(); + final Queue _pendingPointerEvents = Queue(); void _handlePointerDataPacket(ui.PointerDataPacket packet) { // We convert pointer data to logical pixels so that e.g. the touch slop can be @@ -55,7 +55,7 @@ abstract class GestureBinding extends BindingBase with HitTestable, HitTestDispa void cancelPointer(int pointer) { if (_pendingPointerEvents.isEmpty && !locked) scheduleMicrotask(_flushPointerEventQueue); - _pendingPointerEvents.addFirst(new PointerCancelEvent(pointer: pointer)); + _pendingPointerEvents.addFirst(PointerCancelEvent(pointer: pointer)); } void _flushPointerEventQueue() { @@ -65,11 +65,11 @@ abstract class GestureBinding extends BindingBase with HitTestable, HitTestDispa } /// A router that routes all pointer events received from the engine. - final PointerRouter pointerRouter = new PointerRouter(); + final PointerRouter pointerRouter = PointerRouter(); /// The gesture arenas used for disambiguating the meaning of sequences of /// pointer events. - final GestureArenaManager gestureArena = new GestureArenaManager(); + final GestureArenaManager gestureArena = GestureArenaManager(); /// State for all pointers which are currently down. /// @@ -82,7 +82,7 @@ abstract class GestureBinding extends BindingBase with HitTestable, HitTestDispa HitTestResult result; if (event is PointerDownEvent) { assert(!_hitTests.containsKey(event.pointer)); - result = new HitTestResult(); + result = HitTestResult(); hitTest(result, event.position); _hitTests[event.pointer] = result; assert(() { @@ -104,7 +104,7 @@ abstract class GestureBinding extends BindingBase with HitTestable, HitTestDispa /// Determine which [HitTestTarget] objects are located at a given position. @override // from HitTestable void hitTest(HitTestResult result, Offset position) { - result.add(new HitTestEntry(this)); + result.add(HitTestEntry(this)); } /// Dispatch an event to a hit test result's path. @@ -120,7 +120,7 @@ abstract class GestureBinding extends BindingBase with HitTestable, HitTestDispa try { entry.target.handleEvent(event, entry); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetailsForPointerEventDispatcher( + FlutterError.reportError(FlutterErrorDetailsForPointerEventDispatcher( exception: exception, stack: stack, library: 'gesture library', diff --git a/packages/flutter/lib/src/gestures/converter.dart b/packages/flutter/lib/src/gestures/converter.dart index 63d5f1e836..0ca4ea6d9a 100644 --- a/packages/flutter/lib/src/gestures/converter.dart +++ b/packages/flutter/lib/src/gestures/converter.dart @@ -50,7 +50,7 @@ class PointerEventConverter { static _PointerState _ensureStateForPointer(ui.PointerData datum, Offset position) { return _pointers.putIfAbsent( datum.device, - () => new _PointerState(position) + () => _PointerState(position) ); } @@ -62,7 +62,7 @@ class PointerEventConverter { /// [PointerEvent] for more details on the [PointerEvent] coordinate space. static Iterable expand(Iterable data, double devicePixelRatio) sync* { for (ui.PointerData datum in data) { - final Offset position = new Offset(datum.physicalX, datum.physicalY) / devicePixelRatio; + final Offset position = Offset(datum.physicalX, datum.physicalY) / devicePixelRatio; final double radiusMinor = _toLogicalPixels(datum.radiusMinor, devicePixelRatio); final double radiusMajor = _toLogicalPixels(datum.radiusMajor, devicePixelRatio); final double radiusMin = _toLogicalPixels(datum.radiusMin, devicePixelRatio); @@ -75,7 +75,7 @@ class PointerEventConverter { assert(!_pointers.containsKey(datum.device)); final _PointerState state = _ensureStateForPointer(datum, position); assert(state.lastPosition == position); - yield new PointerAddedEvent( + yield PointerAddedEvent( timeStamp: timeStamp, kind: kind, device: datum.device, @@ -97,7 +97,7 @@ class PointerEventConverter { assert(!state.down); if (!alreadyAdded) { assert(state.lastPosition == position); - yield new PointerAddedEvent( + yield PointerAddedEvent( timeStamp: timeStamp, kind: kind, device: datum.device, @@ -115,7 +115,7 @@ class PointerEventConverter { } final Offset offset = position - state.lastPosition; state.lastPosition = position; - yield new PointerHoverEvent( + yield PointerHoverEvent( timeStamp: timeStamp, kind: kind, device: datum.device, @@ -142,7 +142,7 @@ class PointerEventConverter { assert(!state.down); if (!alreadyAdded) { assert(state.lastPosition == position); - yield new PointerAddedEvent( + yield PointerAddedEvent( timeStamp: timeStamp, kind: kind, device: datum.device, @@ -164,7 +164,7 @@ class PointerEventConverter { // down event. We restore the invariant here for our clients. final Offset offset = position - state.lastPosition; state.lastPosition = position; - yield new PointerHoverEvent( + yield PointerHoverEvent( timeStamp: timeStamp, kind: kind, device: datum.device, @@ -188,7 +188,7 @@ class PointerEventConverter { } state.startNewPointer(); state.setDown(); - yield new PointerDownEvent( + yield PointerDownEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, @@ -217,7 +217,7 @@ class PointerEventConverter { assert(state.down); final Offset offset = position - state.lastPosition; state.lastPosition = position; - yield new PointerMoveEvent( + yield PointerMoveEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, @@ -251,7 +251,7 @@ class PointerEventConverter { // invariant. We restore the invariant here for our clients. final Offset offset = position - state.lastPosition; state.lastPosition = position; - yield new PointerMoveEvent( + yield PointerMoveEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, @@ -277,7 +277,7 @@ class PointerEventConverter { assert(position == state.lastPosition); state.setUp(); if (datum.change == ui.PointerChange.up) { - yield new PointerUpEvent( + yield PointerUpEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, @@ -298,7 +298,7 @@ class PointerEventConverter { tilt: datum.tilt ); } else { - yield new PointerCancelEvent( + yield PointerCancelEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, @@ -323,7 +323,7 @@ class PointerEventConverter { assert(_pointers.containsKey(datum.device)); final _PointerState state = _pointers[datum.device]; if (state.down) { - yield new PointerCancelEvent( + yield PointerCancelEvent( timeStamp: timeStamp, pointer: state.pointer, kind: kind, @@ -344,7 +344,7 @@ class PointerEventConverter { ); } _pointers.remove(datum.device); - yield new PointerRemovedEvent( + yield PointerRemovedEvent( timeStamp: timeStamp, kind: kind, device: datum.device, diff --git a/packages/flutter/lib/src/gestures/debug.dart b/packages/flutter/lib/src/gestures/debug.dart index fbadbb91d9..c718d06951 100644 --- a/packages/flutter/lib/src/gestures/debug.dart +++ b/packages/flutter/lib/src/gestures/debug.dart @@ -52,7 +52,7 @@ bool debugAssertAllGesturesVarsUnset(String reason) { if (debugPrintHitTestResults || debugPrintGestureArenaDiagnostics || debugPrintRecognizerCallbacksTrace) - throw new FlutterError(reason); + throw FlutterError(reason); return true; }()); return true; diff --git a/packages/flutter/lib/src/gestures/hit_test.dart b/packages/flutter/lib/src/gestures/hit_test.dart index 1c380bef1f..df45811683 100644 --- a/packages/flutter/lib/src/gestures/hit_test.dart +++ b/packages/flutter/lib/src/gestures/hit_test.dart @@ -66,7 +66,7 @@ class HitTestResult { /// The first entry in the path is the most specific, typically the one at /// the leaf of tree being hit tested. Event propagation starts with the most /// specific (i.e., first) entry and proceeds in order through the path. - List get path => new List.unmodifiable(_path); + List get path => List.unmodifiable(_path); final List _path; /// Add a [HitTestEntry] to the path. diff --git a/packages/flutter/lib/src/gestures/lsq_solver.dart b/packages/flutter/lib/src/gestures/lsq_solver.dart index 1c77166894..1a540c2d43 100644 --- a/packages/flutter/lib/src/gestures/lsq_solver.dart +++ b/packages/flutter/lib/src/gestures/lsq_solver.dart @@ -7,7 +7,7 @@ import 'dart:typed_data'; // TODO(abarth): Consider using vector_math. class _Vector { - _Vector(int size) : _offset = 0, _length = size, _elements = new Float64List(size); + _Vector(int size) : _offset = 0, _length = size, _elements = Float64List(size); _Vector.fromVOL(List values, int offset, int length) : _offset = offset, _length = length, _elements = values; @@ -37,7 +37,7 @@ class _Vector { class _Matrix { _Matrix(int rows, int cols) : _columns = cols, - _elements = new Float64List(rows * cols); + _elements = Float64List(rows * cols); final int _columns; final List _elements; @@ -47,7 +47,7 @@ class _Matrix { _elements[row * _columns + col] = value; } - _Vector getRow(int row) => new _Vector.fromVOL( + _Vector getRow(int row) => _Vector.fromVOL( _elements, row * _columns, _columns @@ -59,7 +59,7 @@ class PolynomialFit { /// Creates a polynomial fit of the given degree. /// /// There are n + 1 coefficients in a fit of degree n. - PolynomialFit(int degree) : coefficients = new Float64List(degree + 1); + PolynomialFit(int degree) : coefficients = Float64List(degree + 1); /// The polynomial coefficients of the fit. final List coefficients; @@ -93,14 +93,14 @@ class LeastSquaresSolver { if (degree > x.length) // Not enough data to fit a curve. return null; - final PolynomialFit result = new PolynomialFit(degree); + final PolynomialFit result = PolynomialFit(degree); // Shorthands for the purpose of notation equivalence to original C++ code. final int m = x.length; final int n = degree + 1; // Expand the X vector to a matrix A, pre-multiplied by the weights. - final _Matrix a = new _Matrix(n, m); + final _Matrix a = _Matrix(n, m); for (int h = 0; h < m; h += 1) { a.set(0, h, w[h]); for (int i = 1; i < n; i += 1) @@ -110,9 +110,9 @@ class LeastSquaresSolver { // Apply the Gram-Schmidt process to A to obtain its QR decomposition. // Orthonormal basis, column-major ordVectorer. - final _Matrix q = new _Matrix(n, m); + final _Matrix q = _Matrix(n, m); // Upper triangular matrix, row-major order. - final _Matrix r = new _Matrix(n, n); + final _Matrix r = _Matrix(n, n); for (int j = 0; j < n; j += 1) { for (int h = 0; h < m; h += 1) q.set(j, h, a.get(j, h)); @@ -137,7 +137,7 @@ class LeastSquaresSolver { // Solve R B = Qt W Y to find B. This is easy because R is upper triangular. // We just work from bottom-right to top-left calculating B's coefficients. - final _Vector wy = new _Vector(m); + final _Vector wy = _Vector(m); for (int h = 0; h < m; h += 1) wy[h] = y[h] * w[h]; for (int i = n - 1; i >= 0; i -= 1) { diff --git a/packages/flutter/lib/src/gestures/monodrag.dart b/packages/flutter/lib/src/gestures/monodrag.dart index 93f021b720..cb8e698911 100644 --- a/packages/flutter/lib/src/gestures/monodrag.dart +++ b/packages/flutter/lib/src/gestures/monodrag.dart @@ -113,14 +113,14 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { @override void addPointer(PointerEvent event) { startTrackingPointer(event.pointer); - _velocityTrackers[event.pointer] = new VelocityTracker(); + _velocityTrackers[event.pointer] = VelocityTracker(); if (_state == _DragState.ready) { _state = _DragState.possible; _initialPosition = event.position; _pendingDragOffset = Offset.zero; _lastPendingEventTimestamp = event.timeStamp; if (onDown != null) - invokeCallback('onDown', () => onDown(new DragDownDetails(globalPosition: _initialPosition))); + invokeCallback('onDown', () => onDown(DragDownDetails(globalPosition: _initialPosition))); } else if (_state == _DragState.accepted) { resolve(GestureDisposition.accepted); } @@ -140,7 +140,7 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { final Offset delta = event.delta; if (_state == _DragState.accepted) { if (onUpdate != null) { - invokeCallback('onUpdate', () => onUpdate(new DragUpdateDetails( + invokeCallback('onUpdate', () => onUpdate(DragUpdateDetails( sourceTimeStamp: event.timeStamp, delta: _getDeltaForDetails(delta), primaryDelta: _getPrimaryValueFromOffset(delta), @@ -166,14 +166,14 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { _pendingDragOffset = Offset.zero; _lastPendingEventTimestamp = null; if (onStart != null) { - invokeCallback('onStart', () => onStart(new DragStartDetails( + invokeCallback('onStart', () => onStart(DragStartDetails( sourceTimeStamp: timestamp, globalPosition: _initialPosition, ))); } if (delta != Offset.zero && onUpdate != null) { final Offset deltaForDetails = _getDeltaForDetails(delta); - invokeCallback('onUpdate', () => onUpdate(new DragUpdateDetails( + invokeCallback('onUpdate', () => onUpdate(DragUpdateDetails( sourceTimeStamp: timestamp, delta: deltaForDetails, primaryDelta: _getPrimaryValueFromOffset(delta), @@ -205,16 +205,16 @@ abstract class DragGestureRecognizer extends OneSequenceGestureRecognizer { final VelocityEstimate estimate = tracker.getVelocityEstimate(); if (estimate != null && _isFlingGesture(estimate)) { - final Velocity velocity = new Velocity(pixelsPerSecond: estimate.pixelsPerSecond) + final Velocity velocity = Velocity(pixelsPerSecond: estimate.pixelsPerSecond) .clampMagnitude(minFlingVelocity ?? kMinFlingVelocity, maxFlingVelocity ?? kMaxFlingVelocity); - invokeCallback('onEnd', () => onEnd(new DragEndDetails( + invokeCallback('onEnd', () => onEnd(DragEndDetails( velocity: velocity, primaryVelocity: _getPrimaryValueFromOffset(velocity.pixelsPerSecond), )), debugReport: () { return '$estimate; fling at $velocity.'; }); } else { - invokeCallback('onEnd', () => onEnd(new DragEndDetails( + invokeCallback('onEnd', () => onEnd(DragEndDetails( velocity: Velocity.zero, primaryVelocity: 0.0, )), debugReport: () { @@ -259,7 +259,7 @@ class VerticalDragGestureRecognizer extends DragGestureRecognizer { bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragOffset.dy.abs() > kTouchSlop; @override - Offset _getDeltaForDetails(Offset delta) => new Offset(0.0, delta.dy); + Offset _getDeltaForDetails(Offset delta) => Offset(0.0, delta.dy); @override double _getPrimaryValueFromOffset(Offset value) => value.dy; @@ -293,7 +293,7 @@ class HorizontalDragGestureRecognizer extends DragGestureRecognizer { bool get _hasSufficientPendingDragDeltaToAccept => _pendingDragOffset.dx.abs() > kTouchSlop; @override - Offset _getDeltaForDetails(Offset delta) => new Offset(delta.dx, 0.0); + Offset _getDeltaForDetails(Offset delta) => Offset(delta.dx, 0.0); @override double _getPrimaryValueFromOffset(Offset value) => value.dx; diff --git a/packages/flutter/lib/src/gestures/multidrag.dart b/packages/flutter/lib/src/gestures/multidrag.dart index 5998e236f0..82cbb981f3 100644 --- a/packages/flutter/lib/src/gestures/multidrag.dart +++ b/packages/flutter/lib/src/gestures/multidrag.dart @@ -33,7 +33,7 @@ abstract class MultiDragPointerState { /// The global coordinates of the pointer when the pointer contacted the screen. final Offset initialPosition; - final VelocityTracker _velocityTracker = new VelocityTracker(); + final VelocityTracker _velocityTracker = VelocityTracker(); Drag _client; /// The offset of the pointer from the last position that was reported to the client. @@ -69,7 +69,7 @@ abstract class MultiDragPointerState { if (_client != null) { assert(pendingDelta == null); // Call client last to avoid reentrancy. - _client.update(new DragUpdateDetails( + _client.update(DragUpdateDetails( sourceTimeStamp: event.timeStamp, delta: event.delta, globalPosition: event.position, @@ -115,7 +115,7 @@ abstract class MultiDragPointerState { assert(client != null); assert(pendingDelta != null); _client = client; - final DragUpdateDetails details = new DragUpdateDetails( + final DragUpdateDetails details = DragUpdateDetails( sourceTimeStamp: _lastPendingEventTimestamp, delta: pendingDelta, globalPosition: initialPosition, @@ -130,7 +130,7 @@ abstract class MultiDragPointerState { assert(_arenaEntry != null); if (_client != null) { assert(pendingDelta == null); - final DragEndDetails details = new DragEndDetails(velocity: _velocityTracker.getVelocity()); + final DragEndDetails details = DragEndDetails(velocity: _velocityTracker.getVelocity()); final Drag client = _client; _client = null; // Call client last to avoid reentrancy. @@ -338,7 +338,7 @@ class ImmediateMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Im @override _ImmediatePointerState createNewPointerState(PointerDownEvent event) { - return new _ImmediatePointerState(event.position); + return _ImmediatePointerState(event.position); } @override @@ -384,7 +384,7 @@ class HorizontalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_H @override _HorizontalPointerState createNewPointerState(PointerDownEvent event) { - return new _HorizontalPointerState(event.position); + return _HorizontalPointerState(event.position); } @override @@ -430,7 +430,7 @@ class VerticalMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Ver @override _VerticalPointerState createNewPointerState(PointerDownEvent event) { - return new _VerticalPointerState(event.position); + return _VerticalPointerState(event.position); } @override @@ -441,7 +441,7 @@ class _DelayedPointerState extends MultiDragPointerState { _DelayedPointerState(Offset initialPosition, Duration delay) : assert(delay != null), super(initialPosition) { - _timer = new Timer(delay, _delayPassed); + _timer = Timer(delay, _delayPassed); } Timer _timer; @@ -537,7 +537,7 @@ class DelayedMultiDragGestureRecognizer extends MultiDragGestureRecognizer<_Dela @override _DelayedPointerState createNewPointerState(PointerDownEvent event) { - return new _DelayedPointerState(event.position, delay); + return _DelayedPointerState(event.position, delay); } @override diff --git a/packages/flutter/lib/src/gestures/multitap.dart b/packages/flutter/lib/src/gestures/multitap.dart index 35f4a3dae7..fc6d81d91a 100644 --- a/packages/flutter/lib/src/gestures/multitap.dart +++ b/packages/flutter/lib/src/gestures/multitap.dart @@ -106,7 +106,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { !_firstTap.isWithinTolerance(event, kDoubleTapSlop)) return; _stopDoubleTapTimer(); - final _TapTracker tracker = new _TapTracker( + final _TapTracker tracker = _TapTracker( event: event, entry: GestureBinding.instance.gestureArena.add(event.pointer, this) ); @@ -208,7 +208,7 @@ class DoubleTapGestureRecognizer extends GestureRecognizer { } void _startDoubleTapTimer() { - _doubleTapTimer ??= new Timer(kDoubleTapTimeout, _reset); + _doubleTapTimer ??= Timer(kDoubleTapTimeout, _reset); } void _stopDoubleTapTimer() { @@ -238,7 +238,7 @@ class _TapGesture extends _TapTracker { ) { startTrackingPointer(handleEvent); if (longTapDelay > Duration.zero) { - _timer = new Timer(longTapDelay, () { + _timer = Timer(longTapDelay, () { _timer = null; gestureRecognizer._dispatchLongTap(event.pointer, _lastPosition); }); @@ -347,13 +347,13 @@ class MultiTapGestureRecognizer extends GestureRecognizer { @override void addPointer(PointerEvent event) { assert(!_gestureMap.containsKey(event.pointer)); - _gestureMap[event.pointer] = new _TapGesture( + _gestureMap[event.pointer] = _TapGesture( gestureRecognizer: this, event: event, longTapDelay: longTapDelay ); if (onTapDown != null) - invokeCallback('onTapDown', () => onTapDown(event.pointer, new TapDownDetails(globalPosition: event.position))); + invokeCallback('onTapDown', () => onTapDown(event.pointer, TapDownDetails(globalPosition: event.position))); } @override @@ -380,7 +380,7 @@ class MultiTapGestureRecognizer extends GestureRecognizer { assert(_gestureMap.containsKey(pointer)); _gestureMap.remove(pointer); if (onTapUp != null) - invokeCallback('onTapUp', () => onTapUp(pointer, new TapUpDetails(globalPosition: globalPosition))); + invokeCallback('onTapUp', () => onTapUp(pointer, TapUpDetails(globalPosition: globalPosition))); if (onTap != null) invokeCallback('onTap', () => onTap(pointer)); } @@ -388,12 +388,12 @@ class MultiTapGestureRecognizer extends GestureRecognizer { void _dispatchLongTap(int pointer, Offset lastPosition) { assert(_gestureMap.containsKey(pointer)); if (onLongTapDown != null) - invokeCallback('onLongTapDown', () => onLongTapDown(pointer, new TapDownDetails(globalPosition: lastPosition))); + invokeCallback('onLongTapDown', () => onLongTapDown(pointer, TapDownDetails(globalPosition: lastPosition))); } @override void dispose() { - final List<_TapGesture> localGestures = new List<_TapGesture>.from(_gestureMap.values); + final List<_TapGesture> localGestures = List<_TapGesture>.from(_gestureMap.values); for (_TapGesture gesture in localGestures) gesture.cancel(); // Rejection of each gesture should cause it to be removed from our map diff --git a/packages/flutter/lib/src/gestures/pointer_router.dart b/packages/flutter/lib/src/gestures/pointer_router.dart index 184192dc41..0ac00cbd56 100644 --- a/packages/flutter/lib/src/gestures/pointer_router.dart +++ b/packages/flutter/lib/src/gestures/pointer_router.dart @@ -14,7 +14,7 @@ typedef void PointerRoute(PointerEvent event); /// A routing table for [PointerEvent] events. class PointerRouter { final Map> _routeMap = >{}; - final LinkedHashSet _globalRoutes = new LinkedHashSet(); + final LinkedHashSet _globalRoutes = LinkedHashSet(); /// Adds a route to the routing table. /// @@ -24,7 +24,7 @@ class PointerRouter { /// Routes added reentrantly within [PointerRouter.route] will take effect when /// routing the next event. void addRoute(int pointer, PointerRoute route) { - final LinkedHashSet routes = _routeMap.putIfAbsent(pointer, () => new LinkedHashSet()); + final LinkedHashSet routes = _routeMap.putIfAbsent(pointer, () => LinkedHashSet()); assert(!routes.contains(route)); routes.add(route); } @@ -72,7 +72,7 @@ class PointerRouter { try { route(event); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetailsForPointerRouter( + FlutterError.reportError(FlutterErrorDetailsForPointerRouter( exception: exception, stack: stack, library: 'gesture library', @@ -94,9 +94,9 @@ class PointerRouter { /// PointerRouter object. void route(PointerEvent event) { final LinkedHashSet routes = _routeMap[event.pointer]; - final List globalRoutes = new List.from(_globalRoutes); + final List globalRoutes = List.from(_globalRoutes); if (routes != null) { - for (PointerRoute route in new List.from(routes)) { + for (PointerRoute route in List.from(routes)) { if (routes.contains(route)) _dispatch(event, route); } diff --git a/packages/flutter/lib/src/gestures/recognizer.dart b/packages/flutter/lib/src/gestures/recognizer.dart index c4b01edffa..d35f4612d5 100644 --- a/packages/flutter/lib/src/gestures/recognizer.dart +++ b/packages/flutter/lib/src/gestures/recognizer.dart @@ -101,7 +101,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT }()); result = callback(); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'gesture', @@ -119,7 +119,7 @@ abstract class GestureRecognizer extends GestureArenaMember with DiagnosticableT @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('debugOwner', debugOwner, defaultValue: null)); + properties.add(DiagnosticsProperty('debugOwner', debugOwner, defaultValue: null)); } } @@ -136,7 +136,7 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer { OneSequenceGestureRecognizer({ Object debugOwner }) : super(debugOwner: debugOwner); final Map _entries = {}; - final Set _trackedPointers = new HashSet(); + final Set _trackedPointers = HashSet(); /// Called when a pointer event is routed to this recognizer. @protected @@ -160,7 +160,7 @@ abstract class OneSequenceGestureRecognizer extends GestureRecognizer { @protected @mustCallSuper void resolve(GestureDisposition disposition) { - final List localEntries = new List.from(_entries.values); + final List localEntries = List.from(_entries.values); _entries.clear(); for (GestureArenaEntry entry in localEntries) entry.resolve(disposition); @@ -299,7 +299,7 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni primaryPointer = event.pointer; initialPosition = event.position; if (deadline != null) - _timer = new Timer(deadline, didExceedDeadline); + _timer = Timer(deadline, didExceedDeadline); } } @@ -366,6 +366,6 @@ abstract class PrimaryPointerGestureRecognizer extends OneSequenceGestureRecogni @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('state', state)); + properties.add(EnumProperty('state', state)); } } diff --git a/packages/flutter/lib/src/gestures/scale.dart b/packages/flutter/lib/src/gestures/scale.dart index 2d4b197ec9..c594caadd0 100644 --- a/packages/flutter/lib/src/gestures/scale.dart +++ b/packages/flutter/lib/src/gestures/scale.dart @@ -135,7 +135,7 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { @override void addPointer(PointerEvent event) { startTrackingPointer(event.pointer); - _velocityTrackers[event.pointer] = new VelocityTracker(); + _velocityTrackers[event.pointer] = VelocityTracker(); if (_state == _ScaleState.ready) { _state = _ScaleState.possible; _initialSpan = 0.0; @@ -199,10 +199,10 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { if (_isFlingGesture(velocity)) { final Offset pixelsPerSecond = velocity.pixelsPerSecond; if (pixelsPerSecond.distanceSquared > kMaxFlingVelocity * kMaxFlingVelocity) - velocity = new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity); - invokeCallback('onEnd', () => onEnd(new ScaleEndDetails(velocity: velocity))); + velocity = Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * kMaxFlingVelocity); + invokeCallback('onEnd', () => onEnd(ScaleEndDetails(velocity: velocity))); } else { - invokeCallback('onEnd', () => onEnd(new ScaleEndDetails(velocity: Velocity.zero))); + invokeCallback('onEnd', () => onEnd(ScaleEndDetails(velocity: Velocity.zero))); } } _state = _ScaleState.accepted; @@ -230,13 +230,13 @@ class ScaleGestureRecognizer extends OneSequenceGestureRecognizer { } if (_state == _ScaleState.started && onUpdate != null) - invokeCallback('onUpdate', () => onUpdate(new ScaleUpdateDetails(scale: _scaleFactor, focalPoint: _currentFocalPoint))); + invokeCallback('onUpdate', () => onUpdate(ScaleUpdateDetails(scale: _scaleFactor, focalPoint: _currentFocalPoint))); } void _dispatchOnStartCallbackIfNeeded() { assert(_state == _ScaleState.started); if (onStart != null) - invokeCallback('onStart', () => onStart(new ScaleStartDetails(focalPoint: _currentFocalPoint))); + invokeCallback('onStart', () => onStart(ScaleStartDetails(focalPoint: _currentFocalPoint))); } @override diff --git a/packages/flutter/lib/src/gestures/tap.dart b/packages/flutter/lib/src/gestures/tap.dart index 6a1db93010..af588ad817 100644 --- a/packages/flutter/lib/src/gestures/tap.dart +++ b/packages/flutter/lib/src/gestures/tap.dart @@ -220,7 +220,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { void _checkDown() { if (!_sentTapDown) { if (onTapDown != null) - invokeCallback('onTapDown', () { onTapDown(new TapDownDetails(globalPosition: initialPosition)); }); + invokeCallback('onTapDown', () { onTapDown(TapDownDetails(globalPosition: initialPosition)); }); _sentTapDown = true; } } @@ -237,7 +237,7 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { return; } if (onTapUp != null) - invokeCallback('onTapUp', () { onTapUp(new TapUpDetails(globalPosition: _finalPosition)); }); + invokeCallback('onTapUp', () { onTapUp(TapUpDetails(globalPosition: _finalPosition)); }); if (onTap != null) invokeCallback('onTap', onTap); _reset(); @@ -256,8 +256,8 @@ class TapGestureRecognizer extends PrimaryPointerGestureRecognizer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('wonArenaForPrimaryPointer', value: _wonArenaForPrimaryPointer, ifTrue: 'won arena')); - properties.add(new DiagnosticsProperty('finalPosition', _finalPosition, defaultValue: null)); - properties.add(new FlagProperty('sentTapDown', value: _sentTapDown, ifTrue: 'sent tap down')); + properties.add(FlagProperty('wonArenaForPrimaryPointer', value: _wonArenaForPrimaryPointer, ifTrue: 'won arena')); + properties.add(DiagnosticsProperty('finalPosition', _finalPosition, defaultValue: null)); + properties.add(FlagProperty('sentTapDown', value: _sentTapDown, ifTrue: 'sent tap down')); } } diff --git a/packages/flutter/lib/src/gestures/team.dart b/packages/flutter/lib/src/gestures/team.dart index 7d3ac4d57c..bd50e23883 100644 --- a/packages/flutter/lib/src/gestures/team.dart +++ b/packages/flutter/lib/src/gestures/team.dart @@ -61,7 +61,7 @@ class _CombiningGestureArenaMember extends GestureArenaMember { assert(_pointer == pointer); _members.add(member); _entry ??= GestureBinding.instance.gestureArena.add(pointer, this); - return new _CombiningGestureArenaEntry(this, member); + return _CombiningGestureArenaEntry(this, member); } void _resolve(GestureArenaMember member, GestureDisposition disposition) { @@ -140,7 +140,7 @@ class GestureArenaTeam { /// [OneSequenceGestureRecognizer.team]. GestureArenaEntry add(int pointer, GestureArenaMember member) { final _CombiningGestureArenaMember combiner = _combiners.putIfAbsent( - pointer, () => new _CombiningGestureArenaMember(this, pointer)); + pointer, () => _CombiningGestureArenaMember(this, pointer)); return combiner._add(pointer, member); } } diff --git a/packages/flutter/lib/src/gestures/velocity_tracker.dart b/packages/flutter/lib/src/gestures/velocity_tracker.dart index 03d2492e00..b099aa39ed 100644 --- a/packages/flutter/lib/src/gestures/velocity_tracker.dart +++ b/packages/flutter/lib/src/gestures/velocity_tracker.dart @@ -26,17 +26,17 @@ class Velocity { final Offset pixelsPerSecond; /// Return the negation of a velocity. - Velocity operator -() => new Velocity(pixelsPerSecond: -pixelsPerSecond); + Velocity operator -() => Velocity(pixelsPerSecond: -pixelsPerSecond); /// Return the difference of two velocities. Velocity operator -(Velocity other) { - return new Velocity( + return Velocity( pixelsPerSecond: pixelsPerSecond - other.pixelsPerSecond); } /// Return the sum of two velocities. Velocity operator +(Velocity other) { - return new Velocity( + return Velocity( pixelsPerSecond: pixelsPerSecond + other.pixelsPerSecond); } @@ -55,9 +55,9 @@ class Velocity { assert(maxValue != null && maxValue >= 0.0 && maxValue >= minValue); final double valueSquared = pixelsPerSecond.distanceSquared; if (valueSquared > maxValue * maxValue) - return new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * maxValue); + return Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * maxValue); if (valueSquared < minValue * minValue) - return new Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * minValue); + return Velocity(pixelsPerSecond: (pixelsPerSecond / pixelsPerSecond.distance) * minValue); return this; } @@ -153,7 +153,7 @@ class VelocityTracker { static const int _minSampleSize = 3; // Circular buffer; current sample at _index. - final List<_PointAtTime> _samples = new List<_PointAtTime>(_historySize); + final List<_PointAtTime> _samples = List<_PointAtTime>(_historySize); int _index = 0; /// Adds a position as the given time to the tracker. @@ -161,7 +161,7 @@ class VelocityTracker { _index += 1; if (_index == _historySize) _index = 0; - _samples[_index] = new _PointAtTime(position, time); + _samples[_index] = _PointAtTime(position, time); } /// Returns an estimate of the velocity of the object being tracked by the @@ -210,14 +210,14 @@ class VelocityTracker { } while (sampleCount < _historySize); if (sampleCount >= _minSampleSize) { - final LeastSquaresSolver xSolver = new LeastSquaresSolver(time, x, w); + final LeastSquaresSolver xSolver = LeastSquaresSolver(time, x, w); final PolynomialFit xFit = xSolver.solve(2); if (xFit != null) { - final LeastSquaresSolver ySolver = new LeastSquaresSolver(time, y, w); + final LeastSquaresSolver ySolver = LeastSquaresSolver(time, y, w); final PolynomialFit yFit = ySolver.solve(2); if (yFit != null) { - return new VelocityEstimate( // convert from pixels/ms to pixels/s - pixelsPerSecond: new Offset(xFit.coefficients[1] * 1000, yFit.coefficients[1] * 1000), + return VelocityEstimate( // convert from pixels/ms to pixels/s + pixelsPerSecond: Offset(xFit.coefficients[1] * 1000, yFit.coefficients[1] * 1000), confidence: xFit.confidence * yFit.confidence, duration: newestSample.time - oldestSample.time, offset: newestSample.point - oldestSample.point, @@ -228,7 +228,7 @@ class VelocityTracker { // We're unable to make a velocity estimate but we did have at least one // valid pointer position. - return new VelocityEstimate( + return VelocityEstimate( pixelsPerSecond: Offset.zero, confidence: 1.0, duration: newestSample.time - oldestSample.time, @@ -247,6 +247,6 @@ class VelocityTracker { final VelocityEstimate estimate = getVelocityEstimate(); if (estimate == null || estimate.pixelsPerSecond == Offset.zero) return Velocity.zero; - return new Velocity(pixelsPerSecond: estimate.pixelsPerSecond); + return Velocity(pixelsPerSecond: estimate.pixelsPerSecond); } } diff --git a/packages/flutter/lib/src/material/about.dart b/packages/flutter/lib/src/material/about.dart index 483a537eb8..59d12a2f38 100644 --- a/packages/flutter/lib/src/material/about.dart +++ b/packages/flutter/lib/src/material/about.dart @@ -109,10 +109,10 @@ class AboutListTile extends StatelessWidget { @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - return new ListTile( + return ListTile( leading: icon, title: child ?? - new Text(MaterialLocalizations.of(context).aboutListTileTitle(applicationName ?? _defaultApplicationName(context))), + Text(MaterialLocalizations.of(context).aboutListTileTitle(applicationName ?? _defaultApplicationName(context))), onTap: () { showAboutDialog( context: context, @@ -155,7 +155,7 @@ void showAboutDialog({ showDialog( context: context, builder: (BuildContext context) { - return new AboutDialog( + return AboutDialog( applicationName: applicationName, applicationVersion: applicationVersion, applicationIcon: applicationIcon, @@ -187,8 +187,8 @@ void showLicensePage({ String applicationLegalese }) { assert(context != null); - Navigator.push(context, new MaterialPageRoute( - builder: (BuildContext context) => new LicensePage( + Navigator.push(context, MaterialPageRoute( + builder: (BuildContext context) => LicensePage( applicationName: applicationName, applicationVersion: applicationVersion, applicationLegalese: applicationLegalese @@ -268,35 +268,35 @@ class AboutDialog extends StatelessWidget { final Widget icon = applicationIcon ?? _defaultApplicationIcon(context); List body = []; if (icon != null) - body.add(new IconTheme(data: const IconThemeData(size: 48.0), child: icon)); - body.add(new Expanded( - child: new Padding( + body.add(IconTheme(data: const IconThemeData(size: 48.0), child: icon)); + body.add(Expanded( + child: Padding( padding: const EdgeInsets.symmetric(horizontal: 24.0), - child: new ListBody( + child: ListBody( children: [ - new Text(name, style: Theme.of(context).textTheme.headline), - new Text(version, style: Theme.of(context).textTheme.body1), - new Container(height: 18.0), - new Text(applicationLegalese ?? '', style: Theme.of(context).textTheme.caption) + Text(name, style: Theme.of(context).textTheme.headline), + Text(version, style: Theme.of(context).textTheme.body1), + Container(height: 18.0), + Text(applicationLegalese ?? '', style: Theme.of(context).textTheme.caption) ] ) ) )); body = [ - new Row( + Row( crossAxisAlignment: CrossAxisAlignment.start, children: body ), ]; if (children != null) body.addAll(children); - return new AlertDialog( - content: new SingleChildScrollView( - child: new ListBody(children: body), + return AlertDialog( + content: SingleChildScrollView( + child: ListBody(children: body), ), actions: [ - new FlatButton( - child: new Text(MaterialLocalizations.of(context).viewLicensesButtonLabel), + FlatButton( + child: Text(MaterialLocalizations.of(context).viewLicensesButtonLabel), onPressed: () { showLicensePage( context: context, @@ -307,8 +307,8 @@ class AboutDialog extends StatelessWidget { ); } ), - new FlatButton( - child: new Text(MaterialLocalizations.of(context).closeButtonLabel), + FlatButton( + child: Text(MaterialLocalizations.of(context).closeButtonLabel), onPressed: () { Navigator.pop(context); } @@ -364,7 +364,7 @@ class LicensePage extends StatefulWidget { final String applicationLegalese; @override - _LicensePageState createState() => new _LicensePageState(); + _LicensePageState createState() => _LicensePageState(); } class _LicensePageState extends State { @@ -399,11 +399,11 @@ class _LicensePageState extends State { textAlign: TextAlign.center ) )); - _licenses.add(new Container( + _licenses.add(Container( decoration: const BoxDecoration( border: Border(bottom: BorderSide(width: 0.0)) ), - child: new Text( + child: Text( license.packages.join(', '), style: const TextStyle(fontWeight: FontWeight.bold), textAlign: TextAlign.center @@ -411,9 +411,9 @@ class _LicensePageState extends State { )); for (LicenseParagraph paragraph in paragraphs) { if (paragraph.indent == LicenseParagraph.centeredIndent) { - _licenses.add(new Padding( + _licenses.add(Padding( padding: const EdgeInsets.only(top: 16.0), - child: new Text( + child: Text( paragraph.text, style: const TextStyle(fontWeight: FontWeight.bold), textAlign: TextAlign.center @@ -421,9 +421,9 @@ class _LicensePageState extends State { )); } else { assert(paragraph.indent >= 0); - _licenses.add(new Padding( - padding: new EdgeInsetsDirectional.only(top: 8.0, start: 16.0 * paragraph.indent), - child: new Text(paragraph.text) + _licenses.add(Padding( + padding: EdgeInsetsDirectional.only(top: 8.0, start: 16.0 * paragraph.indent), + child: Text(paragraph.text) )); } } @@ -441,13 +441,13 @@ class _LicensePageState extends State { final String version = widget.applicationVersion ?? _defaultApplicationVersion(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context); final List contents = [ - new Text(name, style: Theme.of(context).textTheme.headline, textAlign: TextAlign.center), - new Text(version, style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center), - new Container(height: 18.0), - new Text(widget.applicationLegalese ?? '', style: Theme.of(context).textTheme.caption, textAlign: TextAlign.center), - new Container(height: 18.0), - new Text('Powered by Flutter', style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center), - new Container(height: 24.0), + Text(name, style: Theme.of(context).textTheme.headline, textAlign: TextAlign.center), + Text(version, style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center), + Container(height: 18.0), + Text(widget.applicationLegalese ?? '', style: Theme.of(context).textTheme.caption, textAlign: TextAlign.center), + Container(height: 18.0), + Text('Powered by Flutter', style: Theme.of(context).textTheme.body1, textAlign: TextAlign.center), + Container(height: 24.0), ]; contents.addAll(_licenses); if (!_loaded) { @@ -458,19 +458,19 @@ class _LicensePageState extends State { ) )); } - return new Scaffold( - appBar: new AppBar( - title: new Text(localizations.licensesPageTitle), + return Scaffold( + appBar: AppBar( + title: Text(localizations.licensesPageTitle), ), // All of the licenses page text is English. We don't want localized text // or text direction. - body: new Localizations.override( + body: Localizations.override( locale: const Locale('en', 'US'), context: context, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: Theme.of(context).textTheme.caption, - child: new Scrollbar( - child: new ListView( + child: Scrollbar( + child: ListView( padding: const EdgeInsets.symmetric(horizontal: 8.0, vertical: 12.0), children: contents, ), diff --git a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart index e86bacc79e..b063c2004d 100644 --- a/packages/flutter/lib/src/material/animated_icons/animated_icons.dart +++ b/packages/flutter/lib/src/material/animated_icons/animated_icons.dart @@ -97,7 +97,7 @@ class AnimatedIcon extends StatelessWidget { /// horizontally (e.g back arrow will point right). final TextDirection textDirection; - static final _UiPathFactory _pathFactory = () => new ui.Path(); + static final _UiPathFactory _pathFactory = () => ui.Path(); @override Widget build(BuildContext context) { @@ -109,11 +109,11 @@ class AnimatedIcon extends StatelessWidget { Color iconColor = color ?? iconTheme.color; if (iconOpacity != 1.0) iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); - return new Semantics( + return Semantics( label: semanticLabel, - child: new CustomPaint( - size: new Size(iconSize, iconSize), - painter: new _AnimatedIconPainter( + child: CustomPaint( + size: Size(iconSize, iconSize), + painter: _AnimatedIconPainter( paths: iconData.paths, progress: progress, color: iconColor, @@ -196,7 +196,7 @@ class _PathFrames { void paint(ui.Canvas canvas, Color color, _UiPathFactory uiPathFactory, double progress) { final double opacity = _interpolate(opacities, progress, lerpDouble); - final ui.Paint paint = new ui.Paint() + final ui.Paint paint = ui.Paint() ..style = PaintingStyle.fill ..color = color.withOpacity(color.opacity * opacity); final ui.Path path = uiPathFactory(); diff --git a/packages/flutter/lib/src/material/app.dart b/packages/flutter/lib/src/material/app.dart index cfcdc91715..a47f803f82 100644 --- a/packages/flutter/lib/src/material/app.dart +++ b/packages/flutter/lib/src/material/app.dart @@ -421,7 +421,7 @@ class MaterialApp extends StatefulWidget { final bool debugShowMaterialGrid; @override - _MaterialAppState createState() => new _MaterialAppState(); + _MaterialAppState createState() => _MaterialAppState(); } class _MaterialScrollBehavior extends ScrollBehavior { @@ -439,7 +439,7 @@ class _MaterialScrollBehavior extends ScrollBehavior { return child; case TargetPlatform.android: case TargetPlatform.fuchsia: - return new GlowingOverscrollIndicator( + return GlowingOverscrollIndicator( child: child, axisDirection: axisDirection, color: Theme.of(context).accentColor, @@ -455,7 +455,7 @@ class _MaterialAppState extends State { @override void initState() { super.initState(); - _heroController = new HeroController(createRectTween: _createRectTween); + _heroController = HeroController(createRectTween: _createRectTween); _updateNavigator(); } @@ -467,7 +467,7 @@ class _MaterialAppState extends State { // old Navigator won't be disposed (and thus won't unregister with its // observers) until after the new one has been created (because the // Navigator has a GlobalKey). - _heroController = new HeroController(createRectTween: _createRectTween); + _heroController = HeroController(createRectTween: _createRectTween); } _updateNavigator(); } @@ -480,12 +480,12 @@ class _MaterialAppState extends State { widget.routes.isNotEmpty || widget.onGenerateRoute != null || widget.onUnknownRoute != null; - _navigatorObservers = new List.from(widget.navigatorObservers) + _navigatorObservers = List.from(widget.navigatorObservers) ..add(_heroController); } RectTween _createRectTween(Rect begin, Rect end) { - return new MaterialRectArcTween(begin: begin, end: end); + return MaterialRectArcTween(begin: begin, end: end); } Route _onGenerateRoute(RouteSettings settings) { @@ -497,7 +497,7 @@ class _MaterialAppState extends State { builder = widget.routes[name]; } if (builder != null) { - return new MaterialPageRoute( + return MaterialPageRoute( builder: builder, settings: settings, ); @@ -510,7 +510,7 @@ class _MaterialAppState extends State { Route _onUnknownRoute(RouteSettings settings) { assert(() { if (widget.onUnknownRoute == null) { - throw new FlutterError( + throw FlutterError( 'Could not find a generator for route $settings in the $runtimeType.\n' 'Generators for routes are searched for in the following order:\n' ' 1. For the "/" route, the "home" property, if non-null, is used.\n' @@ -527,7 +527,7 @@ class _MaterialAppState extends State { final Route result = widget.onUnknownRoute(settings); assert(() { if (result == null) { - throw new FlutterError( + throw FlutterError( 'The onUnknownRoute callback returned null.\n' 'When the $runtimeType requested the route $settings from its ' 'onUnknownRoute callback, the callback returned null. Such callbacks ' @@ -552,12 +552,12 @@ class _MaterialAppState extends State { @override Widget build(BuildContext context) { - final ThemeData theme = widget.theme ?? new ThemeData.fallback(); - Widget result = new AnimatedTheme( + final ThemeData theme = widget.theme ?? ThemeData.fallback(); + Widget result = AnimatedTheme( data: theme, isMaterialAppTheme: true, - child: new WidgetsApp( - key: new GlobalObjectKey(this), + child: WidgetsApp( + key: GlobalObjectKey(this), navigatorKey: widget.navigatorKey, navigatorObservers: _haveNavigator ? _navigatorObservers : null, initialRoute: widget.initialRoute, @@ -579,7 +579,7 @@ class _MaterialAppState extends State { showSemanticsDebugger: widget.showSemanticsDebugger, debugShowCheckedModeBanner: widget.debugShowCheckedModeBanner, inspectorSelectButtonBuilder: (BuildContext context, VoidCallback onPressed) { - return new FloatingActionButton( + return FloatingActionButton( child: const Icon(Icons.search), onPressed: onPressed, mini: true, @@ -590,7 +590,7 @@ class _MaterialAppState extends State { assert(() { if (widget.debugShowMaterialGrid) { - result = new GridPaper( + result = GridPaper( color: const Color(0xE0F9BBE0), interval: 8.0, divisions: 2, @@ -601,8 +601,8 @@ class _MaterialAppState extends State { return true; }()); - return new ScrollConfiguration( - behavior: new _MaterialScrollBehavior(), + return ScrollConfiguration( + behavior: _MaterialScrollBehavior(), child: result, ); } diff --git a/packages/flutter/lib/src/material/app_bar.dart b/packages/flutter/lib/src/material/app_bar.dart index 89ef37bb78..94f42b5ae1 100644 --- a/packages/flutter/lib/src/material/app_bar.dart +++ b/packages/flutter/lib/src/material/app_bar.dart @@ -39,12 +39,12 @@ class _ToolbarContainerLayout extends SingleChildLayoutDelegate { @override Size getSize(BoxConstraints constraints) { - return new Size(constraints.maxWidth, kToolbarHeight); + return Size(constraints.maxWidth, kToolbarHeight); } @override Offset getPositionForChild(Size size, Size childSize) { - return new Offset(0.0, size.height - childSize.height); + return Offset(0.0, size.height - childSize.height); } @override @@ -156,7 +156,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { assert(titleSpacing != null), assert(toolbarOpacity != null), assert(bottomOpacity != null), - preferredSize = new Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)), + preferredSize = Size.fromHeight(kToolbarHeight + (bottom?.preferredSize?.height ?? 0.0)), super(key: key); /// A widget to display before the [title]. @@ -317,7 +317,7 @@ class AppBar extends StatefulWidget implements PreferredSizeWidget { } @override - _AppBarState createState() => new _AppBarState(); + _AppBarState createState() => _AppBarState(); } class _AppBarState extends State { @@ -359,7 +359,7 @@ class _AppBarState extends State { Widget leading = widget.leading; if (leading == null && widget.automaticallyImplyLeading) { if (hasDrawer) { - leading = new IconButton( + leading = IconButton( icon: const Icon(Icons.menu), onPressed: _handleDrawerButton, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip, @@ -370,7 +370,7 @@ class _AppBarState extends State { } } if (leading != null) { - leading = new ConstrainedBox( + leading = ConstrainedBox( constraints: const BoxConstraints.tightFor(width: _kLeadingWidth), child: leading, ); @@ -387,11 +387,11 @@ class _AppBarState extends State { case TargetPlatform.iOS: break; } - title = new DefaultTextStyle( + title = DefaultTextStyle( style: centerStyle, softWrap: false, overflow: TextOverflow.ellipsis, - child: new Semantics( + child: Semantics( namesRoute: namesRoute, child: title, header: true, @@ -401,20 +401,20 @@ class _AppBarState extends State { Widget actions; if (widget.actions != null && widget.actions.isNotEmpty) { - actions = new Row( + actions = Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: widget.actions, ); } else if (hasEndDrawer) { - actions = new IconButton( + actions = IconButton( icon: const Icon(Icons.menu), onPressed: _handleDrawerButtonEnd, tooltip: MaterialLocalizations.of(context).openAppDrawerTooltip, ); } - final Widget toolbar = new NavigationToolbar( + final Widget toolbar = NavigationToolbar( leading: leading, middle: title, trailing: actions, @@ -424,12 +424,12 @@ class _AppBarState extends State { // If the toolbar is allocated less than kToolbarHeight make it // appear to scroll upwards within its shrinking container. - Widget appBar = new ClipRect( - child: new CustomSingleChildLayout( + Widget appBar = ClipRect( + child: CustomSingleChildLayout( delegate: const _ToolbarContainerLayout(), child: IconTheme.merge( data: appBarIconTheme, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: sideStyle, child: toolbar, ), @@ -437,16 +437,16 @@ class _AppBarState extends State { ), ); if (widget.bottom != null) { - appBar = new Column( + appBar = Column( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new Flexible( - child: new ConstrainedBox( + Flexible( + child: ConstrainedBox( constraints: const BoxConstraints(maxHeight: kToolbarHeight), child: appBar, ), ), - widget.bottomOpacity == 1.0 ? widget.bottom : new Opacity( + widget.bottomOpacity == 1.0 ? widget.bottom : Opacity( opacity: const Interval(0.25, 1.0, curve: Curves.fastOutSlowIn).transform(widget.bottomOpacity), child: widget.bottom, ), @@ -456,19 +456,19 @@ class _AppBarState extends State { // The padding applies to the toolbar and tabbar, not the flexible space. if (widget.primary) { - appBar = new SafeArea( + appBar = SafeArea( top: true, child: appBar, ); } - appBar = new Align( + appBar = Align( alignment: Alignment.topCenter, child: appBar, ); if (widget.flexibleSpace != null) { - appBar = new Stack( + appBar = Stack( fit: StackFit.passthrough, children: [ widget.flexibleSpace, @@ -481,12 +481,12 @@ class _AppBarState extends State { ? SystemUiOverlayStyle.light : SystemUiOverlayStyle.dark; - return new Semantics( + return Semantics( container: true, explicitChildNodes: true, - child: new AnnotatedRegion( + child: AnnotatedRegion( value: overlayStyle, - child: new Material( + child: Material( color: widget.backgroundColor ?? themeData.primaryColor, elevation: widget.elevation, child: appBar, @@ -502,7 +502,7 @@ class _FloatingAppBar extends StatefulWidget { final Widget child; @override - _FloatingAppBarState createState() => new _FloatingAppBarState(); + _FloatingAppBarState createState() => _FloatingAppBarState(); } // A wrapper for the widget created by _SliverAppBarDelegate that starts and @@ -616,13 +616,13 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { maxExtent: maxExtent, currentExtent: math.max(minExtent, maxExtent - shrinkOffset), toolbarOpacity: toolbarOpacity, - child: new AppBar( + child: AppBar( leading: leading, automaticallyImplyLeading: automaticallyImplyLeading, title: title, actions: actions, flexibleSpace: (title == null && flexibleSpace != null) - ? new Semantics(child: flexibleSpace, header: true) + ? Semantics(child: flexibleSpace, header: true) : flexibleSpace, bottom: bottom, elevation: forceElevated || overlapsContent || (pinned && shrinkOffset > maxExtent - minExtent) ? elevation ?? 4.0 : 0.0, @@ -637,7 +637,7 @@ class _SliverAppBarDelegate extends SliverPersistentHeaderDelegate { bottomOpacity: pinned ? 1.0 : (visibleMainHeight / _bottomHeight).clamp(0.0, 1.0), ), ); - return floating ? new _FloatingAppBar(child: appBar) : appBar; + return floating ? _FloatingAppBar(child: appBar) : appBar; } @override @@ -931,7 +931,7 @@ class SliverAppBar extends StatefulWidget { final bool snap; @override - _SliverAppBarState createState() => new _SliverAppBarState(); + _SliverAppBarState createState() => _SliverAppBarState(); } // This class is only Stateful because it owns the TickerProvider used @@ -941,7 +941,7 @@ class _SliverAppBarState extends State with TickerProviderStateMix void _updateSnapConfiguration() { if (widget.snap && widget.floating) { - _snapConfiguration = new FloatingHeaderSnapConfiguration( + _snapConfiguration = FloatingHeaderSnapConfiguration( vsync: this, curve: Curves.easeOut, duration: const Duration(milliseconds: 200), @@ -971,13 +971,13 @@ class _SliverAppBarState extends State with TickerProviderStateMix final double collapsedHeight = (widget.pinned && widget.floating && widget.bottom != null) ? widget.bottom.preferredSize.height + topPadding : null; - return new MediaQuery.removePadding( + return MediaQuery.removePadding( context: context, removeBottom: true, - child: new SliverPersistentHeader( + child: SliverPersistentHeader( floating: widget.floating, pinned: widget.pinned, - delegate: new _SliverAppBarDelegate( + delegate: _SliverAppBarDelegate( leading: widget.leading, automaticallyImplyLeading: widget.automaticallyImplyLeading, title: widget.title, diff --git a/packages/flutter/lib/src/material/arc.dart b/packages/flutter/lib/src/material/arc.dart index bbac8c9795..be0345cb84 100644 --- a/packages/flutter/lib/src/material/arc.dart +++ b/packages/flutter/lib/src/material/arc.dart @@ -50,14 +50,14 @@ class MaterialPointArcTween extends Tween { final double deltaX = delta.dx.abs(); final double deltaY = delta.dy.abs(); final double distanceFromAtoB = delta.distance; - final Offset c = new Offset(end.dx, begin.dy); + final Offset c = Offset(end.dx, begin.dy); double sweepAngle() => 2.0 * math.asin(distanceFromAtoB / (2.0 * _radius)); if (deltaX > _kOnAxisDelta && deltaY > _kOnAxisDelta) { if (deltaX < deltaY) { _radius = distanceFromAtoB * distanceFromAtoB / (c - begin).distance / 2.0; - _center = new Offset(end.dx + _radius * (begin.dx - end.dx).sign, end.dy); + _center = Offset(end.dx + _radius * (begin.dx - end.dx).sign, end.dy); if (begin.dx < end.dx) { _beginAngle = sweepAngle() * (begin.dy - end.dy).sign; _endAngle = 0.0; @@ -67,7 +67,7 @@ class MaterialPointArcTween extends Tween { } } else { _radius = distanceFromAtoB * distanceFromAtoB / (c - end).distance / 2.0; - _center = new Offset(begin.dx, begin.dy + (end.dy - begin.dy).sign * _radius); + _center = Offset(begin.dx, begin.dy + (end.dy - begin.dy).sign * _radius); if (begin.dy < end.dy) { _beginAngle = -math.pi / 2.0; _endAngle = _beginAngle + sweepAngle() * (end.dx - begin.dx).sign; @@ -164,7 +164,7 @@ class MaterialPointArcTween extends Tween { final double angle = lerpDouble(_beginAngle, _endAngle, t); final double x = math.cos(angle) * _radius; final double y = math.sin(angle) * _radius; - return _center + new Offset(x, y); + return _center + Offset(x, y); } @override @@ -246,11 +246,11 @@ class MaterialRectArcTween extends RectTween { assert(end != null); final Offset centersVector = end.center - begin.center; final _Diagonal diagonal = _maxBy<_Diagonal>(_allDiagonals, (_Diagonal d) => _diagonalSupport(centersVector, d)); - _beginArc = new MaterialPointArcTween( + _beginArc = MaterialPointArcTween( begin: _cornerFor(begin, diagonal.beginId), end: _cornerFor(end, diagonal.beginId) ); - _endArc = new MaterialPointArcTween( + _endArc = MaterialPointArcTween( begin: _cornerFor(begin, diagonal.endId), end: _cornerFor(end, diagonal.endId) ); @@ -319,7 +319,7 @@ class MaterialRectArcTween extends RectTween { return begin; if (t == 1.0) return end; - return new Rect.fromPoints(_beginArc.lerp(t), _endArc.lerp(t)); + return Rect.fromPoints(_beginArc.lerp(t), _endArc.lerp(t)); } @override @@ -360,7 +360,7 @@ class MaterialRectCenterArcTween extends RectTween { void _initialize() { assert(begin != null); assert(end != null); - _centerArc = new MaterialPointArcTween( + _centerArc = MaterialPointArcTween( begin: begin.center, end: end.center, ); @@ -405,7 +405,7 @@ class MaterialRectCenterArcTween extends RectTween { final Offset center = _centerArc.lerp(t); final double width = lerpDouble(begin.width, end.width, t); final double height = lerpDouble(begin.height, end.height, t); - return new Rect.fromLTWH(center.dx - width / 2.0, center.dy - height / 2.0, width, height); + return Rect.fromLTWH(center.dx - width / 2.0, center.dy - height / 2.0, width, height); } @override diff --git a/packages/flutter/lib/src/material/back_button.dart b/packages/flutter/lib/src/material/back_button.dart index cef56e0e71..3a37e7512e 100644 --- a/packages/flutter/lib/src/material/back_button.dart +++ b/packages/flutter/lib/src/material/back_button.dart @@ -40,7 +40,7 @@ class BackButtonIcon extends StatelessWidget { } @override - Widget build(BuildContext context) => new Icon(_getIconData(Theme.of(context).platform)); + Widget build(BuildContext context) => Icon(_getIconData(Theme.of(context).platform)); } /// A material design back button. @@ -81,7 +81,7 @@ class BackButton extends StatelessWidget { @override Widget build(BuildContext context) { - return new IconButton( + return IconButton( icon: const BackButtonIcon(), color: color, tooltip: MaterialLocalizations.of(context).backButtonTooltip, @@ -114,7 +114,7 @@ class CloseButton extends StatelessWidget { @override Widget build(BuildContext context) { - return new IconButton( + return IconButton( icon: const Icon(Icons.close), tooltip: MaterialLocalizations.of(context).closeButtonTooltip, onPressed: () { diff --git a/packages/flutter/lib/src/material/bottom_app_bar.dart b/packages/flutter/lib/src/material/bottom_app_bar.dart index cb8c91a4f8..9a220cbf72 100644 --- a/packages/flutter/lib/src/material/bottom_app_bar.dart +++ b/packages/flutter/lib/src/material/bottom_app_bar.dart @@ -89,7 +89,7 @@ class BottomAppBar extends StatefulWidget { final double notchMargin; @override - State createState() => new _BottomAppBarState(); + State createState() => _BottomAppBarState(); } class _BottomAppBarState extends State { @@ -104,22 +104,22 @@ class _BottomAppBarState extends State { @override Widget build(BuildContext context) { final CustomClipper clipper = widget.shape != null - ? new _BottomAppBarClipper( + ? _BottomAppBarClipper( geometry: geometryListenable, shape: widget.shape, notchMargin: widget.notchMargin, ) : const ShapeBorderClipper(shape: RoundedRectangleBorder()); - return new PhysicalShape( + return PhysicalShape( clipper: clipper, elevation: widget.elevation, color: widget.color ?? Theme.of(context).bottomAppBarColor, clipBehavior: widget.clipBehavior, - child: new Material( + child: Material( type: MaterialType.transparency, child: widget.child == null ? null - : new SafeArea(child: widget.child), + : SafeArea(child: widget.child), ), ); } @@ -143,7 +143,7 @@ class _BottomAppBarClipper extends CustomClipper { Path getClip(Size size) { final Rect appBar = Offset.zero & size; if (geometry.value.floatingActionButtonArea == null) { - return new Path()..addRect(appBar); + return Path()..addRect(appBar); } // button is the floating action button's bounding rectangle in the diff --git a/packages/flutter/lib/src/material/bottom_navigation_bar.dart b/packages/flutter/lib/src/material/bottom_navigation_bar.dart index 7601e95738..c09d043337 100644 --- a/packages/flutter/lib/src/material/bottom_navigation_bar.dart +++ b/packages/flutter/lib/src/material/bottom_navigation_bar.dart @@ -132,7 +132,7 @@ class BottomNavigationBar extends StatefulWidget { final double iconSize; @override - _BottomNavigationBarState createState() => new _BottomNavigationBarState(); + _BottomNavigationBarState createState() => _BottomNavigationBarState(); } // This represents a single tile in the bottom navigation bar. It is intended @@ -174,18 +174,18 @@ class _BottomNavigationTile extends StatelessWidget { iconColor = Colors.white; break; } - return new Align( + return Align( alignment: Alignment.topCenter, heightFactor: 1.0, - child: new Container( - margin: new EdgeInsets.only( - top: new Tween( + child: Container( + margin: EdgeInsets.only( + top: Tween( begin: tweenStart, end: _kTopMargin, ).evaluate(animation), ), - child: new IconTheme( - data: new IconThemeData( + child: IconTheme( + data: IconThemeData( color: iconColor, size: iconSize, ), @@ -196,23 +196,23 @@ class _BottomNavigationTile extends StatelessWidget { } Widget _buildFixedLabel() { - return new Align( + return Align( alignment: Alignment.bottomCenter, heightFactor: 1.0, - child: new Container( + child: Container( margin: const EdgeInsets.only(bottom: _kBottomMargin), child: DefaultTextStyle.merge( - style: new TextStyle( + style: TextStyle( fontSize: _kActiveFontSize, color: colorTween.evaluate(animation), ), // The font size should grow here when active, but because of the way // font rendering works, it doesn't grow smoothly if we just animate // the font size, so we use a transform instead. - child: new Transform( - transform: new Matrix4.diagonal3( - new Vector3.all( - new Tween( + child: Transform( + transform: Matrix4.diagonal3( + Vector3.all( + Tween( begin: _kInactiveFontSize / _kActiveFontSize, end: 1.0, ).evaluate(animation), @@ -227,12 +227,12 @@ class _BottomNavigationTile extends StatelessWidget { } Widget _buildShiftingLabel() { - return new Align( + return Align( alignment: Alignment.bottomCenter, heightFactor: 1.0, - child: new Container( - margin: new EdgeInsets.only( - bottom: new Tween( + child: Container( + margin: EdgeInsets.only( + bottom: Tween( // In the spec, they just remove the label for inactive items and // specify a 16dp bottom margin. We don't want to actually remove // the label because we want to fade it in and out, so this modifies @@ -241,7 +241,7 @@ class _BottomNavigationTile extends StatelessWidget { end: _kBottomMargin, ).evaluate(animation), ), - child: new FadeTransition( + child: FadeTransition( alwaysIncludeSemantics: true, opacity: animation, child: DefaultTextStyle.merge( @@ -274,17 +274,17 @@ class _BottomNavigationTile extends StatelessWidget { label = _buildShiftingLabel(); break; } - return new Expanded( + return Expanded( flex: size, - child: new Semantics( + child: Semantics( container: true, header: true, selected: selected, - child: new Stack( + child: Stack( children: [ - new InkResponse( + InkResponse( onTap: onTap, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.center, mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, @@ -294,7 +294,7 @@ class _BottomNavigationTile extends StatelessWidget { ], ), ), - new Semantics( + Semantics( label: indexLabel, ) ], @@ -309,13 +309,13 @@ class _BottomNavigationBarState extends State with TickerPr List _animations; // A queue of color splashes currently being animated. - final Queue<_Circle> _circles = new Queue<_Circle>(); + final Queue<_Circle> _circles = Queue<_Circle>(); // Last splash circle's color, and the final color of the control after // animation is complete. Color _backgroundColor; - static final Tween _flexTween = new Tween(begin: 1.0, end: 1.5); + static final Tween _flexTween = Tween(begin: 1.0, end: 1.5); void _resetState() { for (AnimationController controller in _controllers) @@ -324,14 +324,14 @@ class _BottomNavigationBarState extends State with TickerPr circle.dispose(); _circles.clear(); - _controllers = new List.generate(widget.items.length, (int index) { - return new AnimationController( + _controllers = List.generate(widget.items.length, (int index) { + return AnimationController( duration: kThemeAnimationDuration, vsync: this, )..addListener(_rebuild); }); - _animations = new List.generate(widget.items.length, (int index) { - return new CurvedAnimation( + _animations = List.generate(widget.items.length, (int index) { + return CurvedAnimation( parent: _controllers[index], curve: Curves.fastOutSlowIn, reverseCurve: Curves.fastOutSlowIn.flipped @@ -368,7 +368,7 @@ class _BottomNavigationBarState extends State with TickerPr void _pushCircle(int index) { if (widget.items[index].backgroundColor != null) { _circles.add( - new _Circle( + _Circle( state: this, index: index, color: widget.items[index].backgroundColor, @@ -437,13 +437,13 @@ class _BottomNavigationBarState extends State with TickerPr themeColor = themeData.accentColor; break; } - final ColorTween colorTween = new ColorTween( + final ColorTween colorTween = ColorTween( begin: textTheme.caption.color, end: widget.fixedColor ?? themeColor, ); for (int i = 0; i < widget.items.length; i += 1) { children.add( - new _BottomNavigationTile( + _BottomNavigationTile( widget.type, widget.items[i], _animations[i], @@ -462,7 +462,7 @@ class _BottomNavigationBarState extends State with TickerPr case BottomNavigationBarType.shifting: for (int i = 0; i < widget.items.length; i += 1) { children.add( - new _BottomNavigationTile( + _BottomNavigationTile( widget.type, widget.items[i], _animations[i], @@ -485,7 +485,7 @@ class _BottomNavigationBarState extends State with TickerPr Widget _createContainer(List tiles) { return DefaultTextStyle.merge( overflow: TextOverflow.ellipsis, - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, children: tiles, ), @@ -506,34 +506,34 @@ class _BottomNavigationBarState extends State with TickerPr backgroundColor = _backgroundColor; break; } - return new Semantics( + return Semantics( container: true, explicitChildNodes: true, - child: new Stack( + child: Stack( children: [ - new Positioned.fill( - child: new Material( // Casts shadow. + Positioned.fill( + child: Material( // Casts shadow. elevation: 8.0, color: backgroundColor, ), ), - new ConstrainedBox( - constraints: new BoxConstraints(minHeight: kBottomNavigationBarHeight + additionalBottomPadding), - child: new Stack( + ConstrainedBox( + constraints: BoxConstraints(minHeight: kBottomNavigationBarHeight + additionalBottomPadding), + child: Stack( children: [ - new Positioned.fill( - child: new CustomPaint( - painter: new _RadialPainter( + Positioned.fill( + child: CustomPaint( + painter: _RadialPainter( circles: _circles.toList(), textDirection: Directionality.of(context), ), ), ), - new Material( // Splashes. + Material( // Splashes. type: MaterialType.transparency, - child: new Padding( - padding: new EdgeInsets.only(bottom: additionalBottomPadding), - child: new MediaQuery.removePadding( + child: Padding( + padding: EdgeInsets.only(bottom: additionalBottomPadding), + child: MediaQuery.removePadding( context: context, removeBottom: true, child: _createContainer(_createTiles()), @@ -559,11 +559,11 @@ class _Circle { }) : assert(state != null), assert(index != null), assert(color != null) { - controller = new AnimationController( + controller = AnimationController( duration: kThemeAnimationDuration, vsync: vsync, ); - animation = new CurvedAnimation( + animation = CurvedAnimation( parent: controller, curve: Curves.fastOutSlowIn ); @@ -634,8 +634,8 @@ class _RadialPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { for (_Circle circle in circles) { - final Paint paint = new Paint()..color = circle.color; - final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, size.height); + final Paint paint = Paint()..color = circle.color; + final Rect rect = Rect.fromLTWH(0.0, 0.0, size.width, size.height); canvas.clipRect(rect); double leftFraction; switch (textDirection) { @@ -646,8 +646,8 @@ class _RadialPainter extends CustomPainter { leftFraction = circle.horizontalLeadingOffset; break; } - final Offset center = new Offset(leftFraction * size.width, size.height / 2.0); - final Tween radiusTween = new Tween( + final Offset center = Offset(leftFraction * size.width, size.height / 2.0); + final Tween radiusTween = Tween( begin: 0.0, end: _maxRadius(center, size), ); diff --git a/packages/flutter/lib/src/material/bottom_sheet.dart b/packages/flutter/lib/src/material/bottom_sheet.dart index f84da1122f..9434005ffd 100644 --- a/packages/flutter/lib/src/material/bottom_sheet.dart +++ b/packages/flutter/lib/src/material/bottom_sheet.dart @@ -85,11 +85,11 @@ class BottomSheet extends StatefulWidget { final bool enableDrag; @override - _BottomSheetState createState() => new _BottomSheetState(); + _BottomSheetState createState() => _BottomSheetState(); /// Creates an animation controller suitable for controlling a [BottomSheet]. static AnimationController createAnimationController(TickerProvider vsync) { - return new AnimationController( + return AnimationController( duration: _kBottomSheetDuration, debugLabel: 'BottomSheet', vsync: vsync, @@ -99,7 +99,7 @@ class BottomSheet extends StatefulWidget { class _BottomSheetState extends State { - final GlobalKey _childKey = new GlobalKey(debugLabel: 'BottomSheet child'); + final GlobalKey _childKey = GlobalKey(debugLabel: 'BottomSheet child'); double get _childHeight { final RenderBox renderBox = _childKey.currentContext.findRenderObject(); @@ -134,11 +134,11 @@ class _BottomSheetState extends State { @override Widget build(BuildContext context) { - final Widget bottomSheet = new Material( + final Widget bottomSheet = Material( key: _childKey, child: widget.builder(context), ); - return !widget.enableDrag ? bottomSheet : new GestureDetector( + return !widget.enableDrag ? bottomSheet : GestureDetector( onVerticalDragUpdate: _handleDragUpdate, onVerticalDragEnd: _handleDragEnd, child: bottomSheet, @@ -161,7 +161,7 @@ class _ModalBottomSheetLayout extends SingleChildLayoutDelegate { @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { - return new BoxConstraints( + return BoxConstraints( minWidth: constraints.maxWidth, maxWidth: constraints.maxWidth, minHeight: 0.0, @@ -171,7 +171,7 @@ class _ModalBottomSheetLayout extends SingleChildLayoutDelegate { @override Offset getPositionForChild(Size size, Size childSize) { - return new Offset(0.0, size.height - childSize.height * progress); + return Offset(0.0, size.height - childSize.height * progress); } @override @@ -186,7 +186,7 @@ class _ModalBottomSheet extends StatefulWidget { final _ModalBottomSheetRoute route; @override - _ModalBottomSheetState createState() => new _ModalBottomSheetState(); + _ModalBottomSheetState createState() => _ModalBottomSheetState(); } class _ModalBottomSheetState extends State<_ModalBottomSheet> { @@ -205,24 +205,24 @@ class _ModalBottomSheetState extends State<_ModalBottomSheet> { break; } - return new GestureDetector( + return GestureDetector( excludeFromSemantics: true, onTap: () => Navigator.pop(context), - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: widget.route.animation, builder: (BuildContext context, Widget child) { // Disable the initial animation when accessible navigation is on so // that the semantics are added to the tree at the correct time. final double animationValue = mediaQuery.accessibleNavigation ? 1.0 : widget.route.animation.value; - return new Semantics( + return Semantics( scopesRoute: true, namesRoute: true, label: routeLabel, explicitChildNodes: true, - child: new ClipRect( - child: new CustomSingleChildLayout( - delegate: new _ModalBottomSheetLayout(animationValue), - child: new BottomSheet( + child: ClipRect( + child: CustomSingleChildLayout( + delegate: _ModalBottomSheetLayout(animationValue), + child: BottomSheet( animationController: widget.route._animationController, onClosing: () => Navigator.pop(context), builder: widget.route.builder, @@ -272,13 +272,13 @@ class _ModalBottomSheetRoute extends PopupRoute { Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { // By definition, the bottom sheet is aligned to the bottom of the page // and isn't exposed to the top padding of the MediaQuery. - Widget bottomSheet = new MediaQuery.removePadding( + Widget bottomSheet = MediaQuery.removePadding( context: context, removeTop: true, - child: new _ModalBottomSheet(route: this), + child: _ModalBottomSheet(route: this), ); if (theme != null) - bottomSheet = new Theme(data: theme, child: bottomSheet); + bottomSheet = Theme(data: theme, child: bottomSheet); return bottomSheet; } } @@ -315,7 +315,7 @@ Future showModalBottomSheet({ }) { assert(context != null); assert(builder != null); - return Navigator.push(context, new _ModalBottomSheetRoute( + return Navigator.push(context, _ModalBottomSheetRoute( builder: builder, theme: Theme.of(context, shadowThemeOnly: true), barrierLabel: MaterialLocalizations.of(context).modalBarrierDismissLabel, diff --git a/packages/flutter/lib/src/material/button.dart b/packages/flutter/lib/src/material/button.dart index 712bea27d9..d3c75d9ea4 100644 --- a/packages/flutter/lib/src/material/button.dart +++ b/packages/flutter/lib/src/material/button.dart @@ -154,7 +154,7 @@ class RawMaterialButton extends StatefulWidget { final Clip clipBehavior; @override - _RawMaterialButtonState createState() => new _RawMaterialButtonState(); + _RawMaterialButtonState createState() => _RawMaterialButtonState(); } class _RawMaterialButtonState extends State { @@ -173,9 +173,9 @@ class _RawMaterialButtonState extends State { ? (_highlight ? widget.highlightElevation : widget.elevation) : widget.disabledElevation; - final Widget result = new ConstrainedBox( + final Widget result = ConstrainedBox( constraints: widget.constraints, - child: new Material( + child: Material( elevation: elevation, textStyle: widget.textStyle, shape: widget.shape, @@ -183,17 +183,17 @@ class _RawMaterialButtonState extends State { type: widget.fillColor == null ? MaterialType.transparency : MaterialType.button, animationDuration: widget.animationDuration, clipBehavior: widget.clipBehavior, - child: new InkWell( + child: InkWell( onHighlightChanged: _handleHighlightChanged, splashColor: widget.splashColor, highlightColor: widget.highlightColor, onTap: widget.onPressed, customBorder: widget.shape, child: IconTheme.merge( - data: new IconThemeData(color: widget.textStyle?.color), - child: new Container( + data: IconThemeData(color: widget.textStyle?.color), + child: Container( padding: widget.padding, - child: new Center( + child: Center( widthFactor: 1.0, heightFactor: 1.0, child: widget.child, @@ -213,11 +213,11 @@ class _RawMaterialButtonState extends State { break; } - return new Semantics( + return Semantics( container: true, button: true, enabled: widget.enabled, - child: new _InputPadding( + child: _InputPadding( minSize: minSize, child: result, ), @@ -430,7 +430,7 @@ class MaterialButton extends StatelessWidget { final ButtonThemeData buttonTheme = ButtonTheme.of(context); final Color textColor = _getTextColor(theme, buttonTheme, color); - return new RawMaterialButton( + return RawMaterialButton( onPressed: onPressed, fillColor: color, textStyle: theme.textTheme.button.copyWith(color: textColor), @@ -453,7 +453,7 @@ class MaterialButton extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); + properties.add(FlagProperty('enabled', value: enabled, ifFalse: 'disabled')); } } @@ -473,7 +473,7 @@ class _InputPadding extends SingleChildRenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderInputPadding(minSize); + return _RenderInputPadding(minSize); } @override @@ -528,7 +528,7 @@ class _RenderInputPadding extends RenderShiftedBox { child.layout(constraints, parentUsesSize: true); final double height = math.max(child.size.width, minSize.width); final double width = math.max(child.size.height, minSize.height); - size = constraints.constrain(new Size(height, width)); + size = constraints.constrain(Size(height, width)); final BoxParentData childParentData = child.parentData; childParentData.offset = Alignment.center.alongOffset(size - child.size); } else { diff --git a/packages/flutter/lib/src/material/button_bar.dart b/packages/flutter/lib/src/material/button_bar.dart index 45e902ebce..f4a3af3c86 100644 --- a/packages/flutter/lib/src/material/button_bar.dart +++ b/packages/flutter/lib/src/material/button_bar.dart @@ -49,17 +49,17 @@ class ButtonBar extends StatelessWidget { Widget build(BuildContext context) { // We divide by 4.0 because we want half of the average of the left and right padding. final double paddingUnit = ButtonTheme.of(context).padding.horizontal / 4.0; - return new Padding( - padding: new EdgeInsets.symmetric( + return Padding( + padding: EdgeInsets.symmetric( vertical: 2.0 * paddingUnit, horizontal: paddingUnit ), - child: new Row( + child: Row( mainAxisAlignment: alignment, mainAxisSize: mainAxisSize, children: children.map((Widget child) { - return new Padding( - padding: new EdgeInsets.symmetric(horizontal: paddingUnit), + return Padding( + padding: EdgeInsets.symmetric(horizontal: paddingUnit), child: child ); }).toList() diff --git a/packages/flutter/lib/src/material/button_theme.dart b/packages/flutter/lib/src/material/button_theme.dart index 6ae76f213c..51e52b15fc 100644 --- a/packages/flutter/lib/src/material/button_theme.dart +++ b/packages/flutter/lib/src/material/button_theme.dart @@ -70,7 +70,7 @@ class ButtonTheme extends InheritedWidget { assert(minWidth != null && minWidth >= 0.0), assert(height != null && height >= 0.0), assert(alignedDropdown != null), - data = new ButtonThemeData( + data = ButtonThemeData( textTheme: textTheme, minWidth: minWidth, height: height, @@ -117,7 +117,7 @@ class ButtonTheme extends InheritedWidget { assert(minWidth != null && minWidth >= 0.0), assert(height != null && height >= 0.0), assert(alignedDropdown != null), - data = new ButtonThemeData( + data = ButtonThemeData( textTheme: textTheme, minWidth: minWidth, height: height, @@ -196,7 +196,7 @@ class ButtonThemeData extends Diagnosticable { /// ); /// ``` BoxConstraints get constraints { - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth, minHeight: height, ); @@ -268,7 +268,7 @@ class ButtonThemeData extends Diagnosticable { ShapeBorder shape, bool alignedDropdown, }) { - return new ButtonThemeData( + return ButtonThemeData( textTheme: textTheme ?? this.textTheme, minWidth: minWidth ?? this.minWidth, height: height ?? this.height, @@ -307,12 +307,12 @@ class ButtonThemeData extends Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); const ButtonThemeData defaultTheme = ButtonThemeData(); - properties.add(new EnumProperty('textTheme', textTheme, defaultValue: defaultTheme.textTheme)); - properties.add(new DoubleProperty('minWidth', minWidth, defaultValue: defaultTheme.minWidth)); - properties.add(new DoubleProperty('height', height, defaultValue: defaultTheme.height)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: defaultTheme.padding)); - properties.add(new DiagnosticsProperty('shape', shape, defaultValue: defaultTheme.shape)); - properties.add(new FlagProperty('alignedDropdown', + properties.add(EnumProperty('textTheme', textTheme, defaultValue: defaultTheme.textTheme)); + properties.add(DoubleProperty('minWidth', minWidth, defaultValue: defaultTheme.minWidth)); + properties.add(DoubleProperty('height', height, defaultValue: defaultTheme.height)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: defaultTheme.padding)); + properties.add(DiagnosticsProperty('shape', shape, defaultValue: defaultTheme.shape)); + properties.add(FlagProperty('alignedDropdown', value: alignedDropdown, defaultValue: defaultTheme.alignedDropdown, ifTrue: 'dropdown width matches button', diff --git a/packages/flutter/lib/src/material/card.dart b/packages/flutter/lib/src/material/card.dart index cce955a449..ff70e74298 100644 --- a/packages/flutter/lib/src/material/card.dart +++ b/packages/flutter/lib/src/material/card.dart @@ -127,12 +127,12 @@ class Card extends StatelessWidget { @override Widget build(BuildContext context) { - return new Semantics( + return Semantics( container: semanticContainer, explicitChildNodes: !semanticContainer, - child: new Container( + child: Container( margin: margin ?? const EdgeInsets.all(4.0), - child: new Material( + child: Material( type: MaterialType.card, color: color ?? Theme.of(context).cardColor, elevation: elevation ?? 1.0, diff --git a/packages/flutter/lib/src/material/checkbox.dart b/packages/flutter/lib/src/material/checkbox.dart index ca116ad47f..2f4b33bfd4 100644 --- a/packages/flutter/lib/src/material/checkbox.dart +++ b/packages/flutter/lib/src/material/checkbox.dart @@ -128,7 +128,7 @@ class Checkbox extends StatefulWidget { static const double width = 18.0; @override - _CheckboxState createState() => new _CheckboxState(); + _CheckboxState createState() => _CheckboxState(); } class _CheckboxState extends State with TickerProviderStateMixin { @@ -145,8 +145,8 @@ class _CheckboxState extends State with TickerProviderStateMixin { size = const Size(2 * kRadialReactionRadius, 2 * kRadialReactionRadius); break; } - final BoxConstraints additionalConstraints = new BoxConstraints.tight(size); - return new _CheckboxRenderObjectWidget( + final BoxConstraints additionalConstraints = BoxConstraints.tight(size); + return _CheckboxRenderObjectWidget( value: widget.value, tristate: widget.tristate, activeColor: widget.activeColor ?? themeData.toggleableActiveColor, @@ -184,7 +184,7 @@ class _CheckboxRenderObjectWidget extends LeafRenderObjectWidget { final BoxConstraints additionalConstraints; @override - _RenderCheckbox createRenderObject(BuildContext context) => new _RenderCheckbox( + _RenderCheckbox createRenderObject(BuildContext context) => _RenderCheckbox( value: value, tristate: tristate, activeColor: activeColor, @@ -254,8 +254,8 @@ class _RenderCheckbox extends RenderToggleable { RRect _outerRectAt(Offset origin, double t) { final double inset = 1.0 - (t - 0.5).abs() * 2.0; final double size = _kEdgeSize - inset * _kStrokeWidth; - final Rect rect = new Rect.fromLTWH(origin.dx + inset, origin.dy + inset, size, size); - return new RRect.fromRectAndRadius(rect, _kEdgeRadius); + final Rect rect = Rect.fromLTWH(origin.dx + inset, origin.dy + inset, size, size); + return RRect.fromRectAndRadius(rect, _kEdgeRadius); } // The checkbox's border color if value == false, or its fill color when @@ -287,7 +287,7 @@ class _RenderCheckbox extends RenderToggleable { assert(t >= 0.0 && t <= 1.0); // As t goes from 0.0 to 1.0, animate the two check mark strokes from the // short side to the long side. - final Path path = new Path(); + final Path path = Path(); const Offset start = Offset(_kEdgeSize * 0.15, _kEdgeSize * 0.45); const Offset mid = Offset(_kEdgeSize * 0.4, _kEdgeSize * 0.7); const Offset end = Offset(_kEdgeSize * 0.85, _kEdgeSize * 0.25); @@ -333,7 +333,7 @@ class _RenderCheckbox extends RenderToggleable { if (_oldValue == false || value == false) { final double t = value == false ? 1.0 - tNormalized : tNormalized; final RRect outer = _outerRectAt(origin, t); - final Paint paint = new Paint()..color = _colorAt(t); + final Paint paint = Paint()..color = _colorAt(t); if (t <= 0.5) { _drawBorder(canvas, outer, t, paint); @@ -349,7 +349,7 @@ class _RenderCheckbox extends RenderToggleable { } } else { // Two cases: null to true, true to null final RRect outer = _outerRectAt(origin, 1.0); - final Paint paint = new Paint() ..color = _colorAt(1.0); + final Paint paint = Paint() ..color = _colorAt(1.0); canvas.drawRRect(outer, paint); _initStrokePaint(paint); diff --git a/packages/flutter/lib/src/material/checkbox_list_tile.dart b/packages/flutter/lib/src/material/checkbox_list_tile.dart index fdb6ae5131..3ce24171cf 100644 --- a/packages/flutter/lib/src/material/checkbox_list_tile.dart +++ b/packages/flutter/lib/src/material/checkbox_list_tile.dart @@ -170,7 +170,7 @@ class CheckboxListTile extends StatelessWidget { @override Widget build(BuildContext context) { - final Widget control = new Checkbox( + final Widget control = Checkbox( value: value, onChanged: onChanged, activeColor: activeColor, @@ -188,10 +188,10 @@ class CheckboxListTile extends StatelessWidget { trailing = control; break; } - return new MergeSemantics( + return MergeSemantics( child: ListTileTheme.merge( selectedColor: activeColor ?? Theme.of(context).accentColor, - child: new ListTile( + child: ListTile( leading: leading, title: title, subtitle: subtitle, diff --git a/packages/flutter/lib/src/material/chip.dart b/packages/flutter/lib/src/material/chip.dart index 741cca209b..4dc9a151cf 100644 --- a/packages/flutter/lib/src/material/chip.dart +++ b/packages/flutter/lib/src/material/chip.dart @@ -472,7 +472,7 @@ class Chip extends StatelessWidget implements ChipAttributes, DeletableChipAttri @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - return new RawChip( + return RawChip( avatar: avatar, label: label, labelStyle: labelStyle, @@ -622,7 +622,7 @@ class InputChip extends StatelessWidget @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - return new RawChip( + return RawChip( avatar: avatar, label: label, labelStyle: labelStyle, @@ -764,7 +764,7 @@ class ChoiceChip extends StatelessWidget Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); final ChipThemeData chipTheme = ChipTheme.of(context); - return new RawChip( + return RawChip( avatar: avatar, label: label, labelStyle: labelStyle ?? (selected ? chipTheme.secondaryLabelStyle : null), @@ -935,7 +935,7 @@ class FilterChip extends StatelessWidget @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - return new RawChip( + return RawChip( avatar: avatar, label: label, labelStyle: labelStyle, @@ -1052,7 +1052,7 @@ class ActionChip extends StatelessWidget implements ChipAttributes, TappableChip @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - return new RawChip( + return RawChip( avatar: avatar, label: label, onPressed: onPressed, @@ -1202,7 +1202,7 @@ class RawChip extends StatefulWidget final bool tapEnabled; @override - _RawChipState createState() => new _RawChipState(); + _RawChipState createState() => _RawChipState(); } class _RawChipState extends State with TickerProviderStateMixin { @@ -1218,7 +1218,7 @@ class _RawChipState extends State with TickerProviderStateMixin enableAnimation; Animation selectionFade; - static final Tween pressedShadowTween = new Tween( + static final Tween pressedShadowTween = Tween( begin: 0.0, end: _kPressElevation, ); @@ -1238,26 +1238,26 @@ class _RawChipState extends State with TickerProviderStateMixin with TickerProviderStateMixin with TickerProviderStateMixin with TickerProviderStateMixin with TickerProviderStateMixin with TickerProviderStateMixin[selectController, enableController]), + child: AnimatedBuilder( + animation: Listenable.merge([selectController, enableController]), builder: (BuildContext context, Widget child) { - return new Container( - decoration: new ShapeDecoration( + return Container( + decoration: ShapeDecoration( shape: shape, color: getBackgroundColor(chipTheme), ), @@ -1456,9 +1456,9 @@ class _RawChipState extends State with TickerProviderStateMixin with TickerProviderStateMixin with TickerProviderStateMixin enableAnimation; @override - _RenderChipElement createElement() => new _RenderChipElement(this); + _RenderChipElement createElement() => _RenderChipElement(this); @override void updateRenderObject(BuildContext context, _RenderChip renderObject) { @@ -1598,7 +1598,7 @@ class _ChipRenderWidget extends RenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new _RenderChip( + return _RenderChip( theme: theme, textDirection: Directionality.of(context), value: value, @@ -2005,7 +2005,7 @@ class _RenderChip extends RenderBox { ); } else { label.layout( - new BoxConstraints( + BoxConstraints( minHeight: rawSize.height, maxHeight: size.height, minWidth: 0.0, @@ -2014,7 +2014,7 @@ class _RenderChip extends RenderBox { parentUsesSize: true, ); } - return new Size( + return Size( rawSize.width + theme.labelPadding.horizontal, rawSize.height + theme.labelPadding.vertical, ); @@ -2022,13 +2022,13 @@ class _RenderChip extends RenderBox { Size _layoutAvatar(BoxConstraints contentConstraints, double contentSize) { final double requestedSize = math.max(0.0, contentSize); - final BoxConstraints avatarConstraints = new BoxConstraints.tightFor( + final BoxConstraints avatarConstraints = BoxConstraints.tightFor( width: requestedSize, height: requestedSize, ); avatar.layout(avatarConstraints, parentUsesSize: true); if (!theme.showCheckmark && !theme.showAvatar) { - return new Size(0.0, contentSize); + return Size(0.0, contentSize); } double avatarWidth = 0.0; double avatarHeight = 0.0; @@ -2039,25 +2039,25 @@ class _RenderChip extends RenderBox { avatarWidth += avatarDrawerAnimation.value * contentSize; } avatarHeight += avatarBoxSize.height; - return new Size(avatarWidth, avatarHeight); + return Size(avatarWidth, avatarHeight); } Size _layoutDeleteIcon(BoxConstraints contentConstraints, double contentSize) { final double requestedSize = math.max(0.0, contentSize); - final BoxConstraints deleteIconConstraints = new BoxConstraints.tightFor( + final BoxConstraints deleteIconConstraints = BoxConstraints.tightFor( width: requestedSize, height: requestedSize, ); deleteIcon.layout(deleteIconConstraints, parentUsesSize: true); if (!deleteIconShowing) { - return new Size(0.0, contentSize); + return Size(0.0, contentSize); } double deleteIconWidth = 0.0; double deleteIconHeight = 0.0; final Size boxSize = _boxSize(deleteIcon); deleteIconWidth += deleteDrawerAnimation.value * boxSize.width; deleteIconHeight += boxSize.height; - return new Size(deleteIconWidth, deleteIconHeight); + return Size(deleteIconWidth, deleteIconHeight); } @override @@ -2093,12 +2093,12 @@ class _RenderChip extends RenderBox { ); final Size avatarSize = _layoutAvatar(contentConstraints, contentSize); final Size deleteIconSize = _layoutDeleteIcon(contentConstraints, contentSize); - Size labelSize = new Size(_boxSize(label).width, contentSize); + Size labelSize = Size(_boxSize(label).width, contentSize); labelSize = _layoutLabel(avatarSize.width + deleteIconSize.width, labelSize); // This is the overall size of the content: it doesn't include // theme.padding, that is added in at the end. - final Size overallSize = new Size( + final Size overallSize = Size( avatarSize.width + labelSize.width + deleteIconSize.width, contentSize, ); @@ -2113,10 +2113,10 @@ class _RenderChip extends RenderBox { Offset boxOffset; switch (textDirection) { case TextDirection.rtl: - boxOffset = new Offset(x - boxSize.width, (contentSize - boxSize.height) / 2.0); + boxOffset = Offset(x - boxSize.width, (contentSize - boxSize.height) / 2.0); break; case TextDirection.ltr: - boxOffset = new Offset(x, (contentSize - boxSize.height) / 2.0); + boxOffset = Offset(x, (contentSize - boxSize.height) / 2.0); break; } return boxOffset; @@ -2138,7 +2138,7 @@ class _RenderChip extends RenderBox { labelOffset = centerLayout(labelSize, start); start -= labelSize.width; if (deleteIconShowing) { - deleteButtonRect = new Rect.fromLTWH( + deleteButtonRect = Rect.fromLTWH( 0.0, 0.0, deleteIconSize.width + theme.padding.right, @@ -2150,7 +2150,7 @@ class _RenderChip extends RenderBox { } start -= deleteIconSize.width; if (theme.canTapBody) { - pressRect = new Rect.fromLTWH( + pressRect = Rect.fromLTWH( deleteButtonRect.width, 0.0, overallSize.width - deleteButtonRect.width + theme.padding.horizontal, @@ -2169,7 +2169,7 @@ class _RenderChip extends RenderBox { labelOffset = centerLayout(labelSize, start); start += labelSize.width; if (theme.canTapBody) { - pressRect = new Rect.fromLTWH( + pressRect = Rect.fromLTWH( 0.0, 0.0, deleteIconShowing @@ -2183,7 +2183,7 @@ class _RenderChip extends RenderBox { start -= _boxSize(deleteIcon).width - deleteIconSize.width; if (deleteIconShowing) { deleteIconOffset = centerLayout(deleteIconSize, start); - deleteButtonRect = new Rect.fromLTWH( + deleteButtonRect = Rect.fromLTWH( start + theme.padding.left, 0.0, deleteIconSize.width + theme.padding.right, @@ -2196,14 +2196,14 @@ class _RenderChip extends RenderBox { } // Center the label vertically. labelOffset = labelOffset + - new Offset( + Offset( 0.0, ((labelSize.height - theme.labelPadding.vertical) - _boxSize(label).height) / 2.0, ); _boxParentData(avatar).offset = theme.padding.topLeft + avatarOffset; _boxParentData(label).offset = theme.padding.topLeft + labelOffset + theme.labelPadding.topLeft; _boxParentData(deleteIcon).offset = theme.padding.topLeft + deleteIconOffset; - final Size paddedSize = new Size( + final Size paddedSize = Size( overallSize.width + theme.padding.horizontal, overallSize.height + theme.padding.vertical, ); @@ -2218,7 +2218,7 @@ class _RenderChip extends RenderBox { '${constraints.constrainWidth(paddedSize.width)}'); } - static final ColorTween selectionScrimTween = new ColorTween( + static final ColorTween selectionScrimTween = ColorTween( begin: Colors.transparent, end: _kSelectScrimColor, ); @@ -2230,13 +2230,13 @@ class _RenderChip extends RenderBox { ColorTween enableTween; switch (theme.brightness) { case Brightness.light: - enableTween = new ColorTween( + enableTween = ColorTween( begin: Colors.white.withAlpha(_kDisabledAlpha), end: Colors.white, ); break; case Brightness.dark: - enableTween = new ColorTween( + enableTween = ColorTween( begin: Colors.black.withAlpha(_kDisabledAlpha), end: Colors.black, ); @@ -2256,13 +2256,13 @@ class _RenderChip extends RenderBox { break; } - final ColorTween fadeTween = new ColorTween(begin: Colors.transparent, end: paintColor); + final ColorTween fadeTween = ColorTween(begin: Colors.transparent, end: paintColor); paintColor = checkmarkAnimation.status == AnimationStatus.reverse ? fadeTween.evaluate(checkmarkAnimation) : paintColor; - final Paint paint = new Paint() + final Paint paint = Paint() ..color = paintColor ..style = PaintingStyle.stroke ..strokeWidth = _kCheckmarkStrokeWidth * (avatar != null ? avatar.size.height / 24.0 : 1.0); @@ -2276,10 +2276,10 @@ class _RenderChip extends RenderBox { assert(t > 0.0 && t <= 1.0); // As t goes from 0.0 to 1.0, animate the two check mark strokes from the // short side to the long side. - final Path path = new Path(); - final Offset start = new Offset(size * 0.15, size * 0.45); - final Offset mid = new Offset(size * 0.4, size * 0.7); - final Offset end = new Offset(size * 0.85, size * 0.25); + final Path path = Path(); + final Offset start = Offset(size * 0.15, size * 0.45); + final Offset mid = Offset(size * 0.4, size * 0.7); + final Offset end = Offset(size * 0.85, size * 0.25); if (t < 0.5) { final double strokeT = t * 2.0; final Offset drawMid = Offset.lerp(start, mid, strokeT); @@ -2299,7 +2299,7 @@ class _RenderChip extends RenderBox { if (isDrawingCheckmark) { if (theme.showAvatar) { final Rect avatarRect = _boxRect(avatar).shift(offset); - final Paint darkenPaint = new Paint() + final Paint darkenPaint = Paint() ..color = selectionScrimTween.evaluate(checkmarkAnimation) ..blendMode = BlendMode.srcATop; context.canvas.drawRect(avatarRect, darkenPaint); @@ -2307,7 +2307,7 @@ class _RenderChip extends RenderBox { // Need to make the check mark be a little smaller than the avatar. final double checkSize = avatar.size.height * 0.75; final Offset checkOffset = _boxParentData(avatar).offset + - new Offset(avatar.size.height * 0.125, avatar.size.height * 0.125); + Offset(avatar.size.height * 0.125, avatar.size.height * 0.125); _paintCheck(context.canvas, offset + checkOffset, checkSize); } } @@ -2324,12 +2324,12 @@ class _RenderChip extends RenderBox { final Color disabledColor = _disabledColor; final int disabledColorAlpha = disabledColor.alpha; if (needsCompositing) { - context.pushLayer(new OpacityLayer(alpha: disabledColorAlpha), paintWithOverlay, offset); + context.pushLayer(OpacityLayer(alpha: disabledColorAlpha), paintWithOverlay, offset); } else { if (disabledColorAlpha != 0xff) { context.canvas.saveLayer( _boxRect(avatar).shift(offset).inflate(20.0), - new Paint()..color = disabledColor, + Paint()..color = disabledColor, ); } paintWithOverlay(context, offset); @@ -2347,7 +2347,7 @@ class _RenderChip extends RenderBox { if (!enableAnimation.isCompleted) { if (needsCompositing) { context.pushLayer( - new OpacityLayer(alpha: disabledColorAlpha), + OpacityLayer(alpha: disabledColorAlpha), (PaintingContext context, Offset offset) { context.paintChild(child, _boxParentData(child).offset + offset); }, @@ -2355,7 +2355,7 @@ class _RenderChip extends RenderBox { ); } else { final Rect childRect = _boxRect(child).shift(offset); - context.canvas.saveLayer(childRect.inflate(20.0), new Paint()..color = _disabledColor); + context.canvas.saveLayer(childRect.inflate(20.0), Paint()..color = _disabledColor); context.paintChild(child, _boxParentData(child).offset + offset); context.canvas.restore(); } @@ -2383,7 +2383,7 @@ class _RenderChip extends RenderBox { () { // Draws a rect around the tap targets to help with visualizing where // they really are. - final Paint outlinePaint = new Paint() + final Paint outlinePaint = Paint() ..color = const Color(0xff800000) ..strokeWidth = 1.0 ..style = PaintingStyle.stroke; diff --git a/packages/flutter/lib/src/material/chip_theme.dart b/packages/flutter/lib/src/material/chip_theme.dart index 1eb85580ba..777439e889 100644 --- a/packages/flutter/lib/src/material/chip_theme.dart +++ b/packages/flutter/lib/src/material/chip_theme.dart @@ -243,7 +243,7 @@ class ChipThemeData extends Diagnosticable { ); labelStyle = labelStyle.copyWith(color: primaryColor.withAlpha(textLabelAlpha)); - return new ChipThemeData( + return ChipThemeData( backgroundColor: backgroundColor, deleteIconColor: deleteIconColor, disabledColor: disabledColor, @@ -341,7 +341,7 @@ class ChipThemeData extends Diagnosticable { TextStyle secondaryLabelStyle, Brightness brightness, }) { - return new ChipThemeData( + return ChipThemeData( backgroundColor: backgroundColor ?? this.backgroundColor, deleteIconColor: deleteIconColor ?? this.deleteIconColor, disabledColor: disabledColor ?? this.disabledColor, @@ -375,7 +375,7 @@ class ChipThemeData extends Diagnosticable { assert(t != null); if (a == null && b == null) return null; - return new ChipThemeData( + return ChipThemeData( backgroundColor: Color.lerp(a?.backgroundColor, b?.backgroundColor, t), deleteIconColor: Color.lerp(a?.deleteIconColor, b?.deleteIconColor, t), disabledColor: Color.lerp(a?.disabledColor, b?.disabledColor, t), @@ -432,22 +432,22 @@ class ChipThemeData extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - final ThemeData defaultTheme = new ThemeData.fallback(); - final ChipThemeData defaultData = new ChipThemeData.fromDefaults( + final ThemeData defaultTheme = ThemeData.fallback(); + final ChipThemeData defaultData = ChipThemeData.fromDefaults( secondaryColor: defaultTheme.primaryColor, brightness: defaultTheme.brightness, labelStyle: defaultTheme.textTheme.body2, ); - properties.add(new DiagnosticsProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor)); - properties.add(new DiagnosticsProperty('deleteIconColor', deleteIconColor, defaultValue: defaultData.deleteIconColor)); - properties.add(new DiagnosticsProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor)); - properties.add(new DiagnosticsProperty('selectedColor', selectedColor, defaultValue: defaultData.selectedColor)); - properties.add(new DiagnosticsProperty('secondarySelectedColor', secondarySelectedColor, defaultValue: defaultData.secondarySelectedColor)); - properties.add(new DiagnosticsProperty('labelPadding', labelPadding, defaultValue: defaultData.labelPadding)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: defaultData.padding)); - properties.add(new DiagnosticsProperty('shape', shape, defaultValue: defaultData.shape)); - properties.add(new DiagnosticsProperty('labelStyle', labelStyle, defaultValue: defaultData.labelStyle)); - properties.add(new DiagnosticsProperty('secondaryLabelStyle', secondaryLabelStyle, defaultValue: defaultData.secondaryLabelStyle)); - properties.add(new EnumProperty('brightness', brightness, defaultValue: defaultData.brightness)); + properties.add(DiagnosticsProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor)); + properties.add(DiagnosticsProperty('deleteIconColor', deleteIconColor, defaultValue: defaultData.deleteIconColor)); + properties.add(DiagnosticsProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor)); + properties.add(DiagnosticsProperty('selectedColor', selectedColor, defaultValue: defaultData.selectedColor)); + properties.add(DiagnosticsProperty('secondarySelectedColor', secondarySelectedColor, defaultValue: defaultData.secondarySelectedColor)); + properties.add(DiagnosticsProperty('labelPadding', labelPadding, defaultValue: defaultData.labelPadding)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: defaultData.padding)); + properties.add(DiagnosticsProperty('shape', shape, defaultValue: defaultData.shape)); + properties.add(DiagnosticsProperty('labelStyle', labelStyle, defaultValue: defaultData.labelStyle)); + properties.add(DiagnosticsProperty('secondaryLabelStyle', secondaryLabelStyle, defaultValue: defaultData.secondaryLabelStyle)); + properties.add(EnumProperty('brightness', brightness, defaultValue: defaultData.brightness)); } } diff --git a/packages/flutter/lib/src/material/circle_avatar.dart b/packages/flutter/lib/src/material/circle_avatar.dart index 5d907627e4..0f64540965 100644 --- a/packages/flutter/lib/src/material/circle_avatar.dart +++ b/packages/flutter/lib/src/material/circle_avatar.dart @@ -169,31 +169,31 @@ class CircleAvatar extends StatelessWidget { } final double minDiameter = _minDiameter; final double maxDiameter = _maxDiameter; - return new AnimatedContainer( - constraints: new BoxConstraints( + return AnimatedContainer( + constraints: BoxConstraints( minHeight: minDiameter, minWidth: minDiameter, maxWidth: maxDiameter, maxHeight: maxDiameter, ), duration: kThemeChangeDuration, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: effectiveBackgroundColor, image: backgroundImage != null - ? new DecorationImage(image: backgroundImage, fit: BoxFit.cover) + ? DecorationImage(image: backgroundImage, fit: BoxFit.cover) : null, shape: BoxShape.circle, ), child: child == null ? null - : new Center( - child: new MediaQuery( + : Center( + child: MediaQuery( // Need to ignore the ambient textScaleFactor here so that the // text doesn't escape the avatar when the textScaleFactor is large. data: MediaQuery.of(context).copyWith(textScaleFactor: 1.0), - child: new IconTheme( + child: IconTheme( data: theme.iconTheme.copyWith(color: textStyle.color), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: textStyle, child: child, ), diff --git a/packages/flutter/lib/src/material/data_table.dart b/packages/flutter/lib/src/material/data_table.dart index e690528114..67e508a647 100644 --- a/packages/flutter/lib/src/material/data_table.dart +++ b/packages/flutter/lib/src/material/data_table.dart @@ -102,7 +102,7 @@ class DataRow { this.onSelectChanged, @required this.cells, }) : assert(cells != null), - key = new ValueKey(index); + key = ValueKey(index); /// A [Key] that uniquely identifies this row. This is used to /// ensure that if a row is added or removed, any stateful widgets @@ -169,7 +169,7 @@ class DataCell { }) : assert(child != null); /// A cell that has no content and has zero width and height. - static final DataCell empty = new DataCell(new Container(width: 0.0, height: 0.0)); + static final DataCell empty = DataCell(Container(width: 0.0, height: 0.0)); /// The data for the row. /// @@ -335,7 +335,7 @@ class DataTable extends StatelessWidget { || rows.any((DataRow row) => row._debugInteractive); } - static final LocalKey _headingRowKey = new UniqueKey(); + static final LocalKey _headingRowKey = UniqueKey(); void _handleSelectAll(bool checked) { if (onSelectAll != null) { @@ -364,12 +364,12 @@ class DataTable extends StatelessWidget { VoidCallback onRowTap, ValueChanged onCheckboxChanged }) { - Widget contents = new Semantics( + Widget contents = Semantics( container: true, - child: new Padding( + child: Padding( padding: const EdgeInsetsDirectional.only(start: _tablePadding, end: _tablePadding / 2.0), - child: new Center( - child: new Checkbox( + child: Center( + child: Checkbox( activeColor: color, value: checked, onChanged: onCheckboxChanged, @@ -378,12 +378,12 @@ class DataTable extends StatelessWidget { ), ); if (onRowTap != null) { - contents = new TableRowInkWell( + contents = TableRowInkWell( onTap: onRowTap, child: contents, ); } - return new TableCell( + return TableCell( verticalAlignment: TableCellVerticalAlignment.fill, child: contents, ); @@ -400,23 +400,23 @@ class DataTable extends StatelessWidget { bool ascending, }) { if (onSort != null) { - final Widget arrow = new _SortArrow( + final Widget arrow = _SortArrow( visible: sorted, down: sorted ? ascending : null, duration: _sortArrowAnimationDuration, ); const Widget arrowPadding = SizedBox(width: _sortArrowPadding); - label = new Row( + label = Row( textDirection: numeric ? TextDirection.rtl : null, children: [ label, arrowPadding, arrow ], ); } - label = new Container( + label = Container( padding: padding, height: _headingRowHeight, alignment: numeric ? Alignment.centerRight : AlignmentDirectional.centerStart, - child: new AnimatedDefaultTextStyle( - style: new TextStyle( + child: AnimatedDefaultTextStyle( + style: TextStyle( // TODO(ianh): font family should match Theme; see https://github.com/flutter/flutter/issues/3116 fontWeight: FontWeight.w500, fontSize: _headingFontSize, @@ -431,13 +431,13 @@ class DataTable extends StatelessWidget { ), ); if (tooltip != null) { - label = new Tooltip( + label = Tooltip( message: tooltip, child: label, ); } if (onSort != null) { - label = new InkWell( + label = InkWell( onTap: onSort, child: label, ); @@ -458,18 +458,18 @@ class DataTable extends StatelessWidget { final bool isLightTheme = Theme.of(context).brightness == Brightness.light; if (showEditIcon) { const Widget icon = Icon(Icons.edit, size: 18.0); - label = new Expanded(child: label); - label = new Row( + label = Expanded(child: label); + label = Row( textDirection: numeric ? TextDirection.rtl : null, children: [ label, icon ], ); } - label = new Container( + label = Container( padding: padding, height: _dataRowHeight, alignment: numeric ? Alignment.centerRight : AlignmentDirectional.centerStart, - child: new DefaultTextStyle( - style: new TextStyle( + child: DefaultTextStyle( + style: TextStyle( // TODO(ianh): font family should be Roboto; see https://github.com/flutter/flutter/issues/3116 fontSize: 13.0, color: isLightTheme @@ -477,20 +477,20 @@ class DataTable extends StatelessWidget { : (placeholder ? Colors.white30 : Colors.white70), ), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: isLightTheme ? Colors.black54 : Colors.white70, ), - child: new DropdownButtonHideUnderline(child: label), + child: DropdownButtonHideUnderline(child: label), ) ) ); if (onTap != null) { - label = new InkWell( + label = InkWell( onTap: onTap, child: label, ); } else if (onSelectChanged != null) { - label = new TableRowInkWell( + label = TableRowInkWell( onTap: onSelectChanged, child: label, ); @@ -503,27 +503,27 @@ class DataTable extends StatelessWidget { assert(!_debugInteractive || debugCheckHasMaterial(context)); final ThemeData theme = Theme.of(context); - final BoxDecoration _kSelectedDecoration = new BoxDecoration( - border: new Border(bottom: Divider.createBorderSide(context, width: 1.0)), + final BoxDecoration _kSelectedDecoration = BoxDecoration( + border: Border(bottom: Divider.createBorderSide(context, width: 1.0)), // The backgroundColor has to be transparent so you can see the ink on the material color: (Theme.of(context).brightness == Brightness.light) ? _grey100Opacity : _grey300Opacity, ); - final BoxDecoration _kUnselectedDecoration = new BoxDecoration( - border: new Border(bottom: Divider.createBorderSide(context, width: 1.0)), + final BoxDecoration _kUnselectedDecoration = BoxDecoration( + border: Border(bottom: Divider.createBorderSide(context, width: 1.0)), ); final bool showCheckboxColumn = rows.any((DataRow row) => row.onSelectChanged != null); final bool allChecked = showCheckboxColumn && !rows.any((DataRow row) => row.onSelectChanged != null && !row.selected); - final List tableColumns = new List(columns.length + (showCheckboxColumn ? 1 : 0)); - final List tableRows = new List.generate( + final List tableColumns = List(columns.length + (showCheckboxColumn ? 1 : 0)); + final List tableRows = List.generate( rows.length + 1, // the +1 is for the header row (int index) { - return new TableRow( + return TableRow( key: index == 0 ? _headingRowKey : rows[index - 1].key, decoration: index > 0 && rows[index - 1].selected ? _kSelectedDecoration : _kUnselectedDecoration, - children: new List(tableColumns.length) + children: List(tableColumns.length) ); }, ); @@ -553,7 +553,7 @@ class DataTable extends StatelessWidget { for (int dataColumnIndex = 0; dataColumnIndex < columns.length; dataColumnIndex += 1) { final DataColumn column = columns[dataColumnIndex]; - final EdgeInsetsDirectional padding = new EdgeInsetsDirectional.only( + final EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( start: dataColumnIndex == 0 ? showCheckboxColumn ? _tablePadding / 2.0 : _tablePadding : _columnSpacing / 2.0, end: dataColumnIndex == columns.length - 1 ? _tablePadding : _columnSpacing / 2.0, ); @@ -590,7 +590,7 @@ class DataTable extends StatelessWidget { displayColumnIndex += 1; } - return new Table( + return Table( columnWidths: tableColumns.asMap(), children: tableRows, ); @@ -635,7 +635,7 @@ class TableRowInkWell extends InkResponse { return () { RenderObject cell = referenceBox; AbstractNode table = cell.parent; - final Matrix4 transform = new Matrix4.identity(); + final Matrix4 transform = Matrix4.identity(); while (table is RenderObject && table is! RenderTable) { final RenderTable parentBox = table; parentBox.applyPaintTransform(cell, transform); @@ -680,7 +680,7 @@ class _SortArrow extends StatefulWidget { final Duration duration; @override - _SortArrowState createState() => new _SortArrowState(); + _SortArrowState createState() => _SortArrowState(); } class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { @@ -697,8 +697,8 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { @override void initState() { super.initState(); - _opacityAnimation = new CurvedAnimation( - parent: _opacityController = new AnimationController( + _opacityAnimation = CurvedAnimation( + parent: _opacityController = AnimationController( duration: widget.duration, vsync: this, ), @@ -706,11 +706,11 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { ) ..addListener(_rebuild); _opacityController.value = widget.visible ? 1.0 : 0.0; - _orientationAnimation = new Tween( + _orientationAnimation = Tween( begin: 0.0, end: math.pi, - ).animate(new CurvedAnimation( - parent: _orientationController = new AnimationController( + ).animate(CurvedAnimation( + parent: _orientationController = AnimationController( duration: widget.duration, vsync: this, ), @@ -776,13 +776,13 @@ class _SortArrowState extends State<_SortArrow> with TickerProviderStateMixin { @override Widget build(BuildContext context) { - return new Opacity( + return Opacity( opacity: _opacityAnimation.value, - child: new Transform( - transform: new Matrix4.rotationZ(_orientationOffset + _orientationAnimation.value) + child: Transform( + transform: Matrix4.rotationZ(_orientationOffset + _orientationAnimation.value) ..setTranslationRaw(0.0, _arrowIconBaselineOffset, 0.0), alignment: Alignment.center, - child: new Icon( + child: Icon( Icons.arrow_downward, size: _arrowIconSize, color: (Theme.of(context).brightness == Brightness.light) ? Colors.black87 : Colors.white70, diff --git a/packages/flutter/lib/src/material/date_picker.dart b/packages/flutter/lib/src/material/date_picker.dart index a46266ddd6..3f616e81ce 100644 --- a/packages/flutter/lib/src/material/date_picker.dart +++ b/packages/flutter/lib/src/material/date_picker.dart @@ -125,38 +125,38 @@ class _DatePickerHeader extends StatelessWidget { break; } - final Widget yearButton = new IgnorePointer( + final Widget yearButton = IgnorePointer( ignoring: mode != DatePickerMode.day, ignoringSemantics: false, - child: new _DateHeaderButton( + child: _DateHeaderButton( color: backgroundColor, onTap: Feedback.wrapForTap(() => _handleChangeMode(DatePickerMode.year), context), - child: new Semantics( + child: Semantics( selected: mode == DatePickerMode.year, - child: new Text(localizations.formatYear(selectedDate), style: yearStyle), + child: Text(localizations.formatYear(selectedDate), style: yearStyle), ), ), ); - final Widget dayButton = new IgnorePointer( + final Widget dayButton = IgnorePointer( ignoring: mode == DatePickerMode.day, ignoringSemantics: false, - child: new _DateHeaderButton( + child: _DateHeaderButton( color: backgroundColor, onTap: Feedback.wrapForTap(() => _handleChangeMode(DatePickerMode.day), context), - child: new Semantics( + child: Semantics( selected: mode == DatePickerMode.day, - child: new Text(localizations.formatMediumDate(selectedDate), style: dayStyle), + child: Text(localizations.formatMediumDate(selectedDate), style: dayStyle), ), ), ); - return new Container( + return Container( width: width, height: height, padding: padding, color: backgroundColor, - child: new Column( + child: Column( mainAxisAlignment: mainAxisAlignment, crossAxisAlignment: CrossAxisAlignment.start, children: [yearButton, dayButton], @@ -181,15 +181,15 @@ class _DateHeaderButton extends StatelessWidget { Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - return new Material( + return Material( type: MaterialType.button, color: color, - child: new InkWell( + child: InkWell( borderRadius: kMaterialEdges[MaterialType.button], highlightColor: theme.highlightColor, splashColor: theme.splashColor, onTap: onTap, - child: new Container( + child: Container( padding: const EdgeInsets.symmetric(horizontal: 8.0), child: child, ), @@ -206,7 +206,7 @@ class _DayPickerGridDelegate extends SliverGridDelegate { const int columnCount = DateTime.daysPerWeek; final double tileWidth = constraints.crossAxisExtent / columnCount; final double tileHeight = math.min(_kDayPickerRowHeight, constraints.viewportMainAxisExtent / (_kMaxDayPickerRowCount + 1)); - return new SliverGridRegularTileLayout( + return SliverGridRegularTileLayout( crossAxisCount: columnCount, mainAxisStride: tileHeight, crossAxisStride: tileWidth, @@ -300,8 +300,8 @@ class DayPicker extends StatelessWidget { final List result = []; for (int i = localizations.firstDayOfWeekIndex; true; i = (i + 1) % 7) { final String weekday = localizations.narrowWeekdays[i]; - result.add(new ExcludeSemantics( - child: new Center(child: new Text(weekday, style: headerStyle)), + result.add(ExcludeSemantics( + child: Center(child: Text(weekday, style: headerStyle)), )); if (i == (localizations.firstDayOfWeekIndex - 1) % 7) break; @@ -361,7 +361,7 @@ class DayPicker extends StatelessWidget { /// days of week, always starting with Sunday and ending with Saturday. int _computeFirstDayOffset(int year, int month, MaterialLocalizations localizations) { // 0-based day of week, with 0 representing Monday. - final int weekdayFromMonday = new DateTime(year, month).weekday - 1; + final int weekdayFromMonday = DateTime(year, month).weekday - 1; // 0-based day of week, with 0 representing Sunday. final int firstDayOfWeekFromSunday = localizations.firstDayOfWeekIndex; // firstDayOfWeekFromSunday recomputed to be Monday-based @@ -388,9 +388,9 @@ class DayPicker extends StatelessWidget { if (day > daysInMonth) break; if (day < 1) { - labels.add(new Container()); + labels.add(Container()); } else { - final DateTime dayToBuild = new DateTime(year, month, day); + final DateTime dayToBuild = DateTime(year, month, day); final bool disabled = dayToBuild.isAfter(lastDate) || dayToBuild.isBefore(firstDate) || (selectableDayPredicate != null && !selectableDayPredicate(dayToBuild)); @@ -402,7 +402,7 @@ class DayPicker extends StatelessWidget { if (isSelectedDay) { // The selected day gets a circle background highlight, and a contrasting text color. itemStyle = themeData.accentTextTheme.body2; - decoration = new BoxDecoration( + decoration = BoxDecoration( color: themeData.accentColor, shape: BoxShape.circle ); @@ -413,10 +413,10 @@ class DayPicker extends StatelessWidget { itemStyle = themeData.textTheme.body2.copyWith(color: themeData.accentColor); } - Widget dayWidget = new Container( + Widget dayWidget = Container( decoration: decoration, - child: new Center( - child: new Semantics( + child: Center( + child: Semantics( // We want the day of month to be spoken first irrespective of the // locale-specific preferences or TextDirection. This is because // an accessibility user is more likely to be interested in the @@ -425,15 +425,15 @@ class DayPicker extends StatelessWidget { // formatted full date. label: '${localizations.formatDecimal(day)}, ${localizations.formatFullDate(dayToBuild)}', selected: isSelectedDay, - child: new ExcludeSemantics( - child: new Text(localizations.formatDecimal(day), style: itemStyle), + child: ExcludeSemantics( + child: Text(localizations.formatDecimal(day), style: itemStyle), ), ), ), ); if (!disabled) { - dayWidget = new GestureDetector( + dayWidget = GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { onChanged(dayToBuild); @@ -446,25 +446,25 @@ class DayPicker extends StatelessWidget { } } - return new Padding( + return Padding( padding: const EdgeInsets.symmetric(horizontal: 8.0), - child: new Column( + child: Column( children: [ - new Container( + Container( height: _kDayPickerRowHeight, - child: new Center( - child: new ExcludeSemantics( - child: new Text( + child: Center( + child: ExcludeSemantics( + child: Text( localizations.formatMonthYear(displayedMonth), style: themeData.textTheme.subhead, ), ), ), ), - new Flexible( - child: new GridView.custom( + Flexible( + child: GridView.custom( gridDelegate: _kDayPickerGridDelegate, - childrenDelegate: new SliverChildListDelegate(labels, addRepaintBoundaries: false), + childrenDelegate: SliverChildListDelegate(labels, addRepaintBoundaries: false), ), ), ], @@ -521,7 +521,7 @@ class MonthPicker extends StatefulWidget { final SelectableDayPredicate selectableDayPredicate; @override - _MonthPickerState createState() => new _MonthPickerState(); + _MonthPickerState createState() => _MonthPickerState(); } class _MonthPickerState extends State with SingleTickerProviderStateMixin { @@ -530,16 +530,16 @@ class _MonthPickerState extends State with SingleTickerProviderStat super.initState(); // Initially display the pre-selected date. final int monthPage = _monthDelta(widget.firstDate, widget.selectedDate); - _dayPickerController = new PageController(initialPage: monthPage); + _dayPickerController = PageController(initialPage: monthPage); _handleMonthPageChanged(monthPage); _updateCurrentDate(); // Setup the fade animation for chevrons - _chevronOpacityController = new AnimationController( + _chevronOpacityController = AnimationController( duration: const Duration(milliseconds: 250), vsync: this ); - _chevronOpacityAnimation = new Tween(begin: 1.0, end: 0.0).animate( - new CurvedAnimation( + _chevronOpacityAnimation = Tween(begin: 1.0, end: 0.0).animate( + CurvedAnimation( parent: _chevronOpacityController, curve: Curves.easeInOut, ) @@ -551,7 +551,7 @@ class _MonthPickerState extends State with SingleTickerProviderStat super.didUpdateWidget(oldWidget); if (widget.selectedDate != oldWidget.selectedDate) { final int monthPage = _monthDelta(widget.firstDate, widget.selectedDate); - _dayPickerController = new PageController(initialPage: monthPage); + _dayPickerController = PageController(initialPage: monthPage); _handleMonthPageChanged(monthPage); } } @@ -574,12 +574,12 @@ class _MonthPickerState extends State with SingleTickerProviderStat Animation _chevronOpacityAnimation; void _updateCurrentDate() { - _todayDate = new DateTime.now(); - final DateTime tomorrow = new DateTime(_todayDate.year, _todayDate.month, _todayDate.day + 1); + _todayDate = DateTime.now(); + final DateTime tomorrow = DateTime(_todayDate.year, _todayDate.month, _todayDate.day + 1); Duration timeUntilTomorrow = tomorrow.difference(_todayDate); timeUntilTomorrow += const Duration(seconds: 1); // so we don't miss it by rounding _timer?.cancel(); - _timer = new Timer(timeUntilTomorrow, () { + _timer = Timer(timeUntilTomorrow, () { setState(() { _updateCurrentDate(); }); @@ -592,13 +592,13 @@ class _MonthPickerState extends State with SingleTickerProviderStat /// Add months to a month truncated date. DateTime _addMonthsToMonthDate(DateTime monthDate, int monthsToAdd) { - return new DateTime(monthDate.year + monthsToAdd ~/ 12, monthDate.month + monthsToAdd % 12); + return DateTime(monthDate.year + monthsToAdd ~/ 12, monthDate.month + monthsToAdd % 12); } Widget _buildItems(BuildContext context, int index) { final DateTime month = _addMonthsToMonthDate(widget.firstDate, index); - return new DayPicker( - key: new ValueKey(month), + return DayPicker( + key: ValueKey(month), selectedDate: widget.selectedDate, currentDate: _todayDate, onChanged: widget.onChanged, @@ -626,13 +626,13 @@ class _MonthPickerState extends State with SingleTickerProviderStat /// True if the earliest allowable month is displayed. bool get _isDisplayingFirstMonth { return !_currentDisplayedMonthDate.isAfter( - new DateTime(widget.firstDate.year, widget.firstDate.month)); + DateTime(widget.firstDate.year, widget.firstDate.month)); } /// True if the latest allowable month is displayed. bool get _isDisplayingLastMonth { return !_currentDisplayedMonthDate.isBefore( - new DateTime(widget.lastDate.year, widget.lastDate.month)); + DateTime(widget.lastDate.year, widget.lastDate.month)); } DateTime _previousMonthDate; @@ -648,25 +648,25 @@ class _MonthPickerState extends State with SingleTickerProviderStat @override Widget build(BuildContext context) { - return new SizedBox( + return SizedBox( width: _kMonthPickerPortraitWidth, height: _kMaxDayPickerHeight, - child: new Stack( + child: Stack( children: [ - new Semantics( + Semantics( sortKey: _MonthPickerSortKey.calendar, - child: new NotificationListener( + child: NotificationListener( onNotification: (_) { _chevronOpacityController.forward(); return false; }, - child: new NotificationListener( + child: NotificationListener( onNotification: (_) { _chevronOpacityController.reverse(); return false; }, - child: new PageView.builder( - key: new ValueKey(widget.selectedDate), + child: PageView.builder( + key: ValueKey(widget.selectedDate), controller: _dayPickerController, scrollDirection: Axis.horizontal, itemCount: _monthDelta(widget.firstDate, widget.lastDate) + 1, @@ -676,14 +676,14 @@ class _MonthPickerState extends State with SingleTickerProviderStat ), ), ), - new PositionedDirectional( + PositionedDirectional( top: 0.0, start: 8.0, - child: new Semantics( + child: Semantics( sortKey: _MonthPickerSortKey.previousMonth, - child: new FadeTransition( + child: FadeTransition( opacity: _chevronOpacityAnimation, - child: new IconButton( + child: IconButton( icon: const Icon(Icons.chevron_left), tooltip: _isDisplayingFirstMonth ? null : '${localizations.previousMonthTooltip} ${localizations.formatMonthYear(_previousMonthDate)}', onPressed: _isDisplayingFirstMonth ? null : _handlePreviousMonth, @@ -691,14 +691,14 @@ class _MonthPickerState extends State with SingleTickerProviderStat ), ), ), - new PositionedDirectional( + PositionedDirectional( top: 0.0, end: 8.0, - child: new Semantics( + child: Semantics( sortKey: _MonthPickerSortKey.nextMonth, - child: new FadeTransition( + child: FadeTransition( opacity: _chevronOpacityAnimation, - child: new IconButton( + child: IconButton( icon: const Icon(Icons.chevron_right), tooltip: _isDisplayingLastMonth ? null : '${localizations.nextMonthTooltip} ${localizations.formatMonthYear(_nextMonthDate)}', onPressed: _isDisplayingLastMonth ? null : _handleNextMonth, @@ -774,7 +774,7 @@ class YearPicker extends StatefulWidget { final DateTime lastDate; @override - _YearPickerState createState() => new _YearPickerState(); + _YearPickerState createState() => _YearPickerState(); } class _YearPickerState extends State { @@ -784,7 +784,7 @@ class _YearPickerState extends State { @override void initState() { super.initState(); - scrollController = new ScrollController( + scrollController = ScrollController( // Move the initial scroll position to the currently selected date's year. initialScrollOffset: (widget.selectedDate.year - widget.firstDate.year) * _itemExtent, ); @@ -795,7 +795,7 @@ class _YearPickerState extends State { assert(debugCheckHasMaterial(context)); final ThemeData themeData = Theme.of(context); final TextStyle style = themeData.textTheme.body1; - return new ListView.builder( + return ListView.builder( controller: scrollController, itemExtent: _itemExtent, itemCount: widget.lastDate.year - widget.firstDate.year + 1, @@ -805,15 +805,15 @@ class _YearPickerState extends State { final TextStyle itemStyle = isSelected ? themeData.textTheme.headline.copyWith(color: themeData.accentColor) : style; - return new InkWell( - key: new ValueKey(year), + return InkWell( + key: ValueKey(year), onTap: () { - widget.onChanged(new DateTime(year, widget.selectedDate.month, widget.selectedDate.day)); + widget.onChanged(DateTime(year, widget.selectedDate.month, widget.selectedDate.day)); }, - child: new Center( - child: new Semantics( + child: Center( + child: Semantics( selected: isSelected, - child: new Text(year.toString(), style: itemStyle), + child: Text(year.toString(), style: itemStyle), ), ), ); @@ -839,7 +839,7 @@ class _DatePickerDialog extends StatefulWidget { final DatePickerMode initialDatePickerMode; @override - _DatePickerDialogState createState() => new _DatePickerDialogState(); + _DatePickerDialogState createState() => _DatePickerDialogState(); } class _DatePickerDialogState extends State<_DatePickerDialog> { @@ -871,7 +871,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { DateTime _selectedDate; DatePickerMode _mode; - final GlobalKey _pickerKey = new GlobalKey(); + final GlobalKey _pickerKey = GlobalKey(); void _vibrate() { switch (Theme.of(context).platform) { @@ -923,7 +923,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { assert(_mode != null); switch (_mode) { case DatePickerMode.day: - return new MonthPicker( + return MonthPicker( key: _pickerKey, selectedDate: _selectedDate, onChanged: _handleDayChanged, @@ -932,7 +932,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { selectableDayPredicate: widget.selectableDayPredicate, ); case DatePickerMode.year: - return new YearPicker( + return YearPicker( key: _pickerKey, selectedDate: _selectedDate, onChanged: _handleYearChanged, @@ -946,31 +946,31 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final Widget picker = new Flexible( - child: new SizedBox( + final Widget picker = Flexible( + child: SizedBox( height: _kMaxDayPickerHeight, child: _buildPicker(), ), ); - final Widget actions = new ButtonTheme.bar( - child: new ButtonBar( + final Widget actions = ButtonTheme.bar( + child: ButtonBar( children: [ - new FlatButton( - child: new Text(localizations.cancelButtonLabel), + FlatButton( + child: Text(localizations.cancelButtonLabel), onPressed: _handleCancel, ), - new FlatButton( - child: new Text(localizations.okButtonLabel), + FlatButton( + child: Text(localizations.okButtonLabel), onPressed: _handleOk, ), ], ), ); - final Dialog dialog = new Dialog( - child: new OrientationBuilder( + final Dialog dialog = Dialog( + child: OrientationBuilder( builder: (BuildContext context, Orientation orientation) { assert(orientation != null); - final Widget header = new _DatePickerHeader( + final Widget header = _DatePickerHeader( selectedDate: _selectedDate, mode: _mode, onModeChanged: _handleModeChanged, @@ -978,16 +978,16 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { ); switch (orientation) { case Orientation.portrait: - return new SizedBox( + return SizedBox( width: _kMonthPickerPortraitWidth, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ header, - new Container( + Container( color: theme.dialogBackgroundColor, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ @@ -1000,18 +1000,18 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { ), ); case Orientation.landscape: - return new SizedBox( + return SizedBox( height: _kDatePickerLandscapeHeight, - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ header, - new Flexible( - child: new Container( + Flexible( + child: Container( width: _kMonthPickerLandscapeWidth, color: theme.dialogBackgroundColor, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [picker, actions], @@ -1027,7 +1027,7 @@ class _DatePickerDialogState extends State<_DatePickerDialog> { ) ); - return new Theme( + return Theme( data: theme.copyWith( dialogBackgroundColor: Colors.transparent, ), @@ -1088,7 +1088,7 @@ Future showDatePicker({ ); assert(initialDatePickerMode != null, 'initialDatePickerMode must not be null'); - Widget child = new _DatePickerDialog( + Widget child = _DatePickerDialog( initialDate: initialDate, firstDate: firstDate, lastDate: lastDate, @@ -1097,14 +1097,14 @@ Future showDatePicker({ ); if (textDirection != null) { - child = new Directionality( + child = Directionality( textDirection: textDirection, child: child, ); } if (locale != null) { - child = new Localizations.override( + child = Localizations.override( context: context, locale: locale, child: child, diff --git a/packages/flutter/lib/src/material/debug.dart b/packages/flutter/lib/src/material/debug.dart index 8b21778e1e..f55e929d87 100644 --- a/packages/flutter/lib/src/material/debug.dart +++ b/packages/flutter/lib/src/material/debug.dart @@ -22,7 +22,7 @@ import 'material.dart'; bool debugCheckHasMaterial(BuildContext context) { assert(() { if (context.widget is! Material && context.ancestorWidgetOfExactType(Material) == null) { - final StringBuffer message = new StringBuffer(); + final StringBuffer message = StringBuffer(); message.writeln('No Material widget found.'); message.writeln( '${context.widget.runtimeType} widgets require a Material ' @@ -60,7 +60,7 @@ bool debugCheckHasMaterial(BuildContext context) { 'ancestors, let alone a "Material" ancestor.' ); } - throw new FlutterError(message.toString()); + throw FlutterError(message.toString()); } return true; }()); diff --git a/packages/flutter/lib/src/material/dialog.dart b/packages/flutter/lib/src/material/dialog.dart index de2dc55c23..4d525cd259 100644 --- a/packages/flutter/lib/src/material/dialog.dart +++ b/packages/flutter/lib/src/material/dialog.dart @@ -66,20 +66,20 @@ class Dialog extends StatelessWidget { @override Widget build(BuildContext context) { - return new AnimatedPadding( + return AnimatedPadding( padding: MediaQuery.of(context).viewInsets + const EdgeInsets.symmetric(horizontal: 40.0, vertical: 24.0), duration: insetAnimationDuration, curve: insetAnimationCurve, - child: new MediaQuery.removeViewInsets( + child: MediaQuery.removeViewInsets( removeLeft: true, removeTop: true, removeRight: true, removeBottom: true, context: context, - child: new Center( - child: new ConstrainedBox( + child: Center( + child: ConstrainedBox( constraints: const BoxConstraints(minWidth: 280.0), - child: new Material( + child: Material( elevation: 24.0, color: _getColor(context), type: MaterialType.card, @@ -236,11 +236,11 @@ class AlertDialog extends StatelessWidget { String label = semanticLabel; if (title != null) { - children.add(new Padding( - padding: titlePadding ?? new EdgeInsets.fromLTRB(24.0, 24.0, 24.0, content == null ? 20.0 : 0.0), - child: new DefaultTextStyle( + children.add(Padding( + padding: titlePadding ?? EdgeInsets.fromLTRB(24.0, 24.0, 24.0, content == null ? 20.0 : 0.0), + child: DefaultTextStyle( style: Theme.of(context).textTheme.title, - child: new Semantics(child: title, namesRoute: true), + child: Semantics(child: title, namesRoute: true), ), )); } else { @@ -255,10 +255,10 @@ class AlertDialog extends StatelessWidget { } if (content != null) { - children.add(new Flexible( - child: new Padding( + children.add(Flexible( + child: Padding( padding: contentPadding, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: Theme.of(context).textTheme.subhead, child: content, ), @@ -267,15 +267,15 @@ class AlertDialog extends StatelessWidget { } if (actions != null) { - children.add(new ButtonTheme.bar( - child: new ButtonBar( + children.add(ButtonTheme.bar( + child: ButtonBar( children: actions, ), )); } - Widget dialogChild = new IntrinsicWidth( - child: new Column( + Widget dialogChild = IntrinsicWidth( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: children, @@ -283,13 +283,13 @@ class AlertDialog extends StatelessWidget { ); if (label != null) - dialogChild = new Semantics( + dialogChild = Semantics( namesRoute: true, label: label, child: dialogChild ); - return new Dialog(child: dialogChild); + return Dialog(child: dialogChild); } } @@ -345,9 +345,9 @@ class SimpleDialogOption extends StatelessWidget { @override Widget build(BuildContext context) { - return new InkWell( + return InkWell( onTap: onPressed, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(vertical: 8.0, horizontal: 24.0), child: child ), @@ -494,11 +494,11 @@ class SimpleDialog extends StatelessWidget { String label = semanticLabel; if (title != null) { - body.add(new Padding( + body.add(Padding( padding: titlePadding, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: Theme.of(context).textTheme.title, - child: new Semantics(namesRoute: true, child: title), + child: Semantics(namesRoute: true, child: title), ) )); } else { @@ -513,19 +513,19 @@ class SimpleDialog extends StatelessWidget { } if (children != null) { - body.add(new Flexible( - child: new SingleChildScrollView( + body.add(Flexible( + child: SingleChildScrollView( padding: contentPadding, - child: new ListBody(children: children), + child: ListBody(children: children), ) )); } - Widget dialogChild = new IntrinsicWidth( + Widget dialogChild = IntrinsicWidth( stepWidth: 56.0, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints(minWidth: 280.0), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: body, @@ -534,18 +534,18 @@ class SimpleDialog extends StatelessWidget { ); if (label != null) - dialogChild = new Semantics( + dialogChild = Semantics( namesRoute: true, label: label, child: dialogChild, ); - return new Dialog(child: dialogChild); + return Dialog(child: dialogChild); } } Widget _buildMaterialDialogTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { - return new FadeTransition( - opacity: new CurvedAnimation( + return FadeTransition( + opacity: CurvedAnimation( parent: animation, curve: Curves.easeOut, ), @@ -600,12 +600,12 @@ Future showDialog({ context: context, pageBuilder: (BuildContext buildContext, Animation animation, Animation secondaryAnimation) { final ThemeData theme = Theme.of(context, shadowThemeOnly: true); - final Widget pageChild = child ?? new Builder(builder: builder); - return new SafeArea( - child: new Builder( + final Widget pageChild = child ?? Builder(builder: builder); + return SafeArea( + child: Builder( builder: (BuildContext context) { return theme != null - ? new Theme(data: theme, child: pageChild) + ? Theme(data: theme, child: pageChild) : pageChild; } ), diff --git a/packages/flutter/lib/src/material/divider.dart b/packages/flutter/lib/src/material/divider.dart index 05dda8d89c..af1cbcc9e0 100644 --- a/packages/flutter/lib/src/material/divider.dart +++ b/packages/flutter/lib/src/material/divider.dart @@ -87,7 +87,7 @@ class Divider extends StatelessWidget { /// ``` static BorderSide createBorderSide(BuildContext context, { Color color, double width = 0.0 }) { assert(width != null); - return new BorderSide( + return BorderSide( color: color ?? Theme.of(context).dividerColor, width: width, ); @@ -95,14 +95,14 @@ class Divider extends StatelessWidget { @override Widget build(BuildContext context) { - return new SizedBox( + return SizedBox( height: height, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 0.0, - margin: new EdgeInsetsDirectional.only(start: indent), - decoration: new BoxDecoration( - border: new Border( + margin: EdgeInsetsDirectional.only(start: indent), + decoration: BoxDecoration( + border: Border( bottom: createBorderSide(context, color: color), ), ), diff --git a/packages/flutter/lib/src/material/drawer.dart b/packages/flutter/lib/src/material/drawer.dart index 42637119a3..595f2c207a 100644 --- a/packages/flutter/lib/src/material/drawer.dart +++ b/packages/flutter/lib/src/material/drawer.dart @@ -125,14 +125,14 @@ class Drawer extends StatelessWidget { case TargetPlatform.fuchsia: label = semanticLabel ?? MaterialLocalizations.of(context)?.drawerLabel; } - return new Semantics( + return Semantics( scopesRoute: true, namesRoute: true, explicitChildNodes: true, label: label, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints.expand(width: _kWidth), - child: new Material( + child: Material( elevation: elevation, child: child, ), @@ -189,7 +189,7 @@ class DrawerController extends StatefulWidget { final DrawerCallback drawerCallback; @override - DrawerControllerState createState() => new DrawerControllerState(); + DrawerControllerState createState() => DrawerControllerState(); } /// State for a [DrawerController]. @@ -199,7 +199,7 @@ class DrawerControllerState extends State with SingleTickerPro @override void initState() { super.initState(); - _controller = new AnimationController(duration: _kBaseSettleDuration, vsync: this) + _controller = AnimationController(duration: _kBaseSettleDuration, vsync: this) ..addListener(_animationChanged) ..addStatusListener(_animationStatusChanged); } @@ -218,13 +218,13 @@ class DrawerControllerState extends State with SingleTickerPro } LocalHistoryEntry _historyEntry; - final FocusScopeNode _focusScopeNode = new FocusScopeNode(); + final FocusScopeNode _focusScopeNode = FocusScopeNode(); void _ensureHistoryEntry() { if (_historyEntry == null) { final ModalRoute route = ModalRoute.of(context); if (route != null) { - _historyEntry = new LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved); + _historyEntry = LocalHistoryEntry(onRemove: _handleHistoryEntryRemoved); route.addLocalHistoryEntry(_historyEntry); FocusScope.of(context).setFirstFocus(_focusScopeNode); } @@ -269,7 +269,7 @@ class DrawerControllerState extends State with SingleTickerPro } } - final GlobalKey _drawerKey = new GlobalKey(); + final GlobalKey _drawerKey = GlobalKey(); double get _width { final RenderBox box = _drawerKey.currentContext?.findRenderObject(); @@ -347,8 +347,8 @@ class DrawerControllerState extends State with SingleTickerPro widget.drawerCallback(false); } - final ColorTween _color = new ColorTween(begin: Colors.transparent, end: Colors.black54); - final GlobalKey _gestureDetectorKey = new GlobalKey(); + final ColorTween _color = ColorTween(begin: Colors.transparent, end: Colors.black54); + final GlobalKey _gestureDetectorKey = GlobalKey(); AlignmentDirectional get _drawerOuterAlignment { assert(widget.alignment != null); @@ -374,48 +374,48 @@ class DrawerControllerState extends State with SingleTickerPro Widget _buildDrawer(BuildContext context) { if (_controller.status == AnimationStatus.dismissed) { - return new Align( + return Align( alignment: _drawerOuterAlignment, - child: new GestureDetector( + child: GestureDetector( key: _gestureDetectorKey, onHorizontalDragUpdate: _move, onHorizontalDragEnd: _settle, behavior: HitTestBehavior.translucent, excludeFromSemantics: true, - child: new Container(width: _kEdgeDragWidth) + child: Container(width: _kEdgeDragWidth) ), ); } else { - return new GestureDetector( + return GestureDetector( key: _gestureDetectorKey, onHorizontalDragDown: _handleDragDown, onHorizontalDragUpdate: _move, onHorizontalDragEnd: _settle, onHorizontalDragCancel: _handleDragCancel, excludeFromSemantics: true, - child: new RepaintBoundary( - child: new Stack( + child: RepaintBoundary( + child: Stack( children: [ - new BlockSemantics( - child: new GestureDetector( + BlockSemantics( + child: GestureDetector( // On Android, the back button is used to dismiss a modal. excludeFromSemantics: defaultTargetPlatform == TargetPlatform.android, onTap: close, - child: new Semantics( + child: Semantics( label: MaterialLocalizations.of(context)?.modalBarrierDismissLabel, - child: new Container( + child: Container( color: _color.evaluate(_controller), ), ), ), ), - new Align( + Align( alignment: _drawerOuterAlignment, - child: new Align( + child: Align( alignment: _drawerInnerAlignment, widthFactor: _controller.value, - child: new RepaintBoundary( - child: new FocusScope( + child: RepaintBoundary( + child: FocusScope( key: _drawerKey, node: _focusScopeNode, child: widget.child @@ -431,7 +431,7 @@ class DrawerControllerState extends State with SingleTickerPro } @override Widget build(BuildContext context) { - return new ListTileTheme( + return ListTileTheme( style: ListTileStyle.drawer, child: _buildDrawer(context), ); diff --git a/packages/flutter/lib/src/material/drawer_header.dart b/packages/flutter/lib/src/material/drawer_header.dart index d675ab544d..e2fd8eb7ba 100644 --- a/packages/flutter/lib/src/material/drawer_header.dart +++ b/packages/flutter/lib/src/material/drawer_header.dart @@ -77,22 +77,22 @@ class DrawerHeader extends StatelessWidget { assert(debugCheckHasMediaQuery(context)); final ThemeData theme = Theme.of(context); final double statusBarHeight = MediaQuery.of(context).padding.top; - return new Container( + return Container( height: statusBarHeight + _kDrawerHeaderHeight, margin: margin, - decoration: new BoxDecoration( - border: new Border( + decoration: BoxDecoration( + border: Border( bottom: Divider.createBorderSide(context), ), ), - child: new AnimatedContainer( - padding: padding.add(new EdgeInsets.only(top: statusBarHeight)), + child: AnimatedContainer( + padding: padding.add(EdgeInsets.only(top: statusBarHeight)), decoration: decoration, duration: duration, curve: curve, - child: child == null ? null : new DefaultTextStyle( + child: child == null ? null : DefaultTextStyle( style: theme.textTheme.body2, - child: new MediaQuery.removePadding( + child: MediaQuery.removePadding( context: context, removeTop: true, child: child, diff --git a/packages/flutter/lib/src/material/dropdown.dart b/packages/flutter/lib/src/material/dropdown.dart index 043d985bef..cd0619e2e7 100644 --- a/packages/flutter/lib/src/material/dropdown.dart +++ b/packages/flutter/lib/src/material/dropdown.dart @@ -33,12 +33,12 @@ class _DropdownMenuPainter extends CustomPainter { this.elevation, this.selectedIndex, this.resize, - }) : _painter = new BoxDecoration( + }) : _painter = BoxDecoration( // If you add an image here, you must provide a real // configuration in the paint() function and you must provide some sort // of onChanged callback here. color: color, - borderRadius: new BorderRadius.circular(2.0), + borderRadius: BorderRadius.circular(2.0), boxShadow: kElevationToShadow[elevation] ).createBoxPainter(), super(repaint: resize); @@ -53,19 +53,19 @@ class _DropdownMenuPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final double selectedItemOffset = selectedIndex * _kMenuItemHeight + kMaterialListPadding.top; - final Tween top = new Tween( + final Tween top = Tween( begin: selectedItemOffset.clamp(0.0, size.height - _kMenuItemHeight), end: 0.0, ); - final Tween bottom = new Tween( + final Tween bottom = Tween( begin: (top.begin + _kMenuItemHeight).clamp(_kMenuItemHeight, size.height), end: size.height, ); - final Rect rect = new Rect.fromLTRB(0.0, top.evaluate(resize), size.width, bottom.evaluate(resize)); + final Rect rect = Rect.fromLTRB(0.0, top.evaluate(resize), size.width, bottom.evaluate(resize)); - _painter.paint(canvas, rect.topLeft, new ImageConfiguration(size: rect.size)); + _painter.paint(canvas, rect.topLeft, ImageConfiguration(size: rect.size)); } @override @@ -103,7 +103,7 @@ class _DropdownMenu extends StatefulWidget { final EdgeInsets padding; @override - _DropdownMenuState createState() => new _DropdownMenuState(); + _DropdownMenuState createState() => _DropdownMenuState(); } class _DropdownMenuState extends State<_DropdownMenu> { @@ -117,12 +117,12 @@ class _DropdownMenuState extends State<_DropdownMenu> { // direction. When the route's animation reverses, if we were to recreate // the CurvedAnimation objects in build, we'd lose // CurvedAnimation._curveDirection. - _fadeOpacity = new CurvedAnimation( + _fadeOpacity = CurvedAnimation( parent: widget.route.animation, curve: const Interval(0.0, 0.25), reverseCurve: const Interval(0.75, 1.0), ); - _resize = new CurvedAnimation( + _resize = CurvedAnimation( parent: widget.route.animation, curve: const Interval(0.25, 0.5), reverseCurve: const Threshold(0.0), @@ -146,48 +146,48 @@ class _DropdownMenuState extends State<_DropdownMenu> { for (int itemIndex = 0; itemIndex < route.items.length; ++itemIndex) { CurvedAnimation opacity; if (itemIndex == route.selectedIndex) { - opacity = new CurvedAnimation(parent: route.animation, curve: const Threshold(0.0)); + opacity = CurvedAnimation(parent: route.animation, curve: const Threshold(0.0)); } else { final double start = (0.5 + (itemIndex + 1) * unit).clamp(0.0, 1.0); final double end = (start + 1.5 * unit).clamp(0.0, 1.0); - opacity = new CurvedAnimation(parent: route.animation, curve: new Interval(start, end)); + opacity = CurvedAnimation(parent: route.animation, curve: Interval(start, end)); } - children.add(new FadeTransition( + children.add(FadeTransition( opacity: opacity, - child: new InkWell( - child: new Container( + child: InkWell( + child: Container( padding: widget.padding, child: route.items[itemIndex], ), onTap: () => Navigator.pop( context, - new _DropdownRouteResult(route.items[itemIndex].value), + _DropdownRouteResult(route.items[itemIndex].value), ), ), )); } - return new FadeTransition( + return FadeTransition( opacity: _fadeOpacity, - child: new CustomPaint( - painter: new _DropdownMenuPainter( + child: CustomPaint( + painter: _DropdownMenuPainter( color: Theme.of(context).canvasColor, elevation: route.elevation, selectedIndex: route.selectedIndex, resize: _resize, ), - child: new Semantics( + child: Semantics( scopesRoute: true, namesRoute: true, explicitChildNodes: true, label: localizations.popupMenuLabel, - child: new Material( + child: Material( type: MaterialType.transparency, textStyle: route.style, - child: new ScrollConfiguration( + child: ScrollConfiguration( behavior: const _DropdownScrollBehavior(), - child: new Scrollbar( - child: new ListView( + child: Scrollbar( + child: ListView( controller: widget.route.scrollController, padding: kMaterialListPadding, itemExtent: _kMenuItemHeight, @@ -226,7 +226,7 @@ class _DropdownMenuRouteLayout extends SingleChildLayoutDelegate { // The width of a menu should be at most the view width. This ensures that // the menu does not extend past the left and right edges of the screen. final double width = math.min(constraints.maxWidth, buttonRect.width); - return new BoxConstraints( + return BoxConstraints( minWidth: width, maxWidth: width, minHeight: 0.0, @@ -257,7 +257,7 @@ class _DropdownMenuRouteLayout extends SingleChildLayoutDelegate { left = buttonRect.left.clamp(0.0, size.width - childSize.width); break; } - return new Offset(left, menuTop); + return Offset(left, menuTop); } @override @@ -348,28 +348,28 @@ class _DropdownRoute extends PopupRoute<_DropdownRouteResult> { double scrollOffset = 0.0; if (preferredMenuHeight > maxMenuHeight) scrollOffset = selectedItemOffset - (buttonTop - menuTop); - scrollController = new ScrollController(initialScrollOffset: scrollOffset); + scrollController = ScrollController(initialScrollOffset: scrollOffset); } final TextDirection textDirection = Directionality.of(context); - Widget menu = new _DropdownMenu( + Widget menu = _DropdownMenu( route: this, padding: padding.resolve(textDirection), ); if (theme != null) - menu = new Theme(data: theme, child: menu); + menu = Theme(data: theme, child: menu); - return new MediaQuery.removePadding( + return MediaQuery.removePadding( context: context, removeTop: true, removeBottom: true, removeLeft: true, removeRight: true, - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new CustomSingleChildLayout( - delegate: new _DropdownMenuRouteLayout( + return CustomSingleChildLayout( + delegate: _DropdownMenuRouteLayout( buttonRect: buttonRect, menuTop: menuTop, menuHeight: menuHeight, @@ -414,7 +414,7 @@ class DropdownMenuItem extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( height: _kMenuItemHeight, alignment: AlignmentDirectional.centerStart, child: child, @@ -538,7 +538,7 @@ class DropdownButton extends StatefulWidget { final bool isExpanded; @override - _DropdownButtonState createState() => new _DropdownButtonState(); + _DropdownButtonState createState() => _DropdownButtonState(); } class _DropdownButtonState extends State> with WidgetsBindingObserver { @@ -600,7 +600,7 @@ class _DropdownButtonState extends State> with WidgetsBindi : _kUnalignedMenuMargin; assert(_dropdownRoute == null); - _dropdownRoute = new _DropdownRoute( + _dropdownRoute = _DropdownRoute( items: widget.items, buttonRect: menuMargin.resolve(textDirection).inflateRect(itemRect), padding: _kMenuItemPadding.resolve(textDirection), @@ -634,13 +634,13 @@ class _DropdownButtonState extends State> with WidgetsBindi // The width of the button and the menu are defined by the widest // item and the width of the hint. - final List items = new List.from(widget.items); + final List items = List.from(widget.items); int hintIndex; if (widget.hint != null) { hintIndex = items.length; - items.add(new DefaultTextStyle( + items.add(DefaultTextStyle( style: _textStyle.copyWith(color: Theme.of(context).hintColor), - child: new IgnorePointer( + child: IgnorePointer( child: widget.hint, ignoringSemantics: false, ), @@ -653,23 +653,23 @@ class _DropdownButtonState extends State> with WidgetsBindi // If value is null (then _selectedIndex is null) then we display // the hint or nothing at all. - final IndexedStack innerItemsWidget = new IndexedStack( + final IndexedStack innerItemsWidget = IndexedStack( index: _selectedIndex ?? hintIndex, alignment: AlignmentDirectional.centerStart, children: items, ); - Widget result = new DefaultTextStyle( + Widget result = DefaultTextStyle( style: _textStyle, - child: new Container( + child: Container( padding: padding.resolve(Directionality.of(context)), height: widget.isDense ? _denseButtonHeight : null, - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceBetween, mainAxisSize: MainAxisSize.min, children: [ - widget.isExpanded ? new Expanded(child: innerItemsWidget) : innerItemsWidget, - new Icon(Icons.arrow_drop_down, + widget.isExpanded ? Expanded(child: innerItemsWidget) : innerItemsWidget, + Icon(Icons.arrow_drop_down, size: widget.iconSize, // These colors are not defined in the Material Design spec. color: Theme.of(context).brightness == Brightness.light ? Colors.grey.shade700 : Colors.white70 @@ -681,14 +681,14 @@ class _DropdownButtonState extends State> with WidgetsBindi if (!DropdownButtonHideUnderline.at(context)) { final double bottom = widget.isDense ? 0.0 : 8.0; - result = new Stack( + result = Stack( children: [ result, - new Positioned( + Positioned( left: 0.0, right: 0.0, bottom: bottom, - child: new Container( + child: Container( height: 1.0, decoration: const BoxDecoration( border: Border(bottom: BorderSide(color: Color(0xFFBDBDBD), width: 0.0)) @@ -699,9 +699,9 @@ class _DropdownButtonState extends State> with WidgetsBindi ); } - return new Semantics( + return Semantics( button: true, - child: new GestureDetector( + child: GestureDetector( onTap: _handleTap, behavior: HitTestBehavior.opaque, child: result diff --git a/packages/flutter/lib/src/material/expand_icon.dart b/packages/flutter/lib/src/material/expand_icon.dart index 57b2116335..90a77c323a 100644 --- a/packages/flutter/lib/src/material/expand_icon.dart +++ b/packages/flutter/lib/src/material/expand_icon.dart @@ -60,7 +60,7 @@ class ExpandIcon extends StatefulWidget { final EdgeInsetsGeometry padding; @override - _ExpandIconState createState() => new _ExpandIconState(); + _ExpandIconState createState() => _ExpandIconState(); } class _ExpandIconState extends State with SingleTickerProviderStateMixin { @@ -70,9 +70,9 @@ class _ExpandIconState extends State with SingleTickerProviderStateM @override void initState() { super.initState(); - _controller = new AnimationController(duration: kThemeAnimationDuration, vsync: this); - _iconTurns = new Tween(begin: 0.0, end: 0.5).animate( - new CurvedAnimation( + _controller = AnimationController(duration: kThemeAnimationDuration, vsync: this); + _iconTurns = Tween(begin: 0.0, end: 0.5).animate( + CurvedAnimation( parent: _controller, curve: Curves.fastOutSlowIn ) @@ -113,13 +113,13 @@ class _ExpandIconState extends State with SingleTickerProviderStateM final ThemeData theme = Theme.of(context); final String onTapHint = widget.isExpanded ? localizations.expandedIconTapHint : localizations.collapsedIconTapHint; - return new Semantics( + return Semantics( onTapHint: widget.onPressed == null ? null : onTapHint, - child: new IconButton( + child: IconButton( padding: widget.padding, color: theme.brightness == Brightness.dark ? Colors.white54 : Colors.black54, onPressed: widget.onPressed == null ? null : _handlePressed, - icon: new RotationTransition( + icon: RotationTransition( turns: _iconTurns, child: const Icon(Icons.expand_more) ), diff --git a/packages/flutter/lib/src/material/expansion_panel.dart b/packages/flutter/lib/src/material/expansion_panel.dart index 2e8f5f1dac..3ed9ccb343 100644 --- a/packages/flutter/lib/src/material/expansion_panel.dart +++ b/packages/flutter/lib/src/material/expansion_panel.dart @@ -175,7 +175,7 @@ class ExpansionPanelList extends StatefulWidget { final Object initialOpenPanelValue; @override - State createState() => new _ExpansionPanelListState(); + State createState() => _ExpansionPanelListState(); } class _ExpansionPanelListState extends State { @@ -253,17 +253,17 @@ class _ExpansionPanelListState extends State { for (int index = 0; index < widget.children.length; index += 1) { if (_isChildExpanded(index) && index != 0 && !_isChildExpanded(index - 1)) - items.add(new MaterialGap(key: new _SaltedKey(context, index * 2 - 1))); + items.add(MaterialGap(key: _SaltedKey(context, index * 2 - 1))); final ExpansionPanel child = widget.children[index]; - final Row header = new Row( + final Row header = Row( children: [ - new Expanded( - child: new AnimatedContainer( + Expanded( + child: AnimatedContainer( duration: widget.animationDuration, curve: Curves.fastOutSlowIn, margin: _isChildExpanded(index) ? kExpandedEdgeInsets : EdgeInsets.zero, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints(minHeight: _kPanelHeaderCollapsedHeight), child: child.headerBuilder( context, @@ -272,9 +272,9 @@ class _ExpansionPanelListState extends State { ), ), ), - new Container( + Container( margin: const EdgeInsetsDirectional.only(end: 8.0), - child: new ExpandIcon( + child: ExpandIcon( isExpanded: _isChildExpanded(index), padding: const EdgeInsets.all(16.0), onPressed: (bool isExpanded) => _handlePressed(isExpanded, index), @@ -284,13 +284,13 @@ class _ExpansionPanelListState extends State { ); items.add( - new MaterialSlice( - key: new _SaltedKey(context, index * 2), - child: new Column( + MaterialSlice( + key: _SaltedKey(context, index * 2), + child: Column( children: [ - new MergeSemantics(child: header), - new AnimatedCrossFade( - firstChild: new Container(height: 0.0), + MergeSemantics(child: header), + AnimatedCrossFade( + firstChild: Container(height: 0.0), secondChild: child.body, firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), secondCurve: const Interval(0.4, 1.0, curve: Curves.fastOutSlowIn), @@ -304,10 +304,10 @@ class _ExpansionPanelListState extends State { ); if (_isChildExpanded(index) && index != widget.children.length - 1) - items.add(new MaterialGap(key: new _SaltedKey(context, index * 2 + 1))); + items.add(MaterialGap(key: _SaltedKey(context, index * 2 + 1))); } - return new MergeableMaterial( + return MergeableMaterial( hasDividers: true, children: items, ); diff --git a/packages/flutter/lib/src/material/expansion_tile.dart b/packages/flutter/lib/src/material/expansion_tile.dart index 34c7268362..0254c6188e 100644 --- a/packages/flutter/lib/src/material/expansion_tile.dart +++ b/packages/flutter/lib/src/material/expansion_tile.dart @@ -75,7 +75,7 @@ class ExpansionTile extends StatefulWidget { final bool initiallyExpanded; @override - _ExpansionTileState createState() => new _ExpansionTileState(); + _ExpansionTileState createState() => _ExpansionTileState(); } class _ExpansionTileState extends State with SingleTickerProviderStateMixin { @@ -93,14 +93,14 @@ class _ExpansionTileState extends State with SingleTickerProvider @override void initState() { super.initState(); - _controller = new AnimationController(duration: _kExpand, vsync: this); - _easeOutAnimation = new CurvedAnimation(parent: _controller, curve: Curves.easeOut); - _easeInAnimation = new CurvedAnimation(parent: _controller, curve: Curves.easeIn); - _borderColor = new ColorTween(); - _headerColor = new ColorTween(); - _iconColor = new ColorTween(); - _iconTurns = new Tween(begin: 0.0, end: 0.5).animate(_easeInAnimation); - _backgroundColor = new ColorTween(); + _controller = AnimationController(duration: _kExpand, vsync: this); + _easeOutAnimation = CurvedAnimation(parent: _controller, curve: Curves.easeOut); + _easeInAnimation = CurvedAnimation(parent: _controller, curve: Curves.easeIn); + _borderColor = ColorTween(); + _headerColor = ColorTween(); + _iconColor = ColorTween(); + _iconTurns = Tween(begin: 0.0, end: 0.5).animate(_easeInAnimation); + _backgroundColor = ColorTween(); _isExpanded = PageStorage.of(context)?.readState(context) ?? widget.initiallyExpanded; if (_isExpanded) @@ -134,34 +134,34 @@ class _ExpansionTileState extends State with SingleTickerProvider final Color borderSideColor = _borderColor.evaluate(_easeOutAnimation) ?? Colors.transparent; final Color titleColor = _headerColor.evaluate(_easeInAnimation); - return new Container( - decoration: new BoxDecoration( + return Container( + decoration: BoxDecoration( color: _backgroundColor.evaluate(_easeOutAnimation) ?? Colors.transparent, - border: new Border( - top: new BorderSide(color: borderSideColor), - bottom: new BorderSide(color: borderSideColor), + border: Border( + top: BorderSide(color: borderSideColor), + bottom: BorderSide(color: borderSideColor), ) ), - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ IconTheme.merge( - data: new IconThemeData(color: _iconColor.evaluate(_easeInAnimation)), - child: new ListTile( + data: IconThemeData(color: _iconColor.evaluate(_easeInAnimation)), + child: ListTile( onTap: _handleTap, leading: widget.leading, - title: new DefaultTextStyle( + title: DefaultTextStyle( style: Theme.of(context).textTheme.subhead.copyWith(color: titleColor), child: widget.title, ), - trailing: widget.trailing ?? new RotationTransition( + trailing: widget.trailing ?? RotationTransition( turns: _iconTurns, child: const Icon(Icons.expand_more), ), ), ), - new ClipRect( - child: new Align( + ClipRect( + child: Align( heightFactor: _easeInAnimation.value, child: child, ), @@ -184,10 +184,10 @@ class _ExpansionTileState extends State with SingleTickerProvider _backgroundColor.end = widget.backgroundColor; final bool closed = !_isExpanded && _controller.isDismissed; - return new AnimatedBuilder( + return AnimatedBuilder( animation: _controller.view, builder: _buildChildren, - child: closed ? null : new Column(children: widget.children), + child: closed ? null : Column(children: widget.children), ); } diff --git a/packages/flutter/lib/src/material/feedback.dart b/packages/flutter/lib/src/material/feedback.dart index eeca730022..0576e4a593 100644 --- a/packages/flutter/lib/src/material/feedback.dart +++ b/packages/flutter/lib/src/material/feedback.dart @@ -94,7 +94,7 @@ class Feedback { case TargetPlatform.fuchsia: return SystemSound.play(SystemSoundType.click); default: - return new Future.value(); + return Future.value(); } } @@ -133,7 +133,7 @@ class Feedback { case TargetPlatform.fuchsia: return HapticFeedback.vibrate(); default: - return new Future.value(); + return Future.value(); } } diff --git a/packages/flutter/lib/src/material/flat_button.dart b/packages/flutter/lib/src/material/flat_button.dart index 5c58f5a05b..65048a1cff 100644 --- a/packages/flutter/lib/src/material/flat_button.dart +++ b/packages/flutter/lib/src/material/flat_button.dart @@ -98,7 +98,7 @@ class FlatButton extends StatelessWidget { assert(label != null), assert(clipBehavior != null), padding = const EdgeInsetsDirectional.only(start: 12.0, end: 16.0), - child = new Row( + child = Row( mainAxisSize: MainAxisSize.min, children: [ icon, @@ -301,7 +301,7 @@ class FlatButton extends StatelessWidget { final Color fillColor = enabled ? color : disabledColor; final Color textColor = _getTextColor(theme, buttonTheme, fillColor); - return new RawMaterialButton( + return RawMaterialButton( onPressed: onPressed, onHighlightChanged: onHighlightChanged, fillColor: fillColor, @@ -322,17 +322,17 @@ class FlatButton extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); - properties.add(new DiagnosticsProperty('textTheme', textTheme, defaultValue: null)); - properties.add(new DiagnosticsProperty('textColor', textColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledTextColor', disabledTextColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledColor', disabledColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('highlightColor', highlightColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('splashColor', splashColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('colorBrightness', colorBrightness, defaultValue: null)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); - properties.add(new DiagnosticsProperty('shape', shape, defaultValue: null)); - properties.add(new DiagnosticsProperty('materialTapTargetSize', materialTapTargetSize, defaultValue: null)); + properties.add(ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); + properties.add(DiagnosticsProperty('textTheme', textTheme, defaultValue: null)); + properties.add(DiagnosticsProperty('textColor', textColor, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledTextColor', disabledTextColor, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledColor', disabledColor, defaultValue: null)); + properties.add(DiagnosticsProperty('highlightColor', highlightColor, defaultValue: null)); + properties.add(DiagnosticsProperty('splashColor', splashColor, defaultValue: null)); + properties.add(DiagnosticsProperty('colorBrightness', colorBrightness, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('shape', shape, defaultValue: null)); + properties.add(DiagnosticsProperty('materialTapTargetSize', materialTapTargetSize, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/material/flexible_space_bar.dart b/packages/flutter/lib/src/material/flexible_space_bar.dart index 368b55a69a..a53abd743a 100644 --- a/packages/flutter/lib/src/material/flexible_space_bar.dart +++ b/packages/flutter/lib/src/material/flexible_space_bar.dart @@ -83,7 +83,7 @@ class FlexibleSpaceBar extends StatefulWidget { @required Widget child, }) { assert(currentExtent != null); - return new _FlexibleSpaceBarSettings( + return _FlexibleSpaceBarSettings( toolbarOpacity: toolbarOpacity ?? 1.0, minExtent: minExtent ?? currentExtent, maxExtent: maxExtent ?? currentExtent, @@ -93,7 +93,7 @@ class FlexibleSpaceBar extends StatefulWidget { } @override - _FlexibleSpaceBarState createState() => new _FlexibleSpaceBarState(); + _FlexibleSpaceBarState createState() => _FlexibleSpaceBarState(); } class _FlexibleSpaceBarState extends State { @@ -133,7 +133,7 @@ class _FlexibleSpaceBarState extends State { return 0.0; case CollapseMode.parallax: final double deltaExtent = settings.maxExtent - settings.minExtent; - return -new Tween(begin: 0.0, end: deltaExtent / 4.0).lerp(t); + return -Tween(begin: 0.0, end: deltaExtent / 4.0).lerp(t); } return null; } @@ -156,14 +156,14 @@ class _FlexibleSpaceBarState extends State { final double fadeStart = math.max(0.0, 1.0 - kToolbarHeight / deltaExtent); const double fadeEnd = 1.0; assert(fadeStart <= fadeEnd); - final double opacity = 1.0 - new Interval(fadeStart, fadeEnd).transform(t); + final double opacity = 1.0 - Interval(fadeStart, fadeEnd).transform(t); if (opacity > 0.0) { - children.add(new Positioned( + children.add(Positioned( top: _getCollapsePadding(t, settings), left: 0.0, right: 0.0, height: settings.maxExtent, - child: new Opacity( + child: Opacity( opacity: opacity, child: widget.background ) @@ -179,7 +179,7 @@ class _FlexibleSpaceBarState extends State { break; case TargetPlatform.fuchsia: case TargetPlatform.android: - title = new Semantics( + title = Semantics( namesRoute: true, child: widget.title, ); @@ -193,21 +193,21 @@ class _FlexibleSpaceBarState extends State { color: titleStyle.color.withOpacity(opacity) ); final bool effectiveCenterTitle = _getEffectiveCenterTitle(theme); - final double scaleValue = new Tween(begin: 1.5, end: 1.0).lerp(t); - final Matrix4 scaleTransform = new Matrix4.identity() + final double scaleValue = Tween(begin: 1.5, end: 1.0).lerp(t); + final Matrix4 scaleTransform = Matrix4.identity() ..scale(scaleValue, scaleValue, 1.0); final Alignment titleAlignment = _getTitleAlignment(effectiveCenterTitle); - children.add(new Container( - padding: new EdgeInsetsDirectional.only( + children.add(Container( + padding: EdgeInsetsDirectional.only( start: effectiveCenterTitle ? 0.0 : 72.0, bottom: 16.0 ), - child: new Transform( + child: Transform( alignment: titleAlignment, transform: scaleTransform, - child: new Align( + child: Align( alignment: titleAlignment, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: titleStyle, child: title, ) @@ -217,7 +217,7 @@ class _FlexibleSpaceBarState extends State { } } - return new ClipRect(child: new Stack(children: children)); + return ClipRect(child: Stack(children: children)); } } diff --git a/packages/flutter/lib/src/material/floating_action_button.dart b/packages/flutter/lib/src/material/floating_action_button.dart index 48be7dc363..e1b0243445 100644 --- a/packages/flutter/lib/src/material/floating_action_button.dart +++ b/packages/flutter/lib/src/material/floating_action_button.dart @@ -109,8 +109,8 @@ class FloatingActionButton extends StatefulWidget { assert(clipBehavior != null), _sizeConstraints = _kExtendedSizeConstraints, mini = false, - child = new _ChildOverflowBox( - child: new Row( + child = _ChildOverflowBox( + child: Row( mainAxisSize: MainAxisSize.min, children: [ const SizedBox(width: 16.0), @@ -222,7 +222,7 @@ class FloatingActionButton extends StatefulWidget { final BoxConstraints _sizeConstraints; @override - _FloatingActionButtonState createState() => new _FloatingActionButtonState(); + _FloatingActionButtonState createState() => _FloatingActionButtonState(); } class _FloatingActionButtonState extends State { @@ -242,14 +242,14 @@ class _FloatingActionButtonState extends State { if (widget.child != null) { result = IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: foregroundColor, ), child: widget.child, ); } - result = new RawMaterialButton( + result = RawMaterialButton( onPressed: widget.onPressed, onHighlightChanged: _handleHighlightChanged, elevation: _highlight ? widget.highlightElevation : widget.elevation, @@ -266,8 +266,8 @@ class _FloatingActionButtonState extends State { ); if (widget.tooltip != null) { - result = new MergeSemantics( - child: new Tooltip( + result = MergeSemantics( + child: Tooltip( message: widget.tooltip, child: result, ), @@ -275,7 +275,7 @@ class _FloatingActionButtonState extends State { } if (widget.heroTag != null) { - result = new Hero( + result = Hero( tag: widget.heroTag, child: result, ); @@ -298,7 +298,7 @@ class _ChildOverflowBox extends SingleChildRenderObjectWidget { @override _RenderChildOverflowBox createRenderObject(BuildContext context) { - return new _RenderChildOverflowBox( + return _RenderChildOverflowBox( textDirection: Directionality.of(context), ); } @@ -326,7 +326,7 @@ class _RenderChildOverflowBox extends RenderAligningShiftedBox { void performLayout() { if (child != null) { child.layout(const BoxConstraints(), parentUsesSize: true); - size = new Size( + size = Size( math.max(constraints.minWidth, math.min(constraints.maxWidth, child.size.width)), math.max(constraints.minHeight, math.min(constraints.maxHeight, child.size.height)), ); diff --git a/packages/flutter/lib/src/material/floating_action_button_location.dart b/packages/flutter/lib/src/material/floating_action_button_location.dart index 64a32ec69a..5f4d196bfa 100644 --- a/packages/flutter/lib/src/material/floating_action_button_location.dart +++ b/packages/flutter/lib/src/material/floating_action_button_location.dart @@ -112,7 +112,7 @@ class _CenterFloatFabLocation extends FloatingActionButtonLocation { if (bottomSheetHeight > 0.0) fabY = math.min(fabY, contentBottom - bottomSheetHeight - fabHeight / 2.0); - return new Offset(fabX, fabY); + return Offset(fabX, fabY); } } @@ -149,7 +149,7 @@ class _EndFloatFabLocation extends FloatingActionButtonLocation { if (bottomSheetHeight > 0.0) fabY = math.min(fabY, contentBottom - bottomSheetHeight - fabHeight / 2.0); - return new Offset(fabX, fabY); + return Offset(fabX, fabY); } } @@ -201,7 +201,7 @@ class _EndDockedFloatingActionButtonLocation extends _DockedFloatingActionButton break; } // Return an offset with a docked Y coordinate. - return new Offset(fabX, getDockedY(scaffoldGeometry)); + return Offset(fabX, getDockedY(scaffoldGeometry)); } } @@ -211,7 +211,7 @@ class _CenterDockedFloatingActionButtonLocation extends _DockedFloatingActionBut @override Offset getOffset(ScaffoldPrelayoutGeometry scaffoldGeometry) { final double fabX = (scaffoldGeometry.scaffoldSize.width - scaffoldGeometry.floatingActionButtonSize.width) / 2.0; - return new Offset(fabX, getDockedY(scaffoldGeometry)); + return Offset(fabX, getDockedY(scaffoldGeometry)); } } @@ -331,9 +331,9 @@ class _ScalingFabMotionAnimator extends FloatingActionButtonAnimator { // Animate the scale down from 1 to 0 in the first half of the animation // then from 0 back to 1 in the second half. const Curve curve = Interval(0.5, 1.0, curve: Curves.ease); - return new _AnimationSwap( - new ReverseAnimation(new CurveTween(curve: curve.flipped).animate(parent)), - new CurveTween(curve: curve).animate(parent), + return _AnimationSwap( + ReverseAnimation(CurveTween(curve: curve.flipped).animate(parent)), + CurveTween(curve: curve).animate(parent), parent, 0.5, ); @@ -343,14 +343,14 @@ class _ScalingFabMotionAnimator extends FloatingActionButtonAnimator { Animation getRotationAnimation({Animation parent}) { // Because we only see the last half of the rotation tween, // it needs to go twice as far. - final Tween rotationTween = new Tween( + final Tween rotationTween = Tween( begin: 1.0 - kFloatingActionButtonTurnInterval * 2, end: 1.0, ); // This rotation will turn on the way in, but not on the way out. - return new _AnimationSwap( + return _AnimationSwap( rotationTween.animate(parent), - new ReverseAnimation(new CurveTween(curve: const Threshold(0.5)).animate(parent)), + ReverseAnimation(CurveTween(curve: const Threshold(0.5)).animate(parent)), parent, 0.5, ); diff --git a/packages/flutter/lib/src/material/flutter_logo.dart b/packages/flutter/lib/src/material/flutter_logo.dart index ae0d4590ad..be8835f37d 100644 --- a/packages/flutter/lib/src/material/flutter_logo.dart +++ b/packages/flutter/lib/src/material/flutter_logo.dart @@ -70,12 +70,12 @@ class FlutterLogo extends StatelessWidget { final IconThemeData iconTheme = IconTheme.of(context); final double iconSize = size ?? iconTheme.size; final MaterialColor logoColors = colors ?? Colors.blue; - return new AnimatedContainer( + return AnimatedContainer( width: iconSize, height: iconSize, duration: duration, curve: curve, - decoration: new FlutterLogoDecoration( + decoration: FlutterLogoDecoration( lightColor: logoColors.shade400, darkColor: logoColors.shade900, style: style, diff --git a/packages/flutter/lib/src/material/grid_tile.dart b/packages/flutter/lib/src/material/grid_tile.dart index 13c42159bd..708ee9ec1e 100644 --- a/packages/flutter/lib/src/material/grid_tile.dart +++ b/packages/flutter/lib/src/material/grid_tile.dart @@ -49,12 +49,12 @@ class GridTile extends StatelessWidget { return child; final List children = [ - new Positioned.fill( + Positioned.fill( child: child, ), ]; if (header != null) { - children.add(new Positioned( + children.add(Positioned( top: 0.0, left: 0.0, right: 0.0, @@ -62,13 +62,13 @@ class GridTile extends StatelessWidget { )); } if (footer != null) { - children.add(new Positioned( + children.add(Positioned( left: 0.0, bottom: 0.0, right: 0.0, child: footer, )); } - return new Stack(children: children); + return Stack(children: children); } } diff --git a/packages/flutter/lib/src/material/grid_tile_bar.dart b/packages/flutter/lib/src/material/grid_tile_bar.dart index 21138acae4..3e26193112 100644 --- a/packages/flutter/lib/src/material/grid_tile_bar.dart +++ b/packages/flutter/lib/src/material/grid_tile_bar.dart @@ -60,37 +60,37 @@ class GridTileBar extends StatelessWidget { Widget build(BuildContext context) { BoxDecoration decoration; if (backgroundColor != null) - decoration = new BoxDecoration(color: backgroundColor); + decoration = BoxDecoration(color: backgroundColor); final List children = []; - final EdgeInsetsDirectional padding = new EdgeInsetsDirectional.only( + final EdgeInsetsDirectional padding = EdgeInsetsDirectional.only( start: leading != null ? 8.0 : 16.0, end: trailing != null ? 8.0 : 16.0, ); if (leading != null) - children.add(new Padding(padding: const EdgeInsetsDirectional.only(end: 8.0), child: leading)); + children.add(Padding(padding: const EdgeInsetsDirectional.only(end: 8.0), child: leading)); final ThemeData theme = Theme.of(context); - final ThemeData darkTheme = new ThemeData( + final ThemeData darkTheme = ThemeData( brightness: Brightness.dark, accentColor: theme.accentColor, accentColorBrightness: theme.accentColorBrightness ); if (title != null && subtitle != null) { children.add( - new Expanded( - child: new Column( + Expanded( + child: Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.start, children: [ - new DefaultTextStyle( + DefaultTextStyle( style: darkTheme.textTheme.subhead, softWrap: false, overflow: TextOverflow.ellipsis, child: title ), - new DefaultTextStyle( + DefaultTextStyle( style: darkTheme.textTheme.caption, softWrap: false, overflow: TextOverflow.ellipsis, @@ -102,8 +102,8 @@ class GridTileBar extends StatelessWidget { ); } else if (title != null || subtitle != null) { children.add( - new Expanded( - child: new DefaultTextStyle( + Expanded( + child: DefaultTextStyle( style: darkTheme.textTheme.subhead, softWrap: false, overflow: TextOverflow.ellipsis, @@ -114,17 +114,17 @@ class GridTileBar extends StatelessWidget { } if (trailing != null) - children.add(new Padding(padding: const EdgeInsetsDirectional.only(start: 8.0), child: trailing)); + children.add(Padding(padding: const EdgeInsetsDirectional.only(start: 8.0), child: trailing)); - return new Container( + return Container( padding: padding, decoration: decoration, height: (title != null && subtitle != null) ? 68.0 : 48.0, - child: new Theme( + child: Theme( data: darkTheme, child: IconTheme.merge( data: const IconThemeData(color: Colors.white), - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.center, children: children ) diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index 912dc83ff8..a384a0d848 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -191,20 +191,20 @@ class IconButton extends StatelessWidget { else currentColor = disabledColor ?? Theme.of(context).disabledColor; - Widget result = new Semantics( + Widget result = Semantics( button: true, enabled: onPressed != null, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints(minWidth: _kMinButtonSize, minHeight: _kMinButtonSize), - child: new Padding( + child: Padding( padding: padding, - child: new SizedBox( + child: SizedBox( height: iconSize, width: iconSize, - child: new Align( + child: Align( alignment: alignment, child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( size: iconSize, color: currentColor ), @@ -217,12 +217,12 @@ class IconButton extends StatelessWidget { ); if (tooltip != null) { - result = new Tooltip( + result = Tooltip( message: tooltip, child: result ); } - return new InkResponse( + return InkResponse( onTap: onPressed, child: result, highlightColor: highlightColor ?? Theme.of(context).highlightColor, @@ -238,8 +238,8 @@ class IconButton extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('icon', icon, showName: false)); - properties.add(new ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); - properties.add(new StringProperty('tooltip', tooltip, defaultValue: null, quoted: false)); + properties.add(DiagnosticsProperty('icon', icon, showName: false)); + properties.add(ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); + properties.add(StringProperty('tooltip', tooltip, defaultValue: null, quoted: false)); } } diff --git a/packages/flutter/lib/src/material/ink_decoration.dart b/packages/flutter/lib/src/material/ink_decoration.dart index d204903cf2..7a40b7249f 100644 --- a/packages/flutter/lib/src/material/ink_decoration.dart +++ b/packages/flutter/lib/src/material/ink_decoration.dart @@ -126,7 +126,7 @@ class Ink extends StatefulWidget { 'Cannot provide both a color and a decoration\n' 'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".' ), - decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null), + decoration = decoration ?? (color != null ? BoxDecoration(color: color) : null), super(key: key); /// Creates a widget that shows an image (obtained from an [ImageProvider]) on @@ -160,8 +160,8 @@ class Ink extends StatefulWidget { assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), - decoration = new BoxDecoration( - image: new DecorationImage( + decoration = BoxDecoration( + image: DecorationImage( image: image, colorFilter: colorFilter, fit: fit, @@ -215,12 +215,12 @@ class Ink extends StatefulWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); - properties.add(new DiagnosticsProperty('bg', decoration, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('bg', decoration, defaultValue: null)); } @override - _InkState createState() => new _InkState(); + _InkState createState() => _InkState(); } class _InkState extends State { @@ -239,7 +239,7 @@ class _InkState extends State { Widget _build(BuildContext context, BoxConstraints constraints) { if (_ink == null) { - _ink = new InkDecoration( + _ink = InkDecoration( decoration: widget.decoration, configuration: createLocalImageConfiguration(context), controller: Material.of(context), @@ -253,18 +253,18 @@ class _InkState extends State { Widget current = widget.child; final EdgeInsetsGeometry effectivePadding = widget._paddingIncludingDecoration; if (effectivePadding != null) - current = new Padding(padding: effectivePadding, child: current); + current = Padding(padding: effectivePadding, child: current); return current; } @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - Widget result = new LayoutBuilder( + Widget result = LayoutBuilder( builder: _build, ); if (widget.width != null || widget.height != null) { - result = new SizedBox( + result = SizedBox( width: widget.width, height: widget.height, child: result, diff --git a/packages/flutter/lib/src/material/ink_highlight.dart b/packages/flutter/lib/src/material/ink_highlight.dart index 26019f714e..591654ca80 100644 --- a/packages/flutter/lib/src/material/ink_highlight.dart +++ b/packages/flutter/lib/src/material/ink_highlight.dart @@ -54,11 +54,11 @@ class InkHighlight extends InteractiveInkFeature { _textDirection = textDirection, _rectCallback = rectCallback, super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) { - _alphaController = new AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync) + _alphaController = AnimationController(duration: _kHighlightFadeDuration, vsync: controller.vsync) ..addListener(controller.markNeedsPaint) ..addStatusListener(_handleAlphaStatusChanged) ..forward(); - _alpha = new IntTween( + _alpha = IntTween( begin: 0, end: color.alpha ).animate(_alphaController); @@ -114,7 +114,7 @@ class InkHighlight extends InteractiveInkFeature { break; case BoxShape.rectangle: if (_borderRadius != BorderRadius.zero) { - final RRect clipRRect = new RRect.fromRectAndCorners( + final RRect clipRRect = RRect.fromRectAndCorners( rect, topLeft: _borderRadius.topLeft, topRight: _borderRadius.topRight, bottomLeft: _borderRadius.bottomLeft, bottomRight: _borderRadius.bottomRight, @@ -130,7 +130,7 @@ class InkHighlight extends InteractiveInkFeature { @override void paintFeature(Canvas canvas, Matrix4 transform) { - final Paint paint = new Paint()..color = color.withAlpha(_alpha.value); + final Paint paint = Paint()..color = color.withAlpha(_alpha.value); final Offset originOffset = MatrixUtils.getAsTranslation(transform); final Rect rect = _rectCallback != null ? _rectCallback() : Offset.zero & referenceBox.size; if (originOffset == null) { diff --git a/packages/flutter/lib/src/material/ink_ripple.dart b/packages/flutter/lib/src/material/ink_ripple.dart index b56aa7947a..0cae37b5fc 100644 --- a/packages/flutter/lib/src/material/ink_ripple.dart +++ b/packages/flutter/lib/src/material/ink_ripple.dart @@ -53,7 +53,7 @@ class _InkRippleFactory extends InteractiveInkFeatureFactory { double radius, VoidCallback onRemoved, }) { - return new InkRipple( + return InkRipple( controller: controller, referenceBox: referenceBox, position: position, @@ -137,25 +137,25 @@ class InkRipple extends InteractiveInkFeature { assert(_borderRadius != null); // Immediately begin fading-in the initial splash. - _fadeInController = new AnimationController(duration: _kFadeInDuration, vsync: controller.vsync) + _fadeInController = AnimationController(duration: _kFadeInDuration, vsync: controller.vsync) ..addListener(controller.markNeedsPaint) ..forward(); - _fadeIn = new IntTween( + _fadeIn = IntTween( begin: 0, end: color.alpha, ).animate(_fadeInController); // Controls the splash radius and its center. Starts upon confirm. - _radiusController = new AnimationController(duration: _kUnconfirmedRippleDuration, vsync: controller.vsync) + _radiusController = AnimationController(duration: _kUnconfirmedRippleDuration, vsync: controller.vsync) ..addListener(controller.markNeedsPaint) ..forward(); // Initial splash diameter is 60% of the target diameter, final // diameter is 10dps larger than the target diameter. - _radius = new Tween( + _radius = Tween( begin: _targetRadius * 0.30, end: _targetRadius + 5.0, ).animate( - new CurvedAnimation( + CurvedAnimation( parent: _radiusController, curve: Curves.ease, ) @@ -163,14 +163,14 @@ class InkRipple extends InteractiveInkFeature { // Controls the splash radius and its center. Starts upon confirm however its // Interval delays changes until the radius expansion has completed. - _fadeOutController = new AnimationController(duration: _kFadeOutDuration, vsync: controller.vsync) + _fadeOutController = AnimationController(duration: _kFadeOutDuration, vsync: controller.vsync) ..addListener(controller.markNeedsPaint) ..addStatusListener(_handleAlphaStatusChanged); - _fadeOut = new IntTween( + _fadeOut = IntTween( begin: color.alpha, end: 0, ).animate( - new CurvedAnimation( + CurvedAnimation( parent: _fadeOutController, curve: const Interval(_kFadeOutIntervalStart, 1.0) ), @@ -234,7 +234,7 @@ class InkRipple extends InteractiveInkFeature { @override void paintFeature(Canvas canvas, Matrix4 transform) { final int alpha = _fadeInController.isAnimating ? _fadeIn.value : _fadeOut.value; - final Paint paint = new Paint()..color = color.withAlpha(alpha); + final Paint paint = Paint()..color = color.withAlpha(alpha); // Splash moves to the center of the reference box. final Offset center = Offset.lerp( _position, @@ -253,7 +253,7 @@ class InkRipple extends InteractiveInkFeature { if (_customBorder != null) { canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection)); } else if (_borderRadius != BorderRadius.zero) { - canvas.clipRRect(new RRect.fromRectAndCorners( + canvas.clipRRect(RRect.fromRectAndCorners( rect, topLeft: _borderRadius.topLeft, topRight: _borderRadius.topRight, bottomLeft: _borderRadius.bottomLeft, bottomRight: _borderRadius.bottomRight, diff --git a/packages/flutter/lib/src/material/ink_splash.dart b/packages/flutter/lib/src/material/ink_splash.dart index d6ede371ed..766abc1928 100644 --- a/packages/flutter/lib/src/material/ink_splash.dart +++ b/packages/flutter/lib/src/material/ink_splash.dart @@ -59,7 +59,7 @@ class _InkSplashFactory extends InteractiveInkFeatureFactory { double radius, VoidCallback onRemoved, }) { - return new InkSplash( + return InkSplash( controller: controller, referenceBox: referenceBox, position: position, @@ -137,17 +137,17 @@ class InkSplash extends InteractiveInkFeature { _textDirection = textDirection, super(controller: controller, referenceBox: referenceBox, color: color, onRemoved: onRemoved) { assert(_borderRadius != null); - _radiusController = new AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync) + _radiusController = AnimationController(duration: _kUnconfirmedSplashDuration, vsync: controller.vsync) ..addListener(controller.markNeedsPaint) ..forward(); - _radius = new Tween( + _radius = Tween( begin: _kSplashInitialSize, end: _targetRadius ).animate(_radiusController); - _alphaController = new AnimationController(duration: _kSplashFadeDuration, vsync: controller.vsync) + _alphaController = AnimationController(duration: _kSplashFadeDuration, vsync: controller.vsync) ..addListener(controller.markNeedsPaint) ..addStatusListener(_handleAlphaStatusChanged); - _alpha = new IntTween( + _alpha = IntTween( begin: color.alpha, end: 0 ).animate(_alphaController); @@ -173,7 +173,7 @@ class InkSplash extends InteractiveInkFeature { void confirm() { final int duration = (_targetRadius / _kSplashConfirmedVelocity).floor(); _radiusController - ..duration = new Duration(milliseconds: duration) + ..duration = Duration(milliseconds: duration) ..forward(); _alphaController.forward(); } @@ -198,7 +198,7 @@ class InkSplash extends InteractiveInkFeature { @override void paintFeature(Canvas canvas, Matrix4 transform) { - final Paint paint = new Paint()..color = color.withAlpha(_alpha.value); + final Paint paint = Paint()..color = color.withAlpha(_alpha.value); Offset center = _position; if (_repositionToReferenceBox) center = Offset.lerp(center, referenceBox.size.center(Offset.zero), _radiusController.value); @@ -214,7 +214,7 @@ class InkSplash extends InteractiveInkFeature { if (_customBorder != null) { canvas.clipPath(_customBorder.getOuterPath(rect, textDirection: _textDirection)); } else if (_borderRadius != BorderRadius.zero) { - canvas.clipRRect(new RRect.fromRectAndCorners( + canvas.clipRRect(RRect.fromRectAndCorners( rect, topLeft: _borderRadius.topLeft, topRight: _borderRadius.topRight, bottomLeft: _borderRadius.bottomLeft, bottomRight: _borderRadius.bottomRight, diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index c81ccd3d5f..84eb5ddd96 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -378,7 +378,7 @@ class InkResponse extends StatefulWidget { } @override - _InkResponseState createState() => new _InkResponseState(); + _InkResponseState createState() => _InkResponseState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { @@ -394,9 +394,9 @@ class InkResponse extends StatefulWidget { gestures.add('tap down'); if (onTapCancel != null) gestures.add('tap cancel'); - properties.add(new IterableProperty('gestures', gestures, ifEmpty: '')); - properties.add(new DiagnosticsProperty('containedInkWell', containedInkWell, level: DiagnosticLevel.fine)); - properties.add(new DiagnosticsProperty( + properties.add(IterableProperty('gestures', gestures, ifEmpty: '')); + properties.add(DiagnosticsProperty('containedInkWell', containedInkWell, level: DiagnosticLevel.fine)); + properties.add(DiagnosticsProperty( 'highlightShape', highlightShape, description: '${containedInkWell ? "clipped to " : ""}$highlightShape', @@ -419,7 +419,7 @@ class _InkResponseState extends State with AutomaticKe if (value) { if (_lastHighlight == null) { final RenderBox referenceBox = context.findRenderObject(); - _lastHighlight = new InkHighlight( + _lastHighlight = InkHighlight( controller: Material.of(context), referenceBox: referenceBox, color: widget.highlightColor ?? Theme.of(context).highlightColor, @@ -487,7 +487,7 @@ class _InkResponseState extends State with AutomaticKe void _handleTapDown(TapDownDetails details) { final InteractiveInkFeature splash = _createInkFeature(details); - _splashes ??= new HashSet(); + _splashes ??= HashSet(); _splashes.add(splash); _currentSplash = splash; if (widget.onTapDown != null) { @@ -557,7 +557,7 @@ class _InkResponseState extends State with AutomaticKe _lastHighlight?.color = widget.highlightColor ?? themeData.highlightColor; _currentSplash?.color = widget.splashColor ?? themeData.splashColor; final bool enabled = widget.onTap != null || widget.onDoubleTap != null || widget.onLongPress != null; - return new GestureDetector( + return GestureDetector( onTapDown: enabled ? _handleTapDown : null, onTap: enabled ? () => _handleTap(context) : null, onTapCancel: enabled ? _handleTapCancel : null, diff --git a/packages/flutter/lib/src/material/input_border.dart b/packages/flutter/lib/src/material/input_border.dart index c2b1a97fd8..33d828bc5d 100644 --- a/packages/flutter/lib/src/material/input_border.dart +++ b/packages/flutter/lib/src/material/input_border.dart @@ -97,12 +97,12 @@ class _NoInputBorder extends InputBorder { @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path()..addRect(rect); + return Path()..addRect(rect); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path()..addRect(rect); + return Path()..addRect(rect); } @override @@ -163,7 +163,7 @@ class UnderlineInputBorder extends InputBorder { @override UnderlineInputBorder copyWith({ BorderSide borderSide, BorderRadius borderRadius }) { - return new UnderlineInputBorder( + return UnderlineInputBorder( borderSide: borderSide ?? this.borderSide, borderRadius: borderRadius ?? this.borderRadius, ); @@ -171,29 +171,29 @@ class UnderlineInputBorder extends InputBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.only(bottom: borderSide.width); + return EdgeInsets.only(bottom: borderSide.width); } @override UnderlineInputBorder scale(double t) { - return new UnderlineInputBorder(borderSide: borderSide.scale(t)); + return UnderlineInputBorder(borderSide: borderSide.scale(t)); } @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() - ..addRect(new Rect.fromLTWH(rect.left, rect.top, rect.width, math.max(0.0, rect.height - borderSide.width))); + return Path() + ..addRect(Rect.fromLTWH(rect.left, rect.top, rect.width, math.max(0.0, rect.height - borderSide.width))); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path()..addRRect(borderRadius.resolve(textDirection).toRRect(rect)); + return Path()..addRRect(borderRadius.resolve(textDirection).toRRect(rect)); } @override ShapeBorder lerpFrom(ShapeBorder a, double t) { if (a is UnderlineInputBorder) { - return new UnderlineInputBorder( + return UnderlineInputBorder( borderSide: BorderSide.lerp(a.borderSide, borderSide, t), ); } @@ -203,7 +203,7 @@ class UnderlineInputBorder extends InputBorder { @override ShapeBorder lerpTo(ShapeBorder b, double t) { if (b is UnderlineInputBorder) { - return new UnderlineInputBorder( + return UnderlineInputBorder( borderSide: BorderSide.lerp(borderSide, b.borderSide, t), ); } @@ -307,7 +307,7 @@ class OutlineInputBorder extends InputBorder { BorderRadius borderRadius, double gapPadding, }) { - return new OutlineInputBorder( + return OutlineInputBorder( borderSide: borderSide ?? this.borderSide, borderRadius: borderRadius ?? this.borderRadius, gapPadding: gapPadding ?? this.gapPadding, @@ -316,12 +316,12 @@ class OutlineInputBorder extends InputBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(borderSide.width); + return EdgeInsets.all(borderSide.width); } @override OutlineInputBorder scale(double t) { - return new OutlineInputBorder( + return OutlineInputBorder( borderSide: borderSide.scale(t), borderRadius: borderRadius * t, gapPadding: gapPadding * t, @@ -332,7 +332,7 @@ class OutlineInputBorder extends InputBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { if (a is OutlineInputBorder) { final OutlineInputBorder outline = a; - return new OutlineInputBorder( + return OutlineInputBorder( borderRadius: BorderRadius.lerp(outline.borderRadius, borderRadius, t), borderSide: BorderSide.lerp(outline.borderSide, borderSide, t), gapPadding: outline.gapPadding, @@ -345,7 +345,7 @@ class OutlineInputBorder extends InputBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { if (b is OutlineInputBorder) { final OutlineInputBorder outline = b; - return new OutlineInputBorder( + return OutlineInputBorder( borderRadius: BorderRadius.lerp(borderRadius, outline.borderRadius, t), borderSide: BorderSide.lerp(borderSide, outline.borderSide, t), gapPadding: outline.gapPadding, @@ -356,36 +356,36 @@ class OutlineInputBorder extends InputBorder { @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(borderRadius.resolve(textDirection).toRRect(rect).deflate(borderSide.width)); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(borderRadius.resolve(textDirection).toRRect(rect)); } Path _gapBorderPath(Canvas canvas, RRect center, double start, double extent) { - final Rect tlCorner = new Rect.fromLTWH( + final Rect tlCorner = Rect.fromLTWH( center.left, center.top, center.tlRadiusX * 2.0, center.tlRadiusY * 2.0, ); - final Rect trCorner = new Rect.fromLTWH( + final Rect trCorner = Rect.fromLTWH( center.right - center.trRadiusX * 2.0, center.top, center.trRadiusX * 2.0, center.trRadiusY * 2.0, ); - final Rect brCorner = new Rect.fromLTWH( + final Rect brCorner = Rect.fromLTWH( center.right - center.brRadiusX * 2.0, center.bottom - center.brRadiusY * 2.0, center.brRadiusX * 2.0, center.brRadiusY * 2.0, ); - final Rect blCorner = new Rect.fromLTWH( + final Rect blCorner = Rect.fromLTWH( center.left, center.bottom - center.brRadiusY * 2.0, center.blRadiusX * 2.0, @@ -397,7 +397,7 @@ class OutlineInputBorder extends InputBorder { ? math.asin(start / center.tlRadiusX) : math.pi / 2.0; - final Path path = new Path() + final Path path = Path() ..addArc(tlCorner, math.pi, tlCornerArcSweep) ..moveTo(center.left + center.tlRadiusX, center.top); diff --git a/packages/flutter/lib/src/material/input_decorator.dart b/packages/flutter/lib/src/material/input_decorator.dart index ec1aba31d6..d75e878f89 100644 --- a/packages/flutter/lib/src/material/input_decorator.dart +++ b/packages/flutter/lib/src/material/input_decorator.dart @@ -86,7 +86,7 @@ class _InputBorderPainter extends CustomPainter { if (fillColor.alpha > 0) { canvas.drawPath( borderValue.getOuterPath(canvasRect, textDirection: textDirection), - new Paint() + Paint() ..color = fillColor ..style = PaintingStyle.fill, ); @@ -136,7 +136,7 @@ class _BorderContainer extends StatefulWidget { final Widget child; @override - _BorderContainerState createState() => new _BorderContainerState(); + _BorderContainerState createState() => _BorderContainerState(); } class _BorderContainerState extends State<_BorderContainer> with SingleTickerProviderStateMixin { @@ -147,15 +147,15 @@ class _BorderContainerState extends State<_BorderContainer> with SingleTickerPro @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: _kTransitionDuration, vsync: this, ); - _borderAnimation = new CurvedAnimation( + _borderAnimation = CurvedAnimation( parent: _controller, curve: _kTransitionCurve, ); - _border = new _InputBorderTween( + _border = _InputBorderTween( begin: widget.border, end: widget.border, ); @@ -171,7 +171,7 @@ class _BorderContainerState extends State<_BorderContainer> with SingleTickerPro void didUpdateWidget(_BorderContainer oldWidget) { super.didUpdateWidget(oldWidget); if (widget.border != oldWidget.border) { - _border = new _InputBorderTween( + _border = _InputBorderTween( begin: oldWidget.border, end: widget.border, ); @@ -183,9 +183,9 @@ class _BorderContainerState extends State<_BorderContainer> with SingleTickerPro @override Widget build(BuildContext context) { - return new CustomPaint( - foregroundPainter: new _InputBorderPainter( - repaint: new Listenable.merge([_borderAnimation, widget.gap]), + return CustomPaint( + foregroundPainter: _InputBorderPainter( + repaint: Listenable.merge([_borderAnimation, widget.gap]), borderAnimation: _borderAnimation, border: _border, gapAnimation: widget.gapAnimation, @@ -224,8 +224,8 @@ class _Shaker extends AnimatedWidget { @override Widget build(BuildContext context) { - return new Transform( - transform: new Matrix4.translationValues(translateX, 0.0, 0.0), + return Transform( + transform: Matrix4.translationValues(translateX, 0.0, 0.0), child: child, ); } @@ -253,7 +253,7 @@ class _HelperError extends StatefulWidget { final int errorMaxLines; @override - _HelperErrorState createState() => new _HelperErrorState(); + _HelperErrorState createState() => _HelperErrorState(); } class _HelperErrorState extends State<_HelperError> with SingleTickerProviderStateMixin { @@ -268,7 +268,7 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: _kTransitionDuration, vsync: this, ); @@ -320,9 +320,9 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta Widget _buildHelper() { assert(widget.helperText != null); - return new Opacity( + return Opacity( opacity: 1.0 - _controller.value, - child: new Text( + child: Text( widget.helperText, style: widget.helperStyle, textAlign: widget.textAlign, @@ -333,14 +333,14 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta Widget _buildError() { assert(widget.errorText != null); - return new Opacity( + return Opacity( opacity: _controller.value, - child: new FractionalTranslation( - translation: new Tween( + child: FractionalTranslation( + translation: Tween( begin: const Offset(0.0, -0.25), end: const Offset(0.0, 0.0), ).evaluate(_controller.view), - child: new Text( + child: Text( widget.errorText, style: widget.errorStyle, textAlign: widget.textAlign, @@ -380,9 +380,9 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta return _buildHelper(); if (widget.errorText != null) { - return new Stack( + return Stack( children: [ - new Opacity( + Opacity( opacity: 1.0 - _controller.value, child: _helper, ), @@ -392,10 +392,10 @@ class _HelperErrorState extends State<_HelperError> with SingleTickerProviderSta } if (widget.helperText != null) { - return new Stack( + return Stack( children: [ _buildHelper(), - new Opacity( + Opacity( opacity: _controller.value, child: _error, ), @@ -890,7 +890,7 @@ class _RenderDecoration extends RenderBox { } } - return new _RenderDecorationLayout( + return _RenderDecorationLayout( boxToBaseline: boxToBaseline, containerHeight: containerHeight, inputBaseline: inputBaseline, @@ -972,7 +972,7 @@ class _RenderDecoration extends RenderBox { final double overallHeight = layout.containerHeight + layout.subtextHeight; if (container != null) { - final BoxConstraints containerConstraints = new BoxConstraints.tightFor( + final BoxConstraints containerConstraints = BoxConstraints.tightFor( height: layout.containerHeight, width: overallWidth - _boxSize(icon).width, ); @@ -986,18 +986,18 @@ class _RenderDecoration extends RenderBox { x = _boxSize(icon).width; break; } - _boxParentData(container).offset = new Offset(x, 0.0); + _boxParentData(container).offset = Offset(x, 0.0); } double height; double centerLayout(RenderBox box, double x) { - _boxParentData(box).offset = new Offset(x, (height - box.size.height) / 2.0); + _boxParentData(box).offset = Offset(x, (height - box.size.height) / 2.0); return box.size.width; } double baseline; double baselineLayout(RenderBox box, double x) { - _boxParentData(box).offset = new Offset(x, baseline - layout.boxToBaseline[box]); + _boxParentData(box).offset = Offset(x, baseline - layout.boxToBaseline[box]); return box.size.width; } @@ -1109,7 +1109,7 @@ class _RenderDecoration extends RenderBox { decoration.borderGap.extent = 0.0; } - size = constraints.constrain(new Size(overallWidth, overallHeight)); + size = constraints.constrain(Size(overallWidth, overallHeight)); assert(size.width == constraints.constrainWidth(overallWidth)); assert(size.height == constraints.constrainHeight(overallHeight)); } @@ -1145,7 +1145,7 @@ class _RenderDecoration extends RenderBox { break; } final double dy = lerpDouble(0.0, floatingY - labelOffset.dy, t); - _labelTransform = new Matrix4.identity() + _labelTransform = Matrix4.identity() ..translate(dx, labelOffset.dy + dy) ..scale(scale); context.pushTransform(needsCompositing, offset, _labelTransform, _paintLabel); @@ -1354,11 +1354,11 @@ class _Decorator extends RenderObjectWidget { final bool isFocused; @override - _RenderDecorationElement createElement() => new _RenderDecorationElement(this); + _RenderDecorationElement createElement() => _RenderDecorationElement(this); @override _RenderDecoration createRenderObject(BuildContext context) { - return new _RenderDecoration( + return _RenderDecoration( decoration: decoration, textDirection: textDirection, textBaseline: textBaseline, @@ -1393,11 +1393,11 @@ class _AffixText extends StatelessWidget { Widget build(BuildContext context) { return DefaultTextStyle.merge( style: style, - child: new AnimatedOpacity( + child: AnimatedOpacity( duration: _kTransitionDuration, curve: _kTransitionCurve, opacity: labelIsFloating ? 1.0 : 0.0, - child: child ?? new Text(text, style: style,), + child: child ?? Text(text, style: style,), ), ); } @@ -1484,7 +1484,7 @@ class InputDecorator extends StatefulWidget { bool get _labelIsFloating => !isEmpty || isFocused; @override - _InputDecoratorState createState() => new _InputDecoratorState(); + _InputDecoratorState createState() => _InputDecoratorState(); /// The RenderBox that defines this decorator's "container". That's the /// area which is filled if [InputDecoration.isFilled] is true. It's the area @@ -1501,29 +1501,29 @@ class InputDecorator extends StatefulWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('decoration', decoration)); - properties.add(new DiagnosticsProperty('baseStyle', baseStyle, defaultValue: null)); - properties.add(new DiagnosticsProperty('isFocused', isFocused)); - properties.add(new DiagnosticsProperty('isEmpty', isEmpty)); + properties.add(DiagnosticsProperty('decoration', decoration)); + properties.add(DiagnosticsProperty('baseStyle', baseStyle, defaultValue: null)); + properties.add(DiagnosticsProperty('isFocused', isFocused)); + properties.add(DiagnosticsProperty('isEmpty', isEmpty)); } } class _InputDecoratorState extends State with TickerProviderStateMixin { AnimationController _floatingLabelController; AnimationController _shakingLabelController; - final _InputBorderGap _borderGap = new _InputBorderGap(); + final _InputBorderGap _borderGap = _InputBorderGap(); @override void initState() { super.initState(); - _floatingLabelController = new AnimationController( + _floatingLabelController = AnimationController( duration: _kTransitionDuration, vsync: this, value: widget._labelIsFloating ? 1.0 : 0.0, ); _floatingLabelController.addListener(_handleChange); - _shakingLabelController = new AnimationController( + _shakingLabelController = AnimationController( duration: _kTransitionDuration, vsync: this, ); @@ -1682,7 +1682,7 @@ class _InputDecoratorState extends State with TickerProviderStat borderWeight = isFocused ? 2.0 : 1.0; final InputBorder border = decoration.border ?? const UnderlineInputBorder(); - return border.copyWith(borderSide: new BorderSide(color: borderColor, width: borderWeight)); + return border.copyWith(borderSide: BorderSide(color: borderColor, width: borderWeight)); } @override @@ -1692,11 +1692,11 @@ class _InputDecoratorState extends State with TickerProviderStat final TextBaseline textBaseline = inlineStyle.textBaseline; final TextStyle hintStyle = inlineStyle.merge(decoration.hintStyle); - final Widget hint = decoration.hintText == null ? null : new AnimatedOpacity( + final Widget hint = decoration.hintText == null ? null : AnimatedOpacity( opacity: (isEmpty && !_hasInlineLabel) ? 1.0 : 0.0, duration: _kTransitionDuration, curve: _kTransitionCurve, - child: new Text( + child: Text( decoration.hintText, style: hintStyle, overflow: TextOverflow.ellipsis, @@ -1714,7 +1714,7 @@ class _InputDecoratorState extends State with TickerProviderStat border = isError ? decoration.errorBorder : decoration.enabledBorder; border ??= _getDefaultBorder(themeData); - final Widget container = new _BorderContainer( + final Widget container = _BorderContainer( border: border, gap: _borderGap, gapAnimation: _floatingLabelController.view, @@ -1722,15 +1722,15 @@ class _InputDecoratorState extends State with TickerProviderStat ); final TextStyle inlineLabelStyle = inlineStyle.merge(decoration.labelStyle); - final Widget label = decoration.labelText == null ? null : new _Shaker( + final Widget label = decoration.labelText == null ? null : _Shaker( animation: _shakingLabelController.view, - child: new AnimatedDefaultTextStyle( + child: AnimatedDefaultTextStyle( duration: _kTransitionDuration, curve: _kTransitionCurve, style: widget._labelIsFloating ? _getFloatingLabelStyle(themeData) : inlineLabelStyle, - child: new Text( + child: Text( decoration.labelText, overflow: TextOverflow.ellipsis, textAlign: textAlign, @@ -1739,7 +1739,7 @@ class _InputDecoratorState extends State with TickerProviderStat ); final Widget prefix = decoration.prefix == null && decoration.prefixText == null ? null : - new _AffixText( + _AffixText( labelIsFloating: widget._labelIsFloating, text: decoration.prefixText, style: decoration.prefixStyle ?? hintStyle, @@ -1747,7 +1747,7 @@ class _InputDecoratorState extends State with TickerProviderStat ); final Widget suffix = decoration.suffix == null && decoration.suffixText == null ? null : - new _AffixText( + _AffixText( labelIsFloating: widget._labelIsFloating, text: decoration.suffixText, style: decoration.suffixStyle ?? hintStyle, @@ -1760,10 +1760,10 @@ class _InputDecoratorState extends State with TickerProviderStat final Color iconColor = isFocused ? activeColor : _getDefaultIconColor(themeData); final Widget icon = decoration.icon == null ? null : - new Padding( + Padding( padding: const EdgeInsetsDirectional.only(end: 16.0), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: iconColor, size: iconSize, ), @@ -1772,13 +1772,13 @@ class _InputDecoratorState extends State with TickerProviderStat ); final Widget prefixIcon = decoration.prefixIcon == null ? null : - new Center( + Center( widthFactor: 1.0, heightFactor: 1.0, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: iconColor, size: iconSize, ), @@ -1788,13 +1788,13 @@ class _InputDecoratorState extends State with TickerProviderStat ); final Widget suffixIcon = decoration.suffixIcon == null ? null : - new Center( + Center( widthFactor: 1.0, heightFactor: 1.0, child: ConstrainedBox( constraints: const BoxConstraints(minWidth: 48.0, minHeight: 48.0), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( color: iconColor, size: iconSize, ), @@ -1803,7 +1803,7 @@ class _InputDecoratorState extends State with TickerProviderStat ), ); - final Widget helperError = new _HelperError( + final Widget helperError = _HelperError( textAlign: textAlign, helperText: decoration.helperText, helperStyle: _getHelperStyle(themeData), @@ -1813,9 +1813,9 @@ class _InputDecoratorState extends State with TickerProviderStat ); final Widget counter = decoration.counterText == null ? null : - new Semantics( + Semantics( container: true, - child: new Text( + child: Text( decoration.counterText, style: _getHelperStyle(themeData).merge(decoration.counterStyle), overflow: TextOverflow.ellipsis, @@ -1855,8 +1855,8 @@ class _InputDecoratorState extends State with TickerProviderStat : const EdgeInsets.fromLTRB(12.0, 24.0, 12.0, 16.0)); } - return new _Decorator( - decoration: new _Decoration( + return _Decorator( + decoration: _Decoration( contentPadding: contentPadding, isCollapsed: decoration.isCollapsed, floatingLabelHeight: floatingLabelHeight, @@ -2433,7 +2433,7 @@ class InputDecoration { bool enabled, String semanticCounterText, }) { - return new InputDecoration( + return InputDecoration( icon: icon ?? this.icon, labelText: labelText ?? this.labelText, labelStyle: labelStyle ?? this.labelStyle, @@ -2946,24 +2946,24 @@ class InputDecorationTheme extends Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); const InputDecorationTheme defaultTheme = InputDecorationTheme(); - properties.add(new DiagnosticsProperty('labelStyle', labelStyle, defaultValue: defaultTheme.labelStyle)); - properties.add(new DiagnosticsProperty('helperStyle', helperStyle, defaultValue: defaultTheme.helperStyle)); - properties.add(new DiagnosticsProperty('hintStyle', hintStyle, defaultValue: defaultTheme.hintStyle)); - properties.add(new DiagnosticsProperty('errorStyle', errorStyle, defaultValue: defaultTheme.errorStyle)); - properties.add(new DiagnosticsProperty('errorMaxLines', errorMaxLines, defaultValue: defaultTheme.errorMaxLines)); - properties.add(new DiagnosticsProperty('isDense', isDense, defaultValue: defaultTheme.isDense)); - properties.add(new DiagnosticsProperty('contentPadding', contentPadding, defaultValue: defaultTheme.contentPadding)); - properties.add(new DiagnosticsProperty('isCollapsed', isCollapsed, defaultValue: defaultTheme.isCollapsed)); - properties.add(new DiagnosticsProperty('prefixStyle', prefixStyle, defaultValue: defaultTheme.prefixStyle)); - properties.add(new DiagnosticsProperty('suffixStyle', suffixStyle, defaultValue: defaultTheme.suffixStyle)); - properties.add(new DiagnosticsProperty('counterStyle', counterStyle, defaultValue: defaultTheme.counterStyle)); - properties.add(new DiagnosticsProperty('filled', filled, defaultValue: defaultTheme.filled)); - properties.add(new DiagnosticsProperty('fillColor', fillColor, defaultValue: defaultTheme.fillColor)); - properties.add(new DiagnosticsProperty('errorBorder', errorBorder, defaultValue: defaultTheme.errorBorder)); - properties.add(new DiagnosticsProperty('focusedBorder', focusedBorder, defaultValue: defaultTheme.focusedErrorBorder)); - properties.add(new DiagnosticsProperty('focusedErrorborder', focusedErrorBorder, defaultValue: defaultTheme.focusedErrorBorder)); - properties.add(new DiagnosticsProperty('disabledBorder', disabledBorder, defaultValue: defaultTheme.disabledBorder)); - properties.add(new DiagnosticsProperty('enabledBorder', enabledBorder, defaultValue: defaultTheme.enabledBorder)); - properties.add(new DiagnosticsProperty('border', border, defaultValue: defaultTheme.border)); + properties.add(DiagnosticsProperty('labelStyle', labelStyle, defaultValue: defaultTheme.labelStyle)); + properties.add(DiagnosticsProperty('helperStyle', helperStyle, defaultValue: defaultTheme.helperStyle)); + properties.add(DiagnosticsProperty('hintStyle', hintStyle, defaultValue: defaultTheme.hintStyle)); + properties.add(DiagnosticsProperty('errorStyle', errorStyle, defaultValue: defaultTheme.errorStyle)); + properties.add(DiagnosticsProperty('errorMaxLines', errorMaxLines, defaultValue: defaultTheme.errorMaxLines)); + properties.add(DiagnosticsProperty('isDense', isDense, defaultValue: defaultTheme.isDense)); + properties.add(DiagnosticsProperty('contentPadding', contentPadding, defaultValue: defaultTheme.contentPadding)); + properties.add(DiagnosticsProperty('isCollapsed', isCollapsed, defaultValue: defaultTheme.isCollapsed)); + properties.add(DiagnosticsProperty('prefixStyle', prefixStyle, defaultValue: defaultTheme.prefixStyle)); + properties.add(DiagnosticsProperty('suffixStyle', suffixStyle, defaultValue: defaultTheme.suffixStyle)); + properties.add(DiagnosticsProperty('counterStyle', counterStyle, defaultValue: defaultTheme.counterStyle)); + properties.add(DiagnosticsProperty('filled', filled, defaultValue: defaultTheme.filled)); + properties.add(DiagnosticsProperty('fillColor', fillColor, defaultValue: defaultTheme.fillColor)); + properties.add(DiagnosticsProperty('errorBorder', errorBorder, defaultValue: defaultTheme.errorBorder)); + properties.add(DiagnosticsProperty('focusedBorder', focusedBorder, defaultValue: defaultTheme.focusedErrorBorder)); + properties.add(DiagnosticsProperty('focusedErrorborder', focusedErrorBorder, defaultValue: defaultTheme.focusedErrorBorder)); + properties.add(DiagnosticsProperty('disabledBorder', disabledBorder, defaultValue: defaultTheme.disabledBorder)); + properties.add(DiagnosticsProperty('enabledBorder', enabledBorder, defaultValue: defaultTheme.enabledBorder)); + properties.add(DiagnosticsProperty('border', border, defaultValue: defaultTheme.border)); } } diff --git a/packages/flutter/lib/src/material/list_tile.dart b/packages/flutter/lib/src/material/list_tile.dart index 9c817c8442..cf89a7c901 100644 --- a/packages/flutter/lib/src/material/list_tile.dart +++ b/packages/flutter/lib/src/material/list_tile.dart @@ -65,10 +65,10 @@ class ListTileTheme extends InheritedWidget { @required Widget child, }) { assert(child != null); - return new Builder( + return Builder( builder: (BuildContext context) { final ListTileTheme parent = ListTileTheme.of(context); - return new ListTileTheme( + return ListTileTheme( key: key, dense: dense ?? parent.dense, style: style ?? parent.style, @@ -310,15 +310,15 @@ class ListTile extends StatelessWidget { final Iterator iterator = tiles.iterator; final bool isNotEmpty = iterator.moveNext(); - final Decoration decoration = new BoxDecoration( - border: new Border( + final Decoration decoration = BoxDecoration( + border: Border( bottom: Divider.createBorderSide(context, color: color), ), ); Widget tile = iterator.current; while (iterator.moveNext()) { - yield new DecoratedBox( + yield DecoratedBox( position: DecorationPosition.foreground, decoration: decoration, child: tile, @@ -410,7 +410,7 @@ class ListTile extends StatelessWidget { IconThemeData iconThemeData; if (leading != null || trailing != null) - iconThemeData = new IconThemeData(color: _iconColor(theme, tileTheme)); + iconThemeData = IconThemeData(color: _iconColor(theme, tileTheme)); Widget leadingIcon; if (leading != null) { @@ -421,7 +421,7 @@ class ListTile extends StatelessWidget { } final TextStyle titleStyle = _titleTextStyle(theme, tileTheme); - final Widget titleText = new AnimatedDefaultTextStyle( + final Widget titleText = AnimatedDefaultTextStyle( style: titleStyle, duration: kThemeChangeDuration, child: title ?? const SizedBox() @@ -431,7 +431,7 @@ class ListTile extends StatelessWidget { TextStyle subtitleStyle; if (subtitle != null) { subtitleStyle = _subtitleTextStyle(theme, tileTheme); - subtitleText = new AnimatedDefaultTextStyle( + subtitleText = AnimatedDefaultTextStyle( style: subtitleStyle, duration: kThemeChangeDuration, child: subtitle, @@ -452,17 +452,17 @@ class ListTile extends StatelessWidget { ?? tileTheme?.contentPadding?.resolve(textDirection) ?? _defaultContentPadding; - return new InkWell( + return InkWell( onTap: enabled ? onTap : null, onLongPress: enabled ? onLongPress : null, - child: new Semantics( + child: Semantics( selected: selected, enabled: enabled, - child: new SafeArea( + child: SafeArea( top: false, bottom: false, minimum: resolvedContentPadding, - child: new _ListTile( + child: _ListTile( leading: leadingIcon, title: titleText, subtitle: subtitleText, @@ -516,11 +516,11 @@ class _ListTile extends RenderObjectWidget { final TextBaseline subtitleBaselineType; @override - _ListTileElement createElement() => new _ListTileElement(this); + _ListTileElement createElement() => _ListTileElement(this); @override _RenderListTile createRenderObject(BuildContext context) { - return new _RenderListTile( + return _RenderListTile( isThreeLine: isThreeLine, isDense: isDense, textDirection: textDirection, @@ -969,28 +969,28 @@ class _RenderListTile extends RenderBox { switch (textDirection) { case TextDirection.rtl: { if (hasLeading) - _positionBox(leading, new Offset(tileWidth - leadingSize.width, leadingY)); + _positionBox(leading, Offset(tileWidth - leadingSize.width, leadingY)); final double titleX = hasTrailing ? trailingSize.width + _horizontalTitleGap : 0.0; - _positionBox(title, new Offset(titleX, titleY)); + _positionBox(title, Offset(titleX, titleY)); if (hasSubtitle) - _positionBox(subtitle, new Offset(titleX, subtitleY)); + _positionBox(subtitle, Offset(titleX, subtitleY)); if (hasTrailing) - _positionBox(trailing, new Offset(0.0, trailingY)); + _positionBox(trailing, Offset(0.0, trailingY)); break; } case TextDirection.ltr: { if (hasLeading) - _positionBox(leading, new Offset(0.0, leadingY)); - _positionBox(title, new Offset(titleStart, titleY)); + _positionBox(leading, Offset(0.0, leadingY)); + _positionBox(title, Offset(titleStart, titleY)); if (hasSubtitle) - _positionBox(subtitle, new Offset(titleStart, subtitleY)); + _positionBox(subtitle, Offset(titleStart, subtitleY)); if (hasTrailing) - _positionBox(trailing, new Offset(tileWidth - trailingSize.width, trailingY)); + _positionBox(trailing, Offset(tileWidth - trailingSize.width, trailingY)); break; } } - size = constraints.constrain(new Size(tileWidth, tileHeight)); + size = constraints.constrain(Size(tileWidth, tileHeight)); assert(size.width == constraints.constrainWidth(tileWidth)); assert(size.height == constraints.constrainHeight(tileHeight)); } diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index dc06f8e9ec..88e24d6fed 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -55,9 +55,9 @@ enum MaterialType { /// * [Material] final Map kMaterialEdges = { MaterialType.canvas: null, - MaterialType.card: new BorderRadius.circular(2.0), + MaterialType.card: BorderRadius.circular(2.0), MaterialType.circle: null, - MaterialType.button: new BorderRadius.circular(2.0), + MaterialType.button: BorderRadius.circular(2.0), MaterialType.transparency: null, }; @@ -266,18 +266,18 @@ class Material extends StatefulWidget { } @override - _MaterialState createState() => new _MaterialState(); + _MaterialState createState() => _MaterialState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('type', type)); - properties.add(new DoubleProperty('elevation', elevation, defaultValue: 0.0)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('shadowColor', shadowColor, defaultValue: const Color(0xFF000000))); + properties.add(EnumProperty('type', type)); + properties.add(DoubleProperty('elevation', elevation, defaultValue: 0.0)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('shadowColor', shadowColor, defaultValue: const Color(0xFF000000))); textStyle?.debugFillProperties(properties, prefix: 'textStyle.'); - properties.add(new DiagnosticsProperty('shape', shape, defaultValue: null)); - properties.add(new EnumProperty('borderRadius', borderRadius, defaultValue: null)); + properties.add(DiagnosticsProperty('shape', shape, defaultValue: null)); + properties.add(EnumProperty('borderRadius', borderRadius, defaultValue: null)); } /// The default radius of an ink splash in logical pixels. @@ -285,7 +285,7 @@ class Material extends StatefulWidget { } class _MaterialState extends State with TickerProviderStateMixin { - final GlobalKey _inkFeatureRenderer = new GlobalKey(debugLabel: 'ink renderer'); + final GlobalKey _inkFeatureRenderer = GlobalKey(debugLabel: 'ink renderer'); Color _getBackgroundColor(BuildContext context) { if (widget.color != null) @@ -306,19 +306,19 @@ class _MaterialState extends State with TickerProviderStateMixin { assert(backgroundColor != null || widget.type == MaterialType.transparency); Widget contents = widget.child; if (contents != null) { - contents = new AnimatedDefaultTextStyle( + contents = AnimatedDefaultTextStyle( style: widget.textStyle ?? Theme.of(context).textTheme.body1, duration: widget.animationDuration, child: contents ); } - contents = new NotificationListener( + contents = NotificationListener( onNotification: (LayoutChangedNotification notification) { final _RenderInkFeatures renderer = _inkFeatureRenderer.currentContext.findRenderObject(); renderer._didChangeLayout(); return true; }, - child: new _InkFeatures( + child: _InkFeatures( key: _inkFeatureRenderer, color: backgroundColor, child: contents, @@ -336,7 +336,7 @@ class _MaterialState extends State with TickerProviderStateMixin { // we choose not to as we want the change from the fast-path to the // slow-path to be noticeable in the construction site of Material. if (widget.type == MaterialType.canvas && widget.shape == null && widget.borderRadius == null) { - return new AnimatedPhysicalModel( + return AnimatedPhysicalModel( curve: Curves.fastOutSlowIn, duration: widget.animationDuration, shape: BoxShape.rectangle, @@ -355,7 +355,7 @@ class _MaterialState extends State with TickerProviderStateMixin { if (widget.type == MaterialType.transparency) return _transparentInterior(shape: shape, clipBehavior: widget.clipBehavior, contents: contents); - return new _MaterialInterior( + return _MaterialInterior( curve: Curves.fastOutSlowIn, duration: widget.animationDuration, shape: shape, @@ -368,16 +368,16 @@ class _MaterialState extends State with TickerProviderStateMixin { } static Widget _transparentInterior({ShapeBorder shape, Clip clipBehavior, Widget contents}) { - final _ShapeBorderPaint child = new _ShapeBorderPaint( + final _ShapeBorderPaint child = _ShapeBorderPaint( child: contents, shape: shape, ); if (clipBehavior == Clip.none) { return child; } - return new ClipPath( + return ClipPath( child: child, - clipper: new ShapeBorderClipper(shape: shape), + clipper: ShapeBorderClipper(shape: shape), clipBehavior: clipBehavior, ); } @@ -393,7 +393,7 @@ class _MaterialState extends State with TickerProviderStateMixin { if (widget.shape != null) return widget.shape; if (widget.borderRadius != null) - return new RoundedRectangleBorder(borderRadius: widget.borderRadius); + return RoundedRectangleBorder(borderRadius: widget.borderRadius); switch (widget.type) { case MaterialType.canvas: case MaterialType.transparency: @@ -401,7 +401,7 @@ class _MaterialState extends State with TickerProviderStateMixin { case MaterialType.card: case MaterialType.button: - return new RoundedRectangleBorder( + return RoundedRectangleBorder( borderRadius: widget.borderRadius ?? kMaterialEdges[widget.type], ); @@ -490,7 +490,7 @@ class _InkFeatures extends SingleChildRenderObjectWidget { @override _RenderInkFeatures createRenderObject(BuildContext context) { - return new _RenderInkFeatures( + return _RenderInkFeatures( color: color, vsync: vsync, ); @@ -555,7 +555,7 @@ abstract class InkFeature { descendants.add(node); } // determine the transform that gets our coordinate system to be like theirs - final Matrix4 transform = new Matrix4.identity(); + final Matrix4 transform = Matrix4.identity(); assert(descendants.length >= 2); for (int index = descendants.length - 1; index > 0; index -= 1) descendants[index].applyPaintTransform(descendants[index - 1], transform); @@ -636,15 +636,15 @@ class _MaterialInterior extends ImplicitlyAnimatedWidget { final Color shadowColor; @override - _MaterialInteriorState createState() => new _MaterialInteriorState(); + _MaterialInteriorState createState() => _MaterialInteriorState(); @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('shape', shape)); - description.add(new DoubleProperty('elevation', elevation)); - description.add(new DiagnosticsProperty('color', color)); - description.add(new DiagnosticsProperty('shadowColor', shadowColor)); + description.add(DiagnosticsProperty('shape', shape)); + description.add(DoubleProperty('elevation', elevation)); + description.add(DiagnosticsProperty('color', color)); + description.add(DiagnosticsProperty('shadowColor', shadowColor)); } } @@ -655,20 +655,20 @@ class _MaterialInteriorState extends AnimatedWidgetBaseState<_MaterialInterior> @override void forEachTween(TweenVisitor visitor) { - _elevation = visitor(_elevation, widget.elevation, (dynamic value) => new Tween(begin: value)); - _shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => new ColorTween(begin: value)); - _border = visitor(_border, widget.shape, (dynamic value) => new ShapeBorderTween(begin: value)); + _elevation = visitor(_elevation, widget.elevation, (dynamic value) => Tween(begin: value)); + _shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => ColorTween(begin: value)); + _border = visitor(_border, widget.shape, (dynamic value) => ShapeBorderTween(begin: value)); } @override Widget build(BuildContext context) { final ShapeBorder shape = _border.evaluate(animation); - return new PhysicalShape( - child: new _ShapeBorderPaint( + return PhysicalShape( + child: _ShapeBorderPaint( child: widget.child, shape: shape, ), - clipper: new ShapeBorderClipper( + clipper: ShapeBorderClipper( shape: shape, textDirection: Directionality.of(context) ), @@ -691,9 +691,9 @@ class _ShapeBorderPaint extends StatelessWidget { @override Widget build(BuildContext context) { - return new CustomPaint( + return CustomPaint( child: child, - foregroundPainter: new _ShapeBorderPainter(shape, Directionality.of(context)), + foregroundPainter: _ShapeBorderPainter(shape, Directionality.of(context)), ); } } diff --git a/packages/flutter/lib/src/material/material_localizations.dart b/packages/flutter/lib/src/material/material_localizations.dart index e8236f8e1a..19eaa08ad6 100644 --- a/packages/flutter/lib/src/material/material_localizations.dart +++ b/packages/flutter/lib/src/material/material_localizations.dart @@ -427,7 +427,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { case TimeOfDayFormat.HH_colon_mm: return _formatTwoDigitZeroPad(timeOfDay.hour); default: - throw new AssertionError('$runtimeType does not support $format.'); + throw AssertionError('$runtimeType does not support $format.'); } } @@ -493,7 +493,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { return number.toString(); final String digits = number.abs().toString(); - final StringBuffer result = new StringBuffer(number < 0 ? '-' : ''); + final StringBuffer result = StringBuffer(number < 0 ? '-' : ''); final int maxDigitIndex = digits.length - 1; for (int i = 0; i <= maxDigitIndex; i += 1) { result.write(digits[i]); @@ -513,7 +513,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { // - DateFormat operates on DateTime, which is sensitive to time eras and // time zones, while here we want to format hour and minute within one day // no matter what date the day falls on. - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); // Add hour:minute. buffer @@ -704,7 +704,7 @@ class DefaultMaterialLocalizations implements MaterialLocalizations { /// This method is typically used to create a [LocalizationsDelegate]. /// The [MaterialApp] does so by default. static Future load(Locale locale) { - return new SynchronousFuture(const DefaultMaterialLocalizations()); + return SynchronousFuture(const DefaultMaterialLocalizations()); } /// A [LocalizationsDelegate] that uses [DefaultMaterialLocalizations.load] diff --git a/packages/flutter/lib/src/material/mergeable_material.dart b/packages/flutter/lib/src/material/mergeable_material.dart index 54fc251398..5e333a2d8f 100644 --- a/packages/flutter/lib/src/material/mergeable_material.dart +++ b/packages/flutter/lib/src/material/mergeable_material.dart @@ -126,12 +126,12 @@ class MergeableMaterial extends StatefulWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('mainAxis', mainAxis)); - properties.add(new DoubleProperty('elevation', elevation.toDouble())); + properties.add(EnumProperty('mainAxis', mainAxis)); + properties.add(DoubleProperty('elevation', elevation.toDouble())); } @override - _MergeableMaterialState createState() => new _MergeableMaterialState(); + _MergeableMaterialState createState() => _MergeableMaterialState(); } class _AnimationTuple { @@ -158,7 +158,7 @@ class _MergeableMaterialState extends State with TickerProvid @override void initState() { super.initState(); - _children = new List.from(widget.children); + _children = List.from(widget.children); for (int i = 0; i < _children.length; i += 1) { if (_children[i] is MaterialGap) { @@ -170,27 +170,27 @@ class _MergeableMaterialState extends State with TickerProvid } void _initGap(MaterialGap gap) { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: kThemeAnimationDuration, vsync: this, ); - final CurvedAnimation startAnimation = new CurvedAnimation( + final CurvedAnimation startAnimation = CurvedAnimation( parent: controller, curve: Curves.fastOutSlowIn ); - final CurvedAnimation endAnimation = new CurvedAnimation( + final CurvedAnimation endAnimation = CurvedAnimation( parent: controller, curve: Curves.fastOutSlowIn ); - final CurvedAnimation gapAnimation = new CurvedAnimation( + final CurvedAnimation gapAnimation = CurvedAnimation( parent: controller, curve: Curves.fastOutSlowIn ); controller.addListener(_handleTick); - _animationTuples[gap.key] = new _AnimationTuple( + _animationTuples[gap.key] = _AnimationTuple( controller: controller, startAnimation: startAnimation, endAnimation: endAnimation, @@ -411,8 +411,8 @@ class _MergeableMaterialState extends State with TickerProvid } if (gapSizeSum != 0.0) { - final MaterialGap gap = new MaterialGap( - key: new UniqueKey(), + final MaterialGap gap = MaterialGap( + key: UniqueKey(), size: gapSizeSum ); _insertChild(startOld, gap); @@ -482,12 +482,12 @@ class _MergeableMaterialState extends State with TickerProvid } if (widget.mainAxis == Axis.vertical) { - return new BorderRadius.vertical( + return BorderRadius.vertical( top: start ? cardRadius : startRadius, bottom: end ? cardRadius : endRadius ); } else { - return new BorderRadius.horizontal( + return BorderRadius.horizontal( left: start ? cardRadius : startRadius, right: end ? cardRadius : endRadius ); @@ -524,13 +524,13 @@ class _MergeableMaterialState extends State with TickerProvid if (_children[i] is MaterialGap) { assert(slices.isNotEmpty); widgets.add( - new Container( - decoration: new BoxDecoration( + Container( + decoration: BoxDecoration( color: Theme.of(context).cardColor, borderRadius: _borderRadius(i - 1, widgets.isEmpty, false), shape: BoxShape.rectangle ), - child: new ListBody( + child: ListBody( mainAxis: widget.mainAxis, children: slices ) @@ -539,7 +539,7 @@ class _MergeableMaterialState extends State with TickerProvid slices = []; widgets.add( - new SizedBox( + SizedBox( width: widget.mainAxis == Axis.horizontal ? _getGapSize(i) : null, height: widget.mainAxis == Axis.vertical ? _getGapSize(i) : null ) @@ -559,15 +559,15 @@ class _MergeableMaterialState extends State with TickerProvid ); if (i == 0) { - border = new Border( + border = Border( bottom: hasBottomDivider ? divider : BorderSide.none ); } else if (i == _children.length - 1) { - border = new Border( + border = Border( top: hasTopDivider ? divider : BorderSide.none ); } else { - border = new Border( + border = Border( top: hasTopDivider ? divider : BorderSide.none, bottom: hasBottomDivider ? divider : BorderSide.none ); @@ -575,9 +575,9 @@ class _MergeableMaterialState extends State with TickerProvid assert(border != null); - child = new AnimatedContainer( - key: new _MergeableMaterialSliceKey(_children[i].key), - decoration: new BoxDecoration(border: border), + child = AnimatedContainer( + key: _MergeableMaterialSliceKey(_children[i].key), + decoration: BoxDecoration(border: border), duration: kThemeAnimationDuration, curve: Curves.fastOutSlowIn, child: child @@ -585,7 +585,7 @@ class _MergeableMaterialState extends State with TickerProvid } slices.add( - new Material( + Material( type: MaterialType.transparency, child: child ) @@ -595,13 +595,13 @@ class _MergeableMaterialState extends State with TickerProvid if (slices.isNotEmpty) { widgets.add( - new Container( - decoration: new BoxDecoration( + Container( + decoration: BoxDecoration( color: Theme.of(context).cardColor, borderRadius: _borderRadius(i - 1, widgets.isEmpty, true), shape: BoxShape.rectangle ), - child: new ListBody( + child: ListBody( mainAxis: widget.mainAxis, children: slices ) @@ -610,7 +610,7 @@ class _MergeableMaterialState extends State with TickerProvid slices = []; } - return new _MergeableMaterialListBody( + return _MergeableMaterialListBody( mainAxis: widget.mainAxis, boxShadows: kElevationToShadow[widget.elevation], items: _children, @@ -660,7 +660,7 @@ class _MergeableMaterialListBody extends ListBody { @override RenderListBody createRenderObject(BuildContext context) { - return new _RenderMergeableMaterialListBody( + return _RenderMergeableMaterialListBody( axisDirection: _getDirection(context), boxShadows: boxShadows, ); diff --git a/packages/flutter/lib/src/material/outline_button.dart b/packages/flutter/lib/src/material/outline_button.dart index 85f88e3174..9380cf9009 100644 --- a/packages/flutter/lib/src/material/outline_button.dart +++ b/packages/flutter/lib/src/material/outline_button.dart @@ -104,7 +104,7 @@ class OutlineButton extends StatefulWidget { assert(label != null), assert(clipBehavior != null), padding = const EdgeInsetsDirectional.only(start: 12.0, end: 16.0), - child = new Row( + child = Row( mainAxisSize: MainAxisSize.min, children: [ icon, @@ -243,25 +243,25 @@ class OutlineButton extends StatefulWidget { bool get enabled => onPressed != null; @override - _OutlineButtonState createState() => new _OutlineButtonState(); + _OutlineButtonState createState() => _OutlineButtonState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); - properties.add(new DiagnosticsProperty('textTheme', textTheme, defaultValue: null)); - properties.add(new DiagnosticsProperty('textColor', textColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledTextColor', disabledTextColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('highlightColor', highlightColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('splashColor', splashColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('highlightElevation', highlightElevation, defaultValue: 2.0)); - properties.add(new DiagnosticsProperty('borderSide', borderSide, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledBorderColor', disabledBorderColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('highlightedBorderColor', highlightedBorderColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); - properties.add(new DiagnosticsProperty('shape', shape, defaultValue: null)); + properties.add(ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); + properties.add(DiagnosticsProperty('textTheme', textTheme, defaultValue: null)); + properties.add(DiagnosticsProperty('textColor', textColor, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledTextColor', disabledTextColor, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('highlightColor', highlightColor, defaultValue: null)); + properties.add(DiagnosticsProperty('splashColor', splashColor, defaultValue: null)); + properties.add(DiagnosticsProperty('highlightElevation', highlightElevation, defaultValue: 2.0)); + properties.add(DiagnosticsProperty('borderSide', borderSide, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledBorderColor', disabledBorderColor, defaultValue: null)); + properties.add(DiagnosticsProperty('highlightedBorderColor', highlightedBorderColor, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('shape', shape, defaultValue: null)); } } @@ -282,17 +282,17 @@ class _OutlineButtonState extends State with SingleTickerProvider // button's fill is translucent, because the shadow fills the interior // of the button. - _controller = new AnimationController( + _controller = AnimationController( duration: _kPressDuration, vsync: this ); - _fillAnimation = new CurvedAnimation( + _fillAnimation = CurvedAnimation( parent: _controller, curve: const Interval(0.0, 0.5, curve: Curves.fastOutSlowIn, ), ); - _elevationAnimation = new CurvedAnimation( + _elevationAnimation = CurvedAnimation( parent: _controller, curve: const Interval(0.5, 0.5), reverseCurve: const Interval(1.0, 1.0), @@ -338,7 +338,7 @@ class _OutlineButtonState extends State with SingleTickerProvider final Color color = widget.color ?? (themeIsDark ? const Color(0x00000000) : const Color(0x00FFFFFF)); - final Tween colorTween = new ColorTween( + final Tween colorTween = ColorTween( begin: color.withAlpha(0x00), end: color.withAlpha(0xFF), ); @@ -375,14 +375,14 @@ class _OutlineButtonState extends State with SingleTickerProvider : (widget.disabledBorderColor ?? (themeIsDark ? Colors.grey[800] : Colors.grey[100])); - return new BorderSide( + return BorderSide( color: color, width: widget.borderSide?.width ?? 2.0, ); } double _getHighlightElevation() { - return new Tween( + return Tween( begin: 0.0, end: widget.highlightElevation ?? 2.0, ).evaluate(_elevationAnimation); @@ -395,10 +395,10 @@ class _OutlineButtonState extends State with SingleTickerProvider final Color textColor = _getTextColor(theme, buttonTheme); final Color splashColor = _getSplashColor(theme, buttonTheme); - return new AnimatedBuilder( + return AnimatedBuilder( animation: _controller, builder: (BuildContext context, Widget child) { - return new RaisedButton( + return RaisedButton( textColor: textColor, disabledTextColor: widget.disabledTextColor, color: _getFillColor(theme), @@ -419,7 +419,7 @@ class _OutlineButtonState extends State with SingleTickerProvider }); }, padding: widget.padding, - shape: new _OutlineBorder( + shape: _OutlineBorder( shape: widget.shape ?? buttonTheme.shape, side: _getOutline(theme, buttonTheme), ), @@ -446,12 +446,12 @@ class _OutlineBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override ShapeBorder scale(double t) { - return new _OutlineBorder( + return _OutlineBorder( shape: shape.scale(t), side: side.scale(t), ); @@ -461,7 +461,7 @@ class _OutlineBorder extends ShapeBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is _OutlineBorder) { - return new _OutlineBorder( + return _OutlineBorder( side: BorderSide.lerp(a.side, side, t), shape: ShapeBorder.lerp(a.shape, shape, t), ); @@ -473,7 +473,7 @@ class _OutlineBorder extends ShapeBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { assert(t != null); if (b is _OutlineBorder) { - return new _OutlineBorder( + return _OutlineBorder( side: BorderSide.lerp(side, b.side, t), shape: ShapeBorder.lerp(shape, b.shape, t), ); diff --git a/packages/flutter/lib/src/material/page.dart b/packages/flutter/lib/src/material/page.dart index b4c83affa6..82a989e7eb 100644 --- a/packages/flutter/lib/src/material/page.dart +++ b/packages/flutter/lib/src/material/page.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; import 'theme.dart'; // Fractional offset from 1/4 screen below the top to fully on screen. -final Tween _kBottomUpTween = new Tween( +final Tween _kBottomUpTween = Tween( begin: const Offset(0.0, 0.25), end: Offset.zero, ); @@ -20,11 +20,11 @@ class _MountainViewPageTransition extends StatelessWidget { @required bool fade, @required Animation routeAnimation, @required this.child, - }) : _positionAnimation = _kBottomUpTween.animate(new CurvedAnimation( + }) : _positionAnimation = _kBottomUpTween.animate(CurvedAnimation( parent: routeAnimation, // The route's linear 0.0 - 1.0 animation. curve: Curves.fastOutSlowIn, )), - _opacityAnimation = fade ? new CurvedAnimation( + _opacityAnimation = fade ? CurvedAnimation( parent: routeAnimation, curve: Curves.easeIn, // Eyeballed from other Material apps. ) : const AlwaysStoppedAnimation(1.0), @@ -37,9 +37,9 @@ class _MountainViewPageTransition extends StatelessWidget { @override Widget build(BuildContext context) { // TODO(ianh): tell the transform to be un-transformed for hit testing - return new SlideTransition( + return SlideTransition( position: _positionAnimation, - child: new FadeTransition( + child: FadeTransition( opacity: _opacityAnimation, child: child, ), @@ -97,7 +97,7 @@ class MaterialPageRoute extends PageRoute { /// It's lazily created on first use. CupertinoPageRoute get _cupertinoPageRoute { assert(_useCupertinoTransitions); - _internalCupertinoPageRoute ??= new CupertinoPageRoute( + _internalCupertinoPageRoute ??= CupertinoPageRoute( builder: builder, // Not used. fullscreenDialog: fullscreenDialog, hostRoute: this, @@ -142,14 +142,14 @@ class MaterialPageRoute extends PageRoute { @override Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { - final Widget result = new Semantics( + final Widget result = Semantics( scopesRoute: true, explicitChildNodes: true, child: builder(context), ); assert(() { if (result == null) { - throw new FlutterError( + throw FlutterError( 'The builder for route "${settings.name}" returned null.\n' 'Route builders must never return null.' ); @@ -164,7 +164,7 @@ class MaterialPageRoute extends PageRoute { if (_useCupertinoTransitions) { return _cupertinoPageRoute.buildTransitions(context, animation, secondaryAnimation, child); } else { - return new _MountainViewPageTransition( + return _MountainViewPageTransition( routeAnimation: animation, child: child, fade: true, diff --git a/packages/flutter/lib/src/material/paginated_data_table.dart b/packages/flutter/lib/src/material/paginated_data_table.dart index 2f1fdf08f9..fd4ccbc5ed 100644 --- a/packages/flutter/lib/src/material/paginated_data_table.dart +++ b/packages/flutter/lib/src/material/paginated_data_table.dart @@ -170,7 +170,7 @@ class PaginatedDataTable extends StatefulWidget { final DataTableSource source; @override - PaginatedDataTableState createState() => new PaginatedDataTableState(); + PaginatedDataTableState createState() => PaginatedDataTableState(); } /// Holds the state of a [PaginatedDataTable]. @@ -229,7 +229,7 @@ class PaginatedDataTableState extends State { } DataRow _getBlankRowFor(int index) { - return new DataRow.byIndex( + return DataRow.byIndex( index: index, cells: widget.columns.map((DataColumn column) => DataCell.empty).toList() ); @@ -248,7 +248,7 @@ class PaginatedDataTableState extends State { haveProgressIndicator = true; cells[0] = const DataCell(CircularProgressIndicator()); } - return new DataRow.byIndex( + return DataRow.byIndex( index: index, cells: cells ); @@ -281,7 +281,7 @@ class PaginatedDataTableState extends State { pageTo(_firstRowIndex + widget.rowsPerPage); } - final GlobalKey _tableKey = new GlobalKey(); + final GlobalKey _tableKey = GlobalKey(); @override Widget build(BuildContext context) { @@ -292,7 +292,7 @@ class PaginatedDataTableState extends State { final List headerWidgets = []; double startPadding = 24.0; if (_selectedRowCount == 0) { - headerWidgets.add(new Expanded(child: widget.header)); + headerWidgets.add(Expanded(child: widget.header)); if (widget.header is ButtonBar) { // We adjust the padding when a button bar is present, because the // ButtonBar introduces 2 pixels of outside padding, plus 2 pixels @@ -303,14 +303,14 @@ class PaginatedDataTableState extends State { startPadding = 12.0; } } else { - headerWidgets.add(new Expanded( - child: new Text(localizations.selectedRowCountTitle(_selectedRowCount)), + headerWidgets.add(Expanded( + child: Text(localizations.selectedRowCountTitle(_selectedRowCount)), )); } if (widget.actions != null) { headerWidgets.addAll( widget.actions.map((Widget action) { - return new Padding( + return Padding( // 8.0 is the default padding of an icon button padding: const EdgeInsetsDirectional.only(start: 24.0 - 8.0 * 2.0), child: action, @@ -326,21 +326,21 @@ class PaginatedDataTableState extends State { final List availableRowsPerPage = widget.availableRowsPerPage .where((int value) => value <= _rowCount || value == widget.rowsPerPage) .map>((int value) { - return new DropdownMenuItem( + return DropdownMenuItem( value: value, - child: new Text('$value') + child: Text('$value') ); }) .toList(); footerWidgets.addAll([ - new Container(width: 14.0), // to match trailing padding in case we overflow and end up scrolling - new Text(localizations.rowsPerPageTitle), - new ConstrainedBox( + Container(width: 14.0), // to match trailing padding in case we overflow and end up scrolling + Text(localizations.rowsPerPageTitle), + ConstrainedBox( constraints: const BoxConstraints(minWidth: 64.0), // 40.0 for the text, 24.0 for the icon - child: new Align( + child: Align( alignment: AlignmentDirectional.centerEnd, - child: new DropdownButtonHideUnderline( - child: new DropdownButton( + child: DropdownButtonHideUnderline( + child: DropdownButton( items: availableRowsPerPage, value: widget.rowsPerPage, onChanged: widget.onRowsPerPageChanged, @@ -353,8 +353,8 @@ class PaginatedDataTableState extends State { ]); } footerWidgets.addAll([ - new Container(width: 32.0), - new Text( + Container(width: 32.0), + Text( localizations.pageRowsInfoTitle( _firstRowIndex + 1, _firstRowIndex + widget.rowsPerPage, @@ -362,32 +362,32 @@ class PaginatedDataTableState extends State { _rowCountApproximate ) ), - new Container(width: 32.0), - new IconButton( + Container(width: 32.0), + IconButton( icon: const Icon(Icons.chevron_left), padding: EdgeInsets.zero, tooltip: localizations.previousPageTooltip, onPressed: _firstRowIndex <= 0 ? null : _handlePrevious ), - new Container(width: 24.0), - new IconButton( + Container(width: 24.0), + IconButton( icon: const Icon(Icons.chevron_right), padding: EdgeInsets.zero, tooltip: localizations.nextPageTooltip, onPressed: (!_rowCountApproximate && (_firstRowIndex + widget.rowsPerPage >= _rowCount)) ? null : _handleNext ), - new Container(width: 14.0), + Container(width: 14.0), ]); // CARD - return new Card( + return Card( semanticContainer: false, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Semantics( + Semantics( container: true, - child: new DefaultTextStyle( + child: DefaultTextStyle( // These typographic styles aren't quite the regular ones. We pick the closest ones from the regular // list and then tweak them appropriately. // See https://material.google.com/components/data-tables.html#data-tables-tables-within-cards @@ -397,13 +397,13 @@ class PaginatedDataTableState extends State { data: const IconThemeData( opacity: 0.54 ), - child: new ButtonTheme.bar( - child: new Ink( + child: ButtonTheme.bar( + child: Ink( height: 64.0, color: _selectedRowCount > 0 ? themeData.secondaryHeaderColor : null, - child: new Padding( - padding: new EdgeInsetsDirectional.only(start: startPadding, end: 14.0), - child: new Row( + child: Padding( + padding: EdgeInsetsDirectional.only(start: startPadding, end: 14.0), + child: Row( mainAxisAlignment: MainAxisAlignment.end, children: headerWidgets ), @@ -413,9 +413,9 @@ class PaginatedDataTableState extends State { ), ), ), - new SingleChildScrollView( + SingleChildScrollView( scrollDirection: Axis.horizontal, - child: new DataTable( + child: DataTable( key: _tableKey, columns: widget.columns, sortColumnIndex: widget.sortColumnIndex, @@ -424,18 +424,18 @@ class PaginatedDataTableState extends State { rows: _getRows(_firstRowIndex, widget.rowsPerPage) ) ), - new DefaultTextStyle( + DefaultTextStyle( style: footerTextStyle, child: IconTheme.merge( data: const IconThemeData( opacity: 0.54 ), - child: new Container( + child: Container( height: 56.0, - child: new SingleChildScrollView( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, reverse: true, - child: new Row( + child: Row( children: footerWidgets, ), ), diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index e58dbe5d71..0e2e355cb9 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -108,12 +108,12 @@ class PopupMenuDivider extends PopupMenuEntry { bool represents(dynamic value) => false; @override - _PopupMenuDividerState createState() => new _PopupMenuDividerState(); + _PopupMenuDividerState createState() => _PopupMenuDividerState(); } class _PopupMenuDividerState extends State { @override - Widget build(BuildContext context) => new Divider(height: widget.height); + Widget build(BuildContext context) => Divider(height: widget.height); } /// An item in a material design popup menu. @@ -196,7 +196,7 @@ class PopupMenuItem extends PopupMenuEntry { bool represents(T value) => value == this.value; @override - PopupMenuItemState> createState() => new PopupMenuItemState>(); + PopupMenuItemState> createState() => PopupMenuItemState>(); } /// The [State] for [PopupMenuItem] subclasses. @@ -243,10 +243,10 @@ class PopupMenuItemState> extends State { if (!widget.enabled) style = style.copyWith(color: theme.disabledColor); - Widget item = new AnimatedDefaultTextStyle( + Widget item = AnimatedDefaultTextStyle( style: style, duration: kThemeChangeDuration, - child: new Baseline( + child: Baseline( baseline: widget.height - _kBaselineOffsetFromBottom, baselineType: style.textBaseline, child: buildChild(), @@ -255,14 +255,14 @@ class PopupMenuItemState> extends State { if (!widget.enabled) { final bool isDark = theme.brightness == Brightness.dark; item = IconTheme.merge( - data: new IconThemeData(opacity: isDark ? 0.5 : 0.38), + data: IconThemeData(opacity: isDark ? 0.5 : 0.38), child: item, ); } - return new InkWell( + return InkWell( onTap: widget.enabled ? handleTap : null, - child: new Container( + child: Container( height: widget.height, padding: const EdgeInsets.symmetric(horizontal: _kMenuHorizontalPadding), child: item, @@ -373,7 +373,7 @@ class CheckedPopupMenuItem extends PopupMenuItem { Widget get child => super.child; @override - _CheckedPopupMenuItemState createState() => new _CheckedPopupMenuItemState(); + _CheckedPopupMenuItemState createState() => _CheckedPopupMenuItemState(); } class _CheckedPopupMenuItemState extends PopupMenuItemState> with SingleTickerProviderStateMixin { @@ -384,7 +384,7 @@ class _CheckedPopupMenuItemState extends PopupMenuItemState setState(() { /* animation changed */ })); } @@ -401,11 +401,11 @@ class _CheckedPopupMenuItemState extends PopupMenuItemState extends StatelessWidget { for (int i = 0; i < route.items.length; i += 1) { final double start = (i + 1) * unit; final double end = (start + 1.5 * unit).clamp(0.0, 1.0); - final CurvedAnimation opacity = new CurvedAnimation( + final CurvedAnimation opacity = CurvedAnimation( parent: route.animation, - curve: new Interval(start, end) + curve: Interval(start, end) ); Widget item = route.items[i]; if (route.initialValue != null && route.items[i].represents(route.initialValue)) { - item = new Container( + item = Container( color: Theme.of(context).highlightColor, child: item, ); } - children.add(new FadeTransition( + children.add(FadeTransition( opacity: opacity, child: item, )); } - final CurveTween opacity = new CurveTween(curve: const Interval(0.0, 1.0 / 3.0)); - final CurveTween width = new CurveTween(curve: new Interval(0.0, unit)); - final CurveTween height = new CurveTween(curve: new Interval(0.0, unit * route.items.length)); + final CurveTween opacity = CurveTween(curve: const Interval(0.0, 1.0 / 3.0)); + final CurveTween width = CurveTween(curve: Interval(0.0, unit)); + final CurveTween height = CurveTween(curve: Interval(0.0, unit * route.items.length)); - final Widget child = new ConstrainedBox( + final Widget child = ConstrainedBox( constraints: const BoxConstraints( minWidth: _kMenuMinWidth, maxWidth: _kMenuMaxWidth, ), - child: new IntrinsicWidth( + child: IntrinsicWidth( stepWidth: _kMenuWidthStep, - child: new Semantics( + child: Semantics( scopesRoute: true, namesRoute: true, explicitChildNodes: true, label: semanticLabel, - child: new SingleChildScrollView( + child: SingleChildScrollView( padding: const EdgeInsets.symmetric( vertical: _kMenuVerticalPadding ), - child: new ListBody(children: children), + child: ListBody(children: children), ), ), ), ); - return new AnimatedBuilder( + return AnimatedBuilder( animation: route.animation, builder: (BuildContext context, Widget child) { - return new Opacity( + return Opacity( opacity: opacity.evaluate(route.animation), - child: new Material( + child: Material( type: MaterialType.card, elevation: route.elevation, - child: new Align( + child: Align( alignment: AlignmentDirectional.topEnd, widthFactor: width.evaluate(route.animation), heightFactor: height.evaluate(route.animation), @@ -518,7 +518,7 @@ class _PopupMenuRouteLayout extends SingleChildLayoutDelegate { BoxConstraints getConstraintsForChild(BoxConstraints constraints) { // The menu can be at most the size of the overlay minus 8.0 pixels in each // direction. - return new BoxConstraints.loose(constraints.biggest - const Offset(_kMenuScreenPadding * 2.0, _kMenuScreenPadding * 2.0)); + return BoxConstraints.loose(constraints.biggest - const Offset(_kMenuScreenPadding * 2.0, _kMenuScreenPadding * 2.0)); } @override @@ -566,7 +566,7 @@ class _PopupMenuRouteLayout extends SingleChildLayoutDelegate { y = _kMenuScreenPadding; else if (y + childSize.height > size.height - _kMenuScreenPadding) y = size.height - childSize.height - _kMenuScreenPadding; - return new Offset(x, y); + return Offset(x, y); } @override @@ -595,7 +595,7 @@ class _PopupMenuRoute extends PopupRoute { @override Animation createAnimation() { - return new CurvedAnimation( + return CurvedAnimation( parent: super.createAnimation(), curve: Curves.linear, reverseCurve: const Interval(0.0, _kMenuCloseIntervalEnd) @@ -628,20 +628,20 @@ class _PopupMenuRoute extends PopupRoute { } } - Widget menu = new _PopupMenu(route: this, semanticLabel: semanticLabel); + Widget menu = _PopupMenu(route: this, semanticLabel: semanticLabel); if (theme != null) - menu = new Theme(data: theme, child: menu); + menu = Theme(data: theme, child: menu); - return new MediaQuery.removePadding( + return MediaQuery.removePadding( context: context, removeTop: true, removeBottom: true, removeLeft: true, removeRight: true, - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new CustomSingleChildLayout( - delegate: new _PopupMenuRouteLayout( + return CustomSingleChildLayout( + delegate: _PopupMenuRouteLayout( position, selectedItemOffset, Directionality.of(context), @@ -723,7 +723,7 @@ Future showMenu({ label = semanticLabel ?? MaterialLocalizations.of(context)?.popupMenuLabel; } - return Navigator.push(context, new _PopupMenuRoute( + return Navigator.push(context, _PopupMenuRoute( position: position, items: items, initialValue: initialValue, @@ -863,15 +863,15 @@ class PopupMenuButton extends StatefulWidget { final Icon icon; @override - _PopupMenuButtonState createState() => new _PopupMenuButtonState(); + _PopupMenuButtonState createState() => _PopupMenuButtonState(); } class _PopupMenuButtonState extends State> { void showButtonMenu() { final RenderBox button = context.findRenderObject(); final RenderBox overlay = Overlay.of(context).context.findRenderObject(); - final RelativeRect position = new RelativeRect.fromRect( - new Rect.fromPoints( + final RelativeRect position = RelativeRect.fromRect( + Rect.fromPoints( button.localToGlobal(Offset.zero, ancestor: overlay), button.localToGlobal(button.size.bottomRight(Offset.zero), ancestor: overlay), ), @@ -912,11 +912,11 @@ class _PopupMenuButtonState extends State> { @override Widget build(BuildContext context) { return widget.child != null - ? new InkWell( + ? InkWell( onTap: showButtonMenu, child: widget.child, ) - : new IconButton( + : IconButton( icon: widget.icon ?? _getIcon(Theme.of(context).platform), padding: widget.padding, tooltip: widget.tooltip ?? MaterialLocalizations.of(context).showMenuTooltip, diff --git a/packages/flutter/lib/src/material/progress_indicator.dart b/packages/flutter/lib/src/material/progress_indicator.dart index ca266e627b..6a3cd57a20 100644 --- a/packages/flutter/lib/src/material/progress_indicator.dart +++ b/packages/flutter/lib/src/material/progress_indicator.dart @@ -64,7 +64,7 @@ abstract class ProgressIndicator extends StatefulWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new PercentProperty('value', value, showName: false, ifNull: '')); + properties.add(PercentProperty('value', value, showName: false, ifNull: '')); } } @@ -108,7 +108,7 @@ class _LinearProgressIndicatorPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = backgroundColor ..style = PaintingStyle.fill; canvas.drawRect(Offset.zero & size, paint); @@ -128,7 +128,7 @@ class _LinearProgressIndicatorPainter extends CustomPainter { left = x; break; } - canvas.drawRect(new Offset(left, 0.0) & new Size(width, size.height), paint); + canvas.drawRect(Offset(left, 0.0) & Size(width, size.height), paint); } if (value != null) { @@ -187,7 +187,7 @@ class LinearProgressIndicator extends ProgressIndicator { }) : super(key: key, value: value, backgroundColor: backgroundColor, valueColor: valueColor); @override - _LinearProgressIndicatorState createState() => new _LinearProgressIndicatorState(); + _LinearProgressIndicatorState createState() => _LinearProgressIndicatorState(); } class _LinearProgressIndicatorState extends State with SingleTickerProviderStateMixin { @@ -196,7 +196,7 @@ class _LinearProgressIndicatorState extends State with @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(milliseconds: _kIndeterminateLinearDuration), vsync: this, ); @@ -220,13 +220,13 @@ class _LinearProgressIndicatorState extends State with } Widget _buildIndicator(BuildContext context, double animationValue, TextDirection textDirection) { - return new Container( + return Container( constraints: const BoxConstraints.tightFor( width: double.infinity, height: _kLinearProgressIndicatorHeight, ), - child: new CustomPaint( - painter: new _LinearProgressIndicatorPainter( + child: CustomPaint( + painter: _LinearProgressIndicatorPainter( backgroundColor: widget._getBackgroundColor(context), valueColor: widget._getValueColor(context), value: widget.value, // may be null @@ -244,7 +244,7 @@ class _LinearProgressIndicatorState extends State with if (widget.value != null) return _buildIndicator(context, _controller.value, textDirection); - return new AnimatedBuilder( + return AnimatedBuilder( animation: _controller.view, builder: (BuildContext context, Widget child) { return _buildIndicator(context, _controller.value, textDirection); @@ -287,7 +287,7 @@ class _CircularProgressIndicatorPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = valueColor ..strokeWidth = strokeWidth ..style = PaintingStyle.stroke; @@ -347,25 +347,25 @@ class CircularProgressIndicator extends ProgressIndicator { final double strokeWidth; @override - _CircularProgressIndicatorState createState() => new _CircularProgressIndicatorState(); + _CircularProgressIndicatorState createState() => _CircularProgressIndicatorState(); } // Tweens used by circular progress indicator -final Animatable _kStrokeHeadTween = new CurveTween( +final Animatable _kStrokeHeadTween = CurveTween( curve: const Interval(0.0, 0.5, curve: Curves.fastOutSlowIn), -).chain(new CurveTween( +).chain(CurveTween( curve: const SawTooth(5), )); -final Animatable _kStrokeTailTween = new CurveTween( +final Animatable _kStrokeTailTween = CurveTween( curve: const Interval(0.5, 1.0, curve: Curves.fastOutSlowIn), -).chain(new CurveTween( +).chain(CurveTween( curve: const SawTooth(5), )); -final Animatable _kStepTween = new StepTween(begin: 0, end: 5); +final Animatable _kStepTween = StepTween(begin: 0, end: 5); -final Animatable _kRotationTween = new CurveTween(curve: const SawTooth(5)); +final Animatable _kRotationTween = CurveTween(curve: const SawTooth(5)); class _CircularProgressIndicatorState extends State with SingleTickerProviderStateMixin { AnimationController _controller; @@ -373,7 +373,7 @@ class _CircularProgressIndicatorState extends State w @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: const Duration(milliseconds: 6666), vsync: this, )..repeat(); @@ -386,13 +386,13 @@ class _CircularProgressIndicatorState extends State w } Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) { - return new Container( + return Container( constraints: const BoxConstraints( minWidth: _kMinCircularProgressIndicatorSize, minHeight: _kMinCircularProgressIndicatorSize, ), - child: new CustomPaint( - painter: new _CircularProgressIndicatorPainter( + child: CustomPaint( + painter: _CircularProgressIndicatorPainter( valueColor: widget._getValueColor(context), value: widget.value, // may be null headValue: headValue, // remaining arguments are ignored if widget.value is not null @@ -406,7 +406,7 @@ class _CircularProgressIndicatorState extends State w } Widget _buildAnimation() { - return new AnimatedBuilder( + return AnimatedBuilder( animation: _controller, builder: (BuildContext context, Widget child) { return _buildIndicator( @@ -465,12 +465,12 @@ class _RefreshProgressIndicatorPainter extends _CircularProgressIndicatorPainter final double innerRadius = radius - arrowheadRadius; final double outerRadius = radius + arrowheadRadius; - final Path path = new Path() + final Path path = Path() ..moveTo(radius + ux * innerRadius, radius + uy * innerRadius) ..lineTo(radius + ux * outerRadius, radius + uy * outerRadius) ..lineTo(arrowheadPointX, arrowheadPointY) ..close(); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = valueColor ..strokeWidth = strokeWidth ..style = PaintingStyle.fill; @@ -514,7 +514,7 @@ class RefreshProgressIndicator extends CircularProgressIndicator { ); @override - _RefreshProgressIndicatorState createState() => new _RefreshProgressIndicatorState(); + _RefreshProgressIndicatorState createState() => _RefreshProgressIndicatorState(); } class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { @@ -536,18 +536,18 @@ class _RefreshProgressIndicatorState extends _CircularProgressIndicatorState { @override Widget _buildIndicator(BuildContext context, double headValue, double tailValue, int stepValue, double rotationValue) { final double arrowheadScale = widget.value == null ? 0.0 : (widget.value * 2.0).clamp(0.0, 1.0); - return new Container( + return Container( width: _indicatorSize, height: _indicatorSize, margin: const EdgeInsets.all(4.0), // accommodate the shadow - child: new Material( + child: Material( type: MaterialType.circle, color: widget.backgroundColor ?? Theme.of(context).canvasColor, elevation: 2.0, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(12.0), - child: new CustomPaint( - painter: new _RefreshProgressIndicatorPainter( + child: CustomPaint( + painter: _RefreshProgressIndicatorPainter( valueColor: widget._getValueColor(context), value: null, // Draw the indeterminate progress indicator. headValue: headValue, diff --git a/packages/flutter/lib/src/material/radio.dart b/packages/flutter/lib/src/material/radio.dart index a492f8220d..50e5d5bbcf 100644 --- a/packages/flutter/lib/src/material/radio.dart +++ b/packages/flutter/lib/src/material/radio.dart @@ -108,7 +108,7 @@ class Radio extends StatefulWidget { final MaterialTapTargetSize materialTapTargetSize; @override - _RadioState createState() => new _RadioState(); + _RadioState createState() => _RadioState(); } class _RadioState extends State> with TickerProviderStateMixin { @@ -136,8 +136,8 @@ class _RadioState extends State> with TickerProviderStateMixin { size = const Size(2 * kRadialReactionRadius, 2 * kRadialReactionRadius); break; } - final BoxConstraints additionalConstraints = new BoxConstraints.tight(size); - return new _RadioRenderObjectWidget( + final BoxConstraints additionalConstraints = BoxConstraints.tight(size); + return _RadioRenderObjectWidget( selected: widget.value == widget.groupValue, activeColor: widget.activeColor ?? themeData.toggleableActiveColor, inactiveColor: _getInactiveColor(themeData), @@ -171,7 +171,7 @@ class _RadioRenderObjectWidget extends LeafRenderObjectWidget { final BoxConstraints additionalConstraints; @override - _RenderRadio createRenderObject(BuildContext context) => new _RenderRadio( + _RenderRadio createRenderObject(BuildContext context) => _RenderRadio( value: selected, activeColor: activeColor, inactiveColor: inactiveColor, @@ -220,7 +220,7 @@ class _RenderRadio extends RenderToggleable { final Color radioColor = onChanged != null ? activeColor : inactiveColor; // Outer circle - final Paint paint = new Paint() + final Paint paint = Paint() ..color = Color.lerp(inactiveColor, radioColor, position.value) ..style = PaintingStyle.stroke ..strokeWidth = 2.0; diff --git a/packages/flutter/lib/src/material/radio_list_tile.dart b/packages/flutter/lib/src/material/radio_list_tile.dart index 2fee40c68b..a0cfe73d34 100644 --- a/packages/flutter/lib/src/material/radio_list_tile.dart +++ b/packages/flutter/lib/src/material/radio_list_tile.dart @@ -194,7 +194,7 @@ class RadioListTile extends StatelessWidget { @override Widget build(BuildContext context) { - final Widget control = new Radio( + final Widget control = Radio( value: value, groupValue: groupValue, onChanged: onChanged, @@ -213,10 +213,10 @@ class RadioListTile extends StatelessWidget { trailing = control; break; } - return new MergeSemantics( + return MergeSemantics( child: ListTileTheme.merge( selectedColor: activeColor ?? Theme.of(context).accentColor, - child: new ListTile( + child: ListTile( leading: leading, title: title, subtitle: subtitle, diff --git a/packages/flutter/lib/src/material/raised_button.dart b/packages/flutter/lib/src/material/raised_button.dart index 553dcf8feb..c67e6034d2 100644 --- a/packages/flutter/lib/src/material/raised_button.dart +++ b/packages/flutter/lib/src/material/raised_button.dart @@ -111,7 +111,7 @@ class RaisedButton extends StatelessWidget { assert(animationDuration != null), assert(clipBehavior != null), padding = const EdgeInsetsDirectional.only(start: 12.0, end: 16.0), - child = new Row( + child = Row( mainAxisSize: MainAxisSize.min, children: [ icon, @@ -384,7 +384,7 @@ class RaisedButton extends StatelessWidget { final Color fillColor = _getFillColor(theme, buttonTheme); final Color textColor = _getTextColor(theme, buttonTheme, fillColor); - return new RawMaterialButton( + return RawMaterialButton( onPressed: onPressed, onHighlightChanged: onHighlightChanged, fillColor: fillColor, @@ -407,18 +407,18 @@ class RaisedButton extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); - properties.add(new DiagnosticsProperty('textColor', textColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledTextColor', disabledTextColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledColor', disabledColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('highlightColor', highlightColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('splashColor', splashColor, defaultValue: null)); - properties.add(new DiagnosticsProperty('colorBrightness', colorBrightness, defaultValue: null)); - properties.add(new DiagnosticsProperty('elevation', elevation, defaultValue: null)); - properties.add(new DiagnosticsProperty('highlightElevation', highlightElevation, defaultValue: null)); - properties.add(new DiagnosticsProperty('disabledElevation', disabledElevation, defaultValue: null)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); - properties.add(new DiagnosticsProperty('shape', shape, defaultValue: null)); + properties.add(ObjectFlagProperty('onPressed', onPressed, ifNull: 'disabled')); + properties.add(DiagnosticsProperty('textColor', textColor, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledTextColor', disabledTextColor, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledColor', disabledColor, defaultValue: null)); + properties.add(DiagnosticsProperty('highlightColor', highlightColor, defaultValue: null)); + properties.add(DiagnosticsProperty('splashColor', splashColor, defaultValue: null)); + properties.add(DiagnosticsProperty('colorBrightness', colorBrightness, defaultValue: null)); + properties.add(DiagnosticsProperty('elevation', elevation, defaultValue: null)); + properties.add(DiagnosticsProperty('highlightElevation', highlightElevation, defaultValue: null)); + properties.add(DiagnosticsProperty('disabledElevation', disabledElevation, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('shape', shape, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/material/refresh_indicator.dart b/packages/flutter/lib/src/material/refresh_indicator.dart index 2a9608ef8b..1481c6b866 100644 --- a/packages/flutter/lib/src/material/refresh_indicator.dart +++ b/packages/flutter/lib/src/material/refresh_indicator.dart @@ -132,7 +132,7 @@ class RefreshIndicator extends StatefulWidget { final ScrollNotificationPredicate notificationPredicate; @override - RefreshIndicatorState createState() => new RefreshIndicatorState(); + RefreshIndicatorState createState() => RefreshIndicatorState(); } /// Contains the state for a [RefreshIndicator]. This class can be used to @@ -153,18 +153,18 @@ class RefreshIndicatorState extends State with TickerProviderS @override void initState() { super.initState(); - _positionController = new AnimationController(vsync: this); - _positionFactor = new Tween( + _positionController = AnimationController(vsync: this); + _positionFactor = Tween( begin: 0.0, end: _kDragSizeFactorLimit, ).animate(_positionController); - _value = new Tween( // The "value" of the circular progress indicator during a drag. + _value = Tween( // The "value" of the circular progress indicator during a drag. begin: 0.0, end: 0.75, ).animate(_positionController); - _scaleController = new AnimationController(vsync: this); - _scaleFactor = new Tween( + _scaleController = AnimationController(vsync: this); + _scaleFactor = Tween( begin: 1.0, end: 0.0, ).animate(_scaleController); @@ -173,10 +173,10 @@ class RefreshIndicatorState extends State with TickerProviderS @override void didChangeDependencies() { final ThemeData theme = Theme.of(context); - _valueColor = new ColorTween( + _valueColor = ColorTween( begin: (widget.color ?? theme.accentColor).withOpacity(0.0), end: (widget.color ?? theme.accentColor).withOpacity(1.0) - ).animate(new CurvedAnimation( + ).animate(CurvedAnimation( parent: _positionController, curve: const Interval(0.0, 1.0 / _kDragSizeFactorLimit) )); @@ -297,7 +297,7 @@ class RefreshIndicatorState extends State with TickerProviderS // Stop showing the refresh indicator. Future _dismiss(_RefreshIndicatorMode newMode) async { - await new Future.value(); + await Future.value(); // This can only be called from _show() when refreshing and // _handleScrollNotification in response to a ScrollEndNotification or // direction change. @@ -327,7 +327,7 @@ class RefreshIndicatorState extends State with TickerProviderS void _show() { assert(_mode != _RefreshIndicatorMode.refresh); assert(_mode != _RefreshIndicatorMode.snap); - final Completer completer = new Completer(); + final Completer completer = Completer(); _pendingRefreshFuture = completer.future; _mode = _RefreshIndicatorMode.snap; _positionController @@ -343,8 +343,8 @@ class RefreshIndicatorState extends State with TickerProviderS final Future refreshResult = widget.onRefresh(); assert(() { if (refreshResult == null) - FlutterError.reportError(new FlutterErrorDetails( - exception: new FlutterError( + FlutterError.reportError(FlutterErrorDetails( + exception: FlutterError( 'The onRefresh callback returned null.\n' 'The RefreshIndicator onRefresh callback must return a Future.' ), @@ -391,14 +391,14 @@ class RefreshIndicatorState extends State with TickerProviderS return _pendingRefreshFuture; } - final GlobalKey _key = new GlobalKey(); + final GlobalKey _key = GlobalKey(); @override Widget build(BuildContext context) { - final Widget child = new NotificationListener( + final Widget child = NotificationListener( key: _key, onNotification: _handleScrollNotification, - child: new NotificationListener( + child: NotificationListener( onNotification: _handleGlowNotification, child: widget.child, ), @@ -414,30 +414,30 @@ class RefreshIndicatorState extends State with TickerProviderS final bool showIndeterminateIndicator = _mode == _RefreshIndicatorMode.refresh || _mode == _RefreshIndicatorMode.done; - return new Stack( + return Stack( children: [ child, - new Positioned( + Positioned( top: _isIndicatorAtTop ? 0.0 : null, bottom: !_isIndicatorAtTop ? 0.0 : null, left: 0.0, right: 0.0, - child: new SizeTransition( + child: SizeTransition( axisAlignment: _isIndicatorAtTop ? 1.0 : -1.0, sizeFactor: _positionFactor, // this is what brings it down - child: new Container( + child: Container( padding: _isIndicatorAtTop - ? new EdgeInsets.only(top: widget.displacement) - : new EdgeInsets.only(bottom: widget.displacement), + ? EdgeInsets.only(top: widget.displacement) + : EdgeInsets.only(bottom: widget.displacement), alignment: _isIndicatorAtTop ? Alignment.topCenter : Alignment.bottomCenter, - child: new ScaleTransition( + child: ScaleTransition( scale: _scaleFactor, - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: _positionController, builder: (BuildContext context, Widget child) { - return new RefreshProgressIndicator( + return RefreshProgressIndicator( value: showIndeterminateIndicator ? null : _value.value, valueColor: _valueColor, backgroundColor: widget.backgroundColor, diff --git a/packages/flutter/lib/src/material/reorderable_list.dart b/packages/flutter/lib/src/material/reorderable_list.dart index 06517e4ce5..f91aaa535f 100644 --- a/packages/flutter/lib/src/material/reorderable_list.dart +++ b/packages/flutter/lib/src/material/reorderable_list.dart @@ -86,7 +86,7 @@ class ReorderableListView extends StatefulWidget { final OnReorderCallback onReorder; @override - _ReorderableListViewState createState() => new _ReorderableListViewState(); + _ReorderableListViewState createState() => _ReorderableListViewState(); } // This top-level state manages an Overlay that contains the list and @@ -100,7 +100,7 @@ class ReorderableListView extends StatefulWidget { // insert Draggables into the Overlay above itself. class _ReorderableListViewState extends State { // We use an inner overlay so that the dragging list item doesn't draw outside of the list itself. - final GlobalKey _overlayKey = new GlobalKey(debugLabel: '$ReorderableListView overlay key'); + final GlobalKey _overlayKey = GlobalKey(debugLabel: '$ReorderableListView overlay key'); // This entry contains the scrolling list itself. OverlayEntry _listOverlayEntry; @@ -108,10 +108,10 @@ class _ReorderableListViewState extends State { @override void initState() { super.initState(); - _listOverlayEntry = new OverlayEntry( + _listOverlayEntry = OverlayEntry( opaque: true, builder: (BuildContext context) { - return new _ReorderableListContent( + return _ReorderableListContent( header: widget.header, children: widget.children, scrollDirection: widget.scrollDirection, @@ -124,7 +124,7 @@ class _ReorderableListViewState extends State { @override Widget build(BuildContext context) { - return new Overlay( + return Overlay( key: _overlayKey, initialEntries: [ _listOverlayEntry, @@ -150,7 +150,7 @@ class _ReorderableListContent extends StatefulWidget { final OnReorderCallback onReorder; @override - _ReorderableListContentState createState() => new _ReorderableListContentState(); + _ReorderableListContentState createState() => _ReorderableListContentState(); } class _ReorderableListContentState extends State<_ReorderableListContent> with TickerProviderStateMixin { @@ -226,14 +226,14 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T @override void initState() { super.initState(); - _entranceController = new AnimationController(vsync: this, duration: _reorderAnimationDuration); - _ghostController = new AnimationController(vsync: this, duration: _reorderAnimationDuration); + _entranceController = AnimationController(vsync: this, duration: _reorderAnimationDuration); + _ghostController = AnimationController(vsync: this, duration: _reorderAnimationDuration); _entranceController.addStatusListener(_onEntranceStatusChanged); } @override void didChangeDependencies() { - _scrollController = PrimaryScrollController.of(context) ?? new ScrollController(); + _scrollController = PrimaryScrollController.of(context) ?? ScrollController(); super.didChangeDependencies(); } @@ -308,10 +308,10 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T Widget _buildContainerForScrollDirection({List children}) { switch (widget.scrollDirection) { case Axis.horizontal: - return new Row(children: children); + return Row(children: children); case Axis.vertical: default: - return new Column(children: children); + return Column(children: children); } } @@ -319,7 +319,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // Handles up the logic for dragging and reordering items in the list. Widget _wrap(Widget toWrap, int index, BoxConstraints constraints) { assert(toWrap.key != null); - final GlobalObjectKey keyIndexGlobalKey = new GlobalObjectKey(toWrap.key); + final GlobalObjectKey keyIndexGlobalKey = GlobalObjectKey(toWrap.key); // We pass the toWrapWithGlobalKey into the Draggable so that when a list // item gets dragged, the accessibility framework can preserve the selected // state of the dragging item. @@ -371,14 +371,14 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // If the item can move to before its current position in the list. if (index > 0) { - semanticsActions[new CustomSemanticsAction(label: localizations.reorderItemToStart)] = moveToStart; + semanticsActions[CustomSemanticsAction(label: localizations.reorderItemToStart)] = moveToStart; String reorderItemBefore = localizations.reorderItemUp; if (widget.scrollDirection == Axis.horizontal) { reorderItemBefore = Directionality.of(context) == TextDirection.ltr ? localizations.reorderItemLeft : localizations.reorderItemRight; } - semanticsActions[new CustomSemanticsAction(label: reorderItemBefore)] = moveBefore; + semanticsActions[CustomSemanticsAction(label: reorderItemBefore)] = moveBefore; } // If the item can move to after its current position in the list. @@ -389,8 +389,8 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T ? localizations.reorderItemRight : localizations.reorderItemLeft; } - semanticsActions[new CustomSemanticsAction(label: reorderItemAfter)] = moveAfter; - semanticsActions[new CustomSemanticsAction(label: localizations.reorderItemToEnd)] = moveToEnd; + semanticsActions[CustomSemanticsAction(label: reorderItemAfter)] = moveAfter; + semanticsActions[CustomSemanticsAction(label: localizations.reorderItemToEnd)] = moveToEnd; } // We pass toWrap with a GlobalKey into the Draggable so that when a list @@ -399,10 +399,10 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // // We also apply the relevant custom accessibility actions for moving the item // up, down, to the start, and to the end of the list. - return new KeyedSubtree( + return KeyedSubtree( key: keyIndexGlobalKey, - child: new MergeSemantics( - child: new Semantics( + child: MergeSemantics( + child: Semantics( customSemanticsActions: semanticsActions, child: toWrap, ), @@ -415,16 +415,16 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // We build the draggable inside of a layout builder so that we can // constrain the size of the feedback dragging widget. - Widget child = new LongPressDraggable( + Widget child = LongPressDraggable( maxSimultaneousDrags: 1, axis: widget.scrollDirection, data: toWrap.key, ignoringFeedbackSemantics: false, - feedback: new Container( + feedback: Container( alignment: Alignment.topLeft, // These constraints will limit the cross axis of the drawn widget. constraints: constraints, - child: new Material( + child: Material( elevation: 6.0, child: toWrapWithSemantics, ), @@ -454,11 +454,11 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T Widget spacing; switch (widget.scrollDirection) { case Axis.horizontal: - spacing = new SizedBox(width: _dropAreaExtent); + spacing = SizedBox(width: _dropAreaExtent); break; case Axis.vertical: default: - spacing = new SizedBox(height: _dropAreaExtent); + spacing = SizedBox(height: _dropAreaExtent); break; } @@ -466,7 +466,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // show it can be dropped. if (_currentIndex == index) { return _buildContainerForScrollDirection(children: [ - new SizeTransition( + SizeTransition( sizeFactor: _entranceController, axis: widget.scrollDirection, child: spacing @@ -478,7 +478,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T // with the ghostController animation. if (_ghostIndex == index) { return _buildContainerForScrollDirection(children: [ - new SizeTransition( + SizeTransition( sizeFactor: _ghostController, axis: widget.scrollDirection, child: spacing, @@ -490,8 +490,8 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T } // We wrap the drag target in a Builder so that we can scroll to its specific context. - return new Builder(builder: (BuildContext context) { - return new DragTarget( + return Builder(builder: (BuildContext context) { + return DragTarget( builder: buildDragTarget, onWillAccept: (Key toAccept) { setState(() { @@ -511,7 +511,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T @override Widget build(BuildContext context) { // We use the layout builder to constrain the cross-axis size of dragging child widgets. - return new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { final List wrappedChildren = []; if (widget.header != null) { wrappedChildren.add(widget.header); @@ -523,7 +523,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T Widget finalDropArea; switch (widget.scrollDirection) { case Axis.horizontal: - finalDropArea = new SizedBox( + finalDropArea = SizedBox( key: endWidgetKey, width: _defaultDropAreaExtent, height: constraints.maxHeight, @@ -531,7 +531,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T break; case Axis.vertical: default: - finalDropArea = new SizedBox( + finalDropArea = SizedBox( key: endWidgetKey, height: _defaultDropAreaExtent, width: constraints.maxWidth, @@ -543,7 +543,7 @@ class _ReorderableListContentState extends State<_ReorderableListContent> with T widget.children.length, constraints), ); - return new SingleChildScrollView( + return SingleChildScrollView( scrollDirection: widget.scrollDirection, child: _buildContainerForScrollDirection(children: wrappedChildren), padding: widget.padding, diff --git a/packages/flutter/lib/src/material/scaffold.dart b/packages/flutter/lib/src/material/scaffold.dart index c3d16f82e6..70d5b6cca9 100644 --- a/packages/flutter/lib/src/material/scaffold.dart +++ b/packages/flutter/lib/src/material/scaffold.dart @@ -203,7 +203,7 @@ class ScaffoldGeometry { return this; if (scaleFactor == 0.0) { - return new ScaffoldGeometry( + return ScaffoldGeometry( bottomNavigationBarTop: bottomNavigationBarTop, ); } @@ -222,7 +222,7 @@ class ScaffoldGeometry { double bottomNavigationBarTop, Rect floatingActionButtonArea, }) { - return new ScaffoldGeometry( + return ScaffoldGeometry( bottomNavigationBarTop: bottomNavigationBarTop ?? this.bottomNavigationBarTop, floatingActionButtonArea: floatingActionButtonArea ?? this.floatingActionButtonArea, ); @@ -242,7 +242,7 @@ class _ScaffoldGeometryNotifier extends ChangeNotifier implements ValueListenabl assert(() { final RenderObject renderObject = context.findRenderObject(); if (renderObject == null || !renderObject.owner.debugDoingPaint) - throw new FlutterError( + throw FlutterError( 'Scaffold.geometryOf() must only be accessed during the paint phase.\n' 'The ScaffoldGeometry is only available during the paint phase, because\n' 'its value is computed during the animation and layout phases prior to painting.' @@ -290,7 +290,7 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { @override void performLayout(Size size) { - final BoxConstraints looseConstraints = new BoxConstraints.loose(size); + final BoxConstraints looseConstraints = BoxConstraints.loose(size); // This part of the layout has the same effect as putting the app bar and // body in a column and making the body flexible. What's different is that @@ -312,17 +312,17 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { final double bottomNavigationBarHeight = layoutChild(_ScaffoldSlot.bottomNavigationBar, fullWidthConstraints).height; bottomWidgetsHeight += bottomNavigationBarHeight; bottomNavigationBarTop = math.max(0.0, bottom - bottomWidgetsHeight); - positionChild(_ScaffoldSlot.bottomNavigationBar, new Offset(0.0, bottomNavigationBarTop)); + positionChild(_ScaffoldSlot.bottomNavigationBar, Offset(0.0, bottomNavigationBarTop)); } if (hasChild(_ScaffoldSlot.persistentFooter)) { - final BoxConstraints footerConstraints = new BoxConstraints( + final BoxConstraints footerConstraints = BoxConstraints( maxWidth: fullWidthConstraints.maxWidth, maxHeight: math.max(0.0, bottom - bottomWidgetsHeight - contentTop), ); final double persistentFooterHeight = layoutChild(_ScaffoldSlot.persistentFooter, footerConstraints).height; bottomWidgetsHeight += persistentFooterHeight; - positionChild(_ScaffoldSlot.persistentFooter, new Offset(0.0, math.max(0.0, bottom - bottomWidgetsHeight))); + positionChild(_ScaffoldSlot.persistentFooter, Offset(0.0, math.max(0.0, bottom - bottomWidgetsHeight))); } // Set the content bottom to account for the greater of the height of any @@ -331,12 +331,12 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { final double contentBottom = math.max(0.0, bottom - math.max(minInsets.bottom, bottomWidgetsHeight)); if (hasChild(_ScaffoldSlot.body)) { - final BoxConstraints bodyConstraints = new BoxConstraints( + final BoxConstraints bodyConstraints = BoxConstraints( maxWidth: fullWidthConstraints.maxWidth, maxHeight: math.max(0.0, contentBottom - contentTop), ); layoutChild(_ScaffoldSlot.body, bodyConstraints); - positionChild(_ScaffoldSlot.body, new Offset(0.0, contentTop)); + positionChild(_ScaffoldSlot.body, Offset(0.0, contentTop)); } // The BottomSheet and the SnackBar are anchored to the bottom of the parent, @@ -355,17 +355,17 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { Size snackBarSize = Size.zero; if (hasChild(_ScaffoldSlot.bottomSheet)) { - final BoxConstraints bottomSheetConstraints = new BoxConstraints( + final BoxConstraints bottomSheetConstraints = BoxConstraints( maxWidth: fullWidthConstraints.maxWidth, maxHeight: math.max(0.0, contentBottom - contentTop), ); bottomSheetSize = layoutChild(_ScaffoldSlot.bottomSheet, bottomSheetConstraints); - positionChild(_ScaffoldSlot.bottomSheet, new Offset((size.width - bottomSheetSize.width) / 2.0, contentBottom - bottomSheetSize.height)); + positionChild(_ScaffoldSlot.bottomSheet, Offset((size.width - bottomSheetSize.width) / 2.0, contentBottom - bottomSheetSize.height)); } if (hasChild(_ScaffoldSlot.snackBar)) { snackBarSize = layoutChild(_ScaffoldSlot.snackBar, fullWidthConstraints); - positionChild(_ScaffoldSlot.snackBar, new Offset(0.0, contentBottom - snackBarSize.height)); + positionChild(_ScaffoldSlot.snackBar, Offset(0.0, contentBottom - snackBarSize.height)); } Rect floatingActionButtonRect; @@ -374,7 +374,7 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { // To account for the FAB position being changed, we'll animate between // the old and new positions. - final ScaffoldPrelayoutGeometry currentGeometry = new ScaffoldPrelayoutGeometry( + final ScaffoldPrelayoutGeometry currentGeometry = ScaffoldPrelayoutGeometry( bottomSheetSize: bottomSheetSize, contentBottom: contentBottom, contentTop: contentTop, @@ -401,12 +401,12 @@ class _ScaffoldLayout extends MultiChildLayoutDelegate { } if (hasChild(_ScaffoldSlot.drawer)) { - layoutChild(_ScaffoldSlot.drawer, new BoxConstraints.tight(size)); + layoutChild(_ScaffoldSlot.drawer, BoxConstraints.tight(size)); positionChild(_ScaffoldSlot.drawer, Offset.zero); } if (hasChild(_ScaffoldSlot.endDrawer)) { - layoutChild(_ScaffoldSlot.endDrawer, new BoxConstraints.tight(size)); + layoutChild(_ScaffoldSlot.endDrawer, BoxConstraints.tight(size)); positionChild(_ScaffoldSlot.endDrawer, Offset.zero); } @@ -451,7 +451,7 @@ class _FloatingActionButtonTransition extends StatefulWidget { final _ScaffoldGeometryNotifier geometryNotifier; @override - _FloatingActionButtonTransitionState createState() => new _FloatingActionButtonTransitionState(); + _FloatingActionButtonTransitionState createState() => _FloatingActionButtonTransitionState(); } class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTransition> with TickerProviderStateMixin { @@ -472,12 +472,12 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr void initState() { super.initState(); - _previousController = new AnimationController( + _previousController = AnimationController( duration: kFloatingActionButtonSegue, vsync: this, )..addStatusListener(_handlePreviousAnimationStatusChanged); - _currentController = new AnimationController( + _currentController = AnimationController( duration: kFloatingActionButtonSegue, vsync: this, ); @@ -537,26 +537,26 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr void _updateAnimations() { // Get the animations for exit and entrance. - final CurvedAnimation previousExitScaleAnimation = new CurvedAnimation( + final CurvedAnimation previousExitScaleAnimation = CurvedAnimation( parent: _previousController, curve: Curves.easeIn, ); - final Animation previousExitRotationAnimation = new Tween(begin: 1.0, end: 1.0).animate( - new CurvedAnimation( + final Animation previousExitRotationAnimation = Tween(begin: 1.0, end: 1.0).animate( + CurvedAnimation( parent: _previousController, curve: Curves.easeIn, ), ); - final CurvedAnimation currentEntranceScaleAnimation = new CurvedAnimation( + final CurvedAnimation currentEntranceScaleAnimation = CurvedAnimation( parent: _currentController, curve: Curves.easeIn, ); - final Animation currentEntranceRotationAnimation = new Tween( + final Animation currentEntranceRotationAnimation = Tween( begin: 1.0 - kFloatingActionButtonTurnInterval, end: 1.0, ).animate( - new CurvedAnimation( + CurvedAnimation( parent: _currentController, curve: Curves.easeIn ), @@ -567,15 +567,15 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr final Animation moveRotationAnimation = widget.fabMotionAnimator.getRotationAnimation(parent: widget.fabMoveAnimation); // Aggregate the animations. - _previousScaleAnimation = new AnimationMin(moveScaleAnimation, previousExitScaleAnimation); - _currentScaleAnimation = new AnimationMin(moveScaleAnimation, currentEntranceScaleAnimation); - _extendedCurrentScaleAnimation = new CurvedAnimation( + _previousScaleAnimation = AnimationMin(moveScaleAnimation, previousExitScaleAnimation); + _currentScaleAnimation = AnimationMin(moveScaleAnimation, currentEntranceScaleAnimation); + _extendedCurrentScaleAnimation = CurvedAnimation( parent: _currentScaleAnimation, curve: const Interval(0.0, 0.1), ); - _previousRotationAnimation = new TrainHoppingAnimation(previousExitRotationAnimation, moveRotationAnimation); - _currentRotationAnimation = new TrainHoppingAnimation(currentEntranceRotationAnimation, moveRotationAnimation); + _previousRotationAnimation = TrainHoppingAnimation(previousExitRotationAnimation, moveRotationAnimation); + _currentRotationAnimation = TrainHoppingAnimation(currentEntranceRotationAnimation, moveRotationAnimation); _currentScaleAnimation.addListener(_onProgressChanged); _previousScaleAnimation.addListener(_onProgressChanged); @@ -604,14 +604,14 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr if (_previousController.status != AnimationStatus.dismissed) { if (_isExtendedFloatingActionButton(_previousChild)) { - children.add(new FadeTransition( + children.add(FadeTransition( opacity: _previousScaleAnimation, child: _previousChild, )); } else { - children.add(new ScaleTransition( + children.add(ScaleTransition( scale: _previousScaleAnimation, - child: new RotationTransition( + child: RotationTransition( turns: _previousRotationAnimation, child: _previousChild, ), @@ -620,24 +620,24 @@ class _FloatingActionButtonTransitionState extends State<_FloatingActionButtonTr } if (_isExtendedFloatingActionButton(widget.child)) { - children.add(new ScaleTransition( + children.add(ScaleTransition( scale: _extendedCurrentScaleAnimation, - child: new FadeTransition( + child: FadeTransition( opacity: _currentScaleAnimation, child: widget.child, ), )); } else { - children.add(new ScaleTransition( + children.add(ScaleTransition( scale: _currentScaleAnimation, - child: new RotationTransition( + child: RotationTransition( turns: _currentRotationAnimation, child: widget.child, ), )); } - return new Stack( + return Stack( alignment: Alignment.centerRight, children: children, ); @@ -912,7 +912,7 @@ class Scaffold extends StatefulWidget { final ScaffoldState result = context.ancestorStateOfType(const TypeMatcher()); if (nullOk || result != null) return result; - throw new FlutterError( + throw FlutterError( 'Scaffold.of() called with a context that does not contain a Scaffold.\n' 'No Scaffold ancestor could be found starting from the context that was passed to Scaffold.of(). ' 'This usually happens when the context provided is from the same StatefulWidget as that ' @@ -956,7 +956,7 @@ class Scaffold extends StatefulWidget { static ValueListenable geometryOf(BuildContext context) { final _ScaffoldScope scaffoldScope = context.inheritFromWidgetOfExactType(_ScaffoldScope); if (scaffoldScope == null) - throw new FlutterError( + throw FlutterError( 'Scaffold.geometryOf() called with a context that does not contain a Scaffold.\n' 'This usually happens when the context provided is from the same StatefulWidget as that ' 'whose build function actually creates the Scaffold widget being sought.\n' @@ -1000,7 +1000,7 @@ class Scaffold extends StatefulWidget { } @override - ScaffoldState createState() => new ScaffoldState(); + ScaffoldState createState() => ScaffoldState(); } /// State for a [Scaffold]. @@ -1011,8 +1011,8 @@ class ScaffoldState extends State with TickerProviderStateMixin { // DRAWER API - final GlobalKey _drawerKey = new GlobalKey(); - final GlobalKey _endDrawerKey = new GlobalKey(); + final GlobalKey _drawerKey = GlobalKey(); + final GlobalKey _endDrawerKey = GlobalKey(); /// Whether this scaffold has a non-null [Scaffold.drawer]. bool get hasDrawer => widget.drawer != null; @@ -1072,7 +1072,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { // SNACKBAR API - final Queue> _snackBars = new Queue>(); + final Queue> _snackBars = Queue>(); AnimationController _snackBarController; Timer _snackBarTimer; bool _accessibleNavigation; @@ -1100,12 +1100,12 @@ class ScaffoldState extends State with TickerProviderStateMixin { _snackBarController.forward(); } ScaffoldFeatureController controller; - controller = new ScaffoldFeatureController._( + controller = ScaffoldFeatureController._( // We provide a fallback key so that if back-to-back snackbars happen to // match in structure, material ink splashes and highlights don't survive // from one to the next. - snackbar.withAnimation(_snackBarController, fallbackKey: new UniqueKey()), - new Completer(), + snackbar.withAnimation(_snackBarController, fallbackKey: UniqueKey()), + Completer(), () { assert(_snackBars.first == controller); hideCurrentSnackBar(reason: SnackBarClosedReason.hide); @@ -1206,8 +1206,8 @@ class ScaffoldState extends State with TickerProviderStateMixin { } PersistentBottomSheetController _buildBottomSheet(WidgetBuilder builder, AnimationController controller, bool isLocalHistoryEntry) { - final Completer completer = new Completer(); - final GlobalKey<_PersistentBottomSheetState> bottomSheetKey = new GlobalKey<_PersistentBottomSheetState>(); + final Completer completer = Completer(); + final GlobalKey<_PersistentBottomSheetState> bottomSheetKey = GlobalKey<_PersistentBottomSheetState>(); _PersistentBottomSheet bottomSheet; void _removeCurrentBottomSheet() { @@ -1223,10 +1223,10 @@ class ScaffoldState extends State with TickerProviderStateMixin { } final LocalHistoryEntry entry = isLocalHistoryEntry - ? new LocalHistoryEntry(onRemove: _removeCurrentBottomSheet) + ? LocalHistoryEntry(onRemove: _removeCurrentBottomSheet) : null; - bottomSheet = new _PersistentBottomSheet( + bottomSheet = _PersistentBottomSheet( key: bottomSheetKey, animationController: controller, enableDrag: isLocalHistoryEntry, @@ -1251,7 +1251,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { if (isLocalHistoryEntry) ModalRoute.of(context).addLocalHistoryEntry(entry); - return new PersistentBottomSheetController._( + return PersistentBottomSheetController._( bottomSheet, completer, isLocalHistoryEntry ? entry.remove : _removeCurrentBottomSheet, @@ -1316,7 +1316,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { double restartAnimationFrom = 0.0; // If the Floating Action Button is moving right now, we need to start from a snapshot of the current transition. if (_floatingActionButtonMoveController.isAnimating) { - previousLocation = new _TransitionSnapshotFabLocation(_previousFloatingActionButtonLocation, _floatingActionButtonLocation, _floatingActionButtonAnimator, _floatingActionButtonMoveController.value); + previousLocation = _TransitionSnapshotFabLocation(_previousFloatingActionButtonLocation, _floatingActionButtonLocation, _floatingActionButtonAnimator, _floatingActionButtonMoveController.value); restartAnimationFrom = _floatingActionButtonAnimator.getAnimationRestart(_floatingActionButtonMoveController.value); } @@ -1337,7 +1337,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { // top. We implement this by providing a primary scroll controller and // scrolling it to the top when tapped. - final ScrollController _primaryScrollController = new ScrollController(); + final ScrollController _primaryScrollController = ScrollController(); void _handleStatusBarTap() { if (_primaryScrollController.hasClients) { @@ -1356,11 +1356,11 @@ class ScaffoldState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - _geometryNotifier = new _ScaffoldGeometryNotifier(const ScaffoldGeometry(), context); + _geometryNotifier = _ScaffoldGeometryNotifier(const ScaffoldGeometry(), context); _floatingActionButtonLocation = widget.floatingActionButtonLocation ?? _kDefaultFloatingActionButtonLocation; _floatingActionButtonAnimator = widget.floatingActionButtonAnimator ?? _kDefaultFloatingActionButtonAnimator; _previousFloatingActionButtonLocation = _floatingActionButtonLocation; - _floatingActionButtonMoveController = new AnimationController( + _floatingActionButtonMoveController = AnimationController( vsync: this, lowerBound: 0.0, upperBound: 1.0, @@ -1382,7 +1382,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { if (widget.bottomSheet != oldWidget.bottomSheet) { assert(() { if (widget.bottomSheet != null && _currentBottomSheet?._isLocalHistoryEntry == true) { - throw new FlutterError( + throw FlutterError( 'Scaffold.bottomSheet cannot be specified while a bottom sheet displayed ' 'with showBottomSheet() is still visible.\n Use the PersistentBottomSheetController ' 'returned by showBottomSheet() to close the old bottom sheet before creating ' @@ -1436,9 +1436,9 @@ class ScaffoldState extends State with TickerProviderStateMixin { }) { if (child != null) { children.add( - new LayoutId( + LayoutId( id: childId, - child: new MediaQuery.removePadding( + child: MediaQuery.removePadding( context: context, removeLeft: removeLeftPadding, removeTop: removeTopPadding, @@ -1456,7 +1456,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { assert(hasEndDrawer); _addIfNonNull( children, - new DrawerController( + DrawerController( key: _endDrawerKey, alignment: DrawerAlignment.end, child: widget.endDrawer, @@ -1477,7 +1477,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { assert(hasDrawer); _addIfNonNull( children, - new DrawerController( + DrawerController( key: _drawerKey, alignment: DrawerAlignment.start, child: widget.drawer, @@ -1507,7 +1507,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { if (route == null || route.isCurrent) { if (_snackBarController.isCompleted && _snackBarTimer == null) { final SnackBar snackBar = _snackBars.first._widget; - _snackBarTimer = new Timer(snackBar.duration, () { + _snackBarTimer = Timer(snackBar.duration, () { assert(_snackBarController.status == AnimationStatus.forward || _snackBarController.status == AnimationStatus.completed); // Look up MediaQuery again in case the setting changed. @@ -1542,8 +1542,8 @@ class ScaffoldState extends State with TickerProviderStateMixin { assert(extent >= 0.0 && extent.isFinite); _addIfNonNull( children, - new ConstrainedBox( - constraints: new BoxConstraints(maxHeight: extent), + ConstrainedBox( + constraints: BoxConstraints(maxHeight: extent), child: FlexibleSpaceBar.createSettings( currentExtent: extent, child: widget.appBar, @@ -1574,17 +1574,17 @@ class ScaffoldState extends State with TickerProviderStateMixin { if (widget.persistentFooterButtons != null) { _addIfNonNull( children, - new Container( - decoration: new BoxDecoration( - border: new Border( + Container( + decoration: BoxDecoration( + border: Border( top: Divider.createBorderSide(context, width: 1.0), ), ), - child: new SafeArea( - child: new ButtonTheme.bar( - child: new SafeArea( + child: SafeArea( + child: ButtonTheme.bar( + child: SafeArea( top: false, - child: new ButtonBar( + child: ButtonBar( children: widget.persistentFooterButtons ), ), @@ -1617,7 +1617,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { bottomSheets.addAll(_dismissedBottomSheets); if (_currentBottomSheet != null) bottomSheets.add(_currentBottomSheet._widget); - final Widget stack = new Stack( + final Widget stack = Stack( children: bottomSheets, alignment: Alignment.bottomCenter, ); @@ -1634,7 +1634,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { _addIfNonNull( children, - new _FloatingActionButtonTransition( + _FloatingActionButtonTransition( child: widget.floatingActionButton, fabMoveAnimation: _floatingActionButtonMoveController, fabMotionAnimator: _floatingActionButtonAnimator, @@ -1650,7 +1650,7 @@ class ScaffoldState extends State with TickerProviderStateMixin { if (themeData.platform == TargetPlatform.iOS) { _addIfNonNull( children, - new GestureDetector( + GestureDetector( behavior: HitTestBehavior.opaque, onTap: _handleStatusBarTap, // iOS accessibility automatically adds scroll-to-top to the clock in the status bar @@ -1677,17 +1677,17 @@ class ScaffoldState extends State with TickerProviderStateMixin { bottom: widget.resizeToAvoidBottomPadding ? mediaQuery.viewInsets.bottom : 0.0, ); - return new _ScaffoldScope( + return _ScaffoldScope( hasDrawer: hasDrawer, geometryNotifier: _geometryNotifier, - child: new PrimaryScrollController( + child: PrimaryScrollController( controller: _primaryScrollController, - child: new Material( + child: Material( color: widget.backgroundColor ?? themeData.scaffoldBackgroundColor, - child: new AnimatedBuilder(animation: _floatingActionButtonMoveController, builder: (BuildContext context, Widget child) { - return new CustomMultiChildLayout( + child: AnimatedBuilder(animation: _floatingActionButtonMoveController, builder: (BuildContext context, Widget child) { + return CustomMultiChildLayout( children: children, - delegate: new _ScaffoldLayout( + delegate: _ScaffoldLayout( minInsets: minInsets, currentFloatingActionButtonLocation: _floatingActionButtonLocation, floatingActionButtonMoveAnimationProgress: _floatingActionButtonMoveController.value, @@ -1739,7 +1739,7 @@ class _PersistentBottomSheet extends StatefulWidget { final WidgetBuilder builder; @override - _PersistentBottomSheetState createState() => new _PersistentBottomSheetState(); + _PersistentBottomSheetState createState() => _PersistentBottomSheetState(); } class _PersistentBottomSheetState extends State<_PersistentBottomSheet> { @@ -1768,22 +1768,22 @@ class _PersistentBottomSheetState extends State<_PersistentBottomSheet> { @override Widget build(BuildContext context) { - return new AnimatedBuilder( + return AnimatedBuilder( animation: widget.animationController, builder: (BuildContext context, Widget child) { - return new Align( + return Align( alignment: AlignmentDirectional.topStart, heightFactor: widget.animationController.value, child: child ); }, - child: new Semantics( + child: Semantics( container: true, onDismiss: () { close(); widget.onClosing(); }, - child: new BottomSheet( + child: BottomSheet( animationController: widget.animationController, enableDrag: widget.enableDrag, onClosing: widget.onClosing, diff --git a/packages/flutter/lib/src/material/scrollbar.dart b/packages/flutter/lib/src/material/scrollbar.dart index 6fb03cfc84..7b03fb8c46 100644 --- a/packages/flutter/lib/src/material/scrollbar.dart +++ b/packages/flutter/lib/src/material/scrollbar.dart @@ -47,7 +47,7 @@ class Scrollbar extends StatefulWidget { final Widget child; @override - _ScrollbarState createState() => new _ScrollbarState(); + _ScrollbarState createState() => _ScrollbarState(); } @@ -64,11 +64,11 @@ class _ScrollbarState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - _fadeoutAnimationController = new AnimationController( + _fadeoutAnimationController = AnimationController( vsync: this, duration: _kScrollbarFadeDuration, ); - _fadeoutOpacityAnimation = new CurvedAnimation( + _fadeoutOpacityAnimation = CurvedAnimation( parent: _fadeoutAnimationController, curve: Curves.fastOutSlowIn ); @@ -99,7 +99,7 @@ class _ScrollbarState extends State with TickerProviderStateMixin { } ScrollbarPainter _buildMaterialScrollbarPainter() { - return new ScrollbarPainter( + return ScrollbarPainter( color: _themeColor, textDirection: _textDirection, thickness: _kScrollbarThickness, @@ -119,7 +119,7 @@ class _ScrollbarState extends State with TickerProviderStateMixin { _materialPainter.update(notification.metrics, notification.metrics.axisDirection); _fadeoutTimer?.cancel(); - _fadeoutTimer = new Timer(_kScrollbarTimeToFade, () { + _fadeoutTimer = Timer(_kScrollbarTimeToFade, () { _fadeoutAnimationController.reverse(); _fadeoutTimer = null; }); @@ -139,23 +139,23 @@ class _ScrollbarState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { switch (_currentPlatform) { case TargetPlatform.iOS: - return new CupertinoScrollbar( + return CupertinoScrollbar( child: widget.child, ); case TargetPlatform.android: case TargetPlatform.fuchsia: - return new NotificationListener( + return NotificationListener( onNotification: _handleScrollNotification, - child: new RepaintBoundary( - child: new CustomPaint( + child: RepaintBoundary( + child: CustomPaint( foregroundPainter: _materialPainter, - child: new RepaintBoundary( + child: RepaintBoundary( child: widget.child, ), ), ), ); } - throw new FlutterError('Unknown platform for scrollbar insertion'); + throw FlutterError('Unknown platform for scrollbar insertion'); } } diff --git a/packages/flutter/lib/src/material/search.dart b/packages/flutter/lib/src/material/search.dart index 17dfb1d02f..947fa623d1 100644 --- a/packages/flutter/lib/src/material/search.dart +++ b/packages/flutter/lib/src/material/search.dart @@ -56,7 +56,7 @@ Future showSearch({ assert(context != null); delegate.query = query ?? delegate.query; delegate._currentBody = _SearchBody.suggestions; - return Navigator.of(context).push(new _SearchPageRoute( + return Navigator.of(context).push(_SearchPageRoute( delegate: delegate, )); } @@ -227,13 +227,13 @@ abstract class SearchDelegate { /// page. Animation get transitionAnimation => _proxyAnimation; - final FocusNode _focusNode = new FocusNode(); + final FocusNode _focusNode = FocusNode(); - final TextEditingController _queryTextController = new TextEditingController(); + final TextEditingController _queryTextController = TextEditingController(); - final ProxyAnimation _proxyAnimation = new ProxyAnimation(kAlwaysDismissedAnimation); + final ProxyAnimation _proxyAnimation = ProxyAnimation(kAlwaysDismissedAnimation); - final ValueNotifier<_SearchBody> _currentBodyNotifier = new ValueNotifier<_SearchBody>(null); + final ValueNotifier<_SearchBody> _currentBodyNotifier = ValueNotifier<_SearchBody>(null); _SearchBody get _currentBody => _currentBodyNotifier.value; set _currentBody(_SearchBody value) { @@ -293,7 +293,7 @@ class _SearchPageRoute extends PageRoute { Animation secondaryAnimation, Widget child, ) { - return new FadeTransition( + return FadeTransition( opacity: animation, child: child, ); @@ -312,7 +312,7 @@ class _SearchPageRoute extends PageRoute { Animation animation, Animation secondaryAnimation, ) { - return new _SearchPage( + return _SearchPage( delegate: delegate, animation: animation, ); @@ -337,7 +337,7 @@ class _SearchPage extends StatefulWidget { final Animation animation; @override - State createState() => new _SearchPageState(); + State createState() => _SearchPageState(); } class _SearchPageState extends State<_SearchPage> { @@ -394,13 +394,13 @@ class _SearchPageState extends State<_SearchPage> { Widget body; switch(widget.delegate._currentBody) { case _SearchBody.suggestions: - body = new KeyedSubtree( + body = KeyedSubtree( key: const ValueKey<_SearchBody>(_SearchBody.suggestions), child: widget.delegate.buildSuggestions(context), ); break; case _SearchBody.results: - body = new KeyedSubtree( + body = KeyedSubtree( key: const ValueKey<_SearchBody>(_SearchBody.results), child: widget.delegate.buildResults(context), ); @@ -416,19 +416,19 @@ class _SearchPageState extends State<_SearchPage> { routeName = searchFieldLabel; } - return new Semantics( + return Semantics( explicitChildNodes: true, scopesRoute: true, namesRoute: true, label: routeName, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( backgroundColor: theme.primaryColor, iconTheme: theme.primaryIconTheme, textTheme: theme.primaryTextTheme, brightness: theme.primaryColorBrightness, leading: widget.delegate.buildLeading(context), - title: new TextField( + title: TextField( controller: queryTextController, focusNode: widget.delegate._focusNode, style: theme.textTheme.title, @@ -436,14 +436,14 @@ class _SearchPageState extends State<_SearchPage> { onSubmitted: (String _) { widget.delegate.showResults(context); }, - decoration: new InputDecoration( + decoration: InputDecoration( border: InputBorder.none, hintText: searchFieldLabel, ), ), actions: widget.delegate.buildActions(context), ), - body: new AnimatedSwitcher( + body: AnimatedSwitcher( duration: const Duration(milliseconds: 300), child: body, ), diff --git a/packages/flutter/lib/src/material/slider.dart b/packages/flutter/lib/src/material/slider.dart index a0fecacfcd..78a396b1bc 100644 --- a/packages/flutter/lib/src/material/slider.dart +++ b/packages/flutter/lib/src/material/slider.dart @@ -328,14 +328,14 @@ class Slider extends StatefulWidget { final SemanticFormatterCallback semanticFormatterCallback; @override - _SliderState createState() => new _SliderState(); + _SliderState createState() => _SliderState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('value', value)); - properties.add(new DoubleProperty('min', min)); - properties.add(new DoubleProperty('max', max)); + properties.add(DoubleProperty('value', value)); + properties.add(DoubleProperty('min', min)); + properties.add(DoubleProperty('max', max)); } } @@ -359,19 +359,19 @@ class _SliderState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - overlayController = new AnimationController( + overlayController = AnimationController( duration: kRadialReactionDuration, vsync: this, ); - valueIndicatorController = new AnimationController( + valueIndicatorController = AnimationController( duration: valueIndicatorAnimationDuration, vsync: this, ); - enableController = new AnimationController( + enableController = AnimationController( duration: enableAnimationDuration, vsync: this, ); - positionController = new AnimationController( + positionController = AnimationController( duration: Duration.zero, vsync: this, ); @@ -444,7 +444,7 @@ class _SliderState extends State with TickerProviderStateMixin { ); } - return new _SliderRenderObjectWidget( + return _SliderRenderObjectWidget( value: _unlerp(widget.value), divisions: widget.divisions, label: widget.label, @@ -487,7 +487,7 @@ class _SliderRenderObjectWidget extends LeafRenderObjectWidget { @override _RenderSlider createRenderObject(BuildContext context) { - return new _RenderSlider( + return _RenderSlider( value: value, divisions: divisions, label: label, @@ -554,27 +554,27 @@ class _RenderSlider extends RenderBox { _state = state, _textDirection = textDirection { _updateLabelPainter(); - final GestureArenaTeam team = new GestureArenaTeam(); - _drag = new HorizontalDragGestureRecognizer() + final GestureArenaTeam team = GestureArenaTeam(); + _drag = HorizontalDragGestureRecognizer() ..team = team ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd ..onCancel = _endInteraction; - _tap = new TapGestureRecognizer() + _tap = TapGestureRecognizer() ..team = team ..onTapDown = _handleTapDown ..onTapUp = _handleTapUp ..onTapCancel = _endInteraction; - _overlayAnimation = new CurvedAnimation( + _overlayAnimation = CurvedAnimation( parent: _state.overlayController, curve: Curves.fastOutSlowIn, ); - _valueIndicatorAnimation = new CurvedAnimation( + _valueIndicatorAnimation = CurvedAnimation( parent: _state.valueIndicatorController, curve: Curves.fastOutSlowIn, ); - _enableAnimation = new CurvedAnimation( + _enableAnimation = CurvedAnimation( parent: _state.enableController, curve: Curves.easeInOut, ); @@ -587,13 +587,13 @@ class _RenderSlider extends RenderBox { static const double _preferredTrackWidth = 144.0; static const double _preferredTotalWidth = _preferredTrackWidth + _overlayDiameter; static const Duration _minimumInteractionTime = Duration(milliseconds: 500); - static final Tween _overlayRadiusTween = new Tween(begin: 0.0, end: _overlayRadius); + static final Tween _overlayRadiusTween = Tween(begin: 0.0, end: _overlayRadius); _SliderState _state; Animation _overlayAnimation; Animation _valueIndicatorAnimation; Animation _enableAnimation; - final TextPainter _labelPainter = new TextPainter(); + final TextPainter _labelPainter = TextPainter(); HorizontalDragGestureRecognizer _drag; TapGestureRecognizer _tap; bool _active = false; @@ -768,7 +768,7 @@ class _RenderSlider extends RenderBox { void _updateLabelPainter() { if (label != null) { _labelPainter - ..text = new TextSpan( + ..text = TextSpan( style: _sliderTheme.valueIndicatorTextStyle, text: label, ) @@ -840,7 +840,7 @@ class _RenderSlider extends RenderBox { if (showValueIndicator) { _state.valueIndicatorController.forward(); _state.interactionTimer?.cancel(); - _state.interactionTimer = new Timer(_minimumInteractionTime * timeDilation, () { + _state.interactionTimer = Timer(_minimumInteractionTime * timeDilation, () { _state.interactionTimer = null; if (!_active && _state.valueIndicatorController.status == AnimationStatus.completed) { @@ -927,7 +927,7 @@ class _RenderSlider extends RenderBox { @override void performResize() { - size = new Size( + size = Size( constraints.hasBoundedWidth ? constraints.maxWidth : _preferredTotalWidth, constraints.hasBoundedHeight ? constraints.maxHeight : _overlayDiameter, ); @@ -949,7 +949,7 @@ class _RenderSlider extends RenderBox { if (dx >= 3.0 * _trackHeight) { for (int i = 0; i <= divisions; i += 1) { final double left = trackLeft.left + i * dx; - final Offset center = new Offset(left + tickRadius, trackLeft.top + tickRadius); + final Offset center = Offset(left + tickRadius, trackLeft.top + tickRadius); if (trackLeft.contains(center)) { canvas.drawCircle(center, tickRadius, leftPaint); } else if (trackRight.contains(center)) { @@ -967,7 +967,7 @@ class _RenderSlider extends RenderBox { // and 32% for colored material, but we don't really have a way to // know what the underlying color is, so there's no easy way to // implement this. Choosing the "light" version for now. - final Paint overlayPaint = new Paint()..color = _sliderTheme.overlayColor; + final Paint overlayPaint = Paint()..color = _sliderTheme.overlayColor; final double radius = _overlayRadiusTween.evaluate(_overlayAnimation); canvas.drawCircle(center, radius, overlayPaint); } @@ -979,15 +979,15 @@ class _RenderSlider extends RenderBox { final double trackLength = size.width - 2 * _overlayRadius; final double value = _state.positionController.value; - final ColorTween activeTrackEnableColor = new ColorTween(begin: _sliderTheme.disabledActiveTrackColor, end: _sliderTheme.activeTrackColor); - final ColorTween inactiveTrackEnableColor = new ColorTween(begin: _sliderTheme.disabledInactiveTrackColor, end: _sliderTheme.inactiveTrackColor); - final ColorTween activeTickMarkEnableColor = new ColorTween(begin: _sliderTheme.disabledActiveTickMarkColor, end: _sliderTheme.activeTickMarkColor); - final ColorTween inactiveTickMarkEnableColor = new ColorTween(begin: _sliderTheme.disabledInactiveTickMarkColor, end: _sliderTheme.inactiveTickMarkColor); + final ColorTween activeTrackEnableColor = ColorTween(begin: _sliderTheme.disabledActiveTrackColor, end: _sliderTheme.activeTrackColor); + final ColorTween inactiveTrackEnableColor = ColorTween(begin: _sliderTheme.disabledInactiveTrackColor, end: _sliderTheme.inactiveTrackColor); + final ColorTween activeTickMarkEnableColor = ColorTween(begin: _sliderTheme.disabledActiveTickMarkColor, end: _sliderTheme.activeTickMarkColor); + final ColorTween inactiveTickMarkEnableColor = ColorTween(begin: _sliderTheme.disabledInactiveTickMarkColor, end: _sliderTheme.inactiveTickMarkColor); - final Paint activeTrackPaint = new Paint()..color = activeTrackEnableColor.evaluate(_enableAnimation); - final Paint inactiveTrackPaint = new Paint()..color = inactiveTrackEnableColor.evaluate(_enableAnimation); - final Paint activeTickMarkPaint = new Paint()..color = activeTickMarkEnableColor.evaluate(_enableAnimation); - final Paint inactiveTickMarkPaint = new Paint()..color = inactiveTickMarkEnableColor.evaluate(_enableAnimation); + final Paint activeTrackPaint = Paint()..color = activeTrackEnableColor.evaluate(_enableAnimation); + final Paint inactiveTrackPaint = Paint()..color = inactiveTrackEnableColor.evaluate(_enableAnimation); + final Paint activeTickMarkPaint = Paint()..color = activeTickMarkEnableColor.evaluate(_enableAnimation); + final Paint inactiveTickMarkPaint = Paint()..color = inactiveTickMarkEnableColor.evaluate(_enableAnimation); double visualPosition; Paint leftTrackPaint; @@ -1023,10 +1023,10 @@ class _RenderSlider extends RenderBox { final double thumbRadius = _sliderTheme.thumbShape.getPreferredSize(isInteractive, isDiscrete).width / 2.0; final double trackActiveLeft = math.max(0.0, trackActive - thumbRadius - thumbGap * (1.0 - _enableAnimation.value)); final double trackActiveRight = math.min(trackActive + thumbRadius + thumbGap * (1.0 - _enableAnimation.value), trackRight); - final Rect trackLeftRect = new Rect.fromLTRB(trackLeft, trackTop, trackActiveLeft, trackBottom); - final Rect trackRightRect = new Rect.fromLTRB(trackActiveRight, trackTop, trackRight, trackBottom); + final Rect trackLeftRect = Rect.fromLTRB(trackLeft, trackTop, trackActiveLeft, trackBottom); + final Rect trackRightRect = Rect.fromLTRB(trackActiveRight, trackTop, trackRight, trackBottom); - final Offset thumbCenter = new Offset(trackActive, trackVerticalCenter); + final Offset thumbCenter = Offset(trackActive, trackVerticalCenter); // Paint the track. if (visualPosition > 0.0) { diff --git a/packages/flutter/lib/src/material/slider_theme.dart b/packages/flutter/lib/src/material/slider_theme.dart index eee54fbbb8..085cda8d7e 100644 --- a/packages/flutter/lib/src/material/slider_theme.dart +++ b/packages/flutter/lib/src/material/slider_theme.dart @@ -253,7 +253,7 @@ class SliderThemeData extends Diagnosticable { // implement this. Choosing the "light" version for now. const int overlayLightAlpha = 0x29; // 16% opacity - return new SliderThemeData( + return SliderThemeData( activeTrackColor: primaryColor.withAlpha(activeTrackAlpha), inactiveTrackColor: primaryColor.withAlpha(inactiveTrackAlpha), disabledActiveTrackColor: primaryColorDark.withAlpha(disabledActiveTrackAlpha), @@ -367,7 +367,7 @@ class SliderThemeData extends Diagnosticable { ShowValueIndicator showValueIndicator, TextStyle valueIndicatorTextStyle, }) { - return new SliderThemeData( + return SliderThemeData( activeTrackColor: activeTrackColor ?? this.activeTrackColor, inactiveTrackColor: inactiveTrackColor ?? this.inactiveTrackColor, disabledActiveTrackColor: disabledActiveTrackColor ?? this.disabledActiveTrackColor, @@ -406,7 +406,7 @@ class SliderThemeData extends Diagnosticable { assert(a != null); assert(b != null); assert(t != null); - return new SliderThemeData( + return SliderThemeData( activeTrackColor: Color.lerp(a.activeTrackColor, b.activeTrackColor, t), inactiveTrackColor: Color.lerp(a.inactiveTrackColor, b.inactiveTrackColor, t), disabledActiveTrackColor: Color.lerp(a.disabledActiveTrackColor, b.disabledActiveTrackColor, t), @@ -478,29 +478,29 @@ class SliderThemeData extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - final ThemeData defaultTheme = new ThemeData.fallback(); - final SliderThemeData defaultData = new SliderThemeData.fromPrimaryColors( + final ThemeData defaultTheme = ThemeData.fallback(); + final SliderThemeData defaultData = SliderThemeData.fromPrimaryColors( primaryColor: defaultTheme.primaryColor, primaryColorDark: defaultTheme.primaryColorDark, primaryColorLight: defaultTheme.primaryColorLight, valueIndicatorTextStyle: defaultTheme.accentTextTheme.body2, ); - properties.add(new DiagnosticsProperty('activeTrackColor', activeTrackColor, defaultValue: defaultData.activeTrackColor)); - properties.add(new DiagnosticsProperty('inactiveTrackColor', inactiveTrackColor, defaultValue: defaultData.inactiveTrackColor)); - properties.add(new DiagnosticsProperty('disabledActiveTrackColor', disabledActiveTrackColor, defaultValue: defaultData.disabledActiveTrackColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('disabledInactiveTrackColor', disabledInactiveTrackColor, defaultValue: defaultData.disabledInactiveTrackColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('activeTickMarkColor', activeTickMarkColor, defaultValue: defaultData.activeTickMarkColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('inactiveTickMarkColor', inactiveTickMarkColor, defaultValue: defaultData.inactiveTickMarkColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('disabledActiveTickMarkColor', disabledActiveTickMarkColor, defaultValue: defaultData.disabledActiveTickMarkColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('disabledInactiveTickMarkColor', disabledInactiveTickMarkColor, defaultValue: defaultData.disabledInactiveTickMarkColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('thumbColor', thumbColor, defaultValue: defaultData.thumbColor)); - properties.add(new DiagnosticsProperty('disabledThumbColor', disabledThumbColor, defaultValue: defaultData.disabledThumbColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('overlayColor', overlayColor, defaultValue: defaultData.overlayColor, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('valueIndicatorColor', valueIndicatorColor, defaultValue: defaultData.valueIndicatorColor)); - properties.add(new DiagnosticsProperty('thumbShape', thumbShape, defaultValue: defaultData.thumbShape, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('valueIndicatorShape', valueIndicatorShape, defaultValue: defaultData.valueIndicatorShape, level: DiagnosticLevel.debug)); - properties.add(new EnumProperty('showValueIndicator', showValueIndicator, defaultValue: defaultData.showValueIndicator)); - properties.add(new DiagnosticsProperty('valueIndicatorTextStyle', valueIndicatorTextStyle, defaultValue: defaultData.valueIndicatorTextStyle)); + properties.add(DiagnosticsProperty('activeTrackColor', activeTrackColor, defaultValue: defaultData.activeTrackColor)); + properties.add(DiagnosticsProperty('inactiveTrackColor', inactiveTrackColor, defaultValue: defaultData.inactiveTrackColor)); + properties.add(DiagnosticsProperty('disabledActiveTrackColor', disabledActiveTrackColor, defaultValue: defaultData.disabledActiveTrackColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('disabledInactiveTrackColor', disabledInactiveTrackColor, defaultValue: defaultData.disabledInactiveTrackColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('activeTickMarkColor', activeTickMarkColor, defaultValue: defaultData.activeTickMarkColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('inactiveTickMarkColor', inactiveTickMarkColor, defaultValue: defaultData.inactiveTickMarkColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('disabledActiveTickMarkColor', disabledActiveTickMarkColor, defaultValue: defaultData.disabledActiveTickMarkColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('disabledInactiveTickMarkColor', disabledInactiveTickMarkColor, defaultValue: defaultData.disabledInactiveTickMarkColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('thumbColor', thumbColor, defaultValue: defaultData.thumbColor)); + properties.add(DiagnosticsProperty('disabledThumbColor', disabledThumbColor, defaultValue: defaultData.disabledThumbColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('overlayColor', overlayColor, defaultValue: defaultData.overlayColor, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('valueIndicatorColor', valueIndicatorColor, defaultValue: defaultData.valueIndicatorColor)); + properties.add(DiagnosticsProperty('thumbShape', thumbShape, defaultValue: defaultData.thumbShape, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('valueIndicatorShape', valueIndicatorShape, defaultValue: defaultData.valueIndicatorShape, level: DiagnosticLevel.debug)); + properties.add(EnumProperty('showValueIndicator', showValueIndicator, defaultValue: defaultData.showValueIndicator)); + properties.add(DiagnosticsProperty('valueIndicatorTextStyle', valueIndicatorTextStyle, defaultValue: defaultData.valueIndicatorTextStyle)); } } @@ -567,7 +567,7 @@ class RoundSliderThumbShape extends SliderComponentShape { @override Size getPreferredSize(bool isEnabled, bool isDiscrete) { - return new Size.fromRadius(isEnabled ? _thumbRadius : _disabledThumbRadius); + return Size.fromRadius(isEnabled ? _thumbRadius : _disabledThumbRadius); } @override @@ -584,18 +584,18 @@ class RoundSliderThumbShape extends SliderComponentShape { double value, }) { final Canvas canvas = context.canvas; - final Tween radiusTween = new Tween( + final Tween radiusTween = Tween( begin: _disabledThumbRadius, end: _thumbRadius, ); - final ColorTween colorTween = new ColorTween( + final ColorTween colorTween = ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.thumbColor, ); canvas.drawCircle( thumbCenter, radiusTween.evaluate(enableAnimation), - new Paint()..color = colorTween.evaluate(enableAnimation), + Paint()..color = colorTween.evaluate(enableAnimation), ); } } @@ -660,7 +660,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { // Adds an arc to the path that has the attributes passed in. This is // a convenience to make adding arcs have less boilerplate. static void _addArc(Path path, Offset center, double radius, double startAngle, double endAngle) { - final Rect arcRect = new Rect.fromCircle(center: center, radius: radius); + final Rect arcRect = Rect.fromCircle(center: center, radius: radius); path.arcTo(arcRect, startAngle, endAngle - startAngle, false); } @@ -671,21 +671,21 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { const double bottomNeckStartAngle = _bottomLobeEndAngle - math.pi; const double bottomNeckEndAngle = 0.0; - final Path path = new Path(); - final Offset bottomKnobStart = new Offset( + final Path path = Path(); + final Offset bottomKnobStart = Offset( _bottomLobeRadius * math.cos(_bottomLobeStartAngle), _bottomLobeRadius * math.sin(_bottomLobeStartAngle), ); final Offset bottomNeckRightCenter = bottomKnobStart + - new Offset( + Offset( bottomNeckRadius * math.cos(bottomNeckStartAngle), -bottomNeckRadius * math.sin(bottomNeckStartAngle), ); - final Offset bottomNeckLeftCenter = new Offset( + final Offset bottomNeckLeftCenter = Offset( -bottomNeckRightCenter.dx, bottomNeckRightCenter.dy, ); - final Offset bottomNeckStartRight = new Offset( + final Offset bottomNeckStartRight = Offset( bottomNeckRightCenter.dx - bottomNeckRadius, bottomNeckRightCenter.dy, ); @@ -712,7 +712,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { bottomNeckEndAngle, ); - _bottomLobeEnd = new Offset( + _bottomLobeEnd = Offset( -bottomNeckStartRight.dx, bottomNeckStartRight.dy, ); @@ -737,7 +737,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { Offset center, ) { const double edgeMargin = 4.0; - final Rect topLobeRect = new Rect.fromLTWH( + final Rect topLobeRect = Rect.fromLTWH( -_topLobeRadius - halfWidthNeeded, -_topLobeRadius - _distanceBetweenTopBottomCenters, 2.0 * (_topLobeRadius + halfWidthNeeded), @@ -796,7 +796,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { rightWidthNeeded = halfWidthNeeded + shift; leftWidthNeeded = halfWidthNeeded - shift; - final Path path = new Path(); + final Path path = Path(); final Offset bottomLobeEnd = _addBottomLobe(path); // The base of the triangle between the top lobe center and the centers of @@ -811,11 +811,11 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { final double leftTheta = (1.0 - leftAmount) * _thirtyDegrees; final double rightTheta = (1.0 - rightAmount) * _thirtyDegrees; // The center of the top left neck arc. - final Offset neckLeftCenter = new Offset( + final Offset neckLeftCenter = Offset( -neckTriangleBase, _topLobeCenter.dy + math.cos(leftTheta) * _neckTriangleHypotenuse, ); - final Offset neckRightCenter = new Offset( + final Offset neckRightCenter = Offset( neckTriangleBase, _topLobeCenter.dy + math.cos(rightTheta) * _neckTriangleHypotenuse, ); @@ -827,19 +827,19 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { final double neckStretchBaseline = bottomLobeEnd.dy - math.max(neckLeftCenter.dy, neckRightCenter.dy); final double t = math.pow(inverseTextScale, 3.0); final double stretch = (neckStretchBaseline * t).clamp(0.0, 10.0 * neckStretchBaseline); - final Offset neckStretch = new Offset(0.0, neckStretchBaseline - stretch); + final Offset neckStretch = Offset(0.0, neckStretchBaseline - stretch); assert(!_debuggingLabelLocation || () { - final Offset leftCenter = _topLobeCenter - new Offset(leftWidthNeeded, 0.0) + neckStretch; - final Offset rightCenter = _topLobeCenter + new Offset(rightWidthNeeded, 0.0) + neckStretch; - final Rect valueRect = new Rect.fromLTRB( + final Offset leftCenter = _topLobeCenter - Offset(leftWidthNeeded, 0.0) + neckStretch; + final Offset rightCenter = _topLobeCenter + Offset(rightWidthNeeded, 0.0) + neckStretch; + final Rect valueRect = Rect.fromLTRB( leftCenter.dx - _topLobeRadius, leftCenter.dy - _topLobeRadius, rightCenter.dx + _topLobeRadius, rightCenter.dy + _topLobeRadius, ); - final Paint outlinePaint = new Paint() + final Paint outlinePaint = Paint() ..color = const Color(0xffff0000) ..style = PaintingStyle.stroke ..strokeWidth = 1.0; @@ -856,14 +856,14 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { ); _addArc( path, - _topLobeCenter - new Offset(leftWidthNeeded, 0.0) + neckStretch, + _topLobeCenter - Offset(leftWidthNeeded, 0.0) + neckStretch, _topLobeRadius, _ninetyDegrees + leftTheta, _twoSeventyDegrees, ); _addArc( path, - _topLobeCenter + new Offset(rightWidthNeeded, 0.0) + neckStretch, + _topLobeCenter + Offset(rightWidthNeeded, 0.0) + neckStretch, _topLobeRadius, _twoSeventyDegrees, _twoSeventyDegrees + math.pi - rightTheta, @@ -881,7 +881,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { canvas.save(); canvas.translate(shift, -_distanceBetweenTopBottomCenters + neckStretch.dy); canvas.scale(inverseTextScale, inverseTextScale); - labelPainter.paint(canvas, Offset.zero - new Offset(labelHalfWidth, labelPainter.height / 2.0)); + labelPainter.paint(canvas, Offset.zero - Offset(labelHalfWidth, labelPainter.height / 2.0)); canvas.restore(); canvas.restore(); } @@ -899,7 +899,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { TextDirection textDirection, double value, }) { - final ColorTween enableColor = new ColorTween( + final ColorTween enableColor = ColorTween( begin: sliderTheme.disabledThumbColor, end: sliderTheme.valueIndicatorColor, ); @@ -907,7 +907,7 @@ class PaddleSliderValueIndicatorShape extends SliderComponentShape { parentBox, context.canvas, thumbCenter, - new Paint()..color = enableColor.evaluate(enableAnimation), + Paint()..color = enableColor.evaluate(enableAnimation), activationAnimation.value, labelPainter, ); diff --git a/packages/flutter/lib/src/material/snack_bar.dart b/packages/flutter/lib/src/material/snack_bar.dart index 2e75a517f1..be75053b53 100644 --- a/packages/flutter/lib/src/material/snack_bar.dart +++ b/packages/flutter/lib/src/material/snack_bar.dart @@ -97,7 +97,7 @@ class SnackBarAction extends StatefulWidget { final VoidCallback onPressed; @override - _SnackBarActionState createState() => new _SnackBarActionState(); + _SnackBarActionState createState() => _SnackBarActionState(); } class _SnackBarActionState extends State { @@ -115,9 +115,9 @@ class _SnackBarActionState extends State { @override Widget build(BuildContext context) { - return new FlatButton( + return FlatButton( onPressed: _haveTriggeredAction ? null : _handlePressed, - child: new Text(widget.label), + child: Text(widget.label), ); } } @@ -193,17 +193,17 @@ class SnackBar extends StatelessWidget { final MediaQueryData mediaQueryData = MediaQuery.of(context); assert(animation != null); final ThemeData theme = Theme.of(context); - final ThemeData darkTheme = new ThemeData( + final ThemeData darkTheme = ThemeData( brightness: Brightness.dark, accentColor: theme.accentColor, accentColorBrightness: theme.accentColorBrightness, ); final List children = [ const SizedBox(width: _kSnackBarPadding), - new Expanded( - child: new Container( + Expanded( + child: Container( padding: const EdgeInsets.symmetric(vertical: _kSingleLineVerticalPadding), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: darkTheme.textTheme.subhead, child: content, ), @@ -211,7 +211,7 @@ class SnackBar extends StatelessWidget { ), ]; if (action != null) { - children.add(new ButtonTheme.bar( + children.add(ButtonTheme.bar( padding: const EdgeInsets.symmetric(horizontal: _kSnackBarPadding), textTheme: ButtonTextTheme.accent, child: action, @@ -219,34 +219,34 @@ class SnackBar extends StatelessWidget { } else { children.add(const SizedBox(width: _kSnackBarPadding)); } - final CurvedAnimation heightAnimation = new CurvedAnimation(parent: animation, curve: _snackBarHeightCurve); - final CurvedAnimation fadeAnimation = new CurvedAnimation(parent: animation, curve: _snackBarFadeCurve, reverseCurve: const Threshold(0.0)); - Widget snackbar = new SafeArea( + final CurvedAnimation heightAnimation = CurvedAnimation(parent: animation, curve: _snackBarHeightCurve); + final CurvedAnimation fadeAnimation = CurvedAnimation(parent: animation, curve: _snackBarFadeCurve, reverseCurve: const Threshold(0.0)); + Widget snackbar = SafeArea( top: false, - child: new Row( + child: Row( children: children, crossAxisAlignment: CrossAxisAlignment.center, ), ); - snackbar = new Semantics( + snackbar = Semantics( container: true, liveRegion: true, onDismiss: () { Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.dismiss); }, - child: new Dismissible( + child: Dismissible( key: const Key('dismissible'), direction: DismissDirection.down, resizeDuration: null, onDismissed: (DismissDirection direction) { Scaffold.of(context).removeCurrentSnackBar(reason: SnackBarClosedReason.swipe); }, - child: new Material( + child: Material( elevation: 6.0, color: backgroundColor ?? _kSnackBackground, - child: new Theme( + child: Theme( data: darkTheme, - child: mediaQueryData.accessibleNavigation ? snackbar : new FadeTransition( + child: mediaQueryData.accessibleNavigation ? snackbar : FadeTransition( opacity: fadeAnimation, child: snackbar, ), @@ -254,11 +254,11 @@ class SnackBar extends StatelessWidget { ), ), ); - return new ClipRect( - child: mediaQueryData.accessibleNavigation ? snackbar : new AnimatedBuilder( + return ClipRect( + child: mediaQueryData.accessibleNavigation ? snackbar : AnimatedBuilder( animation: heightAnimation, builder: (BuildContext context, Widget child) { - return new Align( + return Align( alignment: AlignmentDirectional.topStart, heightFactor: heightAnimation.value, child: child, @@ -273,7 +273,7 @@ class SnackBar extends StatelessWidget { /// Creates an animation controller useful for driving a snack bar's entrance and exit animation. static AnimationController createAnimationController({ @required TickerProvider vsync }) { - return new AnimationController( + return AnimationController( duration: _kSnackBarTransitionDuration, debugLabel: 'SnackBar', vsync: vsync, @@ -285,7 +285,7 @@ class SnackBar extends StatelessWidget { /// If the original snack bar lacks a key, the newly created snack bar will /// use the given fallback key. SnackBar withAnimation(Animation newAnimation, { Key fallbackKey }) { - return new SnackBar( + return SnackBar( key: key ?? fallbackKey, content: content, backgroundColor: backgroundColor, diff --git a/packages/flutter/lib/src/material/stepper.dart b/packages/flutter/lib/src/material/stepper.dart index b14cb05c76..ccce366711 100644 --- a/packages/flutter/lib/src/material/stepper.dart +++ b/packages/flutter/lib/src/material/stepper.dart @@ -175,7 +175,7 @@ class Stepper extends StatefulWidget { final VoidCallback onStepCancel; @override - _StepperState createState() => new _StepperState(); + _StepperState createState() => _StepperState(); } class _StepperState extends State with TickerProviderStateMixin { @@ -185,9 +185,9 @@ class _StepperState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - _keys = new List.generate( + _keys = List.generate( widget.steps.length, - (int i) => new GlobalKey(), + (int i) => GlobalKey(), ); for (int i = 0; i < widget.steps.length; i += 1) @@ -220,7 +220,7 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildLine(bool visible) { - return new Container( + return Container( width: visible ? 1.0 : 0.0, height: 16.0, color: Colors.grey.shade400, @@ -234,18 +234,18 @@ class _StepperState extends State with TickerProviderStateMixin { switch (state) { case StepState.indexed: case StepState.disabled: - return new Text( + return Text( '${index + 1}', style: isDarkActive ? _kStepStyle.copyWith(color: Colors.black87) : _kStepStyle, ); case StepState.editing: - return new Icon( + return Icon( Icons.edit, color: isDarkActive ? _kCircleActiveDark : _kCircleActiveLight, size: 18.0, ); case StepState.complete: - return new Icon( + return Icon( Icons.check, color: isDarkActive ? _kCircleActiveDark : _kCircleActiveLight, size: 18.0, @@ -266,18 +266,18 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildCircle(int index, bool oldState) { - return new Container( + return Container( margin: const EdgeInsets.symmetric(vertical: 8.0), width: _kStepSize, height: _kStepSize, - child: new AnimatedContainer( + child: AnimatedContainer( curve: Curves.fastOutSlowIn, duration: kThemeAnimationDuration, - decoration: new BoxDecoration( + decoration: BoxDecoration( color: _circleColor(index), shape: BoxShape.circle, ), - child: new Center( + child: Center( child: _buildCircleChild(index, oldState && widget.steps[index].state == StepState.error), ), ), @@ -285,19 +285,19 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildTriangle(int index, bool oldState) { - return new Container( + return Container( margin: const EdgeInsets.symmetric(vertical: 8.0), width: _kStepSize, height: _kStepSize, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: _kStepSize, height: _kTriangleHeight, // Height of 24dp-long-sided equilateral triangle. - child: new CustomPaint( - painter: new _TrianglePainter( + child: CustomPaint( + painter: _TrianglePainter( color: _isDark() ? _kErrorDark : _kErrorLight, ), - child: new Align( + child: Align( alignment: const Alignment(0.0, 0.8), // 0.8 looks better than the geometrical 0.33. child: _buildCircleChild(index, oldState && widget.steps[index].state != StepState.error), ), @@ -309,7 +309,7 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildIcon(int index) { if (widget.steps[index].state != _oldStates[index]) { - return new AnimatedCrossFade( + return AnimatedCrossFade( firstChild: _buildCircle(index, true), secondChild: _buildTriangle(index, true), firstCurve: const Interval(0.0, 0.6, curve: Curves.fastOutSlowIn), @@ -343,26 +343,26 @@ class _StepperState extends State with TickerProviderStateMixin { final ThemeData themeData = Theme.of(context); final MaterialLocalizations localizations = MaterialLocalizations.of(context); - return new Container( + return Container( margin: const EdgeInsets.only(top: 16.0), - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints.tightFor(height: 48.0), - child: new Row( + child: Row( children: [ - new FlatButton( + FlatButton( onPressed: widget.onStepContinue, color: _isDark() ? themeData.backgroundColor : themeData.primaryColor, textColor: Colors.white, textTheme: ButtonTextTheme.normal, - child: new Text(localizations.continueButtonLabel), + child: Text(localizations.continueButtonLabel), ), - new Container( + Container( margin: const EdgeInsetsDirectional.only(start: 8.0), - child: new FlatButton( + child: FlatButton( onPressed: widget.onStepCancel, textColor: cancelColor, textTheme: ButtonTextTheme.normal, - child: new Text(localizations.cancelButtonLabel), + child: Text(localizations.cancelButtonLabel), ), ), ], @@ -417,7 +417,7 @@ class _StepperState extends State with TickerProviderStateMixin { Widget _buildHeaderText(int index) { final List children = [ - new AnimatedDefaultTextStyle( + AnimatedDefaultTextStyle( style: _titleStyle(index), duration: kThemeAnimationDuration, curve: Curves.fastOutSlowIn, @@ -427,9 +427,9 @@ class _StepperState extends State with TickerProviderStateMixin { if (widget.steps[index].subtitle != null) children.add( - new Container( + Container( margin: const EdgeInsets.only(top: 2.0), - child: new AnimatedDefaultTextStyle( + child: AnimatedDefaultTextStyle( style: _subtitleStyle(index), duration: kThemeAnimationDuration, curve: Curves.fastOutSlowIn, @@ -438,7 +438,7 @@ class _StepperState extends State with TickerProviderStateMixin { ), ); - return new Column( + return Column( crossAxisAlignment: CrossAxisAlignment.start, mainAxisSize: MainAxisSize.min, children: children @@ -446,11 +446,11 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildVerticalHeader(int index) { - return new Container( + return Container( margin: const EdgeInsets.symmetric(horizontal: 24.0), - child: new Row( + child: Row( children: [ - new Column( + Column( children: [ // Line parts are always added in order for the ink splash to // flood the tips of the connector lines. @@ -459,7 +459,7 @@ class _StepperState extends State with TickerProviderStateMixin { _buildLine(!_isLast(index)), ] ), - new Container( + Container( margin: const EdgeInsetsDirectional.only(start: 12.0), child: _buildHeaderText(index) ) @@ -469,33 +469,33 @@ class _StepperState extends State with TickerProviderStateMixin { } Widget _buildVerticalBody(int index) { - return new Stack( + return Stack( children: [ - new PositionedDirectional( + PositionedDirectional( start: 24.0, top: 0.0, bottom: 0.0, - child: new SizedBox( + child: SizedBox( width: 24.0, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: _isLast(index) ? 0.0 : 1.0, - child: new Container( + child: Container( color: Colors.grey.shade400, ), ), ), ), ), - new AnimatedCrossFade( - firstChild: new Container(height: 0.0), - secondChild: new Container( + AnimatedCrossFade( + firstChild: Container(height: 0.0), + secondChild: Container( margin: const EdgeInsetsDirectional.only( start: 60.0, end: 24.0, bottom: 24.0, ), - child: new Column( + child: Column( children: [ widget.steps[index].content, _buildVerticalControls(), @@ -517,10 +517,10 @@ class _StepperState extends State with TickerProviderStateMixin { for (int i = 0; i < widget.steps.length; i += 1) { children.add( - new Column( + Column( key: _keys[i], children: [ - new InkWell( + InkWell( onTap: widget.steps[i].state != StepState.disabled ? () { // In the vertical case we need to scroll to the newly tapped // step. @@ -541,7 +541,7 @@ class _StepperState extends State with TickerProviderStateMixin { ); } - return new ListView( + return ListView( shrinkWrap: true, children: children, ); @@ -552,20 +552,20 @@ class _StepperState extends State with TickerProviderStateMixin { for (int i = 0; i < widget.steps.length; i += 1) { children.add( - new InkResponse( + InkResponse( onTap: widget.steps[i].state != StepState.disabled ? () { if (widget.onStepTapped != null) widget.onStepTapped(i); } : null, - child: new Row( + child: Row( children: [ - new Container( + Container( height: 72.0, - child: new Center( + child: Center( child: _buildIcon(i), ), ), - new Container( + Container( margin: const EdgeInsetsDirectional.only(start: 12.0), child: _buildHeaderText(i), ), @@ -576,8 +576,8 @@ class _StepperState extends State with TickerProviderStateMixin { if (!_isLast(i)) { children.add( - new Expanded( - child: new Container( + Expanded( + child: Container( margin: const EdgeInsets.symmetric(horizontal: 8.0), height: 1.0, color: Colors.grey.shade400, @@ -587,22 +587,22 @@ class _StepperState extends State with TickerProviderStateMixin { } } - return new Column( + return Column( children: [ - new Material( + Material( elevation: 2.0, - child: new Container( + child: Container( margin: const EdgeInsets.symmetric(horizontal: 24.0), - child: new Row( + child: Row( children: children, ), ), ), - new Expanded( - child: new ListView( + Expanded( + child: ListView( padding: const EdgeInsets.all(24.0), children: [ - new AnimatedSize( + AnimatedSize( curve: Curves.fastOutSlowIn, duration: kThemeAnimationDuration, vsync: this, @@ -621,7 +621,7 @@ class _StepperState extends State with TickerProviderStateMixin { assert(debugCheckHasMaterial(context)); assert(() { if (context.ancestorWidgetOfExactType(Stepper) != null) - throw new FlutterError( + throw FlutterError( 'Steppers must not be nested. The material specification advises ' 'that one should avoid embedding steppers within steppers. ' 'https://material.google.com/components/steppers.html#steppers-usage\n' @@ -662,14 +662,14 @@ class _TrianglePainter extends CustomPainter { final double halfBase = size.width / 2.0; final double height = size.height; final List points = [ - new Offset(0.0, height), - new Offset(base, height), - new Offset(halfBase, 0.0), + Offset(0.0, height), + Offset(base, height), + Offset(halfBase, 0.0), ]; canvas.drawPath( - new Path()..addPolygon(points, true), - new Paint()..color = color, + Path()..addPolygon(points, true), + Paint()..color = color, ); } } diff --git a/packages/flutter/lib/src/material/switch.dart b/packages/flutter/lib/src/material/switch.dart index 78696f97f3..e3ee893019 100644 --- a/packages/flutter/lib/src/material/switch.dart +++ b/packages/flutter/lib/src/material/switch.dart @@ -132,13 +132,13 @@ class Switch extends StatefulWidget { final MaterialTapTargetSize materialTapTargetSize; @override - _SwitchState createState() => new _SwitchState(); + _SwitchState createState() => _SwitchState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('value', value: value, ifTrue: 'on', ifFalse: 'off', showName: true)); - properties.add(new ObjectFlagProperty>('onChanged', onChanged, ifNull: 'disabled')); + properties.add(FlagProperty('value', value: value, ifTrue: 'on', ifFalse: 'off', showName: true)); + properties.add(ObjectFlagProperty>('onChanged', onChanged, ifNull: 'disabled')); } } @@ -171,9 +171,9 @@ class _SwitchState extends State with TickerProviderStateMixin { size = const Size(_kSwitchWidth, _kSwitchHeightCollapsed); break; } - final BoxConstraints additionalConstraints = new BoxConstraints.tight(size); + final BoxConstraints additionalConstraints = BoxConstraints.tight(size); - return new _SwitchRenderObjectWidget( + return _SwitchRenderObjectWidget( value: widget.value, activeColor: activeThumbColor, inactiveColor: inactiveThumbColor, @@ -219,7 +219,7 @@ class _SwitchRenderObjectWidget extends LeafRenderObjectWidget { @override _RenderSwitch createRenderObject(BuildContext context) { - return new _RenderSwitch( + return _RenderSwitch( value: value, activeColor: activeColor, inactiveColor: inactiveColor, @@ -283,7 +283,7 @@ class _RenderSwitch extends RenderToggleable { additionalConstraints: additionalConstraints, vsync: vsync, ) { - _drag = new HorizontalDragGestureRecognizer() + _drag = HorizontalDragGestureRecognizer() ..onStart = _handleDragStart ..onUpdate = _handleDragUpdate ..onEnd = _handleDragEnd; @@ -401,9 +401,9 @@ class _RenderSwitch extends RenderToggleable { BoxPainter _cachedThumbPainter; BoxDecoration _createDefaultThumbDecoration(Color color, ImageProvider image) { - return new BoxDecoration( + return BoxDecoration( color: color, - image: image == null ? null : new DecorationImage(image: image), + image: image == null ? null : DecorationImage(image: image), shape: BoxShape.circle, boxShadow: kElevationToShadow[1] ); @@ -446,19 +446,19 @@ class _RenderSwitch extends RenderToggleable { final Color trackColor = isActive ? Color.lerp(inactiveTrackColor, activeTrackColor, currentValue) : inactiveTrackColor; // Paint the track - final Paint paint = new Paint() + final Paint paint = Paint() ..color = trackColor; const double trackHorizontalPadding = kRadialReactionRadius - _kTrackRadius; - final Rect trackRect = new Rect.fromLTWH( + final Rect trackRect = Rect.fromLTWH( offset.dx + trackHorizontalPadding, offset.dy + (size.height - _kTrackHeight) / 2.0, size.width - 2.0 * trackHorizontalPadding, _kTrackHeight ); - final RRect trackRRect = new RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius)); + final RRect trackRRect = RRect.fromRectAndRadius(trackRect, const Radius.circular(_kTrackRadius)); canvas.drawRRect(trackRRect, paint); - final Offset thumbPosition = new Offset( + final Offset thumbPosition = Offset( kRadialReactionRadius + visualPosition * _trackInnerLength, size.height / 2.0 ); @@ -482,8 +482,8 @@ class _RenderSwitch extends RenderToggleable { final double radius = _kThumbRadius - inset; thumbPainter.paint( canvas, - thumbPosition + offset - new Offset(radius, radius), - configuration.copyWith(size: new Size.fromRadius(radius)) + thumbPosition + offset - Offset(radius, radius), + configuration.copyWith(size: Size.fromRadius(radius)) ); } finally { _isPainting = false; diff --git a/packages/flutter/lib/src/material/switch_list_tile.dart b/packages/flutter/lib/src/material/switch_list_tile.dart index 67866aa9f5..08130a3082 100644 --- a/packages/flutter/lib/src/material/switch_list_tile.dart +++ b/packages/flutter/lib/src/material/switch_list_tile.dart @@ -166,7 +166,7 @@ class SwitchListTile extends StatelessWidget { @override Widget build(BuildContext context) { - final Widget control = new Switch( + final Widget control = Switch( value: value, onChanged: onChanged, activeColor: activeColor, @@ -174,10 +174,10 @@ class SwitchListTile extends StatelessWidget { inactiveThumbImage: inactiveThumbImage, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ); - return new MergeSemantics( + return MergeSemantics( child: ListTileTheme.merge( selectedColor: activeColor ?? Theme.of(context).accentColor, - child: new ListTile( + child: ListTile( leading: secondary, title: title, subtitle: subtitle, diff --git a/packages/flutter/lib/src/material/tab_controller.dart b/packages/flutter/lib/src/material/tab_controller.dart index 1fed41f3b2..c50b1b987c 100644 --- a/packages/flutter/lib/src/material/tab_controller.dart +++ b/packages/flutter/lib/src/material/tab_controller.dart @@ -82,7 +82,7 @@ class TabController extends ChangeNotifier { assert(initialIndex != null && initialIndex >= 0 && (length == 0 || initialIndex < length)), _index = initialIndex, _previousIndex = initialIndex, - _animationController = length < 2 ? null : new AnimationController( + _animationController = length < 2 ? null : AnimationController( value: initialIndex.toDouble(), upperBound: (length - 1).toDouble(), vsync: vsync @@ -282,7 +282,7 @@ class DefaultTabController extends StatefulWidget { } @override - _DefaultTabControllerState createState() => new _DefaultTabControllerState(); + _DefaultTabControllerState createState() => _DefaultTabControllerState(); } class _DefaultTabControllerState extends State with SingleTickerProviderStateMixin { @@ -291,7 +291,7 @@ class _DefaultTabControllerState extends State with Single @override void initState() { super.initState(); - _controller = new TabController( + _controller = TabController( vsync: this, length: widget.length, initialIndex: widget.initialIndex, @@ -306,7 +306,7 @@ class _DefaultTabControllerState extends State with Single @override Widget build(BuildContext context) { - return new _TabControllerScope( + return _TabControllerScope( controller: _controller, enabled: TickerMode.of(context), child: widget.child, diff --git a/packages/flutter/lib/src/material/tab_indicator.dart b/packages/flutter/lib/src/material/tab_indicator.dart index 5f38a3dc4d..51d1ee6de2 100644 --- a/packages/flutter/lib/src/material/tab_indicator.dart +++ b/packages/flutter/lib/src/material/tab_indicator.dart @@ -37,7 +37,7 @@ class UnderlineTabIndicator extends Decoration { @override Decoration lerpFrom(Decoration a, double t) { if (a is UnderlineTabIndicator) { - return new UnderlineTabIndicator( + return UnderlineTabIndicator( borderSide: BorderSide.lerp(a.borderSide, borderSide, t), insets: EdgeInsetsGeometry.lerp(a.insets, insets, t), ); @@ -48,7 +48,7 @@ class UnderlineTabIndicator extends Decoration { @override Decoration lerpTo(Decoration b, double t) { if (b is UnderlineTabIndicator) { - return new UnderlineTabIndicator( + return UnderlineTabIndicator( borderSide: BorderSide.lerp(borderSide, b.borderSide, t), insets: EdgeInsetsGeometry.lerp(insets, b.insets, t), ); @@ -58,7 +58,7 @@ class UnderlineTabIndicator extends Decoration { @override _UnderlinePainter createBoxPainter([VoidCallback onChanged]) { - return new _UnderlinePainter(this, onChanged); + return _UnderlinePainter(this, onChanged); } } @@ -75,7 +75,7 @@ class _UnderlinePainter extends BoxPainter { assert(rect != null); assert(textDirection != null); final Rect indicator = insets.resolve(textDirection).deflateRect(rect); - return new Rect.fromLTWH( + return Rect.fromLTWH( indicator.left, indicator.bottom - borderSide.width, indicator.width, diff --git a/packages/flutter/lib/src/material/tabs.dart b/packages/flutter/lib/src/material/tabs.dart index 648aea923e..49b33d9086 100644 --- a/packages/flutter/lib/src/material/tabs.dart +++ b/packages/flutter/lib/src/material/tabs.dart @@ -80,7 +80,7 @@ class Tab extends StatelessWidget { final Widget icon; Widget _buildLabelText() { - return child ?? new Text(text, softWrap: false, overflow: TextOverflow.fade); + return child ?? Text(text, softWrap: false, overflow: TextOverflow.fade); } @override @@ -97,11 +97,11 @@ class Tab extends StatelessWidget { label = icon; } else { height = _kTextAndIconTabHeight; - label = new Column( + label = Column( mainAxisAlignment: MainAxisAlignment.center, crossAxisAlignment: CrossAxisAlignment.center, children: [ - new Container( + Container( child: icon, margin: const EdgeInsets.only(bottom: 10.0), ), @@ -110,9 +110,9 @@ class Tab extends StatelessWidget { ); } - return new SizedBox( + return SizedBox( height: height, - child: new Center( + child: Center( child: label, widthFactor: 1.0, ), @@ -122,8 +122,8 @@ class Tab extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('text', text, defaultValue: null)); - properties.add(new DiagnosticsProperty('icon', icon, defaultValue: null)); + properties.add(StringProperty('text', text, defaultValue: null)); + properties.add(DiagnosticsProperty('icon', icon, defaultValue: null)); } } @@ -161,10 +161,10 @@ class _TabStyle extends AnimatedWidget { ? Color.lerp(selectedColor, unselectedColor, animation.value) : Color.lerp(unselectedColor, selectedColor, animation.value); - return new DefaultTextStyle( + return DefaultTextStyle( style: textStyle.copyWith(color: color), child: IconTheme.merge( - data: new IconThemeData( + data: IconThemeData( size: 24.0, color: color, ), @@ -250,7 +250,7 @@ class _TabLabelBar extends Flex { @override RenderFlex createRenderObject(BuildContext context) { - return new _TabLabelBarRenderer( + return _TabLabelBarRenderer( direction: direction, mainAxisAlignment: mainAxisAlignment, mainAxisSize: mainAxisSize, @@ -356,7 +356,7 @@ class _IndicatorPainter extends CustomPainter { tabRight -= delta; } - return new Rect.fromLTWH(tabLeft, 0.0, tabRight - tabLeft, tabBarSize.height); + return Rect.fromLTWH(tabLeft, 0.0, tabRight - tabLeft, tabBarSize.height); } @override @@ -389,7 +389,7 @@ class _IndicatorPainter extends CustomPainter { } assert(_currentRect != null); - final ImageConfiguration configuration = new ImageConfiguration( + final ImageConfiguration configuration = ImageConfiguration( size: _currentRect.size, textDirection: _currentTextDirection, ); @@ -484,7 +484,7 @@ class _TabBarScrollController extends ScrollController { @override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { - return new _TabBarScrollPosition( + return _TabBarScrollPosition( physics: physics, context: context, oldPosition: oldPosition, @@ -652,14 +652,14 @@ class TabBar extends StatefulWidget implements PreferredSizeWidget { if (item is Tab) { final Tab tab = item; if (tab.text != null && tab.icon != null) - return new Size.fromHeight(_kTextAndIconTabHeight + indicatorWeight); + return Size.fromHeight(_kTextAndIconTabHeight + indicatorWeight); } } - return new Size.fromHeight(_kTabHeight + indicatorWeight); + return Size.fromHeight(_kTabHeight + indicatorWeight); } @override - _TabBarState createState() => new _TabBarState(); + _TabBarState createState() => _TabBarState(); } class _TabBarState extends State { @@ -675,7 +675,7 @@ class _TabBarState extends State { super.initState(); // If indicatorSize is TabIndicatorSize.label, _tabKeys[i] is used to find // the width of tab widget i. See _IndicatorPainter.indicatorRect(). - _tabKeys = widget.tabs.map((Widget tab) => new GlobalKey()).toList(); + _tabKeys = widget.tabs.map((Widget tab) => GlobalKey()).toList(); } Decoration get _indicator { @@ -693,9 +693,9 @@ class _TabBarState extends State { if (color.value == Material.of(context).color.value) color = Colors.white; - return new UnderlineTabIndicator( + return UnderlineTabIndicator( insets: widget.indicatorPadding, - borderSide: new BorderSide( + borderSide: BorderSide( width: widget.indicatorWeight, color: color, ), @@ -706,7 +706,7 @@ class _TabBarState extends State { final TabController newController = widget.controller ?? DefaultTabController.of(context); assert(() { if (newController == null) { - throw new FlutterError( + throw FlutterError( 'No TabController for ${widget.runtimeType}.\n' 'When creating a ${widget.runtimeType}, you must either provide an explicit ' 'TabController using the "controller" property, or you must ensure that there ' @@ -732,7 +732,7 @@ class _TabBarState extends State { } void _initIndicatorPainter() { - _indicatorPainter = _controller == null ? null : new _IndicatorPainter( + _indicatorPainter = _controller == null ? null : _IndicatorPainter( controller: _controller, indicator: _indicator, indicatorSize: widget.indicatorSize, @@ -764,7 +764,7 @@ class _TabBarState extends State { if (widget.tabs.length > oldWidget.tabs.length) { final int delta = widget.tabs.length - oldWidget.tabs.length; - _tabKeys.addAll(new List.generate(delta, (int n) => new GlobalKey())); + _tabKeys.addAll(List.generate(delta, (int n) => GlobalKey())); } else if (widget.tabs.length < oldWidget.tabs.length) { _tabKeys.removeRange(widget.tabs.length, oldWidget.tabs.length); } @@ -866,7 +866,7 @@ class _TabBarState extends State { } Widget _buildStyledTab(Widget child, bool selected, Animation animation) { - return new _TabStyle( + return _TabStyle( animation: animation, selected: selected, labelColor: widget.labelColor, @@ -881,18 +881,18 @@ class _TabBarState extends State { Widget build(BuildContext context) { final MaterialLocalizations localizations = MaterialLocalizations.of(context); if (_controller.length == 0) { - return new Container( + return Container( height: _kTabHeight + widget.indicatorWeight, ); } - final List wrappedTabs = new List(widget.tabs.length); + final List wrappedTabs = List(widget.tabs.length); for (int i = 0; i < widget.tabs.length; i += 1) { - wrappedTabs[i] = new Center( + wrappedTabs[i] = Center( heightFactor: 1.0, - child: new Padding( + child: Padding( padding: kTabLabelPadding, - child: new KeyedSubtree( + child: KeyedSubtree( key: _tabKeys[i], child: widget.tabs[i], ), @@ -910,22 +910,22 @@ class _TabBarState extends State { if (_controller.indexIsChanging) { // The user tapped on a tab, the tab controller's animation is running. assert(_currentIndex != previousIndex); - final Animation animation = new _ChangeAnimation(_controller); + final Animation animation = _ChangeAnimation(_controller); wrappedTabs[_currentIndex] = _buildStyledTab(wrappedTabs[_currentIndex], true, animation); wrappedTabs[previousIndex] = _buildStyledTab(wrappedTabs[previousIndex], false, animation); } else { // The user is dragging the TabBarView's PageView left or right. final int tabIndex = _currentIndex; - final Animation centerAnimation = new _DragAnimation(_controller, tabIndex); + final Animation centerAnimation = _DragAnimation(_controller, tabIndex); wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], true, centerAnimation); if (_currentIndex > 0) { final int tabIndex = _currentIndex - 1; - final Animation previousAnimation = new ReverseAnimation(new _DragAnimation(_controller, tabIndex)); + final Animation previousAnimation = ReverseAnimation(_DragAnimation(_controller, tabIndex)); wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, previousAnimation); } if (_currentIndex < widget.tabs.length - 1) { final int tabIndex = _currentIndex + 1; - final Animation nextAnimation = new ReverseAnimation(new _DragAnimation(_controller, tabIndex)); + final Animation nextAnimation = ReverseAnimation(_DragAnimation(_controller, tabIndex)); wrappedTabs[tabIndex] = _buildStyledTab(wrappedTabs[tabIndex], false, nextAnimation); } } @@ -936,14 +936,14 @@ class _TabBarState extends State { // the same share of the tab bar's overall width. final int tabCount = widget.tabs.length; for (int index = 0; index < tabCount; index += 1) { - wrappedTabs[index] = new InkWell( + wrappedTabs[index] = InkWell( onTap: () { _handleTap(index); }, - child: new Padding( - padding: new EdgeInsets.only(bottom: widget.indicatorWeight), - child: new Stack( + child: Padding( + padding: EdgeInsets.only(bottom: widget.indicatorWeight), + child: Stack( children: [ wrappedTabs[index], - new Semantics( + Semantics( selected: index == _currentIndex, label: localizations.tabLabel(tabIndex: index + 1, tabCount: tabCount), ), @@ -952,19 +952,19 @@ class _TabBarState extends State { ), ); if (!widget.isScrollable) - wrappedTabs[index] = new Expanded(child: wrappedTabs[index]); + wrappedTabs[index] = Expanded(child: wrappedTabs[index]); } - Widget tabBar = new CustomPaint( + Widget tabBar = CustomPaint( painter: _indicatorPainter, - child: new _TabStyle( + child: _TabStyle( animation: kAlwaysDismissedAnimation, selected: false, labelColor: widget.labelColor, unselectedLabelColor: widget.unselectedLabelColor, labelStyle: widget.labelStyle, unselectedLabelStyle: widget.unselectedLabelStyle, - child: new _TabLabelBar( + child: _TabLabelBar( onPerformLayout: _saveTabOffsets, children: wrappedTabs, ), @@ -972,8 +972,8 @@ class _TabBarState extends State { ); if (widget.isScrollable) { - _scrollController ??= new _TabBarScrollController(this); - tabBar = new SingleChildScrollView( + _scrollController ??= _TabBarScrollController(this); + tabBar = SingleChildScrollView( scrollDirection: Axis.horizontal, controller: _scrollController, child: tabBar, @@ -1021,7 +1021,7 @@ class TabBarView extends StatefulWidget { final ScrollPhysics physics; @override - _TabBarViewState createState() => new _TabBarViewState(); + _TabBarViewState createState() => _TabBarViewState(); } final PageScrollPhysics _kTabBarViewPhysics = const PageScrollPhysics().applyTo(const ClampingScrollPhysics()); @@ -1037,7 +1037,7 @@ class _TabBarViewState extends State { final TabController newController = widget.controller ?? DefaultTabController.of(context); assert(() { if (newController == null) { - throw new FlutterError( + throw FlutterError( 'No TabController for ${widget.runtimeType}.\n' 'When creating a ${widget.runtimeType}, you must either provide an explicit ' 'TabController using the "controller" property, or you must ensure that there ' @@ -1068,7 +1068,7 @@ class _TabBarViewState extends State { super.didChangeDependencies(); _updateTabController(); _currentIndex = _controller?.index; - _pageController = new PageController(initialPage: _currentIndex ?? 0); + _pageController = PageController(initialPage: _currentIndex ?? 0); } @override @@ -1100,10 +1100,10 @@ class _TabBarViewState extends State { Future _warpToCurrentIndex() async { if (!mounted) - return new Future.value(); + return Future.value(); if (_pageController.page == _currentIndex.toDouble()) - return new Future.value(); + return Future.value(); final int previousIndex = _controller.previousIndex; if ((_currentIndex - previousIndex).abs() == 1) @@ -1113,7 +1113,7 @@ class _TabBarViewState extends State { int initialPage; setState(() { _warpUnderwayCount += 1; - _children = new List.from(widget.children, growable: false); + _children = List.from(widget.children, growable: false); if (_currentIndex > previousIndex) { _children[_currentIndex - 1] = _children[previousIndex]; initialPage = _currentIndex - 1; @@ -1127,7 +1127,7 @@ class _TabBarViewState extends State { await _pageController.animateToPage(_currentIndex, duration: kTabScrollDuration, curve: Curves.ease); if (!mounted) - return new Future.value(); + return Future.value(); setState(() { _warpUnderwayCount -= 1; @@ -1161,9 +1161,9 @@ class _TabBarViewState extends State { @override Widget build(BuildContext context) { - return new NotificationListener( + return NotificationListener( onNotification: _handleScrollNotification, - child: new PageView( + child: PageView( controller: _pageController, physics: widget.physics == null ? _kTabBarViewPhysics : _kTabBarViewPhysics.applyTo(widget.physics), children: _children, @@ -1197,13 +1197,13 @@ class TabPageSelectorIndicator extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( width: size, height: size, margin: const EdgeInsets.all(4.0), - decoration: new BoxDecoration( + decoration: BoxDecoration( color: backgroundColor, - border: new Border.all(color: borderColor), + border: Border.all(color: borderColor), shape: BoxShape.circle, ), ); @@ -1276,7 +1276,7 @@ class TabPageSelector extends StatelessWidget { background = selectedColorTween.begin; } } - return new TabPageSelectorIndicator( + return TabPageSelectorIndicator( backgroundColor: background, borderColor: selectedColorTween.end, size: indicatorSize, @@ -1287,12 +1287,12 @@ class TabPageSelector extends StatelessWidget { Widget build(BuildContext context) { final Color fixColor = color ?? Colors.transparent; final Color fixSelectedColor = selectedColor ?? Theme.of(context).accentColor; - final ColorTween selectedColorTween = new ColorTween(begin: fixColor, end: fixSelectedColor); - final ColorTween previousColorTween = new ColorTween(begin: fixSelectedColor, end: fixColor); + final ColorTween selectedColorTween = ColorTween(begin: fixColor, end: fixSelectedColor); + final ColorTween previousColorTween = ColorTween(begin: fixSelectedColor, end: fixColor); final TabController tabController = controller ?? DefaultTabController.of(context); assert(() { if (tabController == null) { - throw new FlutterError( + throw FlutterError( 'No TabController for $runtimeType.\n' 'When creating a $runtimeType, you must either provide an explicit TabController ' 'using the "controller" property, or you must ensure that there is a ' @@ -1302,18 +1302,18 @@ class TabPageSelector extends StatelessWidget { } return true; }()); - final Animation animation = new CurvedAnimation( + final Animation animation = CurvedAnimation( parent: tabController.animation, curve: Curves.fastOutSlowIn, ); - return new AnimatedBuilder( + return AnimatedBuilder( animation: animation, builder: (BuildContext context, Widget child) { - return new Semantics( + return Semantics( label: 'Page ${tabController.index + 1} of ${tabController.length}', - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, - children: new List.generate(tabController.length, (int tabIndex) { + children: List.generate(tabController.length, (int tabIndex) { return _buildTabIndicator(tabIndex, tabController, selectedColorTween, previousColorTween); }).toList(), ), diff --git a/packages/flutter/lib/src/material/text_field.dart b/packages/flutter/lib/src/material/text_field.dart index 3d4f900d13..5206d011c9 100644 --- a/packages/flutter/lib/src/material/text_field.dart +++ b/packages/flutter/lib/src/material/text_field.dart @@ -344,27 +344,27 @@ class TextField extends StatefulWidget { final EdgeInsets scrollPadding; @override - _TextFieldState createState() => new _TextFieldState(); + _TextFieldState createState() => _TextFieldState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('controller', controller, defaultValue: null)); - properties.add(new DiagnosticsProperty('focusNode', focusNode, defaultValue: null)); - properties.add(new DiagnosticsProperty('decoration', decoration)); - properties.add(new DiagnosticsProperty('keyboardType', keyboardType, defaultValue: TextInputType.text)); - properties.add(new DiagnosticsProperty('style', style, defaultValue: null)); - properties.add(new DiagnosticsProperty('autofocus', autofocus, defaultValue: false)); - properties.add(new DiagnosticsProperty('obscureText', obscureText, defaultValue: false)); - properties.add(new DiagnosticsProperty('autocorrect', autocorrect, defaultValue: false)); - properties.add(new IntProperty('maxLines', maxLines, defaultValue: 1)); - properties.add(new IntProperty('maxLength', maxLength, defaultValue: null)); - properties.add(new FlagProperty('maxLengthEnforced', value: maxLengthEnforced, ifTrue: 'max length enforced')); + properties.add(DiagnosticsProperty('controller', controller, defaultValue: null)); + properties.add(DiagnosticsProperty('focusNode', focusNode, defaultValue: null)); + properties.add(DiagnosticsProperty('decoration', decoration)); + properties.add(DiagnosticsProperty('keyboardType', keyboardType, defaultValue: TextInputType.text)); + properties.add(DiagnosticsProperty('style', style, defaultValue: null)); + properties.add(DiagnosticsProperty('autofocus', autofocus, defaultValue: false)); + properties.add(DiagnosticsProperty('obscureText', obscureText, defaultValue: false)); + properties.add(DiagnosticsProperty('autocorrect', autocorrect, defaultValue: false)); + properties.add(IntProperty('maxLines', maxLines, defaultValue: 1)); + properties.add(IntProperty('maxLength', maxLength, defaultValue: null)); + properties.add(FlagProperty('maxLengthEnforced', value: maxLengthEnforced, ifTrue: 'max length enforced')); } } class _TextFieldState extends State with AutomaticKeepAliveClientMixin { - final GlobalKey _editableTextKey = new GlobalKey(); + final GlobalKey _editableTextKey = GlobalKey(); Set _splashes; InteractiveInkFeature _currentSplash; @@ -373,7 +373,7 @@ class _TextFieldState extends State with AutomaticKeepAliveClientMixi TextEditingController get _effectiveController => widget.controller ?? _controller; FocusNode _focusNode; - FocusNode get _effectiveFocusNode => widget.focusNode ?? (_focusNode ??= new FocusNode()); + FocusNode get _effectiveFocusNode => widget.focusNode ?? (_focusNode ??= FocusNode()); bool get needsCounter => widget.maxLength != null && widget.decoration != null @@ -414,14 +414,14 @@ class _TextFieldState extends State with AutomaticKeepAliveClientMixi void initState() { super.initState(); if (widget.controller == null) - _controller = new TextEditingController(); + _controller = TextEditingController(); } @override void didUpdateWidget(TextField oldWidget) { super.didUpdateWidget(oldWidget); if (widget.controller == null && oldWidget.controller != null) - _controller = new TextEditingController.fromValue(oldWidget.controller.value); + _controller = TextEditingController.fromValue(oldWidget.controller.value); else if (widget.controller != null && oldWidget.controller == null) _controller = null; final bool isEnabled = widget.enabled ?? widget.decoration?.enabled ?? true; @@ -505,7 +505,7 @@ class _TextFieldState extends State with AutomaticKeepAliveClientMixi if (_effectiveFocusNode.hasFocus) return; final InteractiveInkFeature splash = _createInkFeature(details); - _splashes ??= new HashSet(); + _splashes ??= HashSet(); _splashes.add(splash); _currentSplash = splash; updateKeepAlive(); @@ -548,10 +548,10 @@ class _TextFieldState extends State with AutomaticKeepAliveClientMixi final FocusNode focusNode = _effectiveFocusNode; final List formatters = widget.inputFormatters ?? []; if (widget.maxLength != null && widget.maxLengthEnforced) - formatters.add(new LengthLimitingTextInputFormatter(widget.maxLength)); + formatters.add(LengthLimitingTextInputFormatter(widget.maxLength)); - Widget child = new RepaintBoundary( - child: new EditableText( + Widget child = RepaintBoundary( + child: EditableText( key: _editableTextKey, controller: controller, focusNode: focusNode, @@ -583,10 +583,10 @@ class _TextFieldState extends State with AutomaticKeepAliveClientMixi ); if (widget.decoration != null) { - child = new AnimatedBuilder( - animation: new Listenable.merge([ focusNode, controller ]), + child = AnimatedBuilder( + animation: Listenable.merge([ focusNode, controller ]), builder: (BuildContext context, Widget child) { - return new InputDecorator( + return InputDecorator( decoration: _getEffectiveDecoration(), baseStyle: widget.style, textAlign: widget.textAlign, @@ -599,15 +599,15 @@ class _TextFieldState extends State with AutomaticKeepAliveClientMixi ); } - return new Semantics( + return Semantics( onTap: () { if (!_effectiveController.selection.isValid) - _effectiveController.selection = new TextSelection.collapsed(offset: _effectiveController.text.length); + _effectiveController.selection = TextSelection.collapsed(offset: _effectiveController.text.length); _requestKeyboard(); }, - child: new IgnorePointer( + child: IgnorePointer( ignoring: !(widget.enabled ?? widget.decoration?.enabled ?? true), - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.translucent, onTapDown: _handleTapDown, onTap: _handleTap, diff --git a/packages/flutter/lib/src/material/text_form_field.dart b/packages/flutter/lib/src/material/text_form_field.dart index 50c04d70ca..df4d79fff9 100644 --- a/packages/flutter/lib/src/material/text_form_field.dart +++ b/packages/flutter/lib/src/material/text_form_field.dart @@ -94,7 +94,7 @@ class TextFormField extends FormField { final _TextFormFieldState state = field; final InputDecoration effectiveDecoration = (decoration ?? const InputDecoration()) .applyDefaults(Theme.of(field.context).inputDecorationTheme); - return new TextField( + return TextField( controller: state._effectiveController, focusNode: focusNode, decoration: effectiveDecoration.copyWith(errorText: field.errorText), @@ -127,7 +127,7 @@ class TextFormField extends FormField { final TextEditingController controller; @override - _TextFormFieldState createState() => new _TextFormFieldState(); + _TextFormFieldState createState() => _TextFormFieldState(); } class _TextFormFieldState extends FormFieldState { @@ -142,7 +142,7 @@ class _TextFormFieldState extends FormFieldState { void initState() { super.initState(); if (widget.controller == null) { - _controller = new TextEditingController(text: widget.initialValue); + _controller = TextEditingController(text: widget.initialValue); } else { widget.controller.addListener(_handleControllerChanged); } @@ -156,7 +156,7 @@ class _TextFormFieldState extends FormFieldState { widget.controller?.addListener(_handleControllerChanged); if (oldWidget.controller != null && widget.controller == null) - _controller = new TextEditingController.fromValue(oldWidget.controller.value); + _controller = TextEditingController.fromValue(oldWidget.controller.value); if (widget.controller != null) { setValue(widget.controller.text); if (oldWidget.controller == null) diff --git a/packages/flutter/lib/src/material/text_selection.dart b/packages/flutter/lib/src/material/text_selection.dart index 87761fd138..b4b62bdcf0 100644 --- a/packages/flutter/lib/src/material/text_selection.dart +++ b/packages/flutter/lib/src/material/text_selection.dart @@ -38,19 +38,19 @@ class _TextSelectionToolbar extends StatelessWidget { final MaterialLocalizations localizations = MaterialLocalizations.of(context); if (handleCut != null) - items.add(new FlatButton(child: new Text(localizations.cutButtonLabel), onPressed: handleCut)); + items.add(FlatButton(child: Text(localizations.cutButtonLabel), onPressed: handleCut)); if (handleCopy != null) - items.add(new FlatButton(child: new Text(localizations.copyButtonLabel), onPressed: handleCopy)); + items.add(FlatButton(child: Text(localizations.copyButtonLabel), onPressed: handleCopy)); if (handlePaste != null) - items.add(new FlatButton(child: new Text(localizations.pasteButtonLabel), onPressed: handlePaste,)); + items.add(FlatButton(child: Text(localizations.pasteButtonLabel), onPressed: handlePaste,)); if (handleSelectAll != null) - items.add(new FlatButton(child: new Text(localizations.selectAllButtonLabel), onPressed: handleSelectAll)); + items.add(FlatButton(child: Text(localizations.selectAllButtonLabel), onPressed: handleSelectAll)); - return new Material( + return Material( elevation: 1.0, - child: new Container( + child: Container( height: 44.0, - child: new Row(mainAxisSize: MainAxisSize.min, children: items) + child: Row(mainAxisSize: MainAxisSize.min, children: items) ) ); } @@ -94,7 +94,7 @@ class _TextSelectionToolbarLayout extends SingleChildLayoutDelegate { else if (y + childSize.height > screenSize.height - _kToolbarScreenPadding) y = screenSize.height - childSize.height - _kToolbarScreenPadding; - return new Offset(x, y); + return Offset(x, y); } @override @@ -112,10 +112,10 @@ class _TextSelectionHandlePainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint()..color = color; + final Paint paint = Paint()..color = color; final double radius = size.width/2.0; - canvas.drawCircle(new Offset(radius, radius), radius, paint); - canvas.drawRect(new Rect.fromLTWH(0.0, 0.0, radius, radius), paint); + canvas.drawCircle(Offset(radius, radius), radius, paint); + canvas.drawRect(Rect.fromLTWH(0.0, 0.0, radius, radius), paint); } @override @@ -132,15 +132,15 @@ class _MaterialTextSelectionControls extends TextSelectionControls { @override Widget buildToolbar(BuildContext context, Rect globalEditableRegion, Offset position, TextSelectionDelegate delegate) { assert(debugCheckHasMediaQuery(context)); - return new ConstrainedBox( - constraints: new BoxConstraints.tight(globalEditableRegion.size), - child: new CustomSingleChildLayout( - delegate: new _TextSelectionToolbarLayout( + return ConstrainedBox( + constraints: BoxConstraints.tight(globalEditableRegion.size), + child: CustomSingleChildLayout( + delegate: _TextSelectionToolbarLayout( MediaQuery.of(context).size, globalEditableRegion, position, ), - child: new _TextSelectionToolbar( + child: _TextSelectionToolbar( handleCut: canCut(delegate) ? () => handleCut(delegate) : null, handleCopy: canCopy(delegate) ? () => handleCopy(delegate) : null, handlePaste: canPaste(delegate) ? () => handlePaste(delegate) : null, @@ -153,13 +153,13 @@ class _MaterialTextSelectionControls extends TextSelectionControls { /// Builder for material-style text selection handles. @override Widget buildHandle(BuildContext context, TextSelectionHandleType type, double textHeight) { - final Widget handle = new Padding( + final Widget handle = Padding( padding: const EdgeInsets.only(right: 26.0, bottom: 26.0), - child: new SizedBox( + child: SizedBox( width: _kHandleSize, height: _kHandleSize, - child: new CustomPaint( - painter: new _TextSelectionHandlePainter( + child: CustomPaint( + painter: _TextSelectionHandlePainter( color: Theme.of(context).textSelectionHandleColor ), ), @@ -171,15 +171,15 @@ class _MaterialTextSelectionControls extends TextSelectionControls { // straight up or up-right depending on the handle type. switch (type) { case TextSelectionHandleType.left: // points up-right - return new Transform( - transform: new Matrix4.rotationZ(math.pi / 2.0), + return Transform( + transform: Matrix4.rotationZ(math.pi / 2.0), child: handle ); case TextSelectionHandleType.right: // points up-left return handle; case TextSelectionHandleType.collapsed: // points up - return new Transform( - transform: new Matrix4.rotationZ(math.pi / 4.0), + return Transform( + transform: Matrix4.rotationZ(math.pi / 4.0), child: handle ); } @@ -189,4 +189,4 @@ class _MaterialTextSelectionControls extends TextSelectionControls { } /// Text selection controls that follow the Material Design specification. -final TextSelectionControls materialTextSelectionControls = new _MaterialTextSelectionControls(); +final TextSelectionControls materialTextSelectionControls = _MaterialTextSelectionControls(); diff --git a/packages/flutter/lib/src/material/theme.dart b/packages/flutter/lib/src/material/theme.dart index 6cbe6149c0..081e5e9ed2 100644 --- a/packages/flutter/lib/src/material/theme.dart +++ b/packages/flutter/lib/src/material/theme.dart @@ -64,7 +64,7 @@ class Theme extends StatelessWidget { /// {@macro flutter.widgets.child} final Widget child; - static final ThemeData _kFallbackTheme = new ThemeData.fallback(); + static final ThemeData _kFallbackTheme = ThemeData.fallback(); /// The data from the closest [Theme] instance that encloses the given /// context. @@ -140,9 +140,9 @@ class Theme extends StatelessWidget { @override Widget build(BuildContext context) { - return new _InheritedTheme( + return _InheritedTheme( theme: this, - child: new IconTheme( + child: IconTheme( data: data.iconTheme, child: child, ), @@ -152,7 +152,7 @@ class Theme extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('data', data, showName: false)); + properties.add(DiagnosticsProperty('data', data, showName: false)); } } @@ -230,7 +230,7 @@ class AnimatedTheme extends ImplicitlyAnimatedWidget { final Widget child; @override - _AnimatedThemeState createState() => new _AnimatedThemeState(); + _AnimatedThemeState createState() => _AnimatedThemeState(); } class _AnimatedThemeState extends AnimatedWidgetBaseState { @@ -239,13 +239,13 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { // TODO(ianh): Use constructor tear-offs when it becomes possible - _data = visitor(_data, widget.data, (dynamic value) => new ThemeDataTween(begin: value)); + _data = visitor(_data, widget.data, (dynamic value) => ThemeDataTween(begin: value)); assert(_data != null); } @override Widget build(BuildContext context) { - return new Theme( + return Theme( isMaterialAppTheme: widget.isMaterialAppTheme, child: widget.child, data: _data.evaluate(animation) @@ -255,6 +255,6 @@ class _AnimatedThemeState extends AnimatedWidgetBaseState { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('data', _data, showName: false, defaultValue: null)); + description.add(DiagnosticsProperty('data', _data, showName: false, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/material/theme_data.dart b/packages/flutter/lib/src/material/theme_data.dart index 301d927c8d..3949d8dca1 100644 --- a/packages/flutter/lib/src/material/theme_data.dart +++ b/packages/flutter/lib/src/material/theme_data.dart @@ -186,7 +186,7 @@ class ThemeData extends Diagnosticable { accentIconTheme ??= accentIsDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black); iconTheme ??= isDark ? const IconThemeData(color: Colors.white) : const IconThemeData(color: Colors.black87); platform ??= defaultTargetPlatform; - final Typography typography = new Typography(platform: platform); + final Typography typography = Typography(platform: platform); final TextTheme defaultTextTheme = isDark ? typography.white : typography.black; textTheme = defaultTextTheme.merge(textTheme); final TextTheme defaultPrimaryTextTheme = primaryIsDark ? typography.white : typography.black; @@ -198,18 +198,18 @@ class ThemeData extends Diagnosticable { primaryTextTheme = primaryTextTheme.apply(fontFamily: fontFamily); accentTextTheme = accentTextTheme.apply(fontFamily: fontFamily); } - sliderTheme ??= new SliderThemeData.fromPrimaryColors( + sliderTheme ??= SliderThemeData.fromPrimaryColors( primaryColor: primaryColor, primaryColorLight: primaryColorLight, primaryColorDark: primaryColorDark, valueIndicatorTextStyle: accentTextTheme.body2, ); - chipTheme ??= new ChipThemeData.fromDefaults( + chipTheme ??= ChipThemeData.fromDefaults( secondaryColor: primaryColor, brightness: brightness, labelStyle: textTheme.body2, ); - return new ThemeData.raw( + return ThemeData.raw( brightness: brightness, primaryColor: primaryColor, primaryColorBrightness: primaryColorBrightness, @@ -347,13 +347,13 @@ class ThemeData extends Diagnosticable { /// /// This theme does not contain text geometry. Instead, it is expected that /// this theme is localized using text geometry using [ThemeData.localize]. - factory ThemeData.light() => new ThemeData(brightness: Brightness.light); + factory ThemeData.light() => ThemeData(brightness: Brightness.light); /// A default dark theme with a teal accent color. /// /// This theme does not contain text geometry. Instead, it is expected that /// this theme is localized using text geometry using [ThemeData.localize]. - factory ThemeData.dark() => new ThemeData(brightness: Brightness.dark); + factory ThemeData.dark() => ThemeData(brightness: Brightness.dark); /// The default color theme. Same as [new ThemeData.light]. /// @@ -364,7 +364,7 @@ class ThemeData extends Diagnosticable { /// /// Most applications would use [Theme.of], which provides correct localized /// text geometry. - factory ThemeData.fallback() => new ThemeData.light(); + factory ThemeData.fallback() => ThemeData.light(); /// The brightness of the overall theme of the application. Used by widgets /// like buttons to determine what color to pick when not using the primary or @@ -580,7 +580,7 @@ class ThemeData extends Diagnosticable { TargetPlatform platform, MaterialTapTargetSize materialTapTargetSize, }) { - return new ThemeData.raw( + return ThemeData.raw( brightness: brightness ?? this.brightness, primaryColor: primaryColor ?? this.primaryColor, primaryColorBrightness: primaryColorBrightness ?? this.primaryColorBrightness, @@ -633,7 +633,7 @@ class ThemeData extends Diagnosticable { /// Caches localized themes to speed up the [localize] method. static final _FifoCache<_IdentityThemeDataCacheKey, ThemeData> _localizedThemeDataCache = - new _FifoCache<_IdentityThemeDataCacheKey, ThemeData>(_localizedThemeDataCacheSize); + _FifoCache<_IdentityThemeDataCacheKey, ThemeData>(_localizedThemeDataCacheSize); /// Returns a new theme built by merging the text geometry provided by the /// [localTextGeometry] theme with the [baseTheme]. @@ -659,7 +659,7 @@ class ThemeData extends Diagnosticable { assert(localTextGeometry != null); return _localizedThemeDataCache.putIfAbsent( - new _IdentityThemeDataCacheKey(baseTheme, localTextGeometry), + _IdentityThemeDataCacheKey(baseTheme, localTextGeometry), () { return baseTheme.copyWith( primaryTextTheme: localTextGeometry.merge(baseTheme.primaryTextTheme), @@ -709,7 +709,7 @@ class ThemeData extends Diagnosticable { assert(a != null); assert(b != null); assert(t != null); - return new ThemeData.raw( + return ThemeData.raw( brightness: t < 0.5 ? a.brightness : b.brightness, primaryColor: Color.lerp(a.primaryColor, b.primaryColor, t), primaryColorBrightness: t < 0.5 ? a.primaryColorBrightness : b.primaryColorBrightness, @@ -850,45 +850,45 @@ class ThemeData extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - final ThemeData defaultData = new ThemeData.fallback(); - properties.add(new EnumProperty('platform', platform, defaultValue: defaultTargetPlatform)); - properties.add(new EnumProperty('brightness', brightness, defaultValue: defaultData.brightness)); - properties.add(new DiagnosticsProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor)); - properties.add(new EnumProperty('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness)); - properties.add(new DiagnosticsProperty('accentColor', accentColor, defaultValue: defaultData.accentColor)); - properties.add(new EnumProperty('accentColorBrightness', accentColorBrightness, defaultValue: defaultData.accentColorBrightness)); - properties.add(new DiagnosticsProperty('canvasColor', canvasColor, defaultValue: defaultData.canvasColor)); - properties.add(new DiagnosticsProperty('scaffoldBackgroundColor', scaffoldBackgroundColor, defaultValue: defaultData.scaffoldBackgroundColor)); - properties.add(new DiagnosticsProperty('bottomAppBarColor', bottomAppBarColor, defaultValue: defaultData.bottomAppBarColor)); - properties.add(new DiagnosticsProperty('cardColor', cardColor, defaultValue: defaultData.cardColor)); - properties.add(new DiagnosticsProperty('dividerColor', dividerColor, defaultValue: defaultData.dividerColor)); - properties.add(new DiagnosticsProperty('highlightColor', highlightColor, defaultValue: defaultData.highlightColor)); - properties.add(new DiagnosticsProperty('splashColor', splashColor, defaultValue: defaultData.splashColor)); - properties.add(new DiagnosticsProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor)); - properties.add(new DiagnosticsProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor)); - properties.add(new DiagnosticsProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor)); - properties.add(new DiagnosticsProperty('buttonColor', buttonColor, defaultValue: defaultData.buttonColor)); - properties.add(new DiagnosticsProperty('secondaryHeaderColor', secondaryHeaderColor, defaultValue: defaultData.secondaryHeaderColor)); - properties.add(new DiagnosticsProperty('textSelectionColor', textSelectionColor, defaultValue: defaultData.textSelectionColor)); - properties.add(new DiagnosticsProperty('cursorColor', cursorColor, defaultValue: defaultData.cursorColor)); - properties.add(new DiagnosticsProperty('textSelectionHandleColor', textSelectionHandleColor, defaultValue: defaultData.textSelectionHandleColor)); - properties.add(new DiagnosticsProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor)); - properties.add(new DiagnosticsProperty('dialogBackgroundColor', dialogBackgroundColor, defaultValue: defaultData.dialogBackgroundColor)); - properties.add(new DiagnosticsProperty('indicatorColor', indicatorColor, defaultValue: defaultData.indicatorColor)); - properties.add(new DiagnosticsProperty('hintColor', hintColor, defaultValue: defaultData.hintColor)); - properties.add(new DiagnosticsProperty('errorColor', errorColor, defaultValue: defaultData.errorColor)); - properties.add(new DiagnosticsProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor)); - properties.add(new DiagnosticsProperty('buttonTheme', buttonTheme)); - properties.add(new DiagnosticsProperty('textTheme', textTheme)); - properties.add(new DiagnosticsProperty('primaryTextTheme', primaryTextTheme)); - properties.add(new DiagnosticsProperty('accentTextTheme', accentTextTheme)); - properties.add(new DiagnosticsProperty('inputDecorationTheme', inputDecorationTheme)); - properties.add(new DiagnosticsProperty('iconTheme', iconTheme)); - properties.add(new DiagnosticsProperty('primaryIconTheme', primaryIconTheme)); - properties.add(new DiagnosticsProperty('accentIconTheme', accentIconTheme)); - properties.add(new DiagnosticsProperty('sliderTheme', sliderTheme)); - properties.add(new DiagnosticsProperty('chipTheme', chipTheme)); - properties.add(new DiagnosticsProperty('materialTapTargetSize', materialTapTargetSize)); + final ThemeData defaultData = ThemeData.fallback(); + properties.add(EnumProperty('platform', platform, defaultValue: defaultTargetPlatform)); + properties.add(EnumProperty('brightness', brightness, defaultValue: defaultData.brightness)); + properties.add(DiagnosticsProperty('primaryColor', primaryColor, defaultValue: defaultData.primaryColor)); + properties.add(EnumProperty('primaryColorBrightness', primaryColorBrightness, defaultValue: defaultData.primaryColorBrightness)); + properties.add(DiagnosticsProperty('accentColor', accentColor, defaultValue: defaultData.accentColor)); + properties.add(EnumProperty('accentColorBrightness', accentColorBrightness, defaultValue: defaultData.accentColorBrightness)); + properties.add(DiagnosticsProperty('canvasColor', canvasColor, defaultValue: defaultData.canvasColor)); + properties.add(DiagnosticsProperty('scaffoldBackgroundColor', scaffoldBackgroundColor, defaultValue: defaultData.scaffoldBackgroundColor)); + properties.add(DiagnosticsProperty('bottomAppBarColor', bottomAppBarColor, defaultValue: defaultData.bottomAppBarColor)); + properties.add(DiagnosticsProperty('cardColor', cardColor, defaultValue: defaultData.cardColor)); + properties.add(DiagnosticsProperty('dividerColor', dividerColor, defaultValue: defaultData.dividerColor)); + properties.add(DiagnosticsProperty('highlightColor', highlightColor, defaultValue: defaultData.highlightColor)); + properties.add(DiagnosticsProperty('splashColor', splashColor, defaultValue: defaultData.splashColor)); + properties.add(DiagnosticsProperty('selectedRowColor', selectedRowColor, defaultValue: defaultData.selectedRowColor)); + properties.add(DiagnosticsProperty('unselectedWidgetColor', unselectedWidgetColor, defaultValue: defaultData.unselectedWidgetColor)); + properties.add(DiagnosticsProperty('disabledColor', disabledColor, defaultValue: defaultData.disabledColor)); + properties.add(DiagnosticsProperty('buttonColor', buttonColor, defaultValue: defaultData.buttonColor)); + properties.add(DiagnosticsProperty('secondaryHeaderColor', secondaryHeaderColor, defaultValue: defaultData.secondaryHeaderColor)); + properties.add(DiagnosticsProperty('textSelectionColor', textSelectionColor, defaultValue: defaultData.textSelectionColor)); + properties.add(DiagnosticsProperty('cursorColor', cursorColor, defaultValue: defaultData.cursorColor)); + properties.add(DiagnosticsProperty('textSelectionHandleColor', textSelectionHandleColor, defaultValue: defaultData.textSelectionHandleColor)); + properties.add(DiagnosticsProperty('backgroundColor', backgroundColor, defaultValue: defaultData.backgroundColor)); + properties.add(DiagnosticsProperty('dialogBackgroundColor', dialogBackgroundColor, defaultValue: defaultData.dialogBackgroundColor)); + properties.add(DiagnosticsProperty('indicatorColor', indicatorColor, defaultValue: defaultData.indicatorColor)); + properties.add(DiagnosticsProperty('hintColor', hintColor, defaultValue: defaultData.hintColor)); + properties.add(DiagnosticsProperty('errorColor', errorColor, defaultValue: defaultData.errorColor)); + properties.add(DiagnosticsProperty('toggleableActiveColor', toggleableActiveColor, defaultValue: defaultData.toggleableActiveColor)); + properties.add(DiagnosticsProperty('buttonTheme', buttonTheme)); + properties.add(DiagnosticsProperty('textTheme', textTheme)); + properties.add(DiagnosticsProperty('primaryTextTheme', primaryTextTheme)); + properties.add(DiagnosticsProperty('accentTextTheme', accentTextTheme)); + properties.add(DiagnosticsProperty('inputDecorationTheme', inputDecorationTheme)); + properties.add(DiagnosticsProperty('iconTheme', iconTheme)); + properties.add(DiagnosticsProperty('primaryIconTheme', primaryIconTheme)); + properties.add(DiagnosticsProperty('accentIconTheme', accentIconTheme)); + properties.add(DiagnosticsProperty('sliderTheme', sliderTheme)); + properties.add(DiagnosticsProperty('chipTheme', chipTheme)); + properties.add(DiagnosticsProperty('materialTapTargetSize', materialTapTargetSize)); } } diff --git a/packages/flutter/lib/src/material/time.dart b/packages/flutter/lib/src/material/time.dart index 2580ca497e..11216a5ad0 100644 --- a/packages/flutter/lib/src/material/time.dart +++ b/packages/flutter/lib/src/material/time.dart @@ -55,13 +55,13 @@ class TimeOfDay { /// /// The [hour] is set to the current hour and the [minute] is set to the /// current minute in the local time zone. - factory TimeOfDay.now() { return new TimeOfDay.fromDateTime(new DateTime.now()); } + factory TimeOfDay.now() { return TimeOfDay.fromDateTime(DateTime.now()); } /// Returns a new TimeOfDay with the hour and/or minute replaced. TimeOfDay replacing({ int hour, int minute }) { assert(hour == null || (hour >= 0 && hour < hoursPerDay)); assert(minute == null || (minute >= 0 && minute < minutesPerHour)); - return new TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute); + return TimeOfDay(hour: hour ?? this.hour, minute: minute ?? this.minute); } /// The selected hour, in 24 hour time from 0..23. diff --git a/packages/flutter/lib/src/material/time_picker.dart b/packages/flutter/lib/src/material/time_picker.dart index a21d00188c..a40bfccedc 100644 --- a/packages/flutter/lib/src/material/time_picker.dart +++ b/packages/flutter/lib/src/material/time_picker.dart @@ -235,36 +235,36 @@ class _DayPeriodControl extends StatelessWidget { color: !amSelected ? activeColor: inactiveColor ); - return new Column( + return Column( mainAxisSize: MainAxisSize.min, children: [ - new GestureDetector( + GestureDetector( excludeFromSemantics: true, onTap: Feedback.wrapForTap(() { _setAm(context); }, context), behavior: HitTestBehavior.opaque, - child: new Semantics( + child: Semantics( selected: amSelected, onTap: () { _setAm(context); }, - child: new Text(materialLocalizations.anteMeridiemAbbreviation, style: amStyle), + child: Text(materialLocalizations.anteMeridiemAbbreviation, style: amStyle), ), ), const SizedBox(width: 0.0, height: 4.0), // Vertical spacer - new GestureDetector( + GestureDetector( excludeFromSemantics: true, onTap: Feedback.wrapForTap(() { _setPm(context); }, context), behavior: HitTestBehavior.opaque, - child: new Semantics( + child: Semantics( selected: !amSelected, onTap: () { _setPm(context); }, - child: new Text(materialLocalizations.postMeridiemAbbreviation, style: pmStyle), + child: Text(materialLocalizations.postMeridiemAbbreviation, style: pmStyle), ), ), ], @@ -322,9 +322,9 @@ class _HourControl extends StatelessWidget { alwaysUse24HourFormat: alwaysUse24HourFormat, ); - return new GestureDetector( + return GestureDetector( onTap: Feedback.wrapForTap(() => fragmentContext.onModeChange(_TimePickerMode.hour), context), - child: new Semantics( + child: Semantics( hint: localizations.timePickerHourModeAnnouncement, value: formattedHour, excludeSemantics: true, @@ -336,7 +336,7 @@ class _HourControl extends StatelessWidget { onDecrease: () { fragmentContext.onTimeChange(previousHour); }, - child: new Text(formattedHour, style: hourStyle), + child: Text(formattedHour, style: hourStyle), ), ); } @@ -354,8 +354,8 @@ class _StringFragment extends StatelessWidget { @override Widget build(BuildContext context) { - return new ExcludeSemantics( - child: new Text(value, style: fragmentContext.inactiveStyle), + return ExcludeSemantics( + child: Text(value, style: fragmentContext.inactiveStyle), ); } } @@ -386,9 +386,9 @@ class _MinuteControl extends StatelessWidget { ); final String formattedPreviousMinute = localizations.formatMinute(previousMinute); - return new GestureDetector( + return GestureDetector( onTap: Feedback.wrapForTap(() => fragmentContext.onModeChange(_TimePickerMode.minute), context), - child: new Semantics( + child: Semantics( excludeSemantics: true, hint: localizations.timePickerMinuteModeAnnouncement, value: formattedMinute, @@ -400,7 +400,7 @@ class _MinuteControl extends StatelessWidget { onDecrease: () { fragmentContext.onTimeChange(previousMinute); }, - child: new Text(formattedMinute, style: minuteStyle), + child: Text(formattedMinute, style: minuteStyle), ), ); } @@ -414,26 +414,26 @@ class _MinuteControl extends StatelessWidget { _TimePickerHeaderFormat _buildHeaderFormat(TimeOfDayFormat timeOfDayFormat, _TimePickerFragmentContext context) { // Creates an hour fragment. _TimePickerHeaderFragment hour() { - return new _TimePickerHeaderFragment( + return _TimePickerHeaderFragment( layoutId: _TimePickerHeaderId.hour, - widget: new _HourControl(fragmentContext: context), + widget: _HourControl(fragmentContext: context), startMargin: _kPeriodGap, ); } // Creates a minute fragment. _TimePickerHeaderFragment minute() { - return new _TimePickerHeaderFragment( + return _TimePickerHeaderFragment( layoutId: _TimePickerHeaderId.minute, - widget: new _MinuteControl(fragmentContext: context), + widget: _MinuteControl(fragmentContext: context), ); } // Creates a string fragment. _TimePickerHeaderFragment string(_TimePickerHeaderId layoutId, String value) { - return new _TimePickerHeaderFragment( + return _TimePickerHeaderFragment( layoutId: layoutId, - widget: new _StringFragment( + widget: _StringFragment( fragmentContext: context, value: value, ), @@ -442,9 +442,9 @@ _TimePickerHeaderFormat _buildHeaderFormat(TimeOfDayFormat timeOfDayFormat, _Tim // Creates an am/pm fragment. _TimePickerHeaderFragment dayPeriod() { - return new _TimePickerHeaderFragment( + return _TimePickerHeaderFragment( layoutId: _TimePickerHeaderId.period, - widget: new _DayPeriodControl(fragmentContext: context), + widget: _DayPeriodControl(fragmentContext: context), startMargin: _kPeriodGap, ); } @@ -472,7 +472,7 @@ _TimePickerHeaderFormat _buildHeaderFormat(TimeOfDayFormat timeOfDayFormat, _Tim } } assert(centrepieceIndex != null); - return new _TimePickerHeaderFormat(centrepieceIndex, pieces); + return _TimePickerHeaderFormat(centrepieceIndex, pieces); } // Convenience function for creating a time header piece with up to three fragments. @@ -484,7 +484,7 @@ _TimePickerHeaderFormat _buildHeaderFormat(TimeOfDayFormat timeOfDayFormat, _Tim if (fragment3 != null) fragments.add(fragment3); } - return new _TimePickerHeaderPiece(pivotIndex, fragments, bottomMargin: bottomMargin); + return _TimePickerHeaderPiece(pivotIndex, fragments, bottomMargin: bottomMargin); } switch (timeOfDayFormat) { @@ -557,7 +557,7 @@ class _TimePickerHeaderLayout extends MultiChildLayoutDelegate { @override void performLayout(Size size) { - final BoxConstraints constraints = new BoxConstraints.loose(size); + final BoxConstraints constraints = BoxConstraints.loose(size); switch (orientation) { case Orientation.portrait: @@ -631,7 +631,7 @@ class _TimePickerHeaderLayout extends MultiChildLayoutDelegate { final _TimePickerHeaderFragment fragment = fragments[i]; final Size childSize = childSizes[fragment.layoutId]; x -= childSize.width; - positionChild(fragment.layoutId, new Offset(x, y - childSize.height / 2.0)); + positionChild(fragment.layoutId, Offset(x, y - childSize.height / 2.0)); x -= fragment.startMargin; } } @@ -651,7 +651,7 @@ class _TimePickerHeaderLayout extends MultiChildLayoutDelegate { final _TimePickerHeaderFragment fragment = fragments[i]; final Size childSize = childSizes[fragment.layoutId]; x -= childSize.width; - positionChild(fragment.layoutId, new Offset(x, centeredAroundY - childSize.height / 2.0)); + positionChild(fragment.layoutId, Offset(x, centeredAroundY - childSize.height / 2.0)); x -= fragment.startMargin; } } @@ -748,7 +748,7 @@ class _TimePickerHeader extends StatelessWidget { final TextTheme headerTextTheme = themeData.primaryTextTheme; final TextStyle baseHeaderStyle = _getBaseHeaderStyle(headerTextTheme); - final _TimePickerFragmentContext fragmentContext = new _TimePickerFragmentContext( + final _TimePickerFragmentContext fragmentContext = _TimePickerFragmentContext( headerTextTheme: headerTextTheme, textDirection: Directionality.of(context), selectedTime: selectedTime, @@ -765,17 +765,17 @@ class _TimePickerHeader extends StatelessWidget { final _TimePickerHeaderFormat format = _buildHeaderFormat(timeOfDayFormat, fragmentContext); - return new Container( + return Container( width: width, height: height, padding: padding, color: backgroundColor, - child: new CustomMultiChildLayout( - delegate: new _TimePickerHeaderLayout(orientation, format), + child: CustomMultiChildLayout( + delegate: _TimePickerHeaderLayout(orientation, format), children: format.pieces .expand<_TimePickerHeaderFragment>((_TimePickerHeaderPiece piece) => piece.fragments) .map((_TimePickerHeaderFragment fragment) { - return new LayoutId( + return LayoutId( id: fragment.layoutId, child: fragment.widget, ); @@ -836,9 +836,9 @@ class _DialPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { final double radius = size.shortestSide / 2.0; - final Offset center = new Offset(size.width / 2.0, size.height / 2.0); + final Offset center = Offset(size.width / 2.0, size.height / 2.0); final Offset centerPoint = center; - canvas.drawCircle(centerPoint, radius, new Paint()..color = backgroundColor); + canvas.drawCircle(centerPoint, radius, Paint()..color = backgroundColor); const double labelPadding = 24.0; final double outerLabelRadius = radius - labelPadding; @@ -853,7 +853,7 @@ class _DialPainter extends CustomPainter { labelRadius = innerLabelRadius; break; } - return center + new Offset(labelRadius * math.cos(theta), + return center + Offset(labelRadius * math.cos(theta), -labelRadius * math.sin(theta)); } @@ -865,7 +865,7 @@ class _DialPainter extends CustomPainter { for (_TappableLabel label in labels) { final TextPainter labelPainter = label.painter; - final Offset labelOffset = new Offset(-labelPainter.width / 2.0, -labelPainter.height / 2.0); + final Offset labelOffset = Offset(-labelPainter.width / 2.0, -labelPainter.height / 2.0); labelPainter.paint(canvas, getOffsetForTheta(labelTheta, ring) + labelOffset); labelTheta += labelThetaIncrement; } @@ -874,7 +874,7 @@ class _DialPainter extends CustomPainter { paintLabels(primaryOuterLabels, _DialRing.outer); paintLabels(primaryInnerLabels, _DialRing.inner); - final Paint selectorPaint = new Paint() + final Paint selectorPaint = Paint() ..color = accentColor; final Offset focusedPoint = getOffsetForTheta(theta, activeRing); const double focusedRadius = labelPadding - 4.0; @@ -883,12 +883,12 @@ class _DialPainter extends CustomPainter { selectorPaint.strokeWidth = 2.0; canvas.drawLine(centerPoint, focusedPoint, selectorPaint); - final Rect focusedRect = new Rect.fromCircle( + final Rect focusedRect = Rect.fromCircle( center: focusedPoint, radius: focusedRadius ); canvas ..save() - ..clipPath(new Path()..addOval(focusedRect)); + ..clipPath(Path()..addOval(focusedRect)); paintLabels(secondaryOuterLabels, _DialRing.outer); paintLabels(secondaryInnerLabels, _DialRing.inner); canvas.restore(); @@ -906,7 +906,7 @@ class _DialPainter extends CustomPainter { /// bigger tap area. List _buildSemantics(Size size) { final double radius = size.shortestSide / 2.0; - final Offset center = new Offset(size.width / 2.0, size.height / 2.0); + final Offset center = Offset(size.width / 2.0, size.height / 2.0); const double labelPadding = 24.0; final double outerLabelRadius = radius - labelPadding; final double innerLabelRadius = radius - labelPadding * 2.5; @@ -921,7 +921,7 @@ class _DialPainter extends CustomPainter { labelRadius = innerLabelRadius; break; } - return center + new Offset(labelRadius * math.cos(theta), + return center + Offset(labelRadius * math.cos(theta), -labelRadius * math.sin(theta)); } @@ -939,22 +939,22 @@ class _DialPainter extends CustomPainter { final TextPainter labelPainter = label.painter; final double width = labelPainter.width * _semanticNodeSizeScale; final double height = labelPainter.height * _semanticNodeSizeScale; - final Offset nodeOffset = getOffsetForTheta(labelTheta, ring) + new Offset(-width / 2.0, -height / 2.0); - final CustomPainterSemantics node = new CustomPainterSemantics( - rect: new Rect.fromLTRB( + final Offset nodeOffset = getOffsetForTheta(labelTheta, ring) + Offset(-width / 2.0, -height / 2.0); + final CustomPainterSemantics node = CustomPainterSemantics( + rect: Rect.fromLTRB( nodeOffset.dx - 24.0 + width / 2, nodeOffset.dy - 24.0 + height / 2, nodeOffset.dx + 24.0 + width / 2, nodeOffset.dy + 24.0 + height / 2, ), - properties: new SemanticsProperties( - sortKey: new OrdinalSortKey(i.toDouble() + ordinalOffset), + properties: SemanticsProperties( + sortKey: OrdinalSortKey(i.toDouble() + ordinalOffset), selected: label.value == selectedValue, value: labelPainter.text.text, textDirection: textDirection, onTap: label.onTap, ), - tags: new Set.from(const [ + tags: Set.from(const [ // Used by tests to find this node. SemanticsTag('dial-label'), ]), @@ -997,7 +997,7 @@ class _Dial extends StatefulWidget { final ValueChanged onChanged; @override - _DialState createState() => new _DialState(); + _DialState createState() => _DialState(); } class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { @@ -1005,12 +1005,12 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { void initState() { super.initState(); _updateDialRingFromWidget(); - _thetaController = new AnimationController( + _thetaController = AnimationController( duration: _kDialAnimateDuration, vsync: this, ); - _thetaTween = new Tween(begin: _getThetaForTime(widget.selectedTime)); - _theta = _thetaTween.animate(new CurvedAnimation( + _thetaTween = Tween(begin: _getThetaForTime(widget.selectedTime)); + _theta = _thetaTween.animate(CurvedAnimation( parent: _thetaController, curve: Curves.fastOutSlowIn ))..addListener(() => setState(() { })); @@ -1188,13 +1188,13 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { _activeRing = hour >= 1 && hour <= 12 ? _DialRing.inner : _DialRing.outer; - time = new TimeOfDay(hour: hour, minute: widget.selectedTime.minute); + time = TimeOfDay(hour: hour, minute: widget.selectedTime.minute); } else { _activeRing = _DialRing.outer; if (widget.selectedTime.period == DayPeriod.am) { - time = new TimeOfDay(hour: hour, minute: widget.selectedTime.minute); + time = TimeOfDay(hour: hour, minute: widget.selectedTime.minute); } else { - time = new TimeOfDay(hour: hour + TimeOfDay.hoursPerPeriod, minute: widget.selectedTime.minute); + time = TimeOfDay(hour: hour + TimeOfDay.hoursPerPeriod, minute: widget.selectedTime.minute); } } final double angle = _getThetaForTime(time); @@ -1206,7 +1206,7 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { void _selectMinute(int minute) { _announceToAccessibility(context, localizations.formatDecimal(minute)); - final TimeOfDay time = new TimeOfDay( + final TimeOfDay time = TimeOfDay( hour: widget.selectedTime.hour, minute: minute, ); @@ -1251,10 +1251,10 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { final TextStyle style = textTheme.subhead; // TODO(abarth): Handle textScaleFactor. // https://github.com/flutter/flutter/issues/5939 - return new _TappableLabel( + return _TappableLabel( value: value, - painter: new TextPainter( - text: new TextSpan(style: style, text: label), + painter: TextPainter( + text: TextSpan(style: style, text: label), textDirection: TextDirection.ltr, )..layout(), onTap: onTap, @@ -1377,15 +1377,15 @@ class _DialState extends State<_Dial> with SingleTickerProviderStateMixin { break; } - return new GestureDetector( + return GestureDetector( excludeFromSemantics: true, onPanStart: _handlePanStart, onPanUpdate: _handlePanUpdate, onPanEnd: _handlePanEnd, onTapUp: _handleTapUp, - child: new CustomPaint( + child: CustomPaint( key: const ValueKey('time-picker-dial'), - painter: new _DialPainter( + painter: _DialPainter( selectedValue: selectedDialValue, primaryOuterLabels: primaryOuterLabels, primaryInnerLabels: primaryInnerLabels, @@ -1422,7 +1422,7 @@ class _TimePickerDialog extends StatefulWidget { final TimeOfDay initialTime; @override - _TimePickerDialogState createState() => new _TimePickerDialogState(); + _TimePickerDialogState createState() => _TimePickerDialogState(); } class _TimePickerDialogState extends State<_TimePickerDialog> { @@ -1454,7 +1454,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { case TargetPlatform.android: case TargetPlatform.fuchsia: _vibrateTimer?.cancel(); - _vibrateTimer = new Timer(_kVibrateCommitDelay, () { + _vibrateTimer = Timer(_kVibrateCommitDelay, () { HapticFeedback.vibrate(); _vibrateTimer = null; }); @@ -1527,11 +1527,11 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { final bool use24HourDials = hourFormat(of: timeOfDayFormat) != HourFormat.h; final ThemeData theme = Theme.of(context); - final Widget picker = new Padding( + final Widget picker = Padding( padding: const EdgeInsets.all(16.0), - child: new AspectRatio( + child: AspectRatio( aspectRatio: 1.0, - child: new _Dial( + child: _Dial( mode: _mode, use24HourDials: use24HourDials, selectedTime: _selectedTime, @@ -1540,25 +1540,25 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ) ); - final Widget actions = new ButtonTheme.bar( - child: new ButtonBar( + final Widget actions = ButtonTheme.bar( + child: ButtonBar( children: [ - new FlatButton( - child: new Text(localizations.cancelButtonLabel), + FlatButton( + child: Text(localizations.cancelButtonLabel), onPressed: _handleCancel ), - new FlatButton( - child: new Text(localizations.okButtonLabel), + FlatButton( + child: Text(localizations.okButtonLabel), onPressed: _handleOk ), ] ) ); - final Dialog dialog = new Dialog( - child: new OrientationBuilder( + final Dialog dialog = Dialog( + child: OrientationBuilder( builder: (BuildContext context, Orientation orientation) { - final Widget header = new _TimePickerHeader( + final Widget header = _TimePickerHeader( selectedTime: _selectedTime, mode: _mode, orientation: orientation, @@ -1567,12 +1567,12 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { use24HourDials: use24HourDials, ); - final Widget pickerAndActions = new Container( + final Widget pickerAndActions = Container( color: theme.dialogBackgroundColor, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new Expanded(child: picker), // picker grows and shrinks with the available space + Expanded(child: picker), // picker grows and shrinks with the available space actions, ], ), @@ -1594,30 +1594,30 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { assert(orientation != null); switch (orientation) { case Orientation.portrait: - return new SizedBox( + return SizedBox( width: _kTimePickerWidthPortrait, height: timePickerHeightPortrait, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ header, - new Expanded( + Expanded( child: pickerAndActions, ), ] ) ); case Orientation.landscape: - return new SizedBox( + return SizedBox( width: _kTimePickerWidthLandscape, height: timePickerHeightLandscape, - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, crossAxisAlignment: CrossAxisAlignment.stretch, children: [ header, - new Flexible( + Flexible( child: pickerAndActions, ), ] @@ -1629,7 +1629,7 @@ class _TimePickerDialogState extends State<_TimePickerDialog> { ) ); - return new Theme( + return Theme( data: theme.copyWith( dialogBackgroundColor: Colors.transparent, ), @@ -1675,7 +1675,7 @@ Future showTimePicker({ return await showDialog( context: context, - builder: (BuildContext context) => new _TimePickerDialog(initialTime: initialTime), + builder: (BuildContext context) => _TimePickerDialog(initialTime: initialTime), ); } diff --git a/packages/flutter/lib/src/material/toggleable.dart b/packages/flutter/lib/src/material/toggleable.dart index d1d487fb7a..bee9e4e497 100644 --- a/packages/flutter/lib/src/material/toggleable.dart +++ b/packages/flutter/lib/src/material/toggleable.dart @@ -11,7 +11,7 @@ import 'package:flutter/scheduler.dart'; import 'constants.dart'; const Duration _kToggleDuration = Duration(milliseconds: 200); -final Tween _kRadialReactionRadiusTween = new Tween(begin: 0.0, end: kRadialReactionRadius); +final Tween _kRadialReactionRadiusTween = Tween(begin: 0.0, end: kRadialReactionRadius); /// A base class for material style toggleable controls with toggle animations. /// @@ -43,26 +43,26 @@ abstract class RenderToggleable extends RenderConstrainedBox { _onChanged = onChanged, _vsync = vsync, super(additionalConstraints: additionalConstraints) { - _tap = new TapGestureRecognizer() + _tap = TapGestureRecognizer() ..onTapDown = _handleTapDown ..onTap = _handleTap ..onTapUp = _handleTapUp ..onTapCancel = _handleTapCancel; - _positionController = new AnimationController( + _positionController = AnimationController( duration: _kToggleDuration, value: value == false ? 0.0 : 1.0, vsync: vsync, ); - _position = new CurvedAnimation( + _position = CurvedAnimation( parent: _positionController, curve: Curves.linear, )..addListener(markNeedsPaint) ..addStatusListener(_handlePositionStateChanged); - _reactionController = new AnimationController( + _reactionController = AnimationController( duration: kRadialReactionDuration, vsync: vsync, ); - _reaction = new CurvedAnimation( + _reaction = CurvedAnimation( parent: _reactionController, curve: Curves.fastOutSlowIn, )..addListener(markNeedsPaint); @@ -325,7 +325,7 @@ abstract class RenderToggleable extends RenderConstrainedBox { void paintRadialReaction(Canvas canvas, Offset offset, Offset origin) { if (!_reaction.isDismissed) { // TODO(abarth): We should have a different reaction color when position is zero. - final Paint reactionPaint = new Paint()..color = activeColor.withAlpha(kRadialReactionAlpha); + final Paint reactionPaint = Paint()..color = activeColor.withAlpha(kRadialReactionAlpha); final Offset center = Offset.lerp(_downPosition ?? origin, origin, _reaction.value); final double radius = _kRadialReactionRadiusTween.evaluate(_reaction); canvas.drawCircle(center + offset, radius, reactionPaint); @@ -344,7 +344,7 @@ abstract class RenderToggleable extends RenderConstrainedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('value', value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true)); - properties.add(new FlagProperty('isInteractive', value: isInteractive, ifTrue: 'enabled', ifFalse: 'disabled', defaultValue: true)); + properties.add(FlagProperty('value', value: value, ifTrue: 'checked', ifFalse: 'unchecked', showName: true)); + properties.add(FlagProperty('isInteractive', value: isInteractive, ifTrue: 'enabled', ifFalse: 'disabled', defaultValue: true)); } } diff --git a/packages/flutter/lib/src/material/tooltip.dart b/packages/flutter/lib/src/material/tooltip.dart index 35616ce658..e80fa8e27f 100644 --- a/packages/flutter/lib/src/material/tooltip.dart +++ b/packages/flutter/lib/src/material/tooltip.dart @@ -88,14 +88,14 @@ class Tooltip extends StatefulWidget { final Widget child; @override - _TooltipState createState() => new _TooltipState(); + _TooltipState createState() => _TooltipState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('message', message, showName: false)); - properties.add(new DoubleProperty('vertical offset', verticalOffset)); - properties.add(new FlagProperty('position', value: preferBelow, ifTrue: 'below', ifFalse: 'above', showName: true)); + properties.add(StringProperty('message', message, showName: false)); + properties.add(DoubleProperty('vertical offset', verticalOffset)); + properties.add(FlagProperty('position', value: preferBelow, ifTrue: 'below', ifFalse: 'above', showName: true)); } } @@ -107,7 +107,7 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { @override void initState() { super.initState(); - _controller = new AnimationController(duration: _kFadeDuration, vsync: this) + _controller = AnimationController(duration: _kFadeDuration, vsync: this) ..addStatusListener(_handleStatusChanged); } @@ -131,11 +131,11 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { // We create this widget outside of the overlay entry's builder to prevent // updated values from happening to leak into the overlay when the overlay // rebuilds. - final Widget overlay = new _TooltipOverlay( + final Widget overlay = _TooltipOverlay( message: widget.message, height: widget.height, padding: widget.padding, - animation: new CurvedAnimation( + animation: CurvedAnimation( parent: _controller, curve: Curves.fastOutSlowIn ), @@ -143,7 +143,7 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { verticalOffset: widget.verticalOffset, preferBelow: widget.preferBelow ); - _entry = new OverlayEntry(builder: (BuildContext context) => overlay); + _entry = OverlayEntry(builder: (BuildContext context) => overlay); Overlay.of(context, debugRequiredFor: widget).insert(_entry); GestureBinding.instance.pointerRouter.addGlobalRoute(_handlePointerEvent); SemanticsService.tooltip(widget.message); @@ -163,7 +163,7 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { void _handlePointerEvent(PointerEvent event) { assert(_entry != null); if (event is PointerUpEvent || event is PointerCancelEvent) - _timer ??= new Timer(_kShowDuration, _controller.reverse); + _timer ??= Timer(_kShowDuration, _controller.reverse); else if (event is PointerDownEvent) _controller.reverse(); } @@ -192,11 +192,11 @@ class _TooltipState extends State with SingleTickerProviderStateMixin { @override Widget build(BuildContext context) { assert(Overlay.of(context, debugRequiredFor: widget) != null); - return new GestureDetector( + return GestureDetector( behavior: HitTestBehavior.opaque, onLongPress: _handleLongPress, excludeFromSemantics: true, - child: new Semantics( + child: Semantics( label: widget.excludeFromSemantics ? null : widget.message, child: widget.child, ), @@ -277,35 +277,35 @@ class _TooltipOverlay extends StatelessWidget { @override Widget build(BuildContext context) { final ThemeData theme = Theme.of(context); - final ThemeData darkTheme = new ThemeData( + final ThemeData darkTheme = ThemeData( brightness: Brightness.dark, textTheme: theme.brightness == Brightness.dark ? theme.textTheme : theme.primaryTextTheme, platform: theme.platform, ); - return new Positioned.fill( - child: new IgnorePointer( - child: new CustomSingleChildLayout( - delegate: new _TooltipPositionDelegate( + return Positioned.fill( + child: IgnorePointer( + child: CustomSingleChildLayout( + delegate: _TooltipPositionDelegate( target: target, verticalOffset: verticalOffset, preferBelow: preferBelow, ), - child: new FadeTransition( + child: FadeTransition( opacity: animation, - child: new Opacity( + child: Opacity( opacity: 0.9, - child: new ConstrainedBox( - constraints: new BoxConstraints(minHeight: height), - child: new Container( - decoration: new BoxDecoration( + child: ConstrainedBox( + constraints: BoxConstraints(minHeight: height), + child: Container( + decoration: BoxDecoration( color: darkTheme.backgroundColor, - borderRadius: new BorderRadius.circular(2.0), + borderRadius: BorderRadius.circular(2.0), ), padding: padding, - child: new Center( + child: Center( widthFactor: 1.0, heightFactor: 1.0, - child: new Text(message, style: darkTheme.textTheme.body1), + child: Text(message, style: darkTheme.textTheme.body1), ), ), ), diff --git a/packages/flutter/lib/src/material/two_level_list.dart b/packages/flutter/lib/src/material/two_level_list.dart index 856049b770..e001c2b419 100644 --- a/packages/flutter/lib/src/material/two_level_list.dart +++ b/packages/flutter/lib/src/material/two_level_list.dart @@ -89,9 +89,9 @@ class TwoLevelListItem extends StatelessWidget { final TwoLevelList parentList = context.ancestorWidgetOfExactType(TwoLevelList); assert(parentList != null); - return new SizedBox( + return SizedBox( height: kListTileExtent[parentList.type], - child: new ListTile( + child: ListTile( leading: leading, title: title, trailing: trailing, @@ -142,7 +142,7 @@ class TwoLevelSublist extends StatefulWidget { final Color backgroundColor; @override - _TwoLevelSublistState createState() => new _TwoLevelSublistState(); + _TwoLevelSublistState createState() => _TwoLevelSublistState(); } @deprecated @@ -161,14 +161,14 @@ class _TwoLevelSublistState extends State with SingleTickerProv @override void initState() { super.initState(); - _controller = new AnimationController(duration: _kExpand, vsync: this); - _easeOutAnimation = new CurvedAnimation(parent: _controller, curve: Curves.easeOut); - _easeInAnimation = new CurvedAnimation(parent: _controller, curve: Curves.easeIn); - _borderColor = new ColorTween(begin: Colors.transparent); - _headerColor = new ColorTween(); - _iconColor = new ColorTween(); - _iconTurns = new Tween(begin: 0.0, end: 0.5).animate(_easeInAnimation); - _backgroundColor = new ColorTween(); + _controller = AnimationController(duration: _kExpand, vsync: this); + _easeOutAnimation = CurvedAnimation(parent: _controller, curve: Curves.easeOut); + _easeInAnimation = CurvedAnimation(parent: _controller, curve: Curves.easeIn); + _borderColor = ColorTween(begin: Colors.transparent); + _headerColor = ColorTween(); + _iconColor = ColorTween(); + _iconTurns = Tween(begin: 0.0, end: 0.5).animate(_easeInAnimation); + _backgroundColor = ColorTween(); _isExpanded = PageStorage.of(context)?.readState(context) ?? false; if (_isExpanded) @@ -195,35 +195,35 @@ class _TwoLevelSublistState extends State with SingleTickerProv } Widget buildList(BuildContext context, Widget child) { - return new Container( - decoration: new BoxDecoration( + return Container( + decoration: BoxDecoration( color: _backgroundColor.evaluate(_easeOutAnimation), - border: new Border( - top: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)), - bottom: new BorderSide(color: _borderColor.evaluate(_easeOutAnimation)) + border: Border( + top: BorderSide(color: _borderColor.evaluate(_easeOutAnimation)), + bottom: BorderSide(color: _borderColor.evaluate(_easeOutAnimation)) ) ), - child: new Column( + child: Column( children: [ IconTheme.merge( - data: new IconThemeData(color: _iconColor.evaluate(_easeInAnimation)), - child: new TwoLevelListItem( + data: IconThemeData(color: _iconColor.evaluate(_easeInAnimation)), + child: TwoLevelListItem( onTap: _handleOnTap, leading: widget.leading, - title: new DefaultTextStyle( + title: DefaultTextStyle( style: Theme.of(context).textTheme.subhead.copyWith(color: _headerColor.evaluate(_easeInAnimation)), child: widget.title ), - trailing: new RotationTransition( + trailing: RotationTransition( turns: _iconTurns, child: const Icon(Icons.expand_more) ) ) ), - new ClipRect( - child: new Align( + ClipRect( + child: Align( heightFactor: _easeInAnimation.value, - child: new Column(children: widget.children) + child: Column(children: widget.children) ) ) ] @@ -245,7 +245,7 @@ class _TwoLevelSublistState extends State with SingleTickerProv ..begin = Colors.transparent ..end = widget.backgroundColor ?? Colors.transparent; - return new AnimatedBuilder( + return AnimatedBuilder( animation: _controller.view, builder: buildList ); @@ -279,7 +279,7 @@ class TwoLevelList extends StatelessWidget { @override Widget build(BuildContext context) { - return new ListView( + return ListView( padding: padding, shrinkWrap: true, children: KeyedSubtree.ensureUniqueKeysForList(children), diff --git a/packages/flutter/lib/src/material/typography.dart b/packages/flutter/lib/src/material/typography.dart index 1476be91dc..f8e69371e5 100644 --- a/packages/flutter/lib/src/material/typography.dart +++ b/packages/flutter/lib/src/material/typography.dart @@ -151,7 +151,7 @@ class TextTheme extends Diagnosticable { TextStyle caption, TextStyle button, }) { - return new TextTheme( + return TextTheme( display4: display4 ?? this.display4, display3: display3 ?? this.display3, display2: display2 ?? this.display2, @@ -254,7 +254,7 @@ class TextTheme extends Diagnosticable { Color decorationColor, TextDecorationStyle decorationStyle, }) { - return new TextTheme( + return TextTheme( display4: display4.apply( color: displayColor, decoration: decoration, @@ -376,7 +376,7 @@ class TextTheme extends Diagnosticable { assert(a != null); assert(b != null); assert(t != null); - return new TextTheme( + return TextTheme( display4: TextStyle.lerp(a.display4, b.display4, t), display3: TextStyle.lerp(a.display3, b.display3, t), display2: TextStyle.lerp(a.display2, b.display2, t), @@ -431,18 +431,18 @@ class TextTheme extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - final TextTheme defaultTheme = new Typography(platform: defaultTargetPlatform).black; - properties.add(new DiagnosticsProperty('display4', display4, defaultValue: defaultTheme.display4)); - properties.add(new DiagnosticsProperty('display3', display3, defaultValue: defaultTheme.display3)); - properties.add(new DiagnosticsProperty('display2', display2, defaultValue: defaultTheme.display2)); - properties.add(new DiagnosticsProperty('display1', display1, defaultValue: defaultTheme.display1)); - properties.add(new DiagnosticsProperty('headline', headline, defaultValue: defaultTheme.headline)); - properties.add(new DiagnosticsProperty('title', title, defaultValue: defaultTheme.title)); - properties.add(new DiagnosticsProperty('subhead', subhead, defaultValue: defaultTheme.subhead)); - properties.add(new DiagnosticsProperty('body2', body2, defaultValue: defaultTheme.body2)); - properties.add(new DiagnosticsProperty('body1', body1, defaultValue: defaultTheme.body1)); - properties.add(new DiagnosticsProperty('caption', caption, defaultValue: defaultTheme.caption)); - properties.add(new DiagnosticsProperty('button', button, defaultValue: defaultTheme.button)); + final TextTheme defaultTheme = Typography(platform: defaultTargetPlatform).black; + properties.add(DiagnosticsProperty('display4', display4, defaultValue: defaultTheme.display4)); + properties.add(DiagnosticsProperty('display3', display3, defaultValue: defaultTheme.display3)); + properties.add(DiagnosticsProperty('display2', display2, defaultValue: defaultTheme.display2)); + properties.add(DiagnosticsProperty('display1', display1, defaultValue: defaultTheme.display1)); + properties.add(DiagnosticsProperty('headline', headline, defaultValue: defaultTheme.headline)); + properties.add(DiagnosticsProperty('title', title, defaultValue: defaultTheme.title)); + properties.add(DiagnosticsProperty('subhead', subhead, defaultValue: defaultTheme.subhead)); + properties.add(DiagnosticsProperty('body2', body2, defaultValue: defaultTheme.body2)); + properties.add(DiagnosticsProperty('body1', body1, defaultValue: defaultTheme.body1)); + properties.add(DiagnosticsProperty('caption', caption, defaultValue: defaultTheme.caption)); + properties.add(DiagnosticsProperty('button', button, defaultValue: defaultTheme.button)); } } diff --git a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart index a3816fe6ba..011a216f96 100644 --- a/packages/flutter/lib/src/material/user_accounts_drawer_header.dart +++ b/packages/flutter/lib/src/material/user_accounts_drawer_header.dart @@ -24,18 +24,18 @@ class _AccountPictures extends StatelessWidget { @override Widget build(BuildContext context) { - return new Stack( + return Stack( children: [ - new PositionedDirectional( + PositionedDirectional( top: 0.0, end: 0.0, - child: new Row( + child: Row( children: (otherAccountsPictures ?? []).take(3).map((Widget picture) { - return new Padding( + return Padding( padding: const EdgeInsetsDirectional.only(start: 8.0), - child: new Semantics( + child: Semantics( container: true, - child: new Container( + child: Container( padding: const EdgeInsets.only(left: 8.0, bottom: 8.0), width: 48.0, height: 48.0, @@ -46,11 +46,11 @@ class _AccountPictures extends StatelessWidget { }).toList(), ), ), - new Positioned( + Positioned( top: 0.0, - child: new Semantics( + child: Semantics( explicitChildNodes: true, - child: new SizedBox( + child: SizedBox( width: 72.0, height: 72.0, child: currentAccountPicture @@ -84,11 +84,11 @@ class _AccountDetails extends StatelessWidget { final List children = []; if (accountName != null) { - final Widget accountNameLine = new LayoutId( + final Widget accountNameLine = LayoutId( id: _AccountDetailsLayout.accountName, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(vertical: 2.0), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: theme.primaryTextTheme.body2, overflow: TextOverflow.ellipsis, child: accountName, @@ -99,11 +99,11 @@ class _AccountDetails extends StatelessWidget { } if (accountEmail != null) { - final Widget accountEmailLine = new LayoutId( + final Widget accountEmailLine = LayoutId( id: _AccountDetailsLayout.accountEmail, - child: new Padding( + child: Padding( padding: const EdgeInsets.symmetric(vertical: 2.0), - child: new DefaultTextStyle( + child: DefaultTextStyle( style: theme.primaryTextTheme.body1, overflow: TextOverflow.ellipsis, child: accountEmail, @@ -115,17 +115,17 @@ class _AccountDetails extends StatelessWidget { if (onTap != null) { final MaterialLocalizations localizations = MaterialLocalizations.of(context); - final Widget dropDownIcon = new LayoutId( + final Widget dropDownIcon = LayoutId( id: _AccountDetailsLayout.dropdownIcon, - child: new Semantics( + child: Semantics( container: true, button: true, onTap: onTap, - child: new SizedBox( + child: SizedBox( height: _kAccountDetailsHeight, width: _kAccountDetailsHeight, - child: new Center( - child: new Icon( + child: Center( + child: Icon( isOpen ? Icons.arrow_drop_up : Icons.arrow_drop_down, color: Colors.white, semanticLabel: isOpen @@ -139,22 +139,22 @@ class _AccountDetails extends StatelessWidget { children.add(dropDownIcon); } - Widget accountDetails = new CustomMultiChildLayout( - delegate: new _AccountDetailsLayout( + Widget accountDetails = CustomMultiChildLayout( + delegate: _AccountDetailsLayout( textDirection: Directionality.of(context), ), children: children, ); if (onTap != null) { - accountDetails = new InkWell( + accountDetails = InkWell( onTap: onTap, child: accountDetails, excludeFromSemantics: true, ); } - return new SizedBox( + return SizedBox( height: _kAccountDetailsHeight, child: accountDetails, ); @@ -178,24 +178,24 @@ class _AccountDetailsLayout extends MultiChildLayoutDelegate { Size iconSize; if (hasChild(dropdownIcon)) { // place the dropdown icon in bottom right (LTR) or bottom left (RTL) - iconSize = layoutChild(dropdownIcon, new BoxConstraints.loose(size)); + iconSize = layoutChild(dropdownIcon, BoxConstraints.loose(size)); positionChild(dropdownIcon, _offsetForIcon(size, iconSize)); } final String bottomLine = hasChild(accountEmail) ? accountEmail : (hasChild(accountName) ? accountName : null); if (bottomLine != null) { - final Size constraintSize = iconSize == null ? size : size - new Offset(iconSize.width, 0.0); + final Size constraintSize = iconSize == null ? size : size - Offset(iconSize.width, 0.0); iconSize ??= const Size(_kAccountDetailsHeight, _kAccountDetailsHeight); // place bottom line center at same height as icon center - final Size bottomLineSize = layoutChild(bottomLine, new BoxConstraints.loose(constraintSize)); + final Size bottomLineSize = layoutChild(bottomLine, BoxConstraints.loose(constraintSize)); final Offset bottomLineOffset = _offsetForBottomLine(size, iconSize, bottomLineSize); positionChild(bottomLine, bottomLineOffset); // place account name above account email if (bottomLine == accountEmail && hasChild(accountName)) { - final Size nameSize = layoutChild(accountName, new BoxConstraints.loose(constraintSize)); + final Size nameSize = layoutChild(accountName, BoxConstraints.loose(constraintSize)); positionChild(accountName, _offsetForName(size, nameSize, bottomLineOffset)); } } @@ -207,9 +207,9 @@ class _AccountDetailsLayout extends MultiChildLayoutDelegate { Offset _offsetForIcon(Size size, Size iconSize) { switch (textDirection) { case TextDirection.ltr: - return new Offset(size.width - iconSize.width, size.height - iconSize.height); + return Offset(size.width - iconSize.width, size.height - iconSize.height); case TextDirection.rtl: - return new Offset(0.0, size.height - iconSize.height); + return Offset(0.0, size.height - iconSize.height); } assert(false, 'Unreachable'); return null; @@ -219,9 +219,9 @@ class _AccountDetailsLayout extends MultiChildLayoutDelegate { final double y = size.height - 0.5 * iconSize.height - 0.5 * bottomLineSize.height; switch (textDirection) { case TextDirection.ltr: - return new Offset(0.0, y); + return Offset(0.0, y); case TextDirection.rtl: - return new Offset(size.width - bottomLineSize.width, y); + return Offset(size.width - bottomLineSize.width, y); } assert(false, 'Unreachable'); return null; @@ -231,9 +231,9 @@ class _AccountDetailsLayout extends MultiChildLayoutDelegate { final double y = bottomLineOffset.dy - nameSize.height; switch (textDirection) { case TextDirection.ltr: - return new Offset(0.0, y); + return Offset(0.0, y); case TextDirection.rtl: - return new Offset(size.width - nameSize.width, y); + return Offset(size.width - nameSize.width, y); } assert(false, 'Unreachable'); return null; @@ -292,7 +292,7 @@ class UserAccountsDrawerHeader extends StatefulWidget { final VoidCallback onDetailsPressed; @override - _UserAccountsDrawerHeaderState createState() => new _UserAccountsDrawerHeaderState(); + _UserAccountsDrawerHeaderState createState() => _UserAccountsDrawerHeaderState(); } class _UserAccountsDrawerHeaderState extends State { @@ -308,30 +308,30 @@ class _UserAccountsDrawerHeaderState extends State { @override Widget build(BuildContext context) { assert(debugCheckHasMaterial(context)); - return new Semantics( + return Semantics( container: true, label: MaterialLocalizations.of(context).signedInLabel, - child: new DrawerHeader( - decoration: widget.decoration ?? new BoxDecoration( + child: DrawerHeader( + decoration: widget.decoration ?? BoxDecoration( color: Theme.of(context).primaryColor, ), margin: widget.margin, padding: const EdgeInsetsDirectional.only(top: 16.0, start: 16.0), - child: new SafeArea( + child: SafeArea( bottom: false, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Expanded( - child: new Padding( + Expanded( + child: Padding( padding: const EdgeInsetsDirectional.only(end: 16.0), - child: new _AccountPictures( + child: _AccountPictures( currentAccountPicture: widget.currentAccountPicture, otherAccountsPictures: widget.otherAccountsPictures, ), ) ), - new _AccountDetails( + _AccountDetails( accountName: widget.accountName, accountEmail: widget.accountEmail, isOpen: _isOpen, diff --git a/packages/flutter/lib/src/painting/alignment.dart b/packages/flutter/lib/src/painting/alignment.dart index e2ed3a0a5b..efa2883b40 100644 --- a/packages/flutter/lib/src/painting/alignment.dart +++ b/packages/flutter/lib/src/painting/alignment.dart @@ -40,7 +40,7 @@ abstract class AlignmentGeometry { /// representing a combination of both is returned. That object can be turned /// into a concrete [Alignment] using [resolve]. AlignmentGeometry add(AlignmentGeometry other) { - return new _MixedAlignment( + return _MixedAlignment( _x + other._x, _start + other._start, _y + other._y, @@ -108,7 +108,7 @@ abstract class AlignmentGeometry { return Alignment.lerp(a, b, t); if (a is AlignmentDirectional && b is AlignmentDirectional) return AlignmentDirectional.lerp(a, b, t); - return new _MixedAlignment( + return _MixedAlignment( ui.lerpDouble(a._x, b._x, t), ui.lerpDouble(a._start, b._start, t), ui.lerpDouble(a._y, b._y, t), @@ -251,63 +251,63 @@ class Alignment extends AlignmentGeometry { /// Returns the difference between two [Alignment]s. Alignment operator -(Alignment other) { - return new Alignment(x - other.x, y - other.y); + return Alignment(x - other.x, y - other.y); } /// Returns the sum of two [Alignment]s. Alignment operator +(Alignment other) { - return new Alignment(x + other.x, y + other.y); + return Alignment(x + other.x, y + other.y); } /// Returns the negation of the given [Alignment]. @override Alignment operator -() { - return new Alignment(-x, -y); + return Alignment(-x, -y); } /// Scales the [Alignment] in each dimension by the given factor. @override Alignment operator *(double other) { - return new Alignment(x * other, y * other); + return Alignment(x * other, y * other); } /// Divides the [Alignment] in each dimension by the given factor. @override Alignment operator /(double other) { - return new Alignment(x / other, y / other); + return Alignment(x / other, y / other); } /// Integer divides the [Alignment] in each dimension by the given factor. @override Alignment operator ~/(double other) { - return new Alignment((x ~/ other).toDouble(), (y ~/ other).toDouble()); + return Alignment((x ~/ other).toDouble(), (y ~/ other).toDouble()); } /// Computes the remainder in each dimension by the given factor. @override Alignment operator %(double other) { - return new Alignment(x % other, y % other); + return Alignment(x % other, y % other); } /// Returns the offset that is this fraction in the direction of the given offset. Offset alongOffset(Offset other) { final double centerX = other.dx / 2.0; final double centerY = other.dy / 2.0; - return new Offset(centerX + x * centerX, centerY + y * centerY); + return Offset(centerX + x * centerX, centerY + y * centerY); } /// Returns the offset that is this fraction within the given size. Offset alongSize(Size other) { final double centerX = other.width / 2.0; final double centerY = other.height / 2.0; - return new Offset(centerX + x * centerX, centerY + y * centerY); + return Offset(centerX + x * centerX, centerY + y * centerY); } /// Returns the point that is this fraction within the given rect. Offset withinRect(Rect rect) { final double halfWidth = rect.width / 2.0; final double halfHeight = rect.height / 2.0; - return new Offset( + return Offset( rect.left + halfWidth + x * halfWidth, rect.top + halfHeight + y * halfHeight, ); @@ -322,7 +322,7 @@ class Alignment extends AlignmentGeometry { Rect inscribe(Size size, Rect rect) { final double halfWidthDelta = (rect.width - size.width) / 2.0; final double halfHeightDelta = (rect.height - size.height) / 2.0; - return new Rect.fromLTWH( + return Rect.fromLTWH( rect.left + halfWidthDelta + x * halfWidthDelta, rect.top + halfHeightDelta + y * halfHeightDelta, size.width, @@ -350,10 +350,10 @@ class Alignment extends AlignmentGeometry { if (a == null && b == null) return null; if (a == null) - return new Alignment(ui.lerpDouble(0.0, b.x, t), ui.lerpDouble(0.0, b.y, t)); + return Alignment(ui.lerpDouble(0.0, b.x, t), ui.lerpDouble(0.0, b.y, t)); if (b == null) - return new Alignment(ui.lerpDouble(a.x, 0.0, t), ui.lerpDouble(a.y, 0.0, t)); - return new Alignment(ui.lerpDouble(a.x, b.x, t), ui.lerpDouble(a.y, b.y, t)); + return Alignment(ui.lerpDouble(a.x, 0.0, t), ui.lerpDouble(a.y, 0.0, t)); + return Alignment(ui.lerpDouble(a.x, b.x, t), ui.lerpDouble(a.y, b.y, t)); } @override @@ -483,42 +483,42 @@ class AlignmentDirectional extends AlignmentGeometry { /// Returns the difference between two [AlignmentDirectional]s. AlignmentDirectional operator -(AlignmentDirectional other) { - return new AlignmentDirectional(start - other.start, y - other.y); + return AlignmentDirectional(start - other.start, y - other.y); } /// Returns the sum of two [AlignmentDirectional]s. AlignmentDirectional operator +(AlignmentDirectional other) { - return new AlignmentDirectional(start + other.start, y + other.y); + return AlignmentDirectional(start + other.start, y + other.y); } /// Returns the negation of the given [AlignmentDirectional]. @override AlignmentDirectional operator -() { - return new AlignmentDirectional(-start, -y); + return AlignmentDirectional(-start, -y); } /// Scales the [AlignmentDirectional] in each dimension by the given factor. @override AlignmentDirectional operator *(double other) { - return new AlignmentDirectional(start * other, y * other); + return AlignmentDirectional(start * other, y * other); } /// Divides the [AlignmentDirectional] in each dimension by the given factor. @override AlignmentDirectional operator /(double other) { - return new AlignmentDirectional(start / other, y / other); + return AlignmentDirectional(start / other, y / other); } /// Integer divides the [AlignmentDirectional] in each dimension by the given factor. @override AlignmentDirectional operator ~/(double other) { - return new AlignmentDirectional((start ~/ other).toDouble(), (y ~/ other).toDouble()); + return AlignmentDirectional((start ~/ other).toDouble(), (y ~/ other).toDouble()); } /// Computes the remainder in each dimension by the given factor. @override AlignmentDirectional operator %(double other) { - return new AlignmentDirectional(start % other, y % other); + return AlignmentDirectional(start % other, y % other); } /// Linearly interpolate between two [AlignmentDirectional]s. @@ -541,10 +541,10 @@ class AlignmentDirectional extends AlignmentGeometry { if (a == null && b == null) return null; if (a == null) - return new AlignmentDirectional(ui.lerpDouble(0.0, b.start, t), ui.lerpDouble(0.0, b.y, t)); + return AlignmentDirectional(ui.lerpDouble(0.0, b.start, t), ui.lerpDouble(0.0, b.y, t)); if (b == null) - return new AlignmentDirectional(ui.lerpDouble(a.start, 0.0, t), ui.lerpDouble(a.y, 0.0, t)); - return new AlignmentDirectional(ui.lerpDouble(a.start, b.start, t), ui.lerpDouble(a.y, b.y, t)); + return AlignmentDirectional(ui.lerpDouble(a.start, 0.0, t), ui.lerpDouble(a.y, 0.0, t)); + return AlignmentDirectional(ui.lerpDouble(a.start, b.start, t), ui.lerpDouble(a.y, b.y, t)); } @override @@ -552,9 +552,9 @@ class AlignmentDirectional extends AlignmentGeometry { assert(direction != null); switch (direction) { case TextDirection.rtl: - return new Alignment(-start, y); + return Alignment(-start, y); case TextDirection.ltr: - return new Alignment(start, y); + return Alignment(start, y); } return null; } @@ -600,7 +600,7 @@ class _MixedAlignment extends AlignmentGeometry { @override _MixedAlignment operator -() { - return new _MixedAlignment( + return _MixedAlignment( -_x, -_start, -_y, @@ -609,7 +609,7 @@ class _MixedAlignment extends AlignmentGeometry { @override _MixedAlignment operator *(double other) { - return new _MixedAlignment( + return _MixedAlignment( _x * other, _start * other, _y * other, @@ -618,7 +618,7 @@ class _MixedAlignment extends AlignmentGeometry { @override _MixedAlignment operator /(double other) { - return new _MixedAlignment( + return _MixedAlignment( _x / other, _start / other, _y / other, @@ -627,7 +627,7 @@ class _MixedAlignment extends AlignmentGeometry { @override _MixedAlignment operator ~/(double other) { - return new _MixedAlignment( + return _MixedAlignment( (_x ~/ other).toDouble(), (_start ~/ other).toDouble(), (_y ~/ other).toDouble(), @@ -636,7 +636,7 @@ class _MixedAlignment extends AlignmentGeometry { @override _MixedAlignment operator %(double other) { - return new _MixedAlignment( + return _MixedAlignment( _x % other, _start % other, _y % other, @@ -648,9 +648,9 @@ class _MixedAlignment extends AlignmentGeometry { assert(direction != null); switch (direction) { case TextDirection.rtl: - return new Alignment(_x - _start, _y); + return Alignment(_x - _start, _y); case TextDirection.ltr: - return new Alignment(_x + _start, _y); + return Alignment(_x + _start, _y); } return null; } diff --git a/packages/flutter/lib/src/painting/beveled_rectangle_border.dart b/packages/flutter/lib/src/painting/beveled_rectangle_border.dart index fca46b5153..247c8c70d5 100644 --- a/packages/flutter/lib/src/painting/beveled_rectangle_border.dart +++ b/packages/flutter/lib/src/painting/beveled_rectangle_border.dart @@ -43,12 +43,12 @@ class BeveledRectangleBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override ShapeBorder scale(double t) { - return new BeveledRectangleBorder( + return BeveledRectangleBorder( side: side.scale(t), borderRadius: borderRadius * t, ); @@ -58,7 +58,7 @@ class BeveledRectangleBorder extends ShapeBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is BeveledRectangleBorder) { - return new BeveledRectangleBorder( + return BeveledRectangleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: BorderRadius.lerp(a.borderRadius, borderRadius, t), ); @@ -70,7 +70,7 @@ class BeveledRectangleBorder extends ShapeBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { assert(t != null); if (b is BeveledRectangleBorder) { - return new BeveledRectangleBorder( + return BeveledRectangleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: BorderRadius.lerp(borderRadius, b.borderRadius, t), ); @@ -79,10 +79,10 @@ class BeveledRectangleBorder extends ShapeBorder { } Path _getPath(RRect rrect) { - final Offset centerLeft = new Offset(rrect.left, rrect.center.dy); - final Offset centerRight = new Offset(rrect.right, rrect.center.dy); - final Offset centerTop = new Offset(rrect.center.dx, rrect.top); - final Offset centerBottom = new Offset(rrect.center.dx, rrect.bottom); + final Offset centerLeft = Offset(rrect.left, rrect.center.dy); + final Offset centerRight = Offset(rrect.right, rrect.center.dy); + final Offset centerTop = Offset(rrect.center.dx, rrect.top); + final Offset centerBottom = Offset(rrect.center.dx, rrect.bottom); final double tlRadiusX = math.max(0.0, rrect.tlRadiusX); final double tlRadiusY = math.max(0.0, rrect.tlRadiusY); @@ -94,17 +94,17 @@ class BeveledRectangleBorder extends ShapeBorder { final double brRadiusY = math.max(0.0, rrect.brRadiusY); final List vertices = [ - new Offset(rrect.left, math.min(centerLeft.dy, rrect.top + tlRadiusY)), - new Offset(math.min(centerTop.dx, rrect.left + tlRadiusX), rrect.top), - new Offset(math.max(centerTop.dx, rrect.right -trRadiusX), rrect.top), - new Offset(rrect.right, math.min(centerRight.dy, rrect.top + trRadiusY)), - new Offset(rrect.right, math.max(centerRight.dy, rrect.bottom - brRadiusY)), - new Offset(math.max(centerBottom.dx, rrect.right - brRadiusX), rrect.bottom), - new Offset(math.min(centerBottom.dx, rrect.left + blRadiusX), rrect.bottom), - new Offset(rrect.left, math.max(centerLeft.dy, rrect.bottom - blRadiusY)), + Offset(rrect.left, math.min(centerLeft.dy, rrect.top + tlRadiusY)), + Offset(math.min(centerTop.dx, rrect.left + tlRadiusX), rrect.top), + Offset(math.max(centerTop.dx, rrect.right -trRadiusX), rrect.top), + Offset(rrect.right, math.min(centerRight.dy, rrect.top + trRadiusY)), + Offset(rrect.right, math.max(centerRight.dy, rrect.bottom - brRadiusY)), + Offset(math.max(centerBottom.dx, rrect.right - brRadiusX), rrect.bottom), + Offset(math.min(centerBottom.dx, rrect.left + blRadiusX), rrect.bottom), + Offset(rrect.left, math.max(centerLeft.dy, rrect.bottom - blRadiusY)), ]; - return new Path()..addPolygon(vertices, true); + return Path()..addPolygon(vertices, true); } @override diff --git a/packages/flutter/lib/src/painting/binding.dart b/packages/flutter/lib/src/painting/binding.dart index 33b6c67085..34ac70d0d7 100644 --- a/packages/flutter/lib/src/painting/binding.dart +++ b/packages/flutter/lib/src/painting/binding.dart @@ -42,7 +42,7 @@ abstract class PaintingBinding extends BindingBase with ServicesBinding { /// /// This method can be overridden to provide a custom image cache. @protected - ImageCache createImageCache() => new ImageCache(); + ImageCache createImageCache() => ImageCache(); @override void evict(String asset) { diff --git a/packages/flutter/lib/src/painting/border_radius.dart b/packages/flutter/lib/src/painting/border_radius.dart index ee0bc61f53..ef244f91f1 100644 --- a/packages/flutter/lib/src/painting/border_radius.dart +++ b/packages/flutter/lib/src/painting/border_radius.dart @@ -46,7 +46,7 @@ abstract class BorderRadiusGeometry { /// negating the argument (using the prefix unary `-` operator or multiplying /// the argument by -1.0 using the `*` operator). BorderRadiusGeometry subtract(BorderRadiusGeometry other) { - return new _MixedBorderRadius( + return _MixedBorderRadius( _topLeft - other._topLeft, _topRight - other._topRight, _bottomLeft - other._bottomLeft, @@ -70,7 +70,7 @@ abstract class BorderRadiusGeometry { /// representing a combination of both is returned. That object can be turned /// into a concrete [BorderRadius] using [resolve]. BorderRadiusGeometry add(BorderRadiusGeometry other) { - return new _MixedBorderRadius( + return _MixedBorderRadius( _topLeft + other._topLeft, _topRight + other._topRight, _bottomLeft + other._bottomLeft, @@ -173,7 +173,7 @@ abstract class BorderRadiusGeometry { } } else { // visuals aren't the same and at least one isn't zero - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); result.write('BorderRadius.only('); bool comma = false; if (_topLeft != Radius.zero) { @@ -212,7 +212,7 @@ abstract class BorderRadiusGeometry { } } else { // logicals aren't the same and at least one isn't zero - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); result.write('BorderRadiusDirectional.only('); bool comma = false; if (_topStart != Radius.zero) { @@ -300,7 +300,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Creates a border radius where all radii are [Radius.circular(radius)]. BorderRadius.circular(double radius) : this.all( - new Radius.circular(radius), + Radius.circular(radius), ); /// Creates a vertically symmetric border radius where the top and bottom @@ -377,7 +377,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Creates an [RRect] from the current border radius and a [Rect]. RRect toRRect(Rect rect) { - return new RRect.fromRectAndCorners( + return RRect.fromRectAndCorners( rect, topLeft: topLeft, topRight: topRight, @@ -402,7 +402,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Returns the difference between two [BorderRadius] objects. BorderRadius operator -(BorderRadius other) { - return new BorderRadius.only( + return BorderRadius.only( topLeft: topLeft - other.topLeft, topRight: topRight - other.topRight, bottomLeft: bottomLeft - other.bottomLeft, @@ -412,7 +412,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Returns the sum of two [BorderRadius] objects. BorderRadius operator +(BorderRadius other) { - return new BorderRadius.only( + return BorderRadius.only( topLeft: topLeft + other.topLeft, topRight: topRight + other.topRight, bottomLeft: bottomLeft + other.bottomLeft, @@ -425,7 +425,7 @@ class BorderRadius extends BorderRadiusGeometry { /// This is the same as multiplying the object by -1.0. @override BorderRadius operator -() { - return new BorderRadius.only( + return BorderRadius.only( topLeft: -topLeft, topRight: -topRight, bottomLeft: -bottomLeft, @@ -436,7 +436,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Scales each corner of the [BorderRadius] by the given factor. @override BorderRadius operator *(double other) { - return new BorderRadius.only( + return BorderRadius.only( topLeft: topLeft * other, topRight: topRight * other, bottomLeft: bottomLeft * other, @@ -447,7 +447,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Divides each corner of the [BorderRadius] by the given factor. @override BorderRadius operator /(double other) { - return new BorderRadius.only( + return BorderRadius.only( topLeft: topLeft / other, topRight: topRight / other, bottomLeft: bottomLeft / other, @@ -458,7 +458,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Integer divides each corner of the [BorderRadius] by the given factor. @override BorderRadius operator ~/(double other) { - return new BorderRadius.only( + return BorderRadius.only( topLeft: topLeft ~/ other, topRight: topRight ~/ other, bottomLeft: bottomLeft ~/ other, @@ -469,7 +469,7 @@ class BorderRadius extends BorderRadiusGeometry { /// Computes the remainder of each corner by the given factor. @override BorderRadius operator %(double other) { - return new BorderRadius.only( + return BorderRadius.only( topLeft: topLeft % other, topRight: topRight % other, bottomLeft: bottomLeft % other, @@ -500,7 +500,7 @@ class BorderRadius extends BorderRadiusGeometry { return b * t; if (b == null) return a * (1.0 - t); - return new BorderRadius.only( + return BorderRadius.only( topLeft: Radius.lerp(a.topLeft, b.topLeft, t), topRight: Radius.lerp(a.topRight, b.topRight, t), bottomLeft: Radius.lerp(a.bottomLeft, b.bottomLeft, t), @@ -535,7 +535,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Creates a border radius where all radii are [Radius.circular(radius)]. BorderRadiusDirectional.circular(double radius) : this.all( - new Radius.circular(radius), + Radius.circular(radius), ); /// Creates a vertically symmetric border radius where the top and bottom @@ -629,7 +629,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Returns the difference between two [BorderRadiusDirectional] objects. BorderRadiusDirectional operator -(BorderRadiusDirectional other) { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: topStart - other.topStart, topEnd: topEnd - other.topEnd, bottomStart: bottomStart - other.bottomStart, @@ -639,7 +639,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Returns the sum of two [BorderRadiusDirectional] objects. BorderRadiusDirectional operator +(BorderRadiusDirectional other) { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: topStart + other.topStart, topEnd: topEnd + other.topEnd, bottomStart: bottomStart + other.bottomStart, @@ -652,7 +652,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// This is the same as multiplying the object by -1.0. @override BorderRadiusDirectional operator -() { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: -topStart, topEnd: -topEnd, bottomStart: -bottomStart, @@ -663,7 +663,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Scales each corner of the [BorderRadiusDirectional] by the given factor. @override BorderRadiusDirectional operator *(double other) { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: topStart * other, topEnd: topEnd * other, bottomStart: bottomStart * other, @@ -674,7 +674,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Divides each corner of the [BorderRadiusDirectional] by the given factor. @override BorderRadiusDirectional operator /(double other) { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: topStart / other, topEnd: topEnd / other, bottomStart: bottomStart / other, @@ -685,7 +685,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Integer divides each corner of the [BorderRadiusDirectional] by the given factor. @override BorderRadiusDirectional operator ~/(double other) { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: topStart ~/ other, topEnd: topEnd ~/ other, bottomStart: bottomStart ~/ other, @@ -696,7 +696,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { /// Computes the remainder of each corner by the given factor. @override BorderRadiusDirectional operator %(double other) { - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: topStart % other, topEnd: topEnd % other, bottomStart: bottomStart % other, @@ -727,7 +727,7 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { return b * t; if (b == null) return a * (1.0 - t); - return new BorderRadiusDirectional.only( + return BorderRadiusDirectional.only( topStart: Radius.lerp(a.topStart, b.topStart, t), topEnd: Radius.lerp(a.topEnd, b.topEnd, t), bottomStart: Radius.lerp(a.bottomStart, b.bottomStart, t), @@ -740,14 +740,14 @@ class BorderRadiusDirectional extends BorderRadiusGeometry { assert(direction != null); switch (direction) { case TextDirection.rtl: - return new BorderRadius.only( + return BorderRadius.only( topLeft: topEnd, topRight: topStart, bottomLeft: bottomEnd, bottomRight: bottomStart, ); case TextDirection.ltr: - return new BorderRadius.only( + return BorderRadius.only( topLeft: topStart, topRight: topEnd, bottomLeft: bottomStart, @@ -796,7 +796,7 @@ class _MixedBorderRadius extends BorderRadiusGeometry { @override _MixedBorderRadius operator -() { - return new _MixedBorderRadius( + return _MixedBorderRadius( -_topLeft, -_topRight, -_bottomLeft, @@ -811,7 +811,7 @@ class _MixedBorderRadius extends BorderRadiusGeometry { /// Scales each corner of the [_MixedBorderRadius] by the given factor. @override _MixedBorderRadius operator *(double other) { - return new _MixedBorderRadius( + return _MixedBorderRadius( _topLeft * other, _topRight * other, _bottomLeft * other, @@ -825,7 +825,7 @@ class _MixedBorderRadius extends BorderRadiusGeometry { @override _MixedBorderRadius operator /(double other) { - return new _MixedBorderRadius( + return _MixedBorderRadius( _topLeft / other, _topRight / other, _bottomLeft / other, @@ -839,7 +839,7 @@ class _MixedBorderRadius extends BorderRadiusGeometry { @override _MixedBorderRadius operator ~/(double other) { - return new _MixedBorderRadius( + return _MixedBorderRadius( _topLeft ~/ other, _topRight ~/ other, _bottomLeft ~/ other, @@ -853,7 +853,7 @@ class _MixedBorderRadius extends BorderRadiusGeometry { @override _MixedBorderRadius operator %(double other) { - return new _MixedBorderRadius( + return _MixedBorderRadius( _topLeft % other, _topRight % other, _bottomLeft % other, @@ -870,14 +870,14 @@ class _MixedBorderRadius extends BorderRadiusGeometry { assert(direction != null); switch (direction) { case TextDirection.rtl: - return new BorderRadius.only( + return BorderRadius.only( topLeft: _topLeft + _topEnd, topRight: _topRight + _topStart, bottomLeft: _bottomLeft + _bottomEnd, bottomRight: _bottomRight + _bottomStart, ); case TextDirection.ltr: - return new BorderRadius.only( + return BorderRadius.only( topLeft: _topLeft + _topStart, topRight: _topRight + _topEnd, bottomLeft: _bottomLeft + _bottomStart, diff --git a/packages/flutter/lib/src/painting/borders.dart b/packages/flutter/lib/src/painting/borders.dart index d1b4311312..99e61a54b7 100644 --- a/packages/flutter/lib/src/painting/borders.dart +++ b/packages/flutter/lib/src/painting/borders.dart @@ -92,7 +92,7 @@ class BorderSide { return a; assert(a.color == b.color); assert(a.style == b.style); - return new BorderSide( + return BorderSide( color: a.color, // == b.color width: a.width + b.width, style: a.style, // == b.style @@ -123,7 +123,7 @@ class BorderSide { BorderStyle style }) { assert(width == null || width >= 0.0); - return new BorderSide( + return BorderSide( color: color ?? this.color, width: width ?? this.width, style: style ?? this.style, @@ -148,7 +148,7 @@ class BorderSide { /// an [AnimationController]. BorderSide scale(double t) { assert(t != null); - return new BorderSide( + return BorderSide( color: color, width: math.max(0.0, width * t), style: t <= 0.0 ? BorderStyle.none : style, @@ -164,12 +164,12 @@ class BorderSide { Paint toPaint() { switch (style) { case BorderStyle.solid: - return new Paint() + return Paint() ..color = color ..strokeWidth = width ..style = PaintingStyle.stroke; case BorderStyle.none: - return new Paint() + return Paint() ..color = const Color(0x00000000) ..strokeWidth = 0.0 ..style = PaintingStyle.stroke; @@ -221,7 +221,7 @@ class BorderSide { if (width < 0.0) return BorderSide.none; if (a.style == b.style) { - return new BorderSide( + return BorderSide( color: Color.lerp(a.color, b.color, t), width: width, style: a.style, // == b.style @@ -244,7 +244,7 @@ class BorderSide { colorB = b.color.withAlpha(0x00); break; } - return new BorderSide( + return BorderSide( color: Color.lerp(colorA, colorB, t), width: width, style: BorderStyle.solid, @@ -317,7 +317,7 @@ abstract class ShapeBorder { /// merely paints the two borders sequentially, with the left hand operand on /// the inside and the right hand operand on the outside. ShapeBorder operator +(ShapeBorder other) { - return add(other) ?? other.add(this, reversed: true) ?? new _CompoundBorder([other, this]); + return add(other) ?? other.add(this, reversed: true) ?? _CompoundBorder([other, this]); } /// Creates a copy of this border, scaled by the factor `t`. @@ -530,7 +530,7 @@ class _CompoundBorder extends ShapeBorder { final List result = []; result.addAll(borders); result[reversed ? result.length - 1 : 0] = merged; - return new _CompoundBorder(result); + return _CompoundBorder(result); } } // We can't, so fall back to just adding the new border to the list. @@ -543,12 +543,12 @@ class _CompoundBorder extends ShapeBorder { mergedBorders.add(other); if (!reversed) mergedBorders.addAll(borders); - return new _CompoundBorder(mergedBorders); + return _CompoundBorder(mergedBorders); } @override ShapeBorder scale(double t) { - return new _CompoundBorder( + return _CompoundBorder( borders.map((ShapeBorder border) => border.scale(t)).toList() ); } @@ -589,7 +589,7 @@ class _CompoundBorder extends ShapeBorder { if (localA != null) results.add(localA.scale(1.0 - t)); } - return new _CompoundBorder(results); + return _CompoundBorder(results); } @override @@ -676,10 +676,10 @@ void paintBorder(Canvas canvas, Rect rect, { // We draw the borders as filled shapes, unless the borders are hairline // borders, in which case we use PaintingStyle.stroke, with the stroke width // specified here. - final Paint paint = new Paint() + final Paint paint = Paint() ..strokeWidth = 0.0; - final Path path = new Path(); + final Path path = Path(); switch (top.style) { case BorderStyle.solid: diff --git a/packages/flutter/lib/src/painting/box_border.dart b/packages/flutter/lib/src/painting/box_border.dart index 6814b9da62..76daa9a238 100644 --- a/packages/flutter/lib/src/painting/box_border.dart +++ b/packages/flutter/lib/src/painting/box_border.dart @@ -125,7 +125,7 @@ abstract class BoxBorder extends ShapeBorder { if (a is Border && b is BorderDirectional) { if (b.start == BorderSide.none && b.end == BorderSide.none) { // The fact that b is a BorderDirectional really doesn't matter, it turns out. - return new Border( + return Border( top: BorderSide.lerp(a.top, b.top, t), right: BorderSide.lerp(a.right, BorderSide.none, t), bottom: BorderSide.lerp(a.bottom, b.bottom, t), @@ -134,7 +134,7 @@ abstract class BoxBorder extends ShapeBorder { } if (a.left == BorderSide.none && a.right == BorderSide.none) { // The fact that a is a Border really doesn't matter, it turns out. - return new BorderDirectional( + return BorderDirectional( top: BorderSide.lerp(a.top, b.top, t), start: BorderSide.lerp(BorderSide.none, b.start, t), end: BorderSide.lerp(BorderSide.none, b.end, t), @@ -145,21 +145,21 @@ abstract class BoxBorder extends ShapeBorder { // we speed up the horizontal sides' transitions and switch from // one mode to the other at t=0.5. if (t < 0.5) { - return new Border( + return Border( top: BorderSide.lerp(a.top, b.top, t), right: BorderSide.lerp(a.right, BorderSide.none, t * 2.0), bottom: BorderSide.lerp(a.bottom, b.bottom, t), left: BorderSide.lerp(a.left, BorderSide.none, t * 2.0), ); } - return new BorderDirectional( + return BorderDirectional( top: BorderSide.lerp(a.top, b.top, t), start: BorderSide.lerp(BorderSide.none, b.start, (t - 0.5) * 2.0), end: BorderSide.lerp(BorderSide.none, b.end, (t - 0.5) * 2.0), bottom: BorderSide.lerp(a.bottom, b.bottom, t), ); } - throw new FlutterError( + throw FlutterError( 'BoxBorder.lerp can only interpolate Border and BorderDirectional classes.\n' 'BoxBorder.lerp() was called with two objects of type ${a.runtimeType} and ${b.runtimeType}:\n' ' $a\n' @@ -172,14 +172,14 @@ abstract class BoxBorder extends ShapeBorder { @override Path getInnerPath(Rect rect, { @required TextDirection textDirection }) { assert(textDirection != null, 'The textDirection argument to $runtimeType.getInnerPath must not be null.'); - return new Path() + return Path() ..addRect(dimensions.resolve(textDirection).deflateRect(rect)); } @override Path getOuterPath(Rect rect, { @required TextDirection textDirection }) { assert(textDirection != null, 'The textDirection argument to $runtimeType.getOuterPath must not be null.'); - return new Path() + return Path() ..addRect(rect); } @@ -211,7 +211,7 @@ abstract class BoxBorder extends ShapeBorder { static void _paintUniformBorderWithRadius(Canvas canvas, Rect rect, BorderSide side, BorderRadius borderRadius) { assert(side.style != BorderStyle.none); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = side.color; final RRect outer = borderRadius.toRRect(rect); final double width = side.width; @@ -322,8 +322,8 @@ class Border extends BoxBorder { double width = 1.0, BorderStyle style = BorderStyle.solid, }) { - final BorderSide side = new BorderSide(color: color, width: width, style: style); - return new Border(top: side, right: side, bottom: side, left: side); + final BorderSide side = BorderSide(color: color, width: width, style: style); + return Border(top: side, right: side, bottom: side, left: side); } /// Creates a [Border] that represents the addition of the two given @@ -340,7 +340,7 @@ class Border extends BoxBorder { assert(BorderSide.canMerge(a.right, b.right)); assert(BorderSide.canMerge(a.bottom, b.bottom)); assert(BorderSide.canMerge(a.left, b.left)); - return new Border( + return Border( top: BorderSide.merge(a.top, b.top), right: BorderSide.merge(a.right, b.right), bottom: BorderSide.merge(a.bottom, b.bottom), @@ -362,7 +362,7 @@ class Border extends BoxBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.fromLTRB(left.width, top.width, right.width, bottom.width); + return EdgeInsets.fromLTRB(left.width, top.width, right.width, bottom.width); } @override @@ -404,7 +404,7 @@ class Border extends BoxBorder { @override Border scale(double t) { - return new Border( + return Border( top: top.scale(t), right: right.scale(t), bottom: bottom.scale(t), @@ -450,7 +450,7 @@ class Border extends BoxBorder { return b.scale(t); if (b == null) return a.scale(1.0 - t); - return new Border( + return Border( top: BorderSide.lerp(a.top, b.top, t), right: BorderSide.lerp(a.right, b.right, t), bottom: BorderSide.lerp(a.bottom, b.bottom, t), @@ -597,7 +597,7 @@ class BorderDirectional extends BoxBorder { assert(BorderSide.canMerge(a.start, b.start)); assert(BorderSide.canMerge(a.end, b.end)); assert(BorderSide.canMerge(a.bottom, b.bottom)); - return new BorderDirectional( + return BorderDirectional( top: BorderSide.merge(a.top, b.top), start: BorderSide.merge(a.start, b.start), end: BorderSide.merge(a.end, b.end), @@ -633,7 +633,7 @@ class BorderDirectional extends BoxBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsetsDirectional.fromSTEB(start.width, top.width, end.width, bottom.width); + return EdgeInsetsDirectional.fromSTEB(start.width, top.width, end.width, bottom.width); } @override @@ -683,7 +683,7 @@ class BorderDirectional extends BoxBorder { return null; assert(typedOther.left == BorderSide.none); assert(typedOther.right == BorderSide.none); - return new BorderDirectional( + return BorderDirectional( top: BorderSide.merge(typedOther.top, top), start: start, end: end, @@ -692,7 +692,7 @@ class BorderDirectional extends BoxBorder { } assert(start == BorderSide.none); assert(end == BorderSide.none); - return new Border( + return Border( top: BorderSide.merge(typedOther.top, top), right: typedOther.right, bottom: BorderSide.merge(typedOther.bottom, bottom), @@ -704,7 +704,7 @@ class BorderDirectional extends BoxBorder { @override BorderDirectional scale(double t) { - return new BorderDirectional( + return BorderDirectional( top: top.scale(t), start: start.scale(t), end: end.scale(t), @@ -750,7 +750,7 @@ class BorderDirectional extends BoxBorder { return b.scale(t); if (b == null) return a.scale(1.0 - t); - return new BorderDirectional( + return BorderDirectional( top: BorderSide.lerp(a.top, b.top, t), end: BorderSide.lerp(a.end, b.end, t), bottom: BorderSide.lerp(a.bottom, b.bottom, t), diff --git a/packages/flutter/lib/src/painting/box_decoration.dart b/packages/flutter/lib/src/painting/box_decoration.dart index f4f7e61ed5..c3f0166579 100644 --- a/packages/flutter/lib/src/painting/box_decoration.dart +++ b/packages/flutter/lib/src/painting/box_decoration.dart @@ -170,7 +170,7 @@ class BoxDecoration extends Decoration { /// Returns a new box decoration that is scaled by the given factor. BoxDecoration scale(double factor) { - return new BoxDecoration( + return BoxDecoration( color: Color.lerp(null, color, factor), image: image, // TODO(ianh): fade the image from transparent border: BoxBorder.lerp(null, border, factor), @@ -247,7 +247,7 @@ class BoxDecoration extends Decoration { return a; if (t == 1.0) return b; - return new BoxDecoration( + return BoxDecoration( color: Color.lerp(a.color, b.color, t), image: t < 0.5 ? a.image : b.image, // TODO(ianh): cross-fade the image border: BoxBorder.lerp(a.border, b.border, t), @@ -294,13 +294,13 @@ class BoxDecoration extends Decoration { ..defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace ..emptyBodyDescription = ''; - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('image', image, defaultValue: null)); - properties.add(new DiagnosticsProperty('border', border, defaultValue: null)); - properties.add(new DiagnosticsProperty('borderRadius', borderRadius, defaultValue: null)); - properties.add(new IterableProperty('boxShadow', boxShadow, defaultValue: null, style: DiagnosticsTreeStyle.whitespace)); - properties.add(new DiagnosticsProperty('gradient', gradient, defaultValue: null)); - properties.add(new EnumProperty('shape', shape, defaultValue: BoxShape.rectangle)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('image', image, defaultValue: null)); + properties.add(DiagnosticsProperty('border', border, defaultValue: null)); + properties.add(DiagnosticsProperty('borderRadius', borderRadius, defaultValue: null)); + properties.add(IterableProperty('boxShadow', boxShadow, defaultValue: null, style: DiagnosticsTreeStyle.whitespace)); + properties.add(DiagnosticsProperty('gradient', gradient, defaultValue: null)); + properties.add(EnumProperty('shape', shape, defaultValue: BoxShape.rectangle)); } @override @@ -327,7 +327,7 @@ class BoxDecoration extends Decoration { @override _BoxDecorationPainter createBoxPainter([VoidCallback onChanged]) { assert(onChanged != null || image == null); - return new _BoxDecorationPainter(this, onChanged); + return _BoxDecorationPainter(this, onChanged); } } @@ -347,7 +347,7 @@ class _BoxDecorationPainter extends BoxPainter { if (_cachedBackgroundPaint == null || (_decoration.gradient != null && _rectForCachedBackgroundPaint != rect)) { - final Paint paint = new Paint(); + final Paint paint = Paint(); if (_decoration.backgroundBlendMode != null) paint.blendMode = _decoration.backgroundBlendMode; if (_decoration.color != null) @@ -403,11 +403,11 @@ class _BoxDecorationPainter extends BoxPainter { Path clipPath; switch (_decoration.shape) { case BoxShape.circle: - clipPath = new Path()..addOval(rect); + clipPath = Path()..addOval(rect); break; case BoxShape.rectangle: if (_decoration.borderRadius != null) - clipPath = new Path()..addRRect(_decoration.borderRadius.resolve(configuration.textDirection).toRRect(rect)); + clipPath = Path()..addRRect(_decoration.borderRadius.resolve(configuration.textDirection).toRRect(rect)); break; } _imagePainter.paint(canvas, rect, clipPath, configuration); diff --git a/packages/flutter/lib/src/painting/box_fit.dart b/packages/flutter/lib/src/painting/box_fit.dart index a0638c02c4..236e6dc76b 100644 --- a/packages/flutter/lib/src/painting/box_fit.dart +++ b/packages/flutter/lib/src/painting/box_fit.dart @@ -137,28 +137,28 @@ FittedSizes applyBoxFit(BoxFit fit, Size inputSize, Size outputSize) { case BoxFit.contain: sourceSize = inputSize; if (outputSize.width / outputSize.height > sourceSize.width / sourceSize.height) - destinationSize = new Size(sourceSize.width * outputSize.height / sourceSize.height, outputSize.height); + destinationSize = Size(sourceSize.width * outputSize.height / sourceSize.height, outputSize.height); else - destinationSize = new Size(outputSize.width, sourceSize.height * outputSize.width / sourceSize.width); + destinationSize = Size(outputSize.width, sourceSize.height * outputSize.width / sourceSize.width); break; case BoxFit.cover: if (outputSize.width / outputSize.height > inputSize.width / inputSize.height) { - sourceSize = new Size(inputSize.width, inputSize.width * outputSize.height / outputSize.width); + sourceSize = Size(inputSize.width, inputSize.width * outputSize.height / outputSize.width); } else { - sourceSize = new Size(inputSize.height * outputSize.width / outputSize.height, inputSize.height); + sourceSize = Size(inputSize.height * outputSize.width / outputSize.height, inputSize.height); } destinationSize = outputSize; break; case BoxFit.fitWidth: - sourceSize = new Size(inputSize.width, inputSize.width * outputSize.height / outputSize.width); - destinationSize = new Size(outputSize.width, sourceSize.height * outputSize.width / sourceSize.width); + sourceSize = Size(inputSize.width, inputSize.width * outputSize.height / outputSize.width); + destinationSize = Size(outputSize.width, sourceSize.height * outputSize.width / sourceSize.width); break; case BoxFit.fitHeight: - sourceSize = new Size(inputSize.height * outputSize.width / outputSize.height, inputSize.height); - destinationSize = new Size(sourceSize.width * outputSize.height / sourceSize.height, outputSize.height); + sourceSize = Size(inputSize.height * outputSize.width / outputSize.height, inputSize.height); + destinationSize = Size(sourceSize.width * outputSize.height / sourceSize.height, outputSize.height); break; case BoxFit.none: - sourceSize = new Size(math.min(inputSize.width, outputSize.width), + sourceSize = Size(math.min(inputSize.width, outputSize.width), math.min(inputSize.height, outputSize.height)); destinationSize = sourceSize; break; @@ -167,10 +167,10 @@ FittedSizes applyBoxFit(BoxFit fit, Size inputSize, Size outputSize) { destinationSize = inputSize; final double aspectRatio = inputSize.width / inputSize.height; if (destinationSize.height > outputSize.height) - destinationSize = new Size(outputSize.height * aspectRatio, outputSize.height); + destinationSize = Size(outputSize.height * aspectRatio, outputSize.height); if (destinationSize.width > outputSize.width) - destinationSize = new Size(outputSize.width, outputSize.width / aspectRatio); + destinationSize = Size(outputSize.width, outputSize.width / aspectRatio); break; } - return new FittedSizes(sourceSize, destinationSize); + return FittedSizes(sourceSize, destinationSize); } diff --git a/packages/flutter/lib/src/painting/box_shadow.dart b/packages/flutter/lib/src/painting/box_shadow.dart index f78b8d058e..dce0c53580 100644 --- a/packages/flutter/lib/src/painting/box_shadow.dart +++ b/packages/flutter/lib/src/painting/box_shadow.dart @@ -67,9 +67,9 @@ class BoxShadow { /// in every direction and then translated by [offset] before being filled using /// this [Paint]. Paint toPaint() { - final Paint result = new Paint() + final Paint result = Paint() ..color = color - ..maskFilter = new MaskFilter.blur(BlurStyle.normal, blurSigma); + ..maskFilter = MaskFilter.blur(BlurStyle.normal, blurSigma); assert(() { if (debugDisableShadows) result.maskFilter = null; @@ -80,7 +80,7 @@ class BoxShadow { /// Returns a new box shadow with its offset, blurRadius, and spreadRadius scaled by the given factor. BoxShadow scale(double factor) { - return new BoxShadow( + return BoxShadow( color: color, offset: offset * factor, blurRadius: blurRadius * factor, @@ -113,7 +113,7 @@ class BoxShadow { return b.scale(t); if (b == null) return a.scale(1.0 - t); - return new BoxShadow( + return BoxShadow( color: Color.lerp(a.color, b.color, t), offset: Offset.lerp(a.offset, b.offset, t), blurRadius: ui.lerpDouble(a.blurRadius, b.blurRadius, t), diff --git a/packages/flutter/lib/src/painting/circle_border.dart b/packages/flutter/lib/src/painting/circle_border.dart index 76396c23c3..31322a3ac7 100644 --- a/packages/flutter/lib/src/painting/circle_border.dart +++ b/packages/flutter/lib/src/painting/circle_border.dart @@ -32,30 +32,30 @@ class CircleBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override - ShapeBorder scale(double t) => new CircleBorder(side: side.scale(t)); + ShapeBorder scale(double t) => CircleBorder(side: side.scale(t)); @override ShapeBorder lerpFrom(ShapeBorder a, double t) { if (a is CircleBorder) - return new CircleBorder(side: BorderSide.lerp(a.side, side, t)); + return CircleBorder(side: BorderSide.lerp(a.side, side, t)); return super.lerpFrom(a, t); } @override ShapeBorder lerpTo(ShapeBorder b, double t) { if (b is CircleBorder) - return new CircleBorder(side: BorderSide.lerp(side, b.side, t)); + return CircleBorder(side: BorderSide.lerp(side, b.side, t)); return super.lerpTo(b, t); } @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() - ..addOval(new Rect.fromCircle( + return Path() + ..addOval(Rect.fromCircle( center: rect.center, radius: math.max(0.0, rect.shortestSide / 2.0 - side.width), )); @@ -63,8 +63,8 @@ class CircleBorder extends ShapeBorder { @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() - ..addOval(new Rect.fromCircle( + return Path() + ..addOval(Rect.fromCircle( center: rect.center, radius: rect.shortestSide / 2.0, )); diff --git a/packages/flutter/lib/src/painting/clip.dart b/packages/flutter/lib/src/painting/clip.dart index f756931dfb..91022a19f7 100644 --- a/packages/flutter/lib/src/painting/clip.dart +++ b/packages/flutter/lib/src/painting/clip.dart @@ -23,7 +23,7 @@ abstract class ClipContext { break; case Clip.antiAliasWithSaveLayer: canvasClipCall(true); - canvas.saveLayer(bounds, new Paint()); + canvas.saveLayer(bounds, Paint()); break; } painter(); diff --git a/packages/flutter/lib/src/painting/colors.dart b/packages/flutter/lib/src/painting/colors.dart index 56cc6ae355..d0ccd83e96 100644 --- a/packages/flutter/lib/src/painting/colors.dart +++ b/packages/flutter/lib/src/painting/colors.dart @@ -59,7 +59,7 @@ Color _colorFromHue( green = 0.0; blue = secondary; } - return new Color.fromARGB((alpha * 0xFF).round(), ((red + match) * 0xFF).round(), ((green + match) * 0xFF).round(), ((blue + match) * 0xFF).round()); + return Color.fromARGB((alpha * 0xFF).round(), ((red + match) * 0xFF).round(), ((green + match) * 0xFF).round(), ((blue + match) * 0xFF).round()); } /// A color represented using [alpha], [hue], [saturation], and [value]. @@ -119,7 +119,7 @@ class HSVColor { final double hue = _getHue(red, green, blue, max, delta); final double saturation = max == 0.0 ? 0.0 : delta / max; - return new HSVColor.fromAHSV(alpha, hue, saturation, max); + return HSVColor.fromAHSV(alpha, hue, saturation, max); } /// Alpha, from 0.0 to 1.0. The describes the transparency of the color. @@ -147,25 +147,25 @@ class HSVColor { /// Returns a copy of this color with the [alpha] parameter replaced with the /// given value. HSVColor withAlpha(double alpha) { - return new HSVColor.fromAHSV(alpha, hue, saturation, value); + return HSVColor.fromAHSV(alpha, hue, saturation, value); } /// Returns a copy of this color with the [hue] parameter replaced with the /// given value. HSVColor withHue(double hue) { - return new HSVColor.fromAHSV(alpha, hue, saturation, value); + return HSVColor.fromAHSV(alpha, hue, saturation, value); } /// Returns a copy of this color with the [saturation] parameter replaced with /// the given value. HSVColor withSaturation(double saturation) { - return new HSVColor.fromAHSV(alpha, hue, saturation, value); + return HSVColor.fromAHSV(alpha, hue, saturation, value); } /// Returns a copy of this color with the [value] parameter replaced with the /// given value. HSVColor withValue(double value) { - return new HSVColor.fromAHSV(alpha, hue, saturation, value); + return HSVColor.fromAHSV(alpha, hue, saturation, value); } /// Returns this color in RGB. @@ -215,7 +215,7 @@ class HSVColor { return b._scaleAlpha(t); if (b == null) return a._scaleAlpha(1.0 - t); - return new HSVColor.fromAHSV( + return HSVColor.fromAHSV( lerpDouble(a.alpha, b.alpha, t).clamp(0.0, 1.0), lerpDouble(a.hue, b.hue, t) % 360.0, lerpDouble(a.saturation, b.saturation, t).clamp(0.0, 1.0), @@ -303,7 +303,7 @@ class HSLColor { final double saturation = lightness == 1.0 ? 0.0 : (delta / (1.0 - (2.0 * lightness - 1.0).abs())).clamp(0.0, 1.0); - return new HSLColor.fromAHSL(alpha, hue, saturation, lightness); + return HSLColor.fromAHSL(alpha, hue, saturation, lightness); } /// Alpha, from 0.0 to 1.0. The describes the transparency of the color. @@ -333,25 +333,25 @@ class HSLColor { /// Returns a copy of this color with the alpha parameter replaced with the /// given value. HSLColor withAlpha(double alpha) { - return new HSLColor.fromAHSL(alpha, hue, saturation, lightness); + return HSLColor.fromAHSL(alpha, hue, saturation, lightness); } /// Returns a copy of this color with the [hue] parameter replaced with the /// given value. HSLColor withHue(double hue) { - return new HSLColor.fromAHSL(alpha, hue, saturation, lightness); + return HSLColor.fromAHSL(alpha, hue, saturation, lightness); } /// Returns a copy of this color with the [saturation] parameter replaced with /// the given value. HSLColor withSaturation(double saturation) { - return new HSLColor.fromAHSL(alpha, hue, saturation, lightness); + return HSLColor.fromAHSL(alpha, hue, saturation, lightness); } /// Returns a copy of this color with the [lightness] parameter replaced with /// the given value. HSLColor withLightness(double lightness) { - return new HSLColor.fromAHSL(alpha, hue, saturation, lightness); + return HSLColor.fromAHSL(alpha, hue, saturation, lightness); } /// Returns this HSL color in RGB. @@ -401,7 +401,7 @@ class HSLColor { return b._scaleAlpha(t); if (b == null) return a._scaleAlpha(1.0 - t); - return new HSLColor.fromAHSL( + return HSLColor.fromAHSL( lerpDouble(a.alpha, b.alpha, t).clamp(0.0, 1.0), lerpDouble(a.hue, b.hue, t) % 360.0, lerpDouble(a.saturation, b.saturation, t).clamp(0.0, 1.0), diff --git a/packages/flutter/lib/src/painting/debug.dart b/packages/flutter/lib/src/painting/debug.dart index aff174a234..8315a5e760 100644 --- a/packages/flutter/lib/src/painting/debug.dart +++ b/packages/flutter/lib/src/painting/debug.dart @@ -25,7 +25,7 @@ bool debugDisableShadows = false; bool debugAssertAllPaintingVarsUnset(String reason, { bool debugDisableShadowsOverride = false }) { assert(() { if (debugDisableShadows != debugDisableShadowsOverride) { - throw new FlutterError(reason); + throw FlutterError(reason); } return true; }()); diff --git a/packages/flutter/lib/src/painting/decoration_image.dart b/packages/flutter/lib/src/painting/decoration_image.dart index 144fb85de8..3215d0784b 100644 --- a/packages/flutter/lib/src/painting/decoration_image.dart +++ b/packages/flutter/lib/src/painting/decoration_image.dart @@ -132,7 +132,7 @@ class DecorationImage { /// because it is animated. DecorationImagePainter createPainter(VoidCallback onChanged) { assert(onChanged != null); - return new DecorationImagePainter._(this, onChanged); + return DecorationImagePainter._(this, onChanged); } @override @@ -220,7 +220,7 @@ class DecorationImagePainter { // We check this first so that the assert will fire immediately, not just // when the image is ready. if (configuration.textDirection == null) { - throw new FlutterError( + throw FlutterError( 'ImageDecoration.matchTextDirection can only be used when a TextDirection is available.\n' 'When DecorationImagePainter.paint() was called, there was no text direction provided ' 'in the ImageConfiguration object to match.\n' @@ -370,10 +370,10 @@ void paintImage({ if (rect.isEmpty) return; Size outputSize = rect.size; - Size inputSize = new Size(image.width.toDouble(), image.height.toDouble()); + Size inputSize = Size(image.width.toDouble(), image.height.toDouble()); Offset sliceBorder; if (centerSlice != null) { - sliceBorder = new Offset( + sliceBorder = Offset( centerSlice.left + inputSize.width - centerSlice.right, centerSlice.top + inputSize.height - centerSlice.bottom ); @@ -397,7 +397,7 @@ void paintImage({ // output rect with the image. repeat = ImageRepeat.noRepeat; } - final Paint paint = new Paint()..isAntiAlias = false; + final Paint paint = Paint()..isAntiAlias = false; if (colorFilter != null) paint.colorFilter = colorFilter; if (sourceSize != destinationSize) { @@ -462,6 +462,6 @@ Iterable _generateImageTileRects(Rect outputRect, Rect fundamentalRect, Im for (int i = startX; i <= stopX; ++i) { for (int j = startY; j <= stopY; ++j) - yield fundamentalRect.shift(new Offset(i * strideX, j * strideY)); + yield fundamentalRect.shift(Offset(i * strideX, j * strideY)); } } diff --git a/packages/flutter/lib/src/painting/edge_insets.dart b/packages/flutter/lib/src/painting/edge_insets.dart index 1789f5df9d..66c1458141 100644 --- a/packages/flutter/lib/src/painting/edge_insets.dart +++ b/packages/flutter/lib/src/painting/edge_insets.dart @@ -63,10 +63,10 @@ abstract class EdgeInsetsGeometry { } /// The size that this [EdgeInsets] would occupy with an empty interior. - Size get collapsedSize => new Size(horizontal, vertical); + Size get collapsedSize => Size(horizontal, vertical); /// An [EdgeInsetsGeometry] with top and bottom, left and right, and start and end flipped. - EdgeInsetsGeometry get flipped => new _MixedEdgeInsets.fromLRSETB(_right, _left, _end, _start, _bottom, _top); + EdgeInsetsGeometry get flipped => _MixedEdgeInsets.fromLRSETB(_right, _left, _end, _start, _bottom, _top); /// Returns a new size that is bigger than the given size by the amount of /// inset in the horizontal and vertical directions. @@ -78,7 +78,7 @@ abstract class EdgeInsetsGeometry { /// how the start and end map to the left or right). /// * [deflateSize], to deflate a [Size] rather than inflating it. Size inflateSize(Size size) { - return new Size(size.width + horizontal, size.height + vertical); + return Size(size.width + horizontal, size.height + vertical); } /// Returns a new size that is smaller than the given size by the amount of @@ -94,7 +94,7 @@ abstract class EdgeInsetsGeometry { /// how the start and end map to the left or right). /// * [inflateSize], to inflate a [Size] rather than deflating it. Size deflateSize(Size size) { - return new Size(size.width - horizontal, size.height - vertical); + return Size(size.width - horizontal, size.height - vertical); } /// Returns the difference between two [EdgeInsetsGeometry] objects. @@ -114,7 +114,7 @@ abstract class EdgeInsetsGeometry { /// negating the argument (using the prefix unary `-` operator or multiplying /// the argument by -1.0 using the `*` operator). EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( _left - other._left, _right - other._right, _start - other._start, @@ -136,7 +136,7 @@ abstract class EdgeInsetsGeometry { /// representing a combination of both is returned. That object can be turned /// into a concrete [EdgeInsets] using [resolve]. EdgeInsetsGeometry add(EdgeInsetsGeometry other) { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( _left + other._left, _right + other._right, _start + other._start, @@ -213,7 +213,7 @@ abstract class EdgeInsetsGeometry { return EdgeInsets.lerp(a, b, t); if (a is EdgeInsetsDirectional && b is EdgeInsetsDirectional) return EdgeInsetsDirectional.lerp(a, b, t); - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( ui.lerpDouble(a._left, b._left, t), ui.lerpDouble(a._right, b._right, t), ui.lerpDouble(a._start, b._start, t), @@ -412,23 +412,23 @@ class EdgeInsets extends EdgeInsetsGeometry { /// An Offset describing the vector from the top left of a rectangle to the /// top left of that rectangle inset by this object. - Offset get topLeft => new Offset(left, top); + Offset get topLeft => Offset(left, top); /// An Offset describing the vector from the top right of a rectangle to the /// top right of that rectangle inset by this object. - Offset get topRight => new Offset(-right, top); + Offset get topRight => Offset(-right, top); /// An Offset describing the vector from the bottom left of a rectangle to the /// bottom left of that rectangle inset by this object. - Offset get bottomLeft => new Offset(left, -bottom); + Offset get bottomLeft => Offset(left, -bottom); /// An Offset describing the vector from the bottom right of a rectangle to the /// bottom right of that rectangle inset by this object. - Offset get bottomRight => new Offset(-right, -bottom); + Offset get bottomRight => Offset(-right, -bottom); /// An [EdgeInsets] with top and bottom as well as left and right flipped. @override - EdgeInsets get flipped => new EdgeInsets.fromLTRB(right, bottom, left, top); + EdgeInsets get flipped => EdgeInsets.fromLTRB(right, bottom, left, top); /// Returns a new rect that is bigger than the given rect in each direction by /// the amount of inset in each direction. Specifically, the left edge of the @@ -441,7 +441,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// * [inflateSize], to inflate a [Size] rather than a [Rect]. /// * [deflateRect], to deflate a [Rect] rather than inflating it. Rect inflateRect(Rect rect) { - return new Rect.fromLTRB(rect.left - left, rect.top - top, rect.right + right, rect.bottom + bottom); + return Rect.fromLTRB(rect.left - left, rect.top - top, rect.right + right, rect.bottom + bottom); } /// Returns a new rect that is smaller than the given rect in each direction by @@ -458,7 +458,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// * [deflateSize], to deflate a [Size] rather than a [Rect]. /// * [inflateRect], to inflate a [Rect] rather than deflating it. Rect deflateRect(Rect rect) { - return new Rect.fromLTRB(rect.left + left, rect.top + top, rect.right - right, rect.bottom - bottom); + return Rect.fromLTRB(rect.left + left, rect.top + top, rect.right - right, rect.bottom - bottom); } @override @@ -477,7 +477,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Returns the difference between two [EdgeInsets]. EdgeInsets operator -(EdgeInsets other) { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( left - other.left, top - other.top, right - other.right, @@ -487,7 +487,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Returns the sum of two [EdgeInsets]. EdgeInsets operator +(EdgeInsets other) { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( left + other.left, top + other.top, right + other.right, @@ -500,7 +500,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// This is the same as multiplying the object by -1.0. @override EdgeInsets operator -() { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( -left, -top, -right, @@ -511,7 +511,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Scales the [EdgeInsets] in each dimension by the given factor. @override EdgeInsets operator *(double other) { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( left * other, top * other, right * other, @@ -522,7 +522,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Divides the [EdgeInsets] in each dimension by the given factor. @override EdgeInsets operator /(double other) { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( left / other, top / other, right / other, @@ -533,7 +533,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Integer divides the [EdgeInsets] in each dimension by the given factor. @override EdgeInsets operator ~/(double other) { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( (left ~/ other).toDouble(), (top ~/ other).toDouble(), (right ~/ other).toDouble(), @@ -544,7 +544,7 @@ class EdgeInsets extends EdgeInsetsGeometry { /// Computes the remainder in each dimension by the given factor. @override EdgeInsets operator %(double other) { - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( left % other, top % other, right % other, @@ -575,7 +575,7 @@ class EdgeInsets extends EdgeInsetsGeometry { return b * t; if (b == null) return a * (1.0 - t); - return new EdgeInsets.fromLTRB( + return EdgeInsets.fromLTRB( ui.lerpDouble(a.left, b.left, t), ui.lerpDouble(a.top, b.top, t), ui.lerpDouble(a.right, b.right, t), @@ -594,7 +594,7 @@ class EdgeInsets extends EdgeInsetsGeometry { double right, double bottom, }) { - return new EdgeInsets.only( + return EdgeInsets.only( left: left ?? this.left, top: top ?? this.top, right: right ?? this.right, @@ -689,7 +689,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// An [EdgeInsetsDirectional] with [top] and [bottom] as well as [start] and [end] flipped. @override - EdgeInsetsDirectional get flipped => new EdgeInsetsDirectional.fromSTEB(end, bottom, start, top); + EdgeInsetsDirectional get flipped => EdgeInsetsDirectional.fromSTEB(end, bottom, start, top); @override EdgeInsetsGeometry subtract(EdgeInsetsGeometry other) { @@ -707,7 +707,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Returns the difference between two [EdgeInsetsDirectional] objects. EdgeInsetsDirectional operator -(EdgeInsetsDirectional other) { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( start - other.start, top - other.top, end - other.end, @@ -717,7 +717,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Returns the sum of two [EdgeInsetsDirectional] objects. EdgeInsetsDirectional operator +(EdgeInsetsDirectional other) { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( start + other.start, top + other.top, end + other.end, @@ -730,7 +730,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// This is the same as multiplying the object by -1.0. @override EdgeInsetsDirectional operator -() { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( -start, -top, -end, @@ -741,7 +741,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Scales the [EdgeInsetsDirectional] object in each dimension by the given factor. @override EdgeInsetsDirectional operator *(double other) { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( start * other, top * other, end * other, @@ -752,7 +752,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Divides the [EdgeInsetsDirectional] object in each dimension by the given factor. @override EdgeInsetsDirectional operator /(double other) { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( start / other, top / other, end / other, @@ -763,7 +763,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Integer divides the [EdgeInsetsDirectional] object in each dimension by the given factor. @override EdgeInsetsDirectional operator ~/(double other) { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( (start ~/ other).toDouble(), (top ~/ other).toDouble(), (end ~/ other).toDouble(), @@ -774,7 +774,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { /// Computes the remainder in each dimension by the given factor. @override EdgeInsetsDirectional operator %(double other) { - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( start % other, top % other, end % other, @@ -809,7 +809,7 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { return b * t; if (b == null) return a * (1.0 - t); - return new EdgeInsetsDirectional.fromSTEB( + return EdgeInsetsDirectional.fromSTEB( ui.lerpDouble(a.start, b.start, t), ui.lerpDouble(a.top, b.top, t), ui.lerpDouble(a.end, b.end, t), @@ -822,9 +822,9 @@ class EdgeInsetsDirectional extends EdgeInsetsGeometry { assert(direction != null); switch (direction) { case TextDirection.rtl: - return new EdgeInsets.fromLTRB(end, top, start, bottom); + return EdgeInsets.fromLTRB(end, top, start, bottom); case TextDirection.ltr: - return new EdgeInsets.fromLTRB(start, top, end, bottom); + return EdgeInsets.fromLTRB(start, top, end, bottom); } return null; } @@ -863,7 +863,7 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { @override _MixedEdgeInsets operator -() { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( -_left, -_right, -_start, @@ -875,7 +875,7 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { @override _MixedEdgeInsets operator *(double other) { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( _left * other, _right * other, _start * other, @@ -887,7 +887,7 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { @override _MixedEdgeInsets operator /(double other) { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( _left / other, _right / other, _start / other, @@ -899,7 +899,7 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { @override _MixedEdgeInsets operator ~/(double other) { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( (_left ~/ other).toDouble(), (_right ~/ other).toDouble(), (_start ~/ other).toDouble(), @@ -911,7 +911,7 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { @override _MixedEdgeInsets operator %(double other) { - return new _MixedEdgeInsets.fromLRSETB( + return _MixedEdgeInsets.fromLRSETB( _left % other, _right % other, _start % other, @@ -926,9 +926,9 @@ class _MixedEdgeInsets extends EdgeInsetsGeometry { assert(direction != null); switch (direction) { case TextDirection.rtl: - return new EdgeInsets.fromLTRB(_end + _left, _top, _start + _right, _bottom); + return EdgeInsets.fromLTRB(_end + _left, _top, _start + _right, _bottom); case TextDirection.ltr: - return new EdgeInsets.fromLTRB(_start + _left, _top, _end + _right, _bottom); + return EdgeInsets.fromLTRB(_start + _left, _top, _end + _right, _bottom); } return null; } diff --git a/packages/flutter/lib/src/painting/flutter_logo.dart b/packages/flutter/lib/src/painting/flutter_logo.dart index 468097544b..3732102195 100644 --- a/packages/flutter/lib/src/painting/flutter_logo.dart +++ b/packages/flutter/lib/src/painting/flutter_logo.dart @@ -149,7 +149,7 @@ class FlutterLogoDecoration extends Decoration { if (a == null && b == null) return null; if (a == null) { - return new FlutterLogoDecoration._( + return FlutterLogoDecoration._( b.lightColor, b.darkColor, b.textColor, @@ -160,7 +160,7 @@ class FlutterLogoDecoration extends Decoration { ); } if (b == null) { - return new FlutterLogoDecoration._( + return FlutterLogoDecoration._( a.lightColor, a.darkColor, a.textColor, @@ -174,7 +174,7 @@ class FlutterLogoDecoration extends Decoration { return a; if (t == 1.0) return b; - return new FlutterLogoDecoration._( + return FlutterLogoDecoration._( Color.lerp(a.lightColor, b.lightColor, t), Color.lerp(a.darkColor, b.darkColor, t), Color.lerp(a.textColor, b.textColor, t), @@ -212,7 +212,7 @@ class FlutterLogoDecoration extends Decoration { @override BoxPainter createBoxPainter([VoidCallback onChanged]) { assert(debugAssertIsValid()); - return new _FlutterLogoPainter(this); + return _FlutterLogoPainter(this); } @override @@ -245,10 +245,10 @@ class FlutterLogoDecoration extends Decoration { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsNode.message('$lightColor/$darkColor on $textColor')); - properties.add(new EnumProperty('style', style)); + properties.add(DiagnosticsNode.message('$lightColor/$darkColor on $textColor')); + properties.add(EnumProperty('style', style)); if (_inTransition) - properties.add(new DiagnosticsNode.message('transition $_position:$_opacity')); + properties.add(DiagnosticsNode.message('transition $_position:$_opacity')); } } @@ -270,10 +270,10 @@ class _FlutterLogoPainter extends BoxPainter { void _prepareText() { const String kLabel = 'Flutter'; - _textPainter = new TextPainter( - text: new TextSpan( + _textPainter = TextPainter( + text: TextSpan( text: kLabel, - style: new TextStyle( + style: TextStyle( color: _config.textColor, fontFamily: 'Roboto', fontSize: 100.0 * 350.0 / 247.0, // 247 is the height of the F when the fontSize is 350, assuming device pixel ratio 1.0 @@ -285,7 +285,7 @@ class _FlutterLogoPainter extends BoxPainter { ); _textPainter.layout(); final ui.TextBox textSize = _textPainter.getBoxesForSelection(const TextSelection(baseOffset: 0, extentOffset: kLabel.length)).single; - _textBoundingRect = new Rect.fromLTRB(textSize.left, textSize.top, textSize.right, textSize.bottom); + _textBoundingRect = Rect.fromLTRB(textSize.left, textSize.top, textSize.right, textSize.bottom); } // This class contains a lot of magic numbers. They were derived from the @@ -305,14 +305,14 @@ class _FlutterLogoPainter extends BoxPainter { canvas.translate((202.0 - 166.0) / 2.0, 0.0); // Set up the styles. - final Paint lightPaint = new Paint() + final Paint lightPaint = Paint() ..color = _config.lightColor.withOpacity(0.8); - final Paint mediumPaint = new Paint() + final Paint mediumPaint = Paint() ..color = _config.lightColor; - final Paint darkPaint = new Paint() + final Paint darkPaint = Paint() ..color = _config.darkColor; - final ui.Gradient triangleGradient = new ui.Gradient.linear( + final ui.Gradient triangleGradient = ui.Gradient.linear( const Offset(87.2623 + 37.9092, 28.8384 + 123.4389), const Offset(42.9205 + 37.9092, 35.0952 + 123.4389), [ @@ -328,11 +328,11 @@ class _FlutterLogoPainter extends BoxPainter { ], [ 0.2690, 0.4093, 0.4972, 0.5708, 0.6364, 0.6968, 0.7533, 0.8058, 0.8219 ], ); - final Paint trianglePaint = new Paint() + final Paint trianglePaint = Paint() ..shader = triangleGradient ..blendMode = BlendMode.multiply; - final ui.Gradient rectangleGradient = new ui.Gradient.linear( + final ui.Gradient rectangleGradient = ui.Gradient.linear( const Offset(62.3643 + 37.9092, 40.135 + 123.4389), const Offset(54.0376 + 37.9092, 31.8083 + 123.4389), [ @@ -348,26 +348,26 @@ class _FlutterLogoPainter extends BoxPainter { ], [ 0.4588, 0.5509, 0.6087, 0.6570, 0.7001, 0.7397, 0.7768, 0.8113, 0.8219 ], ); - final Paint rectanglePaint = new Paint() + final Paint rectanglePaint = Paint() ..shader = rectangleGradient ..blendMode = BlendMode.multiply; // Draw the basic shape. - final Path topBeam = new Path() + final Path topBeam = Path() ..moveTo(37.7, 128.9) ..lineTo(9.8, 101.0) ..lineTo(100.4, 10.4) ..lineTo(156.2, 10.4); canvas.drawPath(topBeam, lightPaint); - final Path middleBeam = new Path() + final Path middleBeam = Path() ..moveTo(156.2, 94.0) ..lineTo(100.4, 94.0) ..lineTo(79.5, 114.9) ..lineTo(107.4, 142.8); canvas.drawPath(middleBeam, lightPaint); - final Path bottomBeam = new Path() + final Path bottomBeam = Path() ..moveTo(79.5, 170.7) ..lineTo(100.4, 191.6) ..lineTo(156.2, 191.6) @@ -376,24 +376,24 @@ class _FlutterLogoPainter extends BoxPainter { canvas.drawPath(bottomBeam, darkPaint); canvas.save(); - canvas.transform(new Float64List.fromList(const [ + canvas.transform(Float64List.fromList(const [ // careful, this is in _column_-major order 0.7071, -0.7071, 0.0, 0.0, 0.7071, 0.7071, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, -77.697, 98.057, 0.0, 1.0, ])); - canvas.drawRect(new Rect.fromLTWH(59.8, 123.1, 39.4, 39.4), mediumPaint); + canvas.drawRect(Rect.fromLTWH(59.8, 123.1, 39.4, 39.4), mediumPaint); canvas.restore(); // The two gradients. - final Path triangle = new Path() + final Path triangle = Path() ..moveTo(79.5, 170.7) ..lineTo(120.9, 156.4) ..lineTo(107.4, 142.8); canvas.drawPath(triangle, trianglePaint); - final Path rectangle = new Path() + final Path rectangle = Path() ..moveTo(107.4, 142.8) ..lineTo(79.5, 170.7) ..lineTo(86.1, 177.3) @@ -424,7 +424,7 @@ class _FlutterLogoPainter extends BoxPainter { assert(fittedSize.source == logoSize); final Rect rect = Alignment.center.inscribe(fittedSize.destination, offset & canvasSize); final double centerSquareHeight = canvasSize.shortestSide; - final Rect centerSquare = new Rect.fromLTWH( + final Rect centerSquare = Rect.fromLTWH( offset.dx + (canvasSize.width - centerSquareHeight) / 2.0, offset.dy + (canvasSize.height - centerSquareHeight) / 2.0, centerSquareHeight, @@ -434,11 +434,11 @@ class _FlutterLogoPainter extends BoxPainter { Rect logoTargetSquare; if (_config._position > 0.0) { // horizontal style - logoTargetSquare = new Rect.fromLTWH(rect.left, rect.top, rect.height, rect.height); + logoTargetSquare = Rect.fromLTWH(rect.left, rect.top, rect.height, rect.height); } else if (_config._position < 0.0) { // stacked style final double logoHeight = rect.height * 191.0 / 306.0; - logoTargetSquare = new Rect.fromLTWH( + logoTargetSquare = Rect.fromLTWH( rect.left + (rect.width - logoHeight) / 2.0, rect.top, logoHeight, @@ -453,8 +453,8 @@ class _FlutterLogoPainter extends BoxPainter { if (_config._opacity < 1.0) { canvas.saveLayer( offset & canvasSize, - new Paint() - ..colorFilter = new ColorFilter.mode( + Paint() + ..colorFilter = ColorFilter.mode( const Color(0xFFFFFFFF).withOpacity(_config._opacity), BlendMode.modulate, ) @@ -470,14 +470,14 @@ class _FlutterLogoPainter extends BoxPainter { (32.0 / 350.0) * fontSize; // 32 is the distance from the text bounding box edge to the left edge of the F when the font size is 350 final double initialLeftTextPosition = // position of text when just starting the animation rect.width / 2.0 - _textBoundingRect.width * scale; - final Offset textOffset = new Offset( + final Offset textOffset = Offset( rect.left + ui.lerpDouble(initialLeftTextPosition, finalLeftTextPosition, _config._position), rect.top + (rect.height - _textBoundingRect.height * scale) / 2.0 ); canvas.save(); if (_config._position < 1.0) { final Offset center = logoSquare.center; - final Path path = new Path() + final Path path = Path() ..moveTo(center.dx, center.dy) ..lineTo(center.dx + rect.width, center.dy - rect.width) ..lineTo(center.dx + rect.width, center.dy + rect.width) @@ -494,7 +494,7 @@ class _FlutterLogoPainter extends BoxPainter { final double scale = fontSize / 100.0; if (_config._position > -1.0) { // This limits what the drawRect call below is going to blend with. - canvas.saveLayer(_textBoundingRect, new Paint()); + canvas.saveLayer(_textBoundingRect, Paint()); } else { canvas.save(); } @@ -505,11 +505,11 @@ class _FlutterLogoPainter extends BoxPainter { canvas.scale(scale, scale); _textPainter.paint(canvas, Offset.zero); if (_config._position > -1.0) { - canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), new Paint() + canvas.drawRect(_textBoundingRect.inflate(_textBoundingRect.width * 0.5), Paint() ..blendMode = BlendMode.modulate - ..shader = new ui.Gradient.linear( - new Offset(_textBoundingRect.width * -0.5, 0.0), - new Offset(_textBoundingRect.width * 1.5, 0.0), + ..shader = ui.Gradient.linear( + Offset(_textBoundingRect.width * -0.5, 0.0), + Offset(_textBoundingRect.width * 1.5, 0.0), [const Color(0xFFFFFFFF), const Color(0xFFFFFFFF), const Color(0x00FFFFFF), const Color(0x00FFFFFF)], [ 0.0, math.max(0.0, _config._position.abs() - 0.1), math.min(_config._position.abs() + 0.1, 1.0), 1.0 ], ) diff --git a/packages/flutter/lib/src/painting/fractional_offset.dart b/packages/flutter/lib/src/painting/fractional_offset.dart index 7acd532ba0..dfa3b26378 100644 --- a/packages/flutter/lib/src/painting/fractional_offset.dart +++ b/packages/flutter/lib/src/painting/fractional_offset.dart @@ -67,7 +67,7 @@ class FractionalOffset extends Alignment { factory FractionalOffset.fromOffsetAndSize(Offset offset, Size size) { assert(size != null); assert(offset != null); - return new FractionalOffset( + return FractionalOffset( offset.dx / size.width, offset.dy / size.height, ); @@ -83,7 +83,7 @@ class FractionalOffset extends Alignment { /// The returned [FractionalOffset] describes the position of the /// [Offset] in the [Rect], as a fraction of the [Rect]. factory FractionalOffset.fromOffsetAndRect(Offset offset, Rect rect) { - return new FractionalOffset.fromOffsetAndSize( + return FractionalOffset.fromOffsetAndSize( offset - rect.topLeft, rect.size, ); @@ -138,7 +138,7 @@ class FractionalOffset extends Alignment { if (other is! FractionalOffset) return super - other; final FractionalOffset typedOther = other; - return new FractionalOffset(dx - typedOther.dx, dy - typedOther.dy); + return FractionalOffset(dx - typedOther.dx, dy - typedOther.dy); } @override @@ -146,32 +146,32 @@ class FractionalOffset extends Alignment { if (other is! FractionalOffset) return super + other; final FractionalOffset typedOther = other; - return new FractionalOffset(dx + typedOther.dx, dy + typedOther.dy); + return FractionalOffset(dx + typedOther.dx, dy + typedOther.dy); } @override FractionalOffset operator -() { - return new FractionalOffset(-dx, -dy); + return FractionalOffset(-dx, -dy); } @override FractionalOffset operator *(double other) { - return new FractionalOffset(dx * other, dy * other); + return FractionalOffset(dx * other, dy * other); } @override FractionalOffset operator /(double other) { - return new FractionalOffset(dx / other, dy / other); + return FractionalOffset(dx / other, dy / other); } @override FractionalOffset operator ~/(double other) { - return new FractionalOffset((dx ~/ other).toDouble(), (dy ~/ other).toDouble()); + return FractionalOffset((dx ~/ other).toDouble(), (dy ~/ other).toDouble()); } @override FractionalOffset operator %(double other) { - return new FractionalOffset(dx % other, dy % other); + return FractionalOffset(dx % other, dy % other); } /// Linearly interpolate between two [FractionalOffset]s. @@ -194,10 +194,10 @@ class FractionalOffset extends Alignment { if (a == null && b == null) return null; if (a == null) - return new FractionalOffset(ui.lerpDouble(0.5, b.dx, t), ui.lerpDouble(0.5, b.dy, t)); + return FractionalOffset(ui.lerpDouble(0.5, b.dx, t), ui.lerpDouble(0.5, b.dy, t)); if (b == null) - return new FractionalOffset(ui.lerpDouble(a.dx, 0.5, t), ui.lerpDouble(a.dy, 0.5, t)); - return new FractionalOffset(ui.lerpDouble(a.dx, b.dx, t), ui.lerpDouble(a.dy, b.dy, t)); + return FractionalOffset(ui.lerpDouble(a.dx, 0.5, t), ui.lerpDouble(a.dy, 0.5, t)); + return FractionalOffset(ui.lerpDouble(a.dx, b.dx, t), ui.lerpDouble(a.dy, b.dy, t)); } @override diff --git a/packages/flutter/lib/src/painting/geometry.dart b/packages/flutter/lib/src/painting/geometry.dart index 06c2c57365..362cdcf7cd 100644 --- a/packages/flutter/lib/src/painting/geometry.dart +++ b/packages/flutter/lib/src/painting/geometry.dart @@ -76,5 +76,5 @@ Offset positionDependentBox({ x = normalizedTargetX - childSize.width / 2.0; } } - return new Offset(x, y); + return Offset(x, y); } diff --git a/packages/flutter/lib/src/painting/gradient.dart b/packages/flutter/lib/src/painting/gradient.dart index b8b6c5b865..df4ed65cf4 100644 --- a/packages/flutter/lib/src/painting/gradient.dart +++ b/packages/flutter/lib/src/painting/gradient.dart @@ -32,7 +32,7 @@ _ColorsAndStops _interpolateColorsAndStops(List aColors, List aSt for (int i = 0; i < aStops.length; i += 1) interpolatedStops.add(ui.lerpDouble(aStops[i], bStops[i], t).clamp(0.0, 1.0)); } - return new _ColorsAndStops(interpolatedColors, interpolatedStops); + return _ColorsAndStops(interpolatedColors, interpolatedStops); } /// A 2D gradient. @@ -92,7 +92,7 @@ abstract class Gradient { return null; assert(colors.length >= 2, 'colors list must have at least two colors'); final double separation = 1.0 / (colors.length - 1); - return new List.generate( + return List.generate( colors.length, (int index) => index * separation, growable: false, @@ -320,7 +320,7 @@ class LinearGradient extends Gradient { @override Shader createShader(Rect rect, { TextDirection textDirection }) { - return new ui.Gradient.linear( + return ui.Gradient.linear( begin.resolve(textDirection).withinRect(rect), end.resolve(textDirection).withinRect(rect), colors, _impliedStops(), tileMode, @@ -333,7 +333,7 @@ class LinearGradient extends Gradient { /// of 0.0 or less results in a gradient that is fully transparent. @override LinearGradient scale(double factor) { - return new LinearGradient( + return LinearGradient( begin: begin, end: end, colors: colors.map((Color color) => Color.lerp(null, color, factor)).toList(), @@ -384,7 +384,7 @@ class LinearGradient extends Gradient { if (b == null) return a.scale(1.0 - t); final _ColorsAndStops interpolated = _interpolateColorsAndStops(a.colors, a.stops, b.colors, b.stops, t); - return new LinearGradient( + return LinearGradient( begin: AlignmentGeometry.lerp(a.begin, b.begin, t), end: AlignmentGeometry.lerp(a.end, b.end, t), colors: interpolated.colors, @@ -583,7 +583,7 @@ class RadialGradient extends Gradient { @override Shader createShader(Rect rect, { TextDirection textDirection }) { - return new ui.Gradient.radial( + return ui.Gradient.radial( center.resolve(textDirection).withinRect(rect), radius * rect.shortestSide, colors, _impliedStops(), tileMode, @@ -599,7 +599,7 @@ class RadialGradient extends Gradient { /// of 0.0 or less results in a gradient that is fully transparent. @override RadialGradient scale(double factor) { - return new RadialGradient( + return RadialGradient( center: center, radius: radius, colors: colors.map((Color color) => Color.lerp(null, color, factor)).toList(), @@ -652,7 +652,7 @@ class RadialGradient extends Gradient { if (b == null) return a.scale(1.0 - t); final _ColorsAndStops interpolated = _interpolateColorsAndStops(a.colors, a.stops, b.colors, b.stops, t); - return new RadialGradient( + return RadialGradient( center: AlignmentGeometry.lerp(a.center, b.center, t), radius: math.max(0.0, ui.lerpDouble(a.radius, b.radius, t)), colors: interpolated.colors, @@ -816,7 +816,7 @@ class SweepGradient extends Gradient { @override Shader createShader(Rect rect, { TextDirection textDirection }) { - return new ui.Gradient.sweep( + return ui.Gradient.sweep( center.resolve(textDirection).withinRect(rect), colors, _impliedStops(), tileMode, startAngle, @@ -830,7 +830,7 @@ class SweepGradient extends Gradient { /// of 0.0 or less results in a gradient that is fully transparent. @override SweepGradient scale(double factor) { - return new SweepGradient( + return SweepGradient( center: center, startAngle: startAngle, endAngle: endAngle, @@ -881,7 +881,7 @@ class SweepGradient extends Gradient { if (b == null) return a.scale(1.0 - t); final _ColorsAndStops interpolated = _interpolateColorsAndStops(a.colors, a.stops, b.colors, b.stops, t); - return new SweepGradient( + return SweepGradient( center: AlignmentGeometry.lerp(a.center, b.center, t), startAngle: math.max(0.0, ui.lerpDouble(a.startAngle, b.startAngle, t)), endAngle: math.max(0.0, ui.lerpDouble(a.endAngle, b.endAngle, t)), diff --git a/packages/flutter/lib/src/painting/image_cache.dart b/packages/flutter/lib/src/painting/image_cache.dart index edfd8e7ce4..06988c8b7f 100644 --- a/packages/flutter/lib/src/painting/image_cache.dart +++ b/packages/flutter/lib/src/painting/image_cache.dart @@ -144,7 +144,7 @@ class ImageCache { void listener(ImageInfo info, bool syncCall) { // Images that fail to load don't contribute to cache size. final int imageSize = info?.image == null ? 0 : info.image.height * info.image.width * 4; - final _CachedImage image = new _CachedImage(result, imageSize); + final _CachedImage image = _CachedImage(result, imageSize); // If the image is bigger than the maximum cache size, and the cache size // is not zero, then increase the cache size to the size of the image plus // some change. diff --git a/packages/flutter/lib/src/painting/image_decoder.dart b/packages/flutter/lib/src/painting/image_decoder.dart index 69891acf65..6ad409aa0a 100644 --- a/packages/flutter/lib/src/painting/image_decoder.dart +++ b/packages/flutter/lib/src/painting/image_decoder.dart @@ -12,7 +12,7 @@ import 'dart:ui' as ui show Image, decodeImageFromList; /// the returned [Future] resolves to the decoded image. Otherwise, the [Future] /// resolves to null. Future decodeImageFromList(Uint8List list) { - final Completer completer = new Completer(); + final Completer completer = Completer(); ui.decodeImageFromList(list, completer.complete); return completer.future; } diff --git a/packages/flutter/lib/src/painting/image_provider.dart b/packages/flutter/lib/src/painting/image_provider.dart index 88b7508a47..fc7b6e8e29 100644 --- a/packages/flutter/lib/src/painting/image_provider.dart +++ b/packages/flutter/lib/src/painting/image_provider.dart @@ -51,7 +51,7 @@ class ImageConfiguration { Size size, String platform, }) { - return new ImageConfiguration( + return ImageConfiguration( bundle: bundle ?? this.bundle, devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, locale: locale ?? this.locale, @@ -106,7 +106,7 @@ class ImageConfiguration { @override String toString() { - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); result.write('ImageConfiguration('); bool hasArguments = false; if (bundle != null) { @@ -259,14 +259,14 @@ abstract class ImageProvider { /// method. ImageStream resolve(ImageConfiguration configuration) { assert(configuration != null); - final ImageStream stream = new ImageStream(); + final ImageStream stream = ImageStream(); T obtainedKey; obtainKey(configuration).then((T key) { obtainedKey = key; stream.setCompleter(PaintingBinding.instance.imageCache.putIfAbsent(key, () => load(key))); }).catchError( (dynamic exception, StackTrace stack) async { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'services library', @@ -408,7 +408,7 @@ abstract class AssetBundleImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(NetworkImage key) { - return new MultiFrameImageStreamCompleter( + return MultiFrameImageStreamCompleter( codec: _loadAsync(key), scale: key.scale, informationCollector: (StringBuffer information) { @@ -475,7 +475,7 @@ class NetworkImage extends ImageProvider { ); } - static final HttpClient _httpClient = new HttpClient(); + static final HttpClient _httpClient = HttpClient(); Future _loadAsync(NetworkImage key) async { assert(key == this); @@ -487,11 +487,11 @@ class NetworkImage extends ImageProvider { }); final HttpClientResponse response = await request.close(); if (response.statusCode != HttpStatus.ok) - throw new Exception('HTTP request failed, statusCode: ${response?.statusCode}, $resolved'); + throw Exception('HTTP request failed, statusCode: ${response?.statusCode}, $resolved'); final Uint8List bytes = await consolidateHttpClientResponseBytes(response); if (bytes.lengthInBytes == 0) - throw new Exception('NetworkImage is an empty file: $resolved'); + throw Exception('NetworkImage is an empty file: $resolved'); return await ui.instantiateImageCodec(bytes); } @@ -534,12 +534,12 @@ class FileImage extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(FileImage key) { - return new MultiFrameImageStreamCompleter( + return MultiFrameImageStreamCompleter( codec: _loadAsync(key), scale: key.scale, informationCollector: (StringBuffer information) { @@ -602,12 +602,12 @@ class MemoryImage extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(MemoryImage key) { - return new MultiFrameImageStreamCompleter( + return MultiFrameImageStreamCompleter( codec: _loadAsync(key), scale: key.scale ); @@ -749,7 +749,7 @@ class ExactAssetImage extends AssetBundleImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(new AssetBundleImageKey( + return SynchronousFuture(AssetBundleImageKey( bundle: bundle ?? configuration.bundle ?? rootBundle, name: keyName, scale: scale diff --git a/packages/flutter/lib/src/painting/image_resolution.dart b/packages/flutter/lib/src/painting/image_resolution.dart index 4691c779cd..8e20951990 100644 --- a/packages/flutter/lib/src/painting/image_resolution.dart +++ b/packages/flutter/lib/src/painting/image_resolution.dart @@ -180,7 +180,7 @@ class AssetImage extends AssetBundleImageProvider { manifest == null ? null : manifest[keyName] ); final double chosenScale = _parseScale(chosenName); - final AssetBundleImageKey key = new AssetBundleImageKey( + final AssetBundleImageKey key = AssetBundleImageKey( bundle: chosenBundle, name: chosenName, scale: chosenScale @@ -195,7 +195,7 @@ class AssetImage extends AssetBundleImageProvider { // just after loadStructuredData returned (which means it provided us // with a SynchronousFuture). Let's return a SynchronousFuture // ourselves. - result = new SynchronousFuture(key); + result = SynchronousFuture(key); } } ).catchError((dynamic error, StackTrace stack) { @@ -212,7 +212,7 @@ class AssetImage extends AssetBundleImageProvider { } // The code above hasn't yet run its "then" handler yet. Let's prepare a // completer for it to use when it does run. - completer = new Completer(); + completer = Completer(); return completer.future; } @@ -223,17 +223,17 @@ class AssetImage extends AssetBundleImageProvider { final Map parsedJson = json.decode(jsonData); final Iterable keys = parsedJson.keys; final Map> parsedManifest = - new Map>.fromIterables(keys, - keys.map((String key) => new List.from(parsedJson[key]))); + Map>.fromIterables(keys, + keys.map((String key) => List.from(parsedJson[key]))); // TODO(ianh): convert that data structure to the right types. - return new SynchronousFuture>>(parsedManifest); + return SynchronousFuture>>(parsedManifest); } String _chooseVariant(String main, ImageConfiguration config, List candidates) { if (config.devicePixelRatio == null || candidates == null || candidates.isEmpty) return main; // TODO(ianh): Consider moving this parsing logic into _manifestParser. - final SplayTreeMap mapping = new SplayTreeMap(); + final SplayTreeMap mapping = SplayTreeMap(); for (String candidate in candidates) mapping[_parseScale(candidate)] = candidate; // TODO(ianh): implement support for config.locale, config.textDirection, @@ -258,7 +258,7 @@ class AssetImage extends AssetBundleImageProvider { return candidates[lower]; } - static final RegExp _extractRatioRegExp = new RegExp(r'/?(\d+(\.\d*)?)x$'); + static final RegExp _extractRatioRegExp = RegExp(r'/?(\d+(\.\d*)?)x$'); double _parseScale(String key) { @@ -266,7 +266,7 @@ class AssetImage extends AssetBundleImageProvider { return _naturalResolution; } - final File assetPath = new File(key); + final File assetPath = File(key); final Directory assetDir = assetPath.parent; final Match match = _extractRatioRegExp.firstMatch(assetDir.path); diff --git a/packages/flutter/lib/src/painting/image_stream.dart b/packages/flutter/lib/src/painting/image_stream.dart index c7f81d7c92..beef3b0e82 100644 --- a/packages/flutter/lib/src/painting/image_stream.dart +++ b/packages/flutter/lib/src/painting/image_stream.dart @@ -155,7 +155,7 @@ class ImageStream extends Diagnosticable { if (_completer != null) return _completer.addListener(listener, onError: onError); _listeners ??= <_ImageListenerPair>[]; - _listeners.add(new _ImageListenerPair(listener, onError)); + _listeners.add(_ImageListenerPair(listener, onError)); } /// Stop listening for new concrete [ImageInfo] objects and errors from @@ -188,13 +188,13 @@ class ImageStream extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new ObjectFlagProperty( + properties.add(ObjectFlagProperty( 'completer', _completer, ifPresent: _completer?.toStringShort(), ifNull: 'unresolved', )); - properties.add(new ObjectFlagProperty>( + properties.add(ObjectFlagProperty>( 'listeners', _listeners, ifPresent: '${_listeners?.length} listener${_listeners?.length == 1 ? "" : "s" }', @@ -229,7 +229,7 @@ abstract class ImageStreamCompleter extends Diagnosticable { /// then use this flag to avoid calling [RenderObject.markNeedsPaint] during /// a paint. void addListener(ImageListener listener, { ImageErrorListener onError }) { - _listeners.add(new _ImageListenerPair(listener, onError)); + _listeners.add(_ImageListenerPair(listener, onError)); if (_currentImage != null) { try { listener(_currentImage, true); @@ -246,7 +246,7 @@ abstract class ImageStreamCompleter extends Diagnosticable { onError(_currentError.exception, _currentError.stack); } catch (exception, stack) { FlutterError.reportError( - new FlutterErrorDetails( + FlutterErrorDetails( exception: exception, library: 'image resource service', context: 'by a synchronously-called image error listener', @@ -303,7 +303,7 @@ abstract class ImageStreamCompleter extends Diagnosticable { InformationCollector informationCollector, bool silent = false, }) { - _currentError = new FlutterErrorDetails( + _currentError = FlutterErrorDetails( exception: exception, stack: stack, library: 'image resource service', @@ -327,7 +327,7 @@ abstract class ImageStreamCompleter extends Diagnosticable { errorListener(exception, stack); } catch (exception, stack) { FlutterError.reportError( - new FlutterErrorDetails( + FlutterErrorDetails( context: 'by an image error listener', library: 'image resource service', exception: exception, @@ -344,8 +344,8 @@ abstract class ImageStreamCompleter extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('current', _currentImage, ifNull: 'unresolved', showName: false)); - description.add(new ObjectFlagProperty>( + description.add(DiagnosticsProperty('current', _currentImage, ifNull: 'unresolved', showName: false)); + description.add(ObjectFlagProperty>( 'listeners', _listeners, ifPresent: '${_listeners?.length} listener${_listeners?.length == 1 ? "" : "s" }', @@ -468,7 +468,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { if (!_hasActiveListeners) return; if (_isFirstFrame() || _hasFrameDurationPassed(timestamp)) { - _emitFrame(new ImageInfo(image: _nextFrame.image, scale: _scale)); + _emitFrame(ImageInfo(image: _nextFrame.image, scale: _scale)); _shownTimestamp = timestamp; _frameDuration = _nextFrame.duration; _nextFrame = null; @@ -479,7 +479,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { return; } final Duration delay = _frameDuration - (timestamp - _shownTimestamp); - _timer = new Timer(delay * timeDilation, () { + _timer = Timer(delay * timeDilation, () { SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame); }); } @@ -509,7 +509,7 @@ class MultiFrameImageStreamCompleter extends ImageStreamCompleter { if (_codec.frameCount == 1) { // This is not an animated image, just return it and don't schedule more // frames. - _emitFrame(new ImageInfo(image: _nextFrame.image, scale: _scale)); + _emitFrame(ImageInfo(image: _nextFrame.image, scale: _scale)); return; } SchedulerBinding.instance.scheduleFrameCallback(_handleAppFrame); diff --git a/packages/flutter/lib/src/painting/matrix_utils.dart b/packages/flutter/lib/src/painting/matrix_utils.dart index 1d39a7a6f8..8700781825 100644 --- a/packages/flutter/lib/src/painting/matrix_utils.dart +++ b/packages/flutter/lib/src/painting/matrix_utils.dart @@ -36,7 +36,7 @@ class MatrixUtils { values[11] == 0.0 && values[14] == 0.0 && // bottom of col 4 (values 12 and 13 are the x and y offsets) values[15] == 1.0) { - return new Offset(values[12], values[13]); + return Offset(values[12], values[13]); } return null; } @@ -124,9 +124,9 @@ class MatrixUtils { /// This function assumes the given point has a z-coordinate of 0.0. The /// z-coordinate of the result is ignored. static Offset transformPoint(Matrix4 transform, Offset point) { - final Vector3 position3 = new Vector3(point.dx, point.dy, 0.0); + final Vector3 position3 = Vector3(point.dx, point.dy, 0.0); final Vector3 transformed3 = transform.perspectiveTransform(position3); - return new Offset(transformed3.x, transformed3.y); + return Offset(transformed3.x, transformed3.y); } /// Returns a rect that bounds the result of applying the given matrix as a @@ -140,7 +140,7 @@ class MatrixUtils { final Offset point2 = transformPoint(transform, rect.topRight); final Offset point3 = transformPoint(transform, rect.bottomLeft); final Offset point4 = transformPoint(transform, rect.bottomRight); - return new Rect.fromLTRB( + return Rect.fromLTRB( _min4(point1.dx, point2.dx, point3.dx, point4.dx), _min4(point1.dy, point2.dy, point3.dy, point4.dy), _max4(point1.dx, point2.dx, point3.dx, point4.dx), @@ -166,7 +166,7 @@ class MatrixUtils { assert(transform.determinant != 0.0); if (isIdentity(transform)) return rect; - transform = new Matrix4.copy(transform)..invert(); + transform = Matrix4.copy(transform)..invert(); return transformRect(transform, rect); } @@ -230,7 +230,7 @@ class MatrixUtils { // [0.0, 1.0, 0.0, 0.0], // [0.0, 0.0, 1.0, -radius], // [0.0, 0.0, 0.0, 1.0]] - Matrix4 result = new Matrix4.identity() + Matrix4 result = Matrix4.identity() ..setEntry(3, 2, -perspective) ..setEntry(2, 3, -radius) ..setEntry(3, 3, perspective * radius + 1.0); @@ -239,9 +239,9 @@ class MatrixUtils { // by radius in the z axis and then rotating against the world. result *= ( orientation == Axis.horizontal - ? new Matrix4.rotationY(angle) - : new Matrix4.rotationX(angle) - ) * new Matrix4.translationValues(0.0, 0.0, radius); + ? Matrix4.rotationY(angle) + : Matrix4.rotationX(angle) + ) * Matrix4.translationValues(0.0, 0.0, radius); // Essentially perspective * view * model. return result; diff --git a/packages/flutter/lib/src/painting/notched_shapes.dart b/packages/flutter/lib/src/painting/notched_shapes.dart index 23789120eb..dd041631ad 100644 --- a/packages/flutter/lib/src/painting/notched_shapes.dart +++ b/packages/flutter/lib/src/painting/notched_shapes.dart @@ -46,7 +46,7 @@ class CircularNotchedRectangle implements NotchedShape { @override Path getOuterPath(Rect host, Rect guest) { if (!host.overlaps(guest)) - return new Path()..addRect(host); + return Path()..addRect(host); // The guest's shape is a circle bounded by the guest rectangle. // So the guest's radius is half the guest width. @@ -73,31 +73,31 @@ class CircularNotchedRectangle implements NotchedShape { final double p2yA = math.sqrt(r * r - p2xA * p2xA); final double p2yB = math.sqrt(r * r - p2xB * p2xB); - final List p = new List(6); + final List p = List(6); // p0, p1, and p2 are the control points for segment A. - p[0] = new Offset(a - s1, b); - p[1] = new Offset(a, b); + p[0] = Offset(a - s1, b); + p[1] = Offset(a, b); final double cmp = b < 0 ? -1.0 : 1.0; - p[2] = cmp * p2yA > cmp * p2yB ? new Offset(p2xA, p2yA) : new Offset(p2xB, p2yB); + p[2] = cmp * p2yA > cmp * p2yB ? Offset(p2xA, p2yA) : Offset(p2xB, p2yB); // p3, p4, and p5 are the control points for segment B, which is a mirror // of segment A around the y axis. - p[3] = new Offset(-1.0 * p[2].dx, p[2].dy); - p[4] = new Offset(-1.0 * p[1].dx, p[1].dy); - p[5] = new Offset(-1.0 * p[0].dx, p[0].dy); + p[3] = Offset(-1.0 * p[2].dx, p[2].dy); + p[4] = Offset(-1.0 * p[1].dx, p[1].dy); + p[5] = Offset(-1.0 * p[0].dx, p[0].dy); // translate all points back to the absolute coordinate system. for (int i = 0; i < p.length; i += 1) p[i] += guest.center; - return new Path() + return Path() ..moveTo(host.left, host.top) ..lineTo(p[0].dx, p[0].dy) ..quadraticBezierTo(p[1].dx, p[1].dy, p[2].dx, p[2].dy) ..arcToPoint( p[3], - radius: new Radius.circular(notchRadius), + radius: Radius.circular(notchRadius), clockwise: false, ) ..quadraticBezierTo(p[4].dx, p[4].dy, p[5].dx, p[5].dy) diff --git a/packages/flutter/lib/src/painting/paint_utilities.dart b/packages/flutter/lib/src/painting/paint_utilities.dart index 709549b97e..1cb4bc3c03 100644 --- a/packages/flutter/lib/src/painting/paint_utilities.dart +++ b/packages/flutter/lib/src/painting/paint_utilities.dart @@ -29,7 +29,7 @@ void paintZigZag(Canvas canvas, Paint paint, Offset start, Offset end, int zigs, canvas.rotate(math.atan2(end.dy, end.dx)); final double length = end.distance; final double spacing = length / (zigs * 2.0); - final Path path = new Path() + final Path path = Path() ..moveTo(0.0, 0.0); for (int index = 0; index < zigs; index += 1) { final double x = (index * 2.0 + 1.0) * spacing; diff --git a/packages/flutter/lib/src/painting/rounded_rectangle_border.dart b/packages/flutter/lib/src/painting/rounded_rectangle_border.dart index 009600736b..0143e9ded7 100644 --- a/packages/flutter/lib/src/painting/rounded_rectangle_border.dart +++ b/packages/flutter/lib/src/painting/rounded_rectangle_border.dart @@ -42,12 +42,12 @@ class RoundedRectangleBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override ShapeBorder scale(double t) { - return new RoundedRectangleBorder( + return RoundedRectangleBorder( side: side.scale(t), borderRadius: borderRadius * t, ); @@ -57,13 +57,13 @@ class RoundedRectangleBorder extends ShapeBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is RoundedRectangleBorder) { - return new RoundedRectangleBorder( + return RoundedRectangleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: BorderRadius.lerp(a.borderRadius, borderRadius, t), ); } if (a is CircleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: borderRadius, circleness: 1.0 - t, @@ -76,13 +76,13 @@ class RoundedRectangleBorder extends ShapeBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { assert(t != null); if (b is RoundedRectangleBorder) { - return new RoundedRectangleBorder( + return RoundedRectangleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: BorderRadius.lerp(borderRadius, b.borderRadius, t), ); } if (b is CircleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: borderRadius, circleness: t, @@ -93,13 +93,13 @@ class RoundedRectangleBorder extends ShapeBorder { @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(borderRadius.resolve(textDirection).toRRect(rect).deflate(side.width)); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(borderRadius.resolve(textDirection).toRRect(rect)); } @@ -115,7 +115,7 @@ class RoundedRectangleBorder extends ShapeBorder { } else { final RRect outer = borderRadius.resolve(textDirection).toRRect(rect); final RRect inner = outer.deflate(width); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = side.color; canvas.drawDRRect(outer, inner, paint); } @@ -157,12 +157,12 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override ShapeBorder scale(double t) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: side.scale(t), borderRadius: borderRadius * t, circleness: t, @@ -173,21 +173,21 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is RoundedRectangleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: BorderRadius.lerp(a.borderRadius, borderRadius, t), circleness: circleness * t, ); } if (a is CircleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: borderRadius, circleness: circleness + (1.0 - circleness) * (1.0 - t), ); } if (a is _RoundedRectangleToCircleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: BorderRadius.lerp(a.borderRadius, borderRadius, t), circleness: ui.lerpDouble(a.circleness, circleness, t), @@ -199,21 +199,21 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { @override ShapeBorder lerpTo(ShapeBorder b, double t) { if (b is RoundedRectangleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: BorderRadius.lerp(borderRadius, b.borderRadius, t), circleness: circleness * (1.0 - t), ); } if (b is CircleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: borderRadius, circleness: circleness + (1.0 - circleness) * t, ); } if (b is _RoundedRectangleToCircleBorder) { - return new _RoundedRectangleToCircleBorder( + return _RoundedRectangleToCircleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: BorderRadius.lerp(borderRadius, b.borderRadius, t), circleness: ui.lerpDouble(circleness, b.circleness, t), @@ -227,7 +227,7 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { return rect; if (rect.width < rect.height) { final double delta = circleness * (rect.height - rect.width) / 2.0; - return new Rect.fromLTRB( + return Rect.fromLTRB( rect.left, rect.top + delta, rect.right, @@ -235,7 +235,7 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { ); } else { final double delta = circleness * (rect.width - rect.height) / 2.0; - return new Rect.fromLTRB( + return Rect.fromLTRB( rect.left + delta, rect.top, rect.right - delta, @@ -247,18 +247,18 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { BorderRadius _adjustBorderRadius(Rect rect) { if (circleness == 0.0) return borderRadius; - return BorderRadius.lerp(borderRadius, new BorderRadius.circular(rect.shortestSide / 2.0), circleness); + return BorderRadius.lerp(borderRadius, BorderRadius.circular(rect.shortestSide / 2.0), circleness); } @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect)).deflate(side.width)); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect))); } @@ -274,7 +274,7 @@ class _RoundedRectangleToCircleBorder extends ShapeBorder { } else { final RRect outer = _adjustBorderRadius(rect).toRRect(_adjustRect(rect)); final RRect inner = outer.deflate(width); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = side.color; canvas.drawDRRect(outer, inner, paint); } diff --git a/packages/flutter/lib/src/painting/shape_decoration.dart b/packages/flutter/lib/src/painting/shape_decoration.dart index 7211d348bc..8ded26719c 100644 --- a/packages/flutter/lib/src/painting/shape_decoration.dart +++ b/packages/flutter/lib/src/painting/shape_decoration.dart @@ -94,7 +94,7 @@ class ShapeDecoration extends Decoration { case BoxShape.circle: if (source.border != null) { assert(source.border.isUniform); - shape = new CircleBorder(side: source.border.top); + shape = CircleBorder(side: source.border.top); } else { shape = const CircleBorder(); } @@ -102,7 +102,7 @@ class ShapeDecoration extends Decoration { case BoxShape.rectangle: if (source.borderRadius != null) { assert(source.border == null || source.border.isUniform); - shape = new RoundedRectangleBorder( + shape = RoundedRectangleBorder( side: source.border?.top ?? BorderSide.none, borderRadius: source.borderRadius, ); @@ -111,7 +111,7 @@ class ShapeDecoration extends Decoration { } break; } - return new ShapeDecoration( + return ShapeDecoration( color: source.color, image: source.image, gradient: source.gradient, @@ -178,7 +178,7 @@ class ShapeDecoration extends Decoration { @override ShapeDecoration lerpFrom(Decoration a, double t) { if (a is BoxDecoration) { - return ShapeDecoration.lerp(new ShapeDecoration.fromBoxDecoration(a), this, t); + return ShapeDecoration.lerp(ShapeDecoration.fromBoxDecoration(a), this, t); } else if (a == null || a is ShapeDecoration) { return ShapeDecoration.lerp(a, this, t); } @@ -188,7 +188,7 @@ class ShapeDecoration extends Decoration { @override ShapeDecoration lerpTo(Decoration b, double t) { if (b is BoxDecoration) { - return ShapeDecoration.lerp(this, new ShapeDecoration.fromBoxDecoration(b), t); + return ShapeDecoration.lerp(this, ShapeDecoration.fromBoxDecoration(b), t); } else if (b == null || b is ShapeDecoration) { return ShapeDecoration.lerp(this, b, t); } @@ -233,7 +233,7 @@ class ShapeDecoration extends Decoration { if (t == 1.0) return b; } - return new ShapeDecoration( + return ShapeDecoration( color: Color.lerp(a?.color, b?.color, t), gradient: Gradient.lerp(a?.gradient, b?.gradient, t), image: t < 0.5 ? a.image : b.image, // TODO(ianh): cross-fade the image @@ -271,11 +271,11 @@ class ShapeDecoration extends Decoration { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties.defaultDiagnosticsTreeStyle = DiagnosticsTreeStyle.whitespace; - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DiagnosticsProperty('gradient', gradient, defaultValue: null)); - properties.add(new DiagnosticsProperty('image', image, defaultValue: null)); - properties.add(new IterableProperty('shadows', shadows, defaultValue: null, style: DiagnosticsTreeStyle.whitespace)); - properties.add(new DiagnosticsProperty('shape', shape)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('gradient', gradient, defaultValue: null)); + properties.add(DiagnosticsProperty('image', image, defaultValue: null)); + properties.add(IterableProperty('shadows', shadows, defaultValue: null, style: DiagnosticsTreeStyle.whitespace)); + properties.add(DiagnosticsProperty('shape', shape)); } @override @@ -286,7 +286,7 @@ class ShapeDecoration extends Decoration { @override _ShapeDecorationPainter createBoxPainter([VoidCallback onChanged]) { assert(onChanged != null || image == null); - return new _ShapeDecorationPainter(this, onChanged); + return _ShapeDecorationPainter(this, onChanged); } } @@ -317,7 +317,7 @@ class _ShapeDecorationPainter extends BoxPainter { // - subsequent times, if the rect has changed, in which case we only need to update // the features that depend on the actual rect. if (_interiorPaint == null && (_decoration.color != null || _decoration.gradient != null)) { - _interiorPaint = new Paint(); + _interiorPaint = Paint(); if (_decoration.color != null) _interiorPaint.color = _decoration.color; } @@ -326,8 +326,8 @@ class _ShapeDecorationPainter extends BoxPainter { if (_decoration.shadows != null) { if (_shadowCount == null) { _shadowCount = _decoration.shadows.length; - _shadowPaths = new List(_shadowCount); - _shadowPaints = new List(_shadowCount); + _shadowPaths = List(_shadowCount); + _shadowPaints = List(_shadowCount); for (int index = 0; index < _shadowCount; index += 1) _shadowPaints[index] = _decoration.shadows[index].toPaint(); } diff --git a/packages/flutter/lib/src/painting/stadium_border.dart b/packages/flutter/lib/src/painting/stadium_border.dart index d69f48905e..ab6d007696 100644 --- a/packages/flutter/lib/src/painting/stadium_border.dart +++ b/packages/flutter/lib/src/painting/stadium_border.dart @@ -33,25 +33,25 @@ class StadiumBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override - ShapeBorder scale(double t) => new StadiumBorder(side: side.scale(t)); + ShapeBorder scale(double t) => StadiumBorder(side: side.scale(t)); @override ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is StadiumBorder) - return new StadiumBorder(side: BorderSide.lerp(a.side, side, t)); + return StadiumBorder(side: BorderSide.lerp(a.side, side, t)); if (a is CircleBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(a.side, side, t), circleness: 1.0 - t, ); } if (a is RoundedRectangleBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: a.borderRadius, rectness: 1.0 - t, @@ -64,15 +64,15 @@ class StadiumBorder extends ShapeBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { assert(t != null); if (b is StadiumBorder) - return new StadiumBorder(side: BorderSide.lerp(side, b.side, t)); + return StadiumBorder(side: BorderSide.lerp(side, b.side, t)); if (b is CircleBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(side, b.side, t), circleness: t, ); } if (b is RoundedRectangleBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: b.borderRadius, rectness: t, @@ -83,16 +83,16 @@ class StadiumBorder extends ShapeBorder { @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - final Radius radius = new Radius.circular(rect.shortestSide / 2.0); - return new Path() - ..addRRect(new RRect.fromRectAndRadius(rect, radius).deflate(side.width)); + final Radius radius = Radius.circular(rect.shortestSide / 2.0); + return Path() + ..addRRect(RRect.fromRectAndRadius(rect, radius).deflate(side.width)); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - final Radius radius = new Radius.circular(rect.shortestSide / 2.0); - return new Path() - ..addRRect(new RRect.fromRectAndRadius(rect, radius)); + final Radius radius = Radius.circular(rect.shortestSide / 2.0); + return Path() + ..addRRect(RRect.fromRectAndRadius(rect, radius)); } @override @@ -101,9 +101,9 @@ class StadiumBorder extends ShapeBorder { case BorderStyle.none: break; case BorderStyle.solid: - final Radius radius = new Radius.circular(rect.shortestSide / 2.0); + final Radius radius = Radius.circular(rect.shortestSide / 2.0); canvas.drawRRect( - new RRect.fromRectAndRadius(rect, radius).deflate(side.width / 2.0), + RRect.fromRectAndRadius(rect, radius).deflate(side.width / 2.0), side.toPaint(), ); } @@ -140,12 +140,12 @@ class _StadiumToCircleBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override ShapeBorder scale(double t) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: side.scale(t), circleness: t, ); @@ -155,19 +155,19 @@ class _StadiumToCircleBorder extends ShapeBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is StadiumBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(a.side, side, t), circleness: circleness * t, ); } if (a is CircleBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(a.side, side, t), circleness: circleness + (1.0 - circleness) * (1.0 - t), ); } if (a is _StadiumToCircleBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(a.side, side, t), circleness: ui.lerpDouble(a.circleness, circleness, t), ); @@ -179,19 +179,19 @@ class _StadiumToCircleBorder extends ShapeBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { assert(t != null); if (b is StadiumBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(side, b.side, t), circleness: circleness * (1.0 - t), ); } if (b is CircleBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(side, b.side, t), circleness: circleness + (1.0 - circleness) * t, ); } if (b is _StadiumToCircleBorder) { - return new _StadiumToCircleBorder( + return _StadiumToCircleBorder( side: BorderSide.lerp(side, b.side, t), circleness: ui.lerpDouble(circleness, b.circleness, t), ); @@ -204,7 +204,7 @@ class _StadiumToCircleBorder extends ShapeBorder { return rect; if (rect.width < rect.height) { final double delta = circleness * (rect.height - rect.width) / 2.0; - return new Rect.fromLTRB( + return Rect.fromLTRB( rect.left, rect.top + delta, rect.right, @@ -212,7 +212,7 @@ class _StadiumToCircleBorder extends ShapeBorder { ); } else { final double delta = circleness * (rect.width - rect.height) / 2.0; - return new Rect.fromLTRB( + return Rect.fromLTRB( rect.left + delta, rect.top, rect.right - delta, @@ -222,18 +222,18 @@ class _StadiumToCircleBorder extends ShapeBorder { } BorderRadius _adjustBorderRadius(Rect rect) { - return new BorderRadius.circular(rect.shortestSide / 2.0); + return BorderRadius.circular(rect.shortestSide / 2.0); } @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect)).deflate(side.width)); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(_adjustBorderRadius(rect).toRRect(_adjustRect(rect))); } @@ -249,7 +249,7 @@ class _StadiumToCircleBorder extends ShapeBorder { } else { final RRect outer = _adjustBorderRadius(rect).toRRect(_adjustRect(rect)); final RRect inner = outer.deflate(width); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = side.color; canvas.drawDRRect(outer, inner, paint); } @@ -293,12 +293,12 @@ class _StadiumToRoundedRectangleBorder extends ShapeBorder { @override EdgeInsetsGeometry get dimensions { - return new EdgeInsets.all(side.width); + return EdgeInsets.all(side.width); } @override ShapeBorder scale(double t) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: side.scale(t), borderRadius: borderRadius * t, rectness: t, @@ -309,21 +309,21 @@ class _StadiumToRoundedRectangleBorder extends ShapeBorder { ShapeBorder lerpFrom(ShapeBorder a, double t) { assert(t != null); if (a is StadiumBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: borderRadius, rectness: rectness * t, ); } if (a is RoundedRectangleBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: borderRadius, rectness: rectness + (1.0 - rectness) * (1.0 - t), ); } if (a is _StadiumToRoundedRectangleBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(a.side, side, t), borderRadius: BorderRadius.lerp(a.borderRadius, borderRadius, t), rectness: ui.lerpDouble(a.rectness, rectness, t), @@ -336,21 +336,21 @@ class _StadiumToRoundedRectangleBorder extends ShapeBorder { ShapeBorder lerpTo(ShapeBorder b, double t) { assert(t != null); if (b is StadiumBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: borderRadius, rectness: rectness * (1.0 - t), ); } if (b is RoundedRectangleBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: borderRadius, rectness: rectness + (1.0 - rectness) * t, ); } if (b is _StadiumToRoundedRectangleBorder) { - return new _StadiumToRoundedRectangleBorder( + return _StadiumToRoundedRectangleBorder( side: BorderSide.lerp(side, b.side, t), borderRadius: BorderRadius.lerp(borderRadius, b.borderRadius, t), rectness: ui.lerpDouble(rectness, b.rectness, t), @@ -362,20 +362,20 @@ class _StadiumToRoundedRectangleBorder extends ShapeBorder { BorderRadius _adjustBorderRadius(Rect rect) { return BorderRadius.lerp( borderRadius, - new BorderRadius.all(new Radius.circular(rect.shortestSide / 2.0)), + BorderRadius.all(Radius.circular(rect.shortestSide / 2.0)), 1.0 - rectness ); } @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(_adjustBorderRadius(rect).toRRect(rect).deflate(side.width)); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { - return new Path() + return Path() ..addRRect(_adjustBorderRadius(rect).toRRect(rect)); } @@ -391,7 +391,7 @@ class _StadiumToRoundedRectangleBorder extends ShapeBorder { } else { final RRect outer = _adjustBorderRadius(rect).toRRect(rect); final RRect inner = outer.deflate(width); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = side.color; canvas.drawDRRect(outer, inner, paint); } diff --git a/packages/flutter/lib/src/painting/text_painter.dart b/packages/flutter/lib/src/painting/text_painter.dart index 12d39e81e2..b0a36c5abf 100644 --- a/packages/flutter/lib/src/painting/text_painter.dart +++ b/packages/flutter/lib/src/painting/text_painter.dart @@ -211,7 +211,7 @@ class TextPainter { maxLines: _maxLines, ellipsis: _ellipsis, locale: _locale, - ) ?? new ui.ParagraphStyle( + ) ?? ui.ParagraphStyle( textAlign: textAlign, textDirection: textDirection ?? defaultTextDirection, maxLines: maxLines, @@ -234,14 +234,14 @@ class TextPainter { /// sans-serif font). double get preferredLineHeight { if (_layoutTemplate == null) { - final ui.ParagraphBuilder builder = new ui.ParagraphBuilder( + final ui.ParagraphBuilder builder = ui.ParagraphBuilder( _createParagraphStyle(TextDirection.rtl), ); // direction doesn't matter, text is just a space if (text?.style != null) builder.pushStyle(text.style.getTextStyle(textScaleFactor: textScaleFactor)); builder.addText(' '); _layoutTemplate = builder.build() - ..layout(new ui.ParagraphConstraints(width: double.infinity)); + ..layout(ui.ParagraphConstraints(width: double.infinity)); } return _layoutTemplate.height; } @@ -295,7 +295,7 @@ class TextPainter { /// Valid only after [layout] has been called. Size get size { assert(!_needsLayout); - return new Size(width, height); + return Size(width, height); } /// Returns the distance from the top of the text to the first baseline of the @@ -348,17 +348,17 @@ class TextPainter { return; _needsLayout = false; if (_paragraph == null) { - final ui.ParagraphBuilder builder = new ui.ParagraphBuilder(_createParagraphStyle()); + final ui.ParagraphBuilder builder = ui.ParagraphBuilder(_createParagraphStyle()); _text.build(builder, textScaleFactor: textScaleFactor); _paragraph = builder.build(); } _lastMinWidth = minWidth; _lastMaxWidth = maxWidth; - _paragraph.layout(new ui.ParagraphConstraints(width: maxWidth)); + _paragraph.layout(ui.ParagraphConstraints(width: maxWidth)); if (minWidth != maxWidth) { final double newWidth = maxIntrinsicWidth.clamp(minWidth, maxWidth); if (newWidth != width) - _paragraph.layout(new ui.ParagraphConstraints(width: newWidth)); + _paragraph.layout(ui.ParagraphConstraints(width: newWidth)); } } @@ -377,7 +377,7 @@ class TextPainter { void paint(Canvas canvas, Offset offset) { assert(() { if (_needsLayout) { - throw new FlutterError( + throw FlutterError( 'TextPainter.paint called when text geometry was not yet calculated.\n' 'Please call layout() before paint() to position the text before painting it.' ); @@ -422,7 +422,7 @@ class TextPainter { final TextBox box = boxes[0]; final double caretEnd = box.end; final double dx = box.direction == TextDirection.rtl ? caretEnd : caretEnd - caretPrototype.width; - return new Offset(dx, box.top); + return Offset(dx, box.top); } Offset _getOffsetFromDownstream(int offset, Rect caretPrototype) { @@ -436,7 +436,7 @@ class TextPainter { final TextBox box = boxes[0]; final double caretStart = box.start; final double dx = box.direction == TextDirection.rtl ? caretStart - caretPrototype.width : caretStart; - return new Offset(dx, box.top); + return Offset(dx, box.top); } Offset get _emptyOffset { @@ -446,15 +446,15 @@ class TextPainter { case TextAlign.left: return Offset.zero; case TextAlign.right: - return new Offset(width, 0.0); + return Offset(width, 0.0); case TextAlign.center: - return new Offset(width / 2.0, 0.0); + return Offset(width / 2.0, 0.0); case TextAlign.justify: case TextAlign.start: assert(textDirection != null); switch (textDirection) { case TextDirection.rtl: - return new Offset(width, 0.0); + return Offset(width, 0.0); case TextDirection.ltr: return Offset.zero; } @@ -465,7 +465,7 @@ class TextPainter { case TextDirection.rtl: return Offset.zero; case TextDirection.ltr: - return new Offset(width, 0.0); + return Offset(width, 0.0); } return null; } @@ -518,6 +518,6 @@ class TextPainter { TextRange getWordBoundary(TextPosition position) { assert(!_needsLayout); final List indices = _paragraph.getWordBoundary(position.offset); - return new TextRange(start: indices[0], end: indices[1]); + return TextRange(start: indices[0], end: indices[1]); } } diff --git a/packages/flutter/lib/src/painting/text_span.dart b/packages/flutter/lib/src/painting/text_span.dart index c5a5b75b08..f2a08d5135 100644 --- a/packages/flutter/lib/src/painting/text_span.dart +++ b/packages/flutter/lib/src/painting/text_span.dart @@ -221,7 +221,7 @@ class TextSpan extends DiagnosticableTree { /// Styles are not honored in this process. String toPlainText() { assert(debugAssertIsValid()); - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); visitTextSpan((TextSpan span) { buffer.write(span.text); return true; @@ -267,7 +267,7 @@ class TextSpan extends DiagnosticableTree { } return true; })) { - throw new FlutterError( + throw FlutterError( 'TextSpan contains a null child.\n' 'A TextSpan object with a non-null child list should not have any nulls in its child list.\n' 'The full text in question was:\n' @@ -340,15 +340,15 @@ class TextSpan extends DiagnosticableTree { if (style != null) style.debugFillProperties(properties); - properties.add(new DiagnosticsProperty( + properties.add(DiagnosticsProperty( 'recognizer', recognizer, description: recognizer?.runtimeType?.toString(), defaultValue: null, )); - properties.add(new StringProperty('text', text, showName: false, defaultValue: null)); + properties.add(StringProperty('text', text, showName: false, defaultValue: null)); if (style == null && text == null && children == null) - properties.add(new DiagnosticsNode.message('(empty)')); + properties.add(DiagnosticsNode.message('(empty)')); } @override @@ -359,7 +359,7 @@ class TextSpan extends DiagnosticableTree { if (child != null) { return child.toDiagnosticsNode(); } else { - return new DiagnosticsNode.message(''); + return DiagnosticsNode.message(''); } }).toList(); } diff --git a/packages/flutter/lib/src/painting/text_style.dart b/packages/flutter/lib/src/painting/text_style.dart index 4af9eb9845..32f4d334f9 100644 --- a/packages/flutter/lib/src/painting/text_style.dart +++ b/packages/flutter/lib/src/painting/text_style.dart @@ -400,7 +400,7 @@ class TextStyle extends Diagnosticable { newDebugLabel = debugLabel ?? '(${this.debugLabel}).copyWith'; return true; }()); - return new TextStyle( + return TextStyle( inherit: inherit, color: this.foreground == null && foreground == null ? color ?? this.color : null, fontFamily: fontFamily ?? this.fontFamily, @@ -485,7 +485,7 @@ class TextStyle extends Diagnosticable { return true; }()); - return new TextStyle( + return TextStyle( inherit: inherit, color: foreground == null ? color ?? this.color : null, fontFamily: fontFamily ?? this.fontFamily, @@ -589,7 +589,7 @@ class TextStyle extends Diagnosticable { }()); if (a == null) { - return new TextStyle( + return TextStyle( inherit: b.inherit, color: Color.lerp(null, b.color, t), fontFamily: t < 0.5 ? null : b.fontFamily, @@ -611,7 +611,7 @@ class TextStyle extends Diagnosticable { } if (b == null) { - return new TextStyle( + return TextStyle( inherit: a.inherit, color: Color.lerp(a.color, null, t), fontFamily: t < 0.5 ? a.fontFamily : null, @@ -632,7 +632,7 @@ class TextStyle extends Diagnosticable { ); } - return new TextStyle( + return TextStyle( inherit: b.inherit, color: a.foreground == null && b.foreground == null ? Color.lerp(a.color, b.color, t) : null, fontFamily: t < 0.5 ? a.fontFamily : b.fontFamily, @@ -646,8 +646,8 @@ class TextStyle extends Diagnosticable { locale: t < 0.5 ? a.locale : b.locale, foreground: (a.foreground != null || b.foreground != null) ? t < 0.5 - ? a.foreground ?? (new Paint()..color = a.color) - : b.foreground ?? (new Paint()..color = b.color) + ? a.foreground ?? (Paint()..color = a.color) + : b.foreground ?? (Paint()..color = b.color) : null, background: t < 0.5 ? a.background : b.background, decoration: t < 0.5 ? a.decoration : b.decoration, @@ -659,7 +659,7 @@ class TextStyle extends Diagnosticable { /// The style information for text runs, encoded for use by `dart:ui`. ui.TextStyle getTextStyle({ double textScaleFactor = 1.0 }) { - return new ui.TextStyle( + return ui.TextStyle( color: color, decoration: decoration, decorationColor: decorationColor, @@ -696,7 +696,7 @@ class TextStyle extends Diagnosticable { }) { assert(textScaleFactor != null); assert(maxLines == null || maxLines > 0); - return new ui.ParagraphStyle( + return ui.ParagraphStyle( textAlign: textAlign, textDirection: textDirection, fontWeight: fontWeight, @@ -795,11 +795,11 @@ class TextStyle extends Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties, { String prefix = '' }) { super.debugFillProperties(properties); if (debugLabel != null) - properties.add(new MessageProperty('${prefix}debugLabel', debugLabel)); + properties.add(MessageProperty('${prefix}debugLabel', debugLabel)); final List styles = []; - styles.add(new DiagnosticsProperty('${prefix}color', color, defaultValue: null)); - styles.add(new StringProperty('${prefix}family', fontFamily, defaultValue: null, quoted: false)); - styles.add(new DoubleProperty('${prefix}size', fontSize, defaultValue: null)); + styles.add(DiagnosticsProperty('${prefix}color', color, defaultValue: null)); + styles.add(StringProperty('${prefix}family', fontFamily, defaultValue: null, quoted: false)); + styles.add(DoubleProperty('${prefix}size', fontSize, defaultValue: null)); String weightDescription; if (fontWeight != null) { switch (fontWeight) { @@ -835,20 +835,20 @@ class TextStyle extends Diagnosticable { // TODO(jacobr): switch this to use enumProperty which will either cause the // weight description to change to w600 from 600 or require existing // enumProperty to handle this special case. - styles.add(new DiagnosticsProperty( + styles.add(DiagnosticsProperty( '${prefix}weight', fontWeight, description: weightDescription, defaultValue: null, )); - styles.add(new EnumProperty('${prefix}style', fontStyle, defaultValue: null)); - styles.add(new DoubleProperty('${prefix}letterSpacing', letterSpacing, defaultValue: null)); - styles.add(new DoubleProperty('${prefix}wordSpacing', wordSpacing, defaultValue: null)); - styles.add(new EnumProperty('${prefix}baseline', textBaseline, defaultValue: null)); - styles.add(new DoubleProperty('${prefix}height', height, unit: 'x', defaultValue: null)); - styles.add(new DiagnosticsProperty('${prefix}locale', locale, defaultValue: null)); - styles.add(new DiagnosticsProperty('${prefix}foreground', foreground, defaultValue: null)); - styles.add(new DiagnosticsProperty('${prefix}background', background, defaultValue: null)); + styles.add(EnumProperty('${prefix}style', fontStyle, defaultValue: null)); + styles.add(DoubleProperty('${prefix}letterSpacing', letterSpacing, defaultValue: null)); + styles.add(DoubleProperty('${prefix}wordSpacing', wordSpacing, defaultValue: null)); + styles.add(EnumProperty('${prefix}baseline', textBaseline, defaultValue: null)); + styles.add(DoubleProperty('${prefix}height', height, unit: 'x', defaultValue: null)); + styles.add(DiagnosticsProperty('${prefix}locale', locale, defaultValue: null)); + styles.add(DiagnosticsProperty('${prefix}foreground', foreground, defaultValue: null)); + styles.add(DiagnosticsProperty('${prefix}background', background, defaultValue: null)); if (decoration != null || decorationColor != null || decorationStyle != null) { final List decorationDescription = []; if (decorationStyle != null) @@ -856,7 +856,7 @@ class TextStyle extends Diagnosticable { // Hide decorationColor from the default text view as it is shown in the // terse decoration summary as well. - styles.add(new DiagnosticsProperty('${prefix}decorationColor', decorationColor, defaultValue: null, level: DiagnosticLevel.fine)); + styles.add(DiagnosticsProperty('${prefix}decorationColor', decorationColor, defaultValue: null, level: DiagnosticLevel.fine)); if (decorationColor != null) decorationDescription.add('$decorationColor'); @@ -864,18 +864,18 @@ class TextStyle extends Diagnosticable { // Intentionally collide with the property 'decoration' added below. // Tools that show hidden properties could choose the first property // matching the name to disambiguate. - styles.add(new DiagnosticsProperty('${prefix}decoration', decoration, defaultValue: null, level: DiagnosticLevel.hidden)); + styles.add(DiagnosticsProperty('${prefix}decoration', decoration, defaultValue: null, level: DiagnosticLevel.hidden)); if (decoration != null) decorationDescription.add('$decoration'); assert(decorationDescription.isNotEmpty); - styles.add(new MessageProperty('${prefix}decoration', decorationDescription.join(' '))); + styles.add(MessageProperty('${prefix}decoration', decorationDescription.join(' '))); } final bool styleSpecified = styles.any((DiagnosticsNode n) => !n.isFiltered(DiagnosticLevel.info)); - properties.add(new DiagnosticsProperty('${prefix}inherit', inherit, level: (!styleSpecified && inherit) ? DiagnosticLevel.fine : DiagnosticLevel.info)); + properties.add(DiagnosticsProperty('${prefix}inherit', inherit, level: (!styleSpecified && inherit) ? DiagnosticLevel.fine : DiagnosticLevel.info)); styles.forEach(properties.add); if (!styleSpecified) - properties.add(new FlagProperty('inherit', value: inherit, ifTrue: '$prefix', ifFalse: '$prefix')); + properties.add(FlagProperty('inherit', value: inherit, ifTrue: '$prefix', ifFalse: '$prefix')); } } diff --git a/packages/flutter/lib/src/physics/friction_simulation.dart b/packages/flutter/lib/src/physics/friction_simulation.dart index 7a56b204eb..8403d36a4e 100644 --- a/packages/flutter/lib/src/physics/friction_simulation.dart +++ b/packages/flutter/lib/src/physics/friction_simulation.dart @@ -41,11 +41,11 @@ class FrictionSimulation extends Simulation { assert(startVelocity == 0.0 || endVelocity == 0.0 || startVelocity.sign == endVelocity.sign); assert(startVelocity.abs() >= endVelocity.abs()); assert((endPosition - startPosition).sign == startVelocity.sign); - return new FrictionSimulation( + return FrictionSimulation( _dragFor(startPosition, endPosition, startVelocity, endVelocity), startPosition, startVelocity, - tolerance: new Tolerance(velocity: endVelocity.abs()), + tolerance: Tolerance(velocity: endVelocity.abs()), ); } diff --git a/packages/flutter/lib/src/physics/spring_simulation.dart b/packages/flutter/lib/src/physics/spring_simulation.dart index 137f5602d0..d33154c048 100644 --- a/packages/flutter/lib/src/physics/spring_simulation.dart +++ b/packages/flutter/lib/src/physics/spring_simulation.dart @@ -94,7 +94,7 @@ class SpringSimulation extends Simulation { double velocity, { Tolerance tolerance = Tolerance.defaultTolerance, }) : _endPosition = end, - _solution = new _SpringSolution(spring, start - end, velocity), + _solution = _SpringSolution(spring, start - end, velocity), super(tolerance: tolerance); final double _endPosition; @@ -159,10 +159,10 @@ abstract class _SpringSolution { assert(initialVelocity != null); final double cmk = spring.damping * spring.damping - 4 * spring.mass * spring.stiffness; if (cmk == 0.0) - return new _CriticalSolution(spring, initialPosition, initialVelocity); + return _CriticalSolution(spring, initialPosition, initialVelocity); if (cmk > 0.0) - return new _OverdampedSolution(spring, initialPosition, initialVelocity); - return new _UnderdampedSolution(spring, initialPosition, initialVelocity); + return _OverdampedSolution(spring, initialPosition, initialVelocity); + return _UnderdampedSolution(spring, initialPosition, initialVelocity); } double x(double time); @@ -179,7 +179,7 @@ class _CriticalSolution implements _SpringSolution { final double r = -spring.damping / (2.0 * spring.mass); final double c1 = distance; final double c2 = velocity / (r * distance); - return new _CriticalSolution.withArgs(r, c1, c2); + return _CriticalSolution.withArgs(r, c1, c2); } _CriticalSolution.withArgs(double r, double c1, double c2) @@ -215,7 +215,7 @@ class _OverdampedSolution implements _SpringSolution { final double r2 = (-spring.damping + math.sqrt(cmk)) / (2.0 * spring.mass); final double c2 = (velocity - r1 * distance) / (r2 - r1); final double c1 = distance - c2; - return new _OverdampedSolution.withArgs(r1, r2, c1, c2); + return _OverdampedSolution.withArgs(r1, r2, c1, c2); } _OverdampedSolution.withArgs(double r1, double r2, double c1, double c2) @@ -253,7 +253,7 @@ class _UnderdampedSolution implements _SpringSolution { final double r = -(spring.damping / 2.0 * spring.mass); final double c1 = distance; final double c2 = (velocity - r * distance) / w; - return new _UnderdampedSolution.withArgs(w, r, c1, c2); + return _UnderdampedSolution.withArgs(w, r, c1, c2); } _UnderdampedSolution.withArgs(double w, double r, double c1, double c2) diff --git a/packages/flutter/lib/src/rendering/animated_size.dart b/packages/flutter/lib/src/rendering/animated_size.dart index a543db5236..3e161ee6fa 100644 --- a/packages/flutter/lib/src/rendering/animated_size.dart +++ b/packages/flutter/lib/src/rendering/animated_size.dart @@ -85,14 +85,14 @@ class RenderAnimatedSize extends RenderAligningShiftedBox { assert(curve != null), _vsync = vsync, super(child: child, alignment: alignment, textDirection: textDirection) { - _controller = new AnimationController( + _controller = AnimationController( vsync: vsync, duration: duration, )..addListener(() { if (_controller.value != _lastValue) markNeedsLayout(); }); - _animation = new CurvedAnimation( + _animation = CurvedAnimation( parent: _controller, curve: curve ); @@ -100,7 +100,7 @@ class RenderAnimatedSize extends RenderAligningShiftedBox { AnimationController _controller; CurvedAnimation _animation; - final SizeTween _sizeTween = new SizeTween(); + final SizeTween _sizeTween = SizeTween(); bool _hasVisualOverflow; double _lastValue; diff --git a/packages/flutter/lib/src/rendering/binding.dart b/packages/flutter/lib/src/rendering/binding.dart index a967bf52f3..fd46141b28 100644 --- a/packages/flutter/lib/src/rendering/binding.dart +++ b/packages/flutter/lib/src/rendering/binding.dart @@ -30,7 +30,7 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul void initInstances() { super.initInstances(); _instance = this; - _pipelineOwner = new PipelineOwner( + _pipelineOwner = PipelineOwner( onNeedVisualUpdate: ensureVisualUpdate, onSemanticsOwnerCreated: _handleSemanticsOwnerCreated, onSemanticsOwnerDisposed: _handleSemanticsOwnerDisposed, @@ -61,7 +61,7 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul getter: () async => debugPaintSizeEnabled, setter: (bool value) { if (debugPaintSizeEnabled == value) - return new Future.value(); + return Future.value(); debugPaintSizeEnabled = value; return _forceRepaint(); } @@ -71,7 +71,7 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul getter: () async => debugPaintBaselinesEnabled, setter: (bool value) { if (debugPaintBaselinesEnabled == value) - return new Future.value(); + return Future.value(); debugPaintBaselinesEnabled = value; return _forceRepaint(); } @@ -84,7 +84,7 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul debugRepaintRainbowEnabled = value; if (repaint) return _forceRepaint(); - return new Future.value(); + return Future.value(); } ); return true; @@ -119,7 +119,7 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul /// Called automatically when the binding is created. void initRenderView() { assert(renderView == null); - renderView = new RenderView(configuration: createViewConfiguration()); + renderView = RenderView(configuration: createViewConfiguration()); renderView.scheduleInitialFrame(); } @@ -165,7 +165,7 @@ abstract class RendererBinding extends BindingBase with ServicesBinding, Schedul /// using `flutter run`. ViewConfiguration createViewConfiguration() { final double devicePixelRatio = ui.window.devicePixelRatio; - return new ViewConfiguration( + return ViewConfiguration( size: ui.window.physicalSize / devicePixelRatio, devicePixelRatio: devicePixelRatio, ); diff --git a/packages/flutter/lib/src/rendering/box.dart b/packages/flutter/lib/src/rendering/box.dart index 12b54b67f7..9f52c73199 100644 --- a/packages/flutter/lib/src/rendering/box.dart +++ b/packages/flutter/lib/src/rendering/box.dart @@ -171,7 +171,7 @@ class BoxConstraints extends Constraints { double minHeight, double maxHeight }) { - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth ?? this.minWidth, maxWidth: maxWidth ?? this.maxWidth, minHeight: minHeight ?? this.minHeight, @@ -187,7 +187,7 @@ class BoxConstraints extends Constraints { final double vertical = edges.vertical; final double deflatedMinWidth = math.max(0.0, minWidth - horizontal); final double deflatedMinHeight = math.max(0.0, minHeight - vertical); - return new BoxConstraints( + return BoxConstraints( minWidth: deflatedMinWidth, maxWidth: math.max(deflatedMinWidth, maxWidth - horizontal), minHeight: deflatedMinHeight, @@ -198,7 +198,7 @@ class BoxConstraints extends Constraints { /// Returns new box constraints that remove the minimum width and height requirements. BoxConstraints loosen() { assert(debugAssertIsValid()); - return new BoxConstraints( + return BoxConstraints( minWidth: 0.0, maxWidth: maxWidth, minHeight: 0.0, @@ -209,7 +209,7 @@ class BoxConstraints extends Constraints { /// Returns new box constraints that respect the given constraints while being /// as close as possible to the original constraints. BoxConstraints enforce(BoxConstraints constraints) { - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth.clamp(constraints.minWidth, constraints.maxWidth), maxWidth: maxWidth.clamp(constraints.minWidth, constraints.maxWidth), minHeight: minHeight.clamp(constraints.minHeight, constraints.maxHeight), @@ -221,7 +221,7 @@ class BoxConstraints extends Constraints { /// the given width and height as possible while still respecting the original /// box constraints. BoxConstraints tighten({ double width, double height }) { - return new BoxConstraints(minWidth: width == null ? minWidth : width.clamp(minWidth, maxWidth), + return BoxConstraints(minWidth: width == null ? minWidth : width.clamp(minWidth, maxWidth), maxWidth: width == null ? maxWidth : width.clamp(minWidth, maxWidth), minHeight: height == null ? minHeight : height.clamp(minHeight, maxHeight), maxHeight: height == null ? maxHeight : height.clamp(minHeight, maxHeight)); @@ -229,7 +229,7 @@ class BoxConstraints extends Constraints { /// A box constraints with the width and height constraints flipped. BoxConstraints get flipped { - return new BoxConstraints( + return BoxConstraints( minWidth: minHeight, maxWidth: maxHeight, minHeight: minWidth, @@ -239,11 +239,11 @@ class BoxConstraints extends Constraints { /// Returns box constraints with the same width constraints but with /// unconstrained height. - BoxConstraints widthConstraints() => new BoxConstraints(minWidth: minWidth, maxWidth: maxWidth); + BoxConstraints widthConstraints() => BoxConstraints(minWidth: minWidth, maxWidth: maxWidth); /// Returns box constraints with the same height constraints but with /// unconstrained width - BoxConstraints heightConstraints() => new BoxConstraints(minHeight: minHeight, maxHeight: maxHeight); + BoxConstraints heightConstraints() => BoxConstraints(minHeight: minHeight, maxHeight: maxHeight); /// Returns the width that both satisfies the constraints and is as close as /// possible to the given width. @@ -262,7 +262,7 @@ class BoxConstraints extends Constraints { Size _debugPropagateDebugSize(Size size, Size result) { assert(() { if (size is _DebugSize) - result = new _DebugSize(result, size._owner, size._canBeUsedByParent); + result = _DebugSize(result, size._owner, size._canBeUsedByParent); return true; }()); return result; @@ -274,7 +274,7 @@ class BoxConstraints extends Constraints { /// See also [constrainDimensions], which applies the same algorithm to /// separately provided widths and heights. Size constrain(Size size) { - Size result = new Size(constrainWidth(size.width), constrainHeight(size.height)); + Size result = Size(constrainWidth(size.width), constrainHeight(size.height)); assert(() { result = _debugPropagateDebugSize(size, result); return true; }()); return result; } @@ -285,7 +285,7 @@ class BoxConstraints extends Constraints { /// When you already have a [Size], prefer [constrain], which applies the same /// algorithm to a [Size] directly. Size constrainDimensions(double width, double height) { - return new Size(constrainWidth(width), constrainHeight(height)); + return Size(constrainWidth(width), constrainHeight(height)); } /// Returns a size that attempts to meet the following conditions, in order: @@ -328,16 +328,16 @@ class BoxConstraints extends Constraints { width = height * aspectRatio; } - Size result = new Size(constrainWidth(width), constrainHeight(height)); + Size result = Size(constrainWidth(width), constrainHeight(height)); assert(() { result = _debugPropagateDebugSize(size, result); return true; }()); return result; } /// The biggest size that satisfies the constraints. - Size get biggest => new Size(constrainWidth(), constrainHeight()); + Size get biggest => Size(constrainWidth(), constrainHeight()); /// The smallest size that satisfies the constraints. - Size get smallest => new Size(constrainWidth(0.0), constrainHeight(0.0)); + Size get smallest => Size(constrainWidth(0.0), constrainHeight(0.0)); /// Whether there is exactly one width value that satisfies the constraints. bool get hasTightWidth => minWidth >= maxWidth; @@ -406,7 +406,7 @@ class BoxConstraints extends Constraints { /// Scales each constraint parameter by the given factor. BoxConstraints operator*(double factor) { - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth * factor, maxWidth: maxWidth * factor, minHeight: minHeight * factor, @@ -416,7 +416,7 @@ class BoxConstraints extends Constraints { /// Scales each constraint parameter by the inverse of the given factor. BoxConstraints operator/(double factor) { - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth / factor, maxWidth: maxWidth / factor, minHeight: minHeight / factor, @@ -426,7 +426,7 @@ class BoxConstraints extends Constraints { /// Scales each constraint parameter by the inverse of the given factor, rounded to the nearest integer. BoxConstraints operator~/(double factor) { - return new BoxConstraints( + return BoxConstraints( minWidth: (minWidth ~/ factor).toDouble(), maxWidth: (maxWidth ~/ factor).toDouble(), minHeight: (minHeight ~/ factor).toDouble(), @@ -436,7 +436,7 @@ class BoxConstraints extends Constraints { /// Computes the remainder of each constraint parameter by the given value. BoxConstraints operator%(double value) { - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth % value, maxWidth: maxWidth % value, minHeight: minHeight % value, @@ -474,7 +474,7 @@ class BoxConstraints extends Constraints { assert((a.maxWidth.isFinite && b.maxWidth.isFinite) || (a.maxWidth == double.infinity && b.maxWidth == double.infinity), 'Cannot interpolate between finite constraints and unbounded constraints.'); assert((a.minHeight.isFinite && b.minHeight.isFinite) || (a.minHeight == double.infinity && b.minHeight == double.infinity), 'Cannot interpolate between finite constraints and unbounded constraints.'); assert((a.maxHeight.isFinite && b.maxHeight.isFinite) || (a.maxHeight == double.infinity && b.maxHeight == double.infinity), 'Cannot interpolate between finite constraints and unbounded constraints.'); - return new BoxConstraints( + return BoxConstraints( minWidth: a.minWidth.isFinite ? ui.lerpDouble(a.minWidth, b.minWidth, t) : double.infinity, maxWidth: a.maxWidth.isFinite ? ui.lerpDouble(a.maxWidth, b.maxWidth, t) : double.infinity, minHeight: a.minHeight.isFinite ? ui.lerpDouble(a.minHeight, b.minHeight, t) : double.infinity, @@ -508,10 +508,10 @@ class BoxConstraints extends Constraints { }) { assert(() { void throwError(String message) { - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); if (informationCollector != null) informationCollector(information); - throw new FlutterError('$message\n${information}The offending constraints were:\n $this'); + throw FlutterError('$message\n${information}The offending constraints were:\n $this'); } if (minWidth.isNaN || maxWidth.isNaN || minHeight.isNaN || maxHeight.isNaN) { final List affectedFieldsList = []; @@ -571,7 +571,7 @@ class BoxConstraints extends Constraints { return this; final double minWidth = this.minWidth >= 0.0 ? this.minWidth : 0.0; final double minHeight = this.minHeight >= 0.0 ? this.minHeight : 0.0; - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth, maxWidth: minWidth > maxWidth ? minWidth : maxWidth, minHeight: minHeight, @@ -1087,7 +1087,7 @@ abstract class RenderBox extends RenderObject { @override void setupParentData(covariant RenderObject child) { if (child.parentData is! BoxParentData) - child.parentData = new BoxParentData(); + child.parentData = BoxParentData(); } Map<_IntrinsicDimensionsCacheEntry, double> _cachedIntrinsicDimensions; @@ -1105,7 +1105,7 @@ abstract class RenderBox extends RenderObject { if (shouldCache) { _cachedIntrinsicDimensions ??= <_IntrinsicDimensionsCacheEntry, double>{}; return _cachedIntrinsicDimensions.putIfAbsent( - new _IntrinsicDimensionsCacheEntry(dimension, argument), + _IntrinsicDimensionsCacheEntry(dimension, argument), () => computer(argument) ); } @@ -1132,14 +1132,14 @@ abstract class RenderBox extends RenderObject { double getMinIntrinsicWidth(double height) { assert(() { if (height == null) { - throw new FlutterError( + throw FlutterError( 'The height argument to getMinIntrinsicWidth was null.\n' 'The argument to getMinIntrinsicWidth must not be negative or null. ' 'If you do not have a specific height in mind, then pass double.infinity instead.' ); } if (height < 0.0) { - throw new FlutterError( + throw FlutterError( 'The height argument to getMinIntrinsicWidth was negative.\n' 'The argument to getMinIntrinsicWidth must not be negative or null. ' 'If you perform computations on another height before passing it to ' @@ -1271,14 +1271,14 @@ abstract class RenderBox extends RenderObject { double getMaxIntrinsicWidth(double height) { assert(() { if (height == null) { - throw new FlutterError( + throw FlutterError( 'The height argument to getMaxIntrinsicWidth was null.\n' 'The argument to getMaxIntrinsicWidth must not be negative or null. ' 'If you do not have a specific height in mind, then pass double.infinity instead.' ); } if (height < 0.0) { - throw new FlutterError( + throw FlutterError( 'The height argument to getMaxIntrinsicWidth was negative.\n' 'The argument to getMaxIntrinsicWidth must not be negative or null. ' 'If you perform computations on another height before passing it to ' @@ -1347,14 +1347,14 @@ abstract class RenderBox extends RenderObject { double getMinIntrinsicHeight(double width) { assert(() { if (width == null) { - throw new FlutterError( + throw FlutterError( 'The width argument to getMinIntrinsicHeight was null.\n' 'The argument to getMinIntrinsicHeight must not be negative or null. ' 'If you do not have a specific width in mind, then pass double.infinity instead.' ); } if (width < 0.0) { - throw new FlutterError( + throw FlutterError( 'The width argument to getMinIntrinsicHeight was negative.\n' 'The argument to getMinIntrinsicHeight must not be negative or null. ' 'If you perform computations on another width before passing it to ' @@ -1420,14 +1420,14 @@ abstract class RenderBox extends RenderObject { double getMaxIntrinsicHeight(double width) { assert(() { if (width == null) { - throw new FlutterError( + throw FlutterError( 'The width argument to getMaxIntrinsicHeight was null.\n' 'The argument to getMaxIntrinsicHeight must not be negative or null. ' 'If you do not have a specific width in mind, then pass double.infinity instead.' ); } if (width < 0.0) { - throw new FlutterError( + throw FlutterError( 'The width argument to getMaxIntrinsicHeight was negative.\n' 'The argument to getMaxIntrinsicHeight must not be negative or null. ' 'If you perform computations on another width before passing it to ' @@ -1536,7 +1536,7 @@ abstract class RenderBox extends RenderObject { contract = 'Because this RenderBox has sizedByParent set to true, it must set its size in performResize().'; else contract = 'Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().'; - throw new FlutterError( + throw FlutterError( 'RenderBox size setter called incorrectly.\n' '$violation\n' '$hint\n' @@ -1572,7 +1572,7 @@ abstract class RenderBox extends RenderObject { if (value is _DebugSize) { if (value._owner != this) { if (value._owner.parent != this) { - throw new FlutterError( + throw FlutterError( 'The size property was assigned a size inappropriately.\n' 'The following render object:\n' ' $this\n' @@ -1594,7 +1594,7 @@ abstract class RenderBox extends RenderObject { ); } if (!value._canBeUsedByParent) { - throw new FlutterError( + throw FlutterError( 'A child\'s size was used without setting parentUsesSize.\n' 'The following render object:\n' ' $this\n' @@ -1610,7 +1610,7 @@ abstract class RenderBox extends RenderObject { } } } - result = new _DebugSize(value, this, debugCanParentUseSize); + result = _DebugSize(value, this, debugCanParentUseSize); return true; }()); return result; @@ -1728,7 +1728,7 @@ abstract class RenderBox extends RenderObject { contract = 'Because this RenderBox has sizedByParent set to true, it must set its size in performResize().\n'; else contract = 'Because this RenderBox has sizedByParent set to false, it must set its size in performLayout().\n'; - throw new FlutterError( + throw FlutterError( 'RenderBox did not set its size during layout.\n' '$contract' 'It appears that this did not happen; layout completed, but the size property is still null.\n' @@ -1738,7 +1738,7 @@ abstract class RenderBox extends RenderObject { } // verify that the size is not infinite if (!_size.isFinite) { - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); if (!constraints.hasBoundedWidth) { RenderBox node = this; while (!node.constraints.hasBoundedWidth && node.parent is RenderBox) @@ -1756,7 +1756,7 @@ abstract class RenderBox extends RenderObject { information.writeln(node.toStringShallow(joiner: '\n ')); } - throw new FlutterError( + throw FlutterError( '$runtimeType object was given an infinite size during layout.\n' 'This probably means that it is a render object that tries to be ' 'as big as possible, but it was put inside another render object ' @@ -1771,7 +1771,7 @@ abstract class RenderBox extends RenderObject { } // verify that the size is within the constraints if (!constraints.isSatisfiedBy(_size)) { - throw new FlutterError( + throw FlutterError( '$runtimeType does not meet its constraints.\n' 'Constraints: $constraints\n' 'Size: $_size\n' @@ -1783,7 +1783,7 @@ abstract class RenderBox extends RenderObject { // verify that the intrinsics are sane assert(!RenderObject.debugCheckingIntrinsics); RenderObject.debugCheckingIntrinsics = true; - final StringBuffer failures = new StringBuffer(); + final StringBuffer failures = StringBuffer(); int failureCount = 0; double testIntrinsic(double function(double extent), String name, double constraint) { @@ -1820,7 +1820,7 @@ abstract class RenderBox extends RenderObject { RenderObject.debugCheckingIntrinsics = false; if (failures.isNotEmpty) { assert(failureCount > 0); - throw new FlutterError( + throw FlutterError( 'The intrinsic dimension methods of the $runtimeType class returned values that violate the intrinsic protocol contract.\n' 'The following ${failureCount > 1 ? "failures" : "failure"} was detected:\n' '$failures' @@ -1863,7 +1863,7 @@ abstract class RenderBox extends RenderObject { void performLayout() { assert(() { if (!sizedByParent) { - throw new FlutterError( + throw FlutterError( '$runtimeType did not implement performLayout().\n' 'RenderBox subclasses need to either override performLayout() to ' 'set a size and lay out any children, or, set sizedByParent to true ' @@ -1896,7 +1896,7 @@ abstract class RenderBox extends RenderObject { assert(() { if (!hasSize) { if (debugNeedsLayout) { - throw new FlutterError( + throw FlutterError( 'Cannot hit test a render box that has never been laid out.\n' 'The hitTest() method was called on this RenderBox:\n' ' $this\n' @@ -1908,7 +1908,7 @@ abstract class RenderBox extends RenderObject { 'children, after their layout() method has been called).' ); } - throw new FlutterError( + throw FlutterError( 'Cannot hit test a render box with no size.\n' 'The hitTest() method was called on this RenderBox:\n' ' $this\n' @@ -1922,7 +1922,7 @@ abstract class RenderBox extends RenderObject { }()); if (_size.contains(position)) { if (hitTestChildren(result, position: position) || hitTestSelf(position)) { - result.add(new BoxHitTestEntry(this, position)); + result.add(BoxHitTestEntry(this, position)); return true; } } @@ -1975,7 +1975,7 @@ abstract class RenderBox extends RenderObject { assert(child.parent == this); assert(() { if (child.parentData is! BoxParentData) { - throw new FlutterError( + throw FlutterError( '$runtimeType does not implement applyPaintTransform.\n' 'The following $runtimeType object:\n' ' ${toStringShallow()}\n' @@ -2115,7 +2115,7 @@ abstract class RenderBox extends RenderObject { @protected void debugPaintSize(PaintingContext context, Offset offset) { assert(() { - final Paint paint = new Paint() + final Paint paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 1.0 ..color = const Color(0xFF00FFFF); @@ -2130,7 +2130,7 @@ abstract class RenderBox extends RenderObject { @protected void debugPaintBaselines(PaintingContext context, Offset offset) { assert(() { - final Paint paint = new Paint() + final Paint paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 0.25; Path path; @@ -2138,7 +2138,7 @@ abstract class RenderBox extends RenderObject { final double baselineI = getDistanceToBaseline(TextBaseline.ideographic, onlyReal: true); if (baselineI != null) { paint.color = const Color(0xFFFFD000); - path = new Path(); + path = Path(); path.moveTo(offset.dx, offset.dy + baselineI); path.lineTo(offset.dx + size.width, offset.dy + baselineI); context.canvas.drawPath(path, paint); @@ -2147,7 +2147,7 @@ abstract class RenderBox extends RenderObject { final double baselineA = getDistanceToBaseline(TextBaseline.alphabetic, onlyReal: true); if (baselineA != null) { paint.color = const Color(0xFF00FF00); - path = new Path(); + path = Path(); path.moveTo(offset.dx, offset.dy + baselineA); path.lineTo(offset.dx + size.width, offset.dy + baselineA); context.canvas.drawPath(path, paint); @@ -2167,8 +2167,8 @@ abstract class RenderBox extends RenderObject { void debugPaintPointers(PaintingContext context, Offset offset) { assert(() { if (_debugActivePointers > 0) { - final Paint paint = new Paint() - ..color = new Color(0x00BBBB | ((0x04000000 * depth) & 0xFF000000)); + final Paint paint = Paint() + ..color = Color(0x00BBBB | ((0x04000000 * depth) & 0xFF000000)); context.canvas.drawRect(offset & size, paint); } return true; @@ -2178,7 +2178,7 @@ abstract class RenderBox extends RenderObject { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('size', _size, missingIfNull: true)); + properties.add(DiagnosticsProperty('size', _size, missingIfNull: true)); } } diff --git a/packages/flutter/lib/src/rendering/custom_layout.dart b/packages/flutter/lib/src/rendering/custom_layout.dart index 6d02ddac3e..79f057785e 100644 --- a/packages/flutter/lib/src/rendering/custom_layout.dart +++ b/packages/flutter/lib/src/rendering/custom_layout.dart @@ -114,13 +114,13 @@ abstract class MultiChildLayoutDelegate { final RenderBox child = _idToChild[childId]; assert(() { if (child == null) { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate tried to lay out a non-existent child.\n' 'There is no child with the id "$childId".' ); } if (!_debugChildrenNeedingLayout.remove(child)) { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate tried to lay out the child with id "$childId" more than once.\n' 'Each child must be laid out exactly once.' ); @@ -128,7 +128,7 @@ abstract class MultiChildLayoutDelegate { try { assert(constraints.debugAssertIsValid(isAppliedConstraint: true)); } on AssertionError catch (exception) { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate provided invalid box constraints for the child with id "$childId".\n' '$exception\n' 'The minimum width and height must be greater than or equal to zero.\n' @@ -152,13 +152,13 @@ abstract class MultiChildLayoutDelegate { final RenderBox child = _idToChild[childId]; assert(() { if (child == null) { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate tried to position out a non-existent child:\n' 'There is no child with the id "$childId".' ); } if (offset == null) { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate provided a null position for the child with id "$childId".' ); } @@ -182,7 +182,7 @@ abstract class MultiChildLayoutDelegate { Set debugPreviousChildrenNeedingLayout; assert(() { debugPreviousChildrenNeedingLayout = _debugChildrenNeedingLayout; - _debugChildrenNeedingLayout = new Set(); + _debugChildrenNeedingLayout = Set(); return true; }()); @@ -193,7 +193,7 @@ abstract class MultiChildLayoutDelegate { final MultiChildLayoutParentData childParentData = child.parentData; assert(() { if (childParentData.id == null) { - throw new FlutterError( + throw FlutterError( 'The following child has no ID:\n' ' $child\n' 'Every child of a RenderCustomMultiChildLayoutBox must have an ID in its parent data.' @@ -212,13 +212,13 @@ abstract class MultiChildLayoutDelegate { assert(() { if (_debugChildrenNeedingLayout.isNotEmpty) { if (_debugChildrenNeedingLayout.length > 1) { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate forgot to lay out the following children:\n' ' ${_debugChildrenNeedingLayout.map(_debugDescribeChild).join("\n ")}\n' 'Each child must be laid out exactly once.' ); } else { - throw new FlutterError( + throw FlutterError( 'The $this custom multichild layout delegate forgot to lay out the following child:\n' ' ${_debugDescribeChild(_debugChildrenNeedingLayout.single)}\n' 'Each child must be laid out exactly once.' @@ -293,7 +293,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox @override void setupParentData(RenderBox child) { if (child.parentData is! MultiChildLayoutParentData) - child.parentData = new MultiChildLayoutParentData(); + child.parentData = MultiChildLayoutParentData(); } /// The delegate that controls the layout of the children. @@ -319,7 +319,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox @override double computeMinIntrinsicWidth(double height) { - final double width = _getSize(new BoxConstraints.tightForFinite(height: height)).width; + final double width = _getSize(BoxConstraints.tightForFinite(height: height)).width; if (width.isFinite) return width; return 0.0; @@ -327,7 +327,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox @override double computeMaxIntrinsicWidth(double height) { - final double width = _getSize(new BoxConstraints.tightForFinite(height: height)).width; + final double width = _getSize(BoxConstraints.tightForFinite(height: height)).width; if (width.isFinite) return width; return 0.0; @@ -335,7 +335,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox @override double computeMinIntrinsicHeight(double width) { - final double height = _getSize(new BoxConstraints.tightForFinite(width: width)).height; + final double height = _getSize(BoxConstraints.tightForFinite(width: width)).height; if (height.isFinite) return height; return 0.0; @@ -343,7 +343,7 @@ class RenderCustomMultiChildLayoutBox extends RenderBox @override double computeMaxIntrinsicHeight(double width) { - final double height = _getSize(new BoxConstraints.tightForFinite(width: width)).height; + final double height = _getSize(BoxConstraints.tightForFinite(width: width)).height; if (height.isFinite) return height; return 0.0; diff --git a/packages/flutter/lib/src/rendering/custom_paint.dart b/packages/flutter/lib/src/rendering/custom_paint.dart index 55a3a6c4da..17e82cfbed 100644 --- a/packages/flutter/lib/src/rendering/custom_paint.dart +++ b/packages/flutter/lib/src/rendering/custom_paint.dart @@ -528,7 +528,7 @@ class RenderCustomPaint extends RenderProxyBox { // below that number. final int debugNewCanvasSaveCount = canvas.getSaveCount(); if (debugNewCanvasSaveCount > debugPreviousCanvasSaveCount) { - throw new FlutterError( + throw FlutterError( 'The $painter custom painter called canvas.save() or canvas.saveLayer() at least ' '${debugNewCanvasSaveCount - debugPreviousCanvasSaveCount} more ' 'time${debugNewCanvasSaveCount - debugPreviousCanvasSaveCount == 1 ? '' : 's' } ' @@ -538,7 +538,7 @@ class RenderCustomPaint extends RenderProxyBox { ); } if (debugNewCanvasSaveCount < debugPreviousCanvasSaveCount) { - throw new FlutterError( + throw FlutterError( 'The $painter custom painter called canvas.restore() ' '${debugPreviousCanvasSaveCount - debugNewCanvasSaveCount} more ' 'time${debugPreviousCanvasSaveCount - debugNewCanvasSaveCount == 1 ? '' : 's' } ' @@ -600,7 +600,7 @@ class RenderCustomPaint extends RenderProxyBox { ) { assert(() { if (child == null && children.isNotEmpty) { - throw new FlutterError( + throw FlutterError( '$runtimeType does not have a child widget but received a non-empty list of child SemanticsNode:\n' '${children.join('\n')}' ); @@ -666,8 +666,8 @@ class RenderCustomPaint extends RenderProxyBox { newChildSemantics = newChildSemantics ?? const []; assert(() { - final Map keys = new HashMap(); - final StringBuffer errors = new StringBuffer(); + final Map keys = HashMap(); + final StringBuffer errors = StringBuffer(); for (int i = 0; i < newChildSemantics.length; i += 1) { final CustomPainterSemantics child = newChildSemantics[i]; if (child.key != null) { @@ -681,7 +681,7 @@ class RenderCustomPaint extends RenderProxyBox { } if (errors.isNotEmpty) { - throw new FlutterError( + throw FlutterError( 'Failed to update the list of CustomPainterSemantics:\n' '$errors' ); @@ -695,7 +695,7 @@ class RenderCustomPaint extends RenderProxyBox { int newChildrenBottom = newChildSemantics.length - 1; int oldChildrenBottom = oldSemantics.length - 1; - final List newChildren = new List(newChildSemantics.length); + final List newChildren = List(newChildSemantics.length); // Update the top of the list. while ((oldChildrenTop <= oldChildrenBottom) && (newChildrenTop <= newChildrenBottom)) { @@ -803,12 +803,12 @@ class RenderCustomPaint extends RenderProxyBox { static SemanticsNode _updateSemanticsChild(SemanticsNode oldChild, CustomPainterSemantics newSemantics) { assert(oldChild == null || _canUpdateSemanticsChild(oldChild, newSemantics)); - final SemanticsNode newChild = oldChild ?? new SemanticsNode( + final SemanticsNode newChild = oldChild ?? SemanticsNode( key: newSemantics.key, ); final SemanticsProperties properties = newSemantics.properties; - final SemanticsConfiguration config = new SemanticsConfiguration(); + final SemanticsConfiguration config = SemanticsConfiguration(); if (properties.sortKey != null) { config.sortKey = properties.sortKey; } diff --git a/packages/flutter/lib/src/rendering/debug.dart b/packages/flutter/lib/src/rendering/debug.dart index 65fd247d5c..67a4860df7 100644 --- a/packages/flutter/lib/src/rendering/debug.dart +++ b/packages/flutter/lib/src/rendering/debug.dart @@ -154,11 +154,11 @@ bool debugDisablePhysicalShapeLayers = false; bool debugDisableOpacityLayers = false; void _debugDrawDoubleRect(Canvas canvas, Rect outerRect, Rect innerRect, Color color) { - final Path path = new Path() + final Path path = Path() ..fillType = PathFillType.evenOdd ..addRect(outerRect) ..addRect(innerRect); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color; canvas.drawPath(path, paint); } @@ -173,7 +173,7 @@ void debugPaintPadding(Canvas canvas, Rect outerRect, Rect innerRect, { double o _debugDrawDoubleRect(canvas, outerRect, innerRect, const Color(0x900090FF)); _debugDrawDoubleRect(canvas, innerRect.inflate(outlineWidth).intersect(outerRect), innerRect, const Color(0xFF0090FF)); } else { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = const Color(0x90909090); canvas.drawRect(outerRect, paint); } @@ -206,7 +206,7 @@ bool debugAssertAllRenderVarsUnset(String reason, { bool debugCheckIntrinsicSize debugPrintLayouts || debugCheckIntrinsicSizes != debugCheckIntrinsicSizesOverride || debugProfilePaintsEnabled) { - throw new FlutterError(reason); + throw FlutterError(reason); } return true; }()); diff --git a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart index a7ab1b2ff9..b9fbdce827 100644 --- a/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart +++ b/packages/flutter/lib/src/rendering/debug_overflow_indicator.dart @@ -102,19 +102,19 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { fontSize: _indicatorFontSizePixels, fontWeight: FontWeight.w800, ); - static final Paint _indicatorPaint = new Paint() - ..shader = new ui.Gradient.linear( + static final Paint _indicatorPaint = Paint() + ..shader = ui.Gradient.linear( const Offset(0.0, 0.0), const Offset(10.0, 10.0), [_black, _yellow, _yellow, _black], [0.25, 0.25, 0.75, 0.75], TileMode.repeated, ); - static final Paint _labelBackgroundPaint = new Paint()..color = const Color(0xFFFFFFFF); + static final Paint _labelBackgroundPaint = Paint()..color = const Color(0xFFFFFFFF); - final List _indicatorLabel = new List.filled( + final List _indicatorLabel = List.filled( _OverflowSide.values.length, - new TextPainter(textDirection: TextDirection.ltr), // This label is in English. + TextPainter(textDirection: TextDirection.ltr), // This label is in English. ); // Set to true to trigger a debug message in the console upon @@ -137,13 +137,13 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { List<_OverflowRegionData> _calculateOverflowRegions(RelativeRect overflow, Rect containerRect) { final List<_OverflowRegionData> regions = <_OverflowRegionData>[]; if (overflow.left > 0.0) { - final Rect markerRect = new Rect.fromLTWH( + final Rect markerRect = Rect.fromLTWH( 0.0, 0.0, containerRect.width * _indicatorFraction, containerRect.height, ); - regions.add(new _OverflowRegionData( + regions.add(_OverflowRegionData( rect: markerRect, label: 'LEFT OVERFLOWED BY ${_formatPixels(overflow.left)} PIXELS', labelOffset: markerRect.centerLeft + @@ -153,13 +153,13 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { )); } if (overflow.right > 0.0) { - final Rect markerRect = new Rect.fromLTWH( + final Rect markerRect = Rect.fromLTWH( containerRect.width * (1.0 - _indicatorFraction), 0.0, containerRect.width * _indicatorFraction, containerRect.height, ); - regions.add(new _OverflowRegionData( + regions.add(_OverflowRegionData( rect: markerRect, label: 'RIGHT OVERFLOWED BY ${_formatPixels(overflow.right)} PIXELS', labelOffset: markerRect.centerRight - @@ -169,13 +169,13 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { )); } if (overflow.top > 0.0) { - final Rect markerRect = new Rect.fromLTWH( + final Rect markerRect = Rect.fromLTWH( 0.0, 0.0, containerRect.width, containerRect.height * _indicatorFraction, ); - regions.add(new _OverflowRegionData( + regions.add(_OverflowRegionData( rect: markerRect, label: 'TOP OVERFLOWED BY ${_formatPixels(overflow.top)} PIXELS', labelOffset: markerRect.topCenter + const Offset(0.0, _indicatorLabelPaddingPixels), @@ -184,13 +184,13 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { )); } if (overflow.bottom > 0.0) { - final Rect markerRect = new Rect.fromLTWH( + final Rect markerRect = Rect.fromLTWH( 0.0, containerRect.height * (1.0 - _indicatorFraction), containerRect.width, containerRect.height * _indicatorFraction, ); - regions.add(new _OverflowRegionData( + regions.add(_OverflowRegionData( rect: markerRect, label: 'BOTTOM OVERFLOWED BY ${_formatPixels(overflow.bottom)} PIXELS', labelOffset: markerRect.bottomCenter - @@ -237,7 +237,7 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { overflowText = overflows.join(', '); } FlutterError.reportError( - new FlutterErrorDetailsForRendering( + FlutterErrorDetailsForRendering( exception: 'A $runtimeType overflowed by $overflowText.', library: 'rendering library', context: 'during layout', @@ -265,7 +265,7 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { Rect childRect, { String overflowHints, }) { - final RelativeRect overflow = new RelativeRect.fromRect(containerRect, childRect); + final RelativeRect overflow = RelativeRect.fromRect(containerRect, childRect); if (overflow.left <= 0.0 && overflow.right <= 0.0 && @@ -279,7 +279,7 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { context.canvas.drawRect(region.rect.shift(offset), _indicatorPaint); if (_indicatorLabel[region.side.index].text?.text != region.label) { - _indicatorLabel[region.side.index].text = new TextSpan( + _indicatorLabel[region.side.index].text = TextSpan( text: region.label, style: _indicatorTextStyle, ); @@ -287,7 +287,7 @@ abstract class DebugOverflowIndicatorMixin extends RenderObject { } final Offset labelOffset = region.labelOffset + offset; - final Offset centerOffset = new Offset(-_indicatorLabel[region.side.index].width / 2.0, 0.0); + final Offset centerOffset = Offset(-_indicatorLabel[region.side.index].width / 2.0, 0.0); final Rect textBackgroundRect = centerOffset & _indicatorLabel[region.side.index].size; context.canvas.save(); context.canvas.translate(labelOffset.dx, labelOffset.dy); diff --git a/packages/flutter/lib/src/rendering/editable.dart b/packages/flutter/lib/src/rendering/editable.dart index 1d09dc7bcc..5edfb10d50 100644 --- a/packages/flutter/lib/src/rendering/editable.dart +++ b/packages/flutter/lib/src/rendering/editable.dart @@ -144,7 +144,7 @@ class RenderEditable extends RenderBox { assert(ignorePointer != null), assert(obscureText != null), assert(textSelectionDelegate != null), - _textPainter = new TextPainter( + _textPainter = TextPainter( text: text, textAlign: textAlign, textDirection: textDirection, @@ -152,7 +152,7 @@ class RenderEditable extends RenderBox { locale: locale, ), _cursorColor = cursorColor, - _showCursor = showCursor ?? new ValueNotifier(false), + _showCursor = showCursor ?? ValueNotifier(false), _hasFocus = hasFocus ?? false, _maxLines = maxLines, _selectionColor = selectionColor, @@ -163,10 +163,10 @@ class RenderEditable extends RenderBox { _obscureText = obscureText { assert(_showCursor != null); assert(!_showCursor.value || cursorColor != null); - _tap = new TapGestureRecognizer(debugOwner: this) + _tap = TapGestureRecognizer(debugOwner: this) ..onTapDown = _handleTapDown ..onTap = _handleTap; - _longPress = new LongPressGestureRecognizer(debugOwner: this) + _longPress = LongPressGestureRecognizer(debugOwner: this) ..onLongPress = _handleLongPress; } @@ -294,10 +294,10 @@ class RenderEditable extends RenderBox { // If control is pressed, we will decide which way to look for a word // based on which arrow is pressed. if (leftArrow && _extentOffset > 2) { - final TextSelection textSelection = _selectWordAtOffset(new TextPosition(offset: _extentOffset - 2)); + final TextSelection textSelection = _selectWordAtOffset(TextPosition(offset: _extentOffset - 2)); newOffset = textSelection.baseOffset + 1; } else if (rightArrow && _extentOffset < text.text.length - 2) { - final TextSelection textSelection = _selectWordAtOffset(new TextPosition(offset: _extentOffset + 1)); + final TextSelection textSelection = _selectWordAtOffset(TextPosition(offset: _extentOffset + 1)); newOffset = textSelection.extentOffset - 1; } return newOffset; @@ -329,7 +329,7 @@ class RenderEditable extends RenderBox { final double plh = _textPainter.preferredLineHeight; final double verticalOffset = upArrow ? -0.5 * plh : 1.5 * plh; - final Offset caretOffset = _textPainter.getOffsetForCaret(new TextPosition(offset: _extentOffset), _caretPrototype); + final Offset caretOffset = _textPainter.getOffsetForCaret(TextPosition(offset: _extentOffset), _caretPrototype); final Offset caretOffsetTranslated = caretOffset.translate(0.0, verticalOffset); final TextPosition position = _textPainter.getPositionForOffset(caretOffsetTranslated); @@ -363,7 +363,7 @@ class RenderEditable extends RenderBox { if (shift) { if (_baseOffset < newOffset) { onSelectionChanged( - new TextSelection( + TextSelection( baseOffset: _baseOffset, extentOffset: newOffset ), @@ -372,7 +372,7 @@ class RenderEditable extends RenderBox { ); } else { onSelectionChanged( - new TextSelection( + TextSelection( baseOffset: newOffset, extentOffset: _baseOffset ), @@ -390,8 +390,8 @@ class RenderEditable extends RenderBox { newOffset = _baseOffset > _extentOffset ? _baseOffset : _extentOffset; } onSelectionChanged( - new TextSelection.fromPosition( - new TextPosition( + TextSelection.fromPosition( + TextPosition( offset: newOffset ) ), @@ -409,17 +409,17 @@ class RenderEditable extends RenderBox { case _kCKeyCode: if (!selection.isCollapsed) { Clipboard.setData( - new ClipboardData(text: selection.textInside(text.text))); + ClipboardData(text: selection.textInside(text.text))); } break; case _kXKeyCode: if (!selection.isCollapsed) { Clipboard.setData( - new ClipboardData(text: selection.textInside(text.text))); - textSelectionDelegate.textEditingValue = new TextEditingValue( + ClipboardData(text: selection.textInside(text.text))); + textSelectionDelegate.textEditingValue = TextEditingValue( text: selection.textBefore(text.text) + selection.textAfter(text.text), - selection: new TextSelection.collapsed(offset: selection.start), + selection: TextSelection.collapsed(offset: selection.start), ); } break; @@ -429,11 +429,11 @@ class RenderEditable extends RenderBox { final TextEditingValue value = textSelectionDelegate.textEditingValue; final ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); if (data != null) { - textSelectionDelegate.textEditingValue = new TextEditingValue( + textSelectionDelegate.textEditingValue = TextEditingValue( text: value.selection.textBefore(value.text) + data.text + value.selection.textAfter(value.text), - selection: new TextSelection.collapsed( + selection: TextSelection.collapsed( offset: value.selection.start + data.text.length ), ); @@ -443,7 +443,7 @@ class RenderEditable extends RenderBox { _baseOffset = 0; _extentOffset = textSelectionDelegate.textEditingValue.text.length; onSelectionChanged( - new TextSelection( + TextSelection( baseOffset: 0, extentOffset: textSelectionDelegate.textEditingValue.text.length, ), @@ -458,15 +458,15 @@ class RenderEditable extends RenderBox { void _handleDelete() { if (selection.textAfter(text.text).isNotEmpty) { - textSelectionDelegate.textEditingValue = new TextEditingValue( + textSelectionDelegate.textEditingValue = TextEditingValue( text: selection.textBefore(text.text) + selection.textAfter(text.text).substring(1), - selection: new TextSelection.collapsed(offset: selection.start) + selection: TextSelection.collapsed(offset: selection.start) ); } else { - textSelectionDelegate.textEditingValue = new TextEditingValue( + textSelectionDelegate.textEditingValue = TextEditingValue( text: selection.textBefore(text.text), - selection: new TextSelection.collapsed(offset: selection.start) + selection: TextSelection.collapsed(offset: selection.start) ); } } @@ -731,7 +731,7 @@ class RenderEditable extends RenderBox { return; final int baseOffset = !extentSelection ? extentOffset : _selection.baseOffset; onSelectionChanged( - new TextSelection(baseOffset: baseOffset, extentOffset: extentOffset), this, SelectionChangedCause.keyboard, + TextSelection(baseOffset: baseOffset, extentOffset: extentOffset), this, SelectionChangedCause.keyboard, ); } @@ -741,7 +741,7 @@ class RenderEditable extends RenderBox { return; final int baseOffset = !extentSelection ? extentOffset : _selection.baseOffset; onSelectionChanged( - new TextSelection(baseOffset: baseOffset, extentOffset: extentOffset), this, SelectionChangedCause.keyboard, + TextSelection(baseOffset: baseOffset, extentOffset: extentOffset), this, SelectionChangedCause.keyboard, ); } @@ -754,7 +754,7 @@ class RenderEditable extends RenderBox { return; final int baseOffset = extentSelection ? _selection.baseOffset : nextWord.start; onSelectionChanged( - new TextSelection( + TextSelection( baseOffset: baseOffset, extentOffset: nextWord.start, ), @@ -772,7 +772,7 @@ class RenderEditable extends RenderBox { return; final int baseOffset = extentSelection ? _selection.baseOffset : previousWord.start; onSelectionChanged( - new TextSelection( + TextSelection( baseOffset: baseOffset, extentOffset: previousWord.start, ), @@ -783,7 +783,7 @@ class RenderEditable extends RenderBox { TextRange _getNextWord(int offset) { while (true) { - final TextRange range = _textPainter.getWordBoundary(new TextPosition(offset: offset)); + final TextRange range = _textPainter.getWordBoundary(TextPosition(offset: offset)); if (range == null || !range.isValid || range.isCollapsed) return null; if (!_onlyWhitespace(range)) @@ -794,7 +794,7 @@ class RenderEditable extends RenderBox { TextRange _getPreviousWord(int offset) { while (offset >= 0) { - final TextRange range = _textPainter.getWordBoundary(new TextPosition(offset: offset)); + final TextRange range = _textPainter.getWordBoundary(TextPosition(offset: offset)); if (range == null || !range.isValid || range.isCollapsed) return null; if (!_onlyWhitespace(range)) @@ -871,9 +871,9 @@ class RenderEditable extends RenderBox { Offset get _paintOffset { switch (_viewportAxis) { case Axis.horizontal: - return new Offset(-offset.pixels, 0.0); + return Offset(-offset.pixels, 0.0); case Axis.vertical: - return new Offset(0.0, -offset.pixels); + return Offset(0.0, -offset.pixels); } return null; } @@ -923,15 +923,15 @@ class RenderEditable extends RenderBox { if (selection.isCollapsed) { // TODO(mpcomplete): This doesn't work well at an RTL/LTR boundary. final Offset caretOffset = _textPainter.getOffsetForCaret(selection.extent, _caretPrototype); - final Offset start = new Offset(0.0, preferredLineHeight) + caretOffset + paintOffset; - return [new TextSelectionPoint(start, null)]; + final Offset start = Offset(0.0, preferredLineHeight) + caretOffset + paintOffset; + return [TextSelectionPoint(start, null)]; } else { final List boxes = _textPainter.getBoxesForSelection(selection); - final Offset start = new Offset(boxes.first.start, boxes.first.bottom) + paintOffset; - final Offset end = new Offset(boxes.last.end, boxes.last.bottom) + paintOffset; + final Offset start = Offset(boxes.first.start, boxes.first.bottom) + paintOffset; + final Offset end = Offset(boxes.last.end, boxes.last.bottom) + paintOffset; return [ - new TextSelectionPoint(start, boxes.first.direction), - new TextSelectionPoint(end, boxes.last.direction), + TextSelectionPoint(start, boxes.first.direction), + TextSelectionPoint(end, boxes.last.direction), ]; } } @@ -965,7 +965,7 @@ class RenderEditable extends RenderBox { _layoutText(constraints.maxWidth); final Offset caretOffset = _textPainter.getOffsetForCaret(caretPosition, _caretPrototype); // This rect is the same as _caretPrototype but without the vertical padding. - return new Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight).shift(caretOffset + _paintOffset); + return Rect.fromLTWH(0.0, 0.0, cursorWidth, preferredLineHeight).shift(caretOffset + _paintOffset); } @override @@ -1060,7 +1060,7 @@ class RenderEditable extends RenderBox { assert(_lastTapDownPosition != null); if (onSelectionChanged != null) { final TextPosition position = _textPainter.getPositionForOffset(globalToLocal(_lastTapDownPosition)); - onSelectionChanged(new TextSelection.fromPosition(position), this, SelectionChangedCause.tap); + onSelectionChanged(TextSelection.fromPosition(position), this, SelectionChangedCause.tap); } } void _handleTap() { @@ -1092,8 +1092,8 @@ class RenderEditable extends RenderBox { final TextRange word = _textPainter.getWordBoundary(position); // When long-pressing past the end of the text, we want a collapsed cursor. if (position.offset >= word.end) - return new TextSelection.fromPosition(position); - return new TextSelection(baseOffset: word.start, extentOffset: word.end); + return TextSelection.fromPosition(position); + return TextSelection(baseOffset: word.start, extentOffset: word.end); } Rect _caretPrototype; @@ -1112,7 +1112,7 @@ class RenderEditable extends RenderBox { @override void performLayout() { _layoutText(constraints.maxWidth); - _caretPrototype = new Rect.fromLTWH(0.0, _kCaretHeightOffset, cursorWidth, preferredLineHeight - 2.0 * _kCaretHeightOffset); + _caretPrototype = Rect.fromLTWH(0.0, _kCaretHeightOffset, cursorWidth, preferredLineHeight - 2.0 * _kCaretHeightOffset); _selectionRects = null; // We grab _textPainter.size here because assigning to `size` on the next // line will trigger us to validate our intrinsic sizes, which will change @@ -1123,8 +1123,8 @@ class RenderEditable extends RenderBox { // though we currently don't use those here. // See also RenderParagraph which has a similar issue. final Size textPainterSize = _textPainter.size; - size = new Size(constraints.maxWidth, constraints.constrainHeight(_preferredHeight(constraints.maxWidth))); - final Size contentSize = new Size(textPainterSize.width + _kCaretGap + cursorWidth, textPainterSize.height); + size = Size(constraints.maxWidth, constraints.constrainHeight(_preferredHeight(constraints.maxWidth))); + final Size contentSize = Size(textPainterSize.width + _kCaretGap + cursorWidth, textPainterSize.height); final double _maxScrollExtent = _getMaxScrollExtent(contentSize); _hasVisualOverflow = _maxScrollExtent > 0.0; offset.applyViewportDimension(_viewportExtent); @@ -1134,7 +1134,7 @@ class RenderEditable extends RenderBox { void _paintCaret(Canvas canvas, Offset effectiveOffset) { assert(_textLayoutLastWidth == constraints.maxWidth); final Offset caretOffset = _textPainter.getOffsetForCaret(_selection.extent, _caretPrototype); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = _cursorColor; final Rect caretRect = _caretPrototype.shift(caretOffset + effectiveOffset); @@ -1156,7 +1156,7 @@ class RenderEditable extends RenderBox { void _paintSelection(Canvas canvas, Offset effectiveOffset) { assert(_textLayoutLastWidth == constraints.maxWidth); assert(_selectionRects != null); - final Paint paint = new Paint()..color = _selectionColor; + final Paint paint = Paint()..color = _selectionColor; for (ui.TextBox box in _selectionRects) canvas.drawRect(box.toRect().shift(effectiveOffset), paint); } @@ -1192,14 +1192,14 @@ class RenderEditable extends RenderBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('cursorColor', cursorColor)); - properties.add(new DiagnosticsProperty>('showCursor', showCursor)); - properties.add(new IntProperty('maxLines', maxLines)); - properties.add(new DiagnosticsProperty('selectionColor', selectionColor)); - properties.add(new DoubleProperty('textScaleFactor', textScaleFactor)); - properties.add(new DiagnosticsProperty('locale', locale, defaultValue: null)); - properties.add(new DiagnosticsProperty('selection', selection)); - properties.add(new DiagnosticsProperty('offset', offset)); + properties.add(DiagnosticsProperty('cursorColor', cursorColor)); + properties.add(DiagnosticsProperty>('showCursor', showCursor)); + properties.add(IntProperty('maxLines', maxLines)); + properties.add(DiagnosticsProperty('selectionColor', selectionColor)); + properties.add(DoubleProperty('textScaleFactor', textScaleFactor)); + properties.add(DiagnosticsProperty('locale', locale, defaultValue: null)); + properties.add(DiagnosticsProperty('selection', selection)); + properties.add(DiagnosticsProperty('offset', offset)); } @override diff --git a/packages/flutter/lib/src/rendering/error.dart b/packages/flutter/lib/src/rendering/error.dart index 7dfda9c001..3881fdfd5e 100644 --- a/packages/flutter/lib/src/rendering/error.dart +++ b/packages/flutter/lib/src/rendering/error.dart @@ -43,7 +43,7 @@ class RenderErrorBox extends RenderBox { // Generally, the much better way to draw text in a RenderObject is to // use the TextPainter class. If you're looking for code to crib from, // see the paragraph.dart file and the RenderParagraph class. - final ui.ParagraphBuilder builder = new ui.ParagraphBuilder(paragraphStyle); + final ui.ParagraphBuilder builder = ui.ParagraphBuilder(paragraphStyle); builder.pushStyle(textStyle); builder.addText( '$message$_kLine$message$_kLine$message$_kLine$message$_kLine$message$_kLine$message$_kLine' @@ -84,7 +84,7 @@ class RenderErrorBox extends RenderBox { static Color backgroundColor = const Color(0xF0900000); /// The text style to use when painting [RenderErrorBox] objects. - static ui.TextStyle textStyle = new ui.TextStyle( + static ui.TextStyle textStyle = ui.TextStyle( color: const Color(0xFFFFFF66), fontFamily: 'monospace', fontSize: 14.0, @@ -92,14 +92,14 @@ class RenderErrorBox extends RenderBox { ); /// The paragraph style to use when painting [RenderErrorBox] objects. - static ui.ParagraphStyle paragraphStyle = new ui.ParagraphStyle( + static ui.ParagraphStyle paragraphStyle = ui.ParagraphStyle( lineHeight: 1.0, ); @override void paint(PaintingContext context, Offset offset) { try { - context.canvas.drawRect(offset & size, new Paint() .. color = backgroundColor); + context.canvas.drawRect(offset & size, Paint() .. color = backgroundColor); double width; if (_paragraph != null) { // See the comment in the RenderErrorBox constructor. This is not the @@ -110,7 +110,7 @@ class RenderErrorBox extends RenderBox { } else { width = size.width; } - _paragraph.layout(new ui.ParagraphConstraints(width: width)); + _paragraph.layout(ui.ParagraphConstraints(width: width)); context.canvas.drawParagraph(_paragraph, offset); } diff --git a/packages/flutter/lib/src/rendering/flex.dart b/packages/flutter/lib/src/rendering/flex.dart index 97a85ce1db..970297467b 100644 --- a/packages/flutter/lib/src/rendering/flex.dart +++ b/packages/flutter/lib/src/rendering/flex.dart @@ -474,7 +474,7 @@ class RenderFlex extends RenderBox with ContainerRenderObjectMixin('direction', direction)); - properties.add(new EnumProperty('mainAxisAlignment', mainAxisAlignment)); - properties.add(new EnumProperty('mainAxisSize', mainAxisSize)); - properties.add(new EnumProperty('crossAxisAlignment', crossAxisAlignment)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new EnumProperty('verticalDirection', verticalDirection, defaultValue: null)); - properties.add(new EnumProperty('textBaseline', textBaseline, defaultValue: null)); + properties.add(EnumProperty('direction', direction)); + properties.add(EnumProperty('mainAxisAlignment', mainAxisAlignment)); + properties.add(EnumProperty('mainAxisSize', mainAxisSize)); + properties.add(EnumProperty('crossAxisAlignment', crossAxisAlignment)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('verticalDirection', verticalDirection, defaultValue: null)); + properties.add(EnumProperty('textBaseline', textBaseline, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/rendering/flow.dart b/packages/flutter/lib/src/rendering/flow.dart index d6f764bf17..24a5cdcb0d 100644 --- a/packages/flutter/lib/src/rendering/flow.dart +++ b/packages/flutter/lib/src/rendering/flow.dart @@ -193,7 +193,7 @@ class RenderFlow extends RenderBox if (childParentData is FlowParentData) childParentData._transform = null; else - child.parentData = new FlowParentData(); + child.parentData = FlowParentData(); } /// The delegate that controls the transformation matrices of the children. @@ -248,7 +248,7 @@ class RenderFlow extends RenderBox @override double computeMinIntrinsicWidth(double height) { - final double width = _getSize(new BoxConstraints.tightForFinite(height: height)).width; + final double width = _getSize(BoxConstraints.tightForFinite(height: height)).width; if (width.isFinite) return width; return 0.0; @@ -256,7 +256,7 @@ class RenderFlow extends RenderBox @override double computeMaxIntrinsicWidth(double height) { - final double width = _getSize(new BoxConstraints.tightForFinite(height: height)).width; + final double width = _getSize(BoxConstraints.tightForFinite(height: height)).width; if (width.isFinite) return width; return 0.0; @@ -264,7 +264,7 @@ class RenderFlow extends RenderBox @override double computeMinIntrinsicHeight(double width) { - final double height = _getSize(new BoxConstraints.tightForFinite(width: width)).height; + final double height = _getSize(BoxConstraints.tightForFinite(width: width)).height; if (height.isFinite) return height; return 0.0; @@ -272,7 +272,7 @@ class RenderFlow extends RenderBox @override double computeMaxIntrinsicHeight(double width) { - final double height = _getSize(new BoxConstraints.tightForFinite(width: width)).height; + final double height = _getSize(BoxConstraints.tightForFinite(width: width)).height; if (height.isFinite) return height; return 0.0; @@ -314,12 +314,12 @@ class RenderFlow extends RenderBox @override void paintChild(int i, { Matrix4 transform, double opacity = 1.0 }) { - transform ??= new Matrix4.identity(); + transform ??= Matrix4.identity(); final RenderBox child = _randomAccessChildren[i]; final FlowParentData childParentData = child.parentData; assert(() { if (childParentData._transform != null) { - throw new FlutterError( + throw FlutterError( 'Cannot call paintChild twice for the same child.\n' 'The flow delegate of type ${_delegate.runtimeType} attempted to ' 'paint child $i multiple times, which is not permitted.' @@ -380,7 +380,7 @@ class RenderFlow extends RenderBox final Matrix4 transform = childParentData._transform; if (transform == null) continue; - final Matrix4 inverse = new Matrix4.zero(); + final Matrix4 inverse = Matrix4.zero(); final double determinate = inverse.copyInverse(transform); if (determinate == 0.0) { // We cannot invert the transform. That means the child doesn't appear diff --git a/packages/flutter/lib/src/rendering/image.dart b/packages/flutter/lib/src/rendering/image.dart index 5da0e1d3f5..4d4991c697 100644 --- a/packages/flutter/lib/src/rendering/image.dart +++ b/packages/flutter/lib/src/rendering/image.dart @@ -129,7 +129,7 @@ class RenderImage extends RenderBox { if (_color == null) _colorFilter = null; else - _colorFilter = new ColorFilter.mode(_color, _colorBlendMode ?? BlendMode.srcIn); + _colorFilter = ColorFilter.mode(_color, _colorBlendMode ?? BlendMode.srcIn); } /// If non-null, this color is blended with each image pixel using [colorBlendMode]. @@ -263,7 +263,7 @@ class RenderImage extends RenderBox { Size _sizeForConstraints(BoxConstraints constraints) { // Folds the given |width| and |height| into |constraints| so they can all // be treated uniformly. - constraints = new BoxConstraints.tightFor( + constraints = BoxConstraints.tightFor( width: _width, height: _height ).enforce(constraints); @@ -271,7 +271,7 @@ class RenderImage extends RenderBox { if (_image == null) return constraints.smallest; - return constraints.constrainSizeAndAttemptToPreserveAspectRatio(new Size( + return constraints.constrainSizeAndAttemptToPreserveAspectRatio(Size( _image.width.toDouble() / _scale, _image.height.toDouble() / _scale )); @@ -282,13 +282,13 @@ class RenderImage extends RenderBox { assert(height >= 0.0); if (_width == null && _height == null) return 0.0; - return _sizeForConstraints(new BoxConstraints.tightForFinite(height: height)).width; + return _sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width; } @override double computeMaxIntrinsicWidth(double height) { assert(height >= 0.0); - return _sizeForConstraints(new BoxConstraints.tightForFinite(height: height)).width; + return _sizeForConstraints(BoxConstraints.tightForFinite(height: height)).width; } @override @@ -296,13 +296,13 @@ class RenderImage extends RenderBox { assert(width >= 0.0); if (_width == null && _height == null) return 0.0; - return _sizeForConstraints(new BoxConstraints.tightForFinite(width: width)).height; + return _sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height; } @override double computeMaxIntrinsicHeight(double width) { assert(width >= 0.0); - return _sizeForConstraints(new BoxConstraints.tightForFinite(width: width)).height; + return _sizeForConstraints(BoxConstraints.tightForFinite(width: width)).height; } @override @@ -337,17 +337,17 @@ class RenderImage extends RenderBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('image', image)); - properties.add(new DoubleProperty('width', width, defaultValue: null)); - properties.add(new DoubleProperty('height', height, defaultValue: null)); - properties.add(new DoubleProperty('scale', scale, defaultValue: 1.0)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new EnumProperty('colorBlendMode', colorBlendMode, defaultValue: null)); - properties.add(new EnumProperty('fit', fit, defaultValue: null)); - properties.add(new DiagnosticsProperty('alignment', alignment, defaultValue: null)); - properties.add(new EnumProperty('repeat', repeat, defaultValue: ImageRepeat.noRepeat)); - properties.add(new DiagnosticsProperty('centerSlice', centerSlice, defaultValue: null)); - properties.add(new FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction')); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('image', image)); + properties.add(DoubleProperty('width', width, defaultValue: null)); + properties.add(DoubleProperty('height', height, defaultValue: null)); + properties.add(DoubleProperty('scale', scale, defaultValue: 1.0)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(EnumProperty('colorBlendMode', colorBlendMode, defaultValue: null)); + properties.add(EnumProperty('fit', fit, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment, defaultValue: null)); + properties.add(EnumProperty('repeat', repeat, defaultValue: ImageRepeat.noRepeat)); + properties.add(DiagnosticsProperty('centerSlice', centerSlice, defaultValue: null)); + properties.add(FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction')); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/rendering/layer.dart b/packages/flutter/lib/src/rendering/layer.dart index a4c511f3d8..67ab28afd8 100644 --- a/packages/flutter/lib/src/rendering/layer.dart +++ b/packages/flutter/lib/src/rendering/layer.dart @@ -121,8 +121,8 @@ abstract class Layer extends AbstractNode with DiagnosticableTreeMixin { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('owner', owner, level: parent != null ? DiagnosticLevel.hidden : DiagnosticLevel.info, defaultValue: null)); - properties.add(new DiagnosticsProperty('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('owner', owner, level: parent != null ? DiagnosticLevel.hidden : DiagnosticLevel.info, defaultValue: null)); + properties.add(DiagnosticsProperty('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug)); } } @@ -178,7 +178,7 @@ class PictureLayer extends Layer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('paint bounds', canvasBounds)); + properties.add(DiagnosticsProperty('paint bounds', canvasBounds)); } @override @@ -567,7 +567,7 @@ class OffsetLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('offset', offset)); + properties.add(DiagnosticsProperty('offset', offset)); } /// Capture an image of the current state of this layer and its children. @@ -589,8 +589,8 @@ class OffsetLayer extends ContainerLayer { Future toImage(Rect bounds, {double pixelRatio = 1.0}) async { assert(bounds != null); assert(pixelRatio != null); - final ui.SceneBuilder builder = new ui.SceneBuilder(); - final Matrix4 transform = new Matrix4.translationValues( + final ui.SceneBuilder builder = ui.SceneBuilder(); + final Matrix4 transform = Matrix4.translationValues( (-bounds.left - offset.dx) * pixelRatio, (-bounds.top - offset.dy) * pixelRatio, 0.0, @@ -668,7 +668,7 @@ class ClipRectLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('clipRect', clipRect)); + properties.add(DiagnosticsProperty('clipRect', clipRect)); } } @@ -724,7 +724,7 @@ class ClipRRectLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('clipRRect', clipRRect)); + properties.add(DiagnosticsProperty('clipRRect', clipRRect)); } } @@ -819,7 +819,7 @@ class TransformLayer extends OffsetLayer { _lastEffectiveTransform = transform; final Offset totalOffset = offset + layerOffset; if (totalOffset != Offset.zero) { - _lastEffectiveTransform = new Matrix4.translationValues(totalOffset.dx, totalOffset.dy, 0.0) + _lastEffectiveTransform = Matrix4.translationValues(totalOffset.dx, totalOffset.dy, 0.0) ..multiply(_lastEffectiveTransform); } builder.pushTransform(_lastEffectiveTransform.storage); @@ -835,9 +835,9 @@ class TransformLayer extends OffsetLayer { } if (_invertedTransform == null) return null; - final Vector4 vector = new Vector4(regionOffset.dx, regionOffset.dy, 0.0, 1.0); + final Vector4 vector = Vector4(regionOffset.dx, regionOffset.dy, 0.0, 1.0); final Vector4 result = _invertedTransform.transform(vector); - return super.find(new Offset(result[0], result[1])); + return super.find(Offset(result[0], result[1])); } @override @@ -850,7 +850,7 @@ class TransformLayer extends OffsetLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new TransformProperty('transform', transform)); + properties.add(TransformProperty('transform', transform)); } } @@ -892,7 +892,7 @@ class OpacityLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new IntProperty('alpha', alpha)); + properties.add(IntProperty('alpha', alpha)); } } @@ -932,9 +932,9 @@ class ShaderMaskLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('shader', shader)); - properties.add(new DiagnosticsProperty('maskRect', maskRect)); - properties.add(new DiagnosticsProperty('blendMode', blendMode)); + properties.add(DiagnosticsProperty('shader', shader)); + properties.add(DiagnosticsProperty('maskRect', maskRect)); + properties.add(DiagnosticsProperty('blendMode', blendMode)); } } @@ -1047,8 +1047,8 @@ class PhysicalModelLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('elevation', elevation)); - properties.add(new DiagnosticsProperty('color', color)); + properties.add(DoubleProperty('elevation', elevation)); + properties.add(DiagnosticsProperty('color', color)); } } @@ -1137,7 +1137,7 @@ class LeaderLayer extends ContainerLayer { assert(offset != null); _lastOffset = offset + layerOffset; if (_lastOffset != Offset.zero) - builder.pushTransform(new Matrix4.translationValues(_lastOffset.dx, _lastOffset.dy, 0.0).storage); + builder.pushTransform(Matrix4.translationValues(_lastOffset.dx, _lastOffset.dy, 0.0).storage); addChildrenToScene(builder, Offset.zero); if (_lastOffset != Offset.zero) builder.pop(); @@ -1160,8 +1160,8 @@ class LeaderLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('offset', offset)); - properties.add(new DiagnosticsProperty('link', link)); + properties.add(DiagnosticsProperty('offset', offset)); + properties.add(DiagnosticsProperty('link', link)); } } @@ -1254,9 +1254,9 @@ class FollowerLayer extends ContainerLayer { } if (_invertedTransform == null) return null; - final Vector4 vector = new Vector4(regionOffset.dx, regionOffset.dy, 0.0, 1.0); + final Vector4 vector = Vector4(regionOffset.dx, regionOffset.dy, 0.0, 1.0); final Vector4 result = _invertedTransform.transform(vector); - return super.find(new Offset(result[0] - linkedOffset.dx, result[1] - linkedOffset.dy)); + return super.find(Offset(result[0] - linkedOffset.dx, result[1] - linkedOffset.dy)); } /// The transform that was used during the last composition phase. @@ -1268,7 +1268,7 @@ class FollowerLayer extends ContainerLayer { Matrix4 getLastTransform() { if (_lastTransform == null) return null; - final Matrix4 result = new Matrix4.translationValues(-_lastOffset.dx, -_lastOffset.dy, 0.0); + final Matrix4 result = Matrix4.translationValues(-_lastOffset.dx, -_lastOffset.dy, 0.0); result.multiply(_lastTransform); return result; } @@ -1281,7 +1281,7 @@ class FollowerLayer extends ContainerLayer { /// null. Matrix4 _collectTransformForLayerChain(List layers) { // Initialize our result matrix. - final Matrix4 result = new Matrix4.identity(); + final Matrix4 result = Matrix4.identity(); // Apply each layer to the matrix in turn, starting from the last layer, // and providing the previous layer as the child. for (int index = layers.length - 1; index > 0; index -= 1) @@ -1300,7 +1300,7 @@ class FollowerLayer extends ContainerLayer { assert(link.leader.owner == owner, 'Linked LeaderLayer anchor is not in the same layer tree as the FollowerLayer.'); assert(link.leader._lastOffset != null, 'LeaderLayer anchor must come before FollowerLayer in paint order, but the reverse was true.'); // Collect all our ancestors into a Set so we can recognize them. - final Set ancestors = new HashSet(); + final Set ancestors = HashSet(); Layer ancestor = parent; while (ancestor != null) { ancestors.add(ancestor); @@ -1370,8 +1370,8 @@ class FollowerLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('link', link)); - properties.add(new TransformProperty('transform', getLastTransform(), defaultValue: null)); + properties.add(DiagnosticsProperty('link', link)); + properties.add(TransformProperty('transform', getLastTransform(), defaultValue: null)); } } @@ -1413,7 +1413,7 @@ class AnnotatedRegionLayer extends ContainerLayer { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('value', value)); - properties.add(new DiagnosticsProperty('size', size, defaultValue: null)); + properties.add(DiagnosticsProperty('value', value)); + properties.add(DiagnosticsProperty('size', size, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/rendering/list_body.dart b/packages/flutter/lib/src/rendering/list_body.dart index a7b8adf0a9..2127d65568 100644 --- a/packages/flutter/lib/src/rendering/list_body.dart +++ b/packages/flutter/lib/src/rendering/list_body.dart @@ -40,7 +40,7 @@ class RenderListBody extends RenderBox @override void setupParentData(RenderBox child) { if (child.parentData is! ListBodyParentData) - child.parentData = new ListBodyParentData(); + child.parentData = ListBodyParentData(); } /// The direction in which the children are laid out. @@ -74,7 +74,7 @@ class RenderListBody extends RenderBox return true; break; } - throw new FlutterError( + throw FlutterError( 'RenderListBody must have unlimited space along its main axis.\n' 'RenderListBody does not clip or resize its children, so it must be ' 'placed in a parent that does not constrain the main ' @@ -96,7 +96,7 @@ class RenderListBody extends RenderBox // TODO(ianh): Detect if we're actually nested blocks and say something // more specific to the exact situation in that case, and don't mention // nesting blocks in the negative case. - throw new FlutterError( + throw FlutterError( 'RenderListBody must have a bounded constraint for its cross axis.\n' 'RenderListBody forces its children to expand to fit the RenderListBody\'s container, ' 'so it must be placed in a parent that constrains the cross ' @@ -111,19 +111,19 @@ class RenderListBody extends RenderBox RenderBox child = firstChild; switch (axisDirection) { case AxisDirection.right: - final BoxConstraints innerConstraints = new BoxConstraints.tightFor(height: constraints.maxHeight); + final BoxConstraints innerConstraints = BoxConstraints.tightFor(height: constraints.maxHeight); while (child != null) { child.layout(innerConstraints, parentUsesSize: true); final ListBodyParentData childParentData = child.parentData; - childParentData.offset = new Offset(mainAxisExtent, 0.0); + childParentData.offset = Offset(mainAxisExtent, 0.0); mainAxisExtent += child.size.width; assert(child.parentData == childParentData); child = childParentData.nextSibling; } - size = constraints.constrain(new Size(mainAxisExtent, constraints.maxHeight)); + size = constraints.constrain(Size(mainAxisExtent, constraints.maxHeight)); break; case AxisDirection.left: - final BoxConstraints innerConstraints = new BoxConstraints.tightFor(height: constraints.maxHeight); + final BoxConstraints innerConstraints = BoxConstraints.tightFor(height: constraints.maxHeight); while (child != null) { child.layout(innerConstraints, parentUsesSize: true); final ListBodyParentData childParentData = child.parentData; @@ -136,26 +136,26 @@ class RenderListBody extends RenderBox while (child != null) { final ListBodyParentData childParentData = child.parentData; position += child.size.width; - childParentData.offset = new Offset(mainAxisExtent - position, 0.0); + childParentData.offset = Offset(mainAxisExtent - position, 0.0); assert(child.parentData == childParentData); child = childParentData.nextSibling; } - size = constraints.constrain(new Size(mainAxisExtent, constraints.maxHeight)); + size = constraints.constrain(Size(mainAxisExtent, constraints.maxHeight)); break; case AxisDirection.down: - final BoxConstraints innerConstraints = new BoxConstraints.tightFor(width: constraints.maxWidth); + final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth); while (child != null) { child.layout(innerConstraints, parentUsesSize: true); final ListBodyParentData childParentData = child.parentData; - childParentData.offset = new Offset(0.0, mainAxisExtent); + childParentData.offset = Offset(0.0, mainAxisExtent); mainAxisExtent += child.size.height; assert(child.parentData == childParentData); child = childParentData.nextSibling; } - size = constraints.constrain(new Size(constraints.maxWidth, mainAxisExtent)); + size = constraints.constrain(Size(constraints.maxWidth, mainAxisExtent)); break; case AxisDirection.up: - final BoxConstraints innerConstraints = new BoxConstraints.tightFor(width: constraints.maxWidth); + final BoxConstraints innerConstraints = BoxConstraints.tightFor(width: constraints.maxWidth); while (child != null) { child.layout(innerConstraints, parentUsesSize: true); final ListBodyParentData childParentData = child.parentData; @@ -168,11 +168,11 @@ class RenderListBody extends RenderBox while (child != null) { final ListBodyParentData childParentData = child.parentData; position += child.size.height; - childParentData.offset = new Offset(0.0, mainAxisExtent - position); + childParentData.offset = Offset(0.0, mainAxisExtent - position); assert(child.parentData == childParentData); child = childParentData.nextSibling; } - size = constraints.constrain(new Size(constraints.maxWidth, mainAxisExtent)); + size = constraints.constrain(Size(constraints.maxWidth, mainAxisExtent)); break; } assert(size.isFinite); @@ -181,7 +181,7 @@ class RenderListBody extends RenderBox @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('axisDirection', axisDirection)); + properties.add(EnumProperty('axisDirection', axisDirection)); } double _getIntrinsicCrossAxis(_ChildSizingFunction childSize) { diff --git a/packages/flutter/lib/src/rendering/list_wheel_viewport.dart b/packages/flutter/lib/src/rendering/list_wheel_viewport.dart index 008eec0898..c9b6903eb8 100644 --- a/packages/flutter/lib/src/rendering/list_wheel_viewport.dart +++ b/packages/flutter/lib/src/rendering/list_wheel_viewport.dart @@ -437,7 +437,7 @@ class RenderListWheelViewport @override void setupParentData(RenderObject child) { if (child.parentData is! ListWheelParentData) - child.parentData = new ListWheelParentData(); + child.parentData = ListWheelParentData(); } @override @@ -591,7 +591,7 @@ class RenderListWheelViewport final ListWheelParentData childParentData = child.parentData; // Centers the child horizontally. final double crossPosition = size.width / 2.0 - child.size.width / 2.0; - childParentData.offset = new Offset(crossPosition, indexToScrollOffset(index)); + childParentData.offset = Offset(crossPosition, indexToScrollOffset(index)); } /// Performs layout based on how [childManager] provides children. @@ -761,7 +761,7 @@ class RenderListWheelViewport Offset layoutOffset, ) { final Offset untransformedPaintingCoordinates = offset - + new Offset( + + Offset( layoutOffset.dx, _getUntransformedPaintingCoordinateY(layoutOffset.dy) ); @@ -784,7 +784,7 @@ class RenderListWheelViewport ); // Offset that helps painting everything in the center (e.g. angle = 0). - final Offset offsetToCenter = new Offset( + final Offset offsetToCenter = Offset( untransformedPaintingCoordinates.dx, -_topScrollMarginExtent); @@ -823,17 +823,17 @@ class RenderListWheelViewport // Some part of the child is in the center magnifier. if (isAfterMagnifierTopLine && isBeforeMagnifierBottomLine) { - final Rect centerRect = new Rect.fromLTWH( + final Rect centerRect = Rect.fromLTWH( 0.0, magnifierTopLinePosition, size.width, _itemExtent * _magnification); - final Rect topHalfRect = new Rect.fromLTWH( + final Rect topHalfRect = Rect.fromLTWH( 0.0, 0.0, size.width, magnifierTopLinePosition); - final Rect bottomHalfRect = new Rect.fromLTWH( + final Rect bottomHalfRect = Rect.fromLTWH( 0.0, magnifierBottomLinePosition, size.width, @@ -920,7 +920,7 @@ class RenderListWheelViewport /// Apply incoming transformation with the transformation's origin at the /// viewport's center or horizontally off to the side based on offAxisFraction. Matrix4 _centerOriginTransform(Matrix4 originalMatrix) { - final Matrix4 result = new Matrix4.identity(); + final Matrix4 result = Matrix4.identity(); final Offset centerOriginTranslation = Alignment.center.alongSize(size); result.translate(centerOriginTranslation.dx * (-_offAxisFraction * 2 + 1), centerOriginTranslation.dy); @@ -971,7 +971,7 @@ class RenderListWheelViewport final Rect bounds = MatrixUtils.transformRect(transform, rect); final Rect targetRect = bounds.translate(0.0, (size.height - itemExtent) / 2); - return new RevealedOffset(offset: targetOffset, rect: targetRect); + return RevealedOffset(offset: targetOffset, rect: targetRect); } @override diff --git a/packages/flutter/lib/src/rendering/object.dart b/packages/flutter/lib/src/rendering/object.dart index 45a7a32956..fa89f96bcd 100644 --- a/packages/flutter/lib/src/rendering/object.dart +++ b/packages/flutter/lib/src/rendering/object.dart @@ -115,7 +115,7 @@ class PaintingContext extends ClipContext { }()); if (child._layer == null) { assert(debugAlsoPaintedParent); - child._layer = new OffsetLayer(); + child._layer = OffsetLayer(); } else { assert(debugAlsoPaintedParent || child._layer.attached); child._layer.removeAllChildren(); @@ -124,7 +124,7 @@ class PaintingContext extends ClipContext { child._layer.debugCreator = child.debugCreator ?? child.runtimeType; return true; }()); - childContext ??= new PaintingContext(child._layer, child.paintBounds); + childContext ??= PaintingContext(child._layer, child.paintBounds); child._paintWithContext(childContext, Offset.zero); childContext.stopRecordingIfNeeded(); } @@ -254,9 +254,9 @@ class PaintingContext extends ClipContext { void _startRecording() { assert(!_isRecording); - _currentLayer = new PictureLayer(estimatedBounds); - _recorder = new ui.PictureRecorder(); - _canvas = new Canvas(_recorder); + _currentLayer = PictureLayer(estimatedBounds); + _recorder = ui.PictureRecorder(); + _canvas = Canvas(_recorder); _containerLayer.append(_currentLayer); } @@ -277,14 +277,14 @@ class PaintingContext extends ClipContext { return; assert(() { if (debugRepaintRainbowEnabled) { - final Paint paint = new Paint() + final Paint paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 6.0 ..color = debugCurrentRepaintColor.toColor(); canvas.drawRect(estimatedBounds.deflate(3.0), paint); } if (debugPaintLayerBordersEnabled) { - final Paint paint = new Paint() + final Paint paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 1.0 ..color = const Color(0xFFFF9800); @@ -371,7 +371,7 @@ class PaintingContext extends ClipContext { /// Creates a compatible painting context to paint onto [childLayer]. @protected PaintingContext createChildContext(ContainerLayer childLayer, Rect bounds) { - return new PaintingContext(childLayer, bounds); + return PaintingContext(childLayer, bounds); } /// Clip further painting using a rectangle. @@ -388,7 +388,7 @@ class PaintingContext extends ClipContext { void pushClipRect(bool needsCompositing, Offset offset, Rect clipRect, PaintingContextCallback painter, {Clip clipBehavior = Clip.antiAlias}) { final Rect offsetClipRect = clipRect.shift(offset); if (needsCompositing) { - pushLayer(new ClipRectLayer(clipRect: offsetClipRect, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetClipRect); + pushLayer(ClipRectLayer(clipRect: offsetClipRect, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetClipRect); } else { clipRectAndPaint(offsetClipRect, clipBehavior, offsetClipRect, () => painter(this, offset)); } @@ -413,7 +413,7 @@ class PaintingContext extends ClipContext { final Rect offsetBounds = bounds.shift(offset); final RRect offsetClipRRect = clipRRect.shift(offset); if (needsCompositing) { - pushLayer(new ClipRRectLayer(clipRRect: offsetClipRRect, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetBounds); + pushLayer(ClipRRectLayer(clipRRect: offsetClipRRect, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetBounds); } else { clipRRectAndPaint(offsetClipRRect, clipBehavior, offsetBounds, () => painter(this, offset)); } @@ -438,7 +438,7 @@ class PaintingContext extends ClipContext { final Rect offsetBounds = bounds.shift(offset); final Path offsetClipPath = clipPath.shift(offset); if (needsCompositing) { - pushLayer(new ClipPathLayer(clipPath: offsetClipPath, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetBounds); + pushLayer(ClipPathLayer(clipPath: offsetClipPath, clipBehavior: clipBehavior), painter, offset, childPaintBounds: offsetBounds); } else { clipPathAndPaint(offsetClipPath, clipBehavior, offsetBounds, () => painter(this, offset)); } @@ -454,11 +454,11 @@ class PaintingContext extends ClipContext { /// * `painter` is a callback that will paint with the `transform` applied. This /// function calls the `painter` synchronously. void pushTransform(bool needsCompositing, Offset offset, Matrix4 transform, PaintingContextCallback painter) { - final Matrix4 effectiveTransform = new Matrix4.translationValues(offset.dx, offset.dy, 0.0) + final Matrix4 effectiveTransform = Matrix4.translationValues(offset.dx, offset.dy, 0.0) ..multiply(transform)..translate(-offset.dx, -offset.dy); if (needsCompositing) { pushLayer( - new TransformLayer(transform: effectiveTransform), + TransformLayer(transform: effectiveTransform), painter, offset, childPaintBounds: MatrixUtils.inverseTransformRect(effectiveTransform, estimatedBounds), @@ -488,7 +488,7 @@ class PaintingContext extends ClipContext { /// ancestor render objects that this render object will include a composited /// layer, which, for example, causes them to use composited clips. void pushOpacity(Offset offset, int alpha, PaintingContextCallback painter) { - pushLayer(new OpacityLayer(alpha: alpha), painter, offset); + pushLayer(OpacityLayer(alpha: alpha), painter, offset); } @override @@ -631,7 +631,7 @@ class SemanticsHandle { void dispose() { assert(() { if (_owner == null) { - throw new FlutterError( + throw FlutterError( 'SemanticsHandle has already been disposed.\n' 'Each SemanticsHandle should be disposed exactly once.' ); @@ -901,11 +901,11 @@ class PipelineOwner { _outstandingSemanticsHandles += 1; if (_outstandingSemanticsHandles == 1) { assert(_semanticsOwner == null); - _semanticsOwner = new SemanticsOwner(); + _semanticsOwner = SemanticsOwner(); if (onSemanticsOwnerCreated != null) onSemanticsOwnerCreated(); } - return new SemanticsHandle._(this, listener); + return SemanticsHandle._(this, listener); } void _didDisposeSemanticsHandle() { @@ -920,7 +920,7 @@ class PipelineOwner { } bool _debugDoingSemantics = false; - final Set _nodesNeedingSemantics = new Set(); + final Set _nodesNeedingSemantics = Set(); /// Update the semantics for render objects marked as needing a semantics /// update. @@ -1123,7 +1123,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im void setupParentData(covariant RenderObject child) { assert(_debugCanPerformMutations); if (child.parentData is! ParentData) - child.parentData = new ParentData(); + child.parentData = ParentData(); } /// Called by subclasses when they decide a render object is a child. @@ -1170,7 +1170,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im dynamic debugCreator; void _debugReportException(String method, dynamic exception, StackTrace stack) { - FlutterError.reportError(new FlutterErrorDetailsForRendering( + FlutterError.reportError(FlutterErrorDetailsForRendering( exception: exception, stack: stack, library: 'rendering library', @@ -1548,7 +1548,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im informationCollector: (StringBuffer information) { final List stack = StackTrace.current.toString().split('\n'); int targetFrame; - final Pattern layoutFramePattern = new RegExp(r'^#[0-9]+ +RenderObject.layout \('); + final Pattern layoutFramePattern = RegExp(r'^#[0-9]+ +RenderObject.layout \('); for (int i = 0; i < stack.length; i += 1) { if (layoutFramePattern.matchAsPrefix(stack[i]) != null) { targetFrame = i + 1; @@ -1561,7 +1561,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im 'function by the following function, which probably computed the ' 'invalid constraints in question:' ); - final Pattern targetFramePattern = new RegExp(r'^#[0-9]+ +(.+)$'); + final Pattern targetFramePattern = RegExp(r'^#[0-9]+ +(.+)$'); final Match targetFrameMatch = targetFramePattern.matchAsPrefix(stack[targetFrame]); if (targetFrameMatch != null && targetFrameMatch.groupCount > 0) { information.writeln(' ${targetFrameMatch.group(1)}'); @@ -2036,7 +2036,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im void _paintWithContext(PaintingContext context, Offset offset) { assert(() { if (_debugDoingThisPaint) { - throw new FlutterError( + throw FlutterError( 'Tried to paint a RenderObject reentrantly.\n' 'The following RenderObject was already being painted when it was ' 'painted again:\n' @@ -2058,7 +2058,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im return; assert(() { if (_needsCompositingBitsUpdate) { - throw new FlutterError( + throw FlutterError( 'Tried to paint a RenderObject before its compositing bits were ' 'updated.\n' 'The following RenderObject was marked as having dirty compositing ' @@ -2158,7 +2158,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im assert(renderer != null); // Failed to find ancestor in parent chain. renderers.add(renderer); } - final Matrix4 transform = new Matrix4.identity(); + final Matrix4 transform = Matrix4.identity(); for (int index = renderers.length - 1; index > 0; index -= 1) renderers[index].applyPaintTransform(renderers[index - 1], transform); return transform; @@ -2279,7 +2279,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im SemanticsConfiguration get _semanticsConfiguration { if (_cachedSemanticsConfiguration == null) { - _cachedSemanticsConfiguration = new SemanticsConfiguration(); + _cachedSemanticsConfiguration = SemanticsConfiguration(); describeSemanticsConfiguration(_cachedSemanticsConfiguration); } return _cachedSemanticsConfiguration; @@ -2407,7 +2407,7 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im final bool producesForkingFragment = !config.hasBeenAnnotated && !config.isSemanticBoundary; final List<_InterestingSemanticsFragment> fragments = <_InterestingSemanticsFragment>[]; - final Set<_InterestingSemanticsFragment> toBeMarkedExplicit = new Set<_InterestingSemanticsFragment>(); + final Set<_InterestingSemanticsFragment> toBeMarkedExplicit = Set<_InterestingSemanticsFragment>(); final bool childrenMergeIntoParent = mergeIntoParent || config.isMergingSemanticsOfDescendants; visitChildrenForSemantics((RenderObject renderChild) { @@ -2451,16 +2451,16 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im if (parent is! RenderObject) { assert(!config.hasBeenAnnotated); assert(!mergeIntoParent); - result = new _RootSemanticsFragment( + result = _RootSemanticsFragment( owner: this, dropsSemanticsOfPreviousSiblings: dropSemanticsOfPreviousSiblings, ); } else if (producesForkingFragment) { - result = new _ContainerSemanticsFragment( + result = _ContainerSemanticsFragment( dropsSemanticsOfPreviousSiblings: dropSemanticsOfPreviousSiblings, ); } else { - result = new _SwitchableSemanticsFragment( + result = _SwitchableSemanticsFragment( config: config, mergeIntoParent: mergeIntoParent, owner: this, @@ -2617,18 +2617,18 @@ abstract class RenderObject extends AbstractNode with DiagnosticableTreeMixin im @protected @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { - properties.add(new DiagnosticsProperty('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug)); - properties.add(new DiagnosticsProperty('parentData', parentData, tooltip: _debugCanParentUseSize == true ? 'can use size' : null, missingIfNull: true)); - properties.add(new DiagnosticsProperty('constraints', constraints, missingIfNull: true)); + properties.add(DiagnosticsProperty('creator', debugCreator, defaultValue: null, level: DiagnosticLevel.debug)); + properties.add(DiagnosticsProperty('parentData', parentData, tooltip: _debugCanParentUseSize == true ? 'can use size' : null, missingIfNull: true)); + properties.add(DiagnosticsProperty('constraints', constraints, missingIfNull: true)); // don't access it via the "layer" getter since that's only valid when we don't need paint - properties.add(new DiagnosticsProperty('layer', _layer, defaultValue: null)); - properties.add(new DiagnosticsProperty('semantics node', _semantics, defaultValue: null)); - properties.add(new FlagProperty( + properties.add(DiagnosticsProperty('layer', _layer, defaultValue: null)); + properties.add(DiagnosticsProperty('semantics node', _semantics, defaultValue: null)); + properties.add(FlagProperty( 'isBlockingSemanticsOfPreviouslyPaintedNodes', value: _semanticsConfiguration.isBlockingSemanticsOfPreviouslyPaintedNodes, ifTrue: 'blocks semantics of earlier render objects below the common boundary', )); - properties.add(new FlagProperty('isSemanticBoundary', value: _semanticsConfiguration.isSemanticBoundary, ifTrue: 'semantic boundary')); + properties.add(FlagProperty('isSemanticBoundary', value: _semanticsConfiguration.isSemanticBoundary, ifTrue: 'semantic boundary')); } @override @@ -2684,7 +2684,7 @@ abstract class RenderObjectWithChildMixin extend bool debugValidateChild(RenderObject child) { assert(() { if (child is! ChildType) { - throw new FlutterError( + throw FlutterError( 'A $runtimeType expected a child of type $ChildType but received a ' 'child of type ${child.runtimeType}.\n' 'RenderObjects expect specific types of children because they ' @@ -2821,7 +2821,7 @@ abstract class ContainerRenderObjectMixin tags) { if (tags == null || tags.isEmpty) return; - _tagsForChildren ??= new Set(); + _tagsForChildren ??= Set(); _tagsForChildren.addAll(tags); } @@ -3235,12 +3235,12 @@ class _RootSemanticsFragment extends _InterestingSemanticsFragment { assert(parentPaintClipRect == null); assert(_ancestorChain.length == 1); - owner._semantics ??= new SemanticsNode.root( + owner._semantics ??= SemanticsNode.root( showOnScreen: owner.showOnScreen, owner: owner.owner.semanticsOwner, ); final SemanticsNode node = owner._semantics; - assert(MatrixUtils.matrixEquals(node.transform, new Matrix4.identity())); + assert(MatrixUtils.matrixEquals(node.transform, Matrix4.identity())); assert(node.parentSemanticsClipRect == null); assert(node.parentPaintClipRect == null); @@ -3329,13 +3329,13 @@ class _SwitchableSemanticsFragment extends _InterestingSemanticsFragment { } final _SemanticsGeometry geometry = _needsGeometryUpdate - ? new _SemanticsGeometry(parentSemanticsClipRect: parentSemanticsClipRect, parentPaintClipRect: parentPaintClipRect, ancestors: _ancestorChain) + ? _SemanticsGeometry(parentSemanticsClipRect: parentSemanticsClipRect, parentPaintClipRect: parentPaintClipRect, ancestors: _ancestorChain) : null; if (!_mergeIntoParent && (geometry?.dropFromTree == true)) return; // Drop the node, it's not going to be visible. - owner._semantics ??= new SemanticsNode(showOnScreen: owner.showOnScreen); + owner._semantics ??= SemanticsNode(showOnScreen: owner.showOnScreen); final SemanticsNode node = owner._semantics ..isMergedIntoParent = _mergeIntoParent ..tags = _tagsForChildren; @@ -3439,7 +3439,7 @@ class _SemanticsGeometry { void _computeValues(Rect parentSemanticsClipRect, Rect parentPaintClipRect, List ancestors) { assert(ancestors.length > 1); - _transform = new Matrix4.identity(); + _transform = Matrix4.identity(); _semanticsClipRect = parentSemanticsClipRect; _paintClipRect = parentPaintClipRect; for (int index = ancestors.length-1; index > 0; index -= 1) { @@ -3473,7 +3473,7 @@ class _SemanticsGeometry { return null; if (rect.isEmpty) return Rect.zero; - final Matrix4 transform = new Matrix4.identity(); + final Matrix4 transform = Matrix4.identity(); parent.applyPaintTransform(child, transform); return MatrixUtils.inverseTransformRect(transform, rect); } diff --git a/packages/flutter/lib/src/rendering/paragraph.dart b/packages/flutter/lib/src/rendering/paragraph.dart index a7b7ff057e..a1dfe04aaf 100644 --- a/packages/flutter/lib/src/rendering/paragraph.dart +++ b/packages/flutter/lib/src/rendering/paragraph.dart @@ -55,7 +55,7 @@ class RenderParagraph extends RenderBox { assert(maxLines == null || maxLines > 0), _softWrap = softWrap, _overflow = overflow, - _textPainter = new TextPainter( + _textPainter = TextPainter( text: text, textAlign: textAlign, textDirection: textDirection, @@ -291,8 +291,8 @@ class RenderParagraph extends RenderBox { break; case TextOverflow.fade: assert(textDirection != null); - final TextPainter fadeSizePainter = new TextPainter( - text: new TextSpan(style: _textPainter.text.style, text: '\u2026'), + final TextPainter fadeSizePainter = TextPainter( + text: TextSpan(style: _textPainter.text.style, text: '\u2026'), textDirection: textDirection, textScaleFactor: textScaleFactor, locale: locale, @@ -309,17 +309,17 @@ class RenderParagraph extends RenderBox { fadeStart = fadeEnd - fadeSizePainter.width; break; } - _overflowShader = new ui.Gradient.linear( - new Offset(fadeStart, 0.0), - new Offset(fadeEnd, 0.0), + _overflowShader = ui.Gradient.linear( + Offset(fadeStart, 0.0), + Offset(fadeEnd, 0.0), [const Color(0xFFFFFFFF), const Color(0x00FFFFFF)], ); } else { final double fadeEnd = size.height; final double fadeStart = fadeEnd - fadeSizePainter.height / 2.0; - _overflowShader = new ui.Gradient.linear( - new Offset(0.0, fadeStart), - new Offset(0.0, fadeEnd), + _overflowShader = ui.Gradient.linear( + Offset(0.0, fadeStart), + Offset(0.0, fadeEnd), [const Color(0xFFFFFFFF), const Color(0x00FFFFFF)], ); } @@ -347,7 +347,7 @@ class RenderParagraph extends RenderBox { assert(() { if (debugRepaintTextRainbowEnabled) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = debugCurrentRepaintColor.toColor(); canvas.drawRect(offset & size, paint); } @@ -359,7 +359,7 @@ class RenderParagraph extends RenderBox { if (_overflowShader != null) { // This layer limits what the shader below blends with to be just the text // (as opposed to the text and its background). - canvas.saveLayer(bounds, new Paint()); + canvas.saveLayer(bounds, Paint()); } else { canvas.save(); } @@ -369,7 +369,7 @@ class RenderParagraph extends RenderBox { if (_hasVisualOverflow) { if (_overflowShader != null) { canvas.translate(offset.dx, offset.dy); - final Paint paint = new Paint() + final Paint paint = Paint() ..blendMode = BlendMode.modulate ..shader = _overflowShader; canvas.drawRect(Offset.zero & size, paint); @@ -480,7 +480,7 @@ class RenderParagraph extends RenderBox { SemanticsConfiguration buildSemanticsConfig(int start, int end) { final TextDirection initialDirection = currentDirection; - final TextSelection selection = new TextSelection(baseOffset: start, extentOffset: end); + final TextSelection selection = TextSelection(baseOffset: start, extentOffset: end); final List rects = getBoxesForSelection(selection); Rect rect; for (ui.TextBox textBox in rects) { @@ -491,15 +491,15 @@ class RenderParagraph extends RenderBox { // round the current rectangle to make this API testable and add some // padding so that the accessibility rects do not overlap with the text. // TODO(jonahwilliams): implement this for all text accessibility rects. - currentRect = new Rect.fromLTRB( + currentRect = Rect.fromLTRB( rect.left.floorToDouble() - 4.0, rect.top.floorToDouble() - 4.0, rect.right.ceilToDouble() + 4.0, rect.bottom.ceilToDouble() + 4.0, ); order += 1; - return new SemanticsConfiguration() - ..sortKey = new OrdinalSortKey(order) + return SemanticsConfiguration() + ..sortKey = OrdinalSortKey(order) ..textDirection = initialDirection ..label = rawLabel.substring(start, end); } @@ -508,13 +508,13 @@ class RenderParagraph extends RenderBox { final int start = _recognizerOffsets[i]; final int end = _recognizerOffsets[i + 1]; if (current != start) { - final SemanticsNode node = new SemanticsNode(); + final SemanticsNode node = SemanticsNode(); final SemanticsConfiguration configuration = buildSemanticsConfig(current, start); node.updateWith(config: configuration); node.rect = currentRect; newChildren.add(node); } - final SemanticsNode node = new SemanticsNode(); + final SemanticsNode node = SemanticsNode(); final SemanticsConfiguration configuration = buildSemanticsConfig(start, end); final GestureRecognizer recognizer = _recognizers[j]; if (recognizer is TapGestureRecognizer) { @@ -530,7 +530,7 @@ class RenderParagraph extends RenderBox { current = end; } if (current < rawLabel.length) { - final SemanticsNode node = new SemanticsNode(); + final SemanticsNode node = SemanticsNode(); final SemanticsConfiguration configuration = buildSemanticsConfig(current, rawLabel.length); node.updateWith(config: configuration); node.rect = currentRect; @@ -547,12 +547,12 @@ class RenderParagraph extends RenderBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('textAlign', textAlign)); - properties.add(new EnumProperty('textDirection', textDirection)); - properties.add(new FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); - properties.add(new EnumProperty('overflow', overflow)); - properties.add(new DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: 1.0)); - properties.add(new DiagnosticsProperty('locale', locale, defaultValue: null)); - properties.add(new IntProperty('maxLines', maxLines, ifNull: 'unlimited')); + properties.add(EnumProperty('textAlign', textAlign)); + properties.add(EnumProperty('textDirection', textDirection)); + properties.add(FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); + properties.add(EnumProperty('overflow', overflow)); + properties.add(DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: 1.0)); + properties.add(DiagnosticsProperty('locale', locale, defaultValue: null)); + properties.add(IntProperty('maxLines', maxLines, ifNull: 'unlimited')); } } diff --git a/packages/flutter/lib/src/rendering/performance_overlay.dart b/packages/flutter/lib/src/rendering/performance_overlay.dart index 8386e6b362..bbc49b179b 100644 --- a/packages/flutter/lib/src/rendering/performance_overlay.dart +++ b/packages/flutter/lib/src/rendering/performance_overlay.dart @@ -162,14 +162,14 @@ class RenderPerformanceOverlay extends RenderBox { @override void performResize() { - size = constraints.constrain(new Size(double.infinity, _intrinsicHeight)); + size = constraints.constrain(Size(double.infinity, _intrinsicHeight)); } @override void paint(PaintingContext context, Offset offset) { assert(needsCompositing); - context.addLayer(new PerformanceOverlayLayer( - overlayRect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), + context.addLayer(PerformanceOverlayLayer( + overlayRect: Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), optionsMask: optionsMask, rasterizerThreshold: rasterizerThreshold, checkerboardRasterCacheImages: checkerboardRasterCacheImages, diff --git a/packages/flutter/lib/src/rendering/platform_view.dart b/packages/flutter/lib/src/rendering/platform_view.dart index 222032b22e..f409e1e105 100644 --- a/packages/flutter/lib/src/rendering/platform_view.dart +++ b/packages/flutter/lib/src/rendering/platform_view.dart @@ -67,7 +67,7 @@ class RenderAndroidView extends RenderBox { assert(gestureRecognizers != null), _viewController = viewController { - _motionEventsDispatcher = new _MotionEventsDispatcher(globalToLocal, viewController); + _motionEventsDispatcher = _MotionEventsDispatcher(globalToLocal, viewController); this.gestureRecognizers = gestureRecognizers; } @@ -104,7 +104,7 @@ class RenderAndroidView extends RenderBox { return; } _gestureRecognizer?.dispose(); - _gestureRecognizer = new _AndroidViewGestureRecognizer(_motionEventsDispatcher, recognizers); + _gestureRecognizer = _AndroidViewGestureRecognizer(_motionEventsDispatcher, recognizers); } @override @@ -178,7 +178,7 @@ class RenderAndroidView extends RenderBox { // we know that a frame with the new size is in the buffer. // This guarantees that the size of the texture frame we're painting is always // _currentAndroidViewSize. - context.addLayer(new TextureLayer( + context.addLayer(TextureLayer( rect: offset & _currentAndroidViewSize, textureId: _viewController.textureId, freeze: _state == _PlatformViewState.resizing, @@ -189,7 +189,7 @@ class RenderAndroidView extends RenderBox { bool hitTest(HitTestResult result, { Offset position }) { if (hitTestBehavior == PlatformViewHitTestBehavior.transparent || !size.contains(position)) return false; - result.add(new BoxHitTestEntry(this, position)); + result.add(BoxHitTestEntry(this, position)); return hitTestBehavior == PlatformViewHitTestBehavior.opaque; } @@ -225,7 +225,7 @@ class _AndroidViewGestureRecognizer extends OneSequenceGestureRecognizer { // Pointer for which we have already won the arena, events for pointers in this set are // immediately dispatched to the Android view. - final Set forwardedPointers = new Set(); + final Set forwardedPointers = Set(); // We use OneSequenceGestureRecognizers as they support gesture arena teams. // TODO(amirh): get a list of GestureRecognizers here. @@ -234,7 +234,7 @@ class _AndroidViewGestureRecognizer extends OneSequenceGestureRecognizer { List get gestureRecognizers => _gestureRecognizers; set gestureRecognizers(List recognizers) { _gestureRecognizers = recognizers; - team = new GestureArenaTeam(); + team = GestureArenaTeam(); team.captain = this; for (OneSequenceGestureRecognizer recognizer in _gestureRecognizers) { recognizer.team = team; @@ -377,7 +377,7 @@ class _MotionEventsDispatcher { return; } - final AndroidMotionEvent androidMotionEvent = new AndroidMotionEvent( + final AndroidMotionEvent androidMotionEvent = AndroidMotionEvent( downTime: downTimeMillis, eventTime: event.timeStamp.inMilliseconds, action: action, @@ -398,7 +398,7 @@ class _MotionEventsDispatcher { AndroidPointerCoords coordsFor(PointerEvent event) { final Offset position = globalToLocal(event.position); - return new AndroidPointerCoords( + return AndroidPointerCoords( orientation: event.orientation, pressure: event.pressure, // Currently the engine omits the pointer size, for now I'm fixing this to 0.33 which is roughly @@ -435,7 +435,7 @@ class _MotionEventsDispatcher { toolType = AndroidPointerProperties.kToolTypeUnknown; break; } - return new AndroidPointerProperties(id: pointerId, toolType: toolType); + return AndroidPointerProperties(id: pointerId, toolType: toolType); } bool isSinglePointerAction(PointerEvent event) => diff --git a/packages/flutter/lib/src/rendering/proxy_box.dart b/packages/flutter/lib/src/rendering/proxy_box.dart index 148f960c2a..961b2499d8 100644 --- a/packages/flutter/lib/src/rendering/proxy_box.dart +++ b/packages/flutter/lib/src/rendering/proxy_box.dart @@ -64,7 +64,7 @@ abstract class RenderProxyBoxMixin extends RenderBox with R // We don't actually use the offset argument in BoxParentData, so let's // avoid allocating it at all. if (child.parentData is! ParentData) - child.parentData = new ParentData(); + child.parentData = ParentData(); } @override @@ -163,7 +163,7 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox { if (size.contains(position)) { hitTarget = hitTestChildren(result, position: position) || hitTestSelf(position); if (hitTarget || behavior == HitTestBehavior.translucent) - result.add(new BoxHitTestEntry(this, position)); + result.add(BoxHitTestEntry(this, position)); } return hitTarget; } @@ -174,7 +174,7 @@ abstract class RenderProxyBoxWithHitTestBehavior extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('behavior', behavior, defaultValue: null)); + properties.add(EnumProperty('behavior', behavior, defaultValue: null)); } } @@ -272,7 +272,7 @@ class RenderConstrainedBox extends RenderProxyBox { assert(() { Paint paint; if (child == null || child.size.isEmpty) { - paint = new Paint() + paint = Paint() ..color = const Color(0x90909090); context.canvas.drawRect(offset & size, paint); } @@ -283,7 +283,7 @@ class RenderConstrainedBox extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('additionalConstraints', additionalConstraints)); + properties.add(DiagnosticsProperty('additionalConstraints', additionalConstraints)); } } @@ -338,7 +338,7 @@ class RenderLimitedBox extends RenderProxyBox { } BoxConstraints _limitConstraints(BoxConstraints constraints) { - return new BoxConstraints( + return BoxConstraints( minWidth: constraints.minWidth, maxWidth: constraints.hasBoundedWidth ? constraints.maxWidth : constraints.constrainWidth(maxWidth), minHeight: constraints.minHeight, @@ -359,8 +359,8 @@ class RenderLimitedBox extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('maxWidth', maxWidth, defaultValue: double.infinity)); - properties.add(new DoubleProperty('maxHeight', maxHeight, defaultValue: double.infinity)); + properties.add(DoubleProperty('maxWidth', maxWidth, defaultValue: double.infinity)); + properties.add(DoubleProperty('maxHeight', maxHeight, defaultValue: double.infinity)); } } @@ -459,7 +459,7 @@ class RenderAspectRatio extends RenderProxyBox { assert(constraints.debugAssertIsValid()); assert(() { if (!constraints.hasBoundedWidth && !constraints.hasBoundedHeight) { - throw new FlutterError( + throw FlutterError( '$runtimeType has unbounded constraints.\n' 'This $runtimeType was given an aspect ratio of $aspectRatio but was given ' 'both unbounded width and unbounded height constraints. Because both ' @@ -511,20 +511,20 @@ class RenderAspectRatio extends RenderProxyBox { width = height * _aspectRatio; } - return constraints.constrain(new Size(width, height)); + return constraints.constrain(Size(width, height)); } @override void performLayout() { size = _applyAspectRatio(constraints); if (child != null) - child.layout(new BoxConstraints.tight(size)); + child.layout(BoxConstraints.tight(size)); } @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('aspectRatio', aspectRatio)); + properties.add(DoubleProperty('aspectRatio', aspectRatio)); } } @@ -637,8 +637,8 @@ class RenderIntrinsicWidth extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('stepWidth', stepWidth)); - properties.add(new DoubleProperty('stepHeight', stepHeight)); + properties.add(DoubleProperty('stepWidth', stepWidth)); + properties.add(DoubleProperty('stepHeight', stepHeight)); } } @@ -799,8 +799,8 @@ class RenderOpacity extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('opacity', opacity)); - properties.add(new FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); + properties.add(DoubleProperty('opacity', opacity)); + properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); } } @@ -914,8 +914,8 @@ class RenderAnimatedOpacity extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('opacity', opacity)); - properties.add(new FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); + properties.add(DiagnosticsProperty>('opacity', opacity)); + properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); } } @@ -980,7 +980,7 @@ class RenderShaderMask extends RenderProxyBox { if (child != null) { assert(needsCompositing); context.pushLayer( - new ShaderMaskLayer( + ShaderMaskLayer( shader: _shaderCallback(offset & size), maskRect: offset & size, blendMode: _blendMode, @@ -1027,7 +1027,7 @@ class RenderBackdropFilter extends RenderProxyBox { void paint(PaintingContext context, Offset offset) { if (child != null) { assert(needsCompositing); - context.pushLayer(new BackdropFilterLayer(filter: _filter), super.paint, offset); + context.pushLayer(BackdropFilterLayer(filter: _filter), super.paint, offset); } } } @@ -1208,8 +1208,8 @@ abstract class _RenderCustomClip extends RenderProxyBox { @override void debugPaintSize(PaintingContext context, Offset offset) { assert(() { - _debugPaint ??= new Paint() - ..shader = new ui.Gradient.linear( + _debugPaint ??= Paint() + ..shader = ui.Gradient.linear( const Offset(0.0, 0.0), const Offset(10.0, 10.0), [const Color(0x00000000), const Color(0xFFFF00FF), const Color(0xFFFF00FF), const Color(0x00000000)], @@ -1218,7 +1218,7 @@ abstract class _RenderCustomClip extends RenderProxyBox { ) ..strokeWidth = 2.0 ..style = PaintingStyle.stroke; - _debugText ??= new TextPainter( + _debugText ??= TextPainter( text: const TextSpan( text: '✂', style: TextStyle( @@ -1280,7 +1280,7 @@ class RenderClipRect extends _RenderCustomClip { if (child != null) { super.debugPaintSize(context, offset); context.canvas.drawRect(_clip.shift(offset), _debugPaint); - _debugText.paint(context.canvas, offset + new Offset(_clip.width / 8.0, -_debugText.text.style.fontSize * 1.1)); + _debugText.paint(context.canvas, offset + Offset(_clip.width / 8.0, -_debugText.text.style.fontSize * 1.1)); } return true; }()); @@ -1354,7 +1354,7 @@ class RenderClipRRect extends _RenderCustomClip { if (child != null) { super.debugPaintSize(context, offset); context.canvas.drawRRect(_clip.shift(offset), _debugPaint); - _debugText.paint(context.canvas, offset + new Offset(_clip.tlRadiusX, -_debugText.text.style.fontSize * 1.1)); + _debugText.paint(context.canvas, offset + Offset(_clip.tlRadiusX, -_debugText.text.style.fontSize * 1.1)); } return true; }()); @@ -1385,7 +1385,7 @@ class RenderClipOval extends _RenderCustomClip { Path _getClipPath(Rect rect) { if (rect != _cachedRect) { _cachedRect = rect; - _cachedPath = new Path()..addOval(_cachedRect); + _cachedPath = Path()..addOval(_cachedRect); } return _cachedPath; } @@ -1399,7 +1399,7 @@ class RenderClipOval extends _RenderCustomClip { assert(_clip != null); final Offset center = _clip.center; // convert the position to an offset from the center of the unit circle - final Offset offset = new Offset((position.dx - center.dx) / _clip.width, + final Offset offset = Offset((position.dx - center.dx) / _clip.width, (position.dy - center.dy) / _clip.height); // check if the point is outside the unit circle if (offset.distanceSquared > 0.25) // x^2 + y^2 > r^2 @@ -1421,7 +1421,7 @@ class RenderClipOval extends _RenderCustomClip { if (child != null) { super.debugPaintSize(context, offset); context.canvas.drawPath(_getClipPath(_clip).shift(offset), _debugPaint); - _debugText.paint(context.canvas, offset + new Offset((_clip.width - _debugText.width) / 2.0, -_debugText.text.style.fontSize * 1.1)); + _debugText.paint(context.canvas, offset + Offset((_clip.width - _debugText.width) / 2.0, -_debugText.text.style.fontSize * 1.1)); } return true; }()); @@ -1455,7 +1455,7 @@ class RenderClipPath extends _RenderCustomClip { }) : assert(clipBehavior != Clip.none), super(child: child, clipper: clipper, clipBehavior: clipBehavior); @override - Path get _defaultClip => new Path()..addRect(Offset.zero & size); + Path get _defaultClip => Path()..addRect(Offset.zero & size); @override bool hitTest(HitTestResult result, { Offset position }) { @@ -1550,7 +1550,7 @@ abstract class _RenderPhysicalModelBase extends _RenderCustomClip { markNeedsPaint(); } - static final Paint _transparentPaint = new Paint()..color = const Color(0x00000000); + static final Paint _transparentPaint = Paint()..color = const Color(0x00000000); // On Fuchsia, the system compositor is responsible for drawing shadows // for physical model layers with non-zero elevation. @@ -1560,9 +1560,9 @@ abstract class _RenderPhysicalModelBase extends _RenderCustomClip { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DoubleProperty('elevation', elevation)); - description.add(new DiagnosticsProperty('color', color)); - description.add(new DiagnosticsProperty('shadowColor', color)); + description.add(DoubleProperty('elevation', elevation)); + description.add(DiagnosticsProperty('color', color)); + description.add(DiagnosticsProperty('shadowColor', color)); } } @@ -1639,7 +1639,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { return (borderRadius ?? BorderRadius.zero).toRRect(Offset.zero & size); case BoxShape.circle: final Rect rect = Offset.zero & size; - return new RRect.fromRectXY(rect, rect.width / 2, rect.height / 2); + return RRect.fromRectXY(rect, rect.width / 2, rect.height / 2); } return null; } @@ -1661,14 +1661,14 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { _updateClip(); final RRect offsetRRect = _clip.shift(offset); final Rect offsetBounds = offsetRRect.outerRect; - final Path offsetRRectAsPath = new Path()..addRRect(offsetRRect); + final Path offsetRRectAsPath = Path()..addRRect(offsetRRect); bool paintShadows = true; assert(() { if (debugDisableShadows) { if (elevation > 0.0) { context.canvas.drawRRect( offsetRRect, - new Paint() + Paint() ..color = shadowColor ..style = PaintingStyle.stroke ..strokeWidth = elevation * 2.0, @@ -1679,7 +1679,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { return true; }()); if (needsCompositing) { - final PhysicalModelLayer physicalModel = new PhysicalModelLayer( + final PhysicalModelLayer physicalModel = PhysicalModelLayer( clipPath: offsetRRectAsPath, clipBehavior: clipBehavior, elevation: paintShadows ? elevation : 0.0, @@ -1705,7 +1705,7 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { color.alpha != 0xFF, ); } - canvas.drawRRect(offsetRRect, new Paint()..color = color); + canvas.drawRRect(offsetRRect, Paint()..color = color); context.clipRRectAndPaint(offsetRRect, clipBehavior, offsetBounds, () => super.paint(context, offset)); assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false'); } @@ -1715,8 +1715,8 @@ class RenderPhysicalModel extends _RenderPhysicalModelBase { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('shape', shape)); - description.add(new DiagnosticsProperty('borderRadius', borderRadius)); + description.add(DiagnosticsProperty('shape', shape)); + description.add(DiagnosticsProperty('borderRadius', borderRadius)); } } @@ -1756,7 +1756,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase { ); @override - Path get _defaultClip => new Path()..addRect(Offset.zero & size); + Path get _defaultClip => Path()..addRect(Offset.zero & size); @override bool hitTest(HitTestResult result, { Offset position }) { @@ -1781,7 +1781,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase { if (elevation > 0.0) { context.canvas.drawPath( offsetPath, - new Paint() + Paint() ..color = shadowColor ..style = PaintingStyle.stroke ..strokeWidth = elevation * 2.0, @@ -1792,7 +1792,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase { return true; }()); if (needsCompositing) { - final PhysicalModelLayer physicalModel = new PhysicalModelLayer( + final PhysicalModelLayer physicalModel = PhysicalModelLayer( clipPath: offsetPath, clipBehavior: clipBehavior, elevation: paintShadows ? elevation : 0.0, @@ -1818,7 +1818,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase { color.alpha != 0xFF, ); } - canvas.drawPath(offsetPath, new Paint()..color = color..style = PaintingStyle.fill); + canvas.drawPath(offsetPath, Paint()..color = color..style = PaintingStyle.fill); context.clipPathAndPaint(offsetPath, clipBehavior, offsetBounds, () => super.paint(context, offset)); assert(context.canvas == canvas, 'canvas changed even though needsCompositing was false'); } @@ -1828,7 +1828,7 @@ class RenderPhysicalShape extends _RenderPhysicalModelBase { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty>('clipper', clipper)); + description.add(DiagnosticsProperty>('clipper', clipper)); } } @@ -1940,7 +1940,7 @@ class RenderDecoratedBox extends RenderProxyBox { _painter.paint(context.canvas, offset, filledConfiguration); assert(() { if (debugSaveCount != context.canvas.getSaveCount()) { - throw new FlutterError( + throw FlutterError( '${_decoration.runtimeType} painter had mismatching save and restore calls.\n' 'Before painting the decoration, the canvas save count was $debugSaveCount. ' 'After painting it, the canvas save count was ${context.canvas.getSaveCount()}. ' @@ -1968,7 +1968,7 @@ class RenderDecoratedBox extends RenderProxyBox { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties.add(_decoration.toDiagnosticsNode(name: 'decoration')); - properties.add(new DiagnosticsProperty('configuration', configuration)); + properties.add(DiagnosticsProperty('configuration', configuration)); } } @@ -2058,7 +2058,7 @@ class RenderTransform extends RenderProxyBox { assert(value != null); if (_transform == value) return; - _transform = new Matrix4.copy(value); + _transform = Matrix4.copy(value); markNeedsPaint(); markNeedsSemanticsUpdate(); } @@ -2109,7 +2109,7 @@ class RenderTransform extends RenderProxyBox { final Alignment resolvedAlignment = alignment?.resolve(textDirection); if (_origin == null && resolvedAlignment == null) return _transform; - final Matrix4 result = new Matrix4.identity(); + final Matrix4 result = Matrix4.identity(); if (_origin != null) result.translate(_origin.dx, _origin.dy); Offset translation; @@ -2168,11 +2168,11 @@ class RenderTransform extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new TransformProperty('transform matrix', _transform)); - properties.add(new DiagnosticsProperty('origin', origin)); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('transformHitTests', transformHitTests)); + properties.add(TransformProperty('transform matrix', _transform)); + properties.add(DiagnosticsProperty('origin', origin)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('transformHitTests', transformHitTests)); } } @@ -2278,7 +2278,7 @@ class RenderFittedBox extends RenderProxyBox { if (child == null) { _hasVisualOverflow = false; - _transform = new Matrix4.identity(); + _transform = Matrix4.identity(); } else { _resolve(); final Size childSize = child.size; @@ -2288,7 +2288,7 @@ class RenderFittedBox extends RenderProxyBox { final Rect sourceRect = _resolvedAlignment.inscribe(sizes.source, Offset.zero & childSize); final Rect destinationRect = _resolvedAlignment.inscribe(sizes.destination, Offset.zero & size); _hasVisualOverflow = sourceRect.width < childSize.width || sourceRect.height < childSize.height; - _transform = new Matrix4.translationValues(destinationRect.left, destinationRect.top, 0.0) + _transform = Matrix4.translationValues(destinationRect.left, destinationRect.top, 0.0) ..scale(scaleX, scaleY, 1.0) ..translate(-sourceRect.left, -sourceRect.top); } @@ -2343,9 +2343,9 @@ class RenderFittedBox extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('fit', fit)); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('fit', fit)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); } } @@ -2405,7 +2405,7 @@ class RenderFractionalTranslation extends RenderProxyBox { bool hitTestChildren(HitTestResult result, { Offset position }) { assert(!debugNeedsLayout); if (transformHitTests) { - position = new Offset( + position = Offset( position.dx - translation.dx * size.width, position.dy - translation.dy * size.height, ); @@ -2417,7 +2417,7 @@ class RenderFractionalTranslation extends RenderProxyBox { void paint(PaintingContext context, Offset offset) { assert(!debugNeedsLayout); if (child != null) { - super.paint(context, new Offset( + super.paint(context, Offset( offset.dx + translation.dx * size.width, offset.dy + translation.dy * size.height, )); @@ -2435,8 +2435,8 @@ class RenderFractionalTranslation extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('translation', translation)); - properties.add(new DiagnosticsProperty('transformHitTests', transformHitTests)); + properties.add(DiagnosticsProperty('translation', translation)); + properties.add(DiagnosticsProperty('transformHitTests', transformHitTests)); } } @@ -2524,7 +2524,7 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior { listeners.add('cancel'); if (listeners.isEmpty) listeners.add(''); - properties.add(new IterableProperty('listeners', listeners)); + properties.add(IterableProperty('listeners', listeners)); // TODO(jacobr): add raw listeners to the diagnostics data. } } @@ -2685,7 +2685,7 @@ class RenderRepaintBoundary extends RenderProxyBox { assert(() { inReleaseMode = false; if (debugSymmetricPaintCount + debugAsymmetricPaintCount == 0) { - properties.add(new MessageProperty('usefulness ratio', 'no metrics collected yet (never painted)')); + properties.add(MessageProperty('usefulness ratio', 'no metrics collected yet (never painted)')); } else { final double fraction = debugAsymmetricPaintCount / (debugSymmetricPaintCount + debugAsymmetricPaintCount); String diagnosis; @@ -2704,13 +2704,13 @@ class RenderRepaintBoundary extends RenderProxyBox { } else { diagnosis = 'this repaint boundary is not very effective and should probably be removed'; } - properties.add(new PercentProperty('metrics', fraction, unit: 'useful', tooltip: '$debugSymmetricPaintCount bad vs $debugAsymmetricPaintCount good')); - properties.add(new MessageProperty('diagnosis', diagnosis)); + properties.add(PercentProperty('metrics', fraction, unit: 'useful', tooltip: '$debugSymmetricPaintCount bad vs $debugAsymmetricPaintCount good')); + properties.add(MessageProperty('diagnosis', diagnosis)); } return true; }()); if (inReleaseMode) - properties.add(new DiagnosticsNode.message('(run in checked mode to collect repaint boundary statistics)')); + properties.add(DiagnosticsNode.message('(run in checked mode to collect repaint boundary statistics)')); } } @@ -2792,9 +2792,9 @@ class RenderIgnorePointer extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('ignoring', ignoring)); + properties.add(DiagnosticsProperty('ignoring', ignoring)); properties.add( - new DiagnosticsProperty( + DiagnosticsProperty( 'ignoringSemantics', _effectiveIgnoringSemantics, description: ignoringSemantics == null ? 'implicitly $_effectiveIgnoringSemantics' : null, @@ -2907,7 +2907,7 @@ class RenderOffstage extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('offstage', offstage)); + properties.add(DiagnosticsProperty('offstage', offstage)); } @override @@ -2997,9 +2997,9 @@ class RenderAbsorbPointer extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('absorbing', absorbing)); + properties.add(DiagnosticsProperty('absorbing', absorbing)); properties.add( - new DiagnosticsProperty( + DiagnosticsProperty( 'ignoringSemantics', _effectiveIgnoringSemantics, description: ignoringSemantics == null ? 'implicitly $_effectiveIgnoringSemantics' : null, @@ -3030,7 +3030,7 @@ class RenderMetaData extends RenderProxyBoxWithHitTestBehavior { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('metaData', metaData)); + properties.add(DiagnosticsProperty('metaData', metaData)); } } @@ -3160,8 +3160,8 @@ class RenderSemanticsGestureHandler extends RenderProxyBox { void _performSemanticScrollLeft() { if (onHorizontalDragUpdate != null) { final double primaryDelta = size.width * -scrollFactor; - onHorizontalDragUpdate(new DragUpdateDetails( - delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta, + onHorizontalDragUpdate(DragUpdateDetails( + delta: Offset(primaryDelta, 0.0), primaryDelta: primaryDelta, globalPosition: localToGlobal(size.center(Offset.zero)), )); } @@ -3170,8 +3170,8 @@ class RenderSemanticsGestureHandler extends RenderProxyBox { void _performSemanticScrollRight() { if (onHorizontalDragUpdate != null) { final double primaryDelta = size.width * scrollFactor; - onHorizontalDragUpdate(new DragUpdateDetails( - delta: new Offset(primaryDelta, 0.0), primaryDelta: primaryDelta, + onHorizontalDragUpdate(DragUpdateDetails( + delta: Offset(primaryDelta, 0.0), primaryDelta: primaryDelta, globalPosition: localToGlobal(size.center(Offset.zero)), )); } @@ -3180,8 +3180,8 @@ class RenderSemanticsGestureHandler extends RenderProxyBox { void _performSemanticScrollUp() { if (onVerticalDragUpdate != null) { final double primaryDelta = size.height * -scrollFactor; - onVerticalDragUpdate(new DragUpdateDetails( - delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta, + onVerticalDragUpdate(DragUpdateDetails( + delta: Offset(0.0, primaryDelta), primaryDelta: primaryDelta, globalPosition: localToGlobal(size.center(Offset.zero)), )); } @@ -3190,8 +3190,8 @@ class RenderSemanticsGestureHandler extends RenderProxyBox { void _performSemanticScrollDown() { if (onVerticalDragUpdate != null) { final double primaryDelta = size.height * scrollFactor; - onVerticalDragUpdate(new DragUpdateDetails( - delta: new Offset(0.0, primaryDelta), primaryDelta: primaryDelta, + onVerticalDragUpdate(DragUpdateDetails( + delta: Offset(0.0, primaryDelta), primaryDelta: primaryDelta, globalPosition: localToGlobal(size.center(Offset.zero)), )); } @@ -3211,7 +3211,7 @@ class RenderSemanticsGestureHandler extends RenderProxyBox { gestures.add('vertical scroll'); if (gestures.isEmpty) gestures.add(''); - properties.add(new IterableProperty('gestures', gestures)); + properties.add(IterableProperty('gestures', gestures)); } } @@ -4265,7 +4265,7 @@ class RenderBlockSemantics extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('blocking', blocking)); + properties.add(DiagnosticsProperty('blocking', blocking)); } } @@ -4326,7 +4326,7 @@ class RenderExcludeSemantics extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('excluding', excluding)); + properties.add(DiagnosticsProperty('excluding', excluding)); } } @@ -4368,13 +4368,13 @@ class RenderLeaderLayer extends RenderProxyBox { @override void paint(PaintingContext context, Offset offset) { - context.pushLayer(new LeaderLayer(link: link, offset: offset), super.paint, Offset.zero); + context.pushLayer(LeaderLayer(link: link, offset: offset), super.paint, Offset.zero); } @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('link', link)); + properties.add(DiagnosticsProperty('link', link)); } } @@ -4471,7 +4471,7 @@ class RenderFollowerLayer extends RenderProxyBox { /// [FollowerLayer.getLastTransform]), this returns the identity matrix (see /// [new Matrix4.identity]. Matrix4 getCurrentTransform() { - return _layer?.getLastTransform() ?? new Matrix4.identity(); + return _layer?.getLastTransform() ?? Matrix4.identity(); } @override @@ -4498,7 +4498,7 @@ class RenderFollowerLayer extends RenderProxyBox { @override void paint(PaintingContext context, Offset offset) { assert(showWhenUnlinked != null); - _layer = new FollowerLayer( + _layer = FollowerLayer( link: link, showWhenUnlinked: showWhenUnlinked, linkedOffset: this.offset, @@ -4508,7 +4508,7 @@ class RenderFollowerLayer extends RenderProxyBox { _layer, super.paint, Offset.zero, - childPaintBounds: new Rect.fromLTRB( + childPaintBounds: Rect.fromLTRB( // We don't know where we'll end up, so we have no idea what our cull rect should be. double.negativeInfinity, double.negativeInfinity, @@ -4526,10 +4526,10 @@ class RenderFollowerLayer extends RenderProxyBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('link', link)); - properties.add(new DiagnosticsProperty('showWhenUnlinked', showWhenUnlinked)); - properties.add(new DiagnosticsProperty('offset', offset)); - properties.add(new TransformProperty('current transform matrix', getCurrentTransform())); + properties.add(DiagnosticsProperty('link', link)); + properties.add(DiagnosticsProperty('showWhenUnlinked', showWhenUnlinked)); + properties.add(DiagnosticsProperty('offset', offset)); + properties.add(TransformProperty('current transform matrix', getCurrentTransform())); } } @@ -4583,7 +4583,7 @@ class RenderAnnotatedRegion extends RenderProxyBox { @override void paint(PaintingContext context, Offset offset) { - final AnnotatedRegionLayer layer = new AnnotatedRegionLayer(value, size: sized ? size : null); + final AnnotatedRegionLayer layer = AnnotatedRegionLayer(value, size: sized ? size : null); context.pushLayer(layer, super.paint, offset); } } diff --git a/packages/flutter/lib/src/rendering/rotated_box.dart b/packages/flutter/lib/src/rendering/rotated_box.dart index cf52abda9f..a19acc90c5 100644 --- a/packages/flutter/lib/src/rendering/rotated_box.dart +++ b/packages/flutter/lib/src/rendering/rotated_box.dart @@ -79,8 +79,8 @@ class RenderRotatedBox extends RenderBox with RenderObjectWithChildMixin('padding', padding)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); } } @@ -317,8 +317,8 @@ abstract class RenderAligningShiftedBox extends RenderShiftedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); } } @@ -379,11 +379,11 @@ class RenderPositionedBox extends RenderAligningShiftedBox { if (child != null) { child.layout(constraints.loosen(), parentUsesSize: true); - size = constraints.constrain(new Size(shrinkWrapWidth ? child.size.width * (_widthFactor ?? 1.0) : double.infinity, + size = constraints.constrain(Size(shrinkWrapWidth ? child.size.width * (_widthFactor ?? 1.0) : double.infinity, shrinkWrapHeight ? child.size.height * (_heightFactor ?? 1.0) : double.infinity)); alignChild(); } else { - size = constraints.constrain(new Size(shrinkWrapWidth ? 0.0 : double.infinity, + size = constraints.constrain(Size(shrinkWrapWidth ? 0.0 : double.infinity, shrinkWrapHeight ? 0.0 : double.infinity)); } } @@ -395,11 +395,11 @@ class RenderPositionedBox extends RenderAligningShiftedBox { Paint paint; if (child != null && !child.size.isEmpty) { Path path; - paint = new Paint() + paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 1.0 ..color = const Color(0xFFFFFF00); - path = new Path(); + path = Path(); final BoxParentData childParentData = child.parentData; if (childParentData.offset.dy > 0.0) { // vertical alignment arrows @@ -438,7 +438,7 @@ class RenderPositionedBox extends RenderAligningShiftedBox { context.canvas.drawPath(path, paint); } } else { - paint = new Paint() + paint = Paint() ..color = const Color(0x90909090); context.canvas.drawRect(offset & size, paint); } @@ -449,8 +449,8 @@ class RenderPositionedBox extends RenderAligningShiftedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('widthFactor', _widthFactor, ifNull: 'expand')); - properties.add(new DoubleProperty('heightFactor', _heightFactor, ifNull: 'expand')); + properties.add(DoubleProperty('widthFactor', _widthFactor, ifNull: 'expand')); + properties.add(DoubleProperty('heightFactor', _heightFactor, ifNull: 'expand')); } } @@ -545,7 +545,7 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox { } BoxConstraints _getInnerConstraints(BoxConstraints constraints) { - return new BoxConstraints( + return BoxConstraints( minWidth: _minWidth ?? constraints.minWidth, maxWidth: _maxWidth ?? constraints.maxWidth, minHeight: _minHeight ?? constraints.minHeight, @@ -572,10 +572,10 @@ class RenderConstrainedOverflowBox extends RenderAligningShiftedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('minWidth', minWidth, ifNull: 'use parent minWidth constraint')); - properties.add(new DoubleProperty('maxWidth', maxWidth, ifNull: 'use parent maxWidth constraint')); - properties.add(new DoubleProperty('minHeight', minHeight, ifNull: 'use parent minHeight constraint')); - properties.add(new DoubleProperty('maxHeight', maxHeight, ifNull: 'use parent maxHeight constraint')); + properties.add(DoubleProperty('minWidth', minWidth, ifNull: 'use parent minWidth constraint')); + properties.add(DoubleProperty('maxWidth', maxWidth, ifNull: 'use parent maxWidth constraint')); + properties.add(DoubleProperty('minHeight', minHeight, ifNull: 'use parent minHeight constraint')); + properties.add(DoubleProperty('maxHeight', maxHeight, ifNull: 'use parent maxHeight constraint')); } } @@ -645,10 +645,10 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow if (constrainedAxis != null) { switch (constrainedAxis) { case Axis.horizontal: - childConstraints = new BoxConstraints(maxWidth: constraints.maxWidth, minWidth: constraints.minWidth); + childConstraints = BoxConstraints(maxWidth: constraints.maxWidth, minWidth: constraints.minWidth); break; case Axis.vertical: - childConstraints = new BoxConstraints(maxHeight: constraints.maxHeight, minHeight: constraints.minHeight); + childConstraints = BoxConstraints(maxHeight: constraints.maxHeight, minHeight: constraints.minHeight); break; } } else { @@ -665,7 +665,7 @@ class RenderUnconstrainedBox extends RenderAligningShiftedBox with DebugOverflow _overflowContainerRect = Rect.zero; _overflowChildRect = Rect.zero; } - _isOverflowing = new RelativeRect.fromRect(_overflowContainerRect, _overflowChildRect).hasInsets; + _isOverflowing = RelativeRect.fromRect(_overflowContainerRect, _overflowChildRect).hasInsets; } @override @@ -847,7 +847,7 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { minHeight = height; maxHeight = height; } - return new BoxConstraints( + return BoxConstraints( minWidth: minWidth, maxWidth: maxWidth, minHeight: minHeight, @@ -917,8 +917,8 @@ class RenderFractionallySizedOverflowBox extends RenderAligningShiftedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('widthFactor', _widthFactor, ifNull: 'pass-through')); - properties.add(new DoubleProperty('heightFactor', _heightFactor, ifNull: 'pass-through')); + properties.add(DoubleProperty('widthFactor', _widthFactor, ifNull: 'pass-through')); + properties.add(DoubleProperty('heightFactor', _heightFactor, ifNull: 'pass-through')); } } @@ -1058,7 +1058,7 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { @override double computeMinIntrinsicWidth(double height) { - final double width = _getSize(new BoxConstraints.tightForFinite(height: height)).width; + final double width = _getSize(BoxConstraints.tightForFinite(height: height)).width; if (width.isFinite) return width; return 0.0; @@ -1066,7 +1066,7 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { @override double computeMaxIntrinsicWidth(double height) { - final double width = _getSize(new BoxConstraints.tightForFinite(height: height)).width; + final double width = _getSize(BoxConstraints.tightForFinite(height: height)).width; if (width.isFinite) return width; return 0.0; @@ -1074,7 +1074,7 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { @override double computeMinIntrinsicHeight(double width) { - final double height = _getSize(new BoxConstraints.tightForFinite(width: width)).height; + final double height = _getSize(BoxConstraints.tightForFinite(width: width)).height; if (height.isFinite) return height; return 0.0; @@ -1082,7 +1082,7 @@ class RenderCustomSingleChildLayoutBox extends RenderShiftedBox { @override double computeMaxIntrinsicHeight(double width) { - final double height = _getSize(new BoxConstraints.tightForFinite(width: width)).height; + final double height = _getSize(BoxConstraints.tightForFinite(width: width)).height; if (height.isFinite) return height; return 0.0; @@ -1162,9 +1162,9 @@ class RenderBaseline extends RenderShiftedBox { final double actualBaseline = baseline; final double top = actualBaseline - childBaseline; final BoxParentData childParentData = child.parentData; - childParentData.offset = new Offset(0.0, top); + childParentData.offset = Offset(0.0, top); final Size childSize = child.size; - size = constraints.constrain(new Size(childSize.width, top + childSize.height)); + size = constraints.constrain(Size(childSize.width, top + childSize.height)); } else { performResize(); } @@ -1173,7 +1173,7 @@ class RenderBaseline extends RenderShiftedBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('baseline', baseline)); - properties.add(new EnumProperty('baselineType', baselineType)); + properties.add(DoubleProperty('baseline', baseline)); + properties.add(EnumProperty('baselineType', baselineType)); } } diff --git a/packages/flutter/lib/src/rendering/sliver.dart b/packages/flutter/lib/src/rendering/sliver.dart index aa5705af68..4fd7c4dcd3 100644 --- a/packages/flutter/lib/src/rendering/sliver.dart +++ b/packages/flutter/lib/src/rendering/sliver.dart @@ -133,7 +133,7 @@ class SliverConstraints extends Constraints { double remainingCacheExtent, double cacheOrigin, }) { - return new SliverConstraints( + return SliverConstraints( axisDirection: axisDirection ?? this.axisDirection, growthDirection: growthDirection ?? this.growthDirection, userScrollDirection: userScrollDirection ?? this.userScrollDirection, @@ -366,14 +366,14 @@ class SliverConstraints extends Constraints { crossAxisExtent ??= this.crossAxisExtent; switch (axis) { case Axis.horizontal: - return new BoxConstraints( + return BoxConstraints( minHeight: crossAxisExtent, maxHeight: crossAxisExtent, minWidth: minExtent, maxWidth: maxExtent, ); case Axis.vertical: - return new BoxConstraints( + return BoxConstraints( minWidth: crossAxisExtent, maxWidth: crossAxisExtent, minHeight: minExtent, @@ -392,10 +392,10 @@ class SliverConstraints extends Constraints { void verify(bool check, String message) { if (check) return; - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); if (informationCollector != null) informationCollector(information); - throw new FlutterError('$runtimeType is not valid: $message\n${information}The offending constraints were:\n $this'); + throw FlutterError('$runtimeType is not valid: $message\n${information}The offending constraints were:\n $this'); } verify(axis != null, 'The "axis" is null.'); verify(growthDirection != null, 'The "growthDirection" is null.'); @@ -666,10 +666,10 @@ class SliverGeometry extends Diagnosticable { void verify(bool check, String message) { if (check) return; - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); if (informationCollector != null) informationCollector(information); - throw new FlutterError('$runtimeType is not valid: $message\n$information'); + throw FlutterError('$runtimeType is not valid: $message\n$information'); } verify(scrollExtent != null, 'The "scrollExtent" is null.'); verify(scrollExtent >= 0.0, 'The "scrollExtent" is negative.'); @@ -709,25 +709,25 @@ class SliverGeometry extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('scrollExtent', scrollExtent)); + properties.add(DoubleProperty('scrollExtent', scrollExtent)); if (paintExtent > 0.0) { - properties.add(new DoubleProperty('paintExtent', paintExtent, unit : visible ? null : ' but not painting')); + properties.add(DoubleProperty('paintExtent', paintExtent, unit : visible ? null : ' but not painting')); } else if (paintExtent == 0.0) { if (visible) { - properties.add(new DoubleProperty('paintExtent', paintExtent, unit: visible ? null : ' but visible')); + properties.add(DoubleProperty('paintExtent', paintExtent, unit: visible ? null : ' but visible')); } - properties.add(new FlagProperty('visible', value: visible, ifFalse: 'hidden')); + properties.add(FlagProperty('visible', value: visible, ifFalse: 'hidden')); } else { // Negative paintExtent! - properties.add(new DoubleProperty('paintExtent', paintExtent, tooltip: '!')); + properties.add(DoubleProperty('paintExtent', paintExtent, tooltip: '!')); } - properties.add(new DoubleProperty('paintOrigin', paintOrigin, defaultValue: 0.0)); - properties.add(new DoubleProperty('layoutExtent', layoutExtent, defaultValue: paintExtent)); - properties.add(new DoubleProperty('maxPaintExtent', maxPaintExtent)); - properties.add(new DoubleProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent)); - properties.add(new DiagnosticsProperty('hasVisualOverflow', hasVisualOverflow, defaultValue: false)); - properties.add(new DoubleProperty('scrollOffsetCorrection', scrollOffsetCorrection, defaultValue: null)); - properties.add(new DoubleProperty('cacheExtent', cacheExtent, defaultValue: 0.0)); + properties.add(DoubleProperty('paintOrigin', paintOrigin, defaultValue: 0.0)); + properties.add(DoubleProperty('layoutExtent', layoutExtent, defaultValue: paintExtent)); + properties.add(DoubleProperty('maxPaintExtent', maxPaintExtent)); + properties.add(DoubleProperty('hitTestExtent', hitTestExtent, defaultValue: paintExtent)); + properties.add(DiagnosticsProperty('hasVisualOverflow', hasVisualOverflow, defaultValue: false)); + properties.add(DoubleProperty('scrollOffsetCorrection', scrollOffsetCorrection, defaultValue: null)); + properties.add(DoubleProperty('cacheExtent', cacheExtent, defaultValue: 0.0)); } } @@ -1014,7 +1014,7 @@ abstract class RenderSliver extends RenderObject { contract = 'Because this RenderSliver has sizedByParent set to true, it must set its geometry in performResize().'; else contract = 'Because this RenderSliver has sizedByParent set to false, it must set its geometry in performLayout().'; - throw new FlutterError( + throw FlutterError( 'RenderSliver geometry setter called incorrectly.\n' '$violation\n' '$hint\n' @@ -1034,13 +1034,13 @@ abstract class RenderSliver extends RenderObject { assert(constraints.axis != null); switch (constraints.axis) { case Axis.horizontal: - return new Rect.fromLTWH( + return Rect.fromLTWH( 0.0, 0.0, geometry.paintExtent, constraints.crossAxisExtent, ); case Axis.vertical: - return new Rect.fromLTWH( + return Rect.fromLTWH( 0.0, 0.0, constraints.crossAxisExtent, geometry.paintExtent, @@ -1062,7 +1062,7 @@ abstract class RenderSliver extends RenderObject { )); assert(() { if (geometry.paintExtent > constraints.remainingPaintExtent) { - throw new FlutterError( + throw FlutterError( 'SliverGeometry has a paintOffset that exceeds the remainingPaintExtent from the constraints.\n' 'The render object whose geometry violates the constraints is the following:\n' ' ${toStringShallow(joiner: '\n ')}\n' + @@ -1136,7 +1136,7 @@ abstract class RenderSliver extends RenderObject { crossAxisPosition >= 0.0 && crossAxisPosition < constraints.crossAxisExtent) { if (hitTestChildren(result, mainAxisPosition: mainAxisPosition, crossAxisPosition: crossAxisPosition) || hitTestSelf(mainAxisPosition: mainAxisPosition, crossAxisPosition: crossAxisPosition)) { - result.add(new SliverHitTestEntry( + result.add(SliverHitTestEntry( this, mainAxisPosition: mainAxisPosition, crossAxisPosition: crossAxisPosition @@ -1241,7 +1241,7 @@ abstract class RenderSliver extends RenderObject { @protected double childMainAxisPosition(covariant RenderObject child) { assert(() { - throw new FlutterError('$runtimeType does not implement childPosition.'); + throw FlutterError('$runtimeType does not implement childPosition.'); }()); return 0.0; } @@ -1278,7 +1278,7 @@ abstract class RenderSliver extends RenderObject { @override void applyPaintTransform(RenderObject child, Matrix4 transform) { assert(() { - throw new FlutterError('$runtimeType does not implement applyPaintTransform.'); + throw FlutterError('$runtimeType does not implement applyPaintTransform.'); }()); } @@ -1293,13 +1293,13 @@ abstract class RenderSliver extends RenderObject { assert(!debugNeedsLayout); switch (applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) { case AxisDirection.up: - return new Size(constraints.crossAxisExtent, -geometry.paintExtent); + return Size(constraints.crossAxisExtent, -geometry.paintExtent); case AxisDirection.right: - return new Size(geometry.paintExtent, constraints.crossAxisExtent); + return Size(geometry.paintExtent, constraints.crossAxisExtent); case AxisDirection.down: - return new Size(constraints.crossAxisExtent, geometry.paintExtent); + return Size(constraints.crossAxisExtent, geometry.paintExtent); case AxisDirection.left: - return new Size(-geometry.paintExtent, constraints.crossAxisExtent); + return Size(-geometry.paintExtent, constraints.crossAxisExtent); } return null; } @@ -1329,7 +1329,7 @@ abstract class RenderSliver extends RenderObject { dy2 = -dy2; } canvas.drawPath( - new Path() + Path() ..moveTo(p0.dx, p0.dy) ..lineTo(p1.dx, p1.dy) ..moveTo(p1.dx - dx1, p1.dy - dy1) @@ -1346,11 +1346,11 @@ abstract class RenderSliver extends RenderObject { assert(() { if (debugPaintSizeEnabled) { final double strokeWidth = math.min(4.0, geometry.paintExtent / 30.0); - final Paint paint = new Paint() + final Paint paint = Paint() ..color = const Color(0xFF33CC33) ..strokeWidth = strokeWidth ..style = PaintingStyle.stroke - ..maskFilter = new MaskFilter.blur(BlurStyle.solid, strokeWidth); + ..maskFilter = MaskFilter.blur(BlurStyle.solid, strokeWidth); final double arrowExtent = geometry.paintExtent; final double padding = math.max(2.0, strokeWidth); final Canvas canvas = context.canvas; @@ -1415,7 +1415,7 @@ abstract class RenderSliver extends RenderObject { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('geometry', geometry)); + properties.add(DiagnosticsProperty('geometry', geometry)); } } @@ -1468,11 +1468,11 @@ abstract class RenderSliverHelpers implements RenderSliver { case Axis.horizontal: if (!rightWayUp) absolutePosition = child.size.width - absolutePosition; - return child.hitTest(result, position: new Offset(absolutePosition, absoluteCrossAxisPosition)); + return child.hitTest(result, position: Offset(absolutePosition, absoluteCrossAxisPosition)); case Axis.vertical: if (!rightWayUp) absolutePosition = child.size.height - absolutePosition; - return child.hitTest(result, position: new Offset(absoluteCrossAxisPosition, absolutePosition)); + return child.hitTest(result, position: Offset(absoluteCrossAxisPosition, absolutePosition)); } return false; } @@ -1530,7 +1530,7 @@ abstract class RenderSliverSingleBoxAdapter extends RenderSliver with RenderObje @override void setupParentData(RenderObject child) { if (child.parentData is! SliverPhysicalParentData) - child.parentData = new SliverPhysicalParentData(); + child.parentData = SliverPhysicalParentData(); } /// Sets the [SliverPhysicalParentData.paintOffset] for the given child @@ -1543,16 +1543,16 @@ abstract class RenderSliverSingleBoxAdapter extends RenderSliver with RenderObje assert(constraints.growthDirection != null); switch (applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) { case AxisDirection.up: - childParentData.paintOffset = new Offset(0.0, -(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset))); + childParentData.paintOffset = Offset(0.0, -(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset))); break; case AxisDirection.right: - childParentData.paintOffset = new Offset(-constraints.scrollOffset, 0.0); + childParentData.paintOffset = Offset(-constraints.scrollOffset, 0.0); break; case AxisDirection.down: - childParentData.paintOffset = new Offset(0.0, -constraints.scrollOffset); + childParentData.paintOffset = Offset(0.0, -constraints.scrollOffset); break; case AxisDirection.left: - childParentData.paintOffset = new Offset(-(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)), 0.0); + childParentData.paintOffset = Offset(-(geometry.scrollExtent - (geometry.paintExtent + constraints.scrollOffset)), 0.0); break; } assert(childParentData.paintOffset != null); @@ -1630,7 +1630,7 @@ class RenderSliverToBoxAdapter extends RenderSliverSingleBoxAdapter { assert(paintedChildSize.isFinite); assert(paintedChildSize >= 0.0); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: childExtent, paintExtent: paintedChildSize, cacheExtent: cacheExtent, diff --git a/packages/flutter/lib/src/rendering/sliver_fill.dart b/packages/flutter/lib/src/rendering/sliver_fill.dart index 9c680890f0..a1f20eb58d 100644 --- a/packages/flutter/lib/src/rendering/sliver_fill.dart +++ b/packages/flutter/lib/src/rendering/sliver_fill.dart @@ -122,7 +122,7 @@ class RenderSliverFillRemaining extends RenderSliverSingleBoxAdapter { final double paintedChildSize = calculatePaintOffset(constraints, from: 0.0, to: extent); assert(paintedChildSize.isFinite); assert(paintedChildSize >= 0.0); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: constraints.viewportMainAxisExtent, paintExtent: paintedChildSize, maxPaintExtent: paintedChildSize, diff --git a/packages/flutter/lib/src/rendering/sliver_fixed_extent_list.dart b/packages/flutter/lib/src/rendering/sliver_fixed_extent_list.dart index 42610843df..3627302dfb 100644 --- a/packages/flutter/lib/src/rendering/sliver_fixed_extent_list.dart +++ b/packages/flutter/lib/src/rendering/sliver_fixed_extent_list.dart @@ -169,7 +169,7 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda if (!addInitialChild(index: firstIndex, layoutOffset: indexToLayoutOffset(itemExtent, firstIndex))) { // There are either no children, or we are past the end of all our children. final double max = computeMaxScrollOffset(constraints, itemExtent); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: max, maxPaintExtent: max, ); @@ -186,7 +186,7 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda // Items before the previously first child are no longer present. // Reset the scroll offset to offset all items prior and up to the // missing item. Let parent re-layout everything. - geometry = new SliverGeometry(scrollOffsetCorrection: index * itemExtent); + geometry = SliverGeometry(scrollOffsetCorrection: index * itemExtent); return; } final SliverMultiBoxAdaptorParentData childParentData = child.parentData; @@ -251,7 +251,7 @@ abstract class RenderSliverFixedExtentBoxAdaptor extends RenderSliverMultiBoxAda final double targetEndScrollOffsetForPaint = constraints.scrollOffset + constraints.remainingPaintExtent; final int targetLastIndexForPaint = targetEndScrollOffsetForPaint.isFinite ? getMaxChildIndexForScrollOffset(targetEndScrollOffsetForPaint, itemExtent) : null; - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: estimatedMaxScrollOffset, paintExtent: paintExtent, cacheExtent: cacheExtent, diff --git a/packages/flutter/lib/src/rendering/sliver_grid.dart b/packages/flutter/lib/src/rendering/sliver_grid.dart index 9d922cf48d..ce47807126 100644 --- a/packages/flutter/lib/src/rendering/sliver_grid.dart +++ b/packages/flutter/lib/src/rendering/sliver_grid.dart @@ -214,7 +214,7 @@ class SliverGridRegularTileLayout extends SliverGridLayout { @override SliverGridGeometry getGeometryForChildIndex(int index) { final double crossAxisStart = (index % crossAxisCount) * crossAxisStride; - return new SliverGridGeometry( + return SliverGridGeometry( scrollOffset: (index ~/ crossAxisCount) * mainAxisStride, crossAxisOffset: _getOffsetFromStartInCrossAxis(crossAxisStart), mainAxisExtent: childMainAxisExtent, @@ -328,7 +328,7 @@ class SliverGridDelegateWithFixedCrossAxisCount extends SliverGridDelegate { final double usableCrossAxisExtent = constraints.crossAxisExtent - crossAxisSpacing * (crossAxisCount - 1); final double childCrossAxisExtent = usableCrossAxisExtent / crossAxisCount; final double childMainAxisExtent = childCrossAxisExtent / childAspectRatio; - return new SliverGridRegularTileLayout( + return SliverGridRegularTileLayout( crossAxisCount: crossAxisCount, mainAxisStride: childMainAxisExtent + mainAxisSpacing, crossAxisStride: childCrossAxisExtent + crossAxisSpacing, @@ -426,7 +426,7 @@ class SliverGridDelegateWithMaxCrossAxisExtent extends SliverGridDelegate { final double usableCrossAxisExtent = constraints.crossAxisExtent - crossAxisSpacing * (crossAxisCount - 1); final double childCrossAxisExtent = usableCrossAxisExtent / crossAxisCount; final double childMainAxisExtent = childCrossAxisExtent / childAspectRatio; - return new SliverGridRegularTileLayout( + return SliverGridRegularTileLayout( crossAxisCount: crossAxisCount, mainAxisStride: childMainAxisExtent + mainAxisSpacing, crossAxisStride: childCrossAxisExtent + crossAxisSpacing, @@ -486,7 +486,7 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor { @override void setupParentData(RenderObject child) { if (child.parentData is! SliverGridParentData) - child.parentData = new SliverGridParentData(); + child.parentData = SliverGridParentData(); } /// The delegate that controls the size and position of the children. @@ -543,7 +543,7 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor { if (!addInitialChild(index: firstIndex, layoutOffset: firstChildGridGeometry.scrollOffset)) { // There are either no children, or we are past the end of all our children. final double max = layout.computeMaxScrollOffset(childManager.childCount); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: max, maxPaintExtent: max, ); @@ -623,7 +623,7 @@ class RenderSliverGrid extends RenderSliverMultiBoxAdaptor { to: trailingScrollOffset, ); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: estimatedTotalExtent, paintExtent: paintExtent, maxPaintExtent: estimatedTotalExtent, diff --git a/packages/flutter/lib/src/rendering/sliver_list.dart b/packages/flutter/lib/src/rendering/sliver_list.dart index 41849fbace..9360102dd9 100644 --- a/packages/flutter/lib/src/rendering/sliver_list.dart +++ b/packages/flutter/lib/src/rendering/sliver_list.dart @@ -111,7 +111,7 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor { // We ran out of children before reaching the scroll offset. // We must inform our parent that this sliver cannot fulfill // its contract and that we need a scroll offset correction. - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollOffsetCorrection: -scrollOffset, ); return; @@ -134,7 +134,7 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor { correction += paintExtentOf(firstChild); earliestUsefulChild = insertAndLayoutLeadingChild(childConstraints, parentUsesSize: true); } - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollOffsetCorrection: correction - earliestScrollOffset, ); final SliverMultiBoxAdaptorParentData childParentData = firstChild.parentData; @@ -219,7 +219,7 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor { collectGarbage(leadingGarbage - 1, 0); assert(firstChild == lastChild); final double extent = childScrollOffset(lastChild) + paintExtentOf(lastChild); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: extent, paintExtent: 0.0, maxPaintExtent: extent, @@ -275,7 +275,7 @@ class RenderSliverList extends RenderSliverMultiBoxAdaptor { to: endScrollOffset, ); final double targetEndScrollOffsetForPaint = constraints.scrollOffset + constraints.remainingPaintExtent; - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: estimatedMaxScrollOffset, paintExtent: paintExtent, cacheExtent: cacheExtent, diff --git a/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart b/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart index 4df703ec6f..75e77415c7 100644 --- a/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart +++ b/packages/flutter/lib/src/rendering/sliver_multi_box_adaptor.dart @@ -179,7 +179,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver @override void setupParentData(RenderObject child) { if (child.parentData is! SliverMultiBoxAdaptorParentData) - child.parentData = new SliverMultiBoxAdaptorParentData(); + child.parentData = SliverMultiBoxAdaptorParentData(); } /// The delegate that manages the children of this object. @@ -492,7 +492,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver case AxisDirection.up: mainAxisUnit = const Offset(0.0, -1.0); crossAxisUnit = const Offset(1.0, 0.0); - originOffset = offset + new Offset(0.0, geometry.paintExtent); + originOffset = offset + Offset(0.0, geometry.paintExtent); addExtent = true; break; case AxisDirection.right: @@ -510,7 +510,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver case AxisDirection.left: mainAxisUnit = const Offset(-1.0, 0.0); crossAxisUnit = const Offset(0.0, 1.0); - originOffset = offset + new Offset(geometry.paintExtent, 0.0); + originOffset = offset + Offset(geometry.paintExtent, 0.0); addExtent = true; break; } @@ -520,7 +520,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver while (child != null) { final double mainAxisDelta = childMainAxisPosition(child); final double crossAxisDelta = childCrossAxisPosition(child); - Offset childOffset = new Offset( + Offset childOffset = Offset( originOffset.dx + mainAxisUnit.dx * mainAxisDelta + crossAxisUnit.dx * crossAxisDelta, originOffset.dy + mainAxisUnit.dy * mainAxisDelta + crossAxisUnit.dy * crossAxisDelta, ); @@ -539,7 +539,7 @@ abstract class RenderSliverMultiBoxAdaptor extends RenderSliver @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsNode.message(firstChild != null ? 'currently live children: ${indexOf(firstChild)} to ${indexOf(lastChild)}' : 'no children current live')); + properties.add(DiagnosticsNode.message(firstChild != null ? 'currently live children: ${indexOf(firstChild)} to ${indexOf(lastChild)}' : 'no children current live')); } /// Asserts that the reified child list is not empty and has a contiguous diff --git a/packages/flutter/lib/src/rendering/sliver_padding.dart b/packages/flutter/lib/src/rendering/sliver_padding.dart index fb0e7ee1b8..6c5570e48b 100644 --- a/packages/flutter/lib/src/rendering/sliver_padding.dart +++ b/packages/flutter/lib/src/rendering/sliver_padding.dart @@ -160,7 +160,7 @@ class RenderSliverPadding extends RenderSliver with RenderObjectWithChildMixin('padding', padding)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/rendering/sliver_persistent_header.dart b/packages/flutter/lib/src/rendering/sliver_persistent_header.dart index b830f8c31d..12e038821d 100644 --- a/packages/flutter/lib/src/rendering/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/rendering/sliver_persistent_header.dart @@ -133,7 +133,7 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje assert(() { if (minExtent <= maxExtent) return true; - throw new FlutterError( + throw FlutterError( 'The maxExtent for this $runtimeType is less than its minExtent.\n' 'The specified maxExtent was: ${maxExtent.toStringAsFixed(1)}\n' 'The specified minExtent was: ${minExtent.toStringAsFixed(1)}\n' @@ -189,16 +189,16 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje assert(constraints.axisDirection != null); switch (applyGrowthDirectionToAxisDirection(constraints.axisDirection, constraints.growthDirection)) { case AxisDirection.up: - offset += new Offset(0.0, geometry.paintExtent - childMainAxisPosition(child) - childExtent); + offset += Offset(0.0, geometry.paintExtent - childMainAxisPosition(child) - childExtent); break; case AxisDirection.down: - offset += new Offset(0.0, childMainAxisPosition(child)); + offset += Offset(0.0, childMainAxisPosition(child)); break; case AxisDirection.left: - offset += new Offset(geometry.paintExtent - childMainAxisPosition(child) - childExtent, 0.0); + offset += Offset(geometry.paintExtent - childMainAxisPosition(child) - childExtent, 0.0); break; case AxisDirection.right: - offset += new Offset(childMainAxisPosition(child), 0.0); + offset += Offset(childMainAxisPosition(child), 0.0); break; } context.paintChild(child, offset); @@ -231,8 +231,8 @@ abstract class RenderSliverPersistentHeader extends RenderSliver with RenderObje @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty.lazy('maxExtent', () => maxExtent)); - properties.add(new DoubleProperty.lazy('child position', () => childMainAxisPosition(child))); + properties.add(DoubleProperty.lazy('maxExtent', () => maxExtent)); + properties.add(DoubleProperty.lazy('child position', () => childMainAxisPosition(child))); } } @@ -257,7 +257,7 @@ abstract class RenderSliverScrollingPersistentHeader extends RenderSliverPersist final double maxExtent = this.maxExtent; layoutChild(constraints.scrollOffset, maxExtent); final double paintExtent = maxExtent - constraints.scrollOffset; - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: maxExtent, paintOrigin: math.min(constraints.overlap, 0.0), paintExtent: paintExtent.clamp(0.0, constraints.remainingPaintExtent), @@ -293,7 +293,7 @@ abstract class RenderSliverPinnedPersistentHeader extends RenderSliverPersistent excludeFromSemanticsScrolling = overlapsContent || (constraints.scrollOffset > maxExtent - minExtent); layoutChild(constraints.scrollOffset, maxExtent, overlapsContent: overlapsContent); final double layoutExtent = (maxExtent - constraints.scrollOffset).clamp(0.0, constraints.remainingPaintExtent); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: maxExtent, paintOrigin: constraints.overlap, paintExtent: math.min(childExtent, constraints.remainingPaintExtent), @@ -408,7 +408,7 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste final double maxExtent = this.maxExtent; final double paintExtent = maxExtent - _effectiveScrollOffset; final double layoutExtent = maxExtent - constraints.scrollOffset; - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: maxExtent, paintOrigin: math.min(constraints.overlap, 0.0), paintExtent: paintExtent.clamp(0.0, constraints.remainingPaintExtent), @@ -431,7 +431,7 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste final TickerProvider vsync = snapConfiguration.vsync; final Duration duration = snapConfiguration.duration; - _controller ??= new AnimationController(vsync: vsync, duration: duration) + _controller ??= AnimationController(vsync: vsync, duration: duration) ..addListener(() { if (_effectiveScrollOffset == _animation.value) return; @@ -441,10 +441,10 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste // Recreating the animation rather than updating a cached value, only // to avoid the extra complexity of managing the animation's lifetime. - _animation = new Tween( + _animation = Tween( begin: _effectiveScrollOffset, end: direction == ScrollDirection.forward ? 0.0 : maxExtent, - ).animate(new CurvedAnimation( + ).animate(CurvedAnimation( parent: _controller, curve: snapConfiguration.curve, )); @@ -492,7 +492,7 @@ abstract class RenderSliverFloatingPersistentHeader extends RenderSliverPersiste @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('effective scroll offset', _effectiveScrollOffset)); + properties.add(DoubleProperty('effective scroll offset', _effectiveScrollOffset)); } } @@ -519,7 +519,7 @@ abstract class RenderSliverFloatingPinnedPersistentHeader extends RenderSliverFl final double maxExtent = this.maxExtent; final double paintExtent = maxExtent - _effectiveScrollOffset; final double layoutExtent = maxExtent - constraints.scrollOffset; - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: maxExtent, paintExtent: paintExtent.clamp(minExtent, constraints.remainingPaintExtent), layoutExtent: layoutExtent.clamp(0.0, constraints.remainingPaintExtent - minExtent), diff --git a/packages/flutter/lib/src/rendering/stack.dart b/packages/flutter/lib/src/rendering/stack.dart index 82d5861d57..23f73e7ce2 100644 --- a/packages/flutter/lib/src/rendering/stack.dart +++ b/packages/flutter/lib/src/rendering/stack.dart @@ -30,7 +30,7 @@ class RelativeRect { /// and the RelativeRect (the output) are in the coordinate space of the /// rectangle described by the Size, with 0,0 being at the top left. factory RelativeRect.fromSize(Rect rect, Size container) { - return new RelativeRect.fromLTRB(rect.left, rect.top, container.width - rect.right, container.height - rect.bottom); + return RelativeRect.fromLTRB(rect.left, rect.top, container.width - rect.right, container.height - rect.bottom); } /// Creates a RelativeRect from two Rects. The second Rect provides the @@ -46,7 +46,7 @@ class RelativeRect { /// use [RelativeRect.fromSize] and pass the container's size as the second /// argument instead. factory RelativeRect.fromRect(Rect rect, Rect container) { - return new RelativeRect.fromLTRB( + return RelativeRect.fromLTRB( rect.left - container.left, rect.top - container.top, container.right - rect.right, @@ -85,12 +85,12 @@ class RelativeRect { /// Returns a new rectangle object translated by the given offset. RelativeRect shift(Offset offset) { - return new RelativeRect.fromLTRB(left + offset.dx, top + offset.dy, right - offset.dx, bottom - offset.dy); + return RelativeRect.fromLTRB(left + offset.dx, top + offset.dy, right - offset.dx, bottom - offset.dy); } /// Returns a new rectangle with edges moved outwards by the given delta. RelativeRect inflate(double delta) { - return new RelativeRect.fromLTRB(left - delta, top - delta, right - delta, bottom - delta); + return RelativeRect.fromLTRB(left - delta, top - delta, right - delta, bottom - delta); } /// Returns a new rectangle with edges moved inwards by the given delta. @@ -100,7 +100,7 @@ class RelativeRect { /// Returns a new rectangle that is the intersection of the given rectangle and this rectangle. RelativeRect intersect(RelativeRect other) { - return new RelativeRect.fromLTRB( + return RelativeRect.fromLTRB( math.max(left, other.left), math.max(top, other.top), math.max(right, other.right), @@ -115,7 +115,7 @@ class RelativeRect { /// * [toSize], which returns the size part of the rect, based on the size of /// the container. Rect toRect(Rect container) { - return new Rect.fromLTRB(left, top, container.width - right, container.height - bottom); + return Rect.fromLTRB(left, top, container.width - right, container.height - bottom); } /// Convert this [RelativeRect] to a [Size], assuming a container with the given size. @@ -124,7 +124,7 @@ class RelativeRect { /// /// * [toRect], which also computes the position relative to the container. Size toSize(Size container) { - return new Size(container.width - left - right, container.height - top - bottom); + return Size(container.width - left - right, container.height - top - bottom); } /// Linearly interpolate between two RelativeRects. @@ -147,12 +147,12 @@ class RelativeRect { if (a == null && b == null) return null; if (a == null) - return new RelativeRect.fromLTRB(b.left * t, b.top * t, b.right * t, b.bottom * t); + return RelativeRect.fromLTRB(b.left * t, b.top * t, b.right * t, b.bottom * t); if (b == null) { final double k = 1.0 - t; - return new RelativeRect.fromLTRB(b.left * k, b.top * k, b.right * k, b.bottom * k); + return RelativeRect.fromLTRB(b.left * k, b.top * k, b.right * k, b.bottom * k); } - return new RelativeRect.fromLTRB( + return RelativeRect.fromLTRB( lerpDouble(a.left, b.left, t), lerpDouble(a.top, b.top, t), lerpDouble(a.right, b.right, t), @@ -205,7 +205,7 @@ class StackParentData extends ContainerBoxParentData { double height; /// Get or set the current values in terms of a RelativeRect object. - RelativeRect get rect => new RelativeRect.fromLTRB(left, top, right, bottom); + RelativeRect get rect => RelativeRect.fromLTRB(left, top, right, bottom); set rect(RelativeRect value) { top = value.top; right = value.right; @@ -359,7 +359,7 @@ class RenderStack extends RenderBox @override void setupParentData(RenderBox child) { if (child.parentData is! StackParentData) - child.parentData = new StackParentData(); + child.parentData = StackParentData(); } Alignment _resolvedAlignment; @@ -502,7 +502,7 @@ class RenderStack extends RenderBox nonPositionedConstraints = constraints.loosen(); break; case StackFit.expand: - nonPositionedConstraints = new BoxConstraints.tight(constraints.biggest); + nonPositionedConstraints = BoxConstraints.tight(constraints.biggest); break; case StackFit.passthrough: nonPositionedConstraints = constraints; @@ -528,7 +528,7 @@ class RenderStack extends RenderBox } if (hasNonPositionedChildren) { - size = new Size(width, height); + size = Size(width, height); assert(size.width == constraints.constrainWidth(width)); assert(size.height == constraints.constrainHeight(height)); } else { @@ -582,7 +582,7 @@ class RenderStack extends RenderBox if (y < 0.0 || y + child.size.height > size.height) _hasVisualOverflow = true; - childParentData.offset = new Offset(x, y); + childParentData.offset = Offset(x, y); } assert(child.parentData == childParentData); @@ -619,10 +619,10 @@ class RenderStack extends RenderBox @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new EnumProperty('textDirection', textDirection)); - properties.add(new EnumProperty('fit', fit)); - properties.add(new EnumProperty('overflow', overflow)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(EnumProperty('textDirection', textDirection)); + properties.add(EnumProperty('fit', fit)); + properties.add(EnumProperty('overflow', overflow)); } } @@ -698,6 +698,6 @@ class RenderIndexedStack extends RenderStack { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new IntProperty('index', index)); + properties.add(IntProperty('index', index)); } } diff --git a/packages/flutter/lib/src/rendering/table.dart b/packages/flutter/lib/src/rendering/table.dart index 2ca744f1b9..53333e0911 100644 --- a/packages/flutter/lib/src/rendering/table.dart +++ b/packages/flutter/lib/src/rendering/table.dart @@ -379,7 +379,7 @@ class RenderTable extends RenderBox { _columns = columns ?? (children != null && children.isNotEmpty ? children.first.length : 0); _rows = rows ?? 0; _children = []..length = _columns * _rows; - _columnWidths = columnWidths ?? new HashMap(); + _columnWidths = columnWidths ?? HashMap(); _defaultColumnWidth = defaultColumnWidth; _border = border; this.rowDecorations = rowDecorations; // must use setter to initialize box painters array @@ -459,10 +459,10 @@ class RenderTable extends RenderBox { /// sizing algorithms are used here. In particular, [IntrinsicColumnWidth] is /// quite expensive because it needs to measure each cell in the column to /// determine the intrinsic size of the column. - Map get columnWidths => new Map.unmodifiable(_columnWidths); + Map get columnWidths => Map.unmodifiable(_columnWidths); Map _columnWidths; set columnWidths(Map value) { - value ??= new HashMap(); + value ??= HashMap(); if (_columnWidths == value) return; _columnWidths = value; @@ -517,7 +517,7 @@ class RenderTable extends RenderBox { /// Row decorations fill the horizontal and vertical extent of each row in /// the table, unlike decorations for individual cells, which might not fill /// either. - List get rowDecorations => new List.unmodifiable(_rowDecorations ?? const []); + List get rowDecorations => List.unmodifiable(_rowDecorations ?? const []); List _rowDecorations; List _rowDecorationPainters; set rowDecorations(List value) { @@ -528,7 +528,7 @@ class RenderTable extends RenderBox { for (BoxPainter painter in _rowDecorationPainters) painter?.dispose(); } - _rowDecorationPainters = _rowDecorations != null ? new List(_rowDecorations.length) : null; + _rowDecorationPainters = _rowDecorations != null ? List(_rowDecorations.length) : null; } /// The settings to pass to the [rowDecorations] when painting, so that they @@ -567,7 +567,7 @@ class RenderTable extends RenderBox { @override void setupParentData(RenderObject child) { if (child.parentData is! TableCellParentData) - child.parentData = new TableCellParentData(); + child.parentData = TableCellParentData(); } /// Replaces the children of this table with the given cells. @@ -604,7 +604,7 @@ class RenderTable extends RenderBox { // fill a set with the cells that are moving (it's important not // to dropChild a child that's remaining with us, because that // would clear their parentData field) - final Set lostChildren = new HashSet(); + final Set lostChildren = HashSet(); for (int y = 0; y < _rows; y += 1) { for (int x = 0; x < _columns; x += 1) { final int xyOld = x + y * _columns; @@ -747,7 +747,7 @@ class RenderTable extends RenderBox { // winner of the 2016 world's most expensive intrinsic dimension function award // honorable mention, most likely to improve if taught about memoization award assert(_children.length == rows * columns); - final List widths = _computeColumnWidths(new BoxConstraints.tightForFinite(width: width)); + final List widths = _computeColumnWidths(BoxConstraints.tightForFinite(width: width)); double rowTop = 0.0; for (int y = 0; y < rows; y += 1) { double rowHeight = 0.0; @@ -816,9 +816,9 @@ class RenderTable extends RenderBox { // necessary, applying minimum column widths as we go // 1. apply ideal widths, and collect information we'll need later - final List widths = new List(columns); - final List minWidths = new List(columns); - final List flexes = new List(columns); + final List widths = List(columns); + final List minWidths = List(columns); + final List flexes = List(columns); double tableWidth = 0.0; // running tally of the sum of widths[x] for all x double unflexedTableWidth = 0.0; // sum of the maxIntrinsicWidths of any column that has null flex double totalFlex = 0.0; @@ -983,7 +983,7 @@ class RenderTable extends RenderBox { assert(row >= 0); assert(row < rows); assert(!debugNeedsLayout); - return new Rect.fromLTRB(0.0, _rowTops[row], size.width, _rowTops[row + 1]); + return Rect.fromLTRB(0.0, _rowTops[row], size.width, _rowTops[row + 1]); } @override @@ -998,7 +998,7 @@ class RenderTable extends RenderBox { return; } final List widths = _computeColumnWidths(constraints); - final List positions = new List(columns); + final List positions = List(columns); double tableWidth; switch (textDirection) { case TextDirection.rtl: @@ -1027,7 +1027,7 @@ class RenderTable extends RenderBox { bool haveBaseline = false; double beforeBaselineDistance = 0.0; double afterBaselineDistance = 0.0; - final List baselines = new List(columns); + final List baselines = List(columns); for (int x = 0; x < columns; x += 1) { final int xy = x + y * columns; final RenderBox child = _children[xy]; @@ -1039,7 +1039,7 @@ class RenderTable extends RenderBox { switch (childParentData.verticalAlignment ?? defaultVerticalAlignment) { case TableCellVerticalAlignment.baseline: assert(textBaseline != null); - child.layout(new BoxConstraints.tightFor(width: widths[x]), parentUsesSize: true); + child.layout(BoxConstraints.tightFor(width: widths[x]), parentUsesSize: true); final double childBaseline = child.getDistanceToBaseline(textBaseline, onlyReal: true); if (childBaseline != null) { beforeBaselineDistance = math.max(beforeBaselineDistance, childBaseline); @@ -1048,13 +1048,13 @@ class RenderTable extends RenderBox { haveBaseline = true; } else { rowHeight = math.max(rowHeight, child.size.height); - childParentData.offset = new Offset(positions[x], rowTop); + childParentData.offset = Offset(positions[x], rowTop); } break; case TableCellVerticalAlignment.top: case TableCellVerticalAlignment.middle: case TableCellVerticalAlignment.bottom: - child.layout(new BoxConstraints.tightFor(width: widths[x]), parentUsesSize: true); + child.layout(BoxConstraints.tightFor(width: widths[x]), parentUsesSize: true); rowHeight = math.max(rowHeight, child.size.height); break; case TableCellVerticalAlignment.fill: @@ -1075,20 +1075,20 @@ class RenderTable extends RenderBox { switch (childParentData.verticalAlignment ?? defaultVerticalAlignment) { case TableCellVerticalAlignment.baseline: if (baselines[x] != null) - childParentData.offset = new Offset(positions[x], rowTop + beforeBaselineDistance - baselines[x]); + childParentData.offset = Offset(positions[x], rowTop + beforeBaselineDistance - baselines[x]); break; case TableCellVerticalAlignment.top: - childParentData.offset = new Offset(positions[x], rowTop); + childParentData.offset = Offset(positions[x], rowTop); break; case TableCellVerticalAlignment.middle: - childParentData.offset = new Offset(positions[x], rowTop + (rowHeight - child.size.height) / 2.0); + childParentData.offset = Offset(positions[x], rowTop + (rowHeight - child.size.height) / 2.0); break; case TableCellVerticalAlignment.bottom: - childParentData.offset = new Offset(positions[x], rowTop + rowHeight - child.size.height); + childParentData.offset = Offset(positions[x], rowTop + rowHeight - child.size.height); break; case TableCellVerticalAlignment.fill: - child.layout(new BoxConstraints.tightFor(width: widths[x], height: rowHeight)); - childParentData.offset = new Offset(positions[x], rowTop); + child.layout(BoxConstraints.tightFor(width: widths[x], height: rowHeight)); + childParentData.offset = Offset(positions[x], rowTop); break; } } @@ -1096,7 +1096,7 @@ class RenderTable extends RenderBox { rowTop += rowHeight; } _rowTops.add(rowTop); - size = constraints.constrain(new Size(tableWidth, rowTop)); + size = constraints.constrain(Size(tableWidth, rowTop)); assert(_rowTops.length == rows + 1); } @@ -1119,7 +1119,7 @@ class RenderTable extends RenderBox { assert(_children.length == rows * columns); if (rows * columns == 0) { if (border != null) { - final Rect borderRect = new Rect.fromLTWH(offset.dx, offset.dy, size.width, 0.0); + final Rect borderRect = Rect.fromLTWH(offset.dx, offset.dy, size.width, 0.0); border.paint(context.canvas, borderRect, rows: const [], columns: const []); } return; @@ -1134,8 +1134,8 @@ class RenderTable extends RenderBox { _rowDecorationPainters[y] ??= _rowDecorations[y].createBoxPainter(markNeedsPaint); _rowDecorationPainters[y].paint( canvas, - new Offset(offset.dx, offset.dy + _rowTops[y]), - configuration.copyWith(size: new Size(size.width, _rowTops[y+1] - _rowTops[y])) + Offset(offset.dx, offset.dy + _rowTops[y]), + configuration.copyWith(size: Size(size.width, _rowTops[y+1] - _rowTops[y])) ); } } @@ -1153,7 +1153,7 @@ class RenderTable extends RenderBox { // The border rect might not fill the entire height of this render object // if the rows underflow. We always force the columns to fill the width of // the render object, which means the columns cannot underflow. - final Rect borderRect = new Rect.fromLTWH(offset.dx, offset.dy, size.width, _rowTops.last); + final Rect borderRect = Rect.fromLTWH(offset.dx, offset.dy, size.width, _rowTops.last); final Iterable rows = _rowTops.getRange(1, _rowTops.length - 1); final Iterable columns = _columnLefts.skip(1); border.paint(context.canvas, borderRect, rows: rows, columns: columns); @@ -1163,18 +1163,18 @@ class RenderTable extends RenderBox { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('border', border, defaultValue: null)); - properties.add(new DiagnosticsProperty>('specified column widths', _columnWidths, level: _columnWidths.isEmpty ? DiagnosticLevel.hidden : DiagnosticLevel.info)); - properties.add(new DiagnosticsProperty('default column width', defaultColumnWidth)); - properties.add(new MessageProperty('table size', '$columns\u00D7$rows')); - properties.add(new IterableProperty('column offsets', _columnLefts, ifNull: 'unknown')); - properties.add(new IterableProperty('row offsets', _rowTops, ifNull: 'unknown')); + properties.add(DiagnosticsProperty('border', border, defaultValue: null)); + properties.add(DiagnosticsProperty>('specified column widths', _columnWidths, level: _columnWidths.isEmpty ? DiagnosticLevel.hidden : DiagnosticLevel.info)); + properties.add(DiagnosticsProperty('default column width', defaultColumnWidth)); + properties.add(MessageProperty('table size', '$columns\u00D7$rows')); + properties.add(IterableProperty('column offsets', _columnLefts, ifNull: 'unknown')); + properties.add(IterableProperty('row offsets', _rowTops, ifNull: 'unknown')); } @override List debugDescribeChildren() { if (_children.isEmpty) { - return [new DiagnosticsNode.message('table is empty')]; + return [DiagnosticsNode.message('table is empty')]; } final List children = []; @@ -1186,7 +1186,7 @@ class RenderTable extends RenderBox { if (child != null) children.add(child.toDiagnosticsNode(name: name)); else - children.add(new DiagnosticsProperty(name, null, ifNull: 'is null', showSeparator: false)); + children.add(DiagnosticsProperty(name, null, ifNull: 'is null', showSeparator: false)); } } return children; diff --git a/packages/flutter/lib/src/rendering/table_border.dart b/packages/flutter/lib/src/rendering/table_border.dart index b1a81b9d3e..a6f42e412e 100644 --- a/packages/flutter/lib/src/rendering/table_border.dart +++ b/packages/flutter/lib/src/rendering/table_border.dart @@ -33,8 +33,8 @@ class TableBorder { double width = 1.0, BorderStyle style = BorderStyle.solid, }) { - final BorderSide side = new BorderSide(color: color, width: width, style: style); - return new TableBorder(top: side, right: side, bottom: side, left: side, horizontalInside: side, verticalInside: side); + final BorderSide side = BorderSide(color: color, width: width, style: style); + return TableBorder(top: side, right: side, bottom: side, left: side, horizontalInside: side, verticalInside: side); } /// Creates a border for a table where all the interior sides use the same @@ -43,7 +43,7 @@ class TableBorder { BorderSide inside = BorderSide.none, BorderSide outside = BorderSide.none, }) { - return new TableBorder( + return TableBorder( top: outside, right: outside, bottom: outside, @@ -76,7 +76,7 @@ class TableBorder { /// This can be used, for example, with a [Padding] widget to inset a box by /// the size of these borders. EdgeInsets get dimensions { - return new EdgeInsets.fromLTRB(left.width, top.width, right.width, bottom.width); + return EdgeInsets.fromLTRB(left.width, top.width, right.width, bottom.width); } /// Whether all the sides of the border (outside and inside) are identical. @@ -132,7 +132,7 @@ class TableBorder { /// /// * [BorderSide.scale], which is used to implement this method. TableBorder scale(double t) { - return new TableBorder( + return TableBorder( top: top.scale(t), right: right.scale(t), bottom: bottom.scale(t), @@ -166,7 +166,7 @@ class TableBorder { return b.scale(t); if (b == null) return a.scale(1.0 - t); - return new TableBorder( + return TableBorder( top: BorderSide.lerp(a.top, b.top, t), right: BorderSide.lerp(a.right, b.right, t), bottom: BorderSide.lerp(a.bottom, b.bottom, t), @@ -223,8 +223,8 @@ class TableBorder { assert(columns.isEmpty || (columns.first >= 0.0 && columns.last <= rect.width)); if (columns.isNotEmpty || rows.isNotEmpty) { - final Paint paint = new Paint(); - final Path path = new Path(); + final Paint paint = Paint(); + final Path path = Path(); if (columns.isNotEmpty) { switch (verticalInside.style) { diff --git a/packages/flutter/lib/src/rendering/texture.dart b/packages/flutter/lib/src/rendering/texture.dart index 2bc3234e17..b006a5e7bf 100644 --- a/packages/flutter/lib/src/rendering/texture.dart +++ b/packages/flutter/lib/src/rendering/texture.dart @@ -72,8 +72,8 @@ class TextureBox extends RenderBox { void paint(PaintingContext context, Offset offset) { if (_textureId == null) return; - context.addLayer(new TextureLayer( - rect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), + context.addLayer(TextureLayer( + rect: Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), textureId: _textureId, )); } diff --git a/packages/flutter/lib/src/rendering/view.dart b/packages/flutter/lib/src/rendering/view.dart index 4d7a7e288f..2996d2197f 100644 --- a/packages/flutter/lib/src/rendering/view.dart +++ b/packages/flutter/lib/src/rendering/view.dart @@ -35,7 +35,7 @@ class ViewConfiguration { /// Creates a transformation matrix that applies the [devicePixelRatio]. Matrix4 toMatrix() { - return new Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0); + return Matrix4.diagonal3Values(devicePixelRatio, devicePixelRatio, 1.0); } @override @@ -121,7 +121,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin Layer _updateMatricesAndCreateNewRootLayer() { _rootTransform = configuration.toMatrix(); - final ContainerLayer rootLayer = new TransformLayer(transform: _rootTransform); + final ContainerLayer rootLayer = TransformLayer(transform: _rootTransform); rootLayer.attach(this); assert(_rootTransform != null); return rootLayer; @@ -144,7 +144,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin assert(_size.isFinite); if (child != null) - child.layout(new BoxConstraints.tight(_size)); + child.layout(BoxConstraints.tight(_size)); } @override @@ -165,7 +165,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin bool hitTest(HitTestResult result, { Offset position }) { if (child != null) child.hitTest(result, position: position); - result.add(new HitTestEntry(this)); + result.add(HitTestEntry(this)); return true; } @@ -191,7 +191,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin void compositeFrame() { Timeline.startSync('Compositing', arguments: timelineWhitelistArguments); try { - final ui.SceneBuilder builder = new ui.SceneBuilder(); + final ui.SceneBuilder builder = ui.SceneBuilder(); layer.addToScene(builder, Offset.zero); final ui.Scene scene = builder.build(); if (automaticSystemUiAdjustment) @@ -210,8 +210,8 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin void _updateSystemChrome() { final Rect bounds = paintBounds; - final Offset top = new Offset(bounds.center.dx, ui.window.padding.top / ui.window.devicePixelRatio); - final Offset bottom = new Offset(bounds.center.dx, bounds.center.dy - ui.window.padding.bottom / ui.window.devicePixelRatio); + final Offset top = Offset(bounds.center.dx, ui.window.padding.top / ui.window.devicePixelRatio); + final Offset bottom = Offset(bounds.center.dx, bounds.center.dy - ui.window.padding.bottom / ui.window.devicePixelRatio); final SystemUiOverlayStyle upperOverlayStyle = layer.find(top); // Only android has a customizable system navigation bar. SystemUiOverlayStyle lowerOverlayStyle; @@ -225,7 +225,7 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin } // If there are no overlay styles in the UI don't bother updating. if (upperOverlayStyle != null || lowerOverlayStyle != null) { - final SystemUiOverlayStyle overlayStyle = new SystemUiOverlayStyle( + final SystemUiOverlayStyle overlayStyle = SystemUiOverlayStyle( statusBarBrightness: upperOverlayStyle?.statusBarBrightness, statusBarIconBrightness: upperOverlayStyle?.statusBarIconBrightness, statusBarColor: upperOverlayStyle?.statusBarColor, @@ -252,13 +252,13 @@ class RenderView extends RenderObject with RenderObjectWithChildMixin // root superclasses don't include any interesting information for this // class assert(() { - properties.add(new DiagnosticsNode.message('debug mode enabled - ${Platform.operatingSystem}')); + properties.add(DiagnosticsNode.message('debug mode enabled - ${Platform.operatingSystem}')); return true; }()); - properties.add(new DiagnosticsProperty('window size', ui.window.physicalSize, tooltip: 'in physical pixels')); - properties.add(new DoubleProperty('device pixel ratio', ui.window.devicePixelRatio, tooltip: 'physical pixels per logical pixel')); - properties.add(new DiagnosticsProperty('configuration', configuration, tooltip: 'in logical pixels')); + properties.add(DiagnosticsProperty('window size', ui.window.physicalSize, tooltip: 'in physical pixels')); + properties.add(DoubleProperty('device pixel ratio', ui.window.devicePixelRatio, tooltip: 'physical pixels per logical pixel')); + properties.add(DiagnosticsProperty('configuration', configuration, tooltip: 'in logical pixels')); if (ui.window.semanticsEnabled) - properties.add(new DiagnosticsNode.message('semantics enabled')); + properties.add(DiagnosticsNode.message('semantics enabled')); } } diff --git a/packages/flutter/lib/src/rendering/viewport.dart b/packages/flutter/lib/src/rendering/viewport.dart index 0c011eeea8..b03cca2f64 100644 --- a/packages/flutter/lib/src/rendering/viewport.dart +++ b/packages/flutter/lib/src/rendering/viewport.dart @@ -296,7 +296,7 @@ abstract class RenderViewportBase= 0.0); assert(cacheExtentCorrection <= 0.0); - child.layout(new SliverConstraints( + child.layout(SliverConstraints( axisDirection: axisDirection, growthDirection: growthDirection, userScrollDirection: adjustedUserScrollDirection, @@ -482,7 +482,7 @@ abstract class RenderViewportBase('axisDirection', axisDirection)); - properties.add(new EnumProperty('crossAxisDirection', crossAxisDirection)); - properties.add(new DiagnosticsProperty('offset', offset)); + properties.add(EnumProperty('axisDirection', axisDirection)); + properties.add(EnumProperty('crossAxisDirection', crossAxisDirection)); + properties.add(DiagnosticsProperty('offset', offset)); } @override @@ -1083,7 +1083,7 @@ class RenderViewport extends RenderViewportBase= _maxLayoutCycles) { assert(count != 1); - throw new FlutterError( + throw FlutterError( 'A RenderViewport exceeded its maximum number of layout cycles.\n' 'RenderViewport render objects, during layout, can retry if either their ' 'slivers or their ViewportOffset decide that the offset should be corrected ' @@ -1496,7 +1496,7 @@ class RenderViewport extends RenderViewportBase('direction', direction)); - properties.add(new EnumProperty('alignment', alignment)); - properties.add(new DoubleProperty('spacing', spacing)); - properties.add(new EnumProperty('runAlignment', runAlignment)); - properties.add(new DoubleProperty('runSpacing', runSpacing)); - properties.add(new DoubleProperty('crossAxisAlignment', runSpacing)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new EnumProperty('verticalDirection', verticalDirection, defaultValue: VerticalDirection.down)); + properties.add(EnumProperty('direction', direction)); + properties.add(EnumProperty('alignment', alignment)); + properties.add(DoubleProperty('spacing', spacing)); + properties.add(EnumProperty('runAlignment', runAlignment)); + properties.add(DoubleProperty('runSpacing', runSpacing)); + properties.add(DoubleProperty('crossAxisAlignment', runSpacing)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('verticalDirection', verticalDirection, defaultValue: VerticalDirection.down)); } } diff --git a/packages/flutter/lib/src/scheduler/binding.dart b/packages/flutter/lib/src/scheduler/binding.dart index c3846481e2..7ac7e4f580 100644 --- a/packages/flutter/lib/src/scheduler/binding.dart +++ b/packages/flutter/lib/src/scheduler/binding.dart @@ -64,7 +64,7 @@ class _TaskEntry { debugStack = StackTrace.current; return true; }()); - completer = new Completer(); + completer = Completer(); } final TaskCallback task; final int priority; @@ -91,7 +91,7 @@ class _FrameCallbackEntry { if (rescheduling) { assert(() { if (debugCurrentCallbackStack == null) { - throw new FlutterError( + throw FlutterError( 'scheduleFrameCallback called with rescheduling true, but no callback is in scope.\n' 'The "rescheduling" argument should only be set to true if the ' 'callback is being reregistered from within the callback itself, ' @@ -277,7 +277,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { static int _taskSorter (_TaskEntry e1, _TaskEntry e2) { return -e1.priority.compareTo(e2.priority); } - final PriorityQueue<_TaskEntry> _taskQueue = new HeapPriorityQueue<_TaskEntry>(_taskSorter); + final PriorityQueue<_TaskEntry> _taskQueue = HeapPriorityQueue<_TaskEntry>(_taskSorter); /// Schedules the given `task` with the given `priority` and returns a /// [Future] that completes to the `task`'s eventual return value. @@ -303,7 +303,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { Flow flow, }) { final bool isFirstTask = _taskQueue.isEmpty; - final _TaskEntry entry = new _TaskEntry( + final _TaskEntry entry = _TaskEntry( task, priority.value, debugLabel, @@ -367,7 +367,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { callbackStack = entry.debugStack; return true; }()); - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: exceptionStack, library: 'scheduler library', @@ -389,7 +389,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { int _nextFrameCallbackId = 0; // positive Map _transientCallbacks = {}; - final Set _removedIds = new HashSet(); + final Set _removedIds = HashSet(); /// The current number of transient frame callbacks scheduled. /// @@ -423,7 +423,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { int scheduleFrameCallback(FrameCallback callback, { bool rescheduling = false }) { scheduleFrame(); _nextFrameCallbackId += 1; - _transientCallbacks[_nextFrameCallbackId] = new _FrameCallbackEntry(callback, rescheduling: rescheduling); + _transientCallbacks[_nextFrameCallbackId] = _FrameCallbackEntry(callback, rescheduling: rescheduling); return _nextFrameCallbackId; } @@ -467,8 +467,8 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { // even if the information collector is called after // the problem has been resolved. final int count = transientCallbackCount; - final Map callbacks = new Map.from(_transientCallbacks); - FlutterError.reportError(new FlutterErrorDetails( + final Map callbacks = Map.from(_transientCallbacks); + FlutterError.reportError(FlutterErrorDetails( exception: reason, library: 'scheduler library', informationCollector: (StringBuffer information) { @@ -590,7 +590,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { if (_nextFrameCompleter == null) { if (schedulerPhase == SchedulerPhase.idle) scheduleFrame(); - _nextFrameCompleter = new Completer(); + _nextFrameCompleter = Completer(); addPostFrameCallback((Duration timeStamp) { _nextFrameCompleter.complete(); _nextFrameCompleter = null; @@ -807,7 +807,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { /// during frame callbacks are monotonically increasing. Duration _adjustForEpoch(Duration rawTimeStamp) { final Duration rawDurationSinceEpoch = _firstRawTimeStampInEpoch == null ? Duration.zero : rawTimeStamp - _firstRawTimeStampInEpoch; - return new Duration(microseconds: (rawDurationSinceEpoch.inMicroseconds / timeDilation).round() + _epochStart.inMicroseconds); + return Duration(microseconds: (rawDurationSinceEpoch.inMicroseconds / timeDilation).round() + _epochStart.inMicroseconds); } /// The time stamp for the frame currently being processed. @@ -821,7 +821,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { Duration _currentFrameTimeStamp; int _profileFrameNumber = 0; - final Stopwatch _profileFrameStopwatch = new Stopwatch(); + final Stopwatch _profileFrameStopwatch = Stopwatch(); String _debugBanner; bool _ignoreNextEngineDrawFrame = false; @@ -880,7 +880,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { assert(() { if (debugPrintBeginFrameBanner || debugPrintEndFrameBanner) { - final StringBuffer frameTimeStampDescription = new StringBuffer(); + final StringBuffer frameTimeStampDescription = StringBuffer(); if (rawTimeStamp != null) { _debugDescribeTimeStamp(_currentFrameTimeStamp, frameTimeStampDescription); } else { @@ -932,7 +932,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { // POST-FRAME CALLBACKS _schedulerPhase = SchedulerPhase.postFrameCallbacks; final List localPostFrameCallbacks = - new List.from(_postFrameCallbacks); + List.from(_postFrameCallbacks); _postFrameCallbacks.clear(); for (FrameCallback callback in localPostFrameCallbacks) _invokeFrameCallback(callback, _currentFrameTimeStamp); @@ -989,7 +989,7 @@ abstract class SchedulerBinding extends BindingBase with ServicesBinding { try { callback(timeStamp); } catch (exception, exceptionStack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: exceptionStack, library: 'scheduler library', diff --git a/packages/flutter/lib/src/scheduler/debug.dart b/packages/flutter/lib/src/scheduler/debug.dart index 8144606ee3..4fc1384bc0 100644 --- a/packages/flutter/lib/src/scheduler/debug.dart +++ b/packages/flutter/lib/src/scheduler/debug.dart @@ -61,7 +61,7 @@ bool debugAssertAllSchedulerVarsUnset(String reason) { assert(() { if (debugPrintBeginFrameBanner || debugPrintEndFrameBanner) { - throw new FlutterError(reason); + throw FlutterError(reason); } return true; }()); diff --git a/packages/flutter/lib/src/scheduler/priority.dart b/packages/flutter/lib/src/scheduler/priority.dart index a8789490cd..b33ad6a79e 100644 --- a/packages/flutter/lib/src/scheduler/priority.dart +++ b/packages/flutter/lib/src/scheduler/priority.dart @@ -39,7 +39,7 @@ class Priority { // Clamp the input offset. offset = kMaxOffset * offset.sign; } - return new Priority._(_value + offset); + return Priority._(_value + offset); } /// Returns a priority relative to this priority. diff --git a/packages/flutter/lib/src/scheduler/ticker.dart b/packages/flutter/lib/src/scheduler/ticker.dart index 2e1840a33d..93198a7035 100644 --- a/packages/flutter/lib/src/scheduler/ticker.dart +++ b/packages/flutter/lib/src/scheduler/ticker.dart @@ -145,7 +145,7 @@ class Ticker { TickerFuture start() { assert(() { if (isActive) { - throw new FlutterError( + throw FlutterError( 'A ticker was started twice.\n' 'A ticker that is already active cannot be started again without first stopping it.\n' 'The affected ticker was: ${ toString(debugIncludeStack: true) }' @@ -154,7 +154,7 @@ class Ticker { return true; }()); assert(_startTime == null); - _future = new TickerFuture._(); + _future = TickerFuture._(); if (shouldScheduleTick) { scheduleTick(); } @@ -312,7 +312,7 @@ class Ticker { @override String toString({ bool debugIncludeStack = false }) { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.write('$runtimeType('); assert(() { buffer.write(debugLabel ?? ''); @@ -361,7 +361,7 @@ class TickerFuture implements Future { _complete(); } - final Completer _primaryCompleter = new Completer(); + final Completer _primaryCompleter = Completer(); Completer _secondaryCompleter; bool _completed; // null means unresolved, true means complete, false means canceled @@ -375,7 +375,7 @@ class TickerFuture implements Future { void _cancel(Ticker ticker) { assert(_completed == null); _completed = false; - _secondaryCompleter?.completeError(new TickerCanceled(ticker)); + _secondaryCompleter?.completeError(TickerCanceled(ticker)); } /// Calls `callback` either when this future resolves or when the ticker is @@ -402,7 +402,7 @@ class TickerFuture implements Future { /// will be an uncaught exception in the current zone. Future get orCancel { if (_secondaryCompleter == null) { - _secondaryCompleter = new Completer(); + _secondaryCompleter = Completer(); if (_completed != null) { if (_completed) { _secondaryCompleter.complete(null); diff --git a/packages/flutter/lib/src/semantics/semantics.dart b/packages/flutter/lib/src/semantics/semantics.dart index 72f55976f0..3455bdf2db 100644 --- a/packages/flutter/lib/src/semantics/semantics.dart +++ b/packages/flutter/lib/src/semantics/semantics.dart @@ -316,8 +316,8 @@ class SemanticsData extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('rect', rect, showName: false)); - properties.add(new TransformProperty('transform', transform, showName: false, defaultValue: null)); + properties.add(DiagnosticsProperty('rect', rect, showName: false)); + properties.add(TransformProperty('transform', transform, showName: false, defaultValue: null)); final List actionSummary = []; for (SemanticsAction action in SemanticsAction.values.values) { if ((actions & action.index) != 0) @@ -326,26 +326,26 @@ class SemanticsData extends Diagnosticable { final List customSemanticsActionSummary = customSemanticsActionIds .map((int actionId) => CustomSemanticsAction.getAction(actionId).label) .toList(); - properties.add(new IterableProperty('actions', actionSummary, ifEmpty: null)); - properties.add(new IterableProperty('customActions', customSemanticsActionSummary, ifEmpty: null)); + properties.add(IterableProperty('actions', actionSummary, ifEmpty: null)); + properties.add(IterableProperty('customActions', customSemanticsActionSummary, ifEmpty: null)); final List flagSummary = []; for (SemanticsFlag flag in SemanticsFlag.values.values) { if ((flags & flag.index) != 0) flagSummary.add(describeEnum(flag)); } - properties.add(new IterableProperty('flags', flagSummary, ifEmpty: null)); - properties.add(new StringProperty('label', label, defaultValue: '')); - properties.add(new StringProperty('value', value, defaultValue: '')); - properties.add(new StringProperty('increasedValue', increasedValue, defaultValue: '')); - properties.add(new StringProperty('decreasedValue', decreasedValue, defaultValue: '')); - properties.add(new StringProperty('hint', hint, defaultValue: '')); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(IterableProperty('flags', flagSummary, ifEmpty: null)); + properties.add(StringProperty('label', label, defaultValue: '')); + properties.add(StringProperty('value', value, defaultValue: '')); + properties.add(StringProperty('increasedValue', increasedValue, defaultValue: '')); + properties.add(StringProperty('decreasedValue', decreasedValue, defaultValue: '')); + properties.add(StringProperty('hint', hint, defaultValue: '')); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); if (textSelection?.isValid == true) - properties.add(new MessageProperty('textSelection', '[${textSelection.start}, ${textSelection.end}]')); - properties.add(new DoubleProperty('scrollExtentMin', scrollExtentMin, defaultValue: null)); - properties.add(new DoubleProperty('scrollPosition', scrollPosition, defaultValue: null)); - properties.add(new DoubleProperty('scrollExtentMax', scrollExtentMax, defaultValue: null)); + properties.add(MessageProperty('textSelection', '[${textSelection.start}, ${textSelection.end}]')); + properties.add(DoubleProperty('scrollExtentMin', scrollExtentMin, defaultValue: null)); + properties.add(DoubleProperty('scrollPosition', scrollPosition, defaultValue: null)); + properties.add(DoubleProperty('scrollExtentMax', scrollExtentMax, defaultValue: null)); } @override @@ -484,8 +484,8 @@ class SemanticsHintOverrides extends DiagnosticableTree { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('onTapHint', onTapHint, defaultValue: null)); - properties.add(new StringProperty('onLongPressHint', onLongPressHint, defaultValue: null)); + properties.add(StringProperty('onTapHint', onTapHint, defaultValue: null)); + properties.add(StringProperty('onLongPressHint', onLongPressHint, defaultValue: null)); } } @@ -995,14 +995,14 @@ class SemanticsProperties extends DiagnosticableTree { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('checked', checked, defaultValue: null)); - properties.add(new DiagnosticsProperty('selected', selected, defaultValue: null)); - properties.add(new StringProperty('label', label, defaultValue: '')); - properties.add(new StringProperty('value', value)); - properties.add(new StringProperty('hint', hint)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('sortKey', sortKey, defaultValue: null)); - properties.add(new DiagnosticsProperty('hintOverrides', hintOverrides)); + properties.add(DiagnosticsProperty('checked', checked, defaultValue: null)); + properties.add(DiagnosticsProperty('selected', selected, defaultValue: null)); + properties.add(StringProperty('label', label, defaultValue: '')); + properties.add(StringProperty('value', value)); + properties.add(StringProperty('hint', hint)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('sortKey', sortKey, defaultValue: null)); + properties.add(DiagnosticsProperty('hintOverrides', hintOverrides)); } @override @@ -1180,7 +1180,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { assert(!newChildren.any((SemanticsNode child) => child == this)); assert(() { if (identical(newChildren, _children)) { - final StringBuffer mutationErrors = new StringBuffer(); + final StringBuffer mutationErrors = StringBuffer(); if (newChildren.length != _debugPreviousSnapshot.length) { mutationErrors.writeln( 'The list\'s length has changed from ${_debugPreviousSnapshot.length} ' @@ -1198,7 +1198,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { } } if (mutationErrors.isNotEmpty) { - throw new FlutterError( + throw FlutterError( 'Failed to replace child semantics nodes because the list of `SemanticsNode`s was mutated.\n' 'Instead of mutating the existing list, create a new list containing the desired `SemanticsNode`s.\n' 'Error details:\n' @@ -1208,7 +1208,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { } assert(!newChildren.any((SemanticsNode node) => node.isMergedIntoParent) || isPartOfNodeMerging); - _debugPreviousSnapshot = new List.from(newChildren); + _debugPreviousSnapshot = List.from(newChildren); SemanticsNode ancestor = this; while (ancestor.parent is SemanticsNode) @@ -1217,7 +1217,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { return true; }()); assert(() { - final Set seenChildren = new Set(); + final Set seenChildren = Set(); for (SemanticsNode child in newChildren) assert(seenChildren.add(child)); // check for duplicate adds return true; @@ -1517,7 +1517,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { bool _canPerformAction(SemanticsAction action) => _actions.containsKey(action); - static final SemanticsConfiguration _kEmptyConfig = new SemanticsConfiguration(); + static final SemanticsConfiguration _kEmptyConfig = SemanticsConfiguration(); /// Reconfigures the properties of this object to describe the configuration /// provided in the `config` argument and the children listed in the @@ -1545,8 +1545,8 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { _flags = config._flags; _textDirection = config.textDirection; _sortKey = config.sortKey; - _actions = new Map.from(config._actions); - _customSemanticsActions = new Map.from(config._customSemanticsActions); + _actions = Map.from(config._actions); + _customSemanticsActions = Map.from(config._customSemanticsActions); _actionsAsBits = config._actionsAsBits; _textSelection = config._textSelection; _scrollPosition = config._scrollPosition; @@ -1580,24 +1580,24 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { String increasedValue = _increasedValue; String decreasedValue = _decreasedValue; TextDirection textDirection = _textDirection; - Set mergedTags = tags == null ? null : new Set.from(tags); + Set mergedTags = tags == null ? null : Set.from(tags); TextSelection textSelection = _textSelection; double scrollPosition = _scrollPosition; double scrollExtentMax = _scrollExtentMax; double scrollExtentMin = _scrollExtentMin; - final Set customSemanticsActionIds = new Set(); + final Set customSemanticsActionIds = Set(); for (CustomSemanticsAction action in _customSemanticsActions.keys) customSemanticsActionIds.add(CustomSemanticsAction.getIdentifier(action)); if (hintOverrides != null) { if (hintOverrides.onTapHint != null) { - final CustomSemanticsAction action = new CustomSemanticsAction.overridingAction( + final CustomSemanticsAction action = CustomSemanticsAction.overridingAction( hint: hintOverrides.onTapHint, action: SemanticsAction.tap, ); customSemanticsActionIds.add(CustomSemanticsAction.getIdentifier(action)); } if (hintOverrides.onLongPressHint != null) { - final CustomSemanticsAction action = new CustomSemanticsAction.overridingAction( + final CustomSemanticsAction action = CustomSemanticsAction.overridingAction( hint: hintOverrides.onLongPressHint, action: SemanticsAction.longPress, ); @@ -1622,7 +1622,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { if (decreasedValue == '' || decreasedValue == null) decreasedValue = node._decreasedValue; if (node.tags != null) { - mergedTags ??= new Set(); + mergedTags ??= Set(); mergedTags.addAll(node.tags); } if (node._customSemanticsActions != null) { @@ -1631,14 +1631,14 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { } if (node.hintOverrides != null) { if (node.hintOverrides.onTapHint != null) { - final CustomSemanticsAction action = new CustomSemanticsAction.overridingAction( + final CustomSemanticsAction action = CustomSemanticsAction.overridingAction( hint: node.hintOverrides.onTapHint, action: SemanticsAction.tap, ); customSemanticsActionIds.add(CustomSemanticsAction.getIdentifier(action)); } if (node.hintOverrides.onLongPressHint != null) { - final CustomSemanticsAction action = new CustomSemanticsAction.overridingAction( + final CustomSemanticsAction action = CustomSemanticsAction.overridingAction( hint: node.hintOverrides.onLongPressHint, action: SemanticsAction.longPress, ); @@ -1661,7 +1661,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { }); } - return new SemanticsData( + return SemanticsData( flags: flags, actions: actions, label: label, @@ -1682,11 +1682,11 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { } static Float64List _initIdentityTransform() { - return new Matrix4.identity().storage; + return Matrix4.identity().storage; } - static final Int32List _kEmptyChildList = new Int32List(0); - static final Int32List _kEmptyCustomSemanticsActionsList = new Int32List(0); + static final Int32List _kEmptyChildList = Int32List(0); + static final Int32List _kEmptyCustomSemanticsActionsList = Int32List(0); static final Float64List _kIdentityTransform = _initIdentityTransform(); void _addToUpdate(ui.SemanticsUpdateBuilder builder, Set customSemanticsActionIdsUpdate) { @@ -1700,20 +1700,20 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { } else { final int childCount = _children.length; final List sortedChildren = _childrenInTraversalOrder(); - childrenInTraversalOrder = new Int32List(childCount); + childrenInTraversalOrder = Int32List(childCount); for (int i = 0; i < childCount; i += 1) { childrenInTraversalOrder[i] = sortedChildren[i].id; } // _children is sorted in paint order, so we invert it to get the hit test // order. - childrenInHitTestOrder = new Int32List(childCount); + childrenInHitTestOrder = Int32List(childCount); for (int i = childCount - 1; i >= 0; i -= 1) { childrenInHitTestOrder[i] = _children[childCount - i - 1].id; } } Int32List customSemanticsActionIds; if (data.customSemanticsActionIds?.isNotEmpty == true) { - customSemanticsActionIds = new Int32List(data.customSemanticsActionIds.length); + customSemanticsActionIds = Int32List(data.customSemanticsActionIds.length); for (int i = 0; i < data.customSemanticsActionIds.length; i++) { customSemanticsActionIds[i] = data.customSemanticsActionIds[i]; customSemanticsActionIdsUpdate.add(data.customSemanticsActionIds[i]); @@ -1786,7 +1786,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { sortNodes.clear(); } - sortNodes.add(new _TraversalSortNode( + sortNodes.add(_TraversalSortNode( node: child, sortKey: sortKey, position: position, @@ -1829,15 +1829,15 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { bool hideOwner = true; if (_dirty) { final bool inDirtyNodes = owner != null && owner._dirtyNodes.contains(this); - properties.add(new FlagProperty('inDirtyNodes', value: inDirtyNodes, ifTrue: 'dirty', ifFalse: 'STALE')); + properties.add(FlagProperty('inDirtyNodes', value: inDirtyNodes, ifTrue: 'dirty', ifFalse: 'STALE')); hideOwner = inDirtyNodes; } - properties.add(new DiagnosticsProperty('owner', owner, level: hideOwner ? DiagnosticLevel.hidden : DiagnosticLevel.info)); - properties.add(new FlagProperty('isMergedIntoParent', value: isMergedIntoParent, ifTrue: 'merged up ⬆️')); - properties.add(new FlagProperty('mergeAllDescendantsIntoThisNode', value: mergeAllDescendantsIntoThisNode, ifTrue: 'merge boundary ⛔️')); + properties.add(DiagnosticsProperty('owner', owner, level: hideOwner ? DiagnosticLevel.hidden : DiagnosticLevel.info)); + properties.add(FlagProperty('isMergedIntoParent', value: isMergedIntoParent, ifTrue: 'merged up ⬆️')); + properties.add(FlagProperty('mergeAllDescendantsIntoThisNode', value: mergeAllDescendantsIntoThisNode, ifTrue: 'merge boundary ⛔️')); final Offset offset = transform != null ? MatrixUtils.getAsTranslation(transform) : null; if (offset != null) { - properties.add(new DiagnosticsProperty('rect', rect.shift(offset), showName: false)); + properties.add(DiagnosticsProperty('rect', rect.shift(offset), showName: false)); } else { final double scale = transform != null ? MatrixUtils.getAsScale(transform) : null; String description; @@ -1847,30 +1847,30 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { final String matrix = transform.toString().split('\n').take(4).map((String line) => line.substring(4)).join('; '); description = '$rect with transform [$matrix]'; } - properties.add(new DiagnosticsProperty('rect', rect, description: description, showName: false)); + properties.add(DiagnosticsProperty('rect', rect, description: description, showName: false)); } final List actions = _actions.keys.map((SemanticsAction action) => describeEnum(action)).toList()..sort(); final List customSemanticsActions = _customSemanticsActions.keys .map((CustomSemanticsAction action) => action.label) .toList(); - properties.add(new IterableProperty('actions', actions, ifEmpty: null)); - properties.add(new IterableProperty('customActions', customSemanticsActions, ifEmpty: null)); + properties.add(IterableProperty('actions', actions, ifEmpty: null)); + properties.add(IterableProperty('customActions', customSemanticsActions, ifEmpty: null)); final List flags = SemanticsFlag.values.values.where((SemanticsFlag flag) => _hasFlag(flag)).map((SemanticsFlag flag) => flag.toString().substring('SemanticsFlag.'.length)).toList(); - properties.add(new IterableProperty('flags', flags, ifEmpty: null)); - properties.add(new FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible')); - properties.add(new FlagProperty('isHidden', value: _hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN')); - properties.add(new StringProperty('label', _label, defaultValue: '')); - properties.add(new StringProperty('value', _value, defaultValue: '')); - properties.add(new StringProperty('increasedValue', _increasedValue, defaultValue: '')); - properties.add(new StringProperty('decreasedValue', _decreasedValue, defaultValue: '')); - properties.add(new StringProperty('hint', _hint, defaultValue: '')); - properties.add(new EnumProperty('textDirection', _textDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('sortKey', sortKey, defaultValue: null)); + properties.add(IterableProperty('flags', flags, ifEmpty: null)); + properties.add(FlagProperty('isInvisible', value: isInvisible, ifTrue: 'invisible')); + properties.add(FlagProperty('isHidden', value: _hasFlag(SemanticsFlag.isHidden), ifTrue: 'HIDDEN')); + properties.add(StringProperty('label', _label, defaultValue: '')); + properties.add(StringProperty('value', _value, defaultValue: '')); + properties.add(StringProperty('increasedValue', _increasedValue, defaultValue: '')); + properties.add(StringProperty('decreasedValue', _decreasedValue, defaultValue: '')); + properties.add(StringProperty('hint', _hint, defaultValue: '')); + properties.add(EnumProperty('textDirection', _textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('sortKey', sortKey, defaultValue: null)); if (_textSelection?.isValid == true) - properties.add(new MessageProperty('text selection', '[${_textSelection.start}, ${_textSelection.end}]')); - properties.add(new DoubleProperty('scrollExtentMin', scrollExtentMin, defaultValue: null)); - properties.add(new DoubleProperty('scrollPosition', scrollPosition, defaultValue: null)); - properties.add(new DoubleProperty('scrollExtentMax', scrollExtentMax, defaultValue: null)); + properties.add(MessageProperty('text selection', '[${_textSelection.start}, ${_textSelection.end}]')); + properties.add(DoubleProperty('scrollExtentMin', scrollExtentMin, defaultValue: null)); + properties.add(DoubleProperty('scrollPosition', scrollPosition, defaultValue: null)); + properties.add(DoubleProperty('scrollExtentMax', scrollExtentMax, defaultValue: null)); } /// Returns a string representation of this node and its descendants. @@ -1894,7 +1894,7 @@ class SemanticsNode extends AbstractNode with DiagnosticableTreeMixin { DiagnosticsTreeStyle style = DiagnosticsTreeStyle.sparse, DebugSemanticsDumpOrder childOrder = DebugSemanticsDumpOrder.traversalOrder, }) { - return new _SemanticsDiagnosticableNode( + return _SemanticsDiagnosticableNode( name: name, value: this, style: style, @@ -2003,12 +2003,12 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> { for (SemanticsNode child in nodes) { // Using a small delta to shrink child rects removes overlapping cases. final Rect childRect = child.rect.deflate(0.1); - edges.add(new _BoxEdge( + edges.add(_BoxEdge( isLeadingEdge: true, offset: _pointInParentCoordinates(child, childRect.topLeft).dx, node: child, )); - edges.add(new _BoxEdge( + edges.add(_BoxEdge( isLeadingEdge: false, offset: _pointInParentCoordinates(child, childRect.bottomRight).dx, node: child, @@ -2022,7 +2022,7 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> { for (_BoxEdge edge in edges) { if (edge.isLeadingEdge) { depth += 1; - group ??= new _SemanticsSortGroup( + group ??= _SemanticsSortGroup( startOffset: edge.offset, textDirection: textDirection, ); @@ -2096,7 +2096,7 @@ class _SemanticsSortGroup extends Comparable<_SemanticsSortGroup> { } final List sortedIds = []; - final Set visitedIds = new Set(); + final Set visitedIds = Set(); final List startNodes = nodes.toList()..sort((SemanticsNode a, SemanticsNode b) { final Offset aTopLeft = _pointInParentCoordinates(a, a.rect.topLeft); final Offset bTopLeft = _pointInParentCoordinates(b, b.rect.topLeft); @@ -2128,9 +2128,9 @@ Offset _pointInParentCoordinates(SemanticsNode node, Offset point) { if (node.transform == null) { return point; } - final Vector3 vector = new Vector3(point.dx, point.dy, 0.0); + final Vector3 vector = Vector3(point.dx, point.dy, 0.0); node.transform.transform3(vector); - return new Offset(vector.x, vector.y); + return Offset(vector.x, vector.y); } /// Sorts `children` using the default sorting algorithm, and returns them as a @@ -2149,12 +2149,12 @@ List _childrenInDefaultOrder(List children, TextDi for (SemanticsNode child in children) { // Using a small delta to shrink child rects removes overlapping cases. final Rect childRect = child.rect.deflate(0.1); - edges.add(new _BoxEdge( + edges.add(_BoxEdge( isLeadingEdge: true, offset: _pointInParentCoordinates(child, childRect.topLeft).dy, node: child, )); - edges.add(new _BoxEdge( + edges.add(_BoxEdge( isLeadingEdge: false, offset: _pointInParentCoordinates(child, childRect.bottomRight).dy, node: child, @@ -2168,7 +2168,7 @@ List _childrenInDefaultOrder(List children, TextDi for (_BoxEdge edge in edges) { if (edge.isLeadingEdge) { depth += 1; - group ??= new _SemanticsSortGroup( + group ??= _SemanticsSortGroup( startOffset: edge.offset, textDirection: textDirection, ); @@ -2236,9 +2236,9 @@ class _TraversalSortNode implements Comparable<_TraversalSortNode> { /// obtain a [SemanticsHandle]. This will create a [SemanticsOwner] if /// necessary. class SemanticsOwner extends ChangeNotifier { - final Set _dirtyNodes = new Set(); + final Set _dirtyNodes = Set(); final Map _nodes = {}; - final Set _detachedNodes = new Set(); + final Set _detachedNodes = Set(); final Map _actions = {}; /// The root node of the semantics tree, if any. @@ -2258,7 +2258,7 @@ class SemanticsOwner extends ChangeNotifier { void sendSemanticsUpdate() { if (_dirtyNodes.isEmpty) return; - final Set customSemanticsActionIds = new Set(); + final Set customSemanticsActionIds = Set(); final List visitedNodes = []; while (_dirtyNodes.isNotEmpty) { final List localDirtyNodes = _dirtyNodes.where((SemanticsNode node) => !_detachedNodes.contains(node)).toList(); @@ -2278,7 +2278,7 @@ class SemanticsOwner extends ChangeNotifier { } } visitedNodes.sort((SemanticsNode a, SemanticsNode b) => a.depth - b.depth); - final ui.SemanticsUpdateBuilder builder = new ui.SemanticsUpdateBuilder(); + final ui.SemanticsUpdateBuilder builder = ui.SemanticsUpdateBuilder(); for (SemanticsNode node in visitedNodes) { assert(node.parent?._dirty != true); // could be null (no parent) or false (not dirty) // The _serialize() method marks the node as not dirty, and @@ -2341,7 +2341,7 @@ class SemanticsOwner extends ChangeNotifier { _SemanticsActionHandler _getSemanticsActionHandlerForPosition(SemanticsNode node, Offset position, SemanticsAction action) { if (node.transform != null) { - final Matrix4 inverse = new Matrix4.identity(); + final Matrix4 inverse = Matrix4.identity(); if (inverse.copyInverse(node.transform) == 0.0) return null; position = MatrixUtils.transformPoint(inverse, position); @@ -2806,7 +2806,7 @@ class SemanticsConfiguration { _addAction(SemanticsAction.setSelection, (dynamic args) { final Map selection = args; assert(selection != null && selection['base'] != null && selection['extent'] != null); - value(new TextSelection( + value(TextSelection( baseOffset: selection['base'], extentOffset: selection['extent'], )); @@ -3298,7 +3298,7 @@ class SemanticsConfiguration { /// * [RenderSemanticsGestureHandler.excludeFromScrolling] for an example of /// how tags are used. void addTagForChildren(SemanticsTag tag) { - _tagsForChildren ??= new Set(); + _tagsForChildren ??= Set(); _tagsForChildren.add(tag); } @@ -3385,7 +3385,7 @@ class SemanticsConfiguration { /// Returns an exact copy of this configuration. SemanticsConfiguration copy() { - return new SemanticsConfiguration() + return SemanticsConfiguration() .._isSemanticBoundary = _isSemanticBoundary ..explicitChildNodes = explicitChildNodes ..isBlockingSemanticsOfPreviouslyPaintedNodes = isBlockingSemanticsOfPreviouslyPaintedNodes @@ -3514,7 +3514,7 @@ abstract class SemanticsSortKey extends Diagnosticable implements Comparable announce(String message, TextDirection textDirection) async { - final AnnounceSemanticsEvent event = new AnnounceSemanticsEvent(message, textDirection); + final AnnounceSemanticsEvent event = AnnounceSemanticsEvent(message, textDirection); await SystemChannels.accessibility.send(event.toMap()); } @@ -37,7 +37,7 @@ class SemanticsService { /// Currently only honored on Android. The contents of [message] will be /// read by TalkBack. static Future tooltip(String message) async { - final TooltipSemanticsEvent event = new TooltipSemanticsEvent(message); + final TooltipSemanticsEvent event = TooltipSemanticsEvent(message); await SystemChannels.accessibility.send(event.toMap()); } } diff --git a/packages/flutter/lib/src/services/asset_bundle.dart b/packages/flutter/lib/src/services/asset_bundle.dart index 5946cd3f84..a89b2f56d8 100644 --- a/packages/flutter/lib/src/services/asset_bundle.dart +++ b/packages/flutter/lib/src/services/asset_bundle.dart @@ -66,7 +66,7 @@ abstract class AssetBundle { Future loadString(String key, { bool cache = true }) async { final ByteData data = await load(key); if (data == null) - throw new FlutterError('Unable to load asset: $key'); + throw FlutterError('Unable to load asset: $key'); if (data.lengthInBytes < 10 * 1024) { // 10KB takes about 3ms to parse on a Pixel 2 XL. // See: https://github.com/dart-lang/sdk/issues/31954 @@ -104,7 +104,7 @@ class NetworkAssetBundle extends AssetBundle { /// to the given base URL. NetworkAssetBundle(Uri baseUrl) : _baseUrl = baseUrl, - _httpClient = new HttpClient(); + _httpClient = HttpClient(); final Uri _baseUrl; final HttpClient _httpClient; @@ -116,7 +116,7 @@ class NetworkAssetBundle extends AssetBundle { final HttpClientRequest request = await _httpClient.getUrl(_urlFromKey(key)); final HttpClientResponse response = await request.close(); if (response.statusCode != HttpStatus.ok) - throw new FlutterError( + throw FlutterError( 'Unable to load asset: $key\n' 'HTTP status code: ${response.statusCode}' ); @@ -182,7 +182,7 @@ abstract class CachingAssetBundle extends AssetBundle { Completer completer; Future result; loadString(key, cache: false).then(parser).then((T value) { - result = new SynchronousFuture(value); + result = SynchronousFuture(value); _structuredDataCache[key] = result; if (completer != null) { // We already returned from the loadStructuredData function, which means @@ -198,7 +198,7 @@ abstract class CachingAssetBundle extends AssetBundle { } // The code above hasn't yet run its "then" handler yet. Let's prepare a // completer for it to use when it does run. - completer = new Completer(); + completer = Completer(); _structuredDataCache[key] = completer.future; return completer.future; } @@ -214,17 +214,17 @@ abstract class CachingAssetBundle extends AssetBundle { class PlatformAssetBundle extends CachingAssetBundle { @override Future load(String key) async { - final Uint8List encoded = utf8.encoder.convert(new Uri(path: Uri.encodeFull(key)).path); + final Uint8List encoded = utf8.encoder.convert(Uri(path: Uri.encodeFull(key)).path); final ByteData asset = await BinaryMessages.send('flutter/assets', encoded.buffer.asByteData()); if (asset == null) - throw new FlutterError('Unable to load asset: $key'); + throw FlutterError('Unable to load asset: $key'); return asset; } } AssetBundle _initRootBundle() { - return new PlatformAssetBundle(); + return PlatformAssetBundle(); } /// The [AssetBundle] from which this application was loaded. diff --git a/packages/flutter/lib/src/services/binding.dart b/packages/flutter/lib/src/services/binding.dart index 676ac389a9..ebd2ae9110 100644 --- a/packages/flutter/lib/src/services/binding.dart +++ b/packages/flutter/lib/src/services/binding.dart @@ -55,17 +55,17 @@ abstract class ServicesBinding extends BindingBase { // See: https://github.com/dart-lang/sdk/issues/31959 // https://github.com/dart-lang/sdk/issues/31960 // TODO(ianh): Remove this complexity once these bugs are fixed. - final Completer rawLicenses = new Completer(); + final Completer rawLicenses = Completer(); Timer.run(() async { rawLicenses.complete(rootBundle.loadString('LICENSE', cache: false)); }); await rawLicenses.future; - final Completer> parsedLicenses = new Completer>(); + final Completer> parsedLicenses = Completer>(); Timer.run(() async { parsedLicenses.complete(compute(_parseLicenses, await rawLicenses.future, debugLabel: 'parseLicenses')); }); await parsedLicenses.future; - yield* new Stream.fromIterable(await parsedLicenses.future); + yield* Stream.fromIterable(await parsedLicenses.future); } // This is run in another isolate created by _addLicenses above. @@ -76,12 +76,12 @@ abstract class ServicesBinding extends BindingBase { for (String license in licenses) { final int split = license.indexOf('\n\n'); if (split >= 0) { - result.add(new LicenseEntryWithLineBreaks( + result.add(LicenseEntryWithLineBreaks( license.substring(0, split).split('\n'), license.substring(split + 2) )); } else { - result.add(new LicenseEntryWithLineBreaks(const [], license)); + result.add(LicenseEntryWithLineBreaks(const [], license)); } } return result; diff --git a/packages/flutter/lib/src/services/clipboard.dart b/packages/flutter/lib/src/services/clipboard.dart index b91ca9a22c..13bc929d14 100644 --- a/packages/flutter/lib/src/services/clipboard.dart +++ b/packages/flutter/lib/src/services/clipboard.dart @@ -56,6 +56,6 @@ class Clipboard { ); if (result == null) return null; - return new ClipboardData(text: result['text']); + return ClipboardData(text: result['text']); } } diff --git a/packages/flutter/lib/src/services/message_codecs.dart b/packages/flutter/lib/src/services/message_codecs.dart index 1585cf176a..88ed29e613 100644 --- a/packages/flutter/lib/src/services/message_codecs.dart +++ b/packages/flutter/lib/src/services/message_codecs.dart @@ -128,30 +128,30 @@ class JSONMethodCodec implements MethodCodec { MethodCall decodeMethodCall(ByteData methodCall) { final dynamic decoded = const JSONMessageCodec().decodeMessage(methodCall); if (decoded is! Map) - throw new FormatException('Expected method call Map, got $decoded'); + throw FormatException('Expected method call Map, got $decoded'); final dynamic method = decoded['method']; final dynamic arguments = decoded['args']; if (method is String) - return new MethodCall(method, arguments); - throw new FormatException('Invalid method call: $decoded'); + return MethodCall(method, arguments); + throw FormatException('Invalid method call: $decoded'); } @override dynamic decodeEnvelope(ByteData envelope) { final dynamic decoded = const JSONMessageCodec().decodeMessage(envelope); if (decoded is! List) - throw new FormatException('Expected envelope List, got $decoded'); + throw FormatException('Expected envelope List, got $decoded'); if (decoded.length == 1) return decoded[0]; if (decoded.length == 3 && decoded[0] is String && (decoded[1] == null || decoded[1] is String)) - throw new PlatformException( + throw PlatformException( code: decoded[0], message: decoded[1], details: decoded[2], ); - throw new FormatException('Invalid envelope: $decoded'); + throw FormatException('Invalid envelope: $decoded'); } @override @@ -271,7 +271,7 @@ class StandardMessageCodec implements MessageCodec { ByteData encodeMessage(dynamic message) { if (message == null) return null; - final WriteBuffer buffer = new WriteBuffer(); + final WriteBuffer buffer = WriteBuffer(); writeValue(buffer, message); return buffer.done(); } @@ -280,7 +280,7 @@ class StandardMessageCodec implements MessageCodec { dynamic decodeMessage(ByteData message) { if (message == null) return null; - final ReadBuffer buffer = new ReadBuffer(message); + final ReadBuffer buffer = ReadBuffer(message); final dynamic result = readValue(buffer); if (buffer.hasRemaining) throw const FormatException('Message corrupted'); @@ -350,7 +350,7 @@ class StandardMessageCodec implements MessageCodec { writeValue(buffer, value); }); } else { - throw new ArgumentError.value(value); + throw ArgumentError.value(value); } } @@ -420,7 +420,7 @@ class StandardMessageCodec implements MessageCodec { break; case _valueList: final int length = readSize(buffer); - result = new List(length); + result = List(length); for (int i = 0; i < length; i++) { result[i] = readValue(buffer); } @@ -501,7 +501,7 @@ class StandardMethodCodec implements MethodCodec { @override ByteData encodeMethodCall(MethodCall call) { - final WriteBuffer buffer = new WriteBuffer(); + final WriteBuffer buffer = WriteBuffer(); messageCodec.writeValue(buffer, call.method); messageCodec.writeValue(buffer, call.arguments); return buffer.done(); @@ -509,18 +509,18 @@ class StandardMethodCodec implements MethodCodec { @override MethodCall decodeMethodCall(ByteData methodCall) { - final ReadBuffer buffer = new ReadBuffer(methodCall); + final ReadBuffer buffer = ReadBuffer(methodCall); final dynamic method = messageCodec.readValue(buffer); final dynamic arguments = messageCodec.readValue(buffer); if (method is String && !buffer.hasRemaining) - return new MethodCall(method, arguments); + return MethodCall(method, arguments); else throw const FormatException('Invalid method call'); } @override ByteData encodeSuccessEnvelope(dynamic result) { - final WriteBuffer buffer = new WriteBuffer(); + final WriteBuffer buffer = WriteBuffer(); buffer.putUint8(0); messageCodec.writeValue(buffer, result); return buffer.done(); @@ -528,7 +528,7 @@ class StandardMethodCodec implements MethodCodec { @override ByteData encodeErrorEnvelope({@required String code, String message, dynamic details}) { - final WriteBuffer buffer = new WriteBuffer(); + final WriteBuffer buffer = WriteBuffer(); buffer.putUint8(1); messageCodec.writeValue(buffer, code); messageCodec.writeValue(buffer, message); @@ -541,14 +541,14 @@ class StandardMethodCodec implements MethodCodec { // First byte is zero in success case, and non-zero otherwise. if (envelope.lengthInBytes == 0) throw const FormatException('Expected envelope, got nothing'); - final ReadBuffer buffer = new ReadBuffer(envelope); + final ReadBuffer buffer = ReadBuffer(envelope); if (buffer.getUint8() == 0) return messageCodec.readValue(buffer); final dynamic errorCode = messageCodec.readValue(buffer); final dynamic errorMessage = messageCodec.readValue(buffer); final dynamic errorDetails = messageCodec.readValue(buffer); if (errorCode is String && (errorMessage == null || errorMessage is String) && !buffer.hasRemaining) - throw new PlatformException(code: errorCode, message: errorMessage, details: errorDetails); + throw PlatformException(code: errorCode, message: errorMessage, details: errorDetails); else throw const FormatException('Invalid envelope'); } diff --git a/packages/flutter/lib/src/services/platform_channel.dart b/packages/flutter/lib/src/services/platform_channel.dart index 6c4484a815..a5aca435e7 100644 --- a/packages/flutter/lib/src/services/platform_channel.dart +++ b/packages/flutter/lib/src/services/platform_channel.dart @@ -272,10 +272,10 @@ class MethodChannel { assert(method != null); final dynamic result = await BinaryMessages.send( name, - codec.encodeMethodCall(new MethodCall(method, arguments)), + codec.encodeMethodCall(MethodCall(method, arguments)), ); if (result == null) - throw new MissingPluginException('No implementation found for method $method on channel $name'); + throw MissingPluginException('No implementation found for method $method on channel $name'); return codec.decodeEnvelope(result); } @@ -405,9 +405,9 @@ class EventChannel { /// stream listener count changes from 0 to 1. Stream deactivation happens /// only when stream listener count changes from 1 to 0. Stream receiveBroadcastStream([dynamic arguments]) { - final MethodChannel methodChannel = new MethodChannel(name, codec); + final MethodChannel methodChannel = MethodChannel(name, codec); StreamController controller; - controller = new StreamController.broadcast(onListen: () async { + controller = StreamController.broadcast(onListen: () async { BinaryMessages.setMessageHandler(name, (ByteData reply) async { if (reply == null) { controller.close(); @@ -423,7 +423,7 @@ class EventChannel { try { await methodChannel.invokeMethod('listen', arguments); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'services library', @@ -435,7 +435,7 @@ class EventChannel { try { await methodChannel.invokeMethod('cancel', arguments); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'services library', diff --git a/packages/flutter/lib/src/services/platform_messages.dart b/packages/flutter/lib/src/services/platform_messages.dart index 55f782a1be..40e3e2eb1a 100644 --- a/packages/flutter/lib/src/services/platform_messages.dart +++ b/packages/flutter/lib/src/services/platform_messages.dart @@ -36,12 +36,12 @@ class BinaryMessages { {}; static Future _sendPlatformMessage(String channel, ByteData message) { - final Completer completer = new Completer(); + final Completer completer = Completer(); ui.window.sendPlatformMessage(channel, message, (ByteData reply) { try { completer.complete(reply); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'services library', @@ -66,7 +66,7 @@ class BinaryMessages { if (handler != null) response = await handler(data); } catch (exception, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'services library', diff --git a/packages/flutter/lib/src/services/platform_views.dart b/packages/flutter/lib/src/services/platform_views.dart index f9714589b8..eea7115b6c 100644 --- a/packages/flutter/lib/src/services/platform_views.dart +++ b/packages/flutter/lib/src/services/platform_views.dart @@ -82,7 +82,7 @@ class PlatformViewsService { assert(viewType != null); assert(layoutDirection != null); assert(creationParams == null || creationParamsCodec != null); - return new AndroidViewController._( + return AndroidViewController._( id, viewType, creationParams, @@ -456,7 +456,7 @@ class AndroidViewController { /// The first time a size is set triggers the creation of the Android view. Future setSize(Size size) async { if (_state == _AndroidViewState.disposed) - throw new FlutterError('trying to size a disposed Android View. View id: $id'); + throw FlutterError('trying to size a disposed Android View. View id: $id'); assert(size != null); assert(!size.isEmpty); @@ -474,7 +474,7 @@ class AndroidViewController { /// Sets the layout direction for the Android view. Future setLayoutDirection(TextDirection layoutDirection) async { if (_state == _AndroidViewState.disposed) - throw new FlutterError('trying to set a layout direction for a disposed Android View. View id: $id'); + throw FlutterError('trying to set a layout direction for a disposed Android View. View id: $id'); if (layoutDirection == _layoutDirection) return; diff --git a/packages/flutter/lib/src/services/raw_keyboard.dart b/packages/flutter/lib/src/services/raw_keyboard.dart index 6f2bd1501f..7b0a799de6 100644 --- a/packages/flutter/lib/src/services/raw_keyboard.dart +++ b/packages/flutter/lib/src/services/raw_keyboard.dart @@ -132,7 +132,7 @@ abstract class RawKeyEvent { final String keymap = message['keymap']; switch (keymap) { case 'android': - data = new RawKeyEventDataAndroid( + data = RawKeyEventDataAndroid( flags: message['flags'] ?? 0, codePoint: message['codePoint'] ?? 0, keyCode: message['keyCode'] ?? 0, @@ -141,7 +141,7 @@ abstract class RawKeyEvent { ); break; case 'fuchsia': - data = new RawKeyEventDataFuchsia( + data = RawKeyEventDataFuchsia( hidUsage: message['hidUsage'] ?? 0, codePoint: message['codePoint'] ?? 0, modifiers: message['modifiers'] ?? 0, @@ -150,17 +150,17 @@ abstract class RawKeyEvent { default: // We don't yet implement raw key events on iOS, but we don't hit this // exception because the engine never sends us these messages. - throw new FlutterError('Unknown keymap for key events: $keymap'); + throw FlutterError('Unknown keymap for key events: $keymap'); } final String type = message['type']; switch (type) { case 'keydown': - return new RawKeyDownEvent(data: data); + return RawKeyDownEvent(data: data); case 'keyup': - return new RawKeyUpEvent(data: data); + return RawKeyUpEvent(data: data); default: - throw new FlutterError('Unknown key event type: $type'); + throw FlutterError('Unknown key event type: $type'); } } @@ -215,7 +215,7 @@ class RawKeyboard { } /// The shared instance of [RawKeyboard]. - static final RawKeyboard instance = new RawKeyboard._(); + static final RawKeyboard instance = RawKeyboard._(); final List> _listeners = >[]; @@ -236,10 +236,10 @@ class RawKeyboard { Future _handleKeyEvent(dynamic message) async { if (_listeners.isEmpty) return; - final RawKeyEvent event = new RawKeyEvent.fromMessage(message); + final RawKeyEvent event = RawKeyEvent.fromMessage(message); if (event == null) return; - for (ValueChanged listener in new List>.from(_listeners)) + for (ValueChanged listener in List>.from(_listeners)) if (_listeners.contains(listener)) listener(event); } diff --git a/packages/flutter/lib/src/services/system_chrome.dart b/packages/flutter/lib/src/services/system_chrome.dart index f0c78c79bc..f6c862748f 100644 --- a/packages/flutter/lib/src/services/system_chrome.dart +++ b/packages/flutter/lib/src/services/system_chrome.dart @@ -183,7 +183,7 @@ class SystemUiOverlayStyle { Brightness statusBarIconBrightness, Brightness systemNavigationBarIconBrightness, }) { - return new SystemUiOverlayStyle( + return SystemUiOverlayStyle( systemNavigationBarColor: systemNavigationBarColor ?? this.systemNavigationBarColor, systemNavigationBarDividerColor: systemNavigationBarDividerColor ?? this.systemNavigationBarDividerColor, statusBarColor: statusBarColor ?? this.statusBarColor, diff --git a/packages/flutter/lib/src/services/text_editing.dart b/packages/flutter/lib/src/services/text_editing.dart index 46ac714d38..3ca883a6d9 100644 --- a/packages/flutter/lib/src/services/text_editing.dart +++ b/packages/flutter/lib/src/services/text_editing.dart @@ -163,7 +163,7 @@ class TextSelection extends TextRange { /// The position at which the selection originates. /// /// Might be larger than, smaller than, or equal to extent. - TextPosition get base => new TextPosition(offset: baseOffset, affinity: affinity); + TextPosition get base => TextPosition(offset: baseOffset, affinity: affinity); /// The position at which the selection terminates. /// @@ -172,7 +172,7 @@ class TextSelection extends TextRange { /// side of the selection, this is the location at which to paint the caret. /// /// Might be larger than, smaller than, or equal to base. - TextPosition get extent => new TextPosition(offset: extentOffset, affinity: affinity); + TextPosition get extent => TextPosition(offset: extentOffset, affinity: affinity); @override String toString() { @@ -208,7 +208,7 @@ class TextSelection extends TextRange { TextAffinity affinity, bool isDirectional, }) { - return new TextSelection( + return TextSelection( baseOffset: baseOffset ?? this.baseOffset, extentOffset: extentOffset ?? this.extentOffset, affinity: affinity ?? this.affinity, diff --git a/packages/flutter/lib/src/services/text_formatter.dart b/packages/flutter/lib/src/services/text_formatter.dart index 2c13b01ceb..123efffafe 100644 --- a/packages/flutter/lib/src/services/text_formatter.dart +++ b/packages/flutter/lib/src/services/text_formatter.dart @@ -47,7 +47,7 @@ abstract class TextInputFormatter { static TextInputFormatter withFunction( TextInputFormatFunction formatFunction ) { - return new _SimpleTextInputFormatter(formatFunction); + return _SimpleTextInputFormatter(formatFunction); } } @@ -119,7 +119,7 @@ class BlacklistingTextInputFormatter extends TextInputFormatter { /// A [BlacklistingTextInputFormatter] that forces input to be a single line. static final BlacklistingTextInputFormatter singleLineFormatter - = new BlacklistingTextInputFormatter(new RegExp(r'\n')); + = BlacklistingTextInputFormatter(RegExp(r'\n')); } /// A [TextInputFormatter] that prevents the insertion of more characters @@ -184,13 +184,13 @@ class LengthLimitingTextInputFormatter extends TextInputFormatter { // address this in Dart. // TODO(gspencer): convert this to count actual characters when Dart // supports that. - final RuneIterator iterator = new RuneIterator(newValue.text); + final RuneIterator iterator = RuneIterator(newValue.text); if (iterator.moveNext()) for (int count = 0; count < maxLength; ++count) if (!iterator.moveNext()) break; final String truncated = newValue.text.substring(0, iterator.rawIndex); - return new TextEditingValue( + return TextEditingValue( text: truncated, selection: newSelection, composing: TextRange.empty, @@ -241,7 +241,7 @@ class WhitelistingTextInputFormatter extends TextInputFormatter { /// A [WhitelistingTextInputFormatter] that takes in digits `[0-9]` only. static final WhitelistingTextInputFormatter digitsOnly - = new WhitelistingTextInputFormatter(new RegExp(r'\d+')); + = WhitelistingTextInputFormatter(RegExp(r'\d+')); } TextEditingValue _selectionAwareTextManipulation( @@ -277,7 +277,7 @@ TextEditingValue _selectionAwareTextManipulation( ); } } - return new TextEditingValue( + return TextEditingValue( text: manipulatedText, selection: manipulatedSelection ?? const TextSelection.collapsed(offset: -1), composing: manipulatedText == value.text diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index 48512c028a..13c4d16cba 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -458,15 +458,15 @@ class TextEditingValue { /// Creates an instance of this class from a JSON object. factory TextEditingValue.fromJSON(Map encoded) { - return new TextEditingValue( + return TextEditingValue( text: encoded['text'], - selection: new TextSelection( + selection: TextSelection( baseOffset: encoded['selectionBase'] ?? -1, extentOffset: encoded['selectionExtent'] ?? -1, affinity: _toTextAffinity(encoded['selectionAffinity']) ?? TextAffinity.downstream, isDirectional: encoded['selectionIsDirectional'] ?? false, ), - composing: new TextRange( + composing: TextRange( start: encoded['composingBase'] ?? -1, end: encoded['composingExtent'] ?? -1, ), @@ -504,7 +504,7 @@ class TextEditingValue { TextSelection selection, TextRange composing }) { - return new TextEditingValue( + return TextEditingValue( text: text ?? this.text, selection: selection ?? this.selection, composing: composing ?? this.composing @@ -645,7 +645,7 @@ TextInputAction _toTextInputAction(String action) { case 'TextInputAction.newline': return TextInputAction.newline; } - throw new FlutterError('Unknown text input action: $action'); + throw FlutterError('Unknown text input action: $action'); } class _TextInputClientHandler { @@ -666,13 +666,13 @@ class _TextInputClientHandler { return; switch (method) { case 'TextInputClient.updateEditingState': - _currentConnection._client.updateEditingValue(new TextEditingValue.fromJSON(args[1])); + _currentConnection._client.updateEditingValue(TextEditingValue.fromJSON(args[1])); break; case 'TextInputClient.performAction': _currentConnection._client.performAction(_toTextInputAction(args[1])); break; default: - throw new MissingPluginException(); + throw MissingPluginException(); } } @@ -694,7 +694,7 @@ class _TextInputClientHandler { } } -final _TextInputClientHandler _clientHandler = new _TextInputClientHandler(); +final _TextInputClientHandler _clientHandler = _TextInputClientHandler(); /// An interface to the system's text input control. class TextInput { @@ -740,7 +740,7 @@ class TextInput { assert(client != null); assert(configuration != null); assert(_debugEnsureInputActionWorksOnPlatform(configuration.inputAction)); - final TextInputConnection connection = new TextInputConnection._(client); + final TextInputConnection connection = TextInputConnection._(client); _clientHandler._currentConnection = connection; SystemChannels.textInput.invokeMethod( 'TextInput.setClient', diff --git a/packages/flutter/lib/src/widgets/animated_cross_fade.dart b/packages/flutter/lib/src/widgets/animated_cross_fade.dart index 507350bdc3..065b75ce12 100644 --- a/packages/flutter/lib/src/widgets/animated_cross_fade.dart +++ b/packages/flutter/lib/src/widgets/animated_cross_fade.dart @@ -201,17 +201,17 @@ class AnimatedCrossFade extends StatefulWidget { /// This is the default value for [layoutBuilder]. It implements /// [AnimatedCrossFadeBuilder]. static Widget defaultLayoutBuilder(Widget topChild, Key topChildKey, Widget bottomChild, Key bottomChildKey) { - return new Stack( + return Stack( overflow: Overflow.visible, children: [ - new Positioned( + Positioned( key: bottomChildKey, left: 0.0, top: 0.0, right: 0.0, child: bottomChild, ), - new Positioned( + Positioned( key: topChildKey, child: topChild, ) @@ -220,13 +220,13 @@ class AnimatedCrossFade extends StatefulWidget { } @override - _AnimatedCrossFadeState createState() => new _AnimatedCrossFadeState(); + _AnimatedCrossFadeState createState() => _AnimatedCrossFadeState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('crossFadeState', crossFadeState)); - properties.add(new DiagnosticsProperty('alignment', alignment, defaultValue: Alignment.topCenter)); + properties.add(EnumProperty('crossFadeState', crossFadeState)); + properties.add(DiagnosticsProperty('alignment', alignment, defaultValue: Alignment.topCenter)); } } @@ -238,7 +238,7 @@ class _AnimatedCrossFadeState extends State with TickerProvid @override void initState() { super.initState(); - _controller = new AnimationController(duration: widget.duration, vsync: this); + _controller = AnimationController(duration: widget.duration, vsync: this); if (widget.crossFadeState == CrossFadeState.showSecond) _controller.value = 1.0; _firstAnimation = _initAnimation(widget.firstCurve, true); @@ -246,13 +246,13 @@ class _AnimatedCrossFadeState extends State with TickerProvid } Animation _initAnimation(Curve curve, bool inverted) { - Animation animation = new CurvedAnimation( + Animation animation = CurvedAnimation( parent: _controller, curve: curve, ); if (inverted) { - animation = new Tween( + animation = Tween( begin: 1.0, end: 0.0, ).animate(animation); @@ -326,30 +326,30 @@ class _AnimatedCrossFadeState extends State with TickerProvid bottomAnimation = _secondAnimation; } - bottomChild = new TickerMode( + bottomChild = TickerMode( key: bottomKey, enabled: _isTransitioning, - child: new ExcludeSemantics( + child: ExcludeSemantics( excluding: true, // Always exclude the semantics of the widget that's fading out. - child: new FadeTransition( + child: FadeTransition( opacity: bottomAnimation, child: bottomChild, ), ), ); - topChild = new TickerMode( + topChild = TickerMode( key: topKey, enabled: true, // Top widget always has its animations enabled. - child: new ExcludeSemantics( + child: ExcludeSemantics( excluding: false, // Always publish semantics for the widget that's fading in. - child: new FadeTransition( + child: FadeTransition( opacity: topAnimation, child: topChild, ), ), ); - return new ClipRect( - child: new AnimatedSize( + return ClipRect( + child: AnimatedSize( alignment: widget.alignment, duration: widget.duration, curve: widget.sizeCurve, @@ -362,8 +362,8 @@ class _AnimatedCrossFadeState extends State with TickerProvid @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new EnumProperty('crossFadeState', widget.crossFadeState)); - description.add(new DiagnosticsProperty('controller', _controller, showName: false)); - description.add(new DiagnosticsProperty('alignment', widget.alignment, defaultValue: Alignment.topCenter)); + description.add(EnumProperty('crossFadeState', widget.crossFadeState)); + description.add(DiagnosticsProperty('controller', _controller, showName: false)); + description.add(DiagnosticsProperty('alignment', widget.alignment, defaultValue: Alignment.topCenter)); } } diff --git a/packages/flutter/lib/src/widgets/animated_list.dart b/packages/flutter/lib/src/widgets/animated_list.dart index efeeb69327..b33dafb82e 100644 --- a/packages/flutter/lib/src/widgets/animated_list.dart +++ b/packages/flutter/lib/src/widgets/animated_list.dart @@ -165,7 +165,7 @@ class AnimatedList extends StatefulWidget { final AnimatedListState result = context.ancestorStateOfType(const TypeMatcher()); if (nullOk || result != null) return result; - throw new FlutterError( + throw FlutterError( 'AnimatedList.of() called with a context that does not contain an AnimatedList.\n' 'No AnimatedList ancestor could be found starting from the context that was passed to AnimatedList.of(). ' 'This can happen when the context provided is from the same StatefulWidget that ' @@ -178,7 +178,7 @@ class AnimatedList extends StatefulWidget { } @override - AnimatedListState createState() => new AnimatedListState(); + AnimatedListState createState() => AnimatedListState(); } /// The state for a scrolling container that animates items when they are @@ -226,12 +226,12 @@ class AnimatedListState extends State with TickerProviderStateMixi } _ActiveItem _removeActiveItemAt(List<_ActiveItem> items, int itemIndex) { - final int i = binarySearch(items, new _ActiveItem.index(itemIndex)); + final int i = binarySearch(items, _ActiveItem.index(itemIndex)); return i == -1 ? null : items.removeAt(i); } _ActiveItem _activeItemAt(List<_ActiveItem> items, int itemIndex) { - final int i = binarySearch(items, new _ActiveItem.index(itemIndex)); + final int i = binarySearch(items, _ActiveItem.index(itemIndex)); return i == -1 ? null : items[i]; } @@ -288,8 +288,8 @@ class AnimatedListState extends State with TickerProviderStateMixi item.itemIndex += 1; } - final AnimationController controller = new AnimationController(duration: duration, vsync: this); - final _ActiveItem incomingItem = new _ActiveItem.incoming(controller, itemIndex); + final AnimationController controller = AnimationController(duration: duration, vsync: this); + final _ActiveItem incomingItem = _ActiveItem.incoming(controller, itemIndex); setState(() { _incomingItems ..add(incomingItem) @@ -324,8 +324,8 @@ class AnimatedListState extends State with TickerProviderStateMixi final _ActiveItem incomingItem = _removeActiveItemAt(_incomingItems, itemIndex); final AnimationController controller = incomingItem?.controller - ?? new AnimationController(duration: duration, value: 1.0, vsync: this); - final _ActiveItem outgoingItem = new _ActiveItem.outgoing(controller, itemIndex, builder); + ?? AnimationController(duration: duration, value: 1.0, vsync: this); + final _ActiveItem outgoingItem = _ActiveItem.outgoing(controller, itemIndex, builder); setState(() { _outgoingItems ..add(outgoingItem) @@ -364,7 +364,7 @@ class AnimatedListState extends State with TickerProviderStateMixi @override Widget build(BuildContext context) { - return new ListView.builder( + return ListView.builder( itemBuilder: _itemBuilder, itemCount: _itemsCount, scrollDirection: widget.scrollDirection, diff --git a/packages/flutter/lib/src/widgets/animated_size.dart b/packages/flutter/lib/src/widgets/animated_size.dart index 4f1a1b13fd..8ef3badce5 100644 --- a/packages/flutter/lib/src/widgets/animated_size.dart +++ b/packages/flutter/lib/src/widgets/animated_size.dart @@ -57,7 +57,7 @@ class AnimatedSize extends SingleChildRenderObjectWidget { @override RenderAnimatedSize createRenderObject(BuildContext context) { - return new RenderAnimatedSize( + return RenderAnimatedSize( alignment: alignment, duration: duration, curve: curve, diff --git a/packages/flutter/lib/src/widgets/animated_switcher.dart b/packages/flutter/lib/src/widgets/animated_switcher.dart index 136fad5c44..22f00724c6 100644 --- a/packages/flutter/lib/src/widgets/animated_switcher.dart +++ b/packages/flutter/lib/src/widgets/animated_switcher.dart @@ -194,7 +194,7 @@ class AnimatedSwitcher extends StatefulWidget { final AnimatedSwitcherLayoutBuilder layoutBuilder; @override - _AnimatedSwitcherState createState() => new _AnimatedSwitcherState(); + _AnimatedSwitcherState createState() => _AnimatedSwitcherState(); /// The transition builder used as the default value of [transitionBuilder]. /// @@ -204,7 +204,7 @@ class AnimatedSwitcher extends StatefulWidget { /// /// This is an [AnimatedSwitcherTransitionBuilder] function. static Widget defaultTransitionBuilder(Widget child, Animation animation) { - return new FadeTransition( + return FadeTransition( opacity: animation, child: child, ); @@ -222,7 +222,7 @@ class AnimatedSwitcher extends StatefulWidget { if (currentChild != null) { children = children.toList()..add(currentChild); } - return new Stack( + return Stack( children: children, alignment: Alignment.center, ); @@ -230,7 +230,7 @@ class AnimatedSwitcher extends StatefulWidget { } class _AnimatedSwitcherState extends State with TickerProviderStateMixin { - final Set<_AnimatedSwitcherChildEntry> _previousChildren = new Set<_AnimatedSwitcherChildEntry>(); + final Set<_AnimatedSwitcherChildEntry> _previousChildren = Set<_AnimatedSwitcherChildEntry>(); _AnimatedSwitcherChildEntry _currentChild; List _previousChildWidgetCache = const []; int serialNumber = 0; @@ -245,9 +245,9 @@ class _AnimatedSwitcherState extends State with TickerProvider @required AnimationController controller, @required Animation animation, }) { - final _AnimatedSwitcherChildEntry entry = new _AnimatedSwitcherChildEntry( + final _AnimatedSwitcherChildEntry entry = _AnimatedSwitcherChildEntry( widgetChild: widget.child, - transition: new KeyedSubtree.wrap( + transition: KeyedSubtree.wrap( widget.transitionBuilder( widget.child, animation, @@ -293,7 +293,7 @@ class _AnimatedSwitcherState extends State with TickerProvider _currentChild = null; return; } - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: widget.duration, vsync: this, ); @@ -307,7 +307,7 @@ class _AnimatedSwitcherState extends State with TickerProvider assert(_previousChildren.isEmpty); controller.value = 1.0; } - final Animation animation = new CurvedAnimation( + final Animation animation = CurvedAnimation( parent: controller, curve: widget.switchInCurve, reverseCurve: widget.switchOutCurve, @@ -331,7 +331,7 @@ class _AnimatedSwitcherState extends State with TickerProvider super.didUpdateWidget(oldWidget); void updateTransition(_AnimatedSwitcherChildEntry entry) { - entry.transition = new KeyedSubtree( + entry.transition = KeyedSubtree( key: entry.transition.key, child: widget.transitionBuilder(entry.widgetChild, entry.animation), ); @@ -365,7 +365,7 @@ class _AnimatedSwitcherState extends State with TickerProvider } void _rebuildChildWidgetCacheIfNeeded() { - _previousChildWidgetCache ??= new List.unmodifiable( + _previousChildWidgetCache ??= List.unmodifiable( _previousChildren.map((_AnimatedSwitcherChildEntry child) { return child.transition; }), diff --git a/packages/flutter/lib/src/widgets/annotated_region.dart b/packages/flutter/lib/src/widgets/annotated_region.dart index f14d7fd089..e44b8dda2d 100644 --- a/packages/flutter/lib/src/widgets/annotated_region.dart +++ b/packages/flutter/lib/src/widgets/annotated_region.dart @@ -44,7 +44,7 @@ class AnnotatedRegion extends SingleChildRenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) { - return new RenderAnnotatedRegion(value: value, sized: sized); + return RenderAnnotatedRegion(value: value, sized: sized); } @override diff --git a/packages/flutter/lib/src/widgets/app.dart b/packages/flutter/lib/src/widgets/app.dart index 12ea869576..b27a0dd9da 100644 --- a/packages/flutter/lib/src/widgets/app.dart +++ b/packages/flutter/lib/src/widgets/app.dart @@ -415,7 +415,7 @@ class WidgetsApp extends StatefulWidget { static bool debugAllowBannerOverride = true; @override - _WidgetsAppState createState() => new _WidgetsAppState(); + _WidgetsAppState createState() => _WidgetsAppState(); } class _WidgetsAppState extends State implements WidgetsBindingObserver { @@ -458,7 +458,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv if (widget.onGenerateRoute == null) { _navigator = null; } else { - _navigator = widget.navigatorKey ?? new GlobalObjectKey(this); + _navigator = widget.navigatorKey ?? GlobalObjectKey(this); } } @@ -564,7 +564,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv Widget build(BuildContext context) { Widget navigator; if (_navigator != null) { - navigator = new Navigator( + navigator = Navigator( key: _navigator, initialRoute: widget.initialRoute ?? ui.window.defaultRouteName, onGenerateRoute: widget.onGenerateRoute, @@ -575,7 +575,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv Widget result; if (widget.builder != null) { - result = new Builder( + result = Builder( builder: (BuildContext context) { return widget.builder(context, navigator); }, @@ -586,7 +586,7 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv } if (widget.textStyle != null) { - result = new DefaultTextStyle( + result = DefaultTextStyle( style: widget.textStyle, child: result, ); @@ -596,40 +596,40 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv // We need to push a performance overlay if any of the display or checkerboarding // options are set. if (widget.showPerformanceOverlay || WidgetsApp.showPerformanceOverlayOverride) { - performanceOverlay = new PerformanceOverlay.allEnabled( + performanceOverlay = PerformanceOverlay.allEnabled( checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages, checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers, ); } else if (widget.checkerboardRasterCacheImages || widget.checkerboardOffscreenLayers) { - performanceOverlay = new PerformanceOverlay( + performanceOverlay = PerformanceOverlay( checkerboardRasterCacheImages: widget.checkerboardRasterCacheImages, checkerboardOffscreenLayers: widget.checkerboardOffscreenLayers, ); } if (performanceOverlay != null) { - result = new Stack( + result = Stack( children: [ result, - new Positioned(top: 0.0, left: 0.0, right: 0.0, child: performanceOverlay), + Positioned(top: 0.0, left: 0.0, right: 0.0, child: performanceOverlay), ] ); } if (widget.showSemanticsDebugger) { - result = new SemanticsDebugger( + result = SemanticsDebugger( child: result, ); } assert(() { if (widget.debugShowWidgetInspector || WidgetsApp.debugShowWidgetInspectorOverride) { - result = new WidgetInspector( + result = WidgetInspector( child: result, selectButtonBuilder: widget.inspectorSelectButtonBuilder, ); } if (widget.debugShowCheckedModeBanner && WidgetsApp.debugAllowBannerOverride) { - result = new CheckedModeBanner( + result = CheckedModeBanner( child: result, ); } @@ -638,14 +638,14 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv Widget title; if (widget.onGenerateTitle != null) { - title = new Builder( + title = Builder( // This Builder exists to provide a context below the Localizations widget. // The onGenerateTitle callback can refer to Localizations via its context // parameter. builder: (BuildContext context) { final String title = widget.onGenerateTitle(context); assert(title != null, 'onGenerateTitle must return a non-null String'); - return new Title( + return Title( title: title, color: widget.color, child: result, @@ -653,16 +653,16 @@ class _WidgetsAppState extends State implements WidgetsBindingObserv }, ); } else { - title = new Title( + title = Title( title: widget.title, color: widget.color, child: result, ); } - return new MediaQuery( - data: new MediaQueryData.fromWindow(ui.window), - child: new Localizations( + return MediaQuery( + data: MediaQueryData.fromWindow(ui.window), + child: Localizations( locale: widget.locale ?? _locale, delegates: _localizationsDelegates.toList(), child: title, diff --git a/packages/flutter/lib/src/widgets/async.dart b/packages/flutter/lib/src/widgets/async.dart index b73111c7bd..19e628618b 100644 --- a/packages/flutter/lib/src/widgets/async.dart +++ b/packages/flutter/lib/src/widgets/async.dart @@ -93,7 +93,7 @@ abstract class StreamBuilderBase extends StatefulWidget { Widget build(BuildContext context, S currentSummary); @override - State> createState() => new _StreamBuilderBaseState(); + State> createState() => _StreamBuilderBaseState(); } /// State for [StreamBuilderBase]. @@ -230,7 +230,7 @@ class AsyncSnapshot { return data; if (hasError) throw error; - throw new StateError('Snapshot has neither data nor error'); + throw StateError('Snapshot has neither data nor error'); } /// The latest error object received by the asynchronous computation. @@ -244,7 +244,7 @@ class AsyncSnapshot { /// /// The [data] and [error] fields persist unmodified, even if the new state is /// [ConnectionState.none]. - AsyncSnapshot inState(ConnectionState state) => new AsyncSnapshot._(state, data, error); + AsyncSnapshot inState(ConnectionState state) => AsyncSnapshot._(state, data, error); /// Returns whether this snapshot contains a non-null [data] value. /// @@ -385,19 +385,19 @@ class StreamBuilder extends StreamBuilderBase> { final T initialData; @override - AsyncSnapshot initial() => new AsyncSnapshot.withData(ConnectionState.none, initialData); + AsyncSnapshot initial() => AsyncSnapshot.withData(ConnectionState.none, initialData); @override AsyncSnapshot afterConnected(AsyncSnapshot current) => current.inState(ConnectionState.waiting); @override AsyncSnapshot afterData(AsyncSnapshot current, T data) { - return new AsyncSnapshot.withData(ConnectionState.active, data); + return AsyncSnapshot.withData(ConnectionState.active, data); } @override AsyncSnapshot afterError(AsyncSnapshot current, Object error) { - return new AsyncSnapshot.withError(ConnectionState.active, error); + return AsyncSnapshot.withError(ConnectionState.active, error); } @override @@ -550,7 +550,7 @@ class FutureBuilder extends StatefulWidget { final T initialData; @override - State> createState() => new _FutureBuilderState(); + State> createState() => _FutureBuilderState(); } /// State for [FutureBuilder]. @@ -564,7 +564,7 @@ class _FutureBuilderState extends State> { @override void initState() { super.initState(); - _snapshot = new AsyncSnapshot.withData(ConnectionState.none, widget.initialData); + _snapshot = AsyncSnapshot.withData(ConnectionState.none, widget.initialData); _subscribe(); } @@ -591,18 +591,18 @@ class _FutureBuilderState extends State> { void _subscribe() { if (widget.future != null) { - final Object callbackIdentity = new Object(); + final Object callbackIdentity = Object(); _activeCallbackIdentity = callbackIdentity; widget.future.then((T data) { if (_activeCallbackIdentity == callbackIdentity) { setState(() { - _snapshot = new AsyncSnapshot.withData(ConnectionState.done, data); + _snapshot = AsyncSnapshot.withData(ConnectionState.done, data); }); } }, onError: (Object error) { if (_activeCallbackIdentity == callbackIdentity) { setState(() { - _snapshot = new AsyncSnapshot.withError(ConnectionState.done, error); + _snapshot = AsyncSnapshot.withError(ConnectionState.done, error); }); } }); diff --git a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart index 25dbde45e7..a7aff02fc2 100644 --- a/packages/flutter/lib/src/widgets/automatic_keep_alive.dart +++ b/packages/flutter/lib/src/widgets/automatic_keep_alive.dart @@ -36,7 +36,7 @@ class AutomaticKeepAlive extends StatefulWidget { final Widget child; @override - _AutomaticKeepAliveState createState() => new _AutomaticKeepAliveState(); + _AutomaticKeepAliveState createState() => _AutomaticKeepAliveState(); } class _AutomaticKeepAliveState extends State { @@ -57,7 +57,7 @@ class _AutomaticKeepAliveState extends State { } void _updateChild() { - _child = new NotificationListener( + _child = NotificationListener( onNotification: _addClient, child: widget.child, ); @@ -143,7 +143,7 @@ class _AutomaticKeepAliveState extends State { return () { assert(() { if (!mounted) { - throw new FlutterError( + throw FlutterError( 'AutomaticKeepAlive handle triggered after AutomaticKeepAlive was disposed.' 'Widgets should always trigger their KeepAliveNotification handle when they are ' 'deactivated, so that they (or their handle) do not send spurious events later ' @@ -228,7 +228,7 @@ class _AutomaticKeepAliveState extends State { @override Widget build(BuildContext context) { assert(_child != null); - return new KeepAlive( + return KeepAlive( keepAlive: _keepingAlive, child: _child, ); @@ -238,8 +238,8 @@ class _AutomaticKeepAliveState extends State { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new FlagProperty('_keepingAlive', value: _keepingAlive, ifTrue: 'keeping subtree alive')); - description.add(new DiagnosticsProperty>( + description.add(FlagProperty('_keepingAlive', value: _keepingAlive, ifTrue: 'keeping subtree alive')); + description.add(DiagnosticsProperty>( 'handles', _handles, description: _handles != null ? @@ -345,8 +345,8 @@ abstract class AutomaticKeepAliveClientMixin extends S void _ensureKeepAlive() { assert(_keepAliveHandle == null); - _keepAliveHandle = new KeepAliveHandle(); - new KeepAliveNotification(_keepAliveHandle).dispatch(context); + _keepAliveHandle = KeepAliveHandle(); + KeepAliveNotification(_keepAliveHandle).dispatch(context); } void _releaseKeepAlive() { diff --git a/packages/flutter/lib/src/widgets/banner.dart b/packages/flutter/lib/src/widgets/banner.dart index d5ac0dccab..a9b3c76e2a 100644 --- a/packages/flutter/lib/src/widgets/banner.dart +++ b/packages/flutter/lib/src/widgets/banner.dart @@ -14,7 +14,7 @@ import 'framework.dart'; const double _kOffset = 40.0; // distance to bottom of banner, at a 45 degree angle inwards const double _kHeight = 12.0; // height of banner const double _kBottomOffset = _kOffset + 0.707 * _kHeight; // offset plus sqrt(2)/2 * banner height -final Rect _kRect = new Rect.fromLTWH(-_kOffset, _kOffset - _kHeight, _kOffset * 2.0, _kHeight); +final Rect _kRect = Rect.fromLTWH(-_kOffset, _kOffset - _kHeight, _kOffset * 2.0, _kHeight); const Color _kColor = Color(0xA0B71C1C); const TextStyle _kTextStyle = TextStyle( @@ -120,10 +120,10 @@ class BannerPainter extends CustomPainter { void _prepare() { _paintShadow = _shadow.toPaint(); - _paintBanner = new Paint() + _paintBanner = Paint() ..color = color; - _textPainter = new TextPainter( - text: new TextSpan(style: textStyle, text: message), + _textPainter = TextPainter( + text: TextSpan(style: textStyle, text: message), textAlign: TextAlign.center, textDirection: textDirection, ); @@ -141,7 +141,7 @@ class BannerPainter extends CustomPainter { ..drawRect(_kRect, _paintBanner); const double width = _kOffset * 2.0; _textPainter.layout(minWidth: width, maxWidth: width); - _textPainter.paint(canvas, _kRect.topLeft + new Offset(0.0, (_kRect.height - _textPainter.height) / 2.0)); + _textPainter.paint(canvas, _kRect.topLeft + Offset(0.0, (_kRect.height - _textPainter.height) / 2.0)); } @override @@ -302,8 +302,8 @@ class Banner extends StatelessWidget { @override Widget build(BuildContext context) { assert((textDirection != null && layoutDirection != null) || debugCheckHasDirectionality(context)); - return new CustomPaint( - foregroundPainter: new BannerPainter( + return CustomPaint( + foregroundPainter: BannerPainter( message: message, textDirection: textDirection ?? Directionality.of(context), location: location, @@ -318,11 +318,11 @@ class Banner extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('message', message, showName: false)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new EnumProperty('location', location)); - properties.add(new EnumProperty('layoutDirection', layoutDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, showName: false)); + properties.add(StringProperty('message', message, showName: false)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('location', location)); + properties.add(EnumProperty('layoutDirection', layoutDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, showName: false)); textStyle?.debugFillProperties(properties, prefix: 'text '); } } @@ -346,7 +346,7 @@ class CheckedModeBanner extends StatelessWidget { Widget build(BuildContext context) { Widget result = child; assert(() { - result = new Banner( + result = Banner( child: result, message: 'DEBUG', textDirection: TextDirection.ltr, @@ -365,6 +365,6 @@ class CheckedModeBanner extends StatelessWidget { message = '"DEBUG"'; return true; }()); - properties.add(new DiagnosticsNode.message(message)); + properties.add(DiagnosticsNode.message(message)); } } diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index bb6fbf7906..9ba5d6fb11 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -111,7 +111,7 @@ class Directionality extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('textDirection', textDirection)); + properties.add(EnumProperty('textDirection', textDirection)); } } @@ -199,7 +199,7 @@ class Opacity extends SingleChildRenderObjectWidget { @override RenderOpacity createRenderObject(BuildContext context) { - return new RenderOpacity( + return RenderOpacity( opacity: opacity, alwaysIncludeSemantics: alwaysIncludeSemantics, ); @@ -215,8 +215,8 @@ class Opacity extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('opacity', opacity)); - properties.add(new FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); + properties.add(DoubleProperty('opacity', opacity)); + properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); } } @@ -280,7 +280,7 @@ class ShaderMask extends SingleChildRenderObjectWidget { @override RenderShaderMask createRenderObject(BuildContext context) { - return new RenderShaderMask( + return RenderShaderMask( shaderCallback: shaderCallback, blendMode: blendMode, ); @@ -322,7 +322,7 @@ class BackdropFilter extends SingleChildRenderObjectWidget { @override RenderBackdropFilter createRenderObject(BuildContext context) { - return new RenderBackdropFilter(filter: filter); + return RenderBackdropFilter(filter: filter); } @override @@ -426,7 +426,7 @@ class CustomPaint extends SingleChildRenderObjectWidget { @override RenderCustomPaint createRenderObject(BuildContext context) { - return new RenderCustomPaint( + return RenderCustomPaint( painter: painter, foregroundPainter: foregroundPainter, preferredSize: size, @@ -505,7 +505,7 @@ class ClipRect extends SingleChildRenderObjectWidget { final Clip clipBehavior; @override - RenderClipRect createRenderObject(BuildContext context) => new RenderClipRect(clipper: clipper, clipBehavior: clipBehavior); + RenderClipRect createRenderObject(BuildContext context) => RenderClipRect(clipper: clipper, clipBehavior: clipBehavior); @override void updateRenderObject(BuildContext context, RenderClipRect renderObject) { @@ -520,7 +520,7 @@ class ClipRect extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); + properties.add(DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } } @@ -568,7 +568,7 @@ class ClipRRect extends SingleChildRenderObjectWidget { final Clip clipBehavior; @override - RenderClipRRect createRenderObject(BuildContext context) => new RenderClipRRect(borderRadius: borderRadius, clipper: clipper, clipBehavior: clipBehavior); + RenderClipRRect createRenderObject(BuildContext context) => RenderClipRRect(borderRadius: borderRadius, clipper: clipper, clipBehavior: clipBehavior); @override void updateRenderObject(BuildContext context, RenderClipRRect renderObject) { @@ -580,8 +580,8 @@ class ClipRRect extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('borderRadius', borderRadius, showName: false, defaultValue: null)); - properties.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); + properties.add(DiagnosticsProperty('borderRadius', borderRadius, showName: false, defaultValue: null)); + properties.add(DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } } @@ -620,7 +620,7 @@ class ClipOval extends SingleChildRenderObjectWidget { final Clip clipBehavior; @override - RenderClipOval createRenderObject(BuildContext context) => new RenderClipOval(clipper: clipper, clipBehavior: clipBehavior); + RenderClipOval createRenderObject(BuildContext context) => RenderClipOval(clipper: clipper, clipBehavior: clipBehavior); @override void updateRenderObject(BuildContext context, RenderClipOval renderObject) { @@ -635,7 +635,7 @@ class ClipOval extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); + properties.add(DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } } @@ -671,7 +671,7 @@ class ClipPath extends SingleChildRenderObjectWidget { final Clip clipBehavior; @override - RenderClipPath createRenderObject(BuildContext context) => new RenderClipPath(clipper: clipper, clipBehavior: clipBehavior); + RenderClipPath createRenderObject(BuildContext context) => RenderClipPath(clipper: clipper, clipBehavior: clipBehavior); @override void updateRenderObject(BuildContext context, RenderClipPath renderObject) { @@ -686,7 +686,7 @@ class ClipPath extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('clipper', clipper, defaultValue: null)); + properties.add(DiagnosticsProperty>('clipper', clipper, defaultValue: null)); } } @@ -748,7 +748,7 @@ class PhysicalModel extends SingleChildRenderObjectWidget { @override RenderPhysicalModel createRenderObject(BuildContext context) { - return new RenderPhysicalModel( + return RenderPhysicalModel( shape: shape, clipBehavior: clipBehavior, borderRadius: borderRadius, @@ -770,11 +770,11 @@ class PhysicalModel extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('shape', shape)); - properties.add(new DiagnosticsProperty('borderRadius', borderRadius)); - properties.add(new DoubleProperty('elevation', elevation)); - properties.add(new DiagnosticsProperty('color', color)); - properties.add(new DiagnosticsProperty('shadowColor', shadowColor)); + properties.add(EnumProperty('shape', shape)); + properties.add(DiagnosticsProperty('borderRadius', borderRadius)); + properties.add(DoubleProperty('elevation', elevation)); + properties.add(DiagnosticsProperty('color', color)); + properties.add(DiagnosticsProperty('shadowColor', shadowColor)); } } @@ -832,7 +832,7 @@ class PhysicalShape extends SingleChildRenderObjectWidget { @override RenderPhysicalShape createRenderObject(BuildContext context) { - return new RenderPhysicalShape( + return RenderPhysicalShape( clipper: clipper, clipBehavior: clipBehavior, elevation: elevation, @@ -853,10 +853,10 @@ class PhysicalShape extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('clipper', clipper)); - properties.add(new DoubleProperty('elevation', elevation)); - properties.add(new DiagnosticsProperty('color', color)); - properties.add(new DiagnosticsProperty('shadowColor', shadowColor)); + properties.add(DiagnosticsProperty>('clipper', clipper)); + properties.add(DoubleProperty('elevation', elevation)); + properties.add(DiagnosticsProperty('color', color)); + properties.add(DiagnosticsProperty('shadowColor', shadowColor)); } } @@ -934,7 +934,7 @@ class Transform extends SingleChildRenderObjectWidget { this.alignment = Alignment.center, this.transformHitTests = true, Widget child, - }) : transform = new Matrix4.rotationZ(angle), + }) : transform = Matrix4.rotationZ(angle), super(key: key, child: child); /// Creates a widget that transforms its child using a translation. @@ -960,7 +960,7 @@ class Transform extends SingleChildRenderObjectWidget { @required Offset offset, this.transformHitTests = true, Widget child, - }) : transform = new Matrix4.translationValues(offset.dx, offset.dy, 0.0), + }) : transform = Matrix4.translationValues(offset.dx, offset.dy, 0.0), origin = null, alignment = null, super(key: key, child: child); @@ -995,7 +995,7 @@ class Transform extends SingleChildRenderObjectWidget { this.alignment = Alignment.center, this.transformHitTests = true, Widget child, - }) : transform = new Matrix4.diagonal3Values(scale, scale, 1.0), + }) : transform = Matrix4.diagonal3Values(scale, scale, 1.0), super(key: key, child: child); /// The matrix to transform the child by during painting. @@ -1026,7 +1026,7 @@ class Transform extends SingleChildRenderObjectWidget { @override RenderTransform createRenderObject(BuildContext context) { - return new RenderTransform( + return RenderTransform( transform: transform, origin: origin, alignment: alignment, @@ -1085,7 +1085,7 @@ class CompositedTransformTarget extends SingleChildRenderObjectWidget { @override RenderLeaderLayer createRenderObject(BuildContext context) { - return new RenderLeaderLayer( + return RenderLeaderLayer( link: link, ); } @@ -1164,7 +1164,7 @@ class CompositedTransformFollower extends SingleChildRenderObjectWidget { @override RenderFollowerLayer createRenderObject(BuildContext context) { - return new RenderFollowerLayer( + return RenderFollowerLayer( link: link, showWhenUnlinked: showWhenUnlinked, offset: offset, @@ -1221,7 +1221,7 @@ class FittedBox extends SingleChildRenderObjectWidget { @override RenderFittedBox createRenderObject(BuildContext context) { - return new RenderFittedBox( + return RenderFittedBox( fit: fit, alignment: alignment, textDirection: Directionality.of(context), @@ -1239,8 +1239,8 @@ class FittedBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('fit', fit)); - properties.add(new DiagnosticsProperty('alignment', alignment)); + properties.add(EnumProperty('fit', fit)); + properties.add(DiagnosticsProperty('alignment', alignment)); } } @@ -1284,7 +1284,7 @@ class FractionalTranslation extends SingleChildRenderObjectWidget { @override RenderFractionalTranslation createRenderObject(BuildContext context) { - return new RenderFractionalTranslation( + return RenderFractionalTranslation( translation: translation, transformHitTests: transformHitTests, ); @@ -1337,7 +1337,7 @@ class RotatedBox extends SingleChildRenderObjectWidget { final int quarterTurns; @override - RenderRotatedBox createRenderObject(BuildContext context) => new RenderRotatedBox(quarterTurns: quarterTurns); + RenderRotatedBox createRenderObject(BuildContext context) => RenderRotatedBox(quarterTurns: quarterTurns); @override void updateRenderObject(BuildContext context, RenderRotatedBox renderObject) { @@ -1404,7 +1404,7 @@ class Padding extends SingleChildRenderObjectWidget { @override RenderPadding createRenderObject(BuildContext context) { - return new RenderPadding( + return RenderPadding( padding: padding, textDirection: Directionality.of(context), ); @@ -1420,7 +1420,7 @@ class Padding extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('padding', padding)); + properties.add(DiagnosticsProperty('padding', padding)); } } @@ -1493,7 +1493,7 @@ class Align extends SingleChildRenderObjectWidget { @override RenderPositionedBox createRenderObject(BuildContext context) { - return new RenderPositionedBox( + return RenderPositionedBox( alignment: alignment, widthFactor: widthFactor, heightFactor: heightFactor, @@ -1513,9 +1513,9 @@ class Align extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new DoubleProperty('widthFactor', widthFactor, defaultValue: null)); - properties.add(new DoubleProperty('heightFactor', heightFactor, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(DoubleProperty('widthFactor', widthFactor, defaultValue: null)); + properties.add(DoubleProperty('heightFactor', heightFactor, defaultValue: null)); } } @@ -1576,7 +1576,7 @@ class CustomSingleChildLayout extends SingleChildRenderObjectWidget { @override RenderCustomSingleChildLayoutBox createRenderObject(BuildContext context) { - return new RenderCustomSingleChildLayoutBox(delegate: delegate); + return RenderCustomSingleChildLayoutBox(delegate: delegate); } @override @@ -1600,7 +1600,7 @@ class LayoutId extends ParentDataWidget { @required Widget child }) : assert(child != null), assert(id != null), - super(key: key ?? new ValueKey(id), child: child); + super(key: key ?? ValueKey(id), child: child); /// An object representing the identity of this child. /// @@ -1623,7 +1623,7 @@ class LayoutId extends ParentDataWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('id', id)); + properties.add(DiagnosticsProperty('id', id)); } } @@ -1668,7 +1668,7 @@ class CustomMultiChildLayout extends MultiChildRenderObjectWidget { @override RenderCustomMultiChildLayoutBox createRenderObject(BuildContext context) { - return new RenderCustomMultiChildLayoutBox(delegate: delegate); + return RenderCustomMultiChildLayoutBox(delegate: delegate); } @override @@ -1750,13 +1750,13 @@ class SizedBox extends SingleChildRenderObjectWidget { @override RenderConstrainedBox createRenderObject(BuildContext context) { - return new RenderConstrainedBox( + return RenderConstrainedBox( additionalConstraints: _additionalConstraints, ); } BoxConstraints get _additionalConstraints { - return new BoxConstraints.tightFor(width: width, height: height); + return BoxConstraints.tightFor(width: width, height: height); } @override @@ -1787,8 +1787,8 @@ class SizedBox extends SingleChildRenderObjectWidget { } else { level = DiagnosticLevel.info; } - properties.add(new DoubleProperty('width', width, defaultValue: null, level: level)); - properties.add(new DoubleProperty('height', height, defaultValue: null, level: level)); + properties.add(DoubleProperty('width', width, defaultValue: null, level: level)); + properties.add(DoubleProperty('height', height, defaultValue: null, level: level)); } } @@ -1841,7 +1841,7 @@ class ConstrainedBox extends SingleChildRenderObjectWidget { @override RenderConstrainedBox createRenderObject(BuildContext context) { - return new RenderConstrainedBox(additionalConstraints: constraints); + return RenderConstrainedBox(additionalConstraints: constraints); } @override @@ -1852,7 +1852,7 @@ class ConstrainedBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('constraints', constraints, showName: false)); + properties.add(DiagnosticsProperty('constraints', constraints, showName: false)); } } @@ -1925,7 +1925,7 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { } @override - RenderUnconstrainedBox createRenderObject(BuildContext context) => new RenderUnconstrainedBox( + RenderUnconstrainedBox createRenderObject(BuildContext context) => RenderUnconstrainedBox( textDirection: textDirection ?? Directionality.of(context), alignment: alignment, constrainedAxis: constrainedAxis, @@ -1934,9 +1934,9 @@ class UnconstrainedBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new DiagnosticsProperty('constrainedAxis', null)); - properties.add(new DiagnosticsProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(DiagnosticsProperty('constrainedAxis', null)); + properties.add(DiagnosticsProperty('textDirection', textDirection, defaultValue: null)); } } @@ -2008,7 +2008,7 @@ class FractionallySizedBox extends SingleChildRenderObjectWidget { @override RenderFractionallySizedOverflowBox createRenderObject(BuildContext context) { - return new RenderFractionallySizedOverflowBox( + return RenderFractionallySizedOverflowBox( alignment: alignment, widthFactor: widthFactor, heightFactor: heightFactor, @@ -2028,9 +2028,9 @@ class FractionallySizedBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new DoubleProperty('widthFactor', widthFactor, defaultValue: null)); - properties.add(new DoubleProperty('heightFactor', heightFactor, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(DoubleProperty('widthFactor', widthFactor, defaultValue: null)); + properties.add(DoubleProperty('heightFactor', heightFactor, defaultValue: null)); } } @@ -2081,7 +2081,7 @@ class LimitedBox extends SingleChildRenderObjectWidget { @override RenderLimitedBox createRenderObject(BuildContext context) { - return new RenderLimitedBox( + return RenderLimitedBox( maxWidth: maxWidth, maxHeight: maxHeight ); @@ -2097,8 +2097,8 @@ class LimitedBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('maxWidth', maxWidth, defaultValue: double.infinity)); - properties.add(new DoubleProperty('maxHeight', maxHeight, defaultValue: double.infinity)); + properties.add(DoubleProperty('maxWidth', maxWidth, defaultValue: double.infinity)); + properties.add(DoubleProperty('maxHeight', maxHeight, defaultValue: double.infinity)); } } @@ -2167,7 +2167,7 @@ class OverflowBox extends SingleChildRenderObjectWidget { @override RenderConstrainedOverflowBox createRenderObject(BuildContext context) { - return new RenderConstrainedOverflowBox( + return RenderConstrainedOverflowBox( alignment: alignment, minWidth: minWidth, maxWidth: maxWidth, @@ -2191,11 +2191,11 @@ class OverflowBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new DoubleProperty('minWidth', minWidth, defaultValue: null)); - properties.add(new DoubleProperty('maxWidth', maxWidth, defaultValue: null)); - properties.add(new DoubleProperty('minHeight', minHeight, defaultValue: null)); - properties.add(new DoubleProperty('maxHeight', maxHeight, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(DoubleProperty('minWidth', minWidth, defaultValue: null)); + properties.add(DoubleProperty('maxWidth', maxWidth, defaultValue: null)); + properties.add(DoubleProperty('minHeight', minHeight, defaultValue: null)); + properties.add(DoubleProperty('maxHeight', maxHeight, defaultValue: null)); } } @@ -2250,7 +2250,7 @@ class SizedOverflowBox extends SingleChildRenderObjectWidget { @override RenderSizedOverflowBox createRenderObject(BuildContext context) { - return new RenderSizedOverflowBox( + return RenderSizedOverflowBox( alignment: alignment, requestedSize: size, textDirection: Directionality.of(context), @@ -2268,8 +2268,8 @@ class SizedOverflowBox extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new DiagnosticsProperty('size', size, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(DiagnosticsProperty('size', size, defaultValue: null)); } } @@ -2307,7 +2307,7 @@ class Offstage extends SingleChildRenderObjectWidget { final bool offstage; @override - RenderOffstage createRenderObject(BuildContext context) => new RenderOffstage(offstage: offstage); + RenderOffstage createRenderObject(BuildContext context) => RenderOffstage(offstage: offstage); @override void updateRenderObject(BuildContext context, RenderOffstage renderObject) { @@ -2317,11 +2317,11 @@ class Offstage extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('offstage', offstage)); + properties.add(DiagnosticsProperty('offstage', offstage)); } @override - _OffstageElement createElement() => new _OffstageElement(this); + _OffstageElement createElement() => _OffstageElement(this); } class _OffstageElement extends SingleChildRenderObjectElement { @@ -2391,7 +2391,7 @@ class AspectRatio extends SingleChildRenderObjectWidget { final double aspectRatio; @override - RenderAspectRatio createRenderObject(BuildContext context) => new RenderAspectRatio(aspectRatio: aspectRatio); + RenderAspectRatio createRenderObject(BuildContext context) => RenderAspectRatio(aspectRatio: aspectRatio); @override void updateRenderObject(BuildContext context, RenderAspectRatio renderObject) { @@ -2401,7 +2401,7 @@ class AspectRatio extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('aspectRatio', aspectRatio)); + properties.add(DoubleProperty('aspectRatio', aspectRatio)); } } @@ -2439,7 +2439,7 @@ class IntrinsicWidth extends SingleChildRenderObjectWidget { @override RenderIntrinsicWidth createRenderObject(BuildContext context) { - return new RenderIntrinsicWidth(stepWidth: stepWidth, stepHeight: stepHeight); + return RenderIntrinsicWidth(stepWidth: stepWidth, stepHeight: stepHeight); } @override @@ -2471,7 +2471,7 @@ class IntrinsicHeight extends SingleChildRenderObjectWidget { const IntrinsicHeight({ Key key, Widget child }) : super(key: key, child: child); @override - RenderIntrinsicHeight createRenderObject(BuildContext context) => new RenderIntrinsicHeight(); + RenderIntrinsicHeight createRenderObject(BuildContext context) => RenderIntrinsicHeight(); } /// A widget that positions its child according to the child's baseline. @@ -2511,7 +2511,7 @@ class Baseline extends SingleChildRenderObjectWidget { @override RenderBaseline createRenderObject(BuildContext context) { - return new RenderBaseline(baseline: baseline, baselineType: baselineType); + return RenderBaseline(baseline: baseline, baselineType: baselineType); } @override @@ -2555,7 +2555,7 @@ class SliverToBoxAdapter extends SingleChildRenderObjectWidget { }) : super(key: key, child: child); @override - RenderSliverToBoxAdapter createRenderObject(BuildContext context) => new RenderSliverToBoxAdapter(); + RenderSliverToBoxAdapter createRenderObject(BuildContext context) => RenderSliverToBoxAdapter(); } /// A sliver that applies padding on each side of another sliver. @@ -2590,7 +2590,7 @@ class SliverPadding extends SingleChildRenderObjectWidget { @override RenderSliverPadding createRenderObject(BuildContext context) { - return new RenderSliverPadding( + return RenderSliverPadding( padding: padding, textDirection: Directionality.of(context), ); @@ -2606,7 +2606,7 @@ class SliverPadding extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('padding', padding)); + properties.add(DiagnosticsProperty('padding', padding)); } } @@ -2703,7 +2703,7 @@ class ListBody extends MultiChildRenderObjectWidget { @override RenderListBody createRenderObject(BuildContext context) { - return new RenderListBody(axisDirection: _getDirection(context)); + return RenderListBody(axisDirection: _getDirection(context)); } @override @@ -2810,7 +2810,7 @@ class Stack extends MultiChildRenderObjectWidget { @override RenderStack createRenderObject(BuildContext context) { - return new RenderStack( + return RenderStack( alignment: alignment, textDirection: textDirection ?? Directionality.of(context), fit: fit, @@ -2830,10 +2830,10 @@ class Stack extends MultiChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new EnumProperty('fit', fit)); - properties.add(new EnumProperty('overflow', overflow)); + properties.add(DiagnosticsProperty('alignment', alignment)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('fit', fit)); + properties.add(EnumProperty('overflow', overflow)); } } @@ -2866,7 +2866,7 @@ class IndexedStack extends Stack { @override RenderIndexedStack createRenderObject(BuildContext context) { - return new RenderIndexedStack( + return RenderIndexedStack( index: index, alignment: alignment, textDirection: textDirection ?? Directionality.of(context), @@ -3025,7 +3025,7 @@ class Positioned extends ParentDataWidget { right = end; break; } - return new Positioned( + return Positioned( key: key, left: left, top: top, @@ -3137,12 +3137,12 @@ class Positioned extends ParentDataWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('left', left, defaultValue: null)); - properties.add(new DoubleProperty('top', top, defaultValue: null)); - properties.add(new DoubleProperty('right', right, defaultValue: null)); - properties.add(new DoubleProperty('bottom', bottom, defaultValue: null)); - properties.add(new DoubleProperty('width', width, defaultValue: null)); - properties.add(new DoubleProperty('height', height, defaultValue: null)); + properties.add(DoubleProperty('left', left, defaultValue: null)); + properties.add(DoubleProperty('top', top, defaultValue: null)); + properties.add(DoubleProperty('right', right, defaultValue: null)); + properties.add(DoubleProperty('bottom', bottom, defaultValue: null)); + properties.add(DoubleProperty('width', width, defaultValue: null)); + properties.add(DoubleProperty('height', height, defaultValue: null)); } } @@ -3243,7 +3243,7 @@ class PositionedDirectional extends StatelessWidget { @override Widget build(BuildContext context) { - return new Positioned.directional( + return Positioned.directional( textDirection: Directionality.of(context), start: start, top: top, @@ -3471,7 +3471,7 @@ class Flex extends MultiChildRenderObjectWidget { @override RenderFlex createRenderObject(BuildContext context) { - return new RenderFlex( + return RenderFlex( direction: direction, mainAxisAlignment: mainAxisAlignment, mainAxisSize: mainAxisSize, @@ -3497,13 +3497,13 @@ class Flex extends MultiChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('direction', direction)); - properties.add(new EnumProperty('mainAxisAlignment', mainAxisAlignment)); - properties.add(new EnumProperty('mainAxisSize', mainAxisSize, defaultValue: MainAxisSize.max)); - properties.add(new EnumProperty('crossAxisAlignment', crossAxisAlignment)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new EnumProperty('verticalDirection', verticalDirection, defaultValue: VerticalDirection.down)); - properties.add(new EnumProperty('textBaseline', textBaseline, defaultValue: null)); + properties.add(EnumProperty('direction', direction)); + properties.add(EnumProperty('mainAxisAlignment', mainAxisAlignment)); + properties.add(EnumProperty('mainAxisSize', mainAxisSize, defaultValue: MainAxisSize.max)); + properties.add(EnumProperty('crossAxisAlignment', crossAxisAlignment)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('verticalDirection', verticalDirection, defaultValue: VerticalDirection.down)); + properties.add(EnumProperty('textBaseline', textBaseline, defaultValue: null)); } } @@ -3954,7 +3954,7 @@ class Flexible extends ParentDataWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new IntProperty('flex', flex)); + properties.add(IntProperty('flex', flex)); } } @@ -4192,7 +4192,7 @@ class Wrap extends MultiChildRenderObjectWidget { @override RenderWrap createRenderObject(BuildContext context) { - return new RenderWrap( + return RenderWrap( direction: direction, alignment: alignment, spacing: spacing, @@ -4220,14 +4220,14 @@ class Wrap extends MultiChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('direction', direction)); - properties.add(new EnumProperty('alignment', alignment)); - properties.add(new DoubleProperty('spacing', spacing)); - properties.add(new EnumProperty('runAlignment', runAlignment)); - properties.add(new DoubleProperty('runSpacing', runSpacing)); - properties.add(new DoubleProperty('crossAxisAlignment', runSpacing)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new EnumProperty('verticalDirection', verticalDirection, defaultValue: VerticalDirection.down)); + properties.add(EnumProperty('direction', direction)); + properties.add(EnumProperty('alignment', alignment)); + properties.add(DoubleProperty('spacing', spacing)); + properties.add(EnumProperty('runAlignment', runAlignment)); + properties.add(DoubleProperty('runSpacing', runSpacing)); + properties.add(DoubleProperty('crossAxisAlignment', runSpacing)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(EnumProperty('verticalDirection', verticalDirection, defaultValue: VerticalDirection.down)); } } @@ -4298,7 +4298,7 @@ class Flow extends MultiChildRenderObjectWidget { final FlowDelegate delegate; @override - RenderFlow createRenderObject(BuildContext context) => new RenderFlow(delegate: delegate); + RenderFlow createRenderObject(BuildContext context) => RenderFlow(delegate: delegate); @override void updateRenderObject(BuildContext context, RenderFlow renderObject) { @@ -4432,7 +4432,7 @@ class RichText extends LeafRenderObjectWidget { @override RenderParagraph createRenderObject(BuildContext context) { assert(textDirection != null || debugCheckHasDirectionality(context)); - return new RenderParagraph(text, + return RenderParagraph(text, textAlign: textAlign, textDirection: textDirection ?? Directionality.of(context), softWrap: softWrap, @@ -4460,13 +4460,13 @@ class RichText extends LeafRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('textAlign', textAlign, defaultValue: TextAlign.start)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); - properties.add(new EnumProperty('overflow', overflow, defaultValue: TextOverflow.clip)); - properties.add(new DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: 1.0)); - properties.add(new IntProperty('maxLines', maxLines, ifNull: 'unlimited')); - properties.add(new StringProperty('text', text.toPlainText())); + properties.add(EnumProperty('textAlign', textAlign, defaultValue: TextAlign.start)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); + properties.add(EnumProperty('overflow', overflow, defaultValue: TextOverflow.clip)); + properties.add(DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: 1.0)); + properties.add(IntProperty('maxLines', maxLines, ifNull: 'unlimited')); + properties.add(StringProperty('text', text.toPlainText())); } } @@ -4598,7 +4598,7 @@ class RawImage extends LeafRenderObjectWidget { @override RenderImage createRenderObject(BuildContext context) { assert((!matchTextDirection && alignment is Alignment) || debugCheckHasDirectionality(context)); - return new RenderImage( + return RenderImage( image: image, width: width, height: height, @@ -4634,17 +4634,17 @@ class RawImage extends LeafRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('image', image)); - properties.add(new DoubleProperty('width', width, defaultValue: null)); - properties.add(new DoubleProperty('height', height, defaultValue: null)); - properties.add(new DoubleProperty('scale', scale, defaultValue: 1.0)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new EnumProperty('colorBlendMode', colorBlendMode, defaultValue: null)); - properties.add(new EnumProperty('fit', fit, defaultValue: null)); - properties.add(new DiagnosticsProperty('alignment', alignment, defaultValue: null)); - properties.add(new EnumProperty('repeat', repeat, defaultValue: ImageRepeat.noRepeat)); - properties.add(new DiagnosticsProperty('centerSlice', centerSlice, defaultValue: null)); - properties.add(new FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction')); + properties.add(DiagnosticsProperty('image', image)); + properties.add(DoubleProperty('width', width, defaultValue: null)); + properties.add(DoubleProperty('height', height, defaultValue: null)); + properties.add(DoubleProperty('scale', scale, defaultValue: 1.0)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(EnumProperty('colorBlendMode', colorBlendMode, defaultValue: null)); + properties.add(EnumProperty('fit', fit, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment, defaultValue: null)); + properties.add(EnumProperty('repeat', repeat, defaultValue: ImageRepeat.noRepeat)); + properties.add(DiagnosticsProperty('centerSlice', centerSlice, defaultValue: null)); + properties.add(FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction')); } } @@ -4745,7 +4745,7 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget { // prevents the widget being used in the widget hierarchy in two different // places, which would cause the RenderBox to get inserted in multiple // places in the RenderObject tree. - super(key: new GlobalObjectKey(renderBox)); + super(key: GlobalObjectKey(renderBox)); /// The render box to place in the widget tree. final RenderBox renderBox; @@ -4812,7 +4812,7 @@ class Listener extends SingleChildRenderObjectWidget { @override RenderPointerListener createRenderObject(BuildContext context) { - return new RenderPointerListener( + return RenderPointerListener( onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, @@ -4843,8 +4843,8 @@ class Listener extends SingleChildRenderObjectWidget { listeners.add('up'); if (onPointerCancel != null) listeners.add('cancel'); - properties.add(new IterableProperty('listeners', listeners, ifEmpty: '')); - properties.add(new EnumProperty('behavior', behavior)); + properties.add(IterableProperty('listeners', listeners, ifEmpty: '')); + properties.add(EnumProperty('behavior', behavior)); } } @@ -4909,8 +4909,8 @@ class RepaintBoundary extends SingleChildRenderObjectWidget { /// (if the child has a non-null key) or from the given `childIndex`. factory RepaintBoundary.wrap(Widget child, int childIndex) { assert(child != null); - final Key key = child.key != null ? new ValueKey(child.key) : new ValueKey(childIndex); - return new RepaintBoundary(key: key, child: child); + final Key key = child.key != null ? ValueKey(child.key) : ValueKey(childIndex); + return RepaintBoundary(key: key, child: child); } /// Wraps each of the given children in [RepaintBoundary]s. @@ -4919,14 +4919,14 @@ class RepaintBoundary extends SingleChildRenderObjectWidget { /// child's key (if the wrapped child has a non-null key) or from the wrapped /// child's index in the list. static List wrapAll(List widgets) { - final List result = new List(widgets.length); + final List result = List(widgets.length); for (int i = 0; i < result.length; ++i) - result[i] = new RepaintBoundary.wrap(widgets[i], i); + result[i] = RepaintBoundary.wrap(widgets[i], i); return result; } @override - RenderRepaintBoundary createRenderObject(BuildContext context) => new RenderRepaintBoundary(); + RenderRepaintBoundary createRenderObject(BuildContext context) => RenderRepaintBoundary(); } /// A widget that is invisible during hit testing. @@ -4972,7 +4972,7 @@ class IgnorePointer extends SingleChildRenderObjectWidget { @override RenderIgnorePointer createRenderObject(BuildContext context) { - return new RenderIgnorePointer( + return RenderIgnorePointer( ignoring: ignoring, ignoringSemantics: ignoringSemantics ); @@ -4988,8 +4988,8 @@ class IgnorePointer extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('ignoring', ignoring)); - properties.add(new DiagnosticsProperty('ignoringSemantics', ignoringSemantics, defaultValue: null)); + properties.add(DiagnosticsProperty('ignoring', ignoring)); + properties.add(DiagnosticsProperty('ignoringSemantics', ignoringSemantics, defaultValue: null)); } } @@ -5034,7 +5034,7 @@ class AbsorbPointer extends SingleChildRenderObjectWidget { @override RenderAbsorbPointer createRenderObject(BuildContext context) { - return new RenderAbsorbPointer( + return RenderAbsorbPointer( absorbing: absorbing, ignoringSemantics: ignoringSemantics, ); @@ -5050,8 +5050,8 @@ class AbsorbPointer extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('absorbing', absorbing)); - properties.add(new DiagnosticsProperty('ignoringSemantics', ignoringSemantics, defaultValue: null)); + properties.add(DiagnosticsProperty('absorbing', absorbing)); + properties.add(DiagnosticsProperty('ignoringSemantics', ignoringSemantics, defaultValue: null)); } } @@ -5080,7 +5080,7 @@ class MetaData extends SingleChildRenderObjectWidget { @override RenderMetaData createRenderObject(BuildContext context) { - return new RenderMetaData( + return RenderMetaData( metaData: metaData, behavior: behavior ); @@ -5096,8 +5096,8 @@ class MetaData extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('behavior', behavior)); - properties.add(new DiagnosticsProperty('metaData', metaData)); + properties.add(EnumProperty('behavior', behavior)); + properties.add(DiagnosticsProperty('metaData', metaData)); } } @@ -5189,7 +5189,7 @@ class Semantics extends SingleChildRenderObjectWidget { container: container, explicitChildNodes: explicitChildNodes, excludeSemantics: excludeSemantics, - properties: new SemanticsProperties( + properties: SemanticsProperties( enabled: enabled, checked: checked, toggled: toggled, @@ -5231,7 +5231,7 @@ class Semantics extends SingleChildRenderObjectWidget { onSetSelection: onSetSelection, customSemanticsActions: customSemanticsActions, hintOverrides: onTapHint != null || onLongPressHint != null ? - new SemanticsHintOverrides( + SemanticsHintOverrides( onTapHint: onTapHint, onLongPressHint: onLongPressHint, ) : null, @@ -5294,7 +5294,7 @@ class Semantics extends SingleChildRenderObjectWidget { @override RenderSemanticsAnnotations createRenderObject(BuildContext context) { - return new RenderSemanticsAnnotations( + return RenderSemanticsAnnotations( container: container, explicitChildNodes: explicitChildNodes, excludeSemantics: excludeSemantics, @@ -5410,8 +5410,8 @@ class Semantics extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('container', container)); - properties.add(new DiagnosticsProperty('properties', this.properties)); + properties.add(DiagnosticsProperty('container', container)); + properties.add(DiagnosticsProperty('properties', this.properties)); this.properties.debugFillProperties(properties); } } @@ -5440,7 +5440,7 @@ class MergeSemantics extends SingleChildRenderObjectWidget { const MergeSemantics({ Key key, Widget child }) : super(key: key, child: child); @override - RenderMergeSemantics createRenderObject(BuildContext context) => new RenderMergeSemantics(); + RenderMergeSemantics createRenderObject(BuildContext context) => RenderMergeSemantics(); } /// A widget that drops the semantics of all widget that were painted before it @@ -5465,7 +5465,7 @@ class BlockSemantics extends SingleChildRenderObjectWidget { final bool blocking; @override - RenderBlockSemantics createRenderObject(BuildContext context) => new RenderBlockSemantics(blocking: blocking); + RenderBlockSemantics createRenderObject(BuildContext context) => RenderBlockSemantics(blocking: blocking); @override void updateRenderObject(BuildContext context, RenderBlockSemantics renderObject) { @@ -5475,7 +5475,7 @@ class BlockSemantics extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('blocking', blocking)); + properties.add(DiagnosticsProperty('blocking', blocking)); } } @@ -5505,7 +5505,7 @@ class ExcludeSemantics extends SingleChildRenderObjectWidget { final bool excluding; @override - RenderExcludeSemantics createRenderObject(BuildContext context) => new RenderExcludeSemantics(excluding: excluding); + RenderExcludeSemantics createRenderObject(BuildContext context) => RenderExcludeSemantics(excluding: excluding); @override void updateRenderObject(BuildContext context, RenderExcludeSemantics renderObject) { @@ -5515,7 +5515,7 @@ class ExcludeSemantics extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('excluding', excluding)); + properties.add(DiagnosticsProperty('excluding', excluding)); } } @@ -5537,8 +5537,8 @@ class KeyedSubtree extends StatelessWidget { /// Creates a KeyedSubtree for child with a key that's based on the child's existing key or childIndex. factory KeyedSubtree.wrap(Widget child, int childIndex) { - final Key key = child.key != null ? new ValueKey(child.key) : new ValueKey(childIndex); - return new KeyedSubtree(key: key, child: child); + final Key key = child.key != null ? ValueKey(child.key) : ValueKey(childIndex); + return KeyedSubtree(key: key, child: child); } /// Wrap each item in a KeyedSubtree whose key is based on the item's existing key or @@ -5550,7 +5550,7 @@ class KeyedSubtree extends StatelessWidget { final List itemsWithUniqueKeys = []; int itemIndex = baseIndex; for (Widget item in items) { - itemsWithUniqueKeys.add(new KeyedSubtree.wrap(item, itemIndex)); + itemsWithUniqueKeys.add(KeyedSubtree.wrap(item, itemIndex)); itemIndex += 1; } @@ -5620,7 +5620,7 @@ class StatefulBuilder extends StatefulWidget { final StatefulWidgetBuilder builder; @override - _StatefulBuilderState createState() => new _StatefulBuilderState(); + _StatefulBuilderState createState() => _StatefulBuilderState(); } class _StatefulBuilderState extends State { diff --git a/packages/flutter/lib/src/widgets/binding.dart b/packages/flutter/lib/src/widgets/binding.dart index bcfe883dfe..b1458bdfa3 100644 --- a/packages/flutter/lib/src/widgets/binding.dart +++ b/packages/flutter/lib/src/widgets/binding.dart @@ -88,7 +88,7 @@ abstract class WidgetsBindingObserver { /// /// This method exposes the `popRoute` notification from /// [SystemChannels.navigation]. - Future didPopRoute() => new Future.value(false); + Future didPopRoute() => Future.value(false); /// Called when the host tells the app to push a new route onto the /// navigator. @@ -99,7 +99,7 @@ abstract class WidgetsBindingObserver { /// /// This method exposes the `pushRoute` notification from /// [SystemChannels.navigation]. - Future didPushRoute(String route) => new Future.value(false); + Future didPushRoute(String route) => Future.value(false); /// Called when the application's dimensions change. For example, /// when a phone is rotated. @@ -273,10 +273,10 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture registerBoolServiceExtension( name: 'showPerformanceOverlay', - getter: () => new Future.value(WidgetsApp.showPerformanceOverlayOverride), + getter: () => Future.value(WidgetsApp.showPerformanceOverlayOverride), setter: (bool value) { if (WidgetsApp.showPerformanceOverlayOverride == value) - return new Future.value(); + return Future.value(); WidgetsApp.showPerformanceOverlayOverride = value; return _forceRebuild(); } @@ -284,10 +284,10 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture registerBoolServiceExtension( name: 'debugAllowBanner', - getter: () => new Future.value(WidgetsApp.debugAllowBannerOverride), + getter: () => Future.value(WidgetsApp.debugAllowBannerOverride), setter: (bool value) { if (WidgetsApp.debugAllowBannerOverride == value) - return new Future.value(); + return Future.value(); WidgetsApp.debugAllowBannerOverride = value; return _forceRebuild(); } @@ -301,7 +301,7 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture getter: () async => WidgetsApp.debugShowWidgetInspectorOverride, setter: (bool value) { if (WidgetsApp.debugShowWidgetInspectorOverride == value) - return new Future.value(); + return Future.value(); WidgetsApp.debugShowWidgetInspectorOverride = value; return _forceRebuild(); } @@ -317,13 +317,13 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture buildOwner.reassemble(renderViewElement); return endOfFrame; } - return new Future.value(); + return Future.value(); } /// The [BuildOwner] in charge of executing the build pipeline for the /// widget tree rooted at this binding. BuildOwner get buildOwner => _buildOwner; - final BuildOwner _buildOwner = new BuildOwner(); + final BuildOwner _buildOwner = BuildOwner(); /// The object in charge of the focus tree. /// @@ -438,7 +438,7 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture /// [SystemChannels.navigation]. @protected Future handlePopRoute() async { - for (WidgetsBindingObserver observer in new List.from(_observers)) { + for (WidgetsBindingObserver observer in List.from(_observers)) { if (await observer.didPopRoute()) return; } @@ -458,7 +458,7 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture @protected @mustCallSuper Future handlePushRoute(String route) async { - for (WidgetsBindingObserver observer in new List.from(_observers)) { + for (WidgetsBindingObserver observer in List.from(_observers)) { if (await observer.didPushRoute(route)) return; } @@ -471,7 +471,7 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture case 'pushRoute': return handlePushRoute(methodCall.arguments); } - return new Future.value(); + return Future.value(); } @override @@ -548,7 +548,7 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture // should not trigger a new frame. assert(() { if (debugBuildingDirtyElements) { - throw new FlutterError( + throw FlutterError( 'Build scheduled during frame.\n' 'While the widget tree was being built, laid out, and painted, ' 'a new frame was scheduled to rebuild the widget tree. ' @@ -685,7 +685,7 @@ abstract class WidgetsBinding extends BindingBase with SchedulerBinding, Gesture /// /// See also [RenderObjectToWidgetAdapter.attachToRenderTree]. void attachRootWidget(Widget rootWidget) { - _renderViewElement = new RenderObjectToWidgetAdapter( + _renderViewElement = RenderObjectToWidgetAdapter( container: renderView, debugShortDescription: '[root]', child: rootWidget @@ -761,7 +761,7 @@ class RenderObjectToWidgetAdapter extends RenderObjectWi this.child, this.container, this.debugShortDescription - }) : super(key: new GlobalObjectKey(container)); + }) : super(key: GlobalObjectKey(container)); /// The widget below this widget in the tree. /// @@ -775,7 +775,7 @@ class RenderObjectToWidgetAdapter extends RenderObjectWi final String debugShortDescription; @override - RenderObjectToWidgetElement createElement() => new RenderObjectToWidgetElement(this); + RenderObjectToWidgetElement createElement() => RenderObjectToWidgetElement(this); @override RenderObjectWithChildMixin createRenderObject(BuildContext context) => container; @@ -884,7 +884,7 @@ class RenderObjectToWidgetElement extends RootRenderObje _child = updateChild(_child, widget.child, _rootChildSlot); assert(_child != null); } catch (exception, stack) { - final FlutterErrorDetails details = new FlutterErrorDetails( + final FlutterErrorDetails details = FlutterErrorDetails( exception: exception, stack: stack, library: 'widgets library', @@ -935,7 +935,7 @@ class WidgetsFlutterBinding extends BindingBase with GestureBinding, ServicesBin /// [WidgetsFlutterBinding]. static WidgetsBinding ensureInitialized() { if (WidgetsBinding.instance == null) - new WidgetsFlutterBinding(); + WidgetsFlutterBinding(); return WidgetsBinding.instance; } } diff --git a/packages/flutter/lib/src/widgets/container.dart b/packages/flutter/lib/src/widgets/container.dart index 83f71a4fc6..f3b2a5a1ff 100644 --- a/packages/flutter/lib/src/widgets/container.dart +++ b/packages/flutter/lib/src/widgets/container.dart @@ -70,7 +70,7 @@ class DecoratedBox extends SingleChildRenderObjectWidget { @override RenderDecoratedBox createRenderObject(BuildContext context) { - return new RenderDecoratedBox( + return RenderDecoratedBox( decoration: decoration, position: position, configuration: createLocalImageConfiguration(context), @@ -101,8 +101,8 @@ class DecoratedBox extends SingleChildRenderObjectWidget { } else { label = 'decoration'; } - properties.add(new EnumProperty('position', position, level: position != null ? DiagnosticLevel.hidden : DiagnosticLevel.info)); - properties.add(new DiagnosticsProperty( + properties.add(EnumProperty('position', position, level: position != null ? DiagnosticLevel.hidden : DiagnosticLevel.info)); + properties.add(DiagnosticsProperty( label, decoration, ifNull: 'no decoration', @@ -260,11 +260,11 @@ class Container extends StatelessWidget { 'Cannot provide both a color and a decoration\n' 'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".' ), - decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null), + decoration = decoration ?? (color != null ? BoxDecoration(color: color) : null), constraints = (width != null || height != null) ? constraints?.tighten(width: width, height: height) - ?? new BoxConstraints.tightFor(width: width, height: height) + ?? BoxConstraints.tightFor(width: width, height: height) : constraints, super(key: key); @@ -339,25 +339,25 @@ class Container extends StatelessWidget { Widget current = child; if (child == null && (constraints == null || !constraints.isTight)) { - current = new LimitedBox( + current = LimitedBox( maxWidth: 0.0, maxHeight: 0.0, - child: new ConstrainedBox(constraints: const BoxConstraints.expand()) + child: ConstrainedBox(constraints: const BoxConstraints.expand()) ); } if (alignment != null) - current = new Align(alignment: alignment, child: current); + current = Align(alignment: alignment, child: current); final EdgeInsetsGeometry effectivePadding = _paddingIncludingDecoration; if (effectivePadding != null) - current = new Padding(padding: effectivePadding, child: current); + current = Padding(padding: effectivePadding, child: current); if (decoration != null) - current = new DecoratedBox(decoration: decoration, child: current); + current = DecoratedBox(decoration: decoration, child: current); if (foregroundDecoration != null) { - current = new DecoratedBox( + current = DecoratedBox( decoration: foregroundDecoration, position: DecorationPosition.foreground, child: current @@ -365,13 +365,13 @@ class Container extends StatelessWidget { } if (constraints != null) - current = new ConstrainedBox(constraints: constraints, child: current); + current = ConstrainedBox(constraints: constraints, child: current); if (margin != null) - current = new Padding(padding: margin, child: current); + current = Padding(padding: margin, child: current); if (transform != null) - current = new Transform(transform: transform, child: current); + current = Transform(transform: transform, child: current); return current; } @@ -379,12 +379,12 @@ class Container extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment, showName: false, defaultValue: null)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); - properties.add(new DiagnosticsProperty('bg', decoration, defaultValue: null)); - properties.add(new DiagnosticsProperty('fg', foregroundDecoration, defaultValue: null)); - properties.add(new DiagnosticsProperty('constraints', constraints, defaultValue: null)); - properties.add(new DiagnosticsProperty('margin', margin, defaultValue: null)); - properties.add(new ObjectFlagProperty.has('transform', transform)); + properties.add(DiagnosticsProperty('alignment', alignment, showName: false, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('bg', decoration, defaultValue: null)); + properties.add(DiagnosticsProperty('fg', foregroundDecoration, defaultValue: null)); + properties.add(DiagnosticsProperty('constraints', constraints, defaultValue: null)); + properties.add(DiagnosticsProperty('margin', margin, defaultValue: null)); + properties.add(ObjectFlagProperty.has('transform', transform)); } } diff --git a/packages/flutter/lib/src/widgets/debug.dart b/packages/flutter/lib/src/widgets/debug.dart index 2616bf1133..6ce2e7be33 100644 --- a/packages/flutter/lib/src/widgets/debug.dart +++ b/packages/flutter/lib/src/widgets/debug.dart @@ -76,7 +76,7 @@ bool debugProfileBuildsEnabled = false; bool debugHighlightDeprecatedWidgets = false; Key _firstNonUniqueKey(Iterable widgets) { - final Set keySet = new HashSet(); + final Set keySet = HashSet(); for (Widget widget in widgets) { assert(widget != null); if (widget.key == null) @@ -105,7 +105,7 @@ bool debugChildrenHaveDuplicateKeys(Widget parent, Iterable children) { assert(() { final Key nonUniqueKey = _firstNonUniqueKey(children); if (nonUniqueKey != null) { - throw new FlutterError( + throw FlutterError( 'Duplicate keys found.\n' 'If multiple keyed nodes exist as children of another node, they must have unique keys.\n' '$parent has multiple children with key $nonUniqueKey.' @@ -132,7 +132,7 @@ bool debugItemsHaveDuplicateKeys(Iterable items) { assert(() { final Key nonUniqueKey = _firstNonUniqueKey(items); if (nonUniqueKey != null) - throw new FlutterError('Duplicate key found: $nonUniqueKey.'); + throw FlutterError('Duplicate key found: $nonUniqueKey.'); return true; }()); return false; @@ -154,7 +154,7 @@ bool debugCheckHasTable(BuildContext context) { assert(() { if (context.widget is! Table && context.ancestorWidgetOfExactType(Table) == null) { final Element element = context; - throw new FlutterError( + throw FlutterError( 'No Table widget found.\n' '${context.widget.runtimeType} widgets require a Table widget ancestor.\n' 'The specific widget that could not find a Table ancestor was:\n' @@ -185,7 +185,7 @@ bool debugCheckHasMediaQuery(BuildContext context) { assert(() { if (context.widget is! MediaQuery && context.ancestorWidgetOfExactType(MediaQuery) == null) { final Element element = context; - throw new FlutterError( + throw FlutterError( 'No MediaQuery widget found.\n' '${context.widget.runtimeType} widgets require a MediaQuery widget ancestor.\n' 'The specific widget that could not find a MediaQuery ancestor was:\n' @@ -218,7 +218,7 @@ bool debugCheckHasDirectionality(BuildContext context) { assert(() { if (context.widget is! Directionality && context.ancestorWidgetOfExactType(Directionality) == null) { final Element element = context; - throw new FlutterError( + throw FlutterError( 'No Directionality widget found.\n' '${context.widget.runtimeType} widgets require a Directionality widget ancestor.\n' 'The specific widget that could not find a Directionality ancestor was:\n' @@ -247,7 +247,7 @@ bool debugCheckHasDirectionality(BuildContext context) { void debugWidgetBuilderValue(Widget widget, Widget built) { assert(() { if (built == null) { - throw new FlutterError( + throw FlutterError( 'A build function returned null.\n' 'The offending widget is: $widget\n' 'Build functions must never return null. ' @@ -274,7 +274,7 @@ bool debugAssertAllWidgetVarsUnset(String reason) { debugPrintGlobalKeyedWidgetLifecycle || debugProfileBuildsEnabled || debugHighlightDeprecatedWidgets) { - throw new FlutterError(reason); + throw FlutterError(reason); } return true; }()); diff --git a/packages/flutter/lib/src/widgets/dismissible.dart b/packages/flutter/lib/src/widgets/dismissible.dart index e0d2ebfeeb..09a9fc5d50 100644 --- a/packages/flutter/lib/src/widgets/dismissible.dart +++ b/packages/flutter/lib/src/widgets/dismissible.dart @@ -143,7 +143,7 @@ class Dismissible extends StatefulWidget { final double crossAxisEndOffset; @override - _DismissibleState createState() => new _DismissibleState(); + _DismissibleState createState() => _DismissibleState(); } class _DismissibleClipper extends CustomClipper { @@ -164,13 +164,13 @@ class _DismissibleClipper extends CustomClipper { case Axis.horizontal: final double offset = moveAnimation.value.dx * size.width; if (offset < 0) - return new Rect.fromLTRB(size.width + offset, 0.0, size.width, size.height); - return new Rect.fromLTRB(0.0, 0.0, offset, size.height); + return Rect.fromLTRB(size.width + offset, 0.0, size.width, size.height); + return Rect.fromLTRB(0.0, 0.0, offset, size.height); case Axis.vertical: final double offset = moveAnimation.value.dy * size.height; if (offset < 0) - return new Rect.fromLTRB(0.0, size.height + offset, size.width, size.height); - return new Rect.fromLTRB(0.0, 0.0, size.width, offset); + return Rect.fromLTRB(0.0, size.height + offset, size.width, size.height); + return Rect.fromLTRB(0.0, 0.0, size.width, offset); } return null; } @@ -191,7 +191,7 @@ class _DismissibleState extends State with TickerProviderStateMixin @override void initState() { super.initState(); - _moveController = new AnimationController(duration: widget.movementDuration, vsync: this) + _moveController = AnimationController(duration: widget.movementDuration, vsync: this) ..addStatusListener(_handleDismissStatusChanged); _updateMoveAnimation(); } @@ -323,11 +323,11 @@ class _DismissibleState extends State with TickerProviderStateMixin void _updateMoveAnimation() { final double end = _dragExtent.sign; - _moveAnimation = new Tween( + _moveAnimation = Tween( begin: Offset.zero, end: _directionIsXAxis - ? new Offset(end, widget.crossAxisEndOffset) - : new Offset(widget.crossAxisEndOffset, end), + ? Offset(end, widget.crossAxisEndOffset) + : Offset(widget.crossAxisEndOffset, end), ).animate(_moveController); } @@ -418,16 +418,16 @@ class _DismissibleState extends State with TickerProviderStateMixin widget.onDismissed(direction); } } else { - _resizeController = new AnimationController(duration: widget.resizeDuration, vsync: this) + _resizeController = AnimationController(duration: widget.resizeDuration, vsync: this) ..addListener(_handleResizeProgressChanged) ..addStatusListener((AnimationStatus status) => updateKeepAlive()); _resizeController.forward(); setState(() { _sizePriorToCollapse = context.size; - _resizeAnimation = new Tween( + _resizeAnimation = Tween( begin: 1.0, end: 0.0 - ).animate(new CurvedAnimation( + ).animate(CurvedAnimation( parent: _resizeController, curve: _kResizeTimeCurve )); @@ -466,7 +466,7 @@ class _DismissibleState extends State with TickerProviderStateMixin assert(() { if (_resizeAnimation.status != AnimationStatus.forward) { assert(_resizeAnimation.status == AnimationStatus.completed); - throw new FlutterError( + throw FlutterError( 'A dismissed Dismissible widget is still part of the tree.\n' 'Make sure to implement the onDismissed handler and to immediately remove the Dismissible\n' 'widget from the application once that handler has fired.' @@ -475,10 +475,10 @@ class _DismissibleState extends State with TickerProviderStateMixin return true; }()); - return new SizeTransition( + return SizeTransition( sizeFactor: _resizeAnimation, axis: _directionIsXAxis ? Axis.vertical : Axis.horizontal, - child: new SizedBox( + child: SizedBox( width: _sizePriorToCollapse.width, height: _sizePriorToCollapse.height, child: background @@ -486,7 +486,7 @@ class _DismissibleState extends State with TickerProviderStateMixin ); } - Widget content = new SlideTransition( + Widget content = SlideTransition( position: _moveAnimation, child: widget.child ); @@ -495,9 +495,9 @@ class _DismissibleState extends State with TickerProviderStateMixin final List children = []; if (!_moveAnimation.isDismissed) { - children.add(new Positioned.fill( - child: new ClipRect( - clipper: new _DismissibleClipper( + children.add(Positioned.fill( + child: ClipRect( + clipper: _DismissibleClipper( axis: _directionIsXAxis ? Axis.horizontal : Axis.vertical, moveAnimation: _moveAnimation, ), @@ -507,11 +507,11 @@ class _DismissibleState extends State with TickerProviderStateMixin } children.add(content); - content = new Stack(children: children); + content = Stack(children: children); } // We are not resizing but we may be being dragging in widget.direction. - return new GestureDetector( + return GestureDetector( onHorizontalDragStart: _directionIsXAxis ? _handleDragStart : null, onHorizontalDragUpdate: _directionIsXAxis ? _handleDragUpdate : null, onHorizontalDragEnd: _directionIsXAxis ? _handleDragEnd : null, diff --git a/packages/flutter/lib/src/widgets/drag_target.dart b/packages/flutter/lib/src/widgets/drag_target.dart index f2fbefc73e..329114b385 100644 --- a/packages/flutter/lib/src/widgets/drag_target.dart +++ b/packages/flutter/lib/src/widgets/drag_target.dart @@ -237,15 +237,15 @@ class Draggable extends StatefulWidget { MultiDragGestureRecognizer createRecognizer(GestureMultiDragStartCallback onStart) { switch (affinity) { case Axis.horizontal: - return new HorizontalMultiDragGestureRecognizer()..onStart = onStart; + return HorizontalMultiDragGestureRecognizer()..onStart = onStart; case Axis.vertical: - return new VerticalMultiDragGestureRecognizer()..onStart = onStart; + return VerticalMultiDragGestureRecognizer()..onStart = onStart; } - return new ImmediateMultiDragGestureRecognizer()..onStart = onStart; + return ImmediateMultiDragGestureRecognizer()..onStart = onStart; } @override - _DraggableState createState() => new _DraggableState(); + _DraggableState createState() => _DraggableState(); } /// Makes its child draggable starting from long press. @@ -290,7 +290,7 @@ class LongPressDraggable extends Draggable { @override DelayedMultiDragGestureRecognizer createRecognizer(GestureMultiDragStartCallback onStart) { - return new DelayedMultiDragGestureRecognizer() + return DelayedMultiDragGestureRecognizer() ..onStart = (Offset position) { final Drag result = onStart(position); if (result != null && hapticFeedbackOnStart) @@ -354,7 +354,7 @@ class _DraggableState extends State> { setState(() { _activeCount += 1; }); - final _DragAvatar avatar = new _DragAvatar( + final _DragAvatar avatar = _DragAvatar( overlayState: Overlay.of(context, debugRequiredFor: widget), data: widget.data, axis: widget.axis, @@ -389,7 +389,7 @@ class _DraggableState extends State> { final bool canDrag = widget.maxSimultaneousDrags == null || _activeCount < widget.maxSimultaneousDrags; final bool showChild = _activeCount == 0 || widget.childWhenDragging == null; - return new Listener( + return Listener( onPointerDown: canDrag ? _routePointer : null, child: showChild ? widget.child : widget.childWhenDragging ); @@ -442,7 +442,7 @@ class DragTarget extends StatefulWidget { final DragTargetLeave onLeave; @override - _DragTargetState createState() => new _DragTargetState(); + _DragTargetState createState() => _DragTargetState(); } List _mapAvatarsToData(List<_DragAvatar> avatars) { @@ -492,7 +492,7 @@ class _DragTargetState extends State> { @override Widget build(BuildContext context) { assert(widget.builder != null); - return new MetaData( + return MetaData( metaData: this, behavior: HitTestBehavior.translucent, child: widget.builder(context, _mapAvatarsToData(_candidateAvatars), _mapAvatarsToData(_rejectedAvatars)) @@ -522,7 +522,7 @@ class _DragAvatar extends Drag { assert(ignoringFeedbackSemantics != null), assert(dragStartPoint != null), assert(feedbackOffset != null) { - _entry = new OverlayEntry(builder: _build); + _entry = OverlayEntry(builder: _build); overlayState.insert(_entry); _position = initialPosition; updateDrag(initialPosition); @@ -563,7 +563,7 @@ class _DragAvatar extends Drag { void updateDrag(Offset globalPosition) { _lastOffset = globalPosition - dragStartPoint; _entry.markNeedsBuild(); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); WidgetsBinding.instance.hitTest(result, globalPosition + feedbackOffset); final List<_DragTargetState> targets = _getDragTargets(result.path).toList(); @@ -638,10 +638,10 @@ class _DragAvatar extends Drag { Widget _build(BuildContext context) { final RenderBox box = overlayState.context.findRenderObject(); final Offset overlayTopLeft = box.localToGlobal(Offset.zero); - return new Positioned( + return Positioned( left: _lastOffset.dx - overlayTopLeft.dx, top: _lastOffset.dy - overlayTopLeft.dy, - child: new IgnorePointer( + child: IgnorePointer( child: feedback, ignoringSemantics: ignoringFeedbackSemantics, ) @@ -652,7 +652,7 @@ class _DragAvatar extends Drag { if (axis == null) { return velocity; } - return new Velocity( + return Velocity( pixelsPerSecond: _restrictAxis(velocity.pixelsPerSecond), ); } @@ -662,8 +662,8 @@ class _DragAvatar extends Drag { return offset; } if (axis == Axis.horizontal) { - return new Offset(offset.dx, 0.0); + return Offset(offset.dx, 0.0); } - return new Offset(0.0, offset.dy); + return Offset(0.0, offset.dy); } } diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index cfb313fe49..0fdb6980dc 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -62,7 +62,7 @@ class TextEditingController extends ValueNotifier { /// This constructor treats a null [text] argument as if it were the empty /// string. TextEditingController({ String text }) - : super(text == null ? TextEditingValue.empty : new TextEditingValue(text: text)); + : super(text == null ? TextEditingValue.empty : TextEditingValue(text: text)); /// Creates a controller for an editable text field from an initial [TextEditingValue]. /// @@ -94,7 +94,7 @@ class TextEditingController extends ValueNotifier { /// actions, not during the build, layout, or paint phases. set selection(TextSelection newSelection) { if (newSelection.start > text.length || newSelection.end > text.length) - throw new FlutterError('invalid text selection: $newSelection'); + throw FlutterError('invalid text selection: $newSelection'); value = value.copyWith(selection: newSelection, composing: TextRange.empty); } @@ -406,37 +406,37 @@ class EditableText extends StatefulWidget { static bool debugDeterministicCursor = false; @override - EditableTextState createState() => new EditableTextState(); + EditableTextState createState() => EditableTextState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('controller', controller)); - properties.add(new DiagnosticsProperty('focusNode', focusNode)); - properties.add(new DiagnosticsProperty('obscureText', obscureText, defaultValue: false)); - properties.add(new DiagnosticsProperty('autocorrect', autocorrect, defaultValue: true)); + properties.add(DiagnosticsProperty('controller', controller)); + properties.add(DiagnosticsProperty('focusNode', focusNode)); + properties.add(DiagnosticsProperty('obscureText', obscureText, defaultValue: false)); + properties.add(DiagnosticsProperty('autocorrect', autocorrect, defaultValue: true)); style?.debugFillProperties(properties); - properties.add(new EnumProperty('textAlign', textAlign, defaultValue: null)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('locale', locale, defaultValue: null)); - properties.add(new DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: null)); - properties.add(new IntProperty('maxLines', maxLines, defaultValue: 1)); - properties.add(new DiagnosticsProperty('autofocus', autofocus, defaultValue: false)); - properties.add(new DiagnosticsProperty('keyboardType', keyboardType, defaultValue: null)); + properties.add(EnumProperty('textAlign', textAlign, defaultValue: null)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('locale', locale, defaultValue: null)); + properties.add(DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: null)); + properties.add(IntProperty('maxLines', maxLines, defaultValue: 1)); + properties.add(DiagnosticsProperty('autofocus', autofocus, defaultValue: false)); + properties.add(DiagnosticsProperty('keyboardType', keyboardType, defaultValue: null)); } } /// State for a [EditableText]. class EditableTextState extends State with AutomaticKeepAliveClientMixin, WidgetsBindingObserver implements TextInputClient, TextSelectionDelegate { Timer _cursorTimer; - final ValueNotifier _showCursor = new ValueNotifier(false); - final GlobalKey _editableKey = new GlobalKey(); + final ValueNotifier _showCursor = ValueNotifier(false); + final GlobalKey _editableKey = GlobalKey(); TextInputConnection _textInputConnection; TextSelectionOverlay _selectionOverlay; - final ScrollController _scrollController = new ScrollController(); - final LayerLink _layerLink = new LayerLink(); + final ScrollController _scrollController = ScrollController(); + final LayerLink _layerLink = LayerLink(); bool _didAutoFocus = false; @override @@ -593,7 +593,7 @@ class EditableTextState extends State with AutomaticKeepAliveClien final TextEditingValue localValue = _value; _lastKnownRemoteTextEditingValue = localValue; _textInputConnection = TextInput.attach(this, - new TextInputConfiguration( + TextInputConfiguration( inputType: widget.keyboardType, obscureText: widget.obscureText, autocorrect: widget.autocorrect, @@ -665,7 +665,7 @@ class EditableTextState extends State with AutomaticKeepAliveClien _hideSelectionOverlayIfNeeded(); if (widget.selectionControls != null) { - _selectionOverlay = new TextSelectionOverlay( + _selectionOverlay = TextSelectionOverlay( context: context, value: _value, debugRequiredFor: widget, @@ -786,7 +786,7 @@ class EditableTextState extends State with AutomaticKeepAliveClien void _startCursorTimer() { _showCursor.value = true; - _cursorTimer = new Timer.periodic(_kCursorBlinkHalfPeriod, _cursorTick); + _cursorTimer = Timer.periodic(_kCursorBlinkHalfPeriod, _cursorTick); } void _stopCursorTimer() { @@ -824,12 +824,12 @@ class EditableTextState extends State with AutomaticKeepAliveClien _showCaretOnScreen(); if (!_value.selection.isValid) { // Place cursor at the end if the selection is invalid when we receive focus. - widget.controller.selection = new TextSelection.collapsed(offset: _value.text.length); + widget.controller.selection = TextSelection.collapsed(offset: _value.text.length); } } else { WidgetsBinding.instance.removeObserver(this); // Clear the selection and composition state if this widget lost focus. - _value = new TextEditingValue(text: _value.text); + _value = TextEditingValue(text: _value.text); } updateKeepAlive(); } @@ -871,19 +871,19 @@ class EditableTextState extends State with AutomaticKeepAliveClien super.build(context); // See AutomaticKeepAliveClientMixin. final TextSelectionControls controls = widget.selectionControls; - return new Scrollable( + return Scrollable( excludeFromSemantics: true, axisDirection: _isMultiline ? AxisDirection.down : AxisDirection.right, controller: _scrollController, physics: const ClampingScrollPhysics(), viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new CompositedTransformTarget( + return CompositedTransformTarget( link: _layerLink, - child: new Semantics( + child: Semantics( onCopy: _hasFocus && controls?.canCopy(this) == true ? () => controls.handleCopy(this) : null, onCut: _hasFocus && controls?.canCut(this) == true ? () => controls.handleCut(this) : null, onPaste: _hasFocus && controls?.canPaste(this) == true ? () => controls.handlePaste(this) : null, - child: new _Editable( + child: _Editable( key: _editableKey, textSpan: buildTextSpan(), value: _value, @@ -922,15 +922,15 @@ class EditableTextState extends State with AutomaticKeepAliveClien const TextStyle(decoration: TextDecoration.underline), ); - return new TextSpan( + return TextSpan( style: widget.style, children: [ - new TextSpan(text: _value.composing.textBefore(_value.text)), - new TextSpan( + TextSpan(text: _value.composing.textBefore(_value.text)), + TextSpan( style: composingStyle, text: _value.composing.textInside(_value.text), ), - new TextSpan(text: _value.composing.textAfter(_value.text)), + TextSpan(text: _value.composing.textAfter(_value.text)), ]); } @@ -942,7 +942,7 @@ class EditableTextState extends State with AutomaticKeepAliveClien if (o != null && o >= 0 && o < text.length) text = text.replaceRange(o, o + 1, _value.text.substring(o, o + 1)); } - return new TextSpan(style: widget.style, text: text); + return TextSpan(style: widget.style, text: text); } } @@ -996,7 +996,7 @@ class _Editable extends LeafRenderObjectWidget { @override RenderEditable createRenderObject(BuildContext context) { - return new RenderEditable( + return RenderEditable( text: textSpan, cursorColor: cursorColor, showCursor: showCursor, diff --git a/packages/flutter/lib/src/widgets/fade_in_image.dart b/packages/flutter/lib/src/widgets/fade_in_image.dart index 19cf709bcb..b0b9b41531 100644 --- a/packages/flutter/lib/src/widgets/fade_in_image.dart +++ b/packages/flutter/lib/src/widgets/fade_in_image.dart @@ -138,8 +138,8 @@ class FadeInImage extends StatefulWidget { assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), - placeholder = new MemoryImage(placeholder, scale: placeholderScale), - image = new NetworkImage(image, scale: imageScale), + placeholder = MemoryImage(placeholder, scale: placeholderScale), + image = NetworkImage(image, scale: imageScale), super(key: key); /// Creates a widget that uses a placeholder image stored in an asset bundle @@ -186,8 +186,8 @@ class FadeInImage extends StatefulWidget { }) : assert(placeholder != null), assert(image != null), placeholder = placeholderScale != null - ? new ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale) - : new AssetImage(placeholder, bundle: bundle), + ? ExactAssetImage(placeholder, bundle: bundle, scale: placeholderScale) + : AssetImage(placeholder, bundle: bundle), assert(imageScale != null), assert(fadeOutDuration != null), assert(fadeOutCurve != null), @@ -196,7 +196,7 @@ class FadeInImage extends StatefulWidget { assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), - image = new NetworkImage(image, scale: imageScale), + image = NetworkImage(image, scale: imageScale), super(key: key); /// Image displayed while the target [image] is loading. @@ -284,7 +284,7 @@ class FadeInImage extends StatefulWidget { final bool matchTextDirection; @override - State createState() => new _FadeInImageState(); + State createState() => _FadeInImageState(); } @@ -331,7 +331,7 @@ class _ImageProviderResolver { final ImageStream oldImageStream = _imageStream; _imageStream = provider.resolve(createLocalImageConfiguration( state.context, - size: widget.width != null && widget.height != null ? new Size(widget.width, widget.height) : null + size: widget.width != null && widget.height != null ? Size(widget.width, widget.height) : null )); assert(_imageStream != null); @@ -363,13 +363,13 @@ class _FadeInImageState extends State with TickerProviderStateMixin @override void initState() { - _imageResolver = new _ImageProviderResolver(state: this, listener: _updatePhase); - _placeholderResolver = new _ImageProviderResolver(state: this, listener: () { + _imageResolver = _ImageProviderResolver(state: this, listener: _updatePhase); + _placeholderResolver = _ImageProviderResolver(state: this, listener: () { setState(() { // Trigger rebuild to display the placeholder image }); }); - _controller = new AnimationController( + _controller = AnimationController( value: 1.0, vsync: this, ); @@ -427,7 +427,7 @@ class _FadeInImageState extends State with TickerProviderStateMixin if (_imageResolver._imageInfo != null) { // Received image data. Begin placeholder fade-out. _controller.duration = widget.fadeOutDuration; - _animation = new CurvedAnimation( + _animation = CurvedAnimation( parent: _controller, curve: widget.fadeOutCurve, ); @@ -439,7 +439,7 @@ class _FadeInImageState extends State with TickerProviderStateMixin if (_controller.status == AnimationStatus.dismissed) { // Done fading out placeholder. Begin target image fade-in. _controller.duration = widget.fadeInDuration; - _animation = new CurvedAnimation( + _animation = CurvedAnimation( parent: _controller, curve: widget.fadeInCurve, ); @@ -494,12 +494,12 @@ class _FadeInImageState extends State with TickerProviderStateMixin Widget build(BuildContext context) { assert(_phase != FadeInImagePhase.start); final ImageInfo imageInfo = _imageInfo; - return new RawImage( + return RawImage( image: imageInfo?.image, width: widget.width, height: widget.height, scale: imageInfo?.scale ?? 1.0, - color: new Color.fromRGBO(255, 255, 255, _animation?.value ?? 1.0), + color: Color.fromRGBO(255, 255, 255, _animation?.value ?? 1.0), colorBlendMode: BlendMode.modulate, fit: widget.fit, alignment: widget.alignment, @@ -511,9 +511,9 @@ class _FadeInImageState extends State with TickerProviderStateMixin @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new EnumProperty('phase', _phase)); - description.add(new DiagnosticsProperty('pixels', _imageInfo)); - description.add(new DiagnosticsProperty('image stream', _imageResolver._imageStream)); - description.add(new DiagnosticsProperty('placeholder stream', _placeholderResolver._imageStream)); + description.add(EnumProperty('phase', _phase)); + description.add(DiagnosticsProperty('pixels', _imageInfo)); + description.add(DiagnosticsProperty('image stream', _imageResolver._imageStream)); + description.add(DiagnosticsProperty('placeholder stream', _placeholderResolver._imageStream)); } } diff --git a/packages/flutter/lib/src/widgets/focus_manager.dart b/packages/flutter/lib/src/widgets/focus_manager.dart index cde83cbbe3..3453c2641c 100644 --- a/packages/flutter/lib/src/widgets/focus_manager.dart +++ b/packages/flutter/lib/src/widgets/focus_manager.dart @@ -357,7 +357,7 @@ class FocusScopeNode extends Object with DiagnosticableTreeMixin { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); if (_focus != null) - properties.add(new DiagnosticsProperty('focus', _focus)); + properties.add(DiagnosticsProperty('focus', _focus)); } @override @@ -414,7 +414,7 @@ class FocusManager { /// /// This field is rarely used direction. Instead, to find the /// [FocusScopeNode] for a given [BuildContext], use [FocusScope.of]. - final FocusScopeNode rootScope = new FocusScopeNode(); + final FocusScopeNode rootScope = FocusScopeNode(); FocusNode _currentFocus; diff --git a/packages/flutter/lib/src/widgets/focus_scope.dart b/packages/flutter/lib/src/widgets/focus_scope.dart index ffdc22a2ef..6d0ff2df44 100644 --- a/packages/flutter/lib/src/widgets/focus_scope.dart +++ b/packages/flutter/lib/src/widgets/focus_scope.dart @@ -78,7 +78,7 @@ class FocusScope extends StatefulWidget { } @override - _FocusScopeState createState() => new _FocusScopeState(); + _FocusScopeState createState() => _FocusScopeState(); } class _FocusScopeState extends State { @@ -102,9 +102,9 @@ class _FocusScopeState extends State { @override Widget build(BuildContext context) { FocusScope.of(context).reparentScopeIfNeeded(widget.node); - return new Semantics( + return Semantics( explicitChildNodes: true, - child: new _FocusScopeMarker( + child: _FocusScopeMarker( node: widget.node, child: widget.child, ), diff --git a/packages/flutter/lib/src/widgets/form.dart b/packages/flutter/lib/src/widgets/form.dart index 47d6e3e6a1..a562a785e2 100644 --- a/packages/flutter/lib/src/widgets/form.dart +++ b/packages/flutter/lib/src/widgets/form.dart @@ -72,7 +72,7 @@ class Form extends StatefulWidget { final VoidCallback onChanged; @override - FormState createState() => new FormState(); + FormState createState() => FormState(); } /// State associated with a [Form] widget. @@ -83,7 +83,7 @@ class Form extends StatefulWidget { /// Typically obtained via [Form.of]. class FormState extends State
    { int _generation = 0; - final Set> _fields = new Set>(); + final Set> _fields = Set>(); // Called when a form field has changed. This will cause all form fields // to rebuild, useful if form fields have interdependencies. @@ -111,9 +111,9 @@ class FormState extends State { Widget build(BuildContext context) { if (widget.autovalidate) _validate(); - return new WillPopScope( + return WillPopScope( onWillPop: widget.onWillPop, - child: new _FormScope( + child: _FormScope( formState: this, generation: _generation, child: widget.child, @@ -257,7 +257,7 @@ class FormField extends StatefulWidget { final bool autovalidate; @override - FormFieldState createState() => new FormFieldState(); + FormFieldState createState() => FormFieldState(); } /// The current state of a [FormField]. Passed to the [FormFieldBuilder] method diff --git a/packages/flutter/lib/src/widgets/framework.dart b/packages/flutter/lib/src/widgets/framework.dart index 0626614ce4..445fe88260 100644 --- a/packages/flutter/lib/src/widgets/framework.dart +++ b/packages/flutter/lib/src/widgets/framework.dart @@ -116,7 +116,7 @@ abstract class GlobalKey> extends Key { /// /// The label is purely for debugging and not used for comparing the identity /// of the key. - factory GlobalKey({ String debugLabel }) => new LabeledGlobalKey(debugLabel); + factory GlobalKey({ String debugLabel }) => LabeledGlobalKey(debugLabel); /// Creates a global key without a label. /// @@ -125,8 +125,8 @@ abstract class GlobalKey> extends Key { const GlobalKey.constructor() : super.empty(); static final Map _registry = {}; - static final Set _removedKeys = new HashSet(); - static final Set _debugIllFatedElements = new HashSet(); + static final Set _removedKeys = HashSet(); + static final Set _debugIllFatedElements = HashSet(); static final Map _debugReservations = {}; void _register(Element element) { @@ -169,7 +169,7 @@ abstract class GlobalKey> extends Key { final String older = _debugReservations[this].toString(); final String newer = parent.toString(); if (older != newer) { - throw new FlutterError( + throw FlutterError( 'Multiple widgets used the same GlobalKey.\n' 'The key $this was used by multiple widgets. The parents of those widgets were:\n' '- $older\n' @@ -177,7 +177,7 @@ abstract class GlobalKey> extends Key { 'A GlobalKey can only be specified on one widget at a time in the widget tree.' ); } - throw new FlutterError( + throw FlutterError( 'Multiple widgets used the same GlobalKey.\n' 'The key $this was used by multiple widgets. The parents of those widgets were ' 'different widgets that both had the following description:\n' @@ -201,7 +201,7 @@ abstract class GlobalKey> extends Key { final GlobalKey key = element.widget.key; assert(_registry.containsKey(key)); duplicates ??= >{}; - final Set elements = duplicates.putIfAbsent(key, () => new HashSet()); + final Set elements = duplicates.putIfAbsent(key, () => HashSet()); elements.add(element); elements.add(_registry[key]); } @@ -209,7 +209,7 @@ abstract class GlobalKey> extends Key { _debugIllFatedElements.clear(); _debugReservations.clear(); if (duplicates != null) { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.writeln('Multiple widgets used the same GlobalKey.\n'); for (GlobalKey key in duplicates.keys) { final Set elements = duplicates[key]; @@ -218,7 +218,7 @@ abstract class GlobalKey> extends Key { buffer.writeln('- $element'); } buffer.write('A GlobalKey can only be specified on one widget at a time in the widget tree.'); - throw new FlutterError(buffer.toString()); + throw FlutterError(buffer.toString()); } return true; }()); @@ -555,7 +555,7 @@ abstract class StatelessWidget extends Widget { /// /// It is uncommon for subclasses to override this method. @override - StatelessElement createElement() => new StatelessElement(this); + StatelessElement createElement() => StatelessElement(this); /// Describes the part of the user interface represented by this widget. /// @@ -786,7 +786,7 @@ abstract class StatefulWidget extends Widget { /// /// It is uncommon for subclasses to override this method. @override - StatefulElement createElement() => new StatefulElement(this); + StatefulElement createElement() => StatefulElement(this); /// Creates the mutable state for this widget at a given location in the tree. /// @@ -1095,7 +1095,7 @@ abstract class State extends Diagnosticable { assert(fn != null); assert(() { if (_debugLifecycleState == _StateLifecycle.defunct) { - throw new FlutterError( + throw FlutterError( 'setState() called after dispose(): $this\n' 'This error happens if you call setState() on a State object for a widget that ' 'no longer appears in the widget tree (e.g., whose parent widget no longer ' @@ -1112,7 +1112,7 @@ abstract class State extends Diagnosticable { ); } if (_debugLifecycleState == _StateLifecycle.created && !mounted) { - throw new FlutterError( + throw FlutterError( 'setState() called in constructor: $this\n' 'This happens when you call setState() on a State object for a widget that ' 'hasn\'t been inserted into the widget tree yet. It is not necessary to call ' @@ -1125,7 +1125,7 @@ abstract class State extends Diagnosticable { final dynamic result = fn() as dynamic; assert(() { if (result is Future) { - throw new FlutterError( + throw FlutterError( 'setState() callback argument returned a Future.\n' 'The setState() method on $this was called with a closure or method that ' 'returned a Future. Maybe it is marked as "async".\n' @@ -1320,11 +1320,11 @@ abstract class State extends Diagnosticable { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); assert(() { - properties.add(new EnumProperty<_StateLifecycle>('lifecycle state', _debugLifecycleState, defaultValue: _StateLifecycle.ready)); + properties.add(EnumProperty<_StateLifecycle>('lifecycle state', _debugLifecycleState, defaultValue: _StateLifecycle.ready)); return true; }()); - properties.add(new ObjectFlagProperty('_widget', _widget, ifNull: 'no widget')); - properties.add(new ObjectFlagProperty('_element', _element, ifNull: 'not mounted')); + properties.add(ObjectFlagProperty('_widget', _widget, ifNull: 'no widget')); + properties.add(ObjectFlagProperty('_element', _element, ifNull: 'not mounted')); } } @@ -1413,7 +1413,7 @@ abstract class ParentDataWidget extends ProxyWidge : super(key: key, child: child); @override - ParentDataElement createElement() => new ParentDataElement(this); + ParentDataElement createElement() => ParentDataElement(this); /// Subclasses should override this method to return true if the given /// ancestor is a RenderObjectWidget that wraps a RenderObject that can handle @@ -1553,7 +1553,7 @@ abstract class InheritedWidget extends ProxyWidget { : super(key: key, child: child); @override - InheritedElement createElement() => new InheritedElement(this); + InheritedElement createElement() => InheritedElement(this); /// Whether the framework should notify widgets that inherit from this widget. /// @@ -1622,7 +1622,7 @@ abstract class LeafRenderObjectWidget extends RenderObjectWidget { const LeafRenderObjectWidget({ Key key }) : super(key: key); @override - LeafRenderObjectElement createElement() => new LeafRenderObjectElement(this); + LeafRenderObjectElement createElement() => LeafRenderObjectElement(this); } /// A superclass for RenderObjectWidgets that configure RenderObject subclasses @@ -1639,7 +1639,7 @@ abstract class SingleChildRenderObjectWidget extends RenderObjectWidget { final Widget child; @override - SingleChildRenderObjectElement createElement() => new SingleChildRenderObjectElement(this); + SingleChildRenderObjectElement createElement() => SingleChildRenderObjectElement(this); } /// A superclass for RenderObjectWidgets that configure RenderObject subclasses @@ -1664,7 +1664,7 @@ abstract class MultiChildRenderObjectWidget extends RenderObjectWidget { final List children; @override - MultiChildRenderObjectElement createElement() => new MultiChildRenderObjectElement(this); + MultiChildRenderObjectElement createElement() => MultiChildRenderObjectElement(this); } @@ -1679,7 +1679,7 @@ enum _ElementLifecycle { class _InactiveElements { bool _locked = false; - final Set _elements = new HashSet(); + final Set _elements = HashSet(); void _unmount(Element element) { assert(element._debugLifecycleState == _ElementLifecycle.inactive); @@ -2087,7 +2087,7 @@ class BuildOwner { /// dirty. VoidCallback onBuildScheduled; - final _InactiveElements _inactiveElements = new _InactiveElements(); + final _InactiveElements _inactiveElements = _InactiveElements(); final List _dirtyElements = []; bool _scheduledFlushDirtyElements = false; @@ -2112,7 +2112,7 @@ class BuildOwner { /// the [FocusScopeNode] for a given [BuildContext]. /// /// See [FocusManager] for more details. - final FocusManager focusManager = new FocusManager(); + final FocusManager focusManager = FocusManager(); /// Adds an element to the dirty elements list so that it will be rebuilt /// when [WidgetsBinding.drawFrame] calls [buildScope]. @@ -2123,7 +2123,7 @@ class BuildOwner { if (debugPrintScheduleBuildForStacks) debugPrintStack(label: 'scheduleBuildFor() called for $element${_dirtyElements.contains(element) ? " (ALREADY IN LIST)" : ""}'); if (!element.dirty) { - throw new FlutterError( + throw FlutterError( 'scheduleBuildFor() called for a widget that is not marked as dirty.\n' 'The method was called for the following element:\n' ' $element\n' @@ -2141,7 +2141,7 @@ class BuildOwner { if (debugPrintScheduleBuildForStacks) debugPrintStack(label: 'BuildOwner.scheduleBuildFor() called; _dirtyElementsNeedsResorting was $_dirtyElementsNeedsResorting (now true); dirty list is: $_dirtyElements'); if (!_debugIsInBuildScope) { - throw new FlutterError( + throw FlutterError( 'BuildOwner.scheduleBuildFor() called inappropriately.\n' 'The BuildOwner.scheduleBuildFor() method should only be called while the ' 'buildScope() method is actively rebuilding the widget tree.' @@ -2299,7 +2299,7 @@ class BuildOwner { } assert(() { if (_dirtyElements.any((Element element) => element._active && element.dirty)) { - throw new FlutterError( + throw FlutterError( 'buildScope missed some dirty elements.\n' 'This probably indicates that the dirty list should have been resorted but was not.\n' 'The list of dirty elements at the end of the buildScope call was:\n' @@ -2332,9 +2332,9 @@ class BuildOwner { Map> _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans; void _debugTrackElementThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans(Element node, GlobalKey key) { - _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans ??= new HashMap>(); + _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans ??= HashMap>(); final Set keys = _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans - .putIfAbsent(node, () => new HashSet()); + .putIfAbsent(node, () => HashSet()); keys.add(key); } @@ -2363,13 +2363,13 @@ class BuildOwner { GlobalKey._debugVerifyIllFatedPopulation(); if (_debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans != null && _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans.isNotEmpty) { - final Set keys = new HashSet(); + final Set keys = HashSet(); for (Element element in _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans.keys) { if (element._debugLifecycleState != _ElementLifecycle.defunct) keys.addAll(_debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans[element]); } if (keys.isNotEmpty) { - final Map keyStringCount = new HashMap(); + final Map keyStringCount = HashMap(); for (String key in keys.map((GlobalKey key) => key.toString())) { if (keyStringCount.containsKey(key)) { keyStringCount[key] += 1; @@ -2386,7 +2386,7 @@ class BuildOwner { } }); final Iterable elements = _debugElementsThatWillNeedToBeRebuiltDueToGlobalKeyShenanigans.keys; - final Map elementStringCount = new HashMap(); + final Map elementStringCount = HashMap(); for (String element in elements.map((Element element) => element.toString())) { if (elementStringCount.containsKey(element)) { elementStringCount[element] += 1; @@ -2414,7 +2414,7 @@ class BuildOwner { final String they = elementLabels.length == 1 ? 'it' : 'they'; final String think = elementLabels.length == 1 ? 'thinks' : 'think'; final String are = elementLabels.length == 1 ? 'is' : 'are'; - throw new FlutterError( + throw FlutterError( 'Duplicate GlobalKey$s detected in widget tree.\n' 'The following GlobalKey$s $were specified multiple times in the widget tree. This will lead to ' 'parts of the widget tree being truncated unexpectedly, because the second time a key is seen, ' @@ -2662,7 +2662,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { assert(() { if (owner == null || !owner._debugStateLocked) return true; - throw new FlutterError( + throw FlutterError( 'visitChildElements() called during build.\n' 'The BuildContext.visitChildElements() method can\'t be called during ' 'build because the child list is still being updated at that point, ' @@ -2880,7 +2880,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { if (parent != null) { assert(() { if (parent == this) { - throw new FlutterError( + throw FlutterError( 'A GlobalKey was used multiple times inside one widget\'s child list.\n' 'The offending GlobalKey was: $key\n' 'The parent of the widgets with that key was:\n $parent\n' @@ -3113,7 +3113,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { Size get size { assert(() { if (_debugLifecycleState != _ElementLifecycle.active) { - throw new FlutterError( + throw FlutterError( 'Cannot get size of inactive element.\n' 'In order for an element to have a valid size, the element must be ' 'active, which means it is part of the tree. Instead, this element ' @@ -3123,7 +3123,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ); } if (owner._debugBuilding) { - throw new FlutterError( + throw FlutterError( 'Cannot get size during build.\n' 'The size of this render object has not yet been determined because ' 'the framework is still in the process of building widgets, which ' @@ -3146,7 +3146,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { final RenderObject renderObject = findRenderObject(); assert(() { if (renderObject == null) { - throw new FlutterError( + throw FlutterError( 'Cannot get size without a render object.\n' 'In order for an element to have a valid size, the element must have ' 'an associated render object. This element does not have an associated ' @@ -3158,7 +3158,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ); } if (renderObject is RenderSliver) { - throw new FlutterError( + throw FlutterError( 'Cannot get size from a RenderSliver.\n' 'The render object associated with this element is a ' '${renderObject.runtimeType}, which is a subtype of RenderSliver. ' @@ -3173,7 +3173,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ); } if (renderObject is! RenderBox) { - throw new FlutterError( + throw FlutterError( 'Cannot get size from a render object that is not a RenderBox.\n' 'Instead of being a subtype of RenderBox, the render object associated ' 'with this element is a ${renderObject.runtimeType}. If this type of ' @@ -3187,7 +3187,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { } final RenderBox box = renderObject; if (!box.hasSize) { - throw new FlutterError( + throw FlutterError( 'Cannot get size from a render object that has not been through layout.\n' 'The size of this render object has not yet been determined because ' 'this render object has not yet been through layout, which typically ' @@ -3201,7 +3201,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { ); } if (box.debugNeedsLayout) { - throw new FlutterError( + throw FlutterError( 'Cannot get size from a render object that has been marked dirty for layout.\n' 'The size of this render object is ambiguous because this render object has ' 'been modified since it was last laid out, which typically means that the size ' @@ -3230,7 +3230,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { bool _debugCheckStateIsActiveForAncestorLookup() { assert(() { if (_debugLifecycleState != _ElementLifecycle.active) { - throw new FlutterError( + throw FlutterError( 'Looking up a deactivated widget\'s ancestor is unsafe.\n' 'At this point the state of the widget\'s element tree is no longer ' 'stable. To safely refer to a widget\'s ancestor in its dispose() method, ' @@ -3246,7 +3246,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { @override InheritedWidget inheritFromElement(InheritedElement ancestor, { Object aspect }) { assert(ancestor != null); - _dependencies ??= new HashSet(); + _dependencies ??= HashSet(); _dependencies.add(ancestor); ancestor.updateDependencies(this, aspect); return ancestor.widget; @@ -3350,7 +3350,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { bool _debugCheckOwnerBuildTargetExists(String methodName) { assert(() { if (owner._debugCurrentBuildTarget == null) { - throw new FlutterError( + throw FlutterError( '$methodName for ${widget.runtimeType} was called at an ' 'inappropriate time.\n' 'It may only be called while the widgets are being built. A possible ' @@ -3405,13 +3405,13 @@ abstract class Element extends DiagnosticableTree implements BuildContext { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); properties.defaultDiagnosticsTreeStyle= DiagnosticsTreeStyle.dense; - properties.add(new ObjectFlagProperty('depth', depth, ifNull: 'no depth')); - properties.add(new ObjectFlagProperty('widget', widget, ifNull: 'no widget')); + properties.add(ObjectFlagProperty('depth', depth, ifNull: 'no depth')); + properties.add(ObjectFlagProperty('widget', widget, ifNull: 'no widget')); if (widget != null) { - properties.add(new DiagnosticsProperty('key', widget?.key, showName: false, defaultValue: null, level: DiagnosticLevel.hidden)); + properties.add(DiagnosticsProperty('key', widget?.key, showName: false, defaultValue: null, level: DiagnosticLevel.hidden)); widget.debugFillProperties(properties); } - properties.add(new FlagProperty('dirty', value: dirty, ifTrue: 'dirty')); + properties.add(FlagProperty('dirty', value: dirty, ifTrue: 'dirty')); } @override @@ -3421,7 +3421,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { if (child != null) { children.add(child.toDiagnosticsNode()); } else { - children.add(new DiagnosticsNode.message('')); + children.add(DiagnosticsNode.message('')); } }); return children; @@ -3469,7 +3469,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { if (_debugIsInScope(owner._debugCurrentBuildTarget)) return true; if (!_debugAllowIgnoredCallsToMarkNeedsBuild) { - throw new FlutterError( + throw FlutterError( 'setState() or markNeedsBuild() called during build.\n' 'This ${widget.runtimeType} widget cannot be marked as needing to build because the framework ' 'is already in the process of building widgets. A widget can be marked as ' @@ -3486,7 +3486,7 @@ abstract class Element extends DiagnosticableTree implements BuildContext { assert(dirty); // can only get here if we're not in scope, but ignored calls are allowed, and our call would somehow be ignored (since we're already dirty) } else if (owner._debugStateLocked) { assert(!_debugAllowIgnoredCallsToMarkNeedsBuild); - throw new FlutterError( + throw FlutterError( 'setState() or markNeedsBuild() called when widget tree was locked.\n' 'This ${widget.runtimeType} widget cannot be marked as needing to build ' 'because the framework is locked.\n' @@ -3565,7 +3565,7 @@ typedef Widget ErrorWidgetBuilder(FlutterErrorDetails details); class ErrorWidget extends LeafRenderObjectWidget { /// Creates a widget that displays the given error message. ErrorWidget(Object exception) : message = _stringify(exception), - super(key: new UniqueKey()); + super(key: UniqueKey()); /// The configurable factory for [ErrorWidget]. /// @@ -3591,7 +3591,7 @@ class ErrorWidget extends LeafRenderObjectWidget { /// [FlutterErrorDetails] object immediately prior to this callback being /// invoked, and which can also be configured to control how errors are /// reported. - static ErrorWidgetBuilder builder = (FlutterErrorDetails details) => new ErrorWidget(details.exception); + static ErrorWidgetBuilder builder = (FlutterErrorDetails details) => ErrorWidget(details.exception); /// The message to display. final String message; @@ -3604,12 +3604,12 @@ class ErrorWidget extends LeafRenderObjectWidget { } @override - RenderBox createRenderObject(BuildContext context) => new RenderErrorBox(message); + RenderBox createRenderObject(BuildContext context) => RenderErrorBox(message); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('message', message, quoted: false)); + properties.add(StringProperty('message', message, quoted: false)); } } @@ -3746,7 +3746,7 @@ class StatefulElement extends ComponentElement { : _state = widget.createState(), super(widget) { assert(() { if (!_state._debugTypesAreRight(widget)) { - throw new FlutterError( + throw FlutterError( 'StatefulWidget.createState must return a subtype of State<${widget.runtimeType}>\n' 'The createState function for ${widget.runtimeType} returned a state ' 'of type ${_state.runtimeType}, which is not a subtype of ' @@ -3787,7 +3787,7 @@ class StatefulElement extends ComponentElement { final dynamic debugCheckForReturnedFuture = _state.initState() as dynamic; assert(() { if (debugCheckForReturnedFuture is Future) { - throw new FlutterError( + throw FlutterError( '${_state.runtimeType}.initState() returned a Future.\n' 'State.initState() must be a void method without an `async` keyword.\n' 'Rather than awaiting on asynchronous work directly inside of initState,\n' @@ -3820,7 +3820,7 @@ class StatefulElement extends ComponentElement { final dynamic debugCheckForReturnedFuture = _state.didUpdateWidget(oldWidget) as dynamic; assert(() { if (debugCheckForReturnedFuture is Future) { - throw new FlutterError( + throw FlutterError( '${_state.runtimeType}.didUpdateWidget() returned a Future.\n' 'State.didUpdateWidget() must be a void method without an `async` keyword.\n' 'Rather than awaiting on asynchronous work directly inside of didUpdateWidget,\n' @@ -3858,7 +3858,7 @@ class StatefulElement extends ComponentElement { assert(() { if (_state._debugLifecycleState == _StateLifecycle.defunct) return true; - throw new FlutterError( + throw FlutterError( '${_state.runtimeType}.dispose failed to call super.dispose.\n' 'dispose() implementations must always call their superclass dispose() method, to ensure ' 'that all the resources used by the widget are fully released.' @@ -3874,7 +3874,7 @@ class StatefulElement extends ComponentElement { assert(() { final Type targetType = ancestor.widget.runtimeType; if (state._debugLifecycleState == _StateLifecycle.created) { - throw new FlutterError( + throw FlutterError( 'inheritFromWidgetOfExactType($targetType) or inheritFromElement() was called before ${_state.runtimeType}.initState() completed.\n' 'When an inherited widget changes, for example if the value of Theme.of() changes, ' 'its dependent widgets are rebuilt. If the dependent widget\'s reference to ' @@ -3887,7 +3887,7 @@ class StatefulElement extends ComponentElement { ); } if (state._debugLifecycleState == _StateLifecycle.defunct) { - throw new FlutterError( + throw FlutterError( 'inheritFromWidgetOfExactType($targetType) or inheritFromElement() was called after dispose(): $this\n' 'This error happens if you call inheritFromWidgetOfExactType() on the ' 'BuildContext for a widget that no longer appears in the widget tree ' @@ -3920,7 +3920,7 @@ class StatefulElement extends ComponentElement { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('state', state, defaultValue: null)); + properties.add(DiagnosticsProperty>('state', state, defaultValue: null)); } } @@ -3980,7 +3980,7 @@ class ParentDataElement extends ProxyElement { } if (ancestor != null && badAncestors.isEmpty) return true; - throw new FlutterError( + throw FlutterError( 'Incorrect use of ParentDataWidget.\n' + widget.debugDescribeInvalidAncestorChain( description: '$this', @@ -4058,16 +4058,16 @@ class InheritedElement extends ProxyElement { @override InheritedWidget get widget => super.widget; - final Map _dependents = new HashMap(); + final Map _dependents = HashMap(); @override void _updateInheritance() { assert(_active); final Map incomingWidgets = _parent?._inheritedWidgets; if (incomingWidgets != null) - _inheritedWidgets = new HashMap.from(incomingWidgets); + _inheritedWidgets = HashMap.from(incomingWidgets); else - _inheritedWidgets = new HashMap(); + _inheritedWidgets = HashMap(); _inheritedWidgets[widget.runtimeType] = this; } @@ -4433,7 +4433,7 @@ abstract class RenderObjectElement extends Element { void _debugUpdateRenderObjectOwner() { assert(() { - _renderObject.debugCreator = new _DebugCreator(this); + _renderObject.debugCreator = _DebugCreator(this); return true; }()); } @@ -4507,7 +4507,7 @@ abstract class RenderObjectElement extends Element { int oldChildrenBottom = oldChildren.length - 1; final List newChildren = oldChildren.length == newWidgets.length ? - oldChildren : new List(newWidgets.length); + oldChildren : List(newWidgets.length); Element previousChild; @@ -4696,7 +4696,7 @@ abstract class RenderObjectElement extends Element { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('renderObject', renderObject, defaultValue: null)); + properties.add(DiagnosticsProperty('renderObject', renderObject, defaultValue: null)); } } @@ -4851,7 +4851,7 @@ class MultiChildRenderObjectElement extends RenderObjectElement { List _children; // We keep a set of forgotten children to avoid O(n^2) work walking _children // repeatedly to remove children. - final Set _forgottenChildren = new HashSet(); + final Set _forgottenChildren = HashSet(); @override void insertChildRenderObject(RenderObject child, Element slot) { @@ -4895,7 +4895,7 @@ class MultiChildRenderObjectElement extends RenderObjectElement { @override void mount(Element parent, dynamic newSlot) { super.mount(parent, newSlot); - _children = new List(widget.children.length); + _children = List(widget.children.length); Element previousChild; for (int i = 0; i < _children.length; i += 1) { final Element newChild = inflateWidget(widget.children[i], previousChild); @@ -4926,7 +4926,7 @@ FlutterErrorDetails _debugReportException( StackTrace stack, { InformationCollector informationCollector }) { - final FlutterErrorDetails details = new FlutterErrorDetails( + final FlutterErrorDetails details = FlutterErrorDetails( exception: exception, stack: stack, library: 'widgets library', diff --git a/packages/flutter/lib/src/widgets/gesture_detector.dart b/packages/flutter/lib/src/widgets/gesture_detector.dart index 2e8268ffdf..dc0709a0c6 100644 --- a/packages/flutter/lib/src/widgets/gesture_detector.dart +++ b/packages/flutter/lib/src/widgets/gesture_detector.dart @@ -178,14 +178,14 @@ class GestureDetector extends StatelessWidget { final bool haveScale = onScaleStart != null || onScaleUpdate != null || onScaleEnd != null; if (havePan || haveScale) { if (havePan && haveScale) { - throw new FlutterError( + throw FlutterError( 'Incorrect GestureDetector arguments.\n' 'Having both a pan gesture recognizer and a scale gesture recognizer is redundant; scale is a superset of pan. Just use the scale gesture recognizer.' ); } final String recognizer = havePan ? 'pan' : 'scale'; if (haveVerticalDrag && haveHorizontalDrag) { - throw new FlutterError( + throw FlutterError( 'Incorrect GestureDetector arguments.\n' 'Simultaneously having a vertical drag gesture recognizer, a horizontal drag gesture recognizer, and a $recognizer gesture recognizer ' 'will result in the $recognizer gesture recognizer being ignored, since the other two will catch all drags.' @@ -326,8 +326,8 @@ class GestureDetector extends StatelessWidget { final Map gestures = {}; if (onTapDown != null || onTapUp != null || onTap != null || onTapCancel != null) { - gestures[TapGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new TapGestureRecognizer(debugOwner: this), + gestures[TapGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => TapGestureRecognizer(debugOwner: this), (TapGestureRecognizer instance) { instance ..onTapDown = onTapDown @@ -339,8 +339,8 @@ class GestureDetector extends StatelessWidget { } if (onDoubleTap != null) { - gestures[DoubleTapGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new DoubleTapGestureRecognizer(debugOwner: this), + gestures[DoubleTapGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => DoubleTapGestureRecognizer(debugOwner: this), (DoubleTapGestureRecognizer instance) { instance ..onDoubleTap = onDoubleTap; @@ -349,8 +349,8 @@ class GestureDetector extends StatelessWidget { } if (onLongPress != null) { - gestures[LongPressGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new LongPressGestureRecognizer(debugOwner: this), + gestures[LongPressGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => LongPressGestureRecognizer(debugOwner: this), (LongPressGestureRecognizer instance) { instance ..onLongPress = onLongPress; @@ -363,8 +363,8 @@ class GestureDetector extends StatelessWidget { onVerticalDragUpdate != null || onVerticalDragEnd != null || onVerticalDragCancel != null) { - gestures[VerticalDragGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new VerticalDragGestureRecognizer(debugOwner: this), + gestures[VerticalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => VerticalDragGestureRecognizer(debugOwner: this), (VerticalDragGestureRecognizer instance) { instance ..onDown = onVerticalDragDown @@ -381,8 +381,8 @@ class GestureDetector extends StatelessWidget { onHorizontalDragUpdate != null || onHorizontalDragEnd != null || onHorizontalDragCancel != null) { - gestures[HorizontalDragGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new HorizontalDragGestureRecognizer(debugOwner: this), + gestures[HorizontalDragGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => HorizontalDragGestureRecognizer(debugOwner: this), (HorizontalDragGestureRecognizer instance) { instance ..onDown = onHorizontalDragDown @@ -399,8 +399,8 @@ class GestureDetector extends StatelessWidget { onPanUpdate != null || onPanEnd != null || onPanCancel != null) { - gestures[PanGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new PanGestureRecognizer(debugOwner: this), + gestures[PanGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => PanGestureRecognizer(debugOwner: this), (PanGestureRecognizer instance) { instance ..onDown = onPanDown @@ -413,8 +413,8 @@ class GestureDetector extends StatelessWidget { } if (onScaleStart != null || onScaleUpdate != null || onScaleEnd != null) { - gestures[ScaleGestureRecognizer] = new GestureRecognizerFactoryWithHandlers( - () => new ScaleGestureRecognizer(debugOwner: this), + gestures[ScaleGestureRecognizer] = GestureRecognizerFactoryWithHandlers( + () => ScaleGestureRecognizer(debugOwner: this), (ScaleGestureRecognizer instance) { instance ..onStart = onScaleStart @@ -424,7 +424,7 @@ class GestureDetector extends StatelessWidget { ); } - return new RawGestureDetector( + return RawGestureDetector( gestures: gestures, behavior: behavior, excludeFromSemantics: excludeFromSemantics, @@ -516,7 +516,7 @@ class RawGestureDetector extends StatefulWidget { final bool excludeFromSemantics; @override - RawGestureDetectorState createState() => new RawGestureDetectorState(); + RawGestureDetectorState createState() => RawGestureDetectorState(); } /// State for a [RawGestureDetector]. @@ -551,7 +551,7 @@ class RawGestureDetectorState extends State { void replaceGestureRecognizers(Map gestures) { assert(() { if (!context.findRenderObject().owner.debugDoingLayout) { - throw new FlutterError( + throw FlutterError( 'Unexpected call to replaceGestureRecognizers() method of RawGestureDetectorState.\n' 'The replaceGestureRecognizers() method can only be called during the layout phase. ' 'To set the gesture recognizers at other times, trigger a new build using setState() ' @@ -586,7 +586,7 @@ class RawGestureDetectorState extends State { assert(() { final Element element = context; if (element.owner.debugBuilding) { - throw new FlutterError( + throw FlutterError( 'Unexpected call to replaceSemanticsActions() method of RawGestureDetectorState.\n' 'The replaceSemanticsActions() method can only be called outside of the build phase.' ); @@ -639,9 +639,9 @@ class RawGestureDetectorState extends State { final TapGestureRecognizer recognizer = _recognizers[TapGestureRecognizer]; assert(recognizer != null); if (recognizer.onTapDown != null) - recognizer.onTapDown(new TapDownDetails()); + recognizer.onTapDown(TapDownDetails()); if (recognizer.onTapUp != null) - recognizer.onTapUp(new TapUpDetails()); + recognizer.onTapUp(TapUpDetails()); if (recognizer.onTap != null) recognizer.onTap(); } @@ -658,13 +658,13 @@ class RawGestureDetectorState extends State { final HorizontalDragGestureRecognizer recognizer = _recognizers[HorizontalDragGestureRecognizer]; if (recognizer != null) { if (recognizer.onDown != null) - recognizer.onDown(new DragDownDetails()); + recognizer.onDown(DragDownDetails()); if (recognizer.onStart != null) - recognizer.onStart(new DragStartDetails()); + recognizer.onStart(DragStartDetails()); if (recognizer.onUpdate != null) recognizer.onUpdate(updateDetails); if (recognizer.onEnd != null) - recognizer.onEnd(new DragEndDetails(primaryVelocity: 0.0)); + recognizer.onEnd(DragEndDetails(primaryVelocity: 0.0)); return; } } @@ -672,13 +672,13 @@ class RawGestureDetectorState extends State { final PanGestureRecognizer recognizer = _recognizers[PanGestureRecognizer]; if (recognizer != null) { if (recognizer.onDown != null) - recognizer.onDown(new DragDownDetails()); + recognizer.onDown(DragDownDetails()); if (recognizer.onStart != null) - recognizer.onStart(new DragStartDetails()); + recognizer.onStart(DragStartDetails()); if (recognizer.onUpdate != null) recognizer.onUpdate(updateDetails); if (recognizer.onEnd != null) - recognizer.onEnd(new DragEndDetails()); + recognizer.onEnd(DragEndDetails()); return; } } @@ -689,13 +689,13 @@ class RawGestureDetectorState extends State { final VerticalDragGestureRecognizer recognizer = _recognizers[VerticalDragGestureRecognizer]; if (recognizer != null) { if (recognizer.onDown != null) - recognizer.onDown(new DragDownDetails()); + recognizer.onDown(DragDownDetails()); if (recognizer.onStart != null) - recognizer.onStart(new DragStartDetails()); + recognizer.onStart(DragStartDetails()); if (recognizer.onUpdate != null) recognizer.onUpdate(updateDetails); if (recognizer.onEnd != null) - recognizer.onEnd(new DragEndDetails(primaryVelocity: 0.0)); + recognizer.onEnd(DragEndDetails(primaryVelocity: 0.0)); return; } } @@ -703,13 +703,13 @@ class RawGestureDetectorState extends State { final PanGestureRecognizer recognizer = _recognizers[PanGestureRecognizer]; if (recognizer != null) { if (recognizer.onDown != null) - recognizer.onDown(new DragDownDetails()); + recognizer.onDown(DragDownDetails()); if (recognizer.onStart != null) - recognizer.onStart(new DragStartDetails()); + recognizer.onStart(DragStartDetails()); if (recognizer.onUpdate != null) recognizer.onUpdate(updateDetails); if (recognizer.onEnd != null) - recognizer.onEnd(new DragEndDetails()); + recognizer.onEnd(DragEndDetails()); return; } } @@ -717,13 +717,13 @@ class RawGestureDetectorState extends State { @override Widget build(BuildContext context) { - Widget result = new Listener( + Widget result = Listener( onPointerDown: _handlePointerDown, behavior: widget.behavior ?? _defaultBehavior, child: widget.child ); if (!widget.excludeFromSemantics) - result = new _GestureSemantics(owner: this, child: result); + result = _GestureSemantics(owner: this, child: result); return result; } @@ -731,13 +731,13 @@ class RawGestureDetectorState extends State { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); if (_recognizers == null) { - properties.add(new DiagnosticsNode.message('DISPOSED')); + properties.add(DiagnosticsNode.message('DISPOSED')); } else { final List gestures = _recognizers.values.map((GestureRecognizer recognizer) => recognizer.debugDescription).toList(); - properties.add(new IterableProperty('gestures', gestures, ifEmpty: '')); - properties.add(new IterableProperty('recognizers', _recognizers.values, level: DiagnosticLevel.fine)); + properties.add(IterableProperty('gestures', gestures, ifEmpty: '')); + properties.add(IterableProperty('recognizers', _recognizers.values, level: DiagnosticLevel.fine)); } - properties.add(new EnumProperty('behavior', widget.behavior, defaultValue: null)); + properties.add(EnumProperty('behavior', widget.behavior, defaultValue: null)); } } @@ -752,7 +752,7 @@ class _GestureSemantics extends SingleChildRenderObjectWidget { @override RenderSemanticsGestureHandler createRenderObject(BuildContext context) { - return new RenderSemanticsGestureHandler( + return RenderSemanticsGestureHandler( onTap: _onTapHandler, onLongPress: _onLongPressHandler, onHorizontalDragUpdate: _onHorizontalDragUpdateHandler, diff --git a/packages/flutter/lib/src/widgets/grid_paper.dart b/packages/flutter/lib/src/widgets/grid_paper.dart index 647e6ffcfa..516348dc7f 100644 --- a/packages/flutter/lib/src/widgets/grid_paper.dart +++ b/packages/flutter/lib/src/widgets/grid_paper.dart @@ -22,16 +22,16 @@ class _GridPaperPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint linePaint = new Paint() + final Paint linePaint = Paint() ..color = color; final double allDivisions = (divisions * subdivisions).toDouble(); for (double x = 0.0; x <= size.width; x += interval / allDivisions) { linePaint.strokeWidth = (x % interval == 0.0) ? 1.0 : (x % (interval / subdivisions) == 0.0) ? 0.5 : 0.25; - canvas.drawLine(new Offset(x, 0.0), new Offset(x, size.height), linePaint); + canvas.drawLine(Offset(x, 0.0), Offset(x, size.height), linePaint); } for (double y = 0.0; y <= size.height; y += interval / allDivisions) { linePaint.strokeWidth = (y % interval == 0.0) ? 1.0 : (y % (interval / subdivisions) == 0.0) ? 0.5 : 0.25; - canvas.drawLine(new Offset(0.0, y), new Offset(size.width, y), linePaint); + canvas.drawLine(Offset(0.0, y), Offset(size.width, y), linePaint); } } @@ -107,8 +107,8 @@ class GridPaper extends StatelessWidget { @override Widget build(BuildContext context) { - return new CustomPaint( - foregroundPainter: new _GridPaperPainter( + return CustomPaint( + foregroundPainter: _GridPaperPainter( color: color, interval: interval, divisions: divisions, diff --git a/packages/flutter/lib/src/widgets/heroes.dart b/packages/flutter/lib/src/widgets/heroes.dart index ce2c080173..97bcbfcfe9 100644 --- a/packages/flutter/lib/src/widgets/heroes.dart +++ b/packages/flutter/lib/src/widgets/heroes.dart @@ -188,7 +188,7 @@ class Hero extends StatefulWidget { assert(tag != null); assert(() { if (result.containsKey(tag)) { - throw new FlutterError( + throw FlutterError( 'There are multiple heroes that share the same tag within a subtree.\n' 'Within each subtree for which heroes are to be animated (typically a PageRoute subtree), ' 'each Hero must have a unique non-null tag.\n' @@ -213,17 +213,17 @@ class Hero extends StatefulWidget { } @override - _HeroState createState() => new _HeroState(); + _HeroState createState() => _HeroState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('tag', tag)); + properties.add(DiagnosticsProperty('tag', tag)); } } class _HeroState extends State { - final GlobalKey _key = new GlobalKey(); + final GlobalKey _key = GlobalKey(); Size _placeholderSize; void startFlight() { @@ -247,7 +247,7 @@ class _HeroState extends State { Widget build(BuildContext context) { if (_placeholderSize != null) { if (widget.placeholderBuilder == null) { - return new SizedBox( + return SizedBox( width: _placeholderSize.width, height: _placeholderSize.height ); @@ -255,7 +255,7 @@ class _HeroState extends State { return widget.placeholderBuilder(context, widget.child); } } - return new KeyedSubtree( + return KeyedSubtree( key: _key, child: widget.child, ); @@ -289,7 +289,7 @@ class _HeroFlightManifest { Object get tag => fromHero.widget.tag; Animation get animation { - return new CurvedAnimation( + return CurvedAnimation( parent: (type == HeroFlightDirection.push) ? toRoute.animation : fromRoute.animation, curve: Curves.fastOutSlowIn, ); @@ -305,7 +305,7 @@ class _HeroFlightManifest { // Builds the in-flight hero widget. class _HeroFlight { _HeroFlight(this.onFlightEnded) { - _proxyAnimation = new ProxyAnimation()..addStatusListener(_handleAnimationUpdate); + _proxyAnimation = ProxyAnimation()..addStatusListener(_handleAnimationUpdate); } final _OnFlightEnded onFlightEnded; @@ -323,7 +323,7 @@ class _HeroFlight { final CreateRectTween createRectTween = manifest.toHero.widget.createRectTween ?? manifest.createRectTween; if (createRectTween != null) return createRectTween(begin, end); - return new RectTween(begin: begin, end: end); + return RectTween(begin: begin, end: end); } // The OverlayEntry WidgetBuilder callback for the hero's overlay. @@ -338,7 +338,7 @@ class _HeroFlight { ); assert(shuttle != null); - return new AnimatedBuilder( + return AnimatedBuilder( animation: _proxyAnimation, child: shuttle, builder: (BuildContext context, Widget child) { @@ -347,8 +347,8 @@ class _HeroFlight { // The toHero no longer exists or it's no longer the flight's destination. // Continue flying while fading out. if (_heroOpacity.isCompleted) { - _heroOpacity = new Tween(begin: 1.0, end: 0.0) - .chain(new CurveTween(curve: new Interval(_proxyAnimation.value, 1.0))) + _heroOpacity = Tween(begin: 1.0, end: 0.0) + .chain(CurveTween(curve: Interval(_proxyAnimation.value, 1.0))) .animate(_proxyAnimation); } } else if (toHeroBox.hasSize) { @@ -364,16 +364,16 @@ class _HeroFlight { final Rect rect = heroRectTween.evaluate(_proxyAnimation); final Size size = manifest.navigatorRect.size; - final RelativeRect offsets = new RelativeRect.fromSize(rect, size); + final RelativeRect offsets = RelativeRect.fromSize(rect, size); - return new Positioned( + return Positioned( top: offsets.top, right: offsets.right, bottom: offsets.bottom, left: offsets.left, - child: new IgnorePointer( - child: new RepaintBoundary( - child: new Opacity( + child: IgnorePointer( + child: RepaintBoundary( + child: Opacity( opacity: _heroOpacity.value, child: child, ), @@ -418,7 +418,7 @@ class _HeroFlight { manifest = initialManifest; if (manifest.type == HeroFlightDirection.pop) - _proxyAnimation.parent = new ReverseAnimation(manifest.animation); + _proxyAnimation.parent = ReverseAnimation(manifest.animation); else _proxyAnimation.parent = manifest.animation; @@ -430,7 +430,7 @@ class _HeroFlight { _globalBoundingBoxFor(manifest.toHero.context), ); - overlayEntry = new OverlayEntry(builder: _buildOverlay); + overlayEntry = OverlayEntry(builder: _buildOverlay); manifest.overlay.insert(overlayEntry); } @@ -452,15 +452,15 @@ class _HeroFlight { // That's because tweens like MaterialRectArcTween may create a different // path for swapped begin and end parameters. We want the pop flight // path to be the same (in reverse) as the push flight path. - _proxyAnimation.parent = new ReverseAnimation(newManifest.animation); - heroRectTween = new ReverseTween(heroRectTween); + _proxyAnimation.parent = ReverseAnimation(newManifest.animation); + heroRectTween = ReverseTween(heroRectTween); } else if (manifest.type == HeroFlightDirection.pop && newManifest.type == HeroFlightDirection.push) { // A pop flight was interrupted by a push. assert(newManifest.animation.status == AnimationStatus.forward); assert(manifest.toHero == newManifest.fromHero); assert(manifest.toRoute == newManifest.fromRoute); - _proxyAnimation.parent = new Tween( + _proxyAnimation.parent = Tween( begin: manifest.animation.value, end: 1.0, ).animate(newManifest.animation); @@ -484,7 +484,7 @@ class _HeroFlight { shuttle = null; if (newManifest.type == HeroFlightDirection.pop) - _proxyAnimation.parent = new ReverseAnimation(newManifest.animation); + _proxyAnimation.parent = ReverseAnimation(newManifest.animation); else _proxyAnimation.parent = newManifest.animation; @@ -617,7 +617,7 @@ class HeroController extends NavigatorObserver { final HeroFlightShuttleBuilder fromShuttleBuilder = fromHeroes[tag].widget.flightShuttleBuilder; final HeroFlightShuttleBuilder toShuttleBuilder = toHeroes[tag].widget.flightShuttleBuilder; - final _HeroFlightManifest manifest = new _HeroFlightManifest( + final _HeroFlightManifest manifest = _HeroFlightManifest( type: flightType, overlay: navigator.overlay, navigatorRect: navigatorRect, @@ -633,7 +633,7 @@ class HeroController extends NavigatorObserver { if (_flights[tag] != null) _flights[tag].divert(manifest); else - _flights[tag] = new _HeroFlight(_handleFlightEnded)..start(manifest); + _flights[tag] = _HeroFlight(_handleFlightEnded)..start(manifest); } else if (_flights[tag] != null) { _flights[tag].abort(); } diff --git a/packages/flutter/lib/src/widgets/icon.dart b/packages/flutter/lib/src/widgets/icon.dart index d876dba08e..a4fbe69af1 100644 --- a/packages/flutter/lib/src/widgets/icon.dart +++ b/packages/flutter/lib/src/widgets/icon.dart @@ -122,9 +122,9 @@ class Icon extends StatelessWidget { final double iconSize = size ?? iconTheme.size; if (icon == null) { - return new Semantics( + return Semantics( label: semanticLabel, - child: new SizedBox(width: iconSize, height: iconSize) + child: SizedBox(width: iconSize, height: iconSize) ); } @@ -133,11 +133,11 @@ class Icon extends StatelessWidget { if (iconOpacity != 1.0) iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); - Widget iconWidget = new RichText( + Widget iconWidget = RichText( textDirection: textDirection, // Since we already fetched it for the assert... - text: new TextSpan( - text: new String.fromCharCode(icon.codePoint), - style: new TextStyle( + text: TextSpan( + text: String.fromCharCode(icon.codePoint), + style: TextStyle( inherit: false, color: iconColor, fontSize: iconSize, @@ -150,8 +150,8 @@ class Icon extends StatelessWidget { if (icon.matchTextDirection) { switch (textDirection) { case TextDirection.rtl: - iconWidget = new Transform( - transform: new Matrix4.identity()..scale(-1.0, 1.0, 1.0), + iconWidget = Transform( + transform: Matrix4.identity()..scale(-1.0, 1.0, 1.0), alignment: Alignment.center, transformHitTests: false, child: iconWidget, @@ -162,13 +162,13 @@ class Icon extends StatelessWidget { } } - return new Semantics( + return Semantics( label: semanticLabel, - child: new ExcludeSemantics( - child: new SizedBox( + child: ExcludeSemantics( + child: SizedBox( width: iconSize, height: iconSize, - child: new Center( + child: Center( child: iconWidget, ), ), @@ -179,8 +179,8 @@ class Icon extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('icon', icon, ifNull: '', showName: false)); - properties.add(new DoubleProperty('size', size, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('icon', icon, ifNull: '', showName: false)); + properties.add(DoubleProperty('size', size, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/widgets/icon_theme.dart b/packages/flutter/lib/src/widgets/icon_theme.dart index 1b6955de00..e407a295a9 100644 --- a/packages/flutter/lib/src/widgets/icon_theme.dart +++ b/packages/flutter/lib/src/widgets/icon_theme.dart @@ -33,9 +33,9 @@ class IconTheme extends InheritedWidget { @required IconThemeData data, @required Widget child, }) { - return new Builder( + return Builder( builder: (BuildContext context) { - return new IconTheme( + return IconTheme( key: key, data: _getInheritedIconThemeData(context).merge(data), child: child, @@ -73,6 +73,6 @@ class IconTheme extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('data', data, showName: false)); + properties.add(DiagnosticsProperty('data', data, showName: false)); } } diff --git a/packages/flutter/lib/src/widgets/icon_theme_data.dart b/packages/flutter/lib/src/widgets/icon_theme_data.dart index 51d923cbfb..75d02f7851 100644 --- a/packages/flutter/lib/src/widgets/icon_theme_data.dart +++ b/packages/flutter/lib/src/widgets/icon_theme_data.dart @@ -33,7 +33,7 @@ class IconThemeData extends Diagnosticable { /// Creates a copy of this icon theme but with the given fields replaced with /// the new values. IconThemeData copyWith({Color color, double opacity, double size}) { - return new IconThemeData( + return IconThemeData( color: color ?? this.color, opacity: opacity ?? this.opacity, size: size ?? this.size, @@ -81,7 +81,7 @@ class IconThemeData extends Diagnosticable { /// an [AnimationController]. static IconThemeData lerp(IconThemeData a, IconThemeData b, double t) { assert(t != null); - return new IconThemeData( + return IconThemeData( color: Color.lerp(a.color, b.color, t), opacity: ui.lerpDouble(a.opacity, b.opacity, t), size: ui.lerpDouble(a.size, b.size, t), @@ -104,8 +104,8 @@ class IconThemeData extends Diagnosticable { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new DoubleProperty('opacity', opacity, defaultValue: null)); - properties.add(new DoubleProperty('size', size, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DoubleProperty('opacity', opacity, defaultValue: null)); + properties.add(DoubleProperty('size', size, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/widgets/image.dart b/packages/flutter/lib/src/widgets/image.dart index dc9d74af93..147391bc3f 100644 --- a/packages/flutter/lib/src/widgets/image.dart +++ b/packages/flutter/lib/src/widgets/image.dart @@ -42,7 +42,7 @@ export 'package:flutter/painting.dart' show /// /// * [ImageProvider], which has an example showing how this might be used. ImageConfiguration createLocalImageConfiguration(BuildContext context, { Size size }) { - return new ImageConfiguration( + return ImageConfiguration( bundle: DefaultAssetBundle.of(context), devicePixelRatio: MediaQuery.of(context, nullOk: true)?.devicePixelRatio ?? 1.0, locale: Localizations.localeOf(context, nullOk: true), @@ -77,7 +77,7 @@ Future precacheImage( ImageErrorListener onError, }) { final ImageConfiguration config = createLocalImageConfiguration(context, size: size); - final Completer completer = new Completer(); + final Completer completer = Completer(); final ImageStream stream = provider.resolve(config); void listener(ImageInfo image, bool sync) { completer.complete(); @@ -87,7 +87,7 @@ Future precacheImage( if (onError != null) { onError(exception, stackTrace); } else { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( context: 'image failed to precache', library: 'image resource service', exception: exception, @@ -195,7 +195,7 @@ class Image extends StatefulWidget { this.matchTextDirection = false, this.gaplessPlayback = false, Map headers, - }) : image = new NetworkImage(src, scale: scale, headers: headers), + }) : image = NetworkImage(src, scale: scale, headers: headers), assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), @@ -229,7 +229,7 @@ class Image extends StatefulWidget { this.centerSlice, this.matchTextDirection = false, this.gaplessPlayback = false, - }) : image = new FileImage(file, scale: scale), + }) : image = FileImage(file, scale: scale), assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), @@ -369,8 +369,8 @@ class Image extends StatefulWidget { this.gaplessPlayback = false, String package, }) : image = scale != null - ? new ExactAssetImage(name, bundle: bundle, scale: scale, package: package) - : new AssetImage(name, bundle: bundle, package: package), + ? ExactAssetImage(name, bundle: bundle, scale: scale, package: package) + : AssetImage(name, bundle: bundle, package: package), assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), @@ -401,7 +401,7 @@ class Image extends StatefulWidget { this.centerSlice, this.matchTextDirection = false, this.gaplessPlayback = false, - }) : image = new MemoryImage(bytes, scale: scale), + }) : image = MemoryImage(bytes, scale: scale), assert(alignment != null), assert(repeat != null), assert(matchTextDirection != null), @@ -526,23 +526,23 @@ class Image extends StatefulWidget { final bool excludeFromSemantics; @override - _ImageState createState() => new _ImageState(); + _ImageState createState() => _ImageState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('image', image)); - properties.add(new DoubleProperty('width', width, defaultValue: null)); - properties.add(new DoubleProperty('height', height, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); - properties.add(new EnumProperty('colorBlendMode', colorBlendMode, defaultValue: null)); - properties.add(new EnumProperty('fit', fit, defaultValue: null)); - properties.add(new DiagnosticsProperty('alignment', alignment, defaultValue: null)); - properties.add(new EnumProperty('repeat', repeat, defaultValue: ImageRepeat.noRepeat)); - properties.add(new DiagnosticsProperty('centerSlice', centerSlice, defaultValue: null)); - properties.add(new FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction')); - properties.add(new StringProperty('semanticLabel', semanticLabel, defaultValue: null)); - properties.add(new DiagnosticsProperty('this.excludeFromSemantics', excludeFromSemantics)); + properties.add(DiagnosticsProperty('image', image)); + properties.add(DoubleProperty('width', width, defaultValue: null)); + properties.add(DoubleProperty('height', height, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(EnumProperty('colorBlendMode', colorBlendMode, defaultValue: null)); + properties.add(EnumProperty('fit', fit, defaultValue: null)); + properties.add(DiagnosticsProperty('alignment', alignment, defaultValue: null)); + properties.add(EnumProperty('repeat', repeat, defaultValue: ImageRepeat.noRepeat)); + properties.add(DiagnosticsProperty('centerSlice', centerSlice, defaultValue: null)); + properties.add(FlagProperty('matchTextDirection', value: matchTextDirection, ifTrue: 'match text direction')); + properties.add(StringProperty('semanticLabel', semanticLabel, defaultValue: null)); + properties.add(DiagnosticsProperty('this.excludeFromSemantics', excludeFromSemantics)); } } @@ -580,7 +580,7 @@ class _ImageState extends State { final ImageStream newStream = widget.image.resolve(createLocalImageConfiguration( context, - size: widget.width != null && widget.height != null ? new Size(widget.width, widget.height) : null + size: widget.width != null && widget.height != null ? Size(widget.width, widget.height) : null )); assert(newStream != null); _updateSourceStream(newStream); @@ -633,7 +633,7 @@ class _ImageState extends State { @override Widget build(BuildContext context) { - final RawImage image = new RawImage( + final RawImage image = RawImage( image: _imageInfo?.image, width: widget.width, height: widget.height, @@ -648,7 +648,7 @@ class _ImageState extends State { ); if (widget.excludeFromSemantics) return image; - return new Semantics( + return Semantics( container: widget.semanticLabel != null, image: true, label: widget.semanticLabel == null ? '' : widget.semanticLabel, @@ -659,7 +659,7 @@ class _ImageState extends State { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('stream', _imageStream)); - description.add(new DiagnosticsProperty('pixels', _imageInfo)); + description.add(DiagnosticsProperty('stream', _imageStream)); + description.add(DiagnosticsProperty('pixels', _imageInfo)); } } diff --git a/packages/flutter/lib/src/widgets/image_icon.dart b/packages/flutter/lib/src/widgets/image_icon.dart index beeed7bbc7..8bf51987c4 100644 --- a/packages/flutter/lib/src/widgets/image_icon.dart +++ b/packages/flutter/lib/src/widgets/image_icon.dart @@ -71,7 +71,7 @@ class ImageIcon extends StatelessWidget { final double iconSize = size ?? iconTheme.size; if (image == null) - return new Semantics( + return Semantics( label: semanticLabel, child: SizedBox(width: iconSize, height: iconSize) ); @@ -82,7 +82,7 @@ class ImageIcon extends StatelessWidget { if (iconOpacity != null && iconOpacity != 1.0) iconColor = iconColor.withOpacity(iconColor.opacity * iconOpacity); - return new Semantics( + return Semantics( label: semanticLabel, child: Image( image: image, @@ -99,8 +99,8 @@ class ImageIcon extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('image', image, ifNull: '', showName: false)); - properties.add(new DoubleProperty('size', size, defaultValue: null)); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(DiagnosticsProperty('image', image, ifNull: '', showName: false)); + properties.add(DoubleProperty('size', size, defaultValue: null)); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/widgets/implicit_animations.dart b/packages/flutter/lib/src/widgets/implicit_animations.dart index e1bbeeca5f..3b32f66580 100644 --- a/packages/flutter/lib/src/widgets/implicit_animations.dart +++ b/packages/flutter/lib/src/widgets/implicit_animations.dart @@ -165,12 +165,12 @@ class Matrix4Tween extends Tween { Matrix4 lerp(double t) { assert(begin != null); assert(end != null); - final Vector3 beginTranslation = new Vector3.zero(); - final Vector3 endTranslation = new Vector3.zero(); - final Quaternion beginRotation = new Quaternion.identity(); - final Quaternion endRotation = new Quaternion.identity(); - final Vector3 beginScale = new Vector3.zero(); - final Vector3 endScale = new Vector3.zero(); + final Vector3 beginTranslation = Vector3.zero(); + final Vector3 endTranslation = Vector3.zero(); + final Quaternion beginRotation = Quaternion.identity(); + final Quaternion endRotation = Quaternion.identity(); + final Vector3 beginScale = Vector3.zero(); + final Vector3 endScale = Vector3.zero(); begin.decompose(beginTranslation, beginRotation, beginScale); end.decompose(endTranslation, endRotation, endScale); final Vector3 lerpTranslation = @@ -179,7 +179,7 @@ class Matrix4Tween extends Tween { final Quaternion lerpRotation = (beginRotation.scaled(1.0 - t) + endRotation.scaled(t)).normalized(); final Vector3 lerpScale = beginScale * (1.0 - t) + endScale * t; - return new Matrix4.compose(lerpTranslation, lerpRotation, lerpScale); + return Matrix4.compose(lerpTranslation, lerpRotation, lerpScale); } } @@ -235,7 +235,7 @@ abstract class ImplicitlyAnimatedWidget extends StatefulWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new IntProperty('duration', duration.inMilliseconds, unit: 'ms')); + properties.add(IntProperty('duration', duration.inMilliseconds, unit: 'ms')); } } @@ -270,7 +270,7 @@ abstract class ImplicitlyAnimatedWidgetState @override void initState() { super.initState(); - _controller = new AnimationController( + _controller = AnimationController( duration: widget.duration, debugLabel: '${widget.toStringShort()}', vsync: this, @@ -300,7 +300,7 @@ abstract class ImplicitlyAnimatedWidgetState void _updateCurve() { if (widget.curve != null) - _animation = new CurvedAnimation(parent: _controller, curve: widget.curve); + _animation = CurvedAnimation(parent: _controller, curve: widget.curve); else _animation = _controller; } @@ -445,11 +445,11 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget { 'Cannot provide both a color and a decoration\n' 'The color argument is just a shorthand for "decoration: new BoxDecoration(backgroundColor: color)".' ), - decoration = decoration ?? (color != null ? new BoxDecoration(color: color) : null), + decoration = decoration ?? (color != null ? BoxDecoration(color: color) : null), constraints = (width != null || height != null) ? constraints?.tighten(width: width, height: height) - ?? new BoxConstraints.tightFor(width: width, height: height) + ?? BoxConstraints.tightFor(width: width, height: height) : constraints, super(key: key, curve: curve, duration: duration); @@ -508,18 +508,18 @@ class AnimatedContainer extends ImplicitlyAnimatedWidget { final Matrix4 transform; @override - _AnimatedContainerState createState() => new _AnimatedContainerState(); + _AnimatedContainerState createState() => _AnimatedContainerState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment, showName: false, defaultValue: null)); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); - properties.add(new DiagnosticsProperty('bg', decoration, defaultValue: null)); - properties.add(new DiagnosticsProperty('fg', foregroundDecoration, defaultValue: null)); - properties.add(new DiagnosticsProperty('constraints', constraints, defaultValue: null, showName: false)); - properties.add(new DiagnosticsProperty('margin', margin, defaultValue: null)); - properties.add(new ObjectFlagProperty.has('transform', transform)); + properties.add(DiagnosticsProperty('alignment', alignment, showName: false, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('bg', decoration, defaultValue: null)); + properties.add(DiagnosticsProperty('fg', foregroundDecoration, defaultValue: null)); + properties.add(DiagnosticsProperty('constraints', constraints, defaultValue: null, showName: false)); + properties.add(DiagnosticsProperty('margin', margin, defaultValue: null)); + properties.add(ObjectFlagProperty.has('transform', transform)); } } @@ -534,18 +534,18 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState @override void forEachTween(TweenVisitor visitor) { - _alignment = visitor(_alignment, widget.alignment, (dynamic value) => new AlignmentGeometryTween(begin: value)); - _padding = visitor(_padding, widget.padding, (dynamic value) => new EdgeInsetsGeometryTween(begin: value)); - _decoration = visitor(_decoration, widget.decoration, (dynamic value) => new DecorationTween(begin: value)); - _foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => new DecorationTween(begin: value)); - _constraints = visitor(_constraints, widget.constraints, (dynamic value) => new BoxConstraintsTween(begin: value)); - _margin = visitor(_margin, widget.margin, (dynamic value) => new EdgeInsetsGeometryTween(begin: value)); - _transform = visitor(_transform, widget.transform, (dynamic value) => new Matrix4Tween(begin: value)); + _alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value)); + _padding = visitor(_padding, widget.padding, (dynamic value) => EdgeInsetsGeometryTween(begin: value)); + _decoration = visitor(_decoration, widget.decoration, (dynamic value) => DecorationTween(begin: value)); + _foregroundDecoration = visitor(_foregroundDecoration, widget.foregroundDecoration, (dynamic value) => DecorationTween(begin: value)); + _constraints = visitor(_constraints, widget.constraints, (dynamic value) => BoxConstraintsTween(begin: value)); + _margin = visitor(_margin, widget.margin, (dynamic value) => EdgeInsetsGeometryTween(begin: value)); + _transform = visitor(_transform, widget.transform, (dynamic value) => Matrix4Tween(begin: value)); } @override Widget build(BuildContext context) { - return new Container( + return Container( child: widget.child, alignment: _alignment?.evaluate(animation), padding: _padding?.evaluate(animation), @@ -560,13 +560,13 @@ class _AnimatedContainerState extends AnimatedWidgetBaseState @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('alignment', _alignment, showName: false, defaultValue: null)); - description.add(new DiagnosticsProperty('padding', _padding, defaultValue: null)); - description.add(new DiagnosticsProperty('bg', _decoration, defaultValue: null)); - description.add(new DiagnosticsProperty('fg', _foregroundDecoration, defaultValue: null)); - description.add(new DiagnosticsProperty('constraints', _constraints, showName: false, defaultValue: null)); - description.add(new DiagnosticsProperty('margin', _margin, defaultValue: null)); - description.add(new ObjectFlagProperty.has('transform', _transform)); + description.add(DiagnosticsProperty('alignment', _alignment, showName: false, defaultValue: null)); + description.add(DiagnosticsProperty('padding', _padding, defaultValue: null)); + description.add(DiagnosticsProperty('bg', _decoration, defaultValue: null)); + description.add(DiagnosticsProperty('fg', _foregroundDecoration, defaultValue: null)); + description.add(DiagnosticsProperty('constraints', _constraints, showName: false, defaultValue: null)); + description.add(DiagnosticsProperty('margin', _margin, defaultValue: null)); + description.add(ObjectFlagProperty.has('transform', _transform)); } } @@ -606,12 +606,12 @@ class AnimatedPadding extends ImplicitlyAnimatedWidget { final Widget child; @override - _AnimatedPaddingState createState() => new _AnimatedPaddingState(); + _AnimatedPaddingState createState() => _AnimatedPaddingState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('padding', padding)); + properties.add(DiagnosticsProperty('padding', padding)); } } @@ -620,12 +620,12 @@ class _AnimatedPaddingState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { - _padding = visitor(_padding, widget.padding, (dynamic value) => new EdgeInsetsGeometryTween(begin: value)); + _padding = visitor(_padding, widget.padding, (dynamic value) => EdgeInsetsGeometryTween(begin: value)); } @override Widget build(BuildContext context) { - return new Padding( + return Padding( padding: _padding.evaluate(animation), child: widget.child, ); @@ -634,7 +634,7 @@ class _AnimatedPaddingState extends AnimatedWidgetBaseState { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('padding', _padding, defaultValue: null)); + description.add(DiagnosticsProperty('padding', _padding, defaultValue: null)); } } @@ -691,12 +691,12 @@ class AnimatedAlign extends ImplicitlyAnimatedWidget { final Widget child; @override - _AnimatedAlignState createState() => new _AnimatedAlignState(); + _AnimatedAlignState createState() => _AnimatedAlignState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('alignment', alignment)); + properties.add(DiagnosticsProperty('alignment', alignment)); } } @@ -705,12 +705,12 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState { @override void forEachTween(TweenVisitor visitor) { - _alignment = visitor(_alignment, widget.alignment, (dynamic value) => new AlignmentGeometryTween(begin: value)); + _alignment = visitor(_alignment, widget.alignment, (dynamic value) => AlignmentGeometryTween(begin: value)); } @override Widget build(BuildContext context) { - return new Align( + return Align( alignment: _alignment.evaluate(animation), child: widget.child, ); @@ -719,7 +719,7 @@ class _AnimatedAlignState extends AnimatedWidgetBaseState { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('alignment', _alignment, defaultValue: null)); + description.add(DiagnosticsProperty('alignment', _alignment, defaultValue: null)); } } @@ -815,17 +815,17 @@ class AnimatedPositioned extends ImplicitlyAnimatedWidget { final double height; @override - _AnimatedPositionedState createState() => new _AnimatedPositionedState(); + _AnimatedPositionedState createState() => _AnimatedPositionedState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('left', left, defaultValue: null)); - properties.add(new DoubleProperty('top', top, defaultValue: null)); - properties.add(new DoubleProperty('right', right, defaultValue: null)); - properties.add(new DoubleProperty('bottom', bottom, defaultValue: null)); - properties.add(new DoubleProperty('width', width, defaultValue: null)); - properties.add(new DoubleProperty('height', height, defaultValue: null)); + properties.add(DoubleProperty('left', left, defaultValue: null)); + properties.add(DoubleProperty('top', top, defaultValue: null)); + properties.add(DoubleProperty('right', right, defaultValue: null)); + properties.add(DoubleProperty('bottom', bottom, defaultValue: null)); + properties.add(DoubleProperty('width', width, defaultValue: null)); + properties.add(DoubleProperty('height', height, defaultValue: null)); } } @@ -839,17 +839,17 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState visitor) { - _left = visitor(_left, widget.left, (dynamic value) => new Tween(begin: value)); - _top = visitor(_top, widget.top, (dynamic value) => new Tween(begin: value)); - _right = visitor(_right, widget.right, (dynamic value) => new Tween(begin: value)); - _bottom = visitor(_bottom, widget.bottom, (dynamic value) => new Tween(begin: value)); - _width = visitor(_width, widget.width, (dynamic value) => new Tween(begin: value)); - _height = visitor(_height, widget.height, (dynamic value) => new Tween(begin: value)); + _left = visitor(_left, widget.left, (dynamic value) => Tween(begin: value)); + _top = visitor(_top, widget.top, (dynamic value) => Tween(begin: value)); + _right = visitor(_right, widget.right, (dynamic value) => Tween(begin: value)); + _bottom = visitor(_bottom, widget.bottom, (dynamic value) => Tween(begin: value)); + _width = visitor(_width, widget.width, (dynamic value) => Tween(begin: value)); + _height = visitor(_height, widget.height, (dynamic value) => Tween(begin: value)); } @override Widget build(BuildContext context) { - return new Positioned( + return Positioned( child: widget.child, left: _left?.evaluate(animation), top: _top?.evaluate(animation), @@ -863,12 +863,12 @@ class _AnimatedPositionedState extends AnimatedWidgetBaseState>.has('left', _left)); - description.add(new ObjectFlagProperty>.has('top', _top)); - description.add(new ObjectFlagProperty>.has('right', _right)); - description.add(new ObjectFlagProperty>.has('bottom', _bottom)); - description.add(new ObjectFlagProperty>.has('width', _width)); - description.add(new ObjectFlagProperty>.has('height', _height)); + description.add(ObjectFlagProperty>.has('left', _left)); + description.add(ObjectFlagProperty>.has('top', _top)); + description.add(ObjectFlagProperty>.has('right', _right)); + description.add(ObjectFlagProperty>.has('bottom', _bottom)); + description.add(ObjectFlagProperty>.has('width', _width)); + description.add(ObjectFlagProperty>.has('height', _height)); } } @@ -949,17 +949,17 @@ class AnimatedPositionedDirectional extends ImplicitlyAnimatedWidget { final double height; @override - _AnimatedPositionedDirectionalState createState() => new _AnimatedPositionedDirectionalState(); + _AnimatedPositionedDirectionalState createState() => _AnimatedPositionedDirectionalState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('start', start, defaultValue: null)); - properties.add(new DoubleProperty('top', top, defaultValue: null)); - properties.add(new DoubleProperty('end', end, defaultValue: null)); - properties.add(new DoubleProperty('bottom', bottom, defaultValue: null)); - properties.add(new DoubleProperty('width', width, defaultValue: null)); - properties.add(new DoubleProperty('height', height, defaultValue: null)); + properties.add(DoubleProperty('start', start, defaultValue: null)); + properties.add(DoubleProperty('top', top, defaultValue: null)); + properties.add(DoubleProperty('end', end, defaultValue: null)); + properties.add(DoubleProperty('bottom', bottom, defaultValue: null)); + properties.add(DoubleProperty('width', width, defaultValue: null)); + properties.add(DoubleProperty('height', height, defaultValue: null)); } } @@ -973,18 +973,18 @@ class _AnimatedPositionedDirectionalState extends AnimatedWidgetBaseState visitor) { - _start = visitor(_start, widget.start, (dynamic value) => new Tween(begin: value)); - _top = visitor(_top, widget.top, (dynamic value) => new Tween(begin: value)); - _end = visitor(_end, widget.end, (dynamic value) => new Tween(begin: value)); - _bottom = visitor(_bottom, widget.bottom, (dynamic value) => new Tween(begin: value)); - _width = visitor(_width, widget.width, (dynamic value) => new Tween(begin: value)); - _height = visitor(_height, widget.height, (dynamic value) => new Tween(begin: value)); + _start = visitor(_start, widget.start, (dynamic value) => Tween(begin: value)); + _top = visitor(_top, widget.top, (dynamic value) => Tween(begin: value)); + _end = visitor(_end, widget.end, (dynamic value) => Tween(begin: value)); + _bottom = visitor(_bottom, widget.bottom, (dynamic value) => Tween(begin: value)); + _width = visitor(_width, widget.width, (dynamic value) => Tween(begin: value)); + _height = visitor(_height, widget.height, (dynamic value) => Tween(begin: value)); } @override Widget build(BuildContext context) { assert(debugCheckHasDirectionality(context)); - return new Positioned.directional( + return Positioned.directional( textDirection: Directionality.of(context), child: widget.child, start: _start?.evaluate(animation), @@ -999,12 +999,12 @@ class _AnimatedPositionedDirectionalState extends AnimatedWidgetBaseState>.has('start', _start)); - description.add(new ObjectFlagProperty>.has('top', _top)); - description.add(new ObjectFlagProperty>.has('end', _end)); - description.add(new ObjectFlagProperty>.has('bottom', _bottom)); - description.add(new ObjectFlagProperty>.has('width', _width)); - description.add(new ObjectFlagProperty>.has('height', _height)); + description.add(ObjectFlagProperty>.has('start', _start)); + description.add(ObjectFlagProperty>.has('top', _top)); + description.add(ObjectFlagProperty>.has('end', _end)); + description.add(ObjectFlagProperty>.has('bottom', _bottom)); + description.add(ObjectFlagProperty>.has('width', _width)); + description.add(ObjectFlagProperty>.has('height', _height)); } } @@ -1085,12 +1085,12 @@ class AnimatedOpacity extends ImplicitlyAnimatedWidget { final double opacity; @override - _AnimatedOpacityState createState() => new _AnimatedOpacityState(); + _AnimatedOpacityState createState() => _AnimatedOpacityState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('opacity', opacity)); + properties.add(DoubleProperty('opacity', opacity)); } } @@ -1100,7 +1100,7 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState visitor) { - _opacity = visitor(_opacity, widget.opacity, (dynamic value) => new Tween(begin: value)); + _opacity = visitor(_opacity, widget.opacity, (dynamic value) => Tween(begin: value)); } @override @@ -1110,7 +1110,7 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState new _AnimatedDefaultTextStyleState(); + _AnimatedDefaultTextStyleState createState() => _AnimatedDefaultTextStyleState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); style?.debugFillProperties(properties); - properties.add(new EnumProperty('textAlign', textAlign, defaultValue: null)); - properties.add(new FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); - properties.add(new EnumProperty('overflow', overflow, defaultValue: null)); - properties.add(new IntProperty('maxLines', maxLines, defaultValue: null)); + properties.add(EnumProperty('textAlign', textAlign, defaultValue: null)); + properties.add(FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); + properties.add(EnumProperty('overflow', overflow, defaultValue: null)); + properties.add(IntProperty('maxLines', maxLines, defaultValue: null)); } } @@ -1205,12 +1205,12 @@ class _AnimatedDefaultTextStyleState extends AnimatedWidgetBaseState visitor) { - _style = visitor(_style, widget.style, (dynamic value) => new TextStyleTween(begin: value)); + _style = visitor(_style, widget.style, (dynamic value) => TextStyleTween(begin: value)); } @override Widget build(BuildContext context) { - return new DefaultTextStyle( + return DefaultTextStyle( style: _style.evaluate(animation), textAlign: widget.textAlign, softWrap: widget.softWrap, @@ -1300,18 +1300,18 @@ class AnimatedPhysicalModel extends ImplicitlyAnimatedWidget { final bool animateShadowColor; @override - _AnimatedPhysicalModelState createState() => new _AnimatedPhysicalModelState(); + _AnimatedPhysicalModelState createState() => _AnimatedPhysicalModelState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('shape', shape)); - properties.add(new DiagnosticsProperty('borderRadius', borderRadius)); - properties.add(new DoubleProperty('elevation', elevation)); - properties.add(new DiagnosticsProperty('color', color)); - properties.add(new DiagnosticsProperty('animateColor', animateColor)); - properties.add(new DiagnosticsProperty('shadowColor', shadowColor)); - properties.add(new DiagnosticsProperty('animateShadowColor', animateShadowColor)); + properties.add(EnumProperty('shape', shape)); + properties.add(DiagnosticsProperty('borderRadius', borderRadius)); + properties.add(DoubleProperty('elevation', elevation)); + properties.add(DiagnosticsProperty('color', color)); + properties.add(DiagnosticsProperty('animateColor', animateColor)); + properties.add(DiagnosticsProperty('shadowColor', shadowColor)); + properties.add(DiagnosticsProperty('animateShadowColor', animateShadowColor)); } } @@ -1323,15 +1323,15 @@ class _AnimatedPhysicalModelState extends AnimatedWidgetBaseState visitor) { - _borderRadius = visitor(_borderRadius, widget.borderRadius, (dynamic value) => new BorderRadiusTween(begin: value)); - _elevation = visitor(_elevation, widget.elevation, (dynamic value) => new Tween(begin: value)); - _color = visitor(_color, widget.color, (dynamic value) => new ColorTween(begin: value)); - _shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => new ColorTween(begin: value)); + _borderRadius = visitor(_borderRadius, widget.borderRadius, (dynamic value) => BorderRadiusTween(begin: value)); + _elevation = visitor(_elevation, widget.elevation, (dynamic value) => Tween(begin: value)); + _color = visitor(_color, widget.color, (dynamic value) => ColorTween(begin: value)); + _shadowColor = visitor(_shadowColor, widget.shadowColor, (dynamic value) => ColorTween(begin: value)); } @override Widget build(BuildContext context) { - return new PhysicalModel( + return PhysicalModel( child: widget.child, shape: widget.shape, clipBehavior: widget.clipBehavior, diff --git a/packages/flutter/lib/src/widgets/inherited_model.dart b/packages/flutter/lib/src/widgets/inherited_model.dart index 87dcf6088f..274878da8d 100644 --- a/packages/flutter/lib/src/widgets/inherited_model.dart +++ b/packages/flutter/lib/src/widgets/inherited_model.dart @@ -90,7 +90,7 @@ abstract class InheritedModel extends InheritedWidget { const InheritedModel({ Key key, Widget child }) : super(key: key, child: child); @override - InheritedModelElement createElement() => new InheritedModelElement(this); + InheritedModelElement createElement() => InheritedModelElement(this); /// Return true if the changes between this model and [oldWidget] match any /// of the [dependencies]. @@ -179,10 +179,10 @@ class InheritedModelElement extends InheritedElement { return; if (aspect == null) { - setDependencies(dependent, new HashSet()); + setDependencies(dependent, HashSet()); } else { assert(aspect is T); - setDependencies(dependent, (dependencies ?? new HashSet())..add(aspect)); + setDependencies(dependent, (dependencies ?? HashSet())..add(aspect)); } } diff --git a/packages/flutter/lib/src/widgets/layout_builder.dart b/packages/flutter/lib/src/widgets/layout_builder.dart index 6b6f321159..2b8f9cf566 100644 --- a/packages/flutter/lib/src/widgets/layout_builder.dart +++ b/packages/flutter/lib/src/widgets/layout_builder.dart @@ -43,10 +43,10 @@ class LayoutBuilder extends RenderObjectWidget { final LayoutWidgetBuilder builder; @override - _LayoutBuilderElement createElement() => new _LayoutBuilderElement(this); + _LayoutBuilderElement createElement() => _LayoutBuilderElement(this); @override - _RenderLayoutBuilder createRenderObject(BuildContext context) => new _RenderLayoutBuilder(); + _RenderLayoutBuilder createRenderObject(BuildContext context) => _RenderLayoutBuilder(); // updateRenderObject is redundant with the logic in the LayoutBuilderElement below. } @@ -164,7 +164,7 @@ class _RenderLayoutBuilder extends RenderBox with RenderObjectWithChildMixin new _FixedExtentScrollableState(); + _FixedExtentScrollableState createState() => _FixedExtentScrollableState(); } /// This [ScrollContext] is used by [_FixedExtentScrollPosition] to read the @@ -467,7 +467,7 @@ class FixedExtentScrollPhysics extends ScrollPhysics { @override FixedExtentScrollPhysics applyTo(ScrollPhysics ancestor) { - return new FixedExtentScrollPhysics(parent: buildParent(ancestor)); + return FixedExtentScrollPhysics(parent: buildParent(ancestor)); } @override @@ -526,7 +526,7 @@ class FixedExtentScrollPhysics extends ScrollPhysics { // If we're going to end back at the same item because initial velocity // is too low to break past it, use a spring simulation to get back. if (settlingItemIndex == metrics.itemIndex) { - return new SpringSimulation( + return SpringSimulation( spring, metrics.pixels, settlingPixels, @@ -538,7 +538,7 @@ class FixedExtentScrollPhysics extends ScrollPhysics { // Scenario 5: // Create a new friction simulation except the drag will be tweaked to land // exactly on the item closest to the natural stopping point. - return new FrictionSimulation.through( + return FrictionSimulation.through( metrics.pixels, settlingPixels, velocity, @@ -590,7 +590,7 @@ class ListWheelScrollView extends StatefulWidget { !renderChildrenOutsideViewport || !clipToSize, RenderListWheelViewport.clipToSizeAndRenderChildrenOutsideViewportConflict, ), - childDelegate = new ListWheelChildListDelegate(children: children), + childDelegate = ListWheelChildListDelegate(children: children), super(key: key); /// Constructs a list in which children are scrolled a wheel. Its children @@ -683,7 +683,7 @@ class ListWheelScrollView extends StatefulWidget { final ListWheelChildDelegate childDelegate; @override - _ListWheelScrollViewState createState() => new _ListWheelScrollViewState(); + _ListWheelScrollViewState createState() => _ListWheelScrollViewState(); } class _ListWheelScrollViewState extends State { @@ -693,7 +693,7 @@ class _ListWheelScrollViewState extends State { @override void initState() { super.initState(); - scrollController = widget.controller ?? new FixedExtentScrollController(); + scrollController = widget.controller ?? FixedExtentScrollController(); if (widget.controller is FixedExtentScrollController) { final FixedExtentScrollController controller = widget.controller; _lastReportedItemIndex = controller.initialItem; @@ -714,7 +714,7 @@ class _ListWheelScrollViewState extends State { @override Widget build(BuildContext context) { - return new NotificationListener( + return NotificationListener( onNotification: (ScrollNotification notification) { if (notification.depth == 0 && widget.onSelectedItemChanged != null @@ -730,12 +730,12 @@ class _ListWheelScrollViewState extends State { } return false; }, - child: new _FixedExtentScrollable( + child: _FixedExtentScrollable( controller: scrollController, physics: widget.physics, itemExtent: widget.itemExtent, viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new ListWheelViewport( + return ListWheelViewport( diameterRatio: widget.diameterRatio, perspective: widget.perspective, offAxisFraction: widget.offAxisFraction, @@ -772,11 +772,11 @@ class ListWheelElement extends RenderObjectElement implements ListWheelChildMana // Any time we do case 1, though, we reset the cache. /// A cache of widgets so that we don't have to rebuild every time. - final Map _childWidgets = new HashMap(); + final Map _childWidgets = HashMap(); /// The map containing all active child elements. SplayTreeMap is used so that /// we have all elements ordered and iterable by their keys. - final SplayTreeMap _childElements = new SplayTreeMap(); + final SplayTreeMap _childElements = SplayTreeMap(); @override void update(ListWheelViewport newWidget) { @@ -989,12 +989,12 @@ class ListWheelViewport extends RenderObjectWidget { final ListWheelChildDelegate childDelegate; @override - ListWheelElement createElement() => new ListWheelElement(this); + ListWheelElement createElement() => ListWheelElement(this); @override RenderListWheelViewport createRenderObject(BuildContext context) { final ListWheelElement childManager = context; - return new RenderListWheelViewport( + return RenderListWheelViewport( childManager: childManager, offset: offset, diameterRatio: diameterRatio, diff --git a/packages/flutter/lib/src/widgets/localizations.dart b/packages/flutter/lib/src/widgets/localizations.dart index ecebc524a2..0b4124c299 100644 --- a/packages/flutter/lib/src/widgets/localizations.dart +++ b/packages/flutter/lib/src/widgets/localizations.dart @@ -44,7 +44,7 @@ Future> _loadAll(Locale locale, Iterable types = new Set(); + final Set types = Set(); final List> delegates = >[]; for (LocalizationsDelegate delegate in allDelegates) { if (!types.contains(delegate.type) && delegate.isSupported(locale)) { @@ -65,13 +65,13 @@ Future> _loadAll(Locale locale, Iterable[]; - pendingList.add(new _Pending(delegate, futureValue)); + pendingList.add(_Pending(delegate, futureValue)); } } // All of the delegate.load() values were synchronous futures, we're done. if (pendingList == null) - return new SynchronousFuture>(output); + return SynchronousFuture>(output); // Some of delegate.load() values were asynchronous futures. Wait for them. return Future.wait(pendingList.map((_Pending p) => p.futureValue)) @@ -209,7 +209,7 @@ class DefaultWidgetsLocalizations implements WidgetsLocalizations { /// This method is typically used to create a [LocalizationsDelegate]. /// The [WidgetsApp] does so by default. static Future load(Locale locale) { - return new SynchronousFuture(const DefaultWidgetsLocalizations()); + return SynchronousFuture(const DefaultWidgetsLocalizations()); } /// A [LocalizationsDelegate] that uses [DefaultWidgetsLocalizations.load] @@ -378,7 +378,7 @@ class Localizations extends StatefulWidget { final List> mergedDelegates = Localizations._delegatesOf(context); if (delegates != null) mergedDelegates.insertAll(0, delegates); - return new Localizations( + return Localizations( key: key, locale: locale ?? Localizations.localeOf(context), delegates: mergedDelegates, @@ -420,7 +420,7 @@ class Localizations extends StatefulWidget { assert(context != null); final _LocalizationsScope scope = context.inheritFromWidgetOfExactType(_LocalizationsScope); assert(scope != null, 'a Localizations ancestor was not found'); - return new List>.from(scope.localizationsState.widget.delegates); + return List>.from(scope.localizationsState.widget.delegates); } /// Returns the localized resources object of the given `type` for the widget @@ -446,18 +446,18 @@ class Localizations extends StatefulWidget { } @override - _LocalizationsState createState() => new _LocalizationsState(); + _LocalizationsState createState() => _LocalizationsState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('locale', locale)); - properties.add(new IterableProperty>('delegates', delegates)); + properties.add(DiagnosticsProperty('locale', locale)); + properties.add(IterableProperty>('delegates', delegates)); } } class _LocalizationsState extends State { - final GlobalKey _localizedResourcesScopeKey = new GlobalKey(); + final GlobalKey _localizedResourcesScopeKey = GlobalKey(); Map _typeToResources = {}; Locale get locale => _locale; @@ -543,15 +543,15 @@ class _LocalizationsState extends State { @override Widget build(BuildContext context) { if (_locale == null) - return new Container(); - return new Semantics( + return Container(); + return Semantics( textDirection: _textDirection, - child: new _LocalizationsScope( + child: _LocalizationsScope( key: _localizedResourcesScopeKey, locale: _locale, localizationsState: this, typeToResources: _typeToResources, - child: new Directionality( + child: Directionality( textDirection: _textDirection, child: widget.child, ), diff --git a/packages/flutter/lib/src/widgets/media_query.dart b/packages/flutter/lib/src/widgets/media_query.dart index d79f21e893..269a029bac 100644 --- a/packages/flutter/lib/src/widgets/media_query.dart +++ b/packages/flutter/lib/src/widgets/media_query.dart @@ -59,8 +59,8 @@ class MediaQueryData { : size = window.physicalSize / window.devicePixelRatio, devicePixelRatio = window.devicePixelRatio, textScaleFactor = window.textScaleFactor, - padding = new EdgeInsets.fromWindowPadding(window.padding, window.devicePixelRatio), - viewInsets = new EdgeInsets.fromWindowPadding(window.viewInsets, window.devicePixelRatio), + padding = EdgeInsets.fromWindowPadding(window.padding, window.devicePixelRatio), + viewInsets = EdgeInsets.fromWindowPadding(window.viewInsets, window.devicePixelRatio), accessibleNavigation = window.accessibilityFeatures.accessibleNavigation, invertColors = window.accessibilityFeatures.accessibleNavigation, disableAnimations = window.accessibilityFeatures.disableAnimations, @@ -184,7 +184,7 @@ class MediaQueryData { bool accessibleNavigation, bool boldText, }) { - return new MediaQueryData( + return MediaQueryData( size: size ?? this.size, devicePixelRatio: devicePixelRatio ?? this.devicePixelRatio, textScaleFactor: textScaleFactor ?? this.textScaleFactor, @@ -220,7 +220,7 @@ class MediaQueryData { }) { if (!(removeLeft || removeTop || removeRight || removeBottom)) return this; - return new MediaQueryData( + return MediaQueryData( size: size, devicePixelRatio: devicePixelRatio, textScaleFactor: textScaleFactor, @@ -259,7 +259,7 @@ class MediaQueryData { }) { if (!(removeLeft || removeTop || removeRight || removeBottom)) return this; - return new MediaQueryData( + return MediaQueryData( size: size, devicePixelRatio: devicePixelRatio, textScaleFactor: textScaleFactor, @@ -392,7 +392,7 @@ class MediaQuery extends InheritedWidget { bool removeBottom = false, @required Widget child, }) { - return new MediaQuery( + return MediaQuery( key: key, data: MediaQuery.of(context).removePadding( removeLeft: removeLeft, @@ -434,7 +434,7 @@ class MediaQuery extends InheritedWidget { bool removeBottom = false, @required Widget child, }) { - return new MediaQuery( + return MediaQuery( key: key, data: MediaQuery.of(context).removeViewInsets( removeLeft: removeLeft, @@ -478,7 +478,7 @@ class MediaQuery extends InheritedWidget { return query.data; if (nullOk) return null; - throw new FlutterError( + throw FlutterError( 'MediaQuery.of() called with a context that does not contain a MediaQuery.\n' 'No MediaQuery ancestor could be found starting from the context that was passed ' 'to MediaQuery.of(). This can happen because you do not have a WidgetsApp or ' @@ -507,6 +507,6 @@ class MediaQuery extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('data', data, showName: false)); + properties.add(DiagnosticsProperty('data', data, showName: false)); } } diff --git a/packages/flutter/lib/src/widgets/modal_barrier.dart b/packages/flutter/lib/src/widgets/modal_barrier.dart index 91aa077648..fca9f7cc8e 100644 --- a/packages/flutter/lib/src/widgets/modal_barrier.dart +++ b/packages/flutter/lib/src/widgets/modal_barrier.dart @@ -75,24 +75,24 @@ class ModalBarrier extends StatelessWidget { assert(!dismissible || semanticsLabel == null || debugCheckHasDirectionality(context)); final bool semanticsDismissible = dismissible && defaultTargetPlatform != TargetPlatform.android; final bool modalBarrierSemanticsDismissible = barrierSemanticsDismissible ?? semanticsDismissible; - return new BlockSemantics( - child: new ExcludeSemantics( + return BlockSemantics( + child: ExcludeSemantics( // On Android, the back button is used to dismiss a modal. On iOS, some // modal barriers are not dismissible in accessibility mode. excluding: !semanticsDismissible || !modalBarrierSemanticsDismissible, - child: new GestureDetector( + child: GestureDetector( onTapDown: (TapDownDetails details) { if (dismissible) Navigator.pop(context); }, behavior: HitTestBehavior.opaque, - child: new Semantics( + child: Semantics( label: semanticsDismissible ? semanticsLabel : null, textDirection: semanticsDismissible && semanticsLabel != null ? Directionality.of(context) : null, - child: new ConstrainedBox( + child: ConstrainedBox( constraints: const BoxConstraints.expand(), - child: color == null ? null : new DecoratedBox( - decoration: new BoxDecoration( + child: color == null ? null : DecoratedBox( + decoration: BoxDecoration( color: color, ) ) @@ -165,7 +165,7 @@ class AnimatedModalBarrier extends AnimatedWidget { @override Widget build(BuildContext context) { - return new ModalBarrier( + return ModalBarrier( color: color?.value, dismissible: dismissible, semanticsLabel: semanticsLabel, diff --git a/packages/flutter/lib/src/widgets/navigation_toolbar.dart b/packages/flutter/lib/src/widgets/navigation_toolbar.dart index fafba52f94..e1960eaae2 100644 --- a/packages/flutter/lib/src/widgets/navigation_toolbar.dart +++ b/packages/flutter/lib/src/widgets/navigation_toolbar.dart @@ -64,17 +64,17 @@ class NavigationToolbar extends StatelessWidget { final List children = []; if (leading != null) - children.add(new LayoutId(id: _ToolbarSlot.leading, child: leading)); + children.add(LayoutId(id: _ToolbarSlot.leading, child: leading)); if (middle != null) - children.add(new LayoutId(id: _ToolbarSlot.middle, child: middle)); + children.add(LayoutId(id: _ToolbarSlot.middle, child: middle)); if (trailing != null) - children.add(new LayoutId(id: _ToolbarSlot.trailing, child: trailing)); + children.add(LayoutId(id: _ToolbarSlot.trailing, child: trailing)); final TextDirection textDirection = Directionality.of(context); - return new CustomMultiChildLayout( - delegate: new _ToolbarLayout( + return CustomMultiChildLayout( + delegate: _ToolbarLayout( centerMiddle: centerMiddle, middleSpacing: middleSpacing, textDirection: textDirection, @@ -115,7 +115,7 @@ class _ToolbarLayout extends MultiChildLayoutDelegate { double trailingWidth = 0.0; if (hasChild(_ToolbarSlot.leading)) { - final BoxConstraints constraints = new BoxConstraints( + final BoxConstraints constraints = BoxConstraints( minWidth: 0.0, maxWidth: size.width / 3.0, // The leading widget shouldn't take up more than 1/3 of the space. minHeight: size.height, // The height should be exactly the height of the bar. @@ -131,11 +131,11 @@ class _ToolbarLayout extends MultiChildLayoutDelegate { leadingX = 0.0; break; } - positionChild(_ToolbarSlot.leading, new Offset(leadingX, 0.0)); + positionChild(_ToolbarSlot.leading, Offset(leadingX, 0.0)); } if (hasChild(_ToolbarSlot.trailing)) { - final BoxConstraints constraints = new BoxConstraints.loose(size); + final BoxConstraints constraints = BoxConstraints.loose(size); final Size trailingSize = layoutChild(_ToolbarSlot.trailing, constraints); double trailingX; switch (textDirection) { @@ -148,12 +148,12 @@ class _ToolbarLayout extends MultiChildLayoutDelegate { } final double trailingY = (size.height - trailingSize.height) / 2.0; trailingWidth = trailingSize.width; - positionChild(_ToolbarSlot.trailing, new Offset(trailingX, trailingY)); + positionChild(_ToolbarSlot.trailing, Offset(trailingX, trailingY)); } if (hasChild(_ToolbarSlot.middle)) { final double maxWidth = math.max(size.width - leadingWidth - trailingWidth - middleSpacing * 2.0, 0.0); - final BoxConstraints constraints = new BoxConstraints.loose(size).copyWith(maxWidth: maxWidth); + final BoxConstraints constraints = BoxConstraints.loose(size).copyWith(maxWidth: maxWidth); final Size middleSize = layoutChild(_ToolbarSlot.middle, constraints); final double middleStartMargin = leadingWidth + middleSpacing; @@ -179,7 +179,7 @@ class _ToolbarLayout extends MultiChildLayoutDelegate { break; } - positionChild(_ToolbarSlot.middle, new Offset(middleX, middleY)); + positionChild(_ToolbarSlot.middle, Offset(middleX, middleY)); } } diff --git a/packages/flutter/lib/src/widgets/navigator.dart b/packages/flutter/lib/src/widgets/navigator.dart index b720bee431..5a0ae55871 100644 --- a/packages/flutter/lib/src/widgets/navigator.dart +++ b/packages/flutter/lib/src/widgets/navigator.dart @@ -114,7 +114,7 @@ abstract class Route { /// The [didChangeNext] and [didChangePrevious] methods are typically called /// immediately after this method is called. @protected - TickerFuture didPush() => new TickerFuture.complete(); + TickerFuture didPush() => TickerFuture.complete(); /// Called after [install] when the route replaced another in the navigator. /// @@ -152,7 +152,7 @@ abstract class Route { /// /// The future completes with the value given to [Navigator.pop], if any. Future get popped => _popCompleter.future; - final Completer _popCompleter = new Completer(); + final Completer _popCompleter = Completer(); /// A request was made to pop this route. If the route can handle it /// internally (e.g. because it has its own stack of internal state) then @@ -295,7 +295,7 @@ class RouteSettings { String name, bool isInitialRoute, }) { - return new RouteSettings( + return RouteSettings( name: name ?? this.name, isInitialRoute: isInitialRoute ?? this.isInitialRoute, ); @@ -1270,7 +1270,7 @@ class Navigator extends StatefulWidget { : context.ancestorStateOfType(const TypeMatcher()); assert(() { if (navigator == null && !nullOk) { - throw new FlutterError( + throw FlutterError( 'Navigator operation requested with a context that does not include a Navigator.\n' 'The context used to push or pop routes from the Navigator must be that of a ' 'widget that is a descendant of a Navigator widget.' @@ -1282,17 +1282,17 @@ class Navigator extends StatefulWidget { } @override - NavigatorState createState() => new NavigatorState(); + NavigatorState createState() => NavigatorState(); } /// The state for a [Navigator] widget. class NavigatorState extends State with TickerProviderStateMixin { - final GlobalKey _overlayKey = new GlobalKey(); + final GlobalKey _overlayKey = GlobalKey(); final List> _history = >[]; - final Set> _poppedRoutes = new Set>(); + final Set> _poppedRoutes = Set>(); /// The [FocusScopeNode] for the [FocusScope] that encloses the routes. - final FocusScopeNode focusScopeNode = new FocusScopeNode(); + final FocusScopeNode focusScopeNode = FocusScopeNode(); final List _initialOverlayEntries = []; @@ -1325,7 +1325,7 @@ class NavigatorState extends State with TickerProviderStateMixin { if (plannedInitialRoutes.contains(null)) { assert(() { FlutterError.reportError( - new FlutterErrorDetails( + FlutterErrorDetails( exception: 'Could not navigate to initial route.\n' 'The requested route name was: "/$initialRouteName"\n' @@ -1401,7 +1401,7 @@ class NavigatorState extends State with TickerProviderStateMixin { Route _routeNamed(String name, { bool allowNull = false }) { assert(!_debugLocked); assert(name != null); - final RouteSettings settings = new RouteSettings( + final RouteSettings settings = RouteSettings( name: name, isInitialRoute: _history.isEmpty, ); @@ -1409,7 +1409,7 @@ class NavigatorState extends State with TickerProviderStateMixin { if (route == null && !allowNull) { assert(() { if (widget.onUnknownRoute == null) { - throw new FlutterError( + throw FlutterError( 'If a Navigator has no onUnknownRoute, then its onGenerateRoute must never return null.\n' 'When trying to build the route "$name", onGenerateRoute returned null, but there was no ' 'onUnknownRoute callback specified.\n' @@ -1422,7 +1422,7 @@ class NavigatorState extends State with TickerProviderStateMixin { route = widget.onUnknownRoute(settings); assert(() { if (route == null) { - throw new FlutterError( + throw FlutterError( 'A Navigator\'s onUnknownRoute returned null.\n' 'When trying to build the route "$name", both onGenerateRoute and onUnknownRoute returned ' 'null. The onUnknownRoute callback should never return null.\n' @@ -1915,7 +1915,7 @@ class NavigatorState extends State with TickerProviderStateMixin { } } - final Set _activePointers = new Set(); + final Set _activePointers = Set(); void _handlePointerDown(PointerDownEvent event) { _activePointers.add(event.pointer); @@ -1945,16 +1945,16 @@ class NavigatorState extends State with TickerProviderStateMixin { Widget build(BuildContext context) { assert(!_debugLocked); assert(_history.isNotEmpty); - return new Listener( + return Listener( onPointerDown: _handlePointerDown, onPointerUp: _handlePointerUpOrCancel, onPointerCancel: _handlePointerUpOrCancel, - child: new AbsorbPointer( + child: AbsorbPointer( absorbing: false, // it's mutated directly by _cancelActivePointers above - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new Overlay( + child: Overlay( key: _overlayKey, initialEntries: _initialOverlayEntries, ), diff --git a/packages/flutter/lib/src/widgets/nested_scroll_view.dart b/packages/flutter/lib/src/widgets/nested_scroll_view.dart index 3f373bbd97..04b6b49242 100644 --- a/packages/flutter/lib/src/widgets/nested_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/nested_scroll_view.dart @@ -268,8 +268,8 @@ class NestedScrollView extends StatefulWidget { List _buildSlivers(BuildContext context, ScrollController innerController, bool bodyIsScrolled) { final List slivers = []; slivers.addAll(headerSliverBuilder(context, bodyIsScrolled)); - slivers.add(new SliverFillRemaining( - child: new PrimaryScrollController( + slivers.add(SliverFillRemaining( + child: PrimaryScrollController( controller: innerController, child: body, ), @@ -278,18 +278,18 @@ class NestedScrollView extends StatefulWidget { } @override - _NestedScrollViewState createState() => new _NestedScrollViewState(); + _NestedScrollViewState createState() => _NestedScrollViewState(); } class _NestedScrollViewState extends State { - final SliverOverlapAbsorberHandle _absorberHandle = new SliverOverlapAbsorberHandle(); + final SliverOverlapAbsorberHandle _absorberHandle = SliverOverlapAbsorberHandle(); _NestedScrollCoordinator _coordinator; @override void initState() { super.initState(); - _coordinator = new _NestedScrollCoordinator(this, widget.controller, _handleHasScrolledBodyChanged); + _coordinator = _NestedScrollCoordinator(this, widget.controller, _handleHasScrolledBodyChanged); } @override @@ -331,12 +331,12 @@ class _NestedScrollViewState extends State { @override Widget build(BuildContext context) { - return new _InheritedNestedScrollView( + return _InheritedNestedScrollView( state: this, - child: new Builder( + child: Builder( builder: (BuildContext context) { _lastHasScrolledBody = _coordinator.hasScrolledBody; - return new _NestedScrollViewCustomScrollView( + return _NestedScrollViewCustomScrollView( scrollDirection: widget.scrollDirection, reverse: widget.reverse, physics: widget.physics != null @@ -382,7 +382,7 @@ class _NestedScrollViewCustomScrollView extends CustomScrollView { List slivers, ) { assert(!shrinkWrap); - return new NestedScrollViewViewport( + return NestedScrollViewViewport( axisDirection: axisDirection, offset: offset, slivers: slivers, @@ -435,7 +435,7 @@ class _NestedScrollMetrics extends FixedScrollMetrics { double maxRange, double correctionOffset, }) { - return new _NestedScrollMetrics( + return _NestedScrollMetrics( minScrollExtent: minScrollExtent ?? this.minScrollExtent, maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, pixels: pixels ?? this.pixels, @@ -459,8 +459,8 @@ typedef ScrollActivity _NestedScrollActivityGetter(_NestedScrollPosition positio class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldController { _NestedScrollCoordinator(this._state, this._parent, this._onHasScrolledBodyChanged) { final double initialScrollOffset = _parent?.initialScrollOffset ?? 0.0; - _outerController = new _NestedScrollController(this, initialScrollOffset: initialScrollOffset, debugLabel: 'outer'); - _innerController = new _NestedScrollController(this, initialScrollOffset: 0.0, debugLabel: 'inner'); + _outerController = _NestedScrollController(this, initialScrollOffset: initialScrollOffset, debugLabel: 'outer'); + _innerController = _NestedScrollController(this, initialScrollOffset: 0.0, debugLabel: 'inner'); } final _NestedScrollViewState _state; @@ -533,7 +533,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont AxisDirection get axisDirection => _outerPosition.axisDirection; static IdleScrollActivity _createIdleScrollActivity(_NestedScrollPosition position) { - return new IdleScrollActivity(position); + return IdleScrollActivity(position); } @override @@ -662,7 +662,7 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont correctionOffset = 0.0; } } - return new _NestedScrollMetrics( + return _NestedScrollMetrics( minScrollExtent: _outerPosition.minScrollExtent, maxScrollExtent: _outerPosition.maxScrollExtent + innerPosition.maxScrollExtent - innerPosition.minScrollExtent + extra, pixels: pixels, @@ -745,8 +745,8 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont ScrollHoldController hold(VoidCallback holdCancelCallback) { beginActivity( - new HoldScrollActivity(delegate: _outerPosition, onHoldCanceled: holdCancelCallback), - (_NestedScrollPosition position) => new HoldScrollActivity(delegate: position), + HoldScrollActivity(delegate: _outerPosition, onHoldCanceled: holdCancelCallback), + (_NestedScrollPosition position) => HoldScrollActivity(delegate: position), ); return this; } @@ -757,14 +757,14 @@ class _NestedScrollCoordinator implements ScrollActivityDelegate, ScrollHoldCont } Drag drag(DragStartDetails details, VoidCallback dragCancelCallback) { - final ScrollDragController drag = new ScrollDragController( + final ScrollDragController drag = ScrollDragController( delegate: this, details: details, onDragCanceled: dragCancelCallback, ); beginActivity( - new DragScrollActivity(_outerPosition, drag), - (_NestedScrollPosition position) => new DragScrollActivity(position, drag), + DragScrollActivity(_outerPosition, drag), + (_NestedScrollPosition position) => DragScrollActivity(position, drag), ); assert(_currentDrag == null); _currentDrag = drag; @@ -847,7 +847,7 @@ class _NestedScrollController extends ScrollController { ScrollContext context, ScrollPosition oldPosition, ) { - return new _NestedScrollPosition( + return _NestedScrollPosition( coordinator: coordinator, physics: physics, context: context, @@ -1014,7 +1014,7 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele ScrollDirection get userScrollDirection => coordinator.userScrollDirection; DrivenScrollActivity createDrivenScrollActivity(double to, Duration duration, Curve curve) { - return new DrivenScrollActivity( + return DrivenScrollActivity( this, from: pixels, to: to, @@ -1033,7 +1033,7 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele // This is called by activities when they finish their work. @override void goIdle() { - beginActivity(new IdleScrollActivity(this)); + beginActivity(IdleScrollActivity(this)); } // This is called by activities when they finish their work and want to go ballistic. @@ -1053,18 +1053,18 @@ class _NestedScrollPosition extends ScrollPosition implements ScrollActivityDele _NestedScrollMetrics metrics, }) { if (simulation == null) - return new IdleScrollActivity(this); + return IdleScrollActivity(this); assert(mode != null); switch (mode) { case _NestedBallisticScrollActivityMode.outer: assert(metrics != null); if (metrics.minRange == metrics.maxRange) - return new IdleScrollActivity(this); - return new _NestedOuterBallisticScrollActivity(coordinator, this, metrics, simulation, context.vsync); + return IdleScrollActivity(this); + return _NestedOuterBallisticScrollActivity(coordinator, this, metrics, simulation, context.vsync); case _NestedBallisticScrollActivityMode.inner: - return new _NestedInnerBallisticScrollActivity(coordinator, this, simulation, context.vsync); + return _NestedInnerBallisticScrollActivity(coordinator, this, simulation, context.vsync); case _NestedBallisticScrollActivityMode.independent: - return new BallisticScrollActivity(this, simulation, context.vsync); + return BallisticScrollActivity(this, simulation, context.vsync); } return null; } @@ -1333,7 +1333,7 @@ class SliverOverlapAbsorber extends SingleChildRenderObjectWidget { @override RenderSliverOverlapAbsorber createRenderObject(BuildContext context) { - return new RenderSliverOverlapAbsorber( + return RenderSliverOverlapAbsorber( handle: handle, ); } @@ -1347,7 +1347,7 @@ class SliverOverlapAbsorber extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('handle', handle)); + properties.add(DiagnosticsProperty('handle', handle)); } } @@ -1411,7 +1411,7 @@ class RenderSliverOverlapAbsorber extends RenderSliver with RenderObjectWithChil } child.layout(constraints, parentUsesSize: true); final SliverGeometry childLayoutGeometry = child.geometry; - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: childLayoutGeometry.scrollExtent - childLayoutGeometry.maxScrollObstructionExtent, paintExtent: childLayoutGeometry.paintExtent, paintOrigin: childLayoutGeometry.paintOrigin, @@ -1447,7 +1447,7 @@ class RenderSliverOverlapAbsorber extends RenderSliver with RenderObjectWithChil @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('handle', handle)); + properties.add(DiagnosticsProperty('handle', handle)); } } @@ -1482,7 +1482,7 @@ class SliverOverlapInjector extends SingleChildRenderObjectWidget { @override RenderSliverOverlapInjector createRenderObject(BuildContext context) { - return new RenderSliverOverlapInjector( + return RenderSliverOverlapInjector( handle: handle, ); } @@ -1496,7 +1496,7 @@ class SliverOverlapInjector extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('handle', handle)); + properties.add(DiagnosticsProperty('handle', handle)); } } @@ -1561,7 +1561,7 @@ class RenderSliverOverlapInjector extends RenderSliver { _currentLayoutExtent = handle.layoutExtent; _currentMaxExtent = handle.layoutExtent; final double clampedLayoutExtent = math.min(_currentLayoutExtent - constraints.scrollOffset, constraints.remainingPaintExtent); - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: _currentLayoutExtent, paintExtent: math.max(0.0, clampedLayoutExtent), maxPaintExtent: _currentMaxExtent, @@ -1572,7 +1572,7 @@ class RenderSliverOverlapInjector extends RenderSliver { void debugPaint(PaintingContext context, Offset offset) { assert(() { if (debugPaintSizeEnabled) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = const Color(0xFFCC9933) ..strokeWidth = 3.0 ..style = PaintingStyle.stroke; @@ -1580,15 +1580,15 @@ class RenderSliverOverlapInjector extends RenderSliver { switch (constraints.axis) { case Axis.vertical: final double x = offset.dx + constraints.crossAxisExtent / 2.0; - start = new Offset(x, offset.dy); - end = new Offset(x, offset.dy + geometry.paintExtent); - delta = new Offset(constraints.crossAxisExtent / 5.0, 0.0); + start = Offset(x, offset.dy); + end = Offset(x, offset.dy + geometry.paintExtent); + delta = Offset(constraints.crossAxisExtent / 5.0, 0.0); break; case Axis.horizontal: final double y = offset.dy + constraints.crossAxisExtent / 2.0; - start = new Offset(offset.dx, y); - end = new Offset(offset.dy + geometry.paintExtent, y); - delta = new Offset(0.0, constraints.crossAxisExtent / 5.0); + start = Offset(offset.dx, y); + end = Offset(offset.dy + geometry.paintExtent, y); + delta = Offset(0.0, constraints.crossAxisExtent / 5.0); break; } for (int index = -2; index <= 2; index += 1) { @@ -1602,7 +1602,7 @@ class RenderSliverOverlapInjector extends RenderSliver { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('handle', handle)); + properties.add(DiagnosticsProperty('handle', handle)); } } @@ -1639,7 +1639,7 @@ class NestedScrollViewViewport extends Viewport { @override RenderNestedScrollViewViewport createRenderObject(BuildContext context) { - return new RenderNestedScrollViewViewport( + return RenderNestedScrollViewViewport( axisDirection: axisDirection, crossAxisDirection: crossAxisDirection ?? Viewport.getDefaultCrossAxisDirection(context, axisDirection), anchor: anchor, @@ -1661,7 +1661,7 @@ class NestedScrollViewViewport extends Viewport { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('handle', handle)); + properties.add(DiagnosticsProperty('handle', handle)); } } @@ -1713,6 +1713,6 @@ class RenderNestedScrollViewViewport extends RenderViewport { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('handle', handle)); + properties.add(DiagnosticsProperty('handle', handle)); } } diff --git a/packages/flutter/lib/src/widgets/orientation_builder.dart b/packages/flutter/lib/src/widgets/orientation_builder.dart index 85029cc380..0a9ba16a55 100644 --- a/packages/flutter/lib/src/widgets/orientation_builder.dart +++ b/packages/flutter/lib/src/widgets/orientation_builder.dart @@ -50,6 +50,6 @@ class OrientationBuilder extends StatelessWidget { @override Widget build(BuildContext context) { - return new LayoutBuilder(builder: _buildWithConstraints); + return LayoutBuilder(builder: _buildWithConstraints); } } diff --git a/packages/flutter/lib/src/widgets/overlay.dart b/packages/flutter/lib/src/widgets/overlay.dart index 07c7207ead..d57ef1794a 100644 --- a/packages/flutter/lib/src/widgets/overlay.dart +++ b/packages/flutter/lib/src/widgets/overlay.dart @@ -116,7 +116,7 @@ class OverlayEntry { } OverlayState _overlay; - final GlobalKey<_OverlayEntryState> _key = new GlobalKey<_OverlayEntryState>(); + final GlobalKey<_OverlayEntryState> _key = GlobalKey<_OverlayEntryState>(); /// Remove this entry from the overlay. /// @@ -161,7 +161,7 @@ class _OverlayEntry extends StatefulWidget { final OverlayEntry entry; @override - _OverlayEntryState createState() => new _OverlayEntryState(); + _OverlayEntryState createState() => _OverlayEntryState(); } class _OverlayEntryState extends State<_OverlayEntry> { @@ -241,7 +241,7 @@ class Overlay extends StatefulWidget { final String additional = context.widget != debugRequiredFor ? '\nThe context from which that widget was searching for an overlay was:\n $context' : ''; - throw new FlutterError( + throw FlutterError( 'No Overlay widget found.\n' '${debugRequiredFor.runtimeType} widgets require an Overlay widget ancestor for correct operation.\n' 'The most common way to add an Overlay to an application is to include a MaterialApp or Navigator widget in the runApp() call.\n' @@ -256,7 +256,7 @@ class Overlay extends StatefulWidget { } @override - OverlayState createState() => new OverlayState(); + OverlayState createState() => OverlayState(); } /// The current state of an [Overlay]. @@ -353,15 +353,15 @@ class OverlayState extends State with TickerProviderStateMixin { for (int i = _entries.length - 1; i >= 0; i -= 1) { final OverlayEntry entry = _entries[i]; if (onstage) { - onstageChildren.add(new _OverlayEntry(entry)); + onstageChildren.add(_OverlayEntry(entry)); if (entry.opaque) onstage = false; } else if (entry.maintainState) { - offstageChildren.add(new TickerMode(enabled: false, child: new _OverlayEntry(entry))); + offstageChildren.add(TickerMode(enabled: false, child: _OverlayEntry(entry))); } } - return new _Theatre( - onstage: new Stack( + return _Theatre( + onstage: Stack( fit: StackFit.expand, children: onstageChildren.reversed.toList(growable: false), ), @@ -374,7 +374,7 @@ class OverlayState extends State with TickerProviderStateMixin { super.debugFillProperties(properties); // TODO(jacobr): use IterableProperty instead as that would // provide a slightly more consistent string summary of the List. - properties.add(new DiagnosticsProperty>('entries', _entries)); + properties.add(DiagnosticsProperty>('entries', _entries)); } } @@ -398,10 +398,10 @@ class _Theatre extends RenderObjectWidget { final List offstage; @override - _TheatreElement createElement() => new _TheatreElement(this); + _TheatreElement createElement() => _TheatreElement(this); @override - _RenderTheatre createRenderObject(BuildContext context) => new _RenderTheatre(); + _RenderTheatre createRenderObject(BuildContext context) => _RenderTheatre(); } class _TheatreElement extends RenderObjectElement { @@ -416,10 +416,10 @@ class _TheatreElement extends RenderObjectElement { _RenderTheatre get renderObject => super.renderObject; Element _onstage; - static final Object _onstageSlot = new Object(); + static final Object _onstageSlot = Object(); List _offstage; - final Set _forgottenOffstageChildren = new HashSet(); + final Set _forgottenOffstageChildren = HashSet(); @override void insertChildRenderObject(RenderBox child, dynamic slot) { @@ -491,7 +491,7 @@ class _TheatreElement extends RenderObjectElement { void mount(Element parent, dynamic newSlot) { super.mount(parent, newSlot); _onstage = updateChild(_onstage, widget.onstage, _onstageSlot); - _offstage = new List(widget.offstage.length); + _offstage = List(widget.offstage.length); Element previousChild; for (int i = 0; i < _offstage.length; i += 1) { final Element newChild = inflateWidget(widget.offstage[i], previousChild); @@ -525,7 +525,7 @@ class _RenderTheatre extends RenderBox @override void setupParentData(RenderObject child) { if (child.parentData is! StackParentData) - child.parentData = new StackParentData(); + child.parentData = StackParentData(); } // Because both RenderObjectWithChildMixin and ContainerRenderObjectMixin @@ -584,7 +584,7 @@ class _RenderTheatre extends RenderBox } } else { children.add( - new DiagnosticsNode.message( + DiagnosticsNode.message( 'no offstage children', style: DiagnosticsTreeStyle.offstage, ), diff --git a/packages/flutter/lib/src/widgets/overscroll_indicator.dart b/packages/flutter/lib/src/widgets/overscroll_indicator.dart index 29dece39dd..6da2292e09 100644 --- a/packages/flutter/lib/src/widgets/overscroll_indicator.dart +++ b/packages/flutter/lib/src/widgets/overscroll_indicator.dart @@ -107,12 +107,12 @@ class GlowingOverscrollIndicator extends StatefulWidget { final Widget child; @override - _GlowingOverscrollIndicatorState createState() => new _GlowingOverscrollIndicatorState(); + _GlowingOverscrollIndicatorState createState() => _GlowingOverscrollIndicatorState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('axisDirection', axisDirection)); + properties.add(EnumProperty('axisDirection', axisDirection)); String showDescription; if (showLeading && showTrailing) { showDescription = 'both sides'; @@ -123,8 +123,8 @@ class GlowingOverscrollIndicator extends StatefulWidget { } else { showDescription = 'neither side (!)'; } - properties.add(new MessageProperty('show', showDescription)); - properties.add(new DiagnosticsProperty('color', color, showName: false)); + properties.add(MessageProperty('show', showDescription)); + properties.add(DiagnosticsProperty('color', color, showName: false)); } } @@ -136,9 +136,9 @@ class _GlowingOverscrollIndicatorState extends State @override void initState() { super.initState(); - _leadingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis); - _trailingController = new _GlowController(vsync: this, color: widget.color, axis: widget.axis); - _leadingAndTrailingListener = new Listenable.merge([_leadingController, _trailingController]); + _leadingController = _GlowController(vsync: this, color: widget.color, axis: widget.axis); + _trailingController = _GlowController(vsync: this, color: widget.color, axis: widget.axis); + _leadingAndTrailingListener = Listenable.merge([_leadingController, _trailingController]); } @override @@ -169,7 +169,7 @@ class _GlowingOverscrollIndicatorState extends State } final bool isLeading = controller == _leadingController; if (_lastNotificationType != OverscrollNotification) { - final OverscrollIndicatorNotification confirmationNotification = new OverscrollIndicatorNotification(leading: isLeading); + final OverscrollIndicatorNotification confirmationNotification = OverscrollIndicatorNotification(leading: isLeading); confirmationNotification.dispatch(context); _accepted[isLeading] = confirmationNotification._accepted; } @@ -218,17 +218,17 @@ class _GlowingOverscrollIndicatorState extends State @override Widget build(BuildContext context) { - return new NotificationListener( + return NotificationListener( onNotification: _handleScrollNotification, - child: new RepaintBoundary( - child: new CustomPaint( - foregroundPainter: new _GlowingOverscrollIndicatorPainter( + child: RepaintBoundary( + child: CustomPaint( + foregroundPainter: _GlowingOverscrollIndicatorPainter( leadingController: widget.showLeading ? _leadingController : null, trailingController: widget.showTrailing ? _trailingController : null, axisDirection: widget.axisDirection, repaint: _leadingAndTrailingListener, ), - child: new RepaintBoundary( + child: RepaintBoundary( child: widget.child, ), ), @@ -253,9 +253,9 @@ class _GlowController extends ChangeNotifier { assert(axis != null), _color = color, _axis = axis { - _glowController = new AnimationController(vsync: vsync) + _glowController = AnimationController(vsync: vsync) ..addStatusListener(_changePhase); - final Animation decelerator = new CurvedAnimation( + final Animation decelerator = CurvedAnimation( parent: _glowController, curve: Curves.decelerate, )..addListener(notifyListeners); @@ -270,9 +270,9 @@ class _GlowController extends ChangeNotifier { Timer _pullRecedeTimer; // animation values - final Tween _glowOpacityTween = new Tween(begin: 0.0, end: 0.0); + final Tween _glowOpacityTween = Tween(begin: 0.0, end: 0.0); Animation _glowOpacity; - final Tween _glowSizeTween = new Tween(begin: 0.0, end: 0.0); + final Tween _glowSizeTween = Tween(begin: 0.0, end: 0.0); Animation _glowSize; // animation of the cross axis position @@ -308,7 +308,7 @@ class _GlowController extends ChangeNotifier { static const Duration _pullTime = Duration(milliseconds: 167); static const Duration _pullHoldTime = Duration(milliseconds: 167); static const Duration _pullDecayTime = Duration(milliseconds: 2000); - static final Duration _crossAxisHalfTime = new Duration(microseconds: (Duration.microsecondsPerSecond / 60.0).round()); + static final Duration _crossAxisHalfTime = Duration(microseconds: (Duration.microsecondsPerSecond / 60.0).round()); static const double _maxOpacity = 0.5; static const double _pullOpacityGlowFactor = 0.8; @@ -340,7 +340,7 @@ class _GlowController extends ChangeNotifier { _glowOpacityTween.end = (velocity * _velocityGlowFactor).clamp(_glowOpacityTween.begin, _maxOpacity); _glowSizeTween.begin = _glowSize.value; _glowSizeTween.end = math.min(0.025 + 7.5e-7 * velocity * velocity, 1.0); - _glowController.duration = new Duration(milliseconds: (0.15 + velocity * 0.02).round()); + _glowController.duration = Duration(milliseconds: (0.15 + velocity * 0.02).round()); _glowController.forward(from: 0.0); _displacement = 0.5; _state = _GlowState.absorb; @@ -385,7 +385,7 @@ class _GlowController extends ChangeNotifier { notifyListeners(); } } - _pullRecedeTimer = new Timer(_pullHoldTime, () => _recede(_pullDecayTime)); + _pullRecedeTimer = Timer(_pullHoldTime, () => _recede(_pullDecayTime)); } void scrollEnd() { @@ -445,9 +445,9 @@ class _GlowController extends ChangeNotifier { final double radius = size.width * 3.0 / 2.0; final double height = math.min(size.height, size.width * _widthToHeightFactor); final double scaleY = _glowSize.value * baseGlowScale; - final Rect rect = new Rect.fromLTWH(0.0, 0.0, size.width, height); - final Offset center = new Offset((size.width / 2.0) * (0.5 + _displacement), height - radius); - final Paint paint = new Paint()..color = color.withOpacity(_glowOpacity.value); + final Rect rect = Rect.fromLTWH(0.0, 0.0, size.width, height); + final Offset center = Offset((size.width / 2.0) * (0.5 + _displacement), height - radius); + final Paint paint = Paint()..color = color.withOpacity(_glowOpacity.value); canvas.save(); canvas.scale(1.0, scaleY); canvas.clipRect(rect); @@ -499,14 +499,14 @@ class _GlowingOverscrollIndicatorPainter extends CustomPainter { canvas.save(); canvas.rotate(piOver2); canvas.scale(1.0, -1.0); - controller.paint(canvas, new Size(size.height, size.width)); + controller.paint(canvas, Size(size.height, size.width)); canvas.restore(); break; case AxisDirection.right: canvas.save(); canvas.translate(size.width, 0.0); canvas.rotate(piOver2); - controller.paint(canvas, new Size(size.height, size.width)); + controller.paint(canvas, Size(size.height, size.width)); canvas.restore(); break; } diff --git a/packages/flutter/lib/src/widgets/page_storage.dart b/packages/flutter/lib/src/widgets/page_storage.dart index ca5f331231..e7c8d2f353 100644 --- a/packages/flutter/lib/src/widgets/page_storage.dart +++ b/packages/flutter/lib/src/widgets/page_storage.dart @@ -89,7 +89,7 @@ class PageStorageBucket { } _StorageEntryIdentifier _computeIdentifier(BuildContext context) { - return new _StorageEntryIdentifier(_allKeys(context)); + return _StorageEntryIdentifier(_allKeys(context)); } Map _storage; diff --git a/packages/flutter/lib/src/widgets/page_view.dart b/packages/flutter/lib/src/widgets/page_view.dart index 1743509aa3..6629a80472 100644 --- a/packages/flutter/lib/src/widgets/page_view.dart +++ b/packages/flutter/lib/src/widgets/page_view.dart @@ -154,7 +154,7 @@ class PageController extends ScrollController { @override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { - return new _PagePosition( + return _PagePosition( physics: physics, context: context, initialPage: initialPage, @@ -202,7 +202,7 @@ class PageMetrics extends FixedScrollMetrics { AxisDirection axisDirection, double viewportFraction, }) { - return new PageMetrics( + return PageMetrics( minScrollExtent: minScrollExtent ?? this.minScrollExtent, maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, pixels: pixels ?? this.pixels, @@ -309,7 +309,7 @@ class _PagePosition extends ScrollPositionWithSingleContext implements PageMetri AxisDirection axisDirection, double viewportFraction, }) { - return new PageMetrics( + return PageMetrics( minScrollExtent: minScrollExtent ?? this.minScrollExtent, maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, pixels: pixels ?? this.pixels, @@ -335,7 +335,7 @@ class PageScrollPhysics extends ScrollPhysics { @override PageScrollPhysics applyTo(ScrollPhysics ancestor) { - return new PageScrollPhysics(parent: buildParent(ancestor)); + return PageScrollPhysics(parent: buildParent(ancestor)); } double _getPage(ScrollPosition position) { @@ -369,7 +369,7 @@ class PageScrollPhysics extends ScrollPhysics { final Tolerance tolerance = this.tolerance; final double target = _getTargetPixels(position, tolerance, velocity); if (target != position.pixels) - return new ScrollSpringSimulation(spring, position.pixels, target, velocity, tolerance: tolerance); + return ScrollSpringSimulation(spring, position.pixels, target, velocity, tolerance: tolerance); return null; } @@ -381,7 +381,7 @@ class PageScrollPhysics extends ScrollPhysics { // to plumb in the factory for _PagePosition, but it will end up accumulating // a large list of scroll positions. As long as you don't try to actually // control the scroll positions, everything should be fine. -final PageController _defaultPageController = new PageController(); +final PageController _defaultPageController = PageController(); const PageScrollPhysics _kPagePhysics = PageScrollPhysics(); /// A scrollable list that works page by page. @@ -424,7 +424,7 @@ class PageView extends StatefulWidget { this.onPageChanged, List children = const [], }) : controller = controller ?? _defaultPageController, - childrenDelegate = new SliverChildListDelegate(children), + childrenDelegate = SliverChildListDelegate(children), super(key: key); /// Creates a scrollable list that works page by page using widgets that are @@ -450,7 +450,7 @@ class PageView extends StatefulWidget { @required IndexedWidgetBuilder itemBuilder, int itemCount, }) : controller = controller ?? _defaultPageController, - childrenDelegate = new SliverChildBuilderDelegate(itemBuilder, childCount: itemCount), + childrenDelegate = SliverChildBuilderDelegate(itemBuilder, childCount: itemCount), super(key: key); /// Creates a scrollable list that works page by page with a custom child @@ -517,7 +517,7 @@ class PageView extends StatefulWidget { final SliverChildDelegate childrenDelegate; @override - _PageViewState createState() => new _PageViewState(); + _PageViewState createState() => _PageViewState(); } class _PageViewState extends State { @@ -549,7 +549,7 @@ class _PageViewState extends State { ? _kPagePhysics.applyTo(widget.physics) : widget.physics; - return new NotificationListener( + return NotificationListener( onNotification: (ScrollNotification notification) { if (notification.depth == 0 && widget.onPageChanged != null && notification is ScrollUpdateNotification) { final PageMetrics metrics = notification.metrics; @@ -561,17 +561,17 @@ class _PageViewState extends State { } return false; }, - child: new Scrollable( + child: Scrollable( axisDirection: axisDirection, controller: widget.controller, physics: physics, viewportBuilder: (BuildContext context, ViewportOffset position) { - return new Viewport( + return Viewport( cacheExtent: 0.0, axisDirection: axisDirection, offset: position, slivers: [ - new SliverFillViewport( + SliverFillViewport( viewportFraction: widget.controller.viewportFraction, delegate: widget.childrenDelegate ), @@ -585,10 +585,10 @@ class _PageViewState extends State { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new EnumProperty('scrollDirection', widget.scrollDirection)); - description.add(new FlagProperty('reverse', value: widget.reverse, ifTrue: 'reversed')); - description.add(new DiagnosticsProperty('controller', widget.controller, showName: false)); - description.add(new DiagnosticsProperty('physics', widget.physics, showName: false)); - description.add(new FlagProperty('pageSnapping', value: widget.pageSnapping, ifFalse: 'snapping disabled')); + description.add(EnumProperty('scrollDirection', widget.scrollDirection)); + description.add(FlagProperty('reverse', value: widget.reverse, ifTrue: 'reversed')); + description.add(DiagnosticsProperty('controller', widget.controller, showName: false)); + description.add(DiagnosticsProperty('physics', widget.physics, showName: false)); + description.add(FlagProperty('pageSnapping', value: widget.pageSnapping, ifFalse: 'snapping disabled')); } } diff --git a/packages/flutter/lib/src/widgets/performance_overlay.dart b/packages/flutter/lib/src/widgets/performance_overlay.dart index 96dc565f4b..f8482d3cbe 100644 --- a/packages/flutter/lib/src/widgets/performance_overlay.dart +++ b/packages/flutter/lib/src/widgets/performance_overlay.dart @@ -103,7 +103,7 @@ class PerformanceOverlay extends LeafRenderObjectWidget { final bool checkerboardOffscreenLayers; @override - RenderPerformanceOverlay createRenderObject(BuildContext context) => new RenderPerformanceOverlay( + RenderPerformanceOverlay createRenderObject(BuildContext context) => RenderPerformanceOverlay( optionsMask: optionsMask, rasterizerThreshold: rasterizerThreshold, checkerboardRasterCacheImages: checkerboardRasterCacheImages, diff --git a/packages/flutter/lib/src/widgets/placeholder.dart b/packages/flutter/lib/src/widgets/placeholder.dart index 49bcf59f40..07a81cccb0 100644 --- a/packages/flutter/lib/src/widgets/placeholder.dart +++ b/packages/flutter/lib/src/widgets/placeholder.dart @@ -18,12 +18,12 @@ class _PlaceholderPainter extends CustomPainter { @override void paint(Canvas canvas, Size size) { - final Paint paint = new Paint() + final Paint paint = Paint() ..color = color ..style = PaintingStyle.stroke ..strokeWidth = strokeWidth; final Rect rect = Offset.zero & size; - final Path path = new Path() + final Path path = Path() ..addRect(rect) ..addPolygon([rect.topRight, rect.bottomLeft], false) ..addPolygon([rect.topLeft, rect.bottomRight], false); @@ -83,12 +83,12 @@ class Placeholder extends StatelessWidget { @override Widget build(BuildContext context) { - return new LimitedBox( + return LimitedBox( maxWidth: fallbackWidth, maxHeight: fallbackHeight, - child: new CustomPaint( + child: CustomPaint( size: Size.infinite, - foregroundPainter: new _PlaceholderPainter( + foregroundPainter: _PlaceholderPainter( color: color, strokeWidth: strokeWidth, ), diff --git a/packages/flutter/lib/src/widgets/platform_view.dart b/packages/flutter/lib/src/widgets/platform_view.dart index 800e880105..fbafbd620d 100644 --- a/packages/flutter/lib/src/widgets/platform_view.dart +++ b/packages/flutter/lib/src/widgets/platform_view.dart @@ -146,7 +146,7 @@ class AndroidView extends StatefulWidget { final MessageCodec creationParamsCodec; @override - State createState() => new _AndroidViewState(); + State createState() => _AndroidViewState(); } class _AndroidViewState extends State { @@ -157,7 +157,7 @@ class _AndroidViewState extends State { @override Widget build(BuildContext context) { - return new _AndroidPlatformView( + return _AndroidPlatformView( controller: _controller, hitTestBehavior: widget.hitTestBehavior, gestureRecognizers: widget.gestureRecognizers, @@ -249,7 +249,7 @@ class _AndroidPlatformView extends LeafRenderObjectWidget { @override RenderObject createRenderObject(BuildContext context) => - new RenderAndroidView( + RenderAndroidView( viewController: controller, hitTestBehavior: hitTestBehavior, gestureRecognizers: gestureRecognizers, diff --git a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart index 7f647a4451..cef825b39c 100644 --- a/packages/flutter/lib/src/widgets/primary_scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/primary_scroll_controller.dart @@ -56,6 +56,6 @@ class PrimaryScrollController extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('controller', controller, ifNull: 'no controller', showName: false)); + properties.add(DiagnosticsProperty('controller', controller, ifNull: 'no controller', showName: false)); } } diff --git a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart index 0db2898b79..e44f39a896 100644 --- a/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart +++ b/packages/flutter/lib/src/widgets/raw_keyboard_listener.dart @@ -51,12 +51,12 @@ class RawKeyboardListener extends StatefulWidget { final Widget child; @override - _RawKeyboardListenerState createState() => new _RawKeyboardListenerState(); + _RawKeyboardListenerState createState() => _RawKeyboardListenerState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('focusNode', focusNode)); + properties.add(DiagnosticsProperty('focusNode', focusNode)); } } diff --git a/packages/flutter/lib/src/widgets/routes.dart b/packages/flutter/lib/src/widgets/routes.dart index cbfb8154ff..fc912ee1d5 100644 --- a/packages/flutter/lib/src/widgets/routes.dart +++ b/packages/flutter/lib/src/widgets/routes.dart @@ -89,7 +89,7 @@ abstract class TransitionRoute extends OverlayRoute { /// after [popped], because [popped] typically completes before the animation /// even starts, as soon as the route is popped. Future get completed => _transitionCompleter.future; - final Completer _transitionCompleter = new Completer(); + final Completer _transitionCompleter = Completer(); /// The duration the transition lasts. Duration get transitionDuration; @@ -122,7 +122,7 @@ abstract class TransitionRoute extends OverlayRoute { assert(!_transitionCompleter.isCompleted, 'Cannot reuse a $runtimeType after disposing it.'); final Duration duration = transitionDuration; assert(duration != null && duration >= Duration.zero); - return new AnimationController( + return AnimationController( duration: duration, debugLabel: debugLabel, vsync: navigator, @@ -170,7 +170,7 @@ abstract class TransitionRoute extends OverlayRoute { /// animation lets this route coordinate with the entrance and exit transition /// of routes pushed on top of this route. Animation get secondaryAnimation => _secondaryAnimation; - final ProxyAnimation _secondaryAnimation = new ProxyAnimation(kAlwaysDismissedAnimation); + final ProxyAnimation _secondaryAnimation = ProxyAnimation(kAlwaysDismissedAnimation); @override void install(OverlayEntry insertionPoint) { @@ -231,7 +231,7 @@ abstract class TransitionRoute extends OverlayRoute { if (current != null) { if (current is TrainHoppingAnimation) { TrainHoppingAnimation newAnimation; - newAnimation = new TrainHoppingAnimation( + newAnimation = TrainHoppingAnimation( current.currentTrain, nextRoute._animation, onSwitchedTrain: () { @@ -244,7 +244,7 @@ abstract class TransitionRoute extends OverlayRoute { _secondaryAnimation.parent = newAnimation; current.dispose(); } else { - _secondaryAnimation.parent = new TrainHoppingAnimation(current, nextRoute._animation); + _secondaryAnimation.parent = TrainHoppingAnimation(current, nextRoute._animation); } } else { _secondaryAnimation.parent = nextRoute._animation; @@ -520,8 +520,8 @@ class _ModalScopeStatus extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new FlagProperty('isCurrent', value: isCurrent, ifTrue: 'active', ifFalse: 'inactive')); - description.add(new FlagProperty('canPop', value: canPop, ifTrue: 'can pop')); + description.add(FlagProperty('isCurrent', value: isCurrent, ifTrue: 'active', ifFalse: 'inactive')); + description.add(FlagProperty('canPop', value: canPop, ifTrue: 'can pop')); } } @@ -534,7 +534,7 @@ class _ModalScope extends StatefulWidget { final ModalRoute route; @override - _ModalScopeState createState() => new _ModalScopeState(); + _ModalScopeState createState() => _ModalScopeState(); } class _ModalScopeState extends State<_ModalScope> { @@ -555,7 +555,7 @@ class _ModalScopeState extends State<_ModalScope> { animations.add(widget.route.animation); if (widget.route.secondaryAnimation != null) animations.add(widget.route.secondaryAnimation); - _listenable = new Listenable.merge(animations); + _listenable = Listenable.merge(animations); } @override @@ -584,33 +584,33 @@ class _ModalScopeState extends State<_ModalScope> { @override Widget build(BuildContext context) { - return new _ModalScopeStatus( + return _ModalScopeStatus( route: widget.route, isCurrent: widget.route.isCurrent, // _routeSetState is called if this updates canPop: widget.route.canPop, // _routeSetState is called if this updates - child: new Offstage( + child: Offstage( offstage: widget.route.offstage, // _routeSetState is called if this updates - child: new PageStorage( + child: PageStorage( bucket: widget.route._storageBucket, // immutable - child: new FocusScope( + child: FocusScope( node: widget.route.focusScopeNode, // immutable - child: new RepaintBoundary( - child: new AnimatedBuilder( + child: RepaintBoundary( + child: AnimatedBuilder( animation: _listenable, // immutable builder: (BuildContext context, Widget child) { return widget.route.buildTransitions( context, widget.route.animation, widget.route.secondaryAnimation, - new IgnorePointer( + IgnorePointer( ignoring: widget.route.animation?.status == AnimationStatus.reverse, child: child, ), ); }, - child: _page ??= new RepaintBoundary( + child: _page ??= RepaintBoundary( key: widget.route._subtreeKey, // immutable - child: new Builder( + child: Builder( builder: (BuildContext context) { return widget.route.buildPage( context, @@ -851,13 +851,13 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute extends TransitionRoute with LocalHistoryRoute willPop() async { final _ModalScopeState scope = _scopeKey.currentState; assert(scope != null); - for (WillPopCallback callback in new List.from(_willPopCallbacks)) { + for (WillPopCallback callback in List.from(_willPopCallbacks)) { if (!await callback()) return RoutePopDisposition.doNotPop; } @@ -1167,9 +1167,9 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute> _scopeKey = new GlobalKey<_ModalScopeState>(); - final GlobalKey _subtreeKey = new GlobalKey(); - final PageStorageBucket _storageBucket = new PageStorageBucket(); + final GlobalKey<_ModalScopeState> _scopeKey = GlobalKey<_ModalScopeState>(); + final GlobalKey _subtreeKey = GlobalKey(); + final PageStorageBucket _storageBucket = PageStorageBucket(); // one of the builders OverlayEntry _modalBarrier; @@ -1177,27 +1177,27 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute color = new ColorTween( + final Animation color = ColorTween( begin: _kTransparent, end: barrierColor, // changedInternalState is called if this updates - ).animate(new CurvedAnimation( + ).animate(CurvedAnimation( parent: animation, curve: Curves.ease, )); - barrier = new AnimatedModalBarrier( + barrier = AnimatedModalBarrier( color: color, dismissible: barrierDismissible, // changedInternalState is called if this updates semanticsLabel: barrierLabel, // changedInternalState is called if this updates barrierSemanticsDismissible: semanticsDismissible, ); } else { - barrier = new ModalBarrier( + barrier = ModalBarrier( dismissible: barrierDismissible, // changedInternalState is called if this updates semanticsLabel: barrierLabel, // changedInternalState is called if this updates barrierSemanticsDismissible: semanticsDismissible, ); } - return new IgnorePointer( + return IgnorePointer( ignoring: animation.status == AnimationStatus.reverse || // changedInternalState is called when this updates animation.status == AnimationStatus.dismissed, // dismissed is possible when doing a manual pop gesture child: barrier, @@ -1210,7 +1210,7 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute( + return _modalScopeCache ??= _ModalScope( key: _scopeKey, route: this, // _ModalScope calls buildTransitions() and buildChild(), defined above @@ -1219,8 +1219,8 @@ abstract class ModalRoute extends TransitionRoute with LocalHistoryRoute createOverlayEntries() sync* { - yield _modalBarrier = new OverlayEntry(builder: _buildModalBarrier); - yield new OverlayEntry(builder: _buildModalScope, maintainState: maintainState); + yield _modalBarrier = OverlayEntry(builder: _buildModalBarrier); + yield OverlayEntry(builder: _buildModalScope, maintainState: maintainState); } @override @@ -1324,7 +1324,7 @@ class RouteObserver> extends NavigatorObserver { void subscribe(RouteAware routeAware, R route) { assert(routeAware != null); assert(route != null); - final Set subscribers = _listeners.putIfAbsent(route, () => new Set()); + final Set subscribers = _listeners.putIfAbsent(route, () => Set()); if (subscribers.add(routeAware)) { routeAware.didPush(); } @@ -1437,7 +1437,7 @@ class _DialogRoute extends PopupRoute { @override Widget buildPage(BuildContext context, Animation animation, Animation secondaryAnimation) { - return new Semantics( + return Semantics( child: _pageBuilder(context, animation, secondaryAnimation), scopesRoute: true, explicitChildNodes: true, @@ -1447,8 +1447,8 @@ class _DialogRoute extends PopupRoute { @override Widget buildTransitions(BuildContext context, Animation animation, Animation secondaryAnimation, Widget child) { if (_transitionBuilder == null) { - return new FadeTransition( - opacity: new CurvedAnimation( + return FadeTransition( + opacity: CurvedAnimation( parent: animation, curve: Curves.linear, ), @@ -1515,7 +1515,7 @@ Future showGeneralDialog({ }) { assert(pageBuilder != null); assert(!barrierDismissible || barrierLabel != null); - return Navigator.of(context, rootNavigator: true).push(new _DialogRoute( + return Navigator.of(context, rootNavigator: true).push(_DialogRoute( pageBuilder: pageBuilder, barrierDismissible: barrierDismissible, barrierLabel: barrierLabel, diff --git a/packages/flutter/lib/src/widgets/safe_area.dart b/packages/flutter/lib/src/widgets/safe_area.dart index 3b054830ed..2c847db91d 100644 --- a/packages/flutter/lib/src/widgets/safe_area.dart +++ b/packages/flutter/lib/src/widgets/safe_area.dart @@ -80,14 +80,14 @@ class SafeArea extends StatelessWidget { Widget build(BuildContext context) { assert(debugCheckHasMediaQuery(context)); final EdgeInsets padding = MediaQuery.of(context).padding; - return new Padding( - padding: new EdgeInsets.only( + return Padding( + padding: EdgeInsets.only( left: math.max(left ? padding.left : 0.0, minimum.left), top: math.max(top ? padding.top : 0.0, minimum.top), right: math.max(right ? padding.right : 0.0, minimum.right), bottom: math.max(bottom ? padding.bottom : 0.0, minimum.bottom), ), - child: new MediaQuery.removePadding( + child: MediaQuery.removePadding( context: context, removeLeft: left, removeTop: top, @@ -101,10 +101,10 @@ class SafeArea extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('left', value: left, ifTrue: 'avoid left padding')); - properties.add(new FlagProperty('top', value: left, ifTrue: 'avoid top padding')); - properties.add(new FlagProperty('right', value: left, ifTrue: 'avoid right padding')); - properties.add(new FlagProperty('bottom', value: left, ifTrue: 'avoid bottom padding')); + properties.add(FlagProperty('left', value: left, ifTrue: 'avoid left padding')); + properties.add(FlagProperty('top', value: left, ifTrue: 'avoid top padding')); + properties.add(FlagProperty('right', value: left, ifTrue: 'avoid right padding')); + properties.add(FlagProperty('bottom', value: left, ifTrue: 'avoid bottom padding')); } } @@ -174,14 +174,14 @@ class SliverSafeArea extends StatelessWidget { Widget build(BuildContext context) { assert(debugCheckHasMediaQuery(context)); final EdgeInsets padding = MediaQuery.of(context).padding; - return new SliverPadding( - padding: new EdgeInsets.only( + return SliverPadding( + padding: EdgeInsets.only( left: math.max(left ? padding.left : 0.0, minimum.left), top: math.max(top ? padding.top : 0.0, minimum.top), right: math.max(right ? padding.right : 0.0, minimum.right), bottom: math.max(bottom ? padding.bottom : 0.0, minimum.bottom), ), - sliver: new MediaQuery.removePadding( + sliver: MediaQuery.removePadding( context: context, removeLeft: left, removeTop: top, @@ -195,9 +195,9 @@ class SliverSafeArea extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('left', value: left, ifTrue: 'avoid left padding')); - properties.add(new FlagProperty('top', value: left, ifTrue: 'avoid top padding')); - properties.add(new FlagProperty('right', value: left, ifTrue: 'avoid right padding')); - properties.add(new FlagProperty('bottom', value: left, ifTrue: 'avoid bottom padding')); + properties.add(FlagProperty('left', value: left, ifTrue: 'avoid left padding')); + properties.add(FlagProperty('top', value: left, ifTrue: 'avoid top padding')); + properties.add(FlagProperty('right', value: left, ifTrue: 'avoid right padding')); + properties.add(FlagProperty('bottom', value: left, ifTrue: 'avoid bottom padding')); } } diff --git a/packages/flutter/lib/src/widgets/scroll_activity.dart b/packages/flutter/lib/src/widgets/scroll_activity.dart index 3694e6e60e..4fbb9b9a59 100644 --- a/packages/flutter/lib/src/widgets/scroll_activity.dart +++ b/packages/flutter/lib/src/widgets/scroll_activity.dart @@ -88,22 +88,22 @@ abstract class ScrollActivity { /// Dispatch a [ScrollStartNotification] with the given metrics. void dispatchScrollStartNotification(ScrollMetrics metrics, BuildContext context) { - new ScrollStartNotification(metrics: metrics, context: context).dispatch(context); + ScrollStartNotification(metrics: metrics, context: context).dispatch(context); } /// Dispatch a [ScrollUpdateNotification] with the given metrics and scroll delta. void dispatchScrollUpdateNotification(ScrollMetrics metrics, BuildContext context, double scrollDelta) { - new ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta).dispatch(context); + ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta).dispatch(context); } /// Dispatch an [OverscrollNotification] with the given metrics and overscroll. void dispatchOverscrollNotification(ScrollMetrics metrics, BuildContext context, double overscroll) { - new OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll).dispatch(context); + OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll).dispatch(context); } /// Dispatch a [ScrollEndNotification] with the given metrics and overscroll. void dispatchScrollEndNotification(ScrollMetrics metrics, BuildContext context) { - new ScrollEndNotification(metrics: metrics, context: context).dispatch(context); + ScrollEndNotification(metrics: metrics, context: context).dispatch(context); } /// Called when the scroll view that is performing this activity changes its metrics. @@ -433,28 +433,28 @@ class DragScrollActivity extends ScrollActivity { void dispatchScrollStartNotification(ScrollMetrics metrics, BuildContext context) { final dynamic lastDetails = _controller.lastDetails; assert(lastDetails is DragStartDetails); - new ScrollStartNotification(metrics: metrics, context: context, dragDetails: lastDetails).dispatch(context); + ScrollStartNotification(metrics: metrics, context: context, dragDetails: lastDetails).dispatch(context); } @override void dispatchScrollUpdateNotification(ScrollMetrics metrics, BuildContext context, double scrollDelta) { final dynamic lastDetails = _controller.lastDetails; assert(lastDetails is DragUpdateDetails); - new ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta, dragDetails: lastDetails).dispatch(context); + ScrollUpdateNotification(metrics: metrics, context: context, scrollDelta: scrollDelta, dragDetails: lastDetails).dispatch(context); } @override void dispatchOverscrollNotification(ScrollMetrics metrics, BuildContext context, double overscroll) { final dynamic lastDetails = _controller.lastDetails; assert(lastDetails is DragUpdateDetails); - new OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, dragDetails: lastDetails).dispatch(context); + OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, dragDetails: lastDetails).dispatch(context); } @override void dispatchScrollEndNotification(ScrollMetrics metrics, BuildContext context) { // We might not have DragEndDetails yet if we're being called from beginActivity. final dynamic lastDetails = _controller.lastDetails; - new ScrollEndNotification( + ScrollEndNotification( metrics: metrics, context: context, dragDetails: lastDetails is DragEndDetails ? lastDetails : null @@ -506,7 +506,7 @@ class BallisticScrollActivity extends ScrollActivity { Simulation simulation, TickerProvider vsync, ) : super(delegate) { - _controller = new AnimationController.unbounded( + _controller = AnimationController.unbounded( debugLabel: '$runtimeType', vsync: vsync, ) @@ -553,7 +553,7 @@ class BallisticScrollActivity extends ScrollActivity { @override void dispatchOverscrollNotification(ScrollMetrics metrics, BuildContext context, double overscroll) { - new OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, velocity: velocity).dispatch(context); + OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, velocity: velocity).dispatch(context); } @override @@ -601,8 +601,8 @@ class DrivenScrollActivity extends ScrollActivity { assert(duration > Duration.zero), assert(curve != null), super(delegate) { - _completer = new Completer(); - _controller = new AnimationController.unbounded( + _completer = Completer(); + _controller = AnimationController.unbounded( value: from, debugLabel: '$runtimeType', vsync: vsync, @@ -636,7 +636,7 @@ class DrivenScrollActivity extends ScrollActivity { @override void dispatchOverscrollNotification(ScrollMetrics metrics, BuildContext context, double overscroll) { - new OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, velocity: velocity).dispatch(context); + OverscrollNotification(metrics: metrics, context: context, overscroll: overscroll, velocity: velocity).dispatch(context); } @override diff --git a/packages/flutter/lib/src/widgets/scroll_configuration.dart b/packages/flutter/lib/src/widgets/scroll_configuration.dart index a02c2a795a..d55fd889d2 100644 --- a/packages/flutter/lib/src/widgets/scroll_configuration.dart +++ b/packages/flutter/lib/src/widgets/scroll_configuration.dart @@ -38,7 +38,7 @@ class ScrollBehavior { return child; case TargetPlatform.android: case TargetPlatform.fuchsia: - return new GlowingOverscrollIndicator( + return GlowingOverscrollIndicator( child: child, axisDirection: axisDirection, color: _kDefaultGlowColor, @@ -114,6 +114,6 @@ class ScrollConfiguration extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('behavior', behavior)); + properties.add(DiagnosticsProperty('behavior', behavior)); } } diff --git a/packages/flutter/lib/src/widgets/scroll_controller.dart b/packages/flutter/lib/src/widgets/scroll_controller.dart index a20aa600d7..3c37682678 100644 --- a/packages/flutter/lib/src/widgets/scroll_controller.dart +++ b/packages/flutter/lib/src/widgets/scroll_controller.dart @@ -147,7 +147,7 @@ class ScrollController extends ChangeNotifier { @required Curve curve, }) { assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.'); - final List> animations = new List>(_positions.length); + final List> animations = List>(_positions.length); for (int i = 0; i < _positions.length; i += 1) animations[i] = _positions[i].animateTo(offset, duration: duration, curve: curve); return Future.wait(animations).then((List _) => null); @@ -167,7 +167,7 @@ class ScrollController extends ChangeNotifier { /// value was out of range. void jumpTo(double value) { assert(_positions.isNotEmpty, 'ScrollController not attached to any scroll views.'); - for (ScrollPosition position in new List.from(_positions)) + for (ScrollPosition position in List.from(_positions)) position.jumpTo(value); } @@ -229,7 +229,7 @@ class ScrollController extends ChangeNotifier { ScrollContext context, ScrollPosition oldPosition, ) { - return new ScrollPositionWithSingleContext( + return ScrollPositionWithSingleContext( physics: physics, context: context, initialPixels: initialScrollOffset, diff --git a/packages/flutter/lib/src/widgets/scroll_metrics.dart b/packages/flutter/lib/src/widgets/scroll_metrics.dart index 93f00d7aec..97675e3a49 100644 --- a/packages/flutter/lib/src/widgets/scroll_metrics.dart +++ b/packages/flutter/lib/src/widgets/scroll_metrics.dart @@ -47,7 +47,7 @@ abstract class ScrollMetrics { double viewportDimension, AxisDirection axisDirection, }) { - return new FixedScrollMetrics( + return FixedScrollMetrics( minScrollExtent: minScrollExtent ?? this.minScrollExtent, maxScrollExtent: maxScrollExtent ?? this.maxScrollExtent, pixels: pixels ?? this.pixels, diff --git a/packages/flutter/lib/src/widgets/scroll_physics.dart b/packages/flutter/lib/src/widgets/scroll_physics.dart index 8ba89fc012..3f19a0e4cf 100644 --- a/packages/flutter/lib/src/widgets/scroll_physics.dart +++ b/packages/flutter/lib/src/widgets/scroll_physics.dart @@ -64,7 +64,7 @@ class ScrollPhysics { /// * [buildParent], a utility method that's often used to define [applyTo] /// methods for ScrollPhysics subclasses. ScrollPhysics applyTo(ScrollPhysics ancestor) { - return new ScrollPhysics(parent: buildParent(ancestor)); + return ScrollPhysics(parent: buildParent(ancestor)); } /// Used by [DragScrollActivity] and other user-driven activities to convert @@ -160,7 +160,7 @@ class ScrollPhysics { return parent.createBallisticSimulation(position, velocity); } - static final SpringDescription _kDefaultSpring = new SpringDescription.withDampingRatio( + static final SpringDescription _kDefaultSpring = SpringDescription.withDampingRatio( mass: 0.5, stiffness: 100.0, ratio: 1.1, @@ -170,7 +170,7 @@ class ScrollPhysics { SpringDescription get spring => parent?.spring ?? _kDefaultSpring; /// The default accuracy to which scrolling is computed. - static final Tolerance _kDefaultTolerance = new Tolerance( + static final Tolerance _kDefaultTolerance = Tolerance( // TODO(ianh): Handle the case of the device pixel ratio changing. // TODO(ianh): Get this from the local MediaQuery not dart:ui's window object. velocity: 1.0 / (0.050 * ui.window.devicePixelRatio), // logical pixels per second @@ -260,7 +260,7 @@ class BouncingScrollPhysics extends ScrollPhysics { @override BouncingScrollPhysics applyTo(ScrollPhysics ancestor) { - return new BouncingScrollPhysics(parent: buildParent(ancestor)); + return BouncingScrollPhysics(parent: buildParent(ancestor)); } /// The multiple applied to overscroll to make it appear that scrolling past @@ -316,7 +316,7 @@ class BouncingScrollPhysics extends ScrollPhysics { Simulation createBallisticSimulation(ScrollMetrics position, double velocity) { final Tolerance tolerance = this.tolerance; if (velocity.abs() >= tolerance.velocity || position.outOfRange) { - return new BouncingScrollSimulation( + return BouncingScrollSimulation( spring: spring, position: position.pixels, velocity: velocity * 0.91, // TODO(abarth): We should move this constant closer to the drag end. @@ -382,14 +382,14 @@ class ClampingScrollPhysics extends ScrollPhysics { @override ClampingScrollPhysics applyTo(ScrollPhysics ancestor) { - return new ClampingScrollPhysics(parent: buildParent(ancestor)); + return ClampingScrollPhysics(parent: buildParent(ancestor)); } @override double applyBoundaryConditions(ScrollMetrics position, double value) { assert(() { if (value == position.pixels) { - throw new FlutterError( + throw FlutterError( '$runtimeType.applyBoundaryConditions() was called redundantly.\n' 'The proposed new position, $value, is exactly equal to the current position of the ' 'given ${position.runtimeType}, ${position.pixels}.\n' @@ -424,7 +424,7 @@ class ClampingScrollPhysics extends ScrollPhysics { if (position.pixels < position.minScrollExtent) end = position.minScrollExtent; assert(end != null); - return new ScrollSpringSimulation( + return ScrollSpringSimulation( spring, position.pixels, position.maxScrollExtent, @@ -438,7 +438,7 @@ class ClampingScrollPhysics extends ScrollPhysics { return null; if (velocity < 0.0 && position.pixels <= position.minScrollExtent) return null; - return new ClampingScrollSimulation( + return ClampingScrollSimulation( position: position.pixels, velocity: velocity, tolerance: tolerance, @@ -466,7 +466,7 @@ class AlwaysScrollableScrollPhysics extends ScrollPhysics { @override AlwaysScrollableScrollPhysics applyTo(ScrollPhysics ancestor) { - return new AlwaysScrollableScrollPhysics(parent: buildParent(ancestor)); + return AlwaysScrollableScrollPhysics(parent: buildParent(ancestor)); } @override @@ -489,7 +489,7 @@ class NeverScrollableScrollPhysics extends ScrollPhysics { @override NeverScrollableScrollPhysics applyTo(ScrollPhysics ancestor) { - return new NeverScrollableScrollPhysics(parent: buildParent(ancestor)); + return NeverScrollableScrollPhysics(parent: buildParent(ancestor)); } @override diff --git a/packages/flutter/lib/src/widgets/scroll_position.dart b/packages/flutter/lib/src/widgets/scroll_position.dart index 30b8df5162..9048442d78 100644 --- a/packages/flutter/lib/src/widgets/scroll_position.dart +++ b/packages/flutter/lib/src/widgets/scroll_position.dart @@ -203,7 +203,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { assert(() { final double delta = newPixels - pixels; if (overscroll.abs() > delta.abs()) { - throw new FlutterError( + throw FlutterError( '$runtimeType.applyBoundaryConditions returned invalid overscroll value.\n' 'setPixels() was called to change the scroll offset from $pixels to $newPixels.\n' 'That is a delta of $delta units.\n' @@ -374,7 +374,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { assert(() { final double delta = value - pixels; if (result.abs() > delta.abs()) { - throw new FlutterError( + throw FlutterError( '${physics.runtimeType}.applyBoundaryConditions returned invalid overscroll value.\n' 'The method was called to consider a change from $pixels to $value, which is a ' 'delta of ${delta.toStringAsFixed(1)} units. However, it returned an overscroll of ' @@ -432,7 +432,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { break; } - final Set actions = new Set(); + final Set actions = Set(); if (pixels > minScrollExtent) actions.add(backward); if (pixels < maxScrollExtent) @@ -500,11 +500,11 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { final double target = viewport.getOffsetToReveal(object, alignment).offset.clamp(minScrollExtent, maxScrollExtent); if (target == pixels) - return new Future.value(); + return Future.value(); if (duration == Duration.zero) { jumpTo(target); - return new Future.value(); + return Future.value(); } return animateTo(target, duration: duration, curve: curve); @@ -515,7 +515,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { /// /// Listeners added by stateful widgets should be removed in the widget's /// [State.dispose] method. - final ValueNotifier isScrollingNotifier = new ValueNotifier(false); + final ValueNotifier isScrollingNotifier = ValueNotifier(false); /// Animates the position from its current value to the given value. /// @@ -653,7 +653,7 @@ abstract class ScrollPosition extends ViewportOffset with ScrollMetrics { /// /// Subclasses should call this function when they change [userScrollDirection]. void didUpdateScrollDirection(ScrollDirection direction) { - new UserScrollNotification(metrics: copyWith(), context: context.notificationContext, direction: direction).dispatch(context.notificationContext); + UserScrollNotification(metrics: copyWith(), context: context.notificationContext, direction: direction).dispatch(context.notificationContext); } @override diff --git a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart index 968fffb08c..bd7ab341c5 100644 --- a/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart +++ b/packages/flutter/lib/src/widgets/scroll_position_with_single_context.dart @@ -129,7 +129,7 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc @override void goIdle() { - beginActivity(new IdleScrollActivity(this)); + beginActivity(IdleScrollActivity(this)); } /// Start a physics-driven simulation that settles the [pixels] position, @@ -146,7 +146,7 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc assert(pixels != null); final Simulation simulation = physics.createBallisticSimulation(this, velocity); if (simulation != null) { - beginActivity(new BallisticScrollActivity(this, simulation, context.vsync)); + beginActivity(BallisticScrollActivity(this, simulation, context.vsync)); } else { goIdle(); } @@ -176,10 +176,10 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc if (nearEqual(to, pixels, physics.tolerance.distance)) { // Skip the animation, go straight to the position as we are already close. jumpTo(to); - return new Future.value(); + return Future.value(); } - final DrivenScrollActivity activity = new DrivenScrollActivity( + final DrivenScrollActivity activity = DrivenScrollActivity( this, from: pixels, to: to, @@ -222,7 +222,7 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc @override ScrollHoldController hold(VoidCallback holdCancelCallback) { final double previousVelocity = activity.velocity; - final HoldScrollActivity holdActivity = new HoldScrollActivity( + final HoldScrollActivity holdActivity = HoldScrollActivity( delegate: this, onHoldCanceled: holdCancelCallback, ); @@ -235,14 +235,14 @@ class ScrollPositionWithSingleContext extends ScrollPosition implements ScrollAc @override Drag drag(DragStartDetails details, VoidCallback dragCancelCallback) { - final ScrollDragController drag = new ScrollDragController( + final ScrollDragController drag = ScrollDragController( delegate: this, details: details, onDragCanceled: dragCancelCallback, carriedVelocity: physics.carriedMomentum(_heldPreviousVelocity), motionStartDistanceThreshold: physics.dragStartDistanceMotionThreshold, ); - beginActivity(new DragScrollActivity(this, drag)); + beginActivity(DragScrollActivity(this, drag)); assert(_currentDrag == null); _currentDrag = drag; return drag; diff --git a/packages/flutter/lib/src/widgets/scroll_simulation.dart b/packages/flutter/lib/src/widgets/scroll_simulation.dart index 38c45caf14..96b4e2dd7a 100644 --- a/packages/flutter/lib/src/widgets/scroll_simulation.dart +++ b/packages/flutter/lib/src/widgets/scroll_simulation.dart @@ -49,7 +49,7 @@ class BouncingScrollSimulation extends Simulation { _springSimulation = _overscrollSimulation(position, velocity); _springTime = double.negativeInfinity; } else { - _frictionSimulation = new FrictionSimulation(0.135, position, velocity); + _frictionSimulation = FrictionSimulation(0.135, position, velocity); final double finalX = _frictionSimulation.finalX; if (velocity > 0.0 && finalX > trailingExtent) { _springTime = _frictionSimulation.timeAtX(trailingExtent); @@ -93,11 +93,11 @@ class BouncingScrollSimulation extends Simulation { double _timeOffset = 0.0; Simulation _underscrollSimulation(double x, double dx) { - return new ScrollSpringSimulation(spring, x, leadingExtent, dx); + return ScrollSpringSimulation(spring, x, leadingExtent, dx); } Simulation _overscrollSimulation(double x, double dx) { - return new ScrollSpringSimulation(spring, x, trailingExtent, dx); + return ScrollSpringSimulation(spring, x, trailingExtent, dx); } Simulation _simulation(double time) { diff --git a/packages/flutter/lib/src/widgets/scroll_view.dart b/packages/flutter/lib/src/widgets/scroll_view.dart index f73af56dec..f993487766 100644 --- a/packages/flutter/lib/src/widgets/scroll_view.dart +++ b/packages/flutter/lib/src/widgets/scroll_view.dart @@ -208,13 +208,13 @@ abstract class ScrollView extends StatelessWidget { List slivers, ) { if (shrinkWrap) { - return new ShrinkWrappingViewport( + return ShrinkWrappingViewport( axisDirection: axisDirection, offset: offset, slivers: slivers, ); } - return new Viewport( + return Viewport( axisDirection: axisDirection, offset: offset, slivers: slivers, @@ -230,7 +230,7 @@ abstract class ScrollView extends StatelessWidget { final ScrollController scrollController = primary ? PrimaryScrollController.of(context) : controller; - final Scrollable scrollable = new Scrollable( + final Scrollable scrollable = Scrollable( axisDirection: axisDirection, controller: scrollController, physics: physics, @@ -239,19 +239,19 @@ abstract class ScrollView extends StatelessWidget { }, ); return primary && scrollController != null - ? new PrimaryScrollController.none(child: scrollable) + ? PrimaryScrollController.none(child: scrollable) : scrollable; } @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('scrollDirection', scrollDirection)); - properties.add(new FlagProperty('reverse', value: reverse, ifTrue: 'reversed', showName: true)); - properties.add(new DiagnosticsProperty('controller', controller, showName: false, defaultValue: null)); - properties.add(new FlagProperty('primary', value: primary, ifTrue: 'using primary controller', showName: true)); - properties.add(new DiagnosticsProperty('physics', physics, showName: false, defaultValue: null)); - properties.add(new FlagProperty('shrinkWrap', value: shrinkWrap, ifTrue: 'shrink-wrapping', showName: true)); + properties.add(EnumProperty('scrollDirection', scrollDirection)); + properties.add(FlagProperty('reverse', value: reverse, ifTrue: 'reversed', showName: true)); + properties.add(DiagnosticsProperty('controller', controller, showName: false, defaultValue: null)); + properties.add(FlagProperty('primary', value: primary, ifTrue: 'using primary controller', showName: true)); + properties.add(DiagnosticsProperty('physics', physics, showName: false, defaultValue: null)); + properties.add(FlagProperty('shrinkWrap', value: shrinkWrap, ifTrue: 'shrink-wrapping', showName: true)); } } @@ -414,7 +414,7 @@ abstract class BoxScrollView extends ScrollView { ? mediaQueryVerticalPadding : mediaQueryHorizontalPadding; // Leave behind the cross axis padding. - sliver = new MediaQuery( + sliver = MediaQuery( data: mediaQuery.copyWith( padding: scrollDirection == Axis.vertical ? mediaQueryHorizontalPadding @@ -426,7 +426,7 @@ abstract class BoxScrollView extends ScrollView { } if (effectivePadding != null) - sliver = new SliverPadding(padding: effectivePadding, sliver: sliver); + sliver = SliverPadding(padding: effectivePadding, sliver: sliver); return [ sliver ]; } @@ -437,7 +437,7 @@ abstract class BoxScrollView extends ScrollView { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('padding', padding, defaultValue: null)); + properties.add(DiagnosticsProperty('padding', padding, defaultValue: null)); } } @@ -674,7 +674,7 @@ class ListView extends BoxScrollView { bool addRepaintBoundaries = true, double cacheExtent, List children = const [], - }) : childrenDelegate = new SliverChildListDelegate( + }) : childrenDelegate = SliverChildListDelegate( children, addAutomaticKeepAlives: addAutomaticKeepAlives, addRepaintBoundaries: addRepaintBoundaries, @@ -729,7 +729,7 @@ class ListView extends BoxScrollView { bool addAutomaticKeepAlives = true, bool addRepaintBoundaries = true, double cacheExtent, - }) : childrenDelegate = new SliverChildBuilderDelegate( + }) : childrenDelegate = SliverChildBuilderDelegate( itemBuilder, childCount: itemCount, addAutomaticKeepAlives: addAutomaticKeepAlives, @@ -809,7 +809,7 @@ class ListView extends BoxScrollView { assert(separatorBuilder != null), assert(itemCount != null && itemCount >= 0), itemExtent = null, - childrenDelegate = new SliverChildBuilderDelegate( + childrenDelegate = SliverChildBuilderDelegate( (BuildContext context, int index) { final int itemIndex = index ~/ 2; return index.isEven @@ -880,18 +880,18 @@ class ListView extends BoxScrollView { @override Widget buildChildLayout(BuildContext context) { if (itemExtent != null) { - return new SliverFixedExtentList( + return SliverFixedExtentList( delegate: childrenDelegate, itemExtent: itemExtent, ); } - return new SliverList(delegate: childrenDelegate); + return SliverList(delegate: childrenDelegate); } @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DoubleProperty('itemExtent', itemExtent, defaultValue: null)); + properties.add(DoubleProperty('itemExtent', itemExtent, defaultValue: null)); } } @@ -1050,7 +1050,7 @@ class GridView extends BoxScrollView { double cacheExtent, List children = const [], }) : assert(gridDelegate != null), - childrenDelegate = new SliverChildListDelegate( + childrenDelegate = SliverChildListDelegate( children, addAutomaticKeepAlives: addAutomaticKeepAlives, addRepaintBoundaries: addRepaintBoundaries, @@ -1102,7 +1102,7 @@ class GridView extends BoxScrollView { bool addRepaintBoundaries = true, double cacheExtent, }) : assert(gridDelegate != null), - childrenDelegate = new SliverChildBuilderDelegate( + childrenDelegate = SliverChildBuilderDelegate( itemBuilder, childCount: itemCount, addAutomaticKeepAlives: addAutomaticKeepAlives, @@ -1184,13 +1184,13 @@ class GridView extends BoxScrollView { bool addRepaintBoundaries = true, double cacheExtent, List children = const [], - }) : gridDelegate = new SliverGridDelegateWithFixedCrossAxisCount( + }) : gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: crossAxisCount, mainAxisSpacing: mainAxisSpacing, crossAxisSpacing: crossAxisSpacing, childAspectRatio: childAspectRatio, ), - childrenDelegate = new SliverChildListDelegate( + childrenDelegate = SliverChildListDelegate( children, addAutomaticKeepAlives: addAutomaticKeepAlives, addRepaintBoundaries: addRepaintBoundaries, @@ -1236,13 +1236,13 @@ class GridView extends BoxScrollView { bool addAutomaticKeepAlives = true, bool addRepaintBoundaries = true, List children = const [], - }) : gridDelegate = new SliverGridDelegateWithMaxCrossAxisExtent( + }) : gridDelegate = SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: maxCrossAxisExtent, mainAxisSpacing: mainAxisSpacing, crossAxisSpacing: crossAxisSpacing, childAspectRatio: childAspectRatio, ), - childrenDelegate = new SliverChildListDelegate( + childrenDelegate = SliverChildListDelegate( children, addAutomaticKeepAlives: addAutomaticKeepAlives, addRepaintBoundaries: addRepaintBoundaries, @@ -1273,7 +1273,7 @@ class GridView extends BoxScrollView { @override Widget buildChildLayout(BuildContext context) { - return new SliverGrid( + return SliverGrid( delegate: childrenDelegate, gridDelegate: gridDelegate, ); diff --git a/packages/flutter/lib/src/widgets/scrollable.dart b/packages/flutter/lib/src/widgets/scrollable.dart index 92a38bbff9..4cfb559aa0 100644 --- a/packages/flutter/lib/src/widgets/scrollable.dart +++ b/packages/flutter/lib/src/widgets/scrollable.dart @@ -167,13 +167,13 @@ class Scrollable extends StatefulWidget { Axis get axis => axisDirectionToAxis(axisDirection); @override - ScrollableState createState() => new ScrollableState(); + ScrollableState createState() => ScrollableState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('axisDirection', axisDirection)); - properties.add(new DiagnosticsProperty('physics', physics)); + properties.add(EnumProperty('axisDirection', axisDirection)); + properties.add(DiagnosticsProperty('physics', physics)); } /// The state from the closest instance of this class that encloses the given context. @@ -210,7 +210,7 @@ class Scrollable extends StatefulWidget { } if (futures.isEmpty || duration == Duration.zero) - return new Future.value(); + return Future.value(); if (futures.length == 1) return futures.single; return Future.wait(futures).then((List _) => null); @@ -281,7 +281,7 @@ class ScrollableState extends State with TickerProviderStateMixin } _position = controller?.createScrollPosition(_physics, this, oldPosition) - ?? new ScrollPositionWithSingleContext(physics: _physics, context: this, oldPosition: oldPosition); + ?? ScrollPositionWithSingleContext(physics: _physics, context: this, oldPosition: oldPosition); assert(position != null); controller?.attach(position); } @@ -328,7 +328,7 @@ class ScrollableState extends State with TickerProviderStateMixin // SEMANTICS - final GlobalKey _scrollSemanticsKey = new GlobalKey(); + final GlobalKey _scrollSemanticsKey = GlobalKey(); @override @protected @@ -340,8 +340,8 @@ class ScrollableState extends State with TickerProviderStateMixin // GESTURE RECOGNITION AND POINTER IGNORING - final GlobalKey _gestureDetectorKey = new GlobalKey(); - final GlobalKey _ignorePointerKey = new GlobalKey(); + final GlobalKey _gestureDetectorKey = GlobalKey(); + final GlobalKey _ignorePointerKey = GlobalKey(); // This field is set during layout, and then reused until the next time it is set. Map _gestureRecognizers = const {}; @@ -361,8 +361,8 @@ class ScrollableState extends State with TickerProviderStateMixin switch (widget.axis) { case Axis.vertical: _gestureRecognizers = { - VerticalDragGestureRecognizer: new GestureRecognizerFactoryWithHandlers( - () => new VerticalDragGestureRecognizer(), + VerticalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers( + () => VerticalDragGestureRecognizer(), (VerticalDragGestureRecognizer instance) { instance ..onDown = _handleDragDown @@ -379,8 +379,8 @@ class ScrollableState extends State with TickerProviderStateMixin break; case Axis.horizontal: _gestureRecognizers = { - HorizontalDragGestureRecognizer: new GestureRecognizerFactoryWithHandlers( - () => new HorizontalDragGestureRecognizer(), + HorizontalDragGestureRecognizer: GestureRecognizerFactoryWithHandlers( + () => HorizontalDragGestureRecognizer(), (HorizontalDragGestureRecognizer instance) { instance ..onDown = _handleDragDown @@ -483,18 +483,18 @@ class ScrollableState extends State with TickerProviderStateMixin Widget build(BuildContext context) { assert(position != null); // TODO(ianh): Having all these global keys is sad. - Widget result = new RawGestureDetector( + Widget result = RawGestureDetector( key: _gestureDetectorKey, gestures: _gestureRecognizers, behavior: HitTestBehavior.opaque, excludeFromSemantics: widget.excludeFromSemantics, - child: new Semantics( + child: Semantics( explicitChildNodes: !widget.excludeFromSemantics, - child: new IgnorePointer( + child: IgnorePointer( key: _ignorePointerKey, ignoring: _shouldIgnorePointer, ignoringSemantics: false, - child: new _ScrollableScope( + child: _ScrollableScope( scrollable: this, position: position, child: widget.viewportBuilder(context, position), @@ -504,7 +504,7 @@ class ScrollableState extends State with TickerProviderStateMixin ); if (!widget.excludeFromSemantics) { - result = new _ScrollSemantics( + result = _ScrollSemantics( key: _scrollSemanticsKey, child: result, position: position, @@ -518,7 +518,7 @@ class ScrollableState extends State with TickerProviderStateMixin @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('position', position)); + properties.add(DiagnosticsProperty('position', position)); } } @@ -549,7 +549,7 @@ class _ScrollSemantics extends SingleChildRenderObjectWidget { @override _RenderScrollSemantics createRenderObject(BuildContext context) { - return new _RenderScrollSemantics( + return _RenderScrollSemantics( position: position, allowImplicitScrolling: allowImplicitScrolling, ); @@ -619,7 +619,7 @@ class _RenderScrollSemantics extends RenderProxyBox { return; } - _innerNode ??= new SemanticsNode(showOnScreen: showOnScreen); + _innerNode ??= SemanticsNode(showOnScreen: showOnScreen); _innerNode ..isMergedIntoParent = node.isPartOfNodeMerging ..rect = Offset.zero & node.rect.size; diff --git a/packages/flutter/lib/src/widgets/scrollbar.dart b/packages/flutter/lib/src/widgets/scrollbar.dart index b9381106b4..47dbc4f1cd 100644 --- a/packages/flutter/lib/src/widgets/scrollbar.dart +++ b/packages/flutter/lib/src/widgets/scrollbar.dart @@ -112,7 +112,7 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { } Paint get _paint { - return new Paint()..color = + return Paint()..color = color.withOpacity(color.opacity * fadeoutOpacityAnimation.value); } @@ -128,23 +128,23 @@ class ScrollbarPainter extends ChangeNotifier implements CustomPainter { } void _paintVerticalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) { - final Offset thumbOrigin = new Offset(_getThumbX(size), thumbOffset); - final Size thumbSize = new Size(thickness, thumbExtent); + final Offset thumbOrigin = Offset(_getThumbX(size), thumbOffset); + final Size thumbSize = Size(thickness, thumbExtent); final Rect thumbRect = thumbOrigin & thumbSize; if (radius == null) canvas.drawRect(thumbRect, _paint); else - canvas.drawRRect(new RRect.fromRectAndRadius(thumbRect, radius), _paint); + canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, radius), _paint); } void _paintHorizontalThumb(Canvas canvas, Size size, double thumbOffset, double thumbExtent) { - final Offset thumbOrigin = new Offset(thumbOffset, size.height - thickness); - final Size thumbSize = new Size(thumbExtent, thickness); + final Offset thumbOrigin = Offset(thumbOffset, size.height - thickness); + final Size thumbSize = Size(thumbExtent, thickness); final Rect thumbRect = thumbOrigin & thumbSize; if (radius == null) canvas.drawRect(thumbRect, _paint); else - canvas.drawRRect(new RRect.fromRectAndRadius(thumbRect, radius), _paint); + canvas.drawRRect(RRect.fromRectAndRadius(thumbRect, radius), _paint); } void _paintThumb( diff --git a/packages/flutter/lib/src/widgets/semantics_debugger.dart b/packages/flutter/lib/src/widgets/semantics_debugger.dart index 75fb4541c1..2001c73bdf 100644 --- a/packages/flutter/lib/src/widgets/semantics_debugger.dart +++ b/packages/flutter/lib/src/widgets/semantics_debugger.dart @@ -31,7 +31,7 @@ class SemanticsDebugger extends StatefulWidget { final Widget child; @override - _SemanticsDebuggerState createState() => new _SemanticsDebuggerState(); + _SemanticsDebuggerState createState() => _SemanticsDebuggerState(); } class _SemanticsDebuggerState extends State with WidgetsBindingObserver { @@ -44,7 +44,7 @@ class _SemanticsDebuggerState extends State with WidgetsBindi // static here because we might not be in a tree that's attached to that // binding. Instead, we should find a way to get to the PipelineOwner from // the BuildContext. - _client = new _SemanticsClient(WidgetsBinding.instance.pipelineOwner) + _client = _SemanticsClient(WidgetsBinding.instance.pipelineOwner) ..addListener(_update); WidgetsBinding.instance.addObserver(this); } @@ -145,23 +145,23 @@ class _SemanticsDebuggerState extends State with WidgetsBindi @override Widget build(BuildContext context) { - return new CustomPaint( - foregroundPainter: new _SemanticsDebuggerPainter( + return CustomPaint( + foregroundPainter: _SemanticsDebuggerPainter( _pipelineOwner, _client.generation, _lastPointerDownLocation, // in physical pixels ui.window.devicePixelRatio, ), - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: _handleTap, onLongPress: _handleLongPress, onPanEnd: _handlePanEnd, excludeFromSemantics: true, // otherwise if you don't hit anything, we end up receiving it, which causes an infinite loop... - child: new Listener( + child: Listener( onPointerDown: _handlePointerDown, behavior: HitTestBehavior.opaque, - child: new IgnorePointer( + child: IgnorePointer( ignoringSemantics: false, child: widget.child, ), @@ -272,8 +272,8 @@ void _paintMessage(Canvas canvas, SemanticsNode node) { final Rect rect = node.rect; canvas.save(); canvas.clipRect(rect); - final TextPainter textPainter = new TextPainter() - ..text = new TextSpan( + final TextPainter textPainter = TextPainter() + ..text = TextSpan( style: _messageStyle, text: message, ) @@ -302,19 +302,19 @@ void _paint(Canvas canvas, SemanticsNode node, int rank) { canvas.transform(node.transform.storage); final Rect rect = node.rect; if (!rect.isEmpty) { - final Color lineColor = new Color(0xFF000000 + new math.Random(node.id).nextInt(0xFFFFFF)); + final Color lineColor = Color(0xFF000000 + math.Random(node.id).nextInt(0xFFFFFF)); final Rect innerRect = rect.deflate(rank * 1.0); if (innerRect.isEmpty) { - final Paint fill = new Paint() + final Paint fill = Paint() ..color = lineColor ..style = PaintingStyle.fill; canvas.drawRect(rect, fill); } else { - final Paint fill = new Paint() + final Paint fill = Paint() ..color = const Color(0xFFFFFFFF) ..style = PaintingStyle.fill; canvas.drawRect(rect, fill); - final Paint line = new Paint() + final Paint line = Paint() ..strokeWidth = rank * 2.0 ..color = lineColor ..style = PaintingStyle.stroke; @@ -352,7 +352,7 @@ class _SemanticsDebuggerPainter extends CustomPainter { if (rootNode != null) _paint(canvas, rootNode, _findDepth(rootNode)); if (pointerPosition != null) { - final Paint paint = new Paint(); + final Paint paint = Paint(); paint.color = const Color(0x7F0090FF); canvas.drawCircle(pointerPosition, 10.0 * devicePixelRatio, paint); } diff --git a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart index f7f614a96c..5a9aa14c4d 100644 --- a/packages/flutter/lib/src/widgets/single_child_scroll_view.dart +++ b/packages/flutter/lib/src/widgets/single_child_scroll_view.dart @@ -269,16 +269,16 @@ class SingleChildScrollView extends StatelessWidget { final AxisDirection axisDirection = _getDirection(context); Widget contents = child; if (padding != null) - contents = new Padding(padding: padding, child: contents); + contents = Padding(padding: padding, child: contents); final ScrollController scrollController = primary ? PrimaryScrollController.of(context) : controller; - final Scrollable scrollable = new Scrollable( + final Scrollable scrollable = Scrollable( axisDirection: axisDirection, controller: scrollController, physics: physics, viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new _SingleChildViewport( + return _SingleChildViewport( axisDirection: axisDirection, offset: offset, child: contents, @@ -286,7 +286,7 @@ class SingleChildScrollView extends StatelessWidget { }, ); return primary && scrollController != null - ? new PrimaryScrollController.none(child: scrollable) + ? PrimaryScrollController.none(child: scrollable) : scrollable; } } @@ -305,7 +305,7 @@ class _SingleChildViewport extends SingleChildRenderObjectWidget { @override _RenderSingleChildViewport createRenderObject(BuildContext context) { - return new _RenderSingleChildViewport( + return _RenderSingleChildViewport( axisDirection: axisDirection, offset: offset, ); @@ -382,7 +382,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix // We don't actually use the offset argument in BoxParentData, so let's // avoid allocating it at all. if (child.parentData is! ParentData) - child.parentData = new ParentData(); + child.parentData = ParentData(); } @override @@ -491,13 +491,13 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix assert(axisDirection != null); switch (axisDirection) { case AxisDirection.up: - return new Offset(0.0, position - child.size.height + size.height); + return Offset(0.0, position - child.size.height + size.height); case AxisDirection.down: - return new Offset(0.0, -position); + return Offset(0.0, -position); case AxisDirection.left: - return new Offset(position - child.size.width + size.width, 0.0); + return Offset(position - child.size.width + size.width, 0.0); case AxisDirection.right: - return new Offset(-position, 0.0); + return Offset(-position, 0.0); } return null; } @@ -550,7 +550,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix RevealedOffset getOffsetToReveal(RenderObject target, double alignment, {Rect rect}) { rect ??= target.paintBounds; if (target is! RenderBox) - return new RevealedOffset(offset: offset.pixels, rect: rect); + return RevealedOffset(offset: offset.pixels, rect: rect); final RenderBox targetBox = target; final Matrix4 transform = targetBox.getTransformTo(this); @@ -587,7 +587,7 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix final double targetOffset = leadingScrollOffset - (mainAxisExtent - targetMainAxisExtent) * alignment; final Rect targetRect = bounds.shift(_paintOffsetForPosition(targetOffset)); - return new RevealedOffset(offset: targetOffset, rect: targetRect); + return RevealedOffset(offset: targetOffset, rect: targetRect); } @override @@ -626,14 +626,14 @@ class _RenderSingleChildViewport extends RenderBox with RenderObjectWithChildMix assert(axis != null); switch (axis) { case Axis.vertical: - return new Rect.fromLTRB( + return Rect.fromLTRB( semanticBounds.left, semanticBounds.top - cacheExtent, semanticBounds.right, semanticBounds.bottom + cacheExtent, ); case Axis.horizontal: - return new Rect.fromLTRB( + return Rect.fromLTRB( semanticBounds.left - cacheExtent, semanticBounds.top, semanticBounds.right + cacheExtent, diff --git a/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart b/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart index 26aece454b..cc87648bfa 100644 --- a/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart +++ b/packages/flutter/lib/src/widgets/size_changed_layout_notifier.dart @@ -59,9 +59,9 @@ class SizeChangedLayoutNotifier extends SingleChildRenderObjectWidget { @override _RenderSizeChangedWithCallback createRenderObject(BuildContext context) { - return new _RenderSizeChangedWithCallback( + return _RenderSizeChangedWithCallback( onLayoutChangedCallback: () { - new SizeChangedLayoutNotification().dispatch(context); + SizeChangedLayoutNotification().dispatch(context); } ); } diff --git a/packages/flutter/lib/src/widgets/sliver.dart b/packages/flutter/lib/src/widgets/sliver.dart index 721ef20e29..85fa7d6adc 100644 --- a/packages/flutter/lib/src/widgets/sliver.dart +++ b/packages/flutter/lib/src/widgets/sliver.dart @@ -259,9 +259,9 @@ class SliverChildBuilderDelegate extends SliverChildDelegate { if (child == null) return null; if (addRepaintBoundaries) - child = new RepaintBoundary.wrap(child, index); + child = RepaintBoundary.wrap(child, index); if (addAutomaticKeepAlives) - child = new AutomaticKeepAlive(child: child); + child = AutomaticKeepAlive(child: child); return child; } @@ -351,9 +351,9 @@ class SliverChildListDelegate extends SliverChildDelegate { Widget child = children[index]; assert(child != null); if (addRepaintBoundaries) - child = new RepaintBoundary.wrap(child, index); + child = RepaintBoundary.wrap(child, index); if (addAutomaticKeepAlives) - child = new AutomaticKeepAlive(child: child); + child = AutomaticKeepAlive(child: child); return child; } @@ -390,7 +390,7 @@ abstract class SliverMultiBoxAdaptorWidget extends RenderObjectWidget { final SliverChildDelegate delegate; @override - SliverMultiBoxAdaptorElement createElement() => new SliverMultiBoxAdaptorElement(this); + SliverMultiBoxAdaptorElement createElement() => SliverMultiBoxAdaptorElement(this); @override RenderSliverMultiBoxAdaptor createRenderObject(BuildContext context); @@ -424,7 +424,7 @@ abstract class SliverMultiBoxAdaptorWidget extends RenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('delegate', delegate)); + properties.add(DiagnosticsProperty('delegate', delegate)); } } @@ -464,7 +464,7 @@ class SliverList extends SliverMultiBoxAdaptorWidget { @override RenderSliverList createRenderObject(BuildContext context) { final SliverMultiBoxAdaptorElement element = context; - return new RenderSliverList(childManager: element); + return RenderSliverList(childManager: element); } } @@ -526,7 +526,7 @@ class SliverFixedExtentList extends SliverMultiBoxAdaptorWidget { @override RenderSliverFixedExtentList createRenderObject(BuildContext context) { final SliverMultiBoxAdaptorElement element = context; - return new RenderSliverFixedExtentList(childManager: element, itemExtent: itemExtent); + return RenderSliverFixedExtentList(childManager: element, itemExtent: itemExtent); } @override @@ -605,13 +605,13 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget { double crossAxisSpacing = 0.0, double childAspectRatio = 1.0, List children = const [], - }) : gridDelegate = new SliverGridDelegateWithFixedCrossAxisCount( + }) : gridDelegate = SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: crossAxisCount, mainAxisSpacing: mainAxisSpacing, crossAxisSpacing: crossAxisSpacing, childAspectRatio: childAspectRatio, ), - super(key: key, delegate: new SliverChildListDelegate(children)); + super(key: key, delegate: SliverChildListDelegate(children)); /// Creates a sliver that places multiple box children in a two dimensional /// arrangement with tiles that each have a maximum cross-axis extent. @@ -629,13 +629,13 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget { double crossAxisSpacing = 0.0, double childAspectRatio = 1.0, List children = const [], - }) : gridDelegate = new SliverGridDelegateWithMaxCrossAxisExtent( + }) : gridDelegate = SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: maxCrossAxisExtent, mainAxisSpacing: mainAxisSpacing, crossAxisSpacing: crossAxisSpacing, childAspectRatio: childAspectRatio, ), - super(key: key, delegate: new SliverChildListDelegate(children)); + super(key: key, delegate: SliverChildListDelegate(children)); /// The delegate that controls the size and position of the children. final SliverGridDelegate gridDelegate; @@ -643,7 +643,7 @@ class SliverGrid extends SliverMultiBoxAdaptorWidget { @override RenderSliverGrid createRenderObject(BuildContext context) { final SliverMultiBoxAdaptorElement element = context; - return new RenderSliverGrid(childManager: element, gridDelegate: gridDelegate); + return RenderSliverGrid(childManager: element, gridDelegate: gridDelegate); } @override @@ -704,7 +704,7 @@ class SliverFillViewport extends SliverMultiBoxAdaptorWidget { @override RenderSliverFillViewport createRenderObject(BuildContext context) { final SliverMultiBoxAdaptorElement element = context; - return new RenderSliverFillViewport(childManager: element, viewportFraction: viewportFraction); + return RenderSliverFillViewport(childManager: element, viewportFraction: viewportFraction); } @override @@ -745,8 +745,8 @@ class SliverMultiBoxAdaptorElement extends RenderObjectElement implements Render // so that if we do case 2 later, we don't call the builder again. // Any time we do case 1, though, we reset the cache. - final Map _childWidgets = new HashMap(); - final SplayTreeMap _childElements = new SplayTreeMap(); + final Map _childWidgets = HashMap(); + final SplayTreeMap _childElements = SplayTreeMap(); RenderBox _currentBeforeChild; @override @@ -1001,7 +1001,7 @@ class SliverFillRemaining extends SingleChildRenderObjectWidget { }) : super(key: key, child: child); @override - RenderSliverFillRemaining createRenderObject(BuildContext context) => new RenderSliverFillRemaining(); + RenderSliverFillRemaining createRenderObject(BuildContext context) => RenderSliverFillRemaining(); } /// Mark a child as needing to stay alive even when it's in a lazy list that @@ -1048,6 +1048,6 @@ class KeepAlive extends ParentDataWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('keepAlive', keepAlive)); + properties.add(DiagnosticsProperty('keepAlive', keepAlive)); } } diff --git a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart index 009afbcf47..9719280f1d 100644 --- a/packages/flutter/lib/src/widgets/sliver_persistent_header.dart +++ b/packages/flutter/lib/src/widgets/sliver_persistent_header.dart @@ -131,18 +131,18 @@ class SliverPersistentHeader extends StatelessWidget { @override Widget build(BuildContext context) { if (floating && pinned) - return new _SliverFloatingPinnedPersistentHeader(delegate: delegate); + return _SliverFloatingPinnedPersistentHeader(delegate: delegate); if (pinned) - return new _SliverPinnedPersistentHeader(delegate: delegate); + return _SliverPinnedPersistentHeader(delegate: delegate); if (floating) - return new _SliverFloatingPersistentHeader(delegate: delegate); - return new _SliverScrollingPersistentHeader(delegate: delegate); + return _SliverFloatingPersistentHeader(delegate: delegate); + return _SliverScrollingPersistentHeader(delegate: delegate); } @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('delegate', delegate)); + properties.add(DiagnosticsProperty('delegate', delegate)); final List flags = []; if (pinned) flags.add('pinned'); @@ -150,7 +150,7 @@ class SliverPersistentHeader extends StatelessWidget { flags.add('floating'); if (flags.isEmpty) flags.add('normal'); - properties.add(new IterableProperty('mode', flags)); + properties.add(IterableProperty('mode', flags)); } } @@ -239,7 +239,7 @@ abstract class _SliverPersistentHeaderRenderObjectWidget extends RenderObjectWid final SliverPersistentHeaderDelegate delegate; @override - _SliverPersistentHeaderElement createElement() => new _SliverPersistentHeaderElement(this); + _SliverPersistentHeaderElement createElement() => _SliverPersistentHeaderElement(this); @override _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context); @@ -247,7 +247,7 @@ abstract class _SliverPersistentHeaderRenderObjectWidget extends RenderObjectWid @override void debugFillProperties(DiagnosticPropertiesBuilder description) { super.debugFillProperties(description); - description.add(new DiagnosticsProperty('delegate', delegate)); + description.add(DiagnosticsProperty('delegate', delegate)); } } @@ -284,7 +284,7 @@ class _SliverScrollingPersistentHeader extends _SliverPersistentHeaderRenderObje @override _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) { - return new _RenderSliverScrollingPersistentHeaderForWidgets(); + return _RenderSliverScrollingPersistentHeaderForWidgets(); } } @@ -302,7 +302,7 @@ class _SliverPinnedPersistentHeader extends _SliverPersistentHeaderRenderObjectW @override _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) { - return new _RenderSliverPinnedPersistentHeaderForWidgets(); + return _RenderSliverPinnedPersistentHeaderForWidgets(); } } @@ -321,7 +321,7 @@ class _SliverFloatingPersistentHeader extends _SliverPersistentHeaderRenderObjec _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) { // Not passing this snapConfiguration as a constructor parameter to avoid the // additional layers added due to https://github.com/dart-lang/sdk/issues/31543 - return new _RenderSliverFloatingPersistentHeaderForWidgets() + return _RenderSliverFloatingPersistentHeaderForWidgets() ..snapConfiguration = delegate.snapConfiguration; } @@ -346,7 +346,7 @@ class _SliverFloatingPinnedPersistentHeader extends _SliverPersistentHeaderRende _RenderSliverPersistentHeaderForWidgetsMixin createRenderObject(BuildContext context) { // Not passing this snapConfiguration as a constructor parameter to avoid the // additional layers added due to https://github.com/dart-lang/sdk/issues/31543 - return new _RenderSliverFloatingPinnedPersistentHeaderForWidgets() + return _RenderSliverFloatingPinnedPersistentHeaderForWidgets() ..snapConfiguration = delegate.snapConfiguration; } diff --git a/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart b/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart index ee679538be..2cfab2a5c7 100644 --- a/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart +++ b/packages/flutter/lib/src/widgets/sliver_prototype_extent_list.dart @@ -52,11 +52,11 @@ class SliverPrototypeExtentList extends SliverMultiBoxAdaptorWidget { @override _RenderSliverPrototypeExtentList createRenderObject(BuildContext context) { final _SliverPrototypeExtentListElement element = context; - return new _RenderSliverPrototypeExtentList(childManager: element); + return _RenderSliverPrototypeExtentList(childManager: element); } @override - _SliverPrototypeExtentListElement createElement() => new _SliverPrototypeExtentListElement(this); + _SliverPrototypeExtentListElement createElement() => _SliverPrototypeExtentListElement(this); } class _SliverPrototypeExtentListElement extends SliverMultiBoxAdaptorElement { @@ -69,7 +69,7 @@ class _SliverPrototypeExtentListElement extends SliverMultiBoxAdaptorElement { _RenderSliverPrototypeExtentList get renderObject => super.renderObject; Element _prototype; - static final Object _prototypeSlot = new Object(); + static final Object _prototypeSlot = Object(); @override void insertChildRenderObject(covariant RenderObject child, covariant dynamic slot) { diff --git a/packages/flutter/lib/src/widgets/spacer.dart b/packages/flutter/lib/src/widgets/spacer.dart index 6c64009bd0..dc7fea1149 100644 --- a/packages/flutter/lib/src/widgets/spacer.dart +++ b/packages/flutter/lib/src/widgets/spacer.dart @@ -57,7 +57,7 @@ class Spacer extends StatelessWidget { @override Widget build(BuildContext context) { - return new Expanded( + return Expanded( flex: flex, child: const SizedBox( height: 0.0, diff --git a/packages/flutter/lib/src/widgets/status_transitions.dart b/packages/flutter/lib/src/widgets/status_transitions.dart index b4ec8b9922..081bab4f2e 100644 --- a/packages/flutter/lib/src/widgets/status_transitions.dart +++ b/packages/flutter/lib/src/widgets/status_transitions.dart @@ -24,7 +24,7 @@ abstract class StatusTransitionWidget extends StatefulWidget { Widget build(BuildContext context); @override - _StatusTransitionState createState() => new _StatusTransitionState(); + _StatusTransitionState createState() => _StatusTransitionState(); } class _StatusTransitionState extends State { diff --git a/packages/flutter/lib/src/widgets/table.dart b/packages/flutter/lib/src/widgets/table.dart index bf1766c4d1..9023b5725d 100644 --- a/packages/flutter/lib/src/widgets/table.dart +++ b/packages/flutter/lib/src/widgets/table.dart @@ -53,7 +53,7 @@ class TableRow { @override String toString() { - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); result.write('TableRow('); if (key != null) result.write('$key, '); @@ -107,7 +107,7 @@ class Table extends RenderObjectWidget { assert(defaultVerticalAlignment != null), assert(() { if (children.any((TableRow row) => row.children.any((Widget cell) => cell == null))) { - throw new FlutterError( + throw FlutterError( 'One of the children of one of the rows of the table was null.\n' 'The children of a TableRow must not be null.' ); @@ -116,7 +116,7 @@ class Table extends RenderObjectWidget { }()), assert(() { if (children.any((TableRow row1) => row1.key != null && children.any((TableRow row2) => row1 != row2 && row1.key == row2.key))) { - throw new FlutterError( + throw FlutterError( 'Two or more TableRow children of this Table had the same key.\n' 'All the keyed TableRow children of a Table must have different Keys.' ); @@ -127,7 +127,7 @@ class Table extends RenderObjectWidget { if (children.isNotEmpty) { final int cellCount = children.first.children.length; if (children.any((TableRow row) => row.children.length != cellCount)) { - throw new FlutterError( + throw FlutterError( 'Table contains irregular row lengths.\n' 'Every TableRow in a Table must have the same number of children, so that every cell is filled. ' 'Otherwise, the table will contain holes.' @@ -143,7 +143,7 @@ class Table extends RenderObjectWidget { assert(() { final List flatChildren = children.expand((TableRow row) => row.children).toList(growable: false); if (debugChildrenHaveDuplicateKeys(this, flatChildren)) { - throw new FlutterError( + throw FlutterError( 'Two or more cells in this Table contain widgets with the same key.\n' 'Every widget child of every TableRow in a Table must have different keys. The cells of a Table are ' 'flattened out for processing, so separate cells cannot have duplicate keys even if they are in ' @@ -198,12 +198,12 @@ class Table extends RenderObjectWidget { final List _rowDecorations; @override - _TableElement createElement() => new _TableElement(this); + _TableElement createElement() => _TableElement(this); @override RenderTable createRenderObject(BuildContext context) { assert(debugCheckHasDirectionality(context)); - return new RenderTable( + return RenderTable( columns: children.isNotEmpty ? children[0].children.length : 0, rows: children.length, columnWidths: columnWidths, @@ -256,7 +256,7 @@ class _TableElement extends RenderObjectElement { assert(!_debugWillReattachChildren); assert(() { _debugWillReattachChildren = true; return true; }()); _children = widget.children.map((TableRow row) { - return new _TableElementRow( + return _TableElementRow( key: row.key, children: row.children.map((Widget child) { assert(child != null); @@ -294,7 +294,7 @@ class _TableElement extends RenderObjectElement { renderObject.setChild(childParentData.x, childParentData.y, null); } - final Set _forgottenChildren = new HashSet(); + final Set _forgottenChildren = HashSet(); @override void update(Table newWidget) { @@ -308,7 +308,7 @@ class _TableElement extends RenderObjectElement { } final Iterator<_TableElementRow> oldUnkeyedRows = _children.where((_TableElementRow row) => row.key == null).iterator; final List<_TableElementRow> newChildren = <_TableElementRow>[]; - final Set> taken = new Set>(); + final Set> taken = Set>(); for (TableRow row in newWidget.children) { List oldChildren; if (row.key != null && oldKeyedRows.containsKey(row.key)) { @@ -319,7 +319,7 @@ class _TableElement extends RenderObjectElement { } else { oldChildren = const []; } - newChildren.add(new _TableElementRow( + newChildren.add(_TableElementRow( key: row.key, children: updateChildren(oldChildren, row.children, forgottenChildren: _forgottenChildren) )); @@ -395,6 +395,6 @@ class TableCell extends ParentDataWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('verticalAlignment', verticalAlignment)); + properties.add(EnumProperty('verticalAlignment', verticalAlignment)); } } diff --git a/packages/flutter/lib/src/widgets/text.dart b/packages/flutter/lib/src/widgets/text.dart index 77632fb20d..cd7a84c511 100644 --- a/packages/flutter/lib/src/widgets/text.dart +++ b/packages/flutter/lib/src/widgets/text.dart @@ -76,10 +76,10 @@ class DefaultTextStyle extends InheritedWidget { @required Widget child, }) { assert(child != null); - return new Builder( + return Builder( builder: (BuildContext context) { final DefaultTextStyle parent = DefaultTextStyle.of(context); - return new DefaultTextStyle( + return DefaultTextStyle( key: key, style: parent.style.merge(style), textAlign: textAlign ?? parent.textAlign, @@ -144,10 +144,10 @@ class DefaultTextStyle extends InheritedWidget { void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); style?.debugFillProperties(properties); - properties.add(new EnumProperty('textAlign', textAlign, defaultValue: null)); - properties.add(new FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); - properties.add(new EnumProperty('overflow', overflow, defaultValue: null)); - properties.add(new IntProperty('maxLines', maxLines, defaultValue: null)); + properties.add(EnumProperty('textAlign', textAlign, defaultValue: null)); + properties.add(FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); + properties.add(EnumProperty('overflow', overflow, defaultValue: null)); + properties.add(IntProperty('maxLines', maxLines, defaultValue: null)); } } @@ -344,7 +344,7 @@ class Text extends StatelessWidget { effectiveTextStyle = defaultTextStyle.style.merge(style); if (MediaQuery.boldTextOverride(context)) effectiveTextStyle = effectiveTextStyle.merge(const TextStyle(fontWeight: FontWeight.bold)); - Widget result = new RichText( + Widget result = RichText( textAlign: textAlign ?? defaultTextStyle.textAlign ?? TextAlign.start, textDirection: textDirection, // RichText uses Directionality.of to obtain a default if this is null. locale: locale, // RichText uses Localizations.localeOf to obtain a default if this is null @@ -352,17 +352,17 @@ class Text extends StatelessWidget { overflow: overflow ?? defaultTextStyle.overflow, textScaleFactor: textScaleFactor ?? MediaQuery.textScaleFactorOf(context), maxLines: maxLines ?? defaultTextStyle.maxLines, - text: new TextSpan( + text: TextSpan( style: effectiveTextStyle, text: data, children: textSpan != null ? [textSpan] : null, ), ); if (semanticsLabel != null) { - result = new Semantics( + result = Semantics( textDirection: textDirection, label: semanticsLabel, - child: new ExcludeSemantics( + child: ExcludeSemantics( child: result, ) ); @@ -373,20 +373,20 @@ class Text extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('data', data, showName: false)); + properties.add(StringProperty('data', data, showName: false)); if (textSpan != null) { properties.add(textSpan.toDiagnosticsNode(name: 'textSpan', style: DiagnosticsTreeStyle.transition)); } style?.debugFillProperties(properties); - properties.add(new EnumProperty('textAlign', textAlign, defaultValue: null)); - properties.add(new EnumProperty('textDirection', textDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('locale', locale, defaultValue: null)); - properties.add(new FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); - properties.add(new EnumProperty('overflow', overflow, defaultValue: null)); - properties.add(new DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: null)); - properties.add(new IntProperty('maxLines', maxLines, defaultValue: null)); + properties.add(EnumProperty('textAlign', textAlign, defaultValue: null)); + properties.add(EnumProperty('textDirection', textDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('locale', locale, defaultValue: null)); + properties.add(FlagProperty('softWrap', value: softWrap, ifTrue: 'wrapping at box width', ifFalse: 'no wrapping except at line break characters', showName: true)); + properties.add(EnumProperty('overflow', overflow, defaultValue: null)); + properties.add(DoubleProperty('textScaleFactor', textScaleFactor, defaultValue: null)); + properties.add(IntProperty('maxLines', maxLines, defaultValue: null)); if (semanticsLabel != null) { - properties.add(new StringProperty('semanticsLabel', semanticsLabel)); + properties.add(StringProperty('semanticsLabel', semanticsLabel)); } } } diff --git a/packages/flutter/lib/src/widgets/text_selection.dart b/packages/flutter/lib/src/widgets/text_selection.dart index 07d0b8bf1e..91f3710ec6 100644 --- a/packages/flutter/lib/src/widgets/text_selection.dart +++ b/packages/flutter/lib/src/widgets/text_selection.dart @@ -132,13 +132,13 @@ abstract class TextSelectionControls { /// the user. void handleCut(TextSelectionDelegate delegate) { final TextEditingValue value = delegate.textEditingValue; - Clipboard.setData(new ClipboardData( + Clipboard.setData(ClipboardData( text: value.selection.textInside(value.text), )); - delegate.textEditingValue = new TextEditingValue( + delegate.textEditingValue = TextEditingValue( text: value.selection.textBefore(value.text) + value.selection.textAfter(value.text), - selection: new TextSelection.collapsed( + selection: TextSelection.collapsed( offset: value.selection.start ), ); @@ -154,12 +154,12 @@ abstract class TextSelectionControls { /// the user. void handleCopy(TextSelectionDelegate delegate) { final TextEditingValue value = delegate.textEditingValue; - Clipboard.setData(new ClipboardData( + Clipboard.setData(ClipboardData( text: value.selection.textInside(value.text), )); - delegate.textEditingValue = new TextEditingValue( + delegate.textEditingValue = TextEditingValue( text: value.text, - selection: new TextSelection.collapsed(offset: value.selection.end), + selection: TextSelection.collapsed(offset: value.selection.end), ); delegate.bringIntoView(delegate.textEditingValue.selection.extent); delegate.hideToolbar(); @@ -180,11 +180,11 @@ abstract class TextSelectionControls { final TextEditingValue value = delegate.textEditingValue; // Snapshot the input before using `await`. final ClipboardData data = await Clipboard.getData(Clipboard.kTextPlain); if (data != null) { - delegate.textEditingValue = new TextEditingValue( + delegate.textEditingValue = TextEditingValue( text: value.selection.textBefore(value.text) + data.text + value.selection.textAfter(value.text), - selection: new TextSelection.collapsed( + selection: TextSelection.collapsed( offset: value.selection.start + data.text.length ), ); @@ -201,9 +201,9 @@ abstract class TextSelectionControls { /// This is called by subclasses when their select-all affordance is activated /// by the user. void handleSelectAll(TextSelectionDelegate delegate) { - delegate.textEditingValue = new TextEditingValue( + delegate.textEditingValue = TextEditingValue( text: delegate.textEditingValue.text, - selection: new TextSelection( + selection: TextSelection( baseOffset: 0, extentOffset: delegate.textEditingValue.text.length ), @@ -233,8 +233,8 @@ class TextSelectionOverlay { _value = value { final OverlayState overlay = Overlay.of(context); assert(overlay != null); - _handleController = new AnimationController(duration: _fadeDuration, vsync: overlay); - _toolbarController = new AnimationController(duration: _fadeDuration, vsync: overlay); + _handleController = AnimationController(duration: _fadeDuration, vsync: overlay); + _toolbarController = AnimationController(duration: _fadeDuration, vsync: overlay); } /// The context in which the selection handles should appear. @@ -284,8 +284,8 @@ class TextSelectionOverlay { void showHandles() { assert(_handles == null); _handles = [ - new OverlayEntry(builder: (BuildContext context) => _buildHandle(context, _TextSelectionHandlePosition.start)), - new OverlayEntry(builder: (BuildContext context) => _buildHandle(context, _TextSelectionHandlePosition.end)), + OverlayEntry(builder: (BuildContext context) => _buildHandle(context, _TextSelectionHandlePosition.start)), + OverlayEntry(builder: (BuildContext context) => _buildHandle(context, _TextSelectionHandlePosition.end)), ]; Overlay.of(context, debugRequiredFor: debugRequiredFor).insertAll(_handles); _handleController.forward(from: 0.0); @@ -294,7 +294,7 @@ class TextSelectionOverlay { /// Shows the toolbar by inserting it into the [context]'s overlay. void showToolbar() { assert(_toolbar == null); - _toolbar = new OverlayEntry(builder: _buildToolbar); + _toolbar = OverlayEntry(builder: _buildToolbar); Overlay.of(context, debugRequiredFor: debugRequiredFor).insert(_toolbar); _toolbarController.forward(from: 0.0); } @@ -365,11 +365,11 @@ class TextSelectionOverlay { Widget _buildHandle(BuildContext context, _TextSelectionHandlePosition position) { if ((_selection.isCollapsed && position == _TextSelectionHandlePosition.end) || selectionControls == null) - return new Container(); // hide the second handle when collapsed + return Container(); // hide the second handle when collapsed - return new FadeTransition( + return FadeTransition( opacity: _handleOpacity, - child: new _TextSelectionHandleOverlay( + child: _TextSelectionHandleOverlay( onSelectionHandleChanged: (TextSelection newSelection) { _handleSelectionHandleChanged(newSelection, position); }, onSelectionHandleTapped: _handleSelectionHandleTapped, layerLink: layerLink, @@ -383,25 +383,25 @@ class TextSelectionOverlay { Widget _buildToolbar(BuildContext context) { if (selectionControls == null) - return new Container(); + return Container(); // Find the horizontal midpoint, just above the selected text. final List endpoints = renderObject.getEndpointsForSelection(_selection); - final Offset midpoint = new Offset( + final Offset midpoint = Offset( (endpoints.length == 1) ? endpoints[0].point.dx : (endpoints[0].point.dx + endpoints[1].point.dx) / 2.0, endpoints[0].point.dy - renderObject.preferredLineHeight, ); - final Rect editingRegion = new Rect.fromPoints( + final Rect editingRegion = Rect.fromPoints( renderObject.localToGlobal(Offset.zero), renderObject.localToGlobal(renderObject.size.bottomRight(Offset.zero)), ); - return new FadeTransition( + return FadeTransition( opacity: _toolbarOpacity, - child: new CompositedTransformFollower( + child: CompositedTransformFollower( link: layerLink, showWhenUnlinked: false, offset: -editingRegion.topLeft, @@ -458,14 +458,14 @@ class _TextSelectionHandleOverlay extends StatefulWidget { final TextSelectionControls selectionControls; @override - _TextSelectionHandleOverlayState createState() => new _TextSelectionHandleOverlayState(); + _TextSelectionHandleOverlayState createState() => _TextSelectionHandleOverlayState(); } class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay> { Offset _dragPosition; void _handleDragStart(DragStartDetails details) { - _dragPosition = details.globalPosition + new Offset(0.0, -widget.selectionControls.handleSize.height); + _dragPosition = details.globalPosition + Offset(0.0, -widget.selectionControls.handleSize.height); } void _handleDragUpdate(DragUpdateDetails details) { @@ -473,20 +473,20 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay final TextPosition position = widget.renderObject.getPositionForPoint(_dragPosition); if (widget.selection.isCollapsed) { - widget.onSelectionHandleChanged(new TextSelection.fromPosition(position)); + widget.onSelectionHandleChanged(TextSelection.fromPosition(position)); return; } TextSelection newSelection; switch (widget.position) { case _TextSelectionHandlePosition.start: - newSelection = new TextSelection( + newSelection = TextSelection( baseOffset: position.offset, extentOffset: widget.selection.extentOffset ); break; case _TextSelectionHandlePosition.end: - newSelection = new TextSelection( + newSelection = TextSelection( baseOffset: widget.selection.baseOffset, extentOffset: position.offset ); @@ -523,16 +523,16 @@ class _TextSelectionHandleOverlayState extends State<_TextSelectionHandleOverlay break; } - return new CompositedTransformFollower( + return CompositedTransformFollower( link: widget.layerLink, showWhenUnlinked: false, - child: new GestureDetector( + child: GestureDetector( onPanStart: _handleDragStart, onPanUpdate: _handleDragUpdate, onTap: _handleTap, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( left: point.dx, top: point.dy, child: widget.selectionControls.buildHandle( diff --git a/packages/flutter/lib/src/widgets/texture.dart b/packages/flutter/lib/src/widgets/texture.dart index 5d6807523f..eba4091dcb 100644 --- a/packages/flutter/lib/src/widgets/texture.dart +++ b/packages/flutter/lib/src/widgets/texture.dart @@ -40,7 +40,7 @@ class Texture extends LeafRenderObjectWidget { final int textureId; @override - TextureBox createRenderObject(BuildContext context) => new TextureBox(textureId: textureId); + TextureBox createRenderObject(BuildContext context) => TextureBox(textureId: textureId); @override void updateRenderObject(BuildContext context, TextureBox renderObject) { diff --git a/packages/flutter/lib/src/widgets/ticker_provider.dart b/packages/flutter/lib/src/widgets/ticker_provider.dart index e582afcea6..2f374c607a 100644 --- a/packages/flutter/lib/src/widgets/ticker_provider.dart +++ b/packages/flutter/lib/src/widgets/ticker_provider.dart @@ -59,7 +59,7 @@ class TickerMode extends InheritedWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('mode', value: enabled, ifTrue: 'enabled', ifFalse: 'disabled', showName: true)); + properties.add(FlagProperty('mode', value: enabled, ifTrue: 'enabled', ifFalse: 'disabled', showName: true)); } } @@ -86,7 +86,7 @@ abstract class SingleTickerProviderStateMixin extends assert(() { if (_ticker == null) return true; - throw new FlutterError( + throw FlutterError( '$runtimeType is a SingleTickerProviderStateMixin but multiple tickers were created.\n' 'A SingleTickerProviderStateMixin can only be used as a TickerProvider once. If a ' 'State is used for multiple AnimationController objects, or if it is passed to other ' @@ -94,7 +94,7 @@ abstract class SingleTickerProviderStateMixin extends 'mixing in a SingleTickerProviderStateMixin, use a regular TickerProviderStateMixin.' ); }()); - _ticker = new Ticker(onTick, debugLabel: 'created by $this'); + _ticker = Ticker(onTick, debugLabel: 'created by $this'); // We assume that this is called from initState, build, or some sort of // event handler, and that thus TickerMode.of(context) would return true. We // can't actually check that here because if we're in initState then we're @@ -107,7 +107,7 @@ abstract class SingleTickerProviderStateMixin extends assert(() { if (_ticker == null || !_ticker.isActive) return true; - throw new FlutterError( + throw FlutterError( '$this was disposed with an active Ticker.\n' '$runtimeType created a Ticker via its SingleTickerProviderStateMixin, but at the time ' 'dispose() was called on the mixin, that Ticker was still active. The Ticker must ' @@ -141,7 +141,7 @@ abstract class SingleTickerProviderStateMixin extends else tickerDescription = 'inactive'; } - properties.add(new DiagnosticsProperty('ticker', _ticker, description: tickerDescription, showSeparator: false, defaultValue: null)); + properties.add(DiagnosticsProperty('ticker', _ticker, description: tickerDescription, showSeparator: false, defaultValue: null)); } } @@ -165,8 +165,8 @@ abstract class TickerProviderStateMixin extends State< @override Ticker createTicker(TickerCallback onTick) { - _tickers ??= new Set<_WidgetTicker>(); - final _WidgetTicker result = new _WidgetTicker(onTick, this, debugLabel: 'created by $this'); + _tickers ??= Set<_WidgetTicker>(); + final _WidgetTicker result = _WidgetTicker(onTick, this, debugLabel: 'created by $this'); _tickers.add(result); return result; } @@ -183,7 +183,7 @@ abstract class TickerProviderStateMixin extends State< if (_tickers != null) { for (Ticker ticker in _tickers) { if (ticker.isActive) { - throw new FlutterError( + throw FlutterError( '$this was disposed with an active Ticker.\n' '$runtimeType created a Ticker via its TickerProviderStateMixin, but at the time ' 'dispose() was called on the mixin, that Ticker was still active. All Tickers must ' @@ -214,7 +214,7 @@ abstract class TickerProviderStateMixin extends State< @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>( + properties.add(DiagnosticsProperty>( 'tickers', _tickers, description: _tickers != null ? diff --git a/packages/flutter/lib/src/widgets/title.dart b/packages/flutter/lib/src/widgets/title.dart index dc0c63e918..2d1d2996ae 100644 --- a/packages/flutter/lib/src/widgets/title.dart +++ b/packages/flutter/lib/src/widgets/title.dart @@ -41,7 +41,7 @@ class Title extends StatelessWidget { @override Widget build(BuildContext context) { SystemChrome.setApplicationSwitcherDescription( - new ApplicationSwitcherDescription( + ApplicationSwitcherDescription( label: title, primaryColor: color.value, ) @@ -52,7 +52,7 @@ class Title extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new StringProperty('title', title, defaultValue: '')); - properties.add(new DiagnosticsProperty('color', color, defaultValue: null)); + properties.add(StringProperty('title', title, defaultValue: '')); + properties.add(DiagnosticsProperty('color', color, defaultValue: null)); } } diff --git a/packages/flutter/lib/src/widgets/transitions.dart b/packages/flutter/lib/src/widgets/transitions.dart index 8b0bd7e3ae..4e413821a6 100644 --- a/packages/flutter/lib/src/widgets/transitions.dart +++ b/packages/flutter/lib/src/widgets/transitions.dart @@ -55,12 +55,12 @@ abstract class AnimatedWidget extends StatefulWidget { /// Subclasses typically do not override this method. @override - _AnimatedState createState() => new _AnimatedState(); + _AnimatedState createState() => _AnimatedState(); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty('animation', listenable)); + properties.add(DiagnosticsProperty('animation', listenable)); } } @@ -170,8 +170,8 @@ class SlideTransition extends AnimatedWidget { Widget build(BuildContext context) { Offset offset = position.value; if (textDirection == TextDirection.rtl) - offset = new Offset(-offset.dx, offset.dy); - return new FractionalTranslation( + offset = Offset(-offset.dx, offset.dy); + return FractionalTranslation( translation: offset, transformHitTests: transformHitTests, child: child, @@ -226,9 +226,9 @@ class ScaleTransition extends AnimatedWidget { @override Widget build(BuildContext context) { final double scaleValue = scale.value; - final Matrix4 transform = new Matrix4.identity() + final Matrix4 transform = Matrix4.identity() ..scale(scaleValue, scaleValue, 1.0); - return new Transform( + return Transform( transform: transform, alignment: alignment, child: child, @@ -271,8 +271,8 @@ class RotationTransition extends AnimatedWidget { @override Widget build(BuildContext context) { final double turnsValue = turns.value; - final Matrix4 transform = new Matrix4.rotationZ(turnsValue * math.pi * 2.0); - return new Transform( + final Matrix4 transform = Matrix4.rotationZ(turnsValue * math.pi * 2.0); + return Transform( transform: transform, alignment: Alignment.center, child: child, @@ -360,11 +360,11 @@ class SizeTransition extends AnimatedWidget { Widget build(BuildContext context) { AlignmentDirectional alignment; if (axis == Axis.vertical) - alignment = new AlignmentDirectional(-1.0, axisAlignment); + alignment = AlignmentDirectional(-1.0, axisAlignment); else - alignment = new AlignmentDirectional(axisAlignment, -1.0); - return new ClipRect( - child: new Align( + alignment = AlignmentDirectional(axisAlignment, -1.0); + return ClipRect( + child: Align( alignment: alignment, heightFactor: axis == Axis.vertical ? math.max(sizeFactor.value, 0.0) : null, widthFactor: axis == Axis.horizontal ? math.max(sizeFactor.value, 0.0) : null, @@ -413,7 +413,7 @@ class FadeTransition extends SingleChildRenderObjectWidget { @override RenderAnimatedOpacity createRenderObject(BuildContext context) { - return new RenderAnimatedOpacity( + return RenderAnimatedOpacity( opacity: opacity, alwaysIncludeSemantics: alwaysIncludeSemantics, ); @@ -429,8 +429,8 @@ class FadeTransition extends SingleChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new DiagnosticsProperty>('opacity', opacity)); - properties.add(new FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); + properties.add(DiagnosticsProperty>('opacity', opacity)); + properties.add(FlagProperty('alwaysIncludeSemantics', value: alwaysIncludeSemantics, ifTrue: 'alwaysIncludeSemantics')); } } @@ -495,7 +495,7 @@ class PositionedTransition extends AnimatedWidget { @override Widget build(BuildContext context) { - return new Positioned.fromRelativeRect( + return Positioned.fromRelativeRect( rect: rect.value, child: child, ); @@ -553,8 +553,8 @@ class RelativePositionedTransition extends AnimatedWidget { @override Widget build(BuildContext context) { - final RelativeRect offsets = new RelativeRect.fromSize(rect.value, size); - return new Positioned( + final RelativeRect offsets = RelativeRect.fromSize(rect.value, size); + return Positioned( top: offsets.top, right: offsets.right, bottom: offsets.bottom, @@ -608,7 +608,7 @@ class DecoratedBoxTransition extends AnimatedWidget { @override Widget build(BuildContext context) { - return new DecoratedBox( + return DecoratedBox( decoration: decoration.value, position: position, child: child, @@ -663,7 +663,7 @@ class AlignTransition extends AnimatedWidget { @override Widget build(BuildContext context) { - return new Align( + return Align( alignment: alignment.value, widthFactor: widthFactor, heightFactor: heightFactor, @@ -719,7 +719,7 @@ class DefaultTextStyleTransition extends AnimatedWidget { @override Widget build(BuildContext context) { - return new DefaultTextStyle( + return DefaultTextStyle( style: style.value, textAlign: textAlign, softWrap: softWrap, diff --git a/packages/flutter/lib/src/widgets/value_listenable_builder.dart b/packages/flutter/lib/src/widgets/value_listenable_builder.dart index 4ca7c7a817..5ab391956f 100644 --- a/packages/flutter/lib/src/widgets/value_listenable_builder.dart +++ b/packages/flutter/lib/src/widgets/value_listenable_builder.dart @@ -86,7 +86,7 @@ class ValueListenableBuilder extends StatefulWidget { final Widget child; @override - State createState() => new _ValueListenableBuilderState(); + State createState() => _ValueListenableBuilderState(); } class _ValueListenableBuilderState extends State> { diff --git a/packages/flutter/lib/src/widgets/viewport.dart b/packages/flutter/lib/src/widgets/viewport.dart index 60a02d1d55..0c4b46a937 100644 --- a/packages/flutter/lib/src/widgets/viewport.dart +++ b/packages/flutter/lib/src/widgets/viewport.dart @@ -134,7 +134,7 @@ class Viewport extends MultiChildRenderObjectWidget { @override RenderViewport createRenderObject(BuildContext context) { - return new RenderViewport( + return RenderViewport( axisDirection: axisDirection, crossAxisDirection: crossAxisDirection ?? Viewport.getDefaultCrossAxisDirection(context, axisDirection), anchor: anchor, @@ -154,19 +154,19 @@ class Viewport extends MultiChildRenderObjectWidget { } @override - _ViewportElement createElement() => new _ViewportElement(this); + _ViewportElement createElement() => _ViewportElement(this); @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('axisDirection', axisDirection)); - properties.add(new EnumProperty('crossAxisDirection', crossAxisDirection, defaultValue: null)); - properties.add(new DoubleProperty('anchor', anchor)); - properties.add(new DiagnosticsProperty('offset', offset)); + properties.add(EnumProperty('axisDirection', axisDirection)); + properties.add(EnumProperty('crossAxisDirection', crossAxisDirection, defaultValue: null)); + properties.add(DoubleProperty('anchor', anchor)); + properties.add(DiagnosticsProperty('offset', offset)); if (center != null) { - properties.add(new DiagnosticsProperty('center', center)); + properties.add(DiagnosticsProperty('center', center)); } else if (children.isNotEmpty && children.first.key != null) { - properties.add(new DiagnosticsProperty('center', children.first.key, tooltip: 'implicit')); + properties.add(DiagnosticsProperty('center', children.first.key, tooltip: 'implicit')); } } } @@ -287,7 +287,7 @@ class ShrinkWrappingViewport extends MultiChildRenderObjectWidget { @override RenderShrinkWrappingViewport createRenderObject(BuildContext context) { - return new RenderShrinkWrappingViewport( + return RenderShrinkWrappingViewport( axisDirection: axisDirection, crossAxisDirection: crossAxisDirection ?? Viewport.getDefaultCrossAxisDirection(context, axisDirection), offset: offset, @@ -305,8 +305,8 @@ class ShrinkWrappingViewport extends MultiChildRenderObjectWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new EnumProperty('axisDirection', axisDirection)); - properties.add(new EnumProperty('crossAxisDirection', crossAxisDirection, defaultValue: null)); - properties.add(new DiagnosticsProperty('offset', offset)); + properties.add(EnumProperty('axisDirection', axisDirection)); + properties.add(EnumProperty('crossAxisDirection', crossAxisDirection, defaultValue: null)); + properties.add(DiagnosticsProperty('offset', offset)); } } diff --git a/packages/flutter/lib/src/widgets/visibility.dart b/packages/flutter/lib/src/widgets/visibility.dart index 34b6622bc0..00f5d19c26 100644 --- a/packages/flutter/lib/src/widgets/visibility.dart +++ b/packages/flutter/lib/src/widgets/visibility.dart @@ -203,13 +203,13 @@ class Visibility extends StatelessWidget { if (maintainSize) { Widget result = child; if (!maintainInteractivity) { - result = new IgnorePointer( + result = IgnorePointer( child: child, ignoring: !visible, ignoringSemantics: !visible && !maintainSemantics, ); } - return new Opacity( + return Opacity( opacity: visible ? 1.0 : 0.0, alwaysIncludeSemantics: maintainSemantics, child: result, @@ -221,8 +221,8 @@ class Visibility extends StatelessWidget { if (maintainState) { Widget result = child; if (!maintainAnimation) - result = new TickerMode(child: child, enabled: visible); - return new Offstage( + result = TickerMode(child: child, enabled: visible); + return Offstage( child: result, offstage: !visible, ); @@ -235,11 +235,11 @@ class Visibility extends StatelessWidget { @override void debugFillProperties(DiagnosticPropertiesBuilder properties) { super.debugFillProperties(properties); - properties.add(new FlagProperty('visible', value: visible, ifFalse: 'hidden', ifTrue: 'visible')); - properties.add(new FlagProperty('maintainState', value: maintainState, ifFalse: 'maintainState')); - properties.add(new FlagProperty('maintainAnimation', value: maintainAnimation, ifFalse: 'maintainAnimation')); - properties.add(new FlagProperty('maintainSize', value: maintainSize, ifFalse: 'maintainSize')); - properties.add(new FlagProperty('maintainSemantics', value: maintainSemantics, ifFalse: 'maintainSemantics')); - properties.add(new FlagProperty('maintainInteractivity', value: maintainInteractivity, ifFalse: 'maintainInteractivity')); + properties.add(FlagProperty('visible', value: visible, ifFalse: 'hidden', ifTrue: 'visible')); + properties.add(FlagProperty('maintainState', value: maintainState, ifFalse: 'maintainState')); + properties.add(FlagProperty('maintainAnimation', value: maintainAnimation, ifFalse: 'maintainAnimation')); + properties.add(FlagProperty('maintainSize', value: maintainSize, ifFalse: 'maintainSize')); + properties.add(FlagProperty('maintainSemantics', value: maintainSemantics, ifFalse: 'maintainSemantics')); + properties.add(FlagProperty('maintainInteractivity', value: maintainInteractivity, ifFalse: 'maintainInteractivity')); } } diff --git a/packages/flutter/lib/src/widgets/widget_inspector.dart b/packages/flutter/lib/src/widgets/widget_inspector.dart index 68e9252a4d..086a613f16 100644 --- a/packages/flutter/lib/src/widgets/widget_inspector.dart +++ b/packages/flutter/lib/src/widgets/widget_inspector.dart @@ -305,7 +305,7 @@ Rect _calculateSubtreeBoundsHelper(RenderObject object, Matrix4 transform) { /// Calculate bounds for a render object and all of its descendants. Rect _calculateSubtreeBounds(RenderObject object) { - return _calculateSubtreeBoundsHelper(object, new Matrix4.identity()); + return _calculateSubtreeBoundsHelper(object, Matrix4.identity()); } /// A layer that omits its own offset when adding children to the scene so that @@ -323,7 +323,7 @@ class _ScreenshotData { _ScreenshotData({ @required this.target, }) : assert(target != null), - containerLayer = new _ScreenshotContainerLayer(); + containerLayer = _ScreenshotContainerLayer(); /// Target to take a screenshot of. final RenderObject target; @@ -421,12 +421,12 @@ class _ScreenshotPaintingContext extends PaintingContext { void _startRecordingScreenshot() { assert(_data.includeInScreenshot); assert(!_isScreenshotRecording); - _screenshotCurrentLayer = new PictureLayer(estimatedBounds); - _screenshotRecorder = new ui.PictureRecorder(); - _screenshotCanvas = new Canvas(_screenshotRecorder); + _screenshotCurrentLayer = PictureLayer(estimatedBounds); + _screenshotRecorder = ui.PictureRecorder(); + _screenshotCanvas = Canvas(_screenshotRecorder); _data.containerLayer.append(_screenshotCurrentLayer); if (_data.includeInRegularContext) { - _multicastCanvas = new _MulticastCanvas( + _multicastCanvas = _MulticastCanvas( main: super.canvas, screenshot: _screenshotCanvas, ); @@ -460,7 +460,7 @@ class _ScreenshotPaintingContext extends PaintingContext { assert(!_isScreenshotRecording); // We must use a proxy layer here as the layer is already attached to // the regular layer tree. - _data.containerLayer.append(new _ProxyLayer(layer)); + _data.containerLayer.append(_ProxyLayer(layer)); } } else { // Only record to the screenshot. @@ -479,7 +479,7 @@ class _ScreenshotPaintingContext extends PaintingContext { // so we can optimize and use a standard PaintingContext. return super.createChildContext(childLayer, bounds); } else { - return new _ScreenshotPaintingContext( + return _ScreenshotPaintingContext( containerLayer: childLayer, estimatedBounds: bounds, screenshotData: _data, @@ -542,8 +542,8 @@ class _ScreenshotPaintingContext extends PaintingContext { repaintBoundary = repaintBoundary.parent; } assert(repaintBoundary != null); - final _ScreenshotData data = new _ScreenshotData(target: renderObject); - final _ScreenshotPaintingContext context = new _ScreenshotPaintingContext( + final _ScreenshotData data = _ScreenshotData(target: renderObject); + final _ScreenshotPaintingContext context = _ScreenshotPaintingContext( containerLayer: repaintBoundary.debugLayer, estimatedBounds: repaintBoundary.paintBounds, screenshotData: data, @@ -553,7 +553,7 @@ class _ScreenshotPaintingContext extends PaintingContext { // Painting the existing repaint boundary to the screenshot is sufficient. // We don't just take a direct screenshot of the repaint boundary as we // want to capture debugPaint information as well. - data.containerLayer.append(new _ProxyLayer(repaintBoundary.layer)); + data.containerLayer.append(_ProxyLayer(repaintBoundary.layer)); data.foundTarget = true; data.screenshotOffset = repaintBoundary.layer.offset; } else { @@ -588,7 +588,7 @@ class _ScreenshotPaintingContext extends PaintingContext { // We must build the regular scene before we can build the screenshot // scene as building the screenshot scene assumes addToScene has already // been called successfully for all layers in the regular scene. - repaintBoundary.layer.addToScene(new ui.SceneBuilder(), Offset.zero); + repaintBoundary.layer.addToScene(ui.SceneBuilder(), Offset.zero); return data.containerLayer.toImage(renderBounds, pixelRatio: pixelRatio); } @@ -639,7 +639,7 @@ List<_DiagnosticsPathNode> _followDiagnosticableChain(List chain final DiagnosticsNode child = children[j]; if (child.value == target) { foundMatch = true; - path.add(new _DiagnosticsPathNode( + path.add(_DiagnosticsPathNode( node: diagnostic, children: children, childIndex: j, @@ -650,7 +650,7 @@ List<_DiagnosticsPathNode> _followDiagnosticableChain(List chain } assert(foundMatch); } - path.add(new _DiagnosticsPathNode(node: diagnostic, children: diagnostic.getChildren())); + path.add(_DiagnosticsPathNode(node: diagnostic, children: diagnostic.getChildren())); return path; } @@ -738,16 +738,16 @@ class _WidgetInspectorService extends Object with WidgetInspectorService { class WidgetInspectorService { // This class is usable as a mixin for test purposes and as a singleton // [instance] for production purposes. - factory WidgetInspectorService._() => new _WidgetInspectorService(); + factory WidgetInspectorService._() => _WidgetInspectorService(); /// Ring of cached JSON values to prevent json from being garbage /// collected before it can be requested over the Observatory protocol. - final List _serializeRing = new List(20); + final List _serializeRing = List(20); int _serializeRingIndex = 0; /// The current [WidgetInspectorService]. static WidgetInspectorService get instance => _instance; - static WidgetInspectorService _instance = new WidgetInspectorService._(); + static WidgetInspectorService _instance = WidgetInspectorService._(); @protected static set instance(WidgetInspectorService instance) { _instance = instance; @@ -758,7 +758,7 @@ class WidgetInspectorService { /// Ground truth tracking what object(s) are currently selected used by both /// GUI tools such as the Flutter IntelliJ Plugin and the [WidgetInspector] /// displayed on the device. - final InspectorSelection selection = new InspectorSelection(); + final InspectorSelection selection = InspectorSelection(); /// Callback typically registered by the [WidgetInspector] to receive /// notifications when [selection] changes. @@ -773,7 +773,7 @@ class WidgetInspectorService { /// alive. final Map> _groups = >{}; final Map _idToReferenceData = {}; - final Map _objectToId = new Map.identity(); + final Map _objectToId = Map.identity(); int _nextId = 0; List _pubRootDirectories; @@ -916,7 +916,7 @@ class WidgetInspectorService { binding.buildOwner.reassemble(binding.renderViewElement); return binding.endOfFrame; } - return new Future.value(); + return Future.value(); } /// Called to register service extensions. @@ -939,7 +939,7 @@ class WidgetInspectorService { getter: () async => WidgetsApp.debugShowWidgetInspectorOverride, setter: (bool value) { if (WidgetsApp.debugShowWidgetInspectorOverride == value) { - return new Future.value(); + return Future.value(); } WidgetsApp.debugShowWidgetInspectorOverride = value; return forceRebuild(); @@ -1050,7 +1050,7 @@ class WidgetInspectorService { final ByteData byteData = await image.toByteData(format:ui.ImageByteFormat.png); return { - 'result': base64.encoder.convert(new Uint8List.view(byteData.buffer)), + 'result': base64.encoder.convert(Uint8List.view(byteData.buffer)), }; }, ); @@ -1098,14 +1098,14 @@ class WidgetInspectorService { if (object == null) return null; - final Set<_InspectorReferenceData> group = _groups.putIfAbsent(groupName, () => new Set<_InspectorReferenceData>.identity()); + final Set<_InspectorReferenceData> group = _groups.putIfAbsent(groupName, () => Set<_InspectorReferenceData>.identity()); String id = _objectToId[object]; _InspectorReferenceData referenceData; if (id == null) { id = 'inspector-$_nextId'; _nextId += 1; _objectToId[object] = id; - referenceData = new _InspectorReferenceData(object); + referenceData = _InspectorReferenceData(object); _idToReferenceData[id] = referenceData; group.add(referenceData); } else { @@ -1136,7 +1136,7 @@ class WidgetInspectorService { final _InspectorReferenceData data = _idToReferenceData[id]; if (data == null) { - throw new FlutterError('Id does not exist.'); + throw FlutterError('Id does not exist.'); } return data.object; } @@ -1171,9 +1171,9 @@ class WidgetInspectorService { final _InspectorReferenceData referenceData = _idToReferenceData[id]; if (referenceData == null) - throw new FlutterError('Id does not exist'); + throw FlutterError('Id does not exist'); if (_groups[groupName]?.remove(referenceData) != true) - throw new FlutterError('Id is not in group'); + throw FlutterError('Id is not in group'); _decrementReferenceCount(referenceData); } @@ -1257,11 +1257,11 @@ class WidgetInspectorService { else if (value is Element) path = _getElementParentChain(value, groupName); else - throw new FlutterError('Cannot get parent chain for node of type ${value.runtimeType}'); + throw FlutterError('Cannot get parent chain for node of type ${value.runtimeType}'); return path.map((_DiagnosticsPathNode node) => _pathNodeToJson( node, - new _SerializeConfig(groupName: groupName), + _SerializeConfig(groupName: groupName), )).toList(); } @@ -1342,7 +1342,7 @@ class WidgetInspectorService { node.getProperties().where( (DiagnosticsNode node) => !node.isFiltered(createdByLocalProject ? DiagnosticLevel.fine : DiagnosticLevel.info), ), - new _SerializeConfig(groupName: config.groupName, subtreeDepth: 1, expandPropertyValues: true), + _SerializeConfig(groupName: config.groupName, subtreeDepth: 1, expandPropertyValues: true), ); } @@ -1366,7 +1366,7 @@ class WidgetInspectorService { value.toDiagnosticsNode().getProperties().where( (DiagnosticsNode node) => !node.isFiltered(DiagnosticLevel.info), ), - new _SerializeConfig(groupName: config.groupName, + _SerializeConfig(groupName: config.groupName, subtreeDepth: 0, expandPropertyValues: false, ), @@ -1424,10 +1424,10 @@ class WidgetInspectorService { if (config.pathToInclude.first == node.value) { return _nodeToJson( node, - new _SerializeConfig.merge(config, pathToInclude: config.pathToInclude.skip(1)), + _SerializeConfig.merge(config, pathToInclude: config.pathToInclude.skip(1)), ); } else { - return _nodeToJson(node, new _SerializeConfig.merge(config)); + return _nodeToJson(node, _SerializeConfig.merge(config)); } } // The tricky special case here is that when in the detailsTree, @@ -1438,7 +1438,7 @@ class WidgetInspectorService { return _nodeToJson( node, config.summaryTree || config.subtreeDepth > 1 || _shouldShowInSummaryTree(node) ? - new _SerializeConfig.merge(config, subtreeDepth: config.subtreeDepth - 1) : config, + _SerializeConfig.merge(config, subtreeDepth: config.subtreeDepth - 1) : config, ); }).toList(); } @@ -1452,7 +1452,7 @@ class WidgetInspectorService { List _getProperties(String diagnosticsNodeId, String groupName) { final DiagnosticsNode node = toObject(diagnosticsNodeId); - return _nodesToJson(node == null ? const [] : node.getProperties(), new _SerializeConfig(groupName: groupName)); + return _nodesToJson(node == null ? const [] : node.getProperties(), _SerializeConfig(groupName: groupName)); } /// Returns a JSON representation of the children of the [DiagnosticsNode] @@ -1463,7 +1463,7 @@ class WidgetInspectorService { List _getChildren(String diagnosticsNodeId, String groupName) { final DiagnosticsNode node = toObject(diagnosticsNodeId); - final _SerializeConfig config = new _SerializeConfig(groupName: groupName); + final _SerializeConfig config = _SerializeConfig(groupName: groupName); return _nodesToJson(node == null ? const [] : _getChildrenHelper(node, config), config); } @@ -1485,7 +1485,7 @@ class WidgetInspectorService { List _getChildrenSummaryTree(String diagnosticsNodeId, String groupName) { final DiagnosticsNode node = toObject(diagnosticsNodeId); - final _SerializeConfig config = new _SerializeConfig(groupName: groupName, summaryTree: true); + final _SerializeConfig config = _SerializeConfig(groupName: groupName, summaryTree: true); return _nodesToJson(node == null ? const [] : _getChildrenHelper(node, config), config); } @@ -1502,7 +1502,7 @@ class WidgetInspectorService { List _getChildrenDetailsSubtree(String diagnosticsNodeId, String groupName) { final DiagnosticsNode node = toObject(diagnosticsNodeId); // With this value of minDepth we only expand one extra level of important nodes. - final _SerializeConfig config = new _SerializeConfig(groupName: groupName, subtreeDepth: 1, includeProperties: true); + final _SerializeConfig config = _SerializeConfig(groupName: groupName, subtreeDepth: 1, includeProperties: true); return _nodesToJson(node == null ? const [] : _getChildrenHelper(node, config), config); } @@ -1545,7 +1545,7 @@ class WidgetInspectorService { } Map _getRootWidget(String groupName) { - return _nodeToJson(WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode(), new _SerializeConfig(groupName: groupName)); + return _nodeToJson(WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode(), _SerializeConfig(groupName: groupName)); } /// Returns a JSON representation of the [DiagnosticsNode] for the root @@ -1557,7 +1557,7 @@ class WidgetInspectorService { Map _getRootWidgetSummaryTree(String groupName) { return _nodeToJson( WidgetsBinding.instance?.renderViewElement?.toDiagnosticsNode(), - new _SerializeConfig(groupName: groupName, subtreeDepth: 1000000, summaryTree: true), + _SerializeConfig(groupName: groupName, subtreeDepth: 1000000, summaryTree: true), ); } @@ -1569,7 +1569,7 @@ class WidgetInspectorService { } Map _getRootRenderObject(String groupName) { - return _nodeToJson(RendererBinding.instance?.renderView?.toDiagnosticsNode(), new _SerializeConfig(groupName: groupName)); + return _nodeToJson(RendererBinding.instance?.renderView?.toDiagnosticsNode(), _SerializeConfig(groupName: groupName)); } /// Returns a JSON representation of the subtree rooted at the @@ -1590,7 +1590,7 @@ class WidgetInspectorService { } return _nodeToJson( root, - new _SerializeConfig( + _SerializeConfig( groupName: groupName, summaryTree: false, subtreeDepth: 2, // TODO(jacobr): make subtreeDepth configurable. @@ -1613,7 +1613,7 @@ class WidgetInspectorService { Map _getSelectedRenderObject(String previousSelectionId, String groupName) { final DiagnosticsNode previousSelection = toObject(previousSelectionId); final RenderObject current = selection?.current; - return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), new _SerializeConfig(groupName: groupName)); + return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), _SerializeConfig(groupName: groupName)); } /// Returns a [DiagnosticsNode] representing the currently selected [Element]. @@ -1700,7 +1700,7 @@ class WidgetInspectorService { Map _getSelectedWidget(String previousSelectionId, String groupName) { final DiagnosticsNode previousSelection = toObject(previousSelectionId); final Element current = selection?.currentElement; - return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), new _SerializeConfig(groupName: groupName)); + return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), _SerializeConfig(groupName: groupName)); } /// Returns a [DiagnosticsNode] representing the currently selected [Element] @@ -1731,7 +1731,7 @@ class WidgetInspectorService { } current = firstLocal; } - return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), new _SerializeConfig(groupName: groupName)); + return _nodeToJson(current == previousSelection?.value ? previousSelection : current?.toDiagnosticsNode(), _SerializeConfig(groupName: groupName)); } /// Returns whether [Widget] creation locations are available. @@ -1742,7 +1742,7 @@ class WidgetInspectorService { /// [Dart Kernel Transformer](https://github.com/dart-lang/sdk/wiki/Kernel-Documentation). @protected bool isWidgetCreationTracked() { - _widgetCreationTracked ??= new _WidgetForTypeTests() is _HasCreationLocation; + _widgetCreationTracked ??= _WidgetForTypeTests() is _HasCreationLocation; return _widgetCreationTracked; } @@ -1797,7 +1797,7 @@ class WidgetInspector extends StatefulWidget { final InspectorSelectButtonBuilder selectButtonBuilder; @override - _WidgetInspectorState createState() => new _WidgetInspectorState(); + _WidgetInspectorState createState() => _WidgetInspectorState(); } class _WidgetInspectorState extends State @@ -1816,7 +1816,7 @@ class _WidgetInspectorState extends State /// highlighted but the application can be interacted with normally. bool isSelectMode = true; - final GlobalKey _ignorePointerKey = new GlobalKey(); + final GlobalKey _ignorePointerKey = GlobalKey(); /// Distance from the edge of of the bounding box for an element to consider /// as selecting the edge of the bounding box. @@ -1911,7 +1911,7 @@ class _WidgetInspectorState extends State return size == null ? double.maxFinite : size.width * size.height; } regularHits.sort((RenderObject a, RenderObject b) => _area(a).compareTo(_area(b))); - final Set hits = new LinkedHashSet(); + final Set hits = LinkedHashSet(); hits..addAll(edgeHits)..addAll(regularHits); return hits.toList(); } @@ -1980,14 +1980,14 @@ class _WidgetInspectorState extends State @override Widget build(BuildContext context) { final List children = []; - children.add(new GestureDetector( + children.add(GestureDetector( onTap: _handleTap, onPanDown: _handlePanDown, onPanEnd: _handlePanEnd, onPanUpdate: _handlePanUpdate, behavior: HitTestBehavior.opaque, excludeFromSemantics: true, - child: new IgnorePointer( + child: IgnorePointer( ignoring: isSelectMode, key: _ignorePointerKey, ignoringSemantics: false, @@ -1995,14 +1995,14 @@ class _WidgetInspectorState extends State ), )); if (!isSelectMode && widget.selectButtonBuilder != null) { - children.add(new Positioned( + children.add(Positioned( left: _kInspectButtonMargin, bottom: _kInspectButtonMargin, child: widget.selectButtonBuilder(context, _handleEnableSelect) )); } - children.add(new _InspectorOverlay(selection: selection)); - return new Stack(children: children); + children.add(_InspectorOverlay(selection: selection)); + return Stack(children: children); } } @@ -2087,7 +2087,7 @@ class _InspectorOverlay extends LeafRenderObjectWidget { @override _RenderInspectorOverlay createRenderObject(BuildContext context) { - return new _RenderInspectorOverlay(selection: selection); + return _RenderInspectorOverlay(selection: selection); } @override @@ -2123,8 +2123,8 @@ class _RenderInspectorOverlay extends RenderBox { @override void paint(PaintingContext context, Offset offset) { assert(needsCompositing); - context.addLayer(new _InspectorOverlayLayer( - overlayRect: new Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), + context.addLayer(_InspectorOverlayLayer( + overlayRect: Rect.fromLTWH(offset.dx, offset.dy, size.width, size.height), selection: selection, )); } @@ -2207,7 +2207,7 @@ class _InspectorOverlayLayer extends Layer { return true; }()); if (inDebugMode == false) { - throw new FlutterError( + throw FlutterError( 'The inspector should never be used in production mode due to the ' 'negative performance impact.' ); @@ -2241,12 +2241,12 @@ class _InspectorOverlayLayer extends Layer { for (RenderObject candidate in selection.candidates) { if (candidate == selected || !candidate.attached) continue; - candidates.add(new _TransformedRect(candidate)); + candidates.add(_TransformedRect(candidate)); } - final _InspectorOverlayRenderState state = new _InspectorOverlayRenderState( + final _InspectorOverlayRenderState state = _InspectorOverlayRenderState( overlayRect: overlayRect, - selected: new _TransformedRect(selected), + selected: _TransformedRect(selected), tooltip: selection.currentElement.toStringShort(), textDirection: TextDirection.ltr, candidates: candidates, @@ -2260,15 +2260,15 @@ class _InspectorOverlayLayer extends Layer { } ui.Picture _buildPicture(_InspectorOverlayRenderState state) { - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final Canvas canvas = new Canvas(recorder, state.overlayRect); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final Canvas canvas = Canvas(recorder, state.overlayRect); final Size size = state.overlayRect.size; - final Paint fillPaint = new Paint() + final Paint fillPaint = Paint() ..style = PaintingStyle.fill ..color = _kHighlightedRenderObjectFillColor; - final Paint borderPaint = new Paint() + final Paint borderPaint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 1.0 ..color = _kHighlightedRenderObjectBorderColor; @@ -2295,7 +2295,7 @@ class _InspectorOverlayLayer extends Layer { final Rect targetRect = MatrixUtils.transformRect( state.selected.transform, state.selected.rect); - final Offset target = new Offset(targetRect.left, targetRect.center.dy); + final Offset target = Offset(targetRect.left, targetRect.center.dy); const double offsetFromWidget = 9.0; final double verticalOffset = (targetRect.height) / 2 + offsetFromWidget; @@ -2319,10 +2319,10 @@ class _InspectorOverlayLayer extends Layer { final double maxWidth = size.width - 2 * (_kScreenEdgeMargin + _kTooltipPadding); if (_textPainter == null || _textPainter.text.text != message || _textPainterMaxWidth != maxWidth) { _textPainterMaxWidth = maxWidth; - _textPainter = new TextPainter() + _textPainter = TextPainter() ..maxLines = _kMaxTooltipLines ..ellipsis = '...' - ..text = new TextSpan(style: _messageStyle, text: message) + ..text = TextSpan(style: _messageStyle, text: message) ..textDirection = textDirection ..layout(maxWidth: maxWidth); } @@ -2336,11 +2336,11 @@ class _InspectorOverlayLayer extends Layer { preferBelow: false, ); - final Paint tooltipBackground = new Paint() + final Paint tooltipBackground = Paint() ..style = PaintingStyle.fill ..color = _kTooltipBackgroundColor; canvas.drawRect( - new Rect.fromPoints( + Rect.fromPoints( tipOffset, tipOffset.translate(tooltipSize.width, tooltipSize.height), ), @@ -2356,11 +2356,11 @@ class _InspectorOverlayLayer extends Layer { double wedgeX = math.max(tipOffset.dx, target.dx) + wedgeSize * 2; wedgeX = math.min(wedgeX, tipOffset.dx + tooltipSize.width - wedgeSize * 2); final List wedge = [ - new Offset(wedgeX - wedgeSize, wedgeY), - new Offset(wedgeX + wedgeSize, wedgeY), - new Offset(wedgeX, wedgeY + (tooltipBelow ? -wedgeSize : wedgeSize)), + Offset(wedgeX - wedgeSize, wedgeY), + Offset(wedgeX + wedgeSize, wedgeY), + Offset(wedgeX, wedgeY + (tooltipBelow ? -wedgeSize : wedgeSize)), ]; - canvas.drawPath(new Path()..addPolygon(wedge, true,), tooltipBackground); + canvas.drawPath(Path()..addPolygon(wedge, true,), tooltipBackground); _textPainter.paint(canvas, tipOffset + const Offset(_kTooltipPadding, _kTooltipPadding)); canvas.restore(); } diff --git a/packages/flutter/lib/src/widgets/will_pop_scope.dart b/packages/flutter/lib/src/widgets/will_pop_scope.dart index 30f6b1a624..b9ec6deeee 100644 --- a/packages/flutter/lib/src/widgets/will_pop_scope.dart +++ b/packages/flutter/lib/src/widgets/will_pop_scope.dart @@ -37,7 +37,7 @@ class WillPopScope extends StatefulWidget { final WillPopCallback onWillPop; @override - _WillPopScopeState createState() => new _WillPopScopeState(); + _WillPopScopeState createState() => _WillPopScopeState(); } class _WillPopScopeState extends State { diff --git a/packages/flutter/test/animation/animation_controller_test.dart b/packages/flutter/test/animation/animation_controller_test.dart index 995bfdd825..271f71613e 100644 --- a/packages/flutter/test/animation/animation_controller_test.dart +++ b/packages/flutter/test/animation/animation_controller_test.dart @@ -21,7 +21,7 @@ void main() { }); test('Can set value during status callback', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -53,7 +53,7 @@ void main() { }); test('Receives status callbacks for forward and reverse', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -114,7 +114,7 @@ void main() { }); test('Forward and reverse from values', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -140,7 +140,7 @@ void main() { }); test('Forward only from value', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -159,7 +159,7 @@ void main() { }); test('Can fling to upper and lower bounds', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -170,7 +170,7 @@ void main() { expect(controller.value, 1.0); controller.stop(); - final AnimationController largeRangeController = new AnimationController( + final AnimationController largeRangeController = AnimationController( duration: const Duration(milliseconds: 100), lowerBound: -30.0, upperBound: 45.0, @@ -189,7 +189,7 @@ void main() { }); test('lastElapsedDuration control test', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -202,7 +202,7 @@ void main() { }); test('toString control test', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -221,7 +221,7 @@ void main() { }); test('velocity test - linear', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 1000), vsync: const TestVSync(), ); @@ -264,7 +264,7 @@ void main() { }); test('Disposed AnimationController toString works', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -273,7 +273,7 @@ void main() { }); test('AnimationController error handling', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); @@ -287,7 +287,7 @@ void main() { }); test('AnimationController repeat() throws if period is not specified', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); expect(() { controller.repeat(); }, throwsFlutterError); @@ -297,7 +297,7 @@ void main() { test('Do not animate if already at target', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( value: 0.5, vsync: const TestVSync(), )..addStatusListener(statusLog.add); @@ -311,7 +311,7 @@ void main() { test('Do not animate to upperBound if already at upperBound', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( value: 1.0, upperBound: 1.0, lowerBound: 0.0, @@ -327,7 +327,7 @@ void main() { test('Do not animate to lowerBound if already at lowerBound', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( value: 0.0, upperBound: 1.0, lowerBound: 0.0, @@ -342,7 +342,7 @@ void main() { test('Do not animate if already at target mid-flight (forward)', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( value: 0.0, duration: const Duration(milliseconds: 1000), vsync: const TestVSync(), @@ -364,7 +364,7 @@ void main() { test('Do not animate if already at target mid-flight (reverse)', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( value: 1.0, duration: const Duration(milliseconds: 1000), vsync: const TestVSync(), @@ -385,7 +385,7 @@ void main() { }); test('animateTo can deal with duration == Duration.zero', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -399,7 +399,7 @@ void main() { test('resetting animation works at all phases', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), value: 0.0, lowerBound: 0.0, @@ -451,7 +451,7 @@ void main() { }); test('setting value directly sets correct status', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( value: 0.0, lowerBound: 0.0, upperBound: 1.0, @@ -480,7 +480,7 @@ void main() { test('animateTo sets correct status', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), value: 0.0, lowerBound: 0.0, @@ -526,7 +526,7 @@ void main() { test('after a reverse call animateTo sets correct status', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), value: 1.0, lowerBound: 0.0, @@ -554,7 +554,7 @@ void main() { test('after a forward call animateTo sets correct status', () { final List statusLog = []; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), value: 0.0, lowerBound: 0.0, @@ -582,16 +582,16 @@ void main() { group('AnimationBehavior', () { test('Default values for constructor', () { - final AnimationController controller = new AnimationController(vsync: const TestVSync()); + final AnimationController controller = AnimationController(vsync: const TestVSync()); expect(controller.animationBehavior, AnimationBehavior.normal); - final AnimationController repeating = new AnimationController.unbounded(vsync: const TestVSync()); + final AnimationController repeating = AnimationController.unbounded(vsync: const TestVSync()); expect(repeating.animationBehavior, AnimationBehavior.preserve); }); test('AnimationBehavior.preserve runs at normal speed when animatingTo', () async { debugSemanticsDisableAnimations = true; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), animationBehavior: AnimationBehavior.preserve, ); @@ -616,7 +616,7 @@ void main() { test('AnimationBehavior.normal runs at 20x speed when animatingTo', () async { debugSemanticsDisableAnimations = true; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), animationBehavior: AnimationBehavior.normal, ); @@ -641,10 +641,10 @@ void main() { test('AnimationBehavior.normal runs "faster" whan AnimationBehavior.preserve', () { debugSemanticsDisableAnimations = true; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); - final AnimationController fastController = new AnimationController( + final AnimationController fastController = AnimationController( vsync: const TestVSync(), ); diff --git a/packages/flutter/test/animation/animations_test.dart b/packages/flutter/test/animation/animations_test.dart index a5e7148891..8eb58143ff 100644 --- a/packages/flutter/test/animation/animations_test.dart +++ b/packages/flutter/test/animation/animations_test.dart @@ -21,21 +21,21 @@ void main() { expect(kAlwaysCompleteAnimation, hasOneLineDescription); expect(kAlwaysDismissedAnimation, hasOneLineDescription); expect(const AlwaysStoppedAnimation(0.5), hasOneLineDescription); - CurvedAnimation curvedAnimation = new CurvedAnimation( + CurvedAnimation curvedAnimation = CurvedAnimation( parent: kAlwaysDismissedAnimation, curve: Curves.ease ); expect(curvedAnimation, hasOneLineDescription); curvedAnimation.reverseCurve = Curves.elasticOut; expect(curvedAnimation, hasOneLineDescription); - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 500), vsync: const TestVSync(), ); controller ..value = 0.5 ..reverse(); - curvedAnimation = new CurvedAnimation( + curvedAnimation = CurvedAnimation( parent: controller, curve: Curves.ease, reverseCurve: Curves.elasticOut @@ -45,7 +45,7 @@ void main() { }); test('ProxyAnimation.toString control test', () { - final ProxyAnimation animation = new ProxyAnimation(); + final ProxyAnimation animation = ProxyAnimation(); expect(animation.value, 0.0); expect(animation.status, AnimationStatus.dismissed); expect(animation, hasOneLineDescription); @@ -54,12 +54,12 @@ void main() { }); test('ProxyAnimation set parent generates value changed', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); controller.value = 0.5; bool didReceiveCallback = false; - final ProxyAnimation animation = new ProxyAnimation() + final ProxyAnimation animation = ProxyAnimation() ..addListener(() { didReceiveCallback = true; }); @@ -73,7 +73,7 @@ void main() { }); test('ReverseAnimation calls listeners', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); controller.value = 0.5; @@ -81,7 +81,7 @@ void main() { void listener() { didReceiveCallback = true; } - final ReverseAnimation animation = new ReverseAnimation(controller) + final ReverseAnimation animation = ReverseAnimation(controller) ..addListener(listener); expect(didReceiveCallback, isFalse); controller.value = 0.6; @@ -95,16 +95,16 @@ void main() { }); test('TrainHoppingAnimation', () { - final AnimationController currentTrain = new AnimationController( + final AnimationController currentTrain = AnimationController( vsync: const TestVSync(), ); - final AnimationController nextTrain = new AnimationController( + final AnimationController nextTrain = AnimationController( vsync: const TestVSync(), ); currentTrain.value = 0.5; nextTrain.value = 0.75; bool didSwitchTrains = false; - final TrainHoppingAnimation animation = new TrainHoppingAnimation( + final TrainHoppingAnimation animation = TrainHoppingAnimation( currentTrain, nextTrain, onSwitchedTrain: () { didSwitchTrains = true; }); @@ -119,15 +119,15 @@ void main() { }); test('AnimationMean control test', () { - final AnimationController left = new AnimationController( + final AnimationController left = AnimationController( value: 0.5, vsync: const TestVSync(), ); - final AnimationController right = new AnimationController( + final AnimationController right = AnimationController( vsync: const TestVSync(), ); - final AnimationMean mean = new AnimationMean(left: left, right: right); + final AnimationMean mean = AnimationMean(left: left, right: right); expect(mean, hasOneLineDescription); expect(mean.value, equals(0.25)); @@ -154,15 +154,15 @@ void main() { }); test('AnimationMax control test', () { - final AnimationController first = new AnimationController( + final AnimationController first = AnimationController( value: 0.5, vsync: const TestVSync(), ); - final AnimationController second = new AnimationController( + final AnimationController second = AnimationController( vsync: const TestVSync(), ); - final AnimationMax max = new AnimationMax(first, second); + final AnimationMax max = AnimationMax(first, second); expect(max, hasOneLineDescription); expect(max.value, equals(0.5)); @@ -189,15 +189,15 @@ void main() { }); test('AnimationMin control test', () { - final AnimationController first = new AnimationController( + final AnimationController first = AnimationController( value: 0.5, vsync: const TestVSync(), ); - final AnimationController second = new AnimationController( + final AnimationController second = AnimationController( vsync: const TestVSync(), ); - final AnimationMin min = new AnimationMin(first, second); + final AnimationMin min = AnimationMin(first, second); expect(min, hasOneLineDescription); expect(min.value, equals(0.0)); @@ -224,31 +224,31 @@ void main() { }); test('CurvedAnimation with bogus curve', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); - final CurvedAnimation curved = new CurvedAnimation(parent: controller, curve: new BogusCurve()); + final CurvedAnimation curved = CurvedAnimation(parent: controller, curve: BogusCurve()); expect(() { curved.value; }, throwsFlutterError); }); test('TweenSequence', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); - final Animation animation = new TweenSequence( + final Animation animation = TweenSequence( >[ - new TweenSequenceItem( - tween: new Tween(begin: 5.0, end: 10.0), + TweenSequenceItem( + tween: Tween(begin: 5.0, end: 10.0), weight: 4.0, ), - new TweenSequenceItem( - tween: new ConstantTween(10.0), + TweenSequenceItem( + tween: ConstantTween(10.0), weight: 2.0, ), - new TweenSequenceItem( - tween: new Tween(begin: 10.0, end: 5.0), + TweenSequenceItem( + tween: Tween(begin: 10.0, end: 5.0), weight: 4.0, ), ], @@ -273,25 +273,25 @@ void main() { }); test('TweenSequence with curves', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); - final Animation animation = new TweenSequence( + final Animation animation = TweenSequence( >[ - new TweenSequenceItem( - tween: new Tween(begin: 5.0, end: 10.0) - .chain(new CurveTween(curve: const Interval(0.5, 1.0))), + TweenSequenceItem( + tween: Tween(begin: 5.0, end: 10.0) + .chain(CurveTween(curve: const Interval(0.5, 1.0))), weight: 4.0, ), - new TweenSequenceItem( - tween: new ConstantTween(10.0) - .chain(new CurveTween(curve: Curves.linear)), // linear is a no-op + TweenSequenceItem( + tween: ConstantTween(10.0) + .chain(CurveTween(curve: Curves.linear)), // linear is a no-op weight: 2.0, ), - new TweenSequenceItem( - tween: new Tween(begin: 10.0, end: 5.0) - .chain(new CurveTween(curve: const Interval(0.0, 0.5))), + TweenSequenceItem( + tween: Tween(begin: 10.0, end: 5.0) + .chain(CurveTween(curve: const Interval(0.0, 0.5))), weight: 4.0, ), ], @@ -316,14 +316,14 @@ void main() { }); test('TweenSequence, one tween', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); - final Animation animation = new TweenSequence( + final Animation animation = TweenSequence( >[ - new TweenSequenceItem( - tween: new Tween(begin: 5.0, end: 10.0), + TweenSequenceItem( + tween: Tween(begin: 5.0, end: 10.0), weight: 1.0, ), ], diff --git a/packages/flutter/test/animation/futures_test.dart b/packages/flutter/test/animation/futures_test.dart index 11715c4fcb..2e552f9b2e 100644 --- a/packages/flutter/test/animation/futures_test.dart +++ b/packages/flutter/test/animation/futures_test.dart @@ -9,15 +9,15 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('awaiting animation controllers - using direct future', (WidgetTester tester) async { - final AnimationController controller1 = new AnimationController( + final AnimationController controller1 = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); - final AnimationController controller2 = new AnimationController( + final AnimationController controller2 = AnimationController( duration: const Duration(milliseconds: 600), vsync: const TestVSync(), ); - final AnimationController controller3 = new AnimationController( + final AnimationController controller3 = AnimationController( duration: const Duration(milliseconds: 300), vsync: const TestVSync(), ); @@ -58,15 +58,15 @@ void main() { }); testWidgets('awaiting animation controllers - using orCancel', (WidgetTester tester) async { - final AnimationController controller1 = new AnimationController( + final AnimationController controller1 = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); - final AnimationController controller2 = new AnimationController( + final AnimationController controller2 = AnimationController( duration: const Duration(milliseconds: 600), vsync: const TestVSync(), ); - final AnimationController controller3 = new AnimationController( + final AnimationController controller3 = AnimationController( duration: const Duration(milliseconds: 300), vsync: const TestVSync(), ); @@ -107,7 +107,7 @@ void main() { }); testWidgets('awaiting animation controllers and failing', (WidgetTester tester) async { - final AnimationController controller1 = new AnimationController( + final AnimationController controller1 = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -135,7 +135,7 @@ void main() { }); testWidgets('creating orCancel future later', (WidgetTester tester) async { - final AnimationController controller1 = new AnimationController( + final AnimationController controller1 = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -148,7 +148,7 @@ void main() { }); testWidgets('creating orCancel future later', (WidgetTester tester) async { - final AnimationController controller1 = new AnimationController( + final AnimationController controller1 = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -165,7 +165,7 @@ void main() { }); testWidgets('TickerFuture is a Future', (WidgetTester tester) async { - final AnimationController controller1 = new AnimationController( + final AnimationController controller1 = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); diff --git a/packages/flutter/test/animation/iteration_patterns_test.dart b/packages/flutter/test/animation/iteration_patterns_test.dart index b54ce428ae..d77b217c39 100644 --- a/packages/flutter/test/animation/iteration_patterns_test.dart +++ b/packages/flutter/test/animation/iteration_patterns_test.dart @@ -13,7 +13,7 @@ void main() { }); test('AnimationController with mutating listener', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -46,7 +46,7 @@ void main() { }); test('AnimationController with mutating status listener', () { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -81,7 +81,7 @@ void main() { }); testWidgets('AnimationController with throwing listener', (WidgetTester tester) async { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); @@ -101,7 +101,7 @@ void main() { }); testWidgets('AnimationController with throwing status listener', (WidgetTester tester) async { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(milliseconds: 100), vsync: const TestVSync(), ); diff --git a/packages/flutter/test/animation/tween_test.dart b/packages/flutter/test/animation/tween_test.dart index f35bfd27c6..b8b77a5501 100644 --- a/packages/flutter/test/animation/tween_test.dart +++ b/packages/flutter/test/animation/tween_test.dart @@ -11,10 +11,10 @@ import 'package:vector_math/vector_math_64.dart'; void main() { test('Can chain tweens', () { - final Tween tween = new Tween(begin: 0.30, end: 0.50); + final Tween tween = Tween(begin: 0.30, end: 0.50); expect(tween, hasOneLineDescription); - final Animatable chain = tween.chain(new Tween(begin: 0.50, end: 1.0)); - final AnimationController controller = new AnimationController( + final Animatable chain = tween.chain(Tween(begin: 0.50, end: 1.0)); + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); expect(chain.evaluate(controller), 0.40); @@ -22,8 +22,8 @@ void main() { }); test('Can animated tweens', () { - final Tween tween = new Tween(begin: 0.30, end: 0.50); - final AnimationController controller = new AnimationController( + final Tween tween = Tween(begin: 0.30, end: 0.50); + final AnimationController controller = AnimationController( vsync: const TestVSync(), ); final Animation animation = tween.animate(controller); @@ -34,29 +34,29 @@ void main() { }); test('SizeTween', () { - final SizeTween tween = new SizeTween(begin: Size.zero, end: const Size(20.0, 30.0)); + final SizeTween tween = SizeTween(begin: Size.zero, end: const Size(20.0, 30.0)); expect(tween.lerp(0.5), equals(const Size(10.0, 15.0))); expect(tween, hasOneLineDescription); }); test('IntTween', () { - final IntTween tween = new IntTween(begin: 5, end: 9); + final IntTween tween = IntTween(begin: 5, end: 9); expect(tween.lerp(0.5), 7); expect(tween.lerp(0.7), 8); }); test('RectTween', () { - final Rect a = new Rect.fromLTWH(5.0, 3.0, 7.0, 11.0); - final Rect b = new Rect.fromLTWH(8.0, 12.0, 14.0, 18.0); - final RectTween tween = new RectTween(begin: a, end: b); + final Rect a = Rect.fromLTWH(5.0, 3.0, 7.0, 11.0); + final Rect b = Rect.fromLTWH(8.0, 12.0, 14.0, 18.0); + final RectTween tween = RectTween(begin: a, end: b); expect(tween.lerp(0.5), equals(Rect.lerp(a, b, 0.5))); expect(tween, hasOneLineDescription); }); test('Matrix4Tween', () { - final Matrix4 a = new Matrix4.identity(); + final Matrix4 a = Matrix4.identity(); final Matrix4 b = a.clone()..translate(6.0, -8.0, 0.0)..scale(0.5, 1.0, 5.0); - final Matrix4Tween tween = new Matrix4Tween(begin: a, end: b); + final Matrix4Tween tween = Matrix4Tween(begin: a, end: b); expect(tween.lerp(0.0), equals(a)); expect(tween.lerp(1.0), equals(b)); expect( @@ -64,7 +64,7 @@ void main() { equals(a.clone()..translate(3.0, -4.0, 0.0)..scale(0.75, 1.0, 3.0)) ); final Matrix4 c = a.clone()..rotateZ(1.0); - final Matrix4Tween rotationTween = new Matrix4Tween(begin: a, end: c); + final Matrix4Tween rotationTween = Matrix4Tween(begin: a, end: c); expect(rotationTween.lerp(0.0), equals(a)); expect(rotationTween.lerp(1.0), equals(c)); expect( @@ -76,7 +76,7 @@ void main() { }, skip: Platform.isWindows); // floating point math not quite deterministic on Windows? test('ConstantTween', () { - final ConstantTween tween = new ConstantTween(100.0); + final ConstantTween tween = ConstantTween(100.0); expect(tween.begin, 100.0); expect(tween.end, 100.0); expect(tween.lerp(0.0), 100.0); diff --git a/packages/flutter/test/cupertino/action_sheet_test.dart b/packages/flutter/test/cupertino/action_sheet_test.dart index 404c62dec1..9a7e63a208 100644 --- a/packages/flutter/test/cupertino/action_sheet_test.dart +++ b/packages/flutter/test/cupertino/action_sheet_test.dart @@ -53,7 +53,7 @@ void main() { testWidgets('Action sheet destructive text style', (WidgetTester tester) async { await tester.pumpWidget( boilerplate( - new CupertinoActionSheetAction( + CupertinoActionSheetAction( isDestructiveAction: true, child: const Text('Ok'), onPressed: () {}, @@ -69,7 +69,7 @@ void main() { testWidgets('Action sheet default text style', (WidgetTester tester) async { await tester.pumpWidget( boilerplate( - new CupertinoActionSheetAction( + CupertinoActionSheetAction( isDefaultAction: true, child: const Text('Ok'), onPressed: () {}, @@ -144,10 +144,10 @@ void main() { }); testWidgets('Content section but no actions', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), message: const Text('The message.'), messageScrollController: scrollController, @@ -179,16 +179,16 @@ void main() { }); testWidgets('Actions but no content section', (WidgetTester tester) async { - final ScrollController actionScrollController = new ScrollController(); + final ScrollController actionScrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), @@ -221,33 +221,33 @@ void main() { }); testWidgets('Action section is scrollable', (WidgetTester tester) async { - final ScrollController actionScrollController = new ScrollController(); + final ScrollController actionScrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new Builder(builder: (BuildContext context) { - return new MediaQuery( + Builder(builder: (BuildContext context) { + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), - child: new CupertinoActionSheet( + child: CupertinoActionSheet( title: const Text('The title'), message: const Text('The message.'), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Three'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Four'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Five'), onPressed: () {}, ), @@ -286,23 +286,23 @@ void main() { }); testWidgets('Content section is scrollable', (WidgetTester tester) async { - final ScrollController messageScrollController = new ScrollController(); + final ScrollController messageScrollController = ScrollController(); double screenHeight; await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new Builder(builder: (BuildContext context) { + Builder(builder: (BuildContext context) { screenHeight = MediaQuery.of(context).size.height; - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), - child: new CupertinoActionSheet( + child: CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), @@ -331,10 +331,10 @@ void main() { bool wasPressed = false; await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new Builder(builder: (BuildContext context) { - return new CupertinoActionSheet( + Builder(builder: (BuildContext context) { + return CupertinoActionSheet( actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () { wasPressed = true; @@ -368,15 +368,15 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new Row( + Row( children: [ - new CupertinoActionSheet( + CupertinoActionSheet( actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), @@ -397,15 +397,15 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new Column( + Column( children: [ - new CupertinoActionSheet( + CupertinoActionSheet( actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), @@ -426,16 +426,16 @@ void main() { testWidgets('1 action button with cancel button', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -453,20 +453,20 @@ void main() { testWidgets('2 action buttons with cancel button', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -484,24 +484,24 @@ void main() { testWidgets('3 action buttons with cancel button', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Three'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -519,28 +519,28 @@ void main() { testWidgets('4+ action buttons with cancel button', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Three'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Four'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -558,11 +558,11 @@ void main() { testWidgets('1 action button without cancel button', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), @@ -580,15 +580,15 @@ void main() { testWidgets('2+ action buttons without cancel button', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), - message: new Text('Very long content' * 200), + message: Text('Very long content' * 200), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), @@ -607,8 +607,8 @@ void main() { testWidgets('Action sheet with just cancel button is correct', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( - cancelButton: new CupertinoActionSheetAction( + CupertinoActionSheet( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: (){}, ), @@ -628,9 +628,9 @@ void main() { bool wasPressed = false; await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new Builder(builder: (BuildContext context) { - return new CupertinoActionSheet( - cancelButton: new CupertinoActionSheetAction( + Builder(builder: (BuildContext context) { + return CupertinoActionSheet( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () { wasPressed = true; @@ -662,20 +662,20 @@ void main() { testWidgets('Layout is correct when cancel button is present', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), message: const Text('The message'), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -697,20 +697,20 @@ void main() { testWidgets('Enter/exit animation is correct', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), message: const Text('The message'), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -774,20 +774,20 @@ void main() { testWidgets('Modal barrier is pressed during transition', (WidgetTester tester) async { await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), message: const Text('The message'), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -830,24 +830,24 @@ void main() { testWidgets('Action sheet semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( createAppWithButtonThatLaunchesActionSheet( - new CupertinoActionSheet( + CupertinoActionSheet( title: const Text('The title'), message: const Text('The message'), actions: [ - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('One'), onPressed: () {}, ), - new CupertinoActionSheetAction( + CupertinoActionSheetAction( child: const Text('Two'), onPressed: () {}, ), ], - cancelButton: new CupertinoActionSheetAction( + cancelButton: CupertinoActionSheetAction( child: const Text('Cancel'), onPressed: () {}, ), @@ -861,30 +861,30 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute, ], label: 'Alert', children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: 'The title', ), - new TestSemantics( + TestSemantics( label: 'The message', ), ], ), - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isButton, ], @@ -893,7 +893,7 @@ void main() { ], label: 'One', ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isButton, ], @@ -904,7 +904,7 @@ void main() { ), ], ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isButton, ], @@ -940,10 +940,10 @@ RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) { } Widget createAppWithButtonThatLaunchesActionSheet(Widget actionSheet) { - return new CupertinoApp( - home: new Center( - child: new Builder(builder: (BuildContext context) { - return new CupertinoButton( + return CupertinoApp( + home: Center( + child: Builder(builder: (BuildContext context) { + return CupertinoButton( onPressed: () { showCupertinoModalPopup( context: context, @@ -960,7 +960,7 @@ Widget createAppWithButtonThatLaunchesActionSheet(Widget actionSheet) { } Widget boilerplate(Widget child) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, child: child, ); diff --git a/packages/flutter/test/cupertino/activity_indicator_test.dart b/packages/flutter/test/cupertino/activity_indicator_test.dart index f07e9bfc72..b2f95d79bb 100644 --- a/packages/flutter/test/cupertino/activity_indicator_test.dart +++ b/packages/flutter/test/cupertino/activity_indicator_test.dart @@ -14,7 +14,7 @@ void main() { await tester.pumpWidget(const Center(child: CupertinoActivityIndicator(animating: false))); expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); await tester.pumpWidget(const Center(child: CupertinoActivityIndicator(animating: false))); expect(SchedulerBinding.instance.transientCallbackCount, equals(0)); diff --git a/packages/flutter/test/cupertino/app_test.dart b/packages/flutter/test/cupertino/app_test.dart index 77e9dc5b40..14c186fb55 100644 --- a/packages/flutter/test/cupertino/app_test.dart +++ b/packages/flutter/test/cupertino/app_test.dart @@ -7,18 +7,18 @@ import 'package:flutter/cupertino.dart'; void main() { testWidgets('Heroes work', (WidgetTester tester) async { - await tester.pumpWidget(new CupertinoApp( + await tester.pumpWidget(CupertinoApp( home: - new ListView( + ListView( children: [ const Hero(tag: 'a', child: Text('foo')), - new Builder(builder: (BuildContext context) { - return new CupertinoButton( + Builder(builder: (BuildContext context) { + return CupertinoButton( child: const Text('next'), onPressed: () { Navigator.push( context, - new CupertinoPageRoute( + CupertinoPageRoute( builder: (BuildContext context) { return const Hero(tag: 'a', child: Text('foo')); } diff --git a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart index 3974ffca11..0835324a1d 100644 --- a/packages/flutter/test/cupertino/bottom_tab_bar_test.dart +++ b/packages/flutter/test/cupertino/bottom_tab_bar_test.dart @@ -10,7 +10,7 @@ import '../widgets/semantics_tester.dart'; Future pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, child: widget, ), @@ -20,7 +20,7 @@ Future pumpWidgetWithBoilerplate(WidgetTester tester, Widget widget) async void main() { testWidgets('Need at least 2 tabs', (WidgetTester tester) async { try { - await pumpWidgetWithBoilerplate(tester, new CupertinoTabBar( + await pumpWidgetWithBoilerplate(tester, CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -36,9 +36,9 @@ void main() { }); testWidgets('Active and inactive colors', (WidgetTester tester) async { - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(), - child: new CupertinoTabBar( + child: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -69,7 +69,7 @@ void main() { }); testWidgets('Adjusts height to account for bottom padding', (WidgetTester tester) async { - final CupertinoTabBar tabBar = new CupertinoTabBar( + final CupertinoTabBar tabBar = CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -83,9 +83,9 @@ void main() { ); // Verify height with no bottom padding. - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(), - child: new CupertinoTabScaffold( + child: CupertinoTabScaffold( tabBar: tabBar, tabBuilder: (BuildContext context, int index) { return const Placeholder(); @@ -95,9 +95,9 @@ void main() { expect(tester.getSize(find.byType(CupertinoTabBar)).height, 50.0); // Verify height with bottom padding. - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(padding: EdgeInsets.only(bottom: 40.0)), - child: new CupertinoTabScaffold( + child: CupertinoTabScaffold( tabBar: tabBar, tabBuilder: (BuildContext context, int index) { return const Placeholder(); @@ -108,9 +108,9 @@ void main() { }); testWidgets('Opaque background does not add blur effects', (WidgetTester tester) async { - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(), - child: new CupertinoTabBar( + child: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -126,9 +126,9 @@ void main() { expect(find.byType(BackdropFilter), findsOneWidget); - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(), - child: new CupertinoTabBar( + child: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -149,9 +149,9 @@ void main() { testWidgets('Tap callback', (WidgetTester tester) async { int callbackTab; - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(), - child: new CupertinoTabBar( + child: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -172,11 +172,11 @@ void main() { }); testWidgets('tabs announce semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await pumpWidgetWithBoilerplate(tester, new MediaQuery( + await pumpWidgetWithBoilerplate(tester, MediaQuery( data: const MediaQueryData(), - child: new CupertinoTabBar( + child: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), diff --git a/packages/flutter/test/cupertino/button_test.dart b/packages/flutter/test/cupertino/button_test.dart index dc287b6aa3..8c68f9039f 100644 --- a/packages/flutter/test/cupertino/button_test.dart +++ b/packages/flutter/test/cupertino/button_test.dart @@ -92,10 +92,10 @@ void main() { testWidgets('Button takes taps', (WidgetTester tester) async { bool value = false; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoButton( + child: CupertinoButton( child: const Text('Tap me'), onPressed: () { setState(() { @@ -129,7 +129,7 @@ void main() { }); testWidgets('pressedOpacity defaults to 0.1', (WidgetTester tester) async { - await tester.pumpWidget(boilerplate(child: new CupertinoButton( + await tester.pumpWidget(boilerplate(child: CupertinoButton( child: const Text('Tap me'), onPressed: () { }, ))); @@ -149,7 +149,7 @@ void main() { testWidgets('pressedOpacity parameter', (WidgetTester tester) async { const double pressedOpacity = 0.5; - await tester.pumpWidget(boilerplate(child: new CupertinoButton( + await tester.pumpWidget(boilerplate(child: CupertinoButton( pressedOpacity: pressedOpacity, child: const Text('Tap me'), onPressed: () { }, @@ -169,11 +169,11 @@ void main() { }); testWidgets('Cupertino button is semantically a button', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( boilerplate( - child: new Center( - child: new CupertinoButton( + child: Center( + child: CupertinoButton( onPressed: () { }, child: const Text('ABC') ), @@ -182,9 +182,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( actions: SemanticsAction.tap.index, label: 'ABC', flags: SemanticsFlag.isButton.index, @@ -200,7 +200,7 @@ void main() { }); testWidgets('Can specify colors', (WidgetTester tester) async { - await tester.pumpWidget(boilerplate(child: new CupertinoButton( + await tester.pumpWidget(boilerplate(child: CupertinoButton( child: const Text('Skeuomorph me'), color: const Color(0x0000FF), disabledColor: const Color(0x00FF00), @@ -229,8 +229,8 @@ void main() { } Widget boilerplate({ Widget child }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center(child: child), + child: Center(child: child), ); } diff --git a/packages/flutter/test/cupertino/date_picker_test.dart b/packages/flutter/test/cupertino/date_picker_test.dart index fb756f9bb3..adc09e3985 100644 --- a/packages/flutter/test/cupertino/date_picker_test.dart +++ b/packages/flutter/test/cupertino/date_picker_test.dart @@ -9,7 +9,7 @@ void main() { testWidgets('onTimerDurationChanged is not null', (WidgetTester tester) async { expect( () { - new CupertinoTimerPicker(onTimerDurationChanged: null); + CupertinoTimerPicker(onTimerDurationChanged: null); }, throwsAssertionError, ); @@ -18,7 +18,7 @@ void main() { testWidgets('initialTimerDuration falls within limit', (WidgetTester tester) async { expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, initialTimerDuration: const Duration(days: 1), ); @@ -28,7 +28,7 @@ void main() { expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, initialTimerDuration: const Duration(seconds: -1), ); @@ -40,7 +40,7 @@ void main() { testWidgets('minuteInterval is positive and is a factor of 60', (WidgetTester tester) async { expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, minuteInterval: 0, ); @@ -49,7 +49,7 @@ void main() { ); expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, minuteInterval: -1, ); @@ -58,7 +58,7 @@ void main() { ); expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, minuteInterval: 7, ); @@ -70,7 +70,7 @@ void main() { testWidgets('secondInterval is positive and is a factor of 60', (WidgetTester tester) async { expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, secondInterval: 0, ); @@ -79,7 +79,7 @@ void main() { ); expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, secondInterval: -1, ); @@ -88,7 +88,7 @@ void main() { ); expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, secondInterval: 7, ); @@ -100,7 +100,7 @@ void main() { testWidgets('secondInterval is positive and is a factor of 60', (WidgetTester tester) async { expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, secondInterval: 0, ); @@ -109,7 +109,7 @@ void main() { ); expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, secondInterval: -1, ); @@ -118,7 +118,7 @@ void main() { ); expect( () { - new CupertinoTimerPicker( + CupertinoTimerPicker( onTimerDurationChanged: (_) {}, secondInterval: 7, ); @@ -129,9 +129,9 @@ void main() { testWidgets('columns are ordered correctly when text direction is ltr', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CupertinoTimerPicker( + child: CupertinoTimerPicker( onTimerDurationChanged: (_) {}, initialTimerDuration: const Duration(hours: 12, minutes: 30, seconds: 59), ), @@ -157,9 +157,9 @@ void main() { testWidgets('columns are ordered correctly when text direction is rtl', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new CupertinoTimerPicker( + child: CupertinoTimerPicker( onTimerDurationChanged: (_) {}, initialTimerDuration: const Duration(hours: 12, minutes: 30, seconds: 59), ), @@ -185,12 +185,12 @@ void main() { testWidgets('width of picker is consistent', (WidgetTester tester) async { await tester.pumpWidget( - new SizedBox( + SizedBox( height: 400.0, width: 400.0, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new CupertinoTimerPicker( + child: CupertinoTimerPicker( onTimerDurationChanged: (_) {}, initialTimerDuration: const Duration(hours: 12, minutes: 30, seconds: 59), ), @@ -203,12 +203,12 @@ void main() { tester.getCenter(find.text('sec')).dx - tester.getCenter(find.text('12')).dx; await tester.pumpWidget( - new SizedBox( + SizedBox( height: 400.0, width: 800.0, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new CupertinoTimerPicker( + child: CupertinoTimerPicker( onTimerDurationChanged: (_) {}, initialTimerDuration: const Duration(hours: 12, minutes: 30, seconds: 59), ), diff --git a/packages/flutter/test/cupertino/dialog_test.dart b/packages/flutter/test/cupertino/dialog_test.dart index b60e4ce840..65133e9d6f 100644 --- a/packages/flutter/test/cupertino/dialog_test.dart +++ b/packages/flutter/test/cupertino/dialog_test.dart @@ -19,14 +19,14 @@ void main() { await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The title'), content: const Text('The content'), actions: [ const CupertinoDialogAction( child: Text('Cancel'), ), - new CupertinoDialogAction( + CupertinoDialogAction( isDestructiveAction: true, onPressed: () { didDelete = true; @@ -65,7 +65,7 @@ void main() { }); testWidgets('Has semantic annotations', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(MaterialApp(home: const Material( child: CupertinoAlertDialog( title: Text('The Title'), @@ -80,30 +80,30 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute], label: 'Alert', children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics(label: 'The Title'), - new TestSemantics(label: 'Content'), + TestSemantics(label: 'The Title'), + TestSemantics(label: 'Content'), ], ), - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], label: 'Cancel', ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], label: 'OK', ), @@ -151,15 +151,15 @@ void main() { }); testWidgets('Message is scrollable, has correct padding with large text sizes', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( title: const Text('The Title'), - content: new Text('Very long content ' * 20), + content: Text('Very long content ' * 20), actions: const [ CupertinoDialogAction( child: Text('Cancel'), @@ -206,16 +206,16 @@ void main() { }); testWidgets('Dialog respects small constraints.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new Center( - child: new ConstrainedBox( + return Center( + child: ConstrainedBox( // Constrain the dialog to a tiny size and ensure it respects // these exact constraints. - constraints: new BoxConstraints.tight(const Size(200.0, 100.0)), - child: new CupertinoAlertDialog( + constraints: BoxConstraints.tight(const Size(200.0, 100.0)), + child: CupertinoAlertDialog( title: const Text('The Title'), content: const Text('The message'), actions: const [ @@ -249,13 +249,13 @@ void main() { }); testWidgets('Button list is scrollable, has correct position with large text sizes.', (WidgetTester tester) async { - final ScrollController actionScrollController = new ScrollController(); + final ScrollController actionScrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( title: const Text('The title'), content: const Text('The content.'), actions: const [ @@ -310,13 +310,13 @@ void main() { testWidgets('Title Section is empty, Button section is not empty.', (WidgetTester tester) async { const double textScaleFactor = 1.0; - final ScrollController actionScrollController = new ScrollController(); + final ScrollController actionScrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor), - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( actions: const [ CupertinoDialogAction( child: Text('One'), @@ -361,13 +361,13 @@ void main() { testWidgets('Button section is empty, Title section is not empty.', (WidgetTester tester) async { const double textScaleFactor = 1.0; - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: textScaleFactor), - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( title: const Text('The title'), content: const Text('The content.'), scrollController: scrollController, @@ -401,11 +401,11 @@ void main() { }); testWidgets('Actions section height for 1 button is height of button.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), content: const Text('The message'), actions: const [ @@ -430,13 +430,13 @@ void main() { }); testWidgets('Actions section height for 2 side-by-side buttons is height of tallest button.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); double dividerWidth; // Will be set when the dialog builder runs. Needs a BuildContext. await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { dividerWidth = 1.0 / MediaQuery.of(context).devicePixelRatio; - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), content: const Text('The message'), actions: const [ @@ -475,13 +475,13 @@ void main() { }); testWidgets('Actions section height for 2 stacked buttons with enough room is height of both buttons.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); double dividerThickness; // Will be set when the dialog builder runs. Needs a BuildContext. await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { dividerThickness = 1.0 / MediaQuery.of(context).devicePixelRatio; - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), content: const Text('The message'), actions: const [ @@ -517,13 +517,13 @@ void main() { }); testWidgets('Actions section height for 2 stacked buttons without enough room and regular font is 1.5 buttons tall.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), - content: new Text('The message\n' * 40), + content: Text('The message\n' * 40), actions: const [ CupertinoDialogAction( child: Text('OK'), @@ -551,15 +551,15 @@ void main() { }); testWidgets('Actions section height for 2 stacked buttons without enough room and large accessibility font is 50% of dialog height.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new MediaQuery( + return MediaQuery( data: MediaQuery.of(context).copyWith(textScaleFactor: 3.0), - child: new CupertinoAlertDialog( + child: CupertinoAlertDialog( title: const Text('The Title'), - content: new Text('The message\n' * 20), + content: Text('The message\n' * 20), actions: const [ CupertinoDialogAction( child: Text('This button is multi line'), @@ -591,13 +591,13 @@ void main() { }); testWidgets('Actions section height for 3 buttons without enough room is 1.5 buttons tall.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), - content: new Text('The message\n' * 40), + content: Text('The message\n' * 40), actions: const [ CupertinoDialogAction( child: Text('Option 1'), @@ -638,11 +638,11 @@ void main() { }); testWidgets('Actions section overscroll is painted white.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), content: const Text('The message'), actions: const [ @@ -678,20 +678,20 @@ void main() { // issue for our use-case, so we don't worry about it. expect(actionsSectionBox, paints..path( includes: [ - new Offset(Rect.largest.left, Rect.largest.top), - new Offset(Rect.largest.right, Rect.largest.bottom), + Offset(Rect.largest.left, Rect.largest.top), + Offset(Rect.largest.right, Rect.largest.bottom), ], )); }); testWidgets('Pressed button changes appearance and dividers disappear.', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); double dividerThickness; // Will be set when the dialog builder runs. Needs a BuildContext. await tester.pumpWidget( createAppWithButtonThatLaunchesDialog( dialogBuilder: (BuildContext context) { dividerThickness = 1.0 / MediaQuery.of(context).devicePixelRatio; - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The Title'), content: const Text('The message'), actions: const [ @@ -720,15 +720,15 @@ void main() { final RenderBox secondButtonBox = findActionButtonRenderBoxByTitle(tester, 'Option 2'); final RenderBox actionsSectionBox = findScrollableActionsSectionRenderBox(tester); - final Offset pressedButtonCenter = new Offset( + final Offset pressedButtonCenter = Offset( secondButtonBox.size.width / 2.0, firstButtonBox.size.height + dividerThickness + (secondButtonBox.size.height / 2.0), ); - final Offset topDividerCenter = new Offset( + final Offset topDividerCenter = Offset( secondButtonBox.size.width / 2.0, firstButtonBox.size.height + (0.5 * dividerThickness), ); - final Offset bottomDividerCenter = new Offset( + final Offset bottomDividerCenter = Offset( secondButtonBox.size.width / 2.0, firstButtonBox.size.height + dividerThickness @@ -799,23 +799,23 @@ void main() { testWidgets('ScaleTransition animation for showCupertinoDialog()', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new Center( - child: new Builder( + CupertinoApp( + home: Center( + child: Builder( builder: (BuildContext context) { - return new CupertinoButton( + return CupertinoButton( onPressed: () { showCupertinoDialog( context: context, builder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The title'), content: const Text('The content'), actions: [ const CupertinoDialogAction( child: Text('Cancel'), ), - new CupertinoDialogAction( + CupertinoDialogAction( isDestructiveAction: true, onPressed: () { Navigator.pop(context); @@ -877,23 +877,23 @@ void main() { testWidgets('FadeTransition animation for showCupertinoDialog()', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new Center( - child: new Builder( + CupertinoApp( + home: Center( + child: Builder( builder: (BuildContext context) { - return new CupertinoButton( + return CupertinoButton( onPressed: () { showCupertinoDialog( context: context, builder: (BuildContext context) { - return new CupertinoAlertDialog( + return CupertinoAlertDialog( title: const Text('The title'), content: const Text('The content'), actions: [ const CupertinoDialogAction( child: Text('Cancel'), ), - new CupertinoDialogAction( + CupertinoDialogAction( isDestructiveAction: true, onPressed: () { Navigator.pop(context); @@ -985,11 +985,11 @@ RenderBox findScrollableActionsSectionRenderBox(WidgetTester tester) { } Widget createAppWithButtonThatLaunchesDialog({WidgetBuilder dialogBuilder}) { - return new MaterialApp( - home: new Material( - child: new Center( - child: new Builder(builder: (BuildContext context) { - return new RaisedButton( + return MaterialApp( + home: Material( + child: Center( + child: Builder(builder: (BuildContext context) { + return RaisedButton( onPressed: () { showDialog( context: context, @@ -1005,7 +1005,7 @@ Widget createAppWithButtonThatLaunchesDialog({WidgetBuilder dialogBuilder}) { } Widget boilerplate(Widget child) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, child: child, ); diff --git a/packages/flutter/test/cupertino/nav_bar_test.dart b/packages/flutter/test/cupertino/nav_bar_test.dart index 366c57f06a..8ca3f6c5df 100644 --- a/packages/flutter/test/cupertino/nav_bar_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_test.dart @@ -16,7 +16,7 @@ int count = 0; void main() { testWidgets('Middle still in center with asymmetrical actions', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( leading: CupertinoButton(child: Text('Something'), onPressed: null,), middle: Text('Title'), @@ -30,14 +30,14 @@ void main() { testWidgets('Middle still in center with back button', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Title'), ), ), ); - tester.state(find.byType(Navigator)).push(new CupertinoPageRoute( + tester.state(find.byType(Navigator)).push(CupertinoPageRoute( builder: (BuildContext context) { return const CupertinoNavigationBar( middle: Text('Page 2'), @@ -54,7 +54,7 @@ void main() { testWidgets('Opaque background does not add blur effects', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Title'), backgroundColor: Color(0xFFE5E5E5), @@ -66,7 +66,7 @@ void main() { testWidgets('Non-opaque background adds blur effects', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Title'), ), @@ -76,16 +76,16 @@ void main() { }); testWidgets('Can specify custom padding', (WidgetTester tester) async { - final Key middleBox = new GlobalKey(); + final Key middleBox = GlobalKey(); await tester.pumpWidget( - new CupertinoApp( - home: new Align( + CupertinoApp( + home: Align( alignment: Alignment.topCenter, - child: new CupertinoNavigationBar( + child: CupertinoNavigationBar( leading: const CupertinoButton(child: Text('Cheetah'), onPressed: null), // Let the box take all the vertical space to test vertical padding but let // the nav bar position it horizontally. - middle: new Align( + middle: Align( key: middleBox, alignment: Alignment.center, widthFactor: 1.0, @@ -120,7 +120,7 @@ void main() { testWidgets('Padding works in RTL', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Directionality( textDirection: TextDirection.rtl, child: Align( @@ -151,7 +151,7 @@ void main() { testWidgets('Verify styles of each slot', (WidgetTester tester) async { count = 0x000000; await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( leading: _ExpectStyles(color: Color(0xFF001122), index: 0x000001), middle: _ExpectStyles(color: Color(0xFF000000), letterSpacing: -0.08, index: 0x000100), @@ -165,7 +165,7 @@ void main() { testWidgets('No slivers with no large titles', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( middle: Text('Title'), @@ -179,14 +179,14 @@ void main() { }); testWidgets('Media padding is applied to CupertinoSliverNavigationBar', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); - final Key leadingKey = new GlobalKey(); - final Key middleKey = new GlobalKey(); - final Key trailingKey = new GlobalKey(); - final Key titleKey = new GlobalKey(); + final ScrollController scrollController = ScrollController(); + final Key leadingKey = GlobalKey(); + final Key middleKey = GlobalKey(); + final Key trailingKey = GlobalKey(); + final Key titleKey = GlobalKey(); await tester.pumpWidget( - new CupertinoApp( - home: new MediaQuery( + CupertinoApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.only( top: 10.0, @@ -195,18 +195,18 @@ void main() { right: 40.0, ), ), - child: new CupertinoPageScaffold( - child: new CustomScrollView( + child: CupertinoPageScaffold( + child: CustomScrollView( controller: scrollController, slivers: [ - new CupertinoSliverNavigationBar( - leading: new Placeholder(key: leadingKey), - middle: new Placeholder(key: middleKey), - largeTitle: new Text('Large Title', key: titleKey), - trailing: new Placeholder(key: trailingKey), + CupertinoSliverNavigationBar( + leading: Placeholder(key: leadingKey), + middle: Placeholder(key: middleKey), + largeTitle: Text('Large Title', key: titleKey), + trailing: Placeholder(key: trailingKey), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 1200.0, ), ), @@ -227,18 +227,18 @@ void main() { }); testWidgets('Large title nav bar scrolls', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( controller: scrollController, slivers: [ const CupertinoSliverNavigationBar( largeTitle: Text('Title'), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 1200.0, ), ), @@ -307,18 +307,18 @@ void main() { }); testWidgets('User specified middle is always visible in sliver', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); - final Key segmentedControlsKey = new UniqueKey(); + final ScrollController scrollController = ScrollController(); + final Key segmentedControlsKey = UniqueKey(); await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( controller: scrollController, slivers: [ - new CupertinoSliverNavigationBar( - middle: new ConstrainedBox( + CupertinoSliverNavigationBar( + middle: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 200.0), - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: segmentedControlsKey, children: const { 0: Text('Option A'), @@ -330,8 +330,8 @@ void main() { ), largeTitle: const Text('Title'), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 1200.0, ), ), @@ -366,19 +366,19 @@ void main() { }); testWidgets('Small title can be overridden', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); + final ScrollController scrollController = ScrollController(); await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( controller: scrollController, slivers: [ const CupertinoSliverNavigationBar( middle: Text('Different title'), largeTitle: Text('Title'), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 1200.0, ), ), @@ -431,7 +431,7 @@ void main() { testWidgets('Auto back/close button', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Home page'), ), @@ -440,7 +440,7 @@ void main() { expect(find.byType(CupertinoButton), findsNothing); - tester.state(find.byType(Navigator)).push(new CupertinoPageRoute( + tester.state(find.byType(Navigator)).push(CupertinoPageRoute( builder: (BuildContext context) { return const CupertinoNavigationBar( middle: Text('Page 2'), @@ -452,9 +452,9 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); expect(find.byType(CupertinoButton), findsOneWidget); - expect(find.text(new String.fromCharCode(CupertinoIcons.back.codePoint)), findsOneWidget); + expect(find.text(String.fromCharCode(CupertinoIcons.back.codePoint)), findsOneWidget); - tester.state(find.byType(Navigator)).push(new CupertinoPageRoute( + tester.state(find.byType(Navigator)).push(CupertinoPageRoute( fullscreenDialog: true, builder: (BuildContext context) { return const CupertinoNavigationBar( @@ -476,7 +476,7 @@ void main() { expect(find.text('Page 2'), findsOneWidget); - await tester.tap(find.text(new String.fromCharCode(CupertinoIcons.back.codePoint))); + await tester.tap(find.text(String.fromCharCode(CupertinoIcons.back.codePoint))); await tester.pump(); await tester.pump(const Duration(milliseconds: 500)); @@ -486,13 +486,13 @@ void main() { testWidgets('Long back label turns into "back"', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( builder: (BuildContext context) { return const CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( @@ -510,7 +510,7 @@ void main() { expect(find.widgetWithText(CupertinoButton, '012345678901'), findsOneWidget); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( builder: (BuildContext context) { return const CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( @@ -529,7 +529,7 @@ void main() { testWidgets('Border should be displayed by default', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Title'), ), @@ -551,7 +551,7 @@ void main() { testWidgets('Overrides border color', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Title'), border: Border( @@ -580,7 +580,7 @@ void main() { testWidgets('Border should not be displayed when null', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoNavigationBar( middle: Text('Title'), border: null, @@ -602,9 +602,9 @@ void main() { 'Border is displayed by default in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( slivers: const [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), @@ -632,9 +632,9 @@ void main() { 'Border is not displayed when null in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( slivers: const [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), @@ -657,11 +657,11 @@ void main() { }); testWidgets('CupertinoSliverNavigationBar has semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + await tester.pumpWidget(CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( slivers: const [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), @@ -682,14 +682,14 @@ void main() { }); testWidgets('CupertinoNavigationBar has semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new CupertinoApp( - home: new CupertinoPageScaffold( + await tester.pumpWidget(CupertinoApp( + home: CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( middle: Text('Fixed Title'), ), - child: new Container(), + child: Container(), ), )); @@ -706,9 +706,9 @@ void main() { 'Border can be overridden in sliver nav bar', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: CupertinoPageScaffold( + child: CustomScrollView( slivers: const [ CupertinoSliverNavigationBar( largeTitle: Text('Large Title'), @@ -746,7 +746,7 @@ void main() { 'Standard title golden', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const RepaintBoundary( child: CupertinoPageScaffold( navigationBar: CupertinoNavigationBar( @@ -772,16 +772,16 @@ void main() { 'Large title golden', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new RepaintBoundary( - child: new CupertinoPageScaffold( - child: new CustomScrollView( + CupertinoApp( + home: RepaintBoundary( + child: CupertinoPageScaffold( + child: CustomScrollView( slivers: [ const CupertinoSliverNavigationBar( largeTitle: Text('Bling bling'), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 1200.0, ), ), @@ -805,10 +805,10 @@ void main() { testWidgets('NavBar draws a light system bar for a dark background', (WidgetTester tester) async { await tester.pumpWidget( - new WidgetsApp( + WidgetsApp( color: const Color(0xFFFFFFFF), onGenerateRoute: (RouteSettings settings) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { return const CupertinoNavigationBar( @@ -825,10 +825,10 @@ void main() { testWidgets('NavBar draws a dark system bar for a light background', (WidgetTester tester) async { await tester.pumpWidget( - new WidgetsApp( + WidgetsApp( color: const Color(0xFFFFFFFF), onGenerateRoute: (RouteSettings settings) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { return const CupertinoNavigationBar( @@ -858,6 +858,6 @@ class _ExpectStyles extends StatelessWidget { expect(style.fontSize, 17.0); expect(style.letterSpacing, letterSpacing ?? -0.24); count += index; - return new Container(); + return Container(); } } diff --git a/packages/flutter/test/cupertino/nav_bar_transition_test.dart b/packages/flutter/test/cupertino/nav_bar_transition_test.dart index dd936093af..d7715a4e56 100644 --- a/packages/flutter/test/cupertino/nav_bar_transition_test.dart +++ b/packages/flutter/test/cupertino/nav_bar_transition_test.dart @@ -14,14 +14,14 @@ Future startTransitionBetween( String toTitle, }) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester .state(find.byType(Navigator)) - .push(new CupertinoPageRoute( + .push(CupertinoPageRoute( title: fromTitle, builder: (BuildContext context) => scaffoldForNavBar(from), )); @@ -31,7 +31,7 @@ Future startTransitionBetween( tester .state(find.byType(Navigator)) - .push(new CupertinoPageRoute( + .push(CupertinoPageRoute( title: toTitle, builder: (BuildContext context) => scaffoldForNavBar(to), )); @@ -41,13 +41,13 @@ Future startTransitionBetween( CupertinoPageScaffold scaffoldForNavBar(Widget navBar) { if (navBar is CupertinoNavigationBar || navBar == null) { - return new CupertinoPageScaffold( + return CupertinoPageScaffold( navigationBar: navBar ?? const CupertinoNavigationBar(), child: const Placeholder(), ); } else if (navBar is CupertinoSliverNavigationBar) { - return new CupertinoPageScaffold( - child: new CustomScrollView( + return CupertinoPageScaffold( + child: CustomScrollView( slivers: [ navBar, // Add filler so it's scrollable. @@ -195,14 +195,14 @@ void main() { testWidgets('Fullscreen dialogs do not create heroes', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester .state(find.byType(Navigator)) - .push(new CupertinoPageRoute( + .push(CupertinoPageRoute( title: 'Page 1', builder: (BuildContext context) => scaffoldForNavBar(null), )); @@ -212,7 +212,7 @@ void main() { tester .state(find.byType(Navigator)) - .push(new CupertinoPageRoute( + .push(CupertinoPageRoute( title: 'Page 2', fullscreenDialog: true, builder: (BuildContext context) => scaffoldForNavBar(null), @@ -395,14 +395,14 @@ void main() { testWidgets('First appearance of back chevron fades in from the right', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: scaffoldForNavBar(null), ), ); tester .state(find.byType(Navigator)) - .push(new CupertinoPageRoute( + .push(CupertinoPageRoute( title: 'Page 1', builder: (BuildContext context) => scaffoldForNavBar(null), )); @@ -411,7 +411,7 @@ void main() { await tester.pump(const Duration(milliseconds: 50)); final Finder backChevron = flying(tester, - find.text(new String.fromCharCode(CupertinoIcons.back.codePoint))); + find.text(String.fromCharCode(CupertinoIcons.back.codePoint))); expect( backChevron, @@ -437,7 +437,7 @@ void main() { await tester.pump(const Duration(milliseconds: 50)); final Finder backChevrons = flying(tester, - find.text(new String.fromCharCode(CupertinoIcons.back.codePoint))); + find.text(String.fromCharCode(CupertinoIcons.back.codePoint))); expect( backChevrons, @@ -556,7 +556,7 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); tester .state(find.byType(Navigator)) - .push(new CupertinoPageRoute( + .push(CupertinoPageRoute( title: 'Page 3', builder: (BuildContext context) => scaffoldForNavBar(null), )); @@ -769,14 +769,14 @@ void main() { int topBuildTimes = 0; await startTransitionBetween( tester, - from: new CupertinoNavigationBar( - middle: new Builder(builder: (BuildContext context) { + from: CupertinoNavigationBar( + middle: Builder(builder: (BuildContext context) { bottomBuildTimes++; return const Text('Page 1'); }), ), - to: new CupertinoSliverNavigationBar( - largeTitle: new Builder(builder: (BuildContext context) { + to: CupertinoSliverNavigationBar( + largeTitle: Builder(builder: (BuildContext context) { topBuildTimes++; return const Text('Page 2'); }), diff --git a/packages/flutter/test/cupertino/page_test.dart b/packages/flutter/test/cupertino/page_test.dart index 73a1f0cf8b..5bf44ffc69 100644 --- a/packages/flutter/test/cupertino/page_test.dart +++ b/packages/flutter/test/cupertino/page_test.dart @@ -8,13 +8,13 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('test iOS page transition (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( onGenerateRoute: (RouteSettings settings) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { final String pageNumber = settings.name == '/' ? '1' : '2'; - return new Center(child: new Text('Page $pageNumber')); + return Center(child: Text('Page $pageNumber')); } ); }, @@ -75,16 +75,16 @@ void main() { testWidgets('test iOS page transition (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( localizationsDelegates: const >[ RtlOverrideWidgetsDelegate(), ], onGenerateRoute: (RouteSettings settings) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { final String pageNumber = settings.name == '/' ? '1' : '2'; - return new Center(child: new Text('Page $pageNumber')); + return Center(child: Text('Page $pageNumber')); } ); }, @@ -146,14 +146,14 @@ void main() { testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Center(child: Text('Page 1')), ), ); final Offset widget1InitialTopLeft = tester.getTopLeft(find.text('Page 1')); - tester.state(find.byType(Navigator)).push(new CupertinoPageRoute( + tester.state(find.byType(Navigator)).push(CupertinoPageRoute( builder: (BuildContext context) { return const Center(child: Text('Page 2')); }, @@ -206,13 +206,13 @@ void main() { testWidgets('test only edge swipes work (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( onGenerateRoute: (RouteSettings settings) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { final String pageNumber = settings.name == '/' ? '1' : '2'; - return new Center(child: new Text('Page $pageNumber')); + return Center(child: Text('Page $pageNumber')); } ); }, @@ -267,16 +267,16 @@ void main() { testWidgets('test only edge swipes work (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( localizationsDelegates: const >[ RtlOverrideWidgetsDelegate(), ], onGenerateRoute: (RouteSettings settings) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { final String pageNumber = settings.name == '/' ? '1' : '2'; - return new Center(child: new Text('Page $pageNumber')); + return Center(child: Text('Page $pageNumber')); } ); }, diff --git a/packages/flutter/test/cupertino/picker_test.dart b/packages/flutter/test/cupertino/picker_test.dart index cfdf00a7e5..ae52191e2d 100644 --- a/packages/flutter/test/cupertino/picker_test.dart +++ b/packages/flutter/test/cupertino/picker_test.dart @@ -10,25 +10,25 @@ void main() { group('layout', () { testWidgets('selected item is in the middle', (WidgetTester tester) async { final FixedExtentScrollController controller = - new FixedExtentScrollController(initialItem: 1); + FixedExtentScrollController(initialItem: 1); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Align( + child: Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( height: 300.0, width: 300.0, - child: new CupertinoPicker( + child: CupertinoPicker( scrollController: controller, itemExtent: 50.0, onSelectedItemChanged: (_) {}, - children: new List.generate(3, (int index) { - return new Container( + children: List.generate(3, (int index) { + return Container( height: 50.0, width: 300.0, - child: new Text(index.toString()), + child: Text(index.toString()), ); }), ), @@ -69,17 +69,17 @@ void main() { }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CupertinoPicker( + child: CupertinoPicker( itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, - children: new List.generate(100, (int index) { - return new Center( - child: new Container( + children: List.generate(100, (int index) { + return Center( + child: Container( width: 400.0, height: 100.0, - child: new Text(index.toString()), + child: Text(index.toString()), ), ); }), @@ -124,17 +124,17 @@ void main() { }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CupertinoPicker( + child: CupertinoPicker( itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, - children: new List.generate(100, (int index) { - return new Center( - child: new Container( + children: List.generate(100, (int index) { + return Center( + child: Container( width: 400.0, height: 100.0, - child: new Text(index.toString()), + child: Text(index.toString()), ), ); }), @@ -153,22 +153,22 @@ void main() { testWidgets('a drag in between items settles back', (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final FixedExtentScrollController controller = - new FixedExtentScrollController(initialItem: 10); + FixedExtentScrollController(initialItem: 10); final List selectedItems = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CupertinoPicker( + child: CupertinoPicker( scrollController: controller, itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, - children: new List.generate(100, (int index) { - return new Center( - child: new Container( + children: List.generate(100, (int index) { + return Center( + child: Container( width: 400.0, height: 100.0, - child: new Text(index.toString()), + child: Text(index.toString()), ), ); }), @@ -210,22 +210,22 @@ void main() { testWidgets('a big fling that overscrolls springs back', (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; final FixedExtentScrollController controller = - new FixedExtentScrollController(initialItem: 10); + FixedExtentScrollController(initialItem: 10); final List selectedItems = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CupertinoPicker( + child: CupertinoPicker( scrollController: controller, itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, - children: new List.generate(100, (int index) { - return new Center( - child: new Container( + children: List.generate(100, (int index) { + return Center( + child: Container( width: 400.0, height: 100.0, - child: new Text(index.toString()), + child: Text(index.toString()), ), ); }), diff --git a/packages/flutter/test/cupertino/refresh_test.dart b/packages/flutter/test/cupertino/refresh_test.dart index 78fe80e50f..1a032182e0 100644 --- a/packages/flutter/test/cupertino/refresh_test.dart +++ b/packages/flutter/test/cupertino/refresh_test.dart @@ -31,9 +31,9 @@ void main() { final Function onRefresh = () => mockHelper.refreshTask(); setUp(() { - mockHelper = new MockHelper(); - refreshCompleter = new Completer.sync(); - refreshIndicator = new Container(); + mockHelper = MockHelper(); + refreshCompleter = Completer.sync(); + refreshIndicator = Container(); when(mockHelper.builder( any, any, any, any, any)) @@ -43,19 +43,19 @@ void main() { final double refreshTriggerPullDistance = i.positionalArguments[3]; final double refreshIndicatorExtent = i.positionalArguments[4]; if (refreshState == RefreshIndicatorMode.inactive) { - throw new TestFailure( + throw TestFailure( 'RefreshControlIndicatorBuilder should never be called with the ' "inactive state because there's nothing to build in that case" ); } if (pulledExtent < 0.0) { - throw new TestFailure('The pulledExtent should never be less than 0.0'); + throw TestFailure('The pulledExtent should never be less than 0.0'); } if (refreshTriggerPullDistance < 0.0) { - throw new TestFailure('The refreshTriggerPullDistance should never be less than 0.0'); + throw TestFailure('The refreshTriggerPullDistance should never be less than 0.0'); } if (refreshIndicatorExtent < 0.0) { - throw new TestFailure('The refreshIndicatorExtent should never be less than 0.0'); + throw TestFailure('The refreshIndicatorExtent should never be less than 0.0'); } return refreshIndicator; }); @@ -64,12 +64,12 @@ void main() { int testListLength = 10; SliverList buildAListOfStuff() { - return new SliverList( - delegate: new SliverChildBuilderDelegate( + return SliverList( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - return new Container( + return Container( height: 200.0, - child: new Center(child: new Text(index.toString())), + child: Center(child: Text(index.toString())), ); }, childCount: testListLength, @@ -82,11 +82,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -109,11 +109,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -151,11 +151,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.android; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -183,11 +183,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -247,11 +247,11 @@ void main() { }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -309,11 +309,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -386,11 +386,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -414,7 +414,7 @@ void main() { // Given a box constraint of 150, the Center will occupy all that height. expect( tester.getRect(find.widgetWithText(Center, '-1')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 150.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 150.0), ); await tester.drag(find.text('0'), const Offset(0.0, -300.0)); @@ -450,11 +450,11 @@ void main() { await tester.pump(const Duration(seconds: 2)); expect( tester.getRect(find.widgetWithText(Center, '-1')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 60.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 60.0), ); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), + Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), ); debugDefaultTargetPlatformOverride = null; @@ -466,11 +466,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -491,7 +491,7 @@ void main() { )); expect( tester.getRect(find.widgetWithText(Center, '-1')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 150.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 150.0), ); verify(mockHelper.refreshTask()); @@ -508,11 +508,11 @@ void main() { )); expect( tester.getRect(find.widgetWithText(Center, '-1')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 60.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 60.0), ); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), + Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), ); refreshCompleter.complete(null); @@ -529,7 +529,7 @@ void main() { expect(find.text('-1'), findsNothing); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); debugDefaultTargetPlatformOverride = null; @@ -543,11 +543,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -606,7 +606,7 @@ void main() { expect(find.text('-1'), findsNothing); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); // Start another drag. It's now in drag mode. @@ -632,11 +632,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -664,7 +664,7 @@ void main() { )); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 150.0, 800.0, 350.0), + Rect.fromLTRB(0.0, 150.0, 800.0, 350.0), ); await gesture.up(); @@ -673,7 +673,7 @@ void main() { expect(find.text('-1'), findsNothing); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); debugDefaultTargetPlatformOverride = null; @@ -693,11 +693,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -765,7 +765,7 @@ void main() { expect(find.text('-1'), findsNothing); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); debugDefaultTargetPlatformOverride = null; @@ -780,12 +780,12 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ buildAListOfStuff(), - new CupertinoSliverRefreshControl( // it's in the middle now. + CupertinoSliverRefreshControl( // it's in the middle now. builder: builder, onRefresh: onRefresh, ), @@ -813,11 +813,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -849,7 +849,7 @@ void main() { expect(find.text('-1'), findsNothing); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); debugDefaultTargetPlatformOverride = null; @@ -862,11 +862,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -887,11 +887,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, ), buildAListOfStuff(), @@ -922,11 +922,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, refreshTriggerPullDistance: 80.0, ), @@ -960,11 +960,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, refreshTriggerPullDistance: 90.0, @@ -1005,11 +1005,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -1035,7 +1035,7 @@ void main() { ); expect( tester.getRect(find.widgetWithText(Container, '0')), - new Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), + Rect.fromLTRB(0.0, 60.0, 800.0, 260.0), ); refreshCompleter.complete(null); @@ -1057,11 +1057,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -1120,11 +1120,11 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: builder, onRefresh: onRefresh, ), @@ -1186,11 +1186,11 @@ void main() { refreshIndicator = const Center(child: Text('-1')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new CupertinoSliverRefreshControl( + CupertinoSliverRefreshControl( builder: null, onRefresh: onRefresh, refreshIndicatorExtent: 0.0, @@ -1217,7 +1217,7 @@ void main() { ); expect( tester.getRect(find.widgetWithText(Center, '0')), - new Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), + Rect.fromLTRB(0.0, 0.0, 800.0, 200.0), ); verify(mockHelper.refreshTask()); // The refresh function still called. diff --git a/packages/flutter/test/cupertino/route_test.dart b/packages/flutter/test/cupertino/route_test.dart index 982c2c5b6e..3f74462db4 100644 --- a/packages/flutter/test/cupertino/route_test.dart +++ b/packages/flutter/test/cupertino/route_test.dart @@ -9,13 +9,13 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Middle auto-populates with title', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( title: 'An iPod', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -39,17 +39,17 @@ void main() { testWidgets('Large title auto-populates with title', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( title: 'An iPod', builder: (BuildContext context) { - return new CupertinoPageScaffold( - child: new CustomScrollView( + return CupertinoPageScaffold( + child: CustomScrollView( slivers: const [ CupertinoSliverNavigationBar(), ], @@ -104,13 +104,13 @@ void main() { testWidgets('Leading auto-populates with back button with previous title', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( title: 'An iPod', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -125,7 +125,7 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( title: 'A Phone', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -150,13 +150,13 @@ void main() { testWidgets('Previous title is correct on first transition frame', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( title: 'An iPod', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -171,7 +171,7 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); tester.state(find.byType(Navigator)).push( - new CupertinoPageRoute( + CupertinoPageRoute( title: 'A Phone', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -193,12 +193,12 @@ void main() { testWidgets('Previous title stays up to date with changing routes', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const Placeholder(), ), ); - final CupertinoPageRoute route2 = new CupertinoPageRoute( + final CupertinoPageRoute route2 = CupertinoPageRoute( title: 'An iPod', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -208,7 +208,7 @@ void main() { } ); - final CupertinoPageRoute route3 = new CupertinoPageRoute( + final CupertinoPageRoute route3 = CupertinoPageRoute( title: 'A Phone', builder: (BuildContext context) { return const CupertinoPageScaffold( @@ -230,7 +230,7 @@ void main() { tester.state(find.byType(Navigator)).replace( oldRoute: route2, - newRoute: new CupertinoPageRoute( + newRoute: CupertinoPageRoute( title: 'An Internet communicator', builder: (BuildContext context) { return const CupertinoPageScaffold( diff --git a/packages/flutter/test/cupertino/scaffold_test.dart b/packages/flutter/test/cupertino/scaffold_test.dart index c2b6bcaf0f..dbeca86934 100644 --- a/packages/flutter/test/cupertino/scaffold_test.dart +++ b/packages/flutter/test/cupertino/scaffold_test.dart @@ -11,7 +11,7 @@ import '../painting/mocks_for_image_cache.dart'; void main() { testWidgets('Contents are behind translucent bar', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoPageScaffold( // Default nav bar is translucent. navigationBar: CupertinoNavigationBar( @@ -78,9 +78,9 @@ void main() { const Center page1Center = Center(); await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabScaffold( - tabBar: new CupertinoTabBar( + CupertinoApp( + home: CupertinoTabScaffold( + tabBar: CupertinoTabBar( backgroundColor: CupertinoColors.white, items: const [ BottomNavigationBarItem( @@ -102,7 +102,7 @@ void main() { ), child: page1Center, ) - : new Stack(); + : Stack(); }, ), ), @@ -112,16 +112,16 @@ void main() { }); testWidgets('Contents have automatic sliver padding between translucent bars', (WidgetTester tester) async { - final Container content = new Container(height: 600.0, width: 600.0); + final Container content = Container(height: 600.0, width: 600.0); await tester.pumpWidget( - new CupertinoApp( - home: new MediaQuery( + CupertinoApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.symmetric(vertical: 20.0), ), - child: new CupertinoTabScaffold( - tabBar: new CupertinoTabBar( + child: CupertinoTabScaffold( + tabBar: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -135,17 +135,17 @@ void main() { ), tabBuilder: (BuildContext context, int index) { return index == 0 - ? new CupertinoPageScaffold( + ? CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( middle: Text('Title'), ), - child: new ListView( + child: ListView( children: [ content, ], ), ) - : new Stack(); + : Stack(); } ), ), @@ -169,9 +169,9 @@ void main() { // A full on iOS information architecture app with 2 tabs, and 2 pages // in each with independent navigation states. await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabScaffold( - tabBar: new CupertinoTabBar( + CupertinoApp( + home: CupertinoTabScaffold( + tabBar: CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), @@ -186,25 +186,25 @@ void main() { tabBuilder: (BuildContext context, int index) { // For 1-indexed readability. ++index; - return new CupertinoTabView( + return CupertinoTabView( builder: (BuildContext context) { - return new CupertinoPageScaffold( - navigationBar: new CupertinoNavigationBar( - middle: new Text('Page 1 of tab $index'), + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 1 of tab $index'), ), - child: new Center( - child: new CupertinoButton( + child: Center( + child: CupertinoButton( child: const Text('Next'), onPressed: () { Navigator.of(context).push( - new CupertinoPageRoute( + CupertinoPageRoute( builder: (BuildContext context) { - return new CupertinoPageScaffold( - navigationBar: new CupertinoNavigationBar( - middle: new Text('Page 2 of tab $index'), + return CupertinoPageScaffold( + navigationBar: CupertinoNavigationBar( + middle: Text('Page 2 of tab $index'), ), - child: new Center( - child: new CupertinoButton( + child: Center( + child: CupertinoButton( child: const Text('Back'), onPressed: () { Navigator.of(context).pop(); @@ -276,7 +276,7 @@ void main() { testWidgets('Decorated with white background by default', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoPageScaffold( child: Center(), ), @@ -292,7 +292,7 @@ void main() { testWidgets('Overrides background color', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( + CupertinoApp( home: const CupertinoPageScaffold( child: Center(), backgroundColor: Color(0xFF010203), diff --git a/packages/flutter/test/cupertino/scrollbar_paint_test.dart b/packages/flutter/test/cupertino/scrollbar_paint_test.dart index f4d3771921..6b31a341c8 100644 --- a/packages/flutter/test/cupertino/scrollbar_paint_test.dart +++ b/packages/flutter/test/cupertino/scrollbar_paint_test.dart @@ -9,10 +9,10 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Paints iOS spec', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new CupertinoScrollbar( - child: new SingleChildScrollView( + child: CupertinoScrollbar( + child: SingleChildScrollView( child: const SizedBox(width: 4000.0, height: 4000.0), ), ), @@ -26,8 +26,8 @@ void main() { await tester.pump(const Duration(milliseconds: 500)); expect(find.byType(CupertinoScrollbar), paints..rrect( color: const Color(0x99777777), - rrect: new RRect.fromRectAndRadius( - new Rect.fromLTWH( + rrect: RRect.fromRectAndRadius( + Rect.fromLTWH( 800.0 - 2.5 - 2.5, // Screen width - margin - thickness. 4.0, // Initial position is the top margin. 2.5, // Thickness. diff --git a/packages/flutter/test/cupertino/scrollbar_test.dart b/packages/flutter/test/cupertino/scrollbar_test.dart index edabc5ec2e..2350b823ef 100644 --- a/packages/flutter/test/cupertino/scrollbar_test.dart +++ b/packages/flutter/test/cupertino/scrollbar_test.dart @@ -9,10 +9,10 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Scrollbar never goes away until finger lift', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new CupertinoScrollbar( - child: new SingleChildScrollView( + child: CupertinoScrollbar( + child: SingleChildScrollView( child: const SizedBox(width: 4000.0, height: 4000.0), ), ), @@ -45,10 +45,10 @@ void main() { testWidgets('Scrollbar is not smaller than minLength with large scroll views', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new CupertinoScrollbar( - child: new SingleChildScrollView( + child: CupertinoScrollbar( + child: SingleChildScrollView( child: const SizedBox(width: 800.0, height: 20000.0), ), ), diff --git a/packages/flutter/test/cupertino/segmented_control_test.dart b/packages/flutter/test/cupertino/segmented_control_test.dart index a142e14ad6..c2d36f64fc 100644 --- a/packages/flutter/test/cupertino/segmented_control_test.dart +++ b/packages/flutter/test/cupertino/segmented_control_test.dart @@ -24,10 +24,10 @@ StatefulBuilder setupSimpleSegmentedControl() { children[1] = const Text('Child 2'); int sharedValue = 0; - return new StatefulBuilder( + return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -42,9 +42,9 @@ StatefulBuilder setupSimpleSegmentedControl() { } Widget boilerplate({Widget child}) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center(child: child), + child: Center(child: child), ); } @@ -62,10 +62,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -92,7 +92,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -107,7 +107,7 @@ void main() { await tester.pumpWidget( boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -128,7 +128,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, groupValue: 2, @@ -147,7 +147,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: null, onValueChanged: (int newValue) {}, ), @@ -165,7 +165,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: null, ), @@ -179,7 +179,7 @@ void main() { try { await tester.pumpWidget( boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, unselectedColor: null, @@ -201,10 +201,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -245,10 +245,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -300,14 +300,14 @@ void main() { children[1] = const Text('Child 2'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Align( + child: Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 200.0, height: 200.0, - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -329,10 +329,10 @@ void main() { bool value = false; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { value = true; @@ -359,10 +359,10 @@ void main() { const int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, groupValue: sharedValue, @@ -406,7 +406,7 @@ void main() { (WidgetTester tester) async { final Map children = {}; children[0] = const Text('Child 1'); - children[1] = new Container( + children[1] = Container( constraints: const BoxConstraints.tightFor(width: 50.0, height: 50.0), ); children[2] = const Placeholder(); @@ -414,10 +414,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -452,10 +452,10 @@ void main() { int sharedValue; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -508,21 +508,21 @@ void main() { testWidgets('Height of segmented control is determined by tallest widget', (WidgetTester tester) async { final Map children = {}; - children[0] = new Container( + children[0] = Container( constraints: const BoxConstraints.tightFor(height: 100.0), ); - children[1] = new Container( + children[1] = Container( constraints: const BoxConstraints.tightFor(height: 400.0), ); - children[2] = new Container( + children[2] = Container( constraints: const BoxConstraints.tightFor(height: 200.0), ); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -541,21 +541,21 @@ void main() { testWidgets('Width of each segmented control segment is determined by widest widget', (WidgetTester tester) async { final Map children = {}; - children[0] = new Container( + children[0] = Container( constraints: const BoxConstraints.tightFor(width: 50.0), ); - children[1] = new Container( + children[1] = Container( constraints: const BoxConstraints.tightFor(width: 100.0), ); - children[2] = new Container( + children[2] = Container( constraints: const BoxConstraints.tightFor(width: 200.0), ); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -588,12 +588,12 @@ void main() { children[1] = const Text('Child 2'); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( child: Row( children: [ - new CupertinoSegmentedControl( + CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -620,8 +620,8 @@ void main() { await tester.pumpWidget( Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new CupertinoSegmentedControl( + child: Center( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) {}, ), @@ -642,12 +642,12 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new CupertinoSegmentedControl( + child: Center( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -678,7 +678,7 @@ void main() { }); testWidgets('Segmented control semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final Map children = {}; children[0] = const Text('Child 1'); @@ -686,12 +686,12 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new CupertinoSegmentedControl( + child: Center( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -709,9 +709,9 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Child 1', flags: [ SemanticsFlag.isButton, @@ -722,7 +722,7 @@ void main() { SemanticsAction.tap, ], ), - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Child 2', flags: [ SemanticsFlag.isButton, @@ -746,9 +746,9 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Child 1', flags: [ SemanticsFlag.isButton, @@ -758,7 +758,7 @@ void main() { SemanticsAction.tap, ], ), - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Child 2', flags: [ SemanticsFlag.isButton, @@ -787,10 +787,10 @@ void main() { int sharedValue = 1; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -812,7 +812,7 @@ void main() { // Tap just inside segment bounds await tester.tapAt( - new Offset( + Offset( centerOfSegmentedControl.dx + (childWidth / 2) - 10.0, centerOfSegmentedControl.dy, ), @@ -859,10 +859,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -879,10 +879,10 @@ void main() { await tester.tap(find.text('Child 2')); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -899,10 +899,10 @@ void main() { expect(getBackgroundColor(tester, 1), const Color(0x33007aff)); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -920,10 +920,10 @@ void main() { expect(getBackgroundColor(tester, 1), const Color(0x64007aff)); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -941,10 +941,10 @@ void main() { expect(getBackgroundColor(tester, 1), const Color(0x95007aff)); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -962,10 +962,10 @@ void main() { expect(getBackgroundColor(tester, 1), const Color(0xc7007aff)); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -983,10 +983,10 @@ void main() { expect(getBackgroundColor(tester, 1), const Color(0xf8007aff)); await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( children: children, onValueChanged: (int newValue) { setState(() { @@ -1012,10 +1012,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1055,10 +1055,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1146,10 +1146,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1157,7 +1157,7 @@ void main() { sharedValue = newValue; }); if (sharedValue == 1) { - children = new Map.from(children); + children = Map.from(children); children[3] = const Text('D'); } }, @@ -1194,10 +1194,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1206,7 +1206,7 @@ void main() { }); if (sharedValue == 1) { children.remove(2); - children = new Map.from(children); + children = Map.from(children); } }, groupValue: sharedValue, @@ -1239,10 +1239,10 @@ void main() { int sharedValue = 0; await tester.pumpWidget( - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) { @@ -1251,7 +1251,7 @@ void main() { }); if (sharedValue == 1) { children.remove(1); - children = new Map.from(children); + children = Map.from(children); sharedValue = null; } }, @@ -1284,20 +1284,20 @@ void main() { testWidgets('Golden Test Placeholder Widget', (WidgetTester tester) async { final Map children = {}; - children[0] = new Container(); + children[0] = Container(); children[1] = const Placeholder(); - children[2] = new Container(); + children[2] = Container(); const int currentValue = 0; await tester.pumpWidget( - new RepaintBoundary( - child: new StatefulBuilder( + RepaintBoundary( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SizedBox( + child: SizedBox( width: 800.0, - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, @@ -1325,13 +1325,13 @@ void main() { const int currentValue = 0; await tester.pumpWidget( - new RepaintBoundary( - child: new StatefulBuilder( + RepaintBoundary( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return boilerplate( - child: new SizedBox( + child: SizedBox( width: 800.0, - child: new CupertinoSegmentedControl( + child: CupertinoSegmentedControl( key: const ValueKey('Segmented Control'), children: children, onValueChanged: (int newValue) {}, diff --git a/packages/flutter/test/cupertino/slider_test.dart b/packages/flutter/test/cupertino/slider_test.dart index 2dd543818e..5c8e1ca6fe 100644 --- a/packages/flutter/test/cupertino/slider_test.dart +++ b/packages/flutter/test/cupertino/slider_test.dart @@ -20,16 +20,16 @@ void main() { } testWidgets('Slider does not move when tapped (LTR)', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new CupertinoSlider( + return Material( + child: Center( + child: CupertinoSlider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -54,16 +54,16 @@ void main() { }); testWidgets('Slider does not move when tapped (RTL)', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new CupertinoSlider( + return Material( + child: Center( + child: CupertinoSlider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -88,17 +88,17 @@ void main() { }); testWidgets('Slider calls onChangeStart once when interaction begins', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; int numberOfTimesOnChangeStartIsCalled = 0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new CupertinoSlider( + return Material( + child: Center( + child: CupertinoSlider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -127,17 +127,17 @@ void main() { }); testWidgets('Slider calls onChangeEnd once after interaction has ended', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; int numberOfTimesOnChangeEndIsCalled = 0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new CupertinoSlider( + return Material( + child: Center( + child: CupertinoSlider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -166,18 +166,18 @@ void main() { }); testWidgets('Slider moves when dragged (LTR)', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; double startValue; double endValue; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new CupertinoSlider( + return Material( + child: Center( + child: CupertinoSlider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -218,18 +218,18 @@ void main() { }); testWidgets('Slider moves when dragged (RTL)', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; double startValue; double endValue; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new CupertinoSlider( + return Material( + child: Center( + child: CupertinoSlider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -274,20 +274,20 @@ void main() { }); testWidgets('Slider Semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new CupertinoSlider( + child: CupertinoSlider( value: 0.5, onChanged: (double v) {}, ), )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, value: '50%', increasedValue: '60%', @@ -311,7 +311,7 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root(), + TestSemantics.root(), ignoreRect: true, ignoreTransform: true, )); @@ -322,9 +322,9 @@ void main() { testWidgets('Slider Semantics can be updated', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); double value = 0.5; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new CupertinoSlider( + child: CupertinoSlider( value: value, onChanged: (double v) { }, ), @@ -340,9 +340,9 @@ void main() { )); value = 0.6; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new CupertinoSlider( + child: CupertinoSlider( value: value, onChanged: (double v) { }, ), diff --git a/packages/flutter/test/cupertino/switch_test.dart b/packages/flutter/test/cupertino/switch_test.dart index cffb7c4fb8..c08ea4ab49 100644 --- a/packages/flutter/test/cupertino/switch_test.dart +++ b/packages/flutter/test/cupertino/switch_test.dart @@ -7,15 +7,15 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Switch can toggle on tap', (WidgetTester tester) async { - final Key switchKey = new UniqueKey(); + final Key switchKey = UniqueKey(); bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Center( - child: new CupertinoSwitch( + return Center( + child: CupertinoSwitch( key: switchKey, value: value, onChanged: (bool newValue) { @@ -39,12 +39,12 @@ void main() { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Center( - child: new CupertinoSwitch( + return Center( + child: CupertinoSwitch( value: value, onChanged: (bool newValue) { setState(() { @@ -83,12 +83,12 @@ void main() { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Center( - child: new CupertinoSwitch( + return Center( + child: CupertinoSwitch( value: value, onChanged: (bool newValue) { setState(() { diff --git a/packages/flutter/test/cupertino/tab_scaffold_test.dart b/packages/flutter/test/cupertino/tab_scaffold_test.dart index 94f40cf73d..cfecd3b105 100644 --- a/packages/flutter/test/cupertino/tab_scaffold_test.dart +++ b/packages/flutter/test/cupertino/tab_scaffold_test.dart @@ -20,13 +20,13 @@ void main() { final List tabsPainted = []; await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabScaffold( + CupertinoApp( + home: CupertinoTabScaffold( tabBar: _buildTabBar(), tabBuilder: (BuildContext context, int index) { - return new CustomPaint( - child: new Text('Page ${index + 1}'), - painter: new TestCallbackPainter( + return CustomPaint( + child: Text('Page ${index + 1}'), + painter: TestCallbackPainter( onPaint: () { tabsPainted.add(index); } ) ); @@ -74,12 +74,12 @@ void main() { final List tabsBuilt = []; await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabScaffold( + CupertinoApp( + home: CupertinoTabScaffold( tabBar: _buildTabBar(), tabBuilder: (BuildContext context, int index) { tabsBuilt.add(index); - return new Text('Page ${index + 1}'); + return Text('Page ${index + 1}'); }, ), ), @@ -107,15 +107,15 @@ void main() { testWidgets('Last tab gets focus', (WidgetTester tester) async { // 2 nodes for 2 tabs - final List focusNodes = [new FocusNode(), new FocusNode()]; + final List focusNodes = [FocusNode(), FocusNode()]; await tester.pumpWidget( - new CupertinoApp( - home: new Material( - child: new CupertinoTabScaffold( + CupertinoApp( + home: Material( + child: CupertinoTabScaffold( tabBar: _buildTabBar(), tabBuilder: (BuildContext context, int index) { - return new TextField( + return TextField( focusNode: focusNodes[index], autofocus: true, ); @@ -142,24 +142,24 @@ void main() { testWidgets('Do not affect focus order in the route', (WidgetTester tester) async { final List focusNodes = [ - new FocusNode(), new FocusNode(), new FocusNode(), new FocusNode(), + FocusNode(), FocusNode(), FocusNode(), FocusNode(), ]; await tester.pumpWidget( - new CupertinoApp( - home: new Material( - child: new CupertinoTabScaffold( + CupertinoApp( + home: Material( + child: CupertinoTabScaffold( tabBar: _buildTabBar(), tabBuilder: (BuildContext context, int index) { - return new Column( + return Column( children: [ - new TextField( + TextField( focusNode: focusNodes[index * 2], decoration: const InputDecoration( hintText: 'TextField 1', ), ), - new TextField( + TextField( focusNode: focusNodes[index * 2 + 1], decoration: const InputDecoration( hintText: 'TextField 2', @@ -210,13 +210,13 @@ void main() { final List tabsPainted = []; await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabScaffold( + CupertinoApp( + home: CupertinoTabScaffold( tabBar: _buildTabBar(), tabBuilder: (BuildContext context, int index) { - return new CustomPaint( - child: new Text('Page ${index + 1}'), - painter: new TestCallbackPainter( + return CustomPaint( + child: Text('Page ${index + 1}'), + painter: TestCallbackPainter( onPaint: () { tabsPainted.add(index); } ) ); @@ -228,13 +228,13 @@ void main() { expect(tabsPainted, [0]); await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabScaffold( + CupertinoApp( + home: CupertinoTabScaffold( tabBar: _buildTabBar(selectedTab: 1), // Programmatically change the tab now. tabBuilder: (BuildContext context, int index) { - return new CustomPaint( - child: new Text('Page ${index + 1}'), - painter: new TestCallbackPainter( + return CustomPaint( + child: Text('Page ${index + 1}'), + painter: TestCallbackPainter( onPaint: () { tabsPainted.add(index); } ) ); @@ -257,7 +257,7 @@ void main() { } CupertinoTabBar _buildTabBar({ int selectedTab = 0 }) { - return new CupertinoTabBar( + return CupertinoTabBar( items: const [ BottomNavigationBarItem( icon: ImageIcon(TestImageProvider(24, 24)), diff --git a/packages/flutter/test/cupertino/tab_test.dart b/packages/flutter/test/cupertino/tab_test.dart index 0e8b6754c6..08a873e7a8 100644 --- a/packages/flutter/test/cupertino/tab_test.dart +++ b/packages/flutter/test/cupertino/tab_test.dart @@ -8,8 +8,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Use home', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabView( + CupertinoApp( + home: CupertinoTabView( builder: (BuildContext context) => const Text('home'), ), ), @@ -20,8 +20,8 @@ void main() { testWidgets('Use routes', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabView( + CupertinoApp( + home: CupertinoTabView( routes: { '/': (BuildContext context) => const Text('first route'), }, @@ -34,10 +34,10 @@ void main() { testWidgets('Use home and named routes', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabView( + CupertinoApp( + home: CupertinoTabView( builder: (BuildContext context) { - return new CupertinoButton( + return CupertinoButton( child: const Text('go to second page'), onPressed: () { Navigator.of(context).pushNamed('/2'); @@ -60,11 +60,11 @@ void main() { testWidgets('Use onGenerateRoute', (WidgetTester tester) async { await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabView( + CupertinoApp( + home: CupertinoTabView( onGenerateRoute: (RouteSettings settings) { if (settings.name == Navigator.defaultRouteName) { - return new CupertinoPageRoute( + return CupertinoPageRoute( settings: settings, builder: (BuildContext context) { return const Text('generated home'); @@ -83,8 +83,8 @@ void main() { testWidgets('Use onUnknownRoute', (WidgetTester tester) async { String unknownForRouteCalled; await tester.pumpWidget( - new CupertinoApp( - home: new CupertinoTabView( + CupertinoApp( + home: CupertinoTabView( onUnknownRoute: (RouteSettings settings) { unknownForRouteCalled = settings.name; return null; diff --git a/packages/flutter/test/engine/color_test.dart b/packages/flutter/test/engine/color_test.dart index ed9144e49f..5ca6a2e7cc 100644 --- a/packages/flutter/test/engine/color_test.dart +++ b/packages/flutter/test/engine/color_test.dart @@ -17,7 +17,7 @@ void main() { test('paint set to black', () { const Color c = Color(0x00000000); - final Paint p = new Paint(); + final Paint p = Paint(); p.color = c; expect(c.toString(), equals('Color(0x00000000)')); }); @@ -25,7 +25,7 @@ void main() { test('color created with out of bounds value', () { try { const Color c = Color(0x100 << 24); - final Paint p = new Paint(); + final Paint p = Paint(); p.color = c; } catch (e) { expect(e != null, equals(true)); @@ -35,7 +35,7 @@ void main() { test('color created with wildly out of bounds value', () { try { const Color c = Color(1 << 1000000); - final Paint p = new Paint(); + final Paint p = Paint(); p.color = c; } catch (e) { expect(e != null, equals(true)); diff --git a/packages/flutter/test/engine/dart_test.dart b/packages/flutter/test/engine/dart_test.dart index 86e59667e4..b440600add 100644 --- a/packages/flutter/test/engine/dart_test.dart +++ b/packages/flutter/test/engine/dart_test.dart @@ -12,7 +12,7 @@ void main() { String greeting = 'hello'; Future changeGreeting() async { greeting += ' 1'; - await new Future.value(null); + await Future.value(null); greeting += ' 2'; } test('execution of async method starts synchronously', () async { diff --git a/packages/flutter/test/engine/paragraph_builder_test.dart b/packages/flutter/test/engine/paragraph_builder_test.dart index eb46f31799..ba0905d197 100644 --- a/packages/flutter/test/engine/paragraph_builder_test.dart +++ b/packages/flutter/test/engine/paragraph_builder_test.dart @@ -8,12 +8,12 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { test('Should be able to build and layout a paragraph', () { - final ParagraphBuilder builder = new ParagraphBuilder(new ParagraphStyle()); + final ParagraphBuilder builder = ParagraphBuilder(ParagraphStyle()); builder.addText('Hello'); final Paragraph paragraph = builder.build(); expect(paragraph, isNotNull); - paragraph.layout(new ParagraphConstraints(width: 800.0)); + paragraph.layout(ParagraphConstraints(width: 800.0)); expect(paragraph.width, isNonZero); expect(paragraph.height, isNonZero); }); diff --git a/packages/flutter/test/engine/rect_test.dart b/packages/flutter/test/engine/rect_test.dart index f478f3a113..a46a3168b0 100644 --- a/packages/flutter/test/engine/rect_test.dart +++ b/packages/flutter/test/engine/rect_test.dart @@ -8,7 +8,7 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { test('rect accessors', () { - final Rect r = new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0); + final Rect r = Rect.fromLTRB(1.0, 3.0, 5.0, 7.0); expect(r.left, equals(1.0)); expect(r.top, equals(3.0)); expect(r.right, equals(5.0)); @@ -16,7 +16,7 @@ void main() { }); test('rect created by width and height', () { - final Rect r = new Rect.fromLTWH(1.0, 3.0, 5.0, 7.0); + final Rect r = Rect.fromLTWH(1.0, 3.0, 5.0, 7.0); expect(r.left, equals(1.0)); expect(r.top, equals(3.0)); expect(r.right, equals(6.0)); @@ -24,8 +24,8 @@ void main() { }); test('rect intersection', () { - final Rect r1 = new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0); - final Rect r2 = new Rect.fromLTRB(50.0, 50.0, 200.0, 200.0); + final Rect r1 = Rect.fromLTRB(0.0, 0.0, 100.0, 100.0); + final Rect r2 = Rect.fromLTRB(50.0, 50.0, 200.0, 200.0); final Rect r3 = r1.intersect(r2); expect(r3.left, equals(50.0)); expect(r3.top, equals(50.0)); diff --git a/packages/flutter/test/engine/rrect_test.dart b/packages/flutter/test/engine/rrect_test.dart index 06140102e7..5ae2dae22a 100644 --- a/packages/flutter/test/engine/rrect_test.dart +++ b/packages/flutter/test/engine/rrect_test.dart @@ -8,8 +8,8 @@ import 'package:test/test.dart' hide TypeMatcher, isInstanceOf; void main() { test('RRect.contains()', () { - final RRect rrect = new RRect.fromRectAndCorners( - new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + final RRect rrect = RRect.fromRectAndCorners( + Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), topLeft: const Radius.circular(0.5), topRight: const Radius.circular(0.25), bottomRight: const Radius.elliptical(0.25, 0.75), @@ -27,8 +27,8 @@ void main() { }); test('RRect.contains() large radii', () { - final RRect rrect = new RRect.fromRectAndCorners( - new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + final RRect rrect = RRect.fromRectAndCorners( + Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), topLeft: const Radius.circular(5000.0), topRight: const Radius.circular(2500.0), bottomRight: const Radius.elliptical(2500.0, 7500.0), diff --git a/packages/flutter/test/engine/task_order_test.dart b/packages/flutter/test/engine/task_order_test.dart index 6eadd945fb..f29acf6087 100644 --- a/packages/flutter/test/engine/task_order_test.dart +++ b/packages/flutter/test/engine/task_order_test.dart @@ -13,7 +13,7 @@ void main() { tasks.add(1); // Flush 0 microtasks. - await new Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); scheduleMicrotask(() { tasks.add(3); @@ -25,7 +25,7 @@ void main() { tasks.add(2); // Flush 2 microtasks. - await new Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); scheduleMicrotask(() { tasks.add(6); @@ -40,7 +40,7 @@ void main() { tasks.add(5); // Flush 3 microtasks. - await new Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); tasks.add(9); diff --git a/packages/flutter/test/flutter_test_alternative.dart b/packages/flutter/test/flutter_test_alternative.dart index 79d7310b12..55d44ba91e 100644 --- a/packages/flutter/test/flutter_test_alternative.dart +++ b/packages/flutter/test/flutter_test_alternative.dart @@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher; export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; /// A matcher that compares the type of the actual value to the type argument T. -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 diff --git a/packages/flutter/test/foundation/assertions_test.dart b/packages/flutter/test/foundation/assertions_test.dart index a2ff96a829..4a2d8590fd 100644 --- a/packages/flutter/test/foundation/assertions_test.dart +++ b/packages/flutter/test/foundation/assertions_test.dart @@ -18,7 +18,7 @@ void main() { test('debugPrintStack', () { final List log = captureOutput(() { - final FlutterErrorDetails details = new FlutterErrorDetails( + final FlutterErrorDetails details = FlutterErrorDetails( exception: 'Example exception', stack: StackTrace.current, library: 'Example library', @@ -43,7 +43,7 @@ void main() { test('FlutterErrorDetails.toString', () { expect( - new FlutterErrorDetails( + FlutterErrorDetails( exception: 'MESSAGE', library: 'LIBRARY', context: 'CONTEXTING', @@ -56,7 +56,7 @@ void main() { 'INFO', ); expect( - new FlutterErrorDetails( + FlutterErrorDetails( library: 'LIBRARY', context: 'CONTEXTING', informationCollector: (StringBuffer information) { @@ -68,7 +68,7 @@ void main() { 'INFO', ); expect( - new FlutterErrorDetails( + FlutterErrorDetails( exception: 'MESSAGE', context: 'CONTEXTING', informationCollector: (StringBuffer information) { diff --git a/packages/flutter/test/foundation/bit_field_test.dart b/packages/flutter/test/foundation/bit_field_test.dart index a9a388a2c9..a2cf371e34 100644 --- a/packages/flutter/test/foundation/bit_field_test.dart +++ b/packages/flutter/test/foundation/bit_field_test.dart @@ -11,7 +11,7 @@ enum _TestEnum { void main() { test('BitField control test', () { - final BitField<_TestEnum> field = new BitField<_TestEnum>(8); + final BitField<_TestEnum> field = BitField<_TestEnum>(8); expect(field[_TestEnum.d], isFalse); @@ -42,11 +42,11 @@ void main() { }); test('BitField.filed control test', () { - final BitField<_TestEnum> field1 = new BitField<_TestEnum>.filled(8, true); + final BitField<_TestEnum> field1 = BitField<_TestEnum>.filled(8, true); expect(field1[_TestEnum.d], isTrue); - final BitField<_TestEnum> field2 = new BitField<_TestEnum>.filled(8, false); + final BitField<_TestEnum> field2 = BitField<_TestEnum>.filled(8, false); expect(field2[_TestEnum.d], isFalse); }); diff --git a/packages/flutter/test/foundation/caching_iterable_test.dart b/packages/flutter/test/foundation/caching_iterable_test.dart index beedf3468e..f93229dce9 100644 --- a/packages/flutter/test/foundation/caching_iterable_test.dart +++ b/packages/flutter/test/foundation/caching_iterable_test.dart @@ -21,7 +21,7 @@ void main() { }); test('The Caching Iterable: length caches', () { - final Iterable i = new CachingIterable(range(1, 5).iterator); + final Iterable i = CachingIterable(range(1, 5).iterator); expect(yieldCount, equals(0)); expect(i.length, equals(5)); expect(yieldCount, equals(5)); @@ -37,7 +37,7 @@ void main() { }); test('The Caching Iterable: laziness', () { - final Iterable i = new CachingIterable(range(1, 5).iterator); + final Iterable i = CachingIterable(range(1, 5).iterator); expect(yieldCount, equals(0)); expect(i.first, equals(1)); @@ -51,7 +51,7 @@ void main() { }); test('The Caching Iterable: where and map', () { - final Iterable integers = new CachingIterable(range(1, 5).iterator); + final Iterable integers = CachingIterable(range(1, 5).iterator); expect(yieldCount, equals(0)); final Iterable evens = integers.where((int i) => i % 2 == 0); @@ -74,7 +74,7 @@ void main() { }); test('The Caching Iterable: take and skip', () { - final Iterable integers = new CachingIterable(range(1, 5).iterator); + final Iterable integers = CachingIterable(range(1, 5).iterator); expect(yieldCount, equals(0)); final Iterable secondTwo = integers.skip(1).take(2); @@ -92,7 +92,7 @@ void main() { }); test('The Caching Iterable: expand', () { - final Iterable integers = new CachingIterable(range(1, 5).iterator); + final Iterable integers = CachingIterable(range(1, 5).iterator); expect(yieldCount, equals(0)); final Iterable expanded1 = integers.expand((int i) => [i, i]); diff --git a/packages/flutter/test/foundation/capture_output.dart b/packages/flutter/test/foundation/capture_output.dart index 5bcfac3a70..de4f514d3a 100644 --- a/packages/flutter/test/foundation/capture_output.dart +++ b/packages/flutter/test/foundation/capture_output.dart @@ -8,7 +8,7 @@ import 'dart:ui' show VoidCallback; List captureOutput(VoidCallback fn) { final List log = []; - runZoned(fn, zoneSpecification: new ZoneSpecification( + runZoned(fn, zoneSpecification: ZoneSpecification( print: (Zone self, ZoneDelegate parent, Zone zone, diff --git a/packages/flutter/test/foundation/change_notifier_test.dart b/packages/flutter/test/foundation/change_notifier_test.dart index 87fda33d16..85c2194eca 100644 --- a/packages/flutter/test/foundation/change_notifier_test.dart +++ b/packages/flutter/test/foundation/change_notifier_test.dart @@ -19,7 +19,7 @@ void main() { final VoidCallback listener2 = () { log.add('listener2'); }; final VoidCallback badListener = () { log.add('badListener'); throw null; }; - final TestNotifier test = new TestNotifier(); + final TestNotifier test = TestNotifier(); test.addListener(listener); test.addListener(listener); @@ -85,7 +85,7 @@ void main() { }); test('ChangeNotifier with mutating listener', () { - final TestNotifier test = new TestNotifier(); + final TestNotifier test = TestNotifier(); final List log = []; final VoidCallback listener1 = () { log.add('listener1'); }; @@ -115,12 +115,12 @@ void main() { }); test('Merging change notifiers', () { - final TestNotifier source1 = new TestNotifier(); - final TestNotifier source2 = new TestNotifier(); - final TestNotifier source3 = new TestNotifier(); + final TestNotifier source1 = TestNotifier(); + final TestNotifier source2 = TestNotifier(); + final TestNotifier source3 = TestNotifier(); final List log = []; - final Listenable merged = new Listenable.merge([source1, source2]); + final Listenable merged = Listenable.merge([source1, source2]); final VoidCallback listener1 = () { log.add('listener1'); }; final VoidCallback listener2 = () { log.add('listener2'); }; @@ -148,11 +148,11 @@ void main() { }); test('Merging change notifiers ignores null', () { - final TestNotifier source1 = new TestNotifier(); - final TestNotifier source2 = new TestNotifier(); + final TestNotifier source1 = TestNotifier(); + final TestNotifier source2 = TestNotifier(); final List log = []; - final Listenable merged = new Listenable.merge([null, source1, null, source2, null]); + final Listenable merged = Listenable.merge([null, source1, null, source2, null]); final VoidCallback listener = () { log.add('listener'); }; merged.addListener(listener); @@ -163,11 +163,11 @@ void main() { }); test('Can dispose merged notifier', () { - final TestNotifier source1 = new TestNotifier(); - final TestNotifier source2 = new TestNotifier(); + final TestNotifier source1 = TestNotifier(); + final TestNotifier source2 = TestNotifier(); final List log = []; - final ChangeNotifier merged = new Listenable.merge([source1, source2]); + final ChangeNotifier merged = Listenable.merge([source1, source2]); final VoidCallback listener = () { log.add('listener'); }; merged.addListener(listener); @@ -183,7 +183,7 @@ void main() { }); test('Cannot use a disposed ChangeNotifier', () { - final TestNotifier source = new TestNotifier(); + final TestNotifier source = TestNotifier(); source.dispose(); expect(() { source.addListener(null); }, throwsFlutterError); expect(() { source.removeListener(null); }, throwsFlutterError); @@ -192,7 +192,7 @@ void main() { }); test('Value notifier', () { - final ValueNotifier notifier = new ValueNotifier(2.0); + final ValueNotifier notifier = ValueNotifier(2.0); final List log = []; final VoidCallback listener = () { log.add(notifier.value); }; @@ -208,28 +208,28 @@ void main() { }); test('Listenable.merge toString', () { - final TestNotifier source1 = new TestNotifier(); - final TestNotifier source2 = new TestNotifier(); + final TestNotifier source1 = TestNotifier(); + final TestNotifier source2 = TestNotifier(); - ChangeNotifier listenableUnderTest = new Listenable.merge([]); + ChangeNotifier listenableUnderTest = Listenable.merge([]); expect(listenableUnderTest.toString(), 'Listenable.merge([])'); - listenableUnderTest = new Listenable.merge([null]); + listenableUnderTest = Listenable.merge([null]); expect(listenableUnderTest.toString(), 'Listenable.merge([null])'); - listenableUnderTest = new Listenable.merge([source1]); + listenableUnderTest = Listenable.merge([source1]); expect( listenableUnderTest.toString(), "Listenable.merge([Instance of 'TestNotifier'])", ); - listenableUnderTest = new Listenable.merge([source1, source2]); + listenableUnderTest = Listenable.merge([source1, source2]); expect( listenableUnderTest.toString(), "Listenable.merge([Instance of 'TestNotifier', Instance of 'TestNotifier'])", ); - listenableUnderTest = new Listenable.merge([null, source2]); + listenableUnderTest = Listenable.merge([null, source2]); expect( listenableUnderTest.toString(), "Listenable.merge([null, Instance of 'TestNotifier'])", @@ -237,7 +237,7 @@ void main() { }); test('hasListeners', () { - final HasListenersTester notifier = new HasListenersTester(true); + final HasListenersTester notifier = HasListenersTester(true); expect(notifier.testHasListeners, isFalse); void test1() { } void test2() { } diff --git a/packages/flutter/test/foundation/consolidate_response_test.dart b/packages/flutter/test/foundation/consolidate_response_test.dart index bcd15058c2..3ab3963304 100644 --- a/packages/flutter/test/foundation/consolidate_response_test.dart +++ b/packages/flutter/test/foundation/consolidate_response_test.dart @@ -17,7 +17,7 @@ void main() { MockHttpClientResponse response; setUp(() { - response = new MockHttpClientResponse(); + response = MockHttpClientResponse(); when(response.listen( any, onDone: anyNamed('onDone'), @@ -29,7 +29,7 @@ void main() { final void Function() onDone = invocation.namedArguments[#onDone]; final bool cancelOnError = invocation.namedArguments[#cancelOnError]; - return new Stream>.fromIterable( + return Stream>.fromIterable( >[chunkOne, chunkTwo]).listen( onData, onDone: onDone, @@ -79,8 +79,8 @@ void main() { final void Function() onDone = invocation.namedArguments[#onDone]; final bool cancelOnError = invocation.namedArguments[#cancelOnError]; - return new Stream>.fromFuture( - new Future>.error(new Exception('Test Error'))) + return Stream>.fromFuture( + Future>.error(Exception('Test Error'))) .listen( onData, onDone: onDone, diff --git a/packages/flutter/test/foundation/covariant_templates_test.dart b/packages/flutter/test/foundation/covariant_templates_test.dart index 0006ffaa93..9e5ea70010 100644 --- a/packages/flutter/test/foundation/covariant_templates_test.dart +++ b/packages/flutter/test/foundation/covariant_templates_test.dart @@ -14,10 +14,10 @@ class A { void main() { test('Assignment through a covariant template throws exception', () { - final A ay = new A(); + final A ay = A(); final A ayAsAx = ay; expect(() { - ayAsAx.u = new X(); + ayAsAx.u = X(); }, throwsAssertionError); }); } diff --git a/packages/flutter/test/foundation/debug_test.dart b/packages/flutter/test/foundation/debug_test.dart index 2258cc8b1f..faddcce839 100644 --- a/packages/flutter/test/foundation/debug_test.dart +++ b/packages/flutter/test/foundation/debug_test.dart @@ -12,7 +12,7 @@ void main() { setUp(() { debugInstrumentationEnabled = true; - printBuffer = new StringBuffer(); + printBuffer = StringBuffer(); originalDebugPrintCallback = debugPrint; debugPrint = (String message, {int wrapWidth}) { printBuffer.writeln(message); @@ -32,14 +32,14 @@ void main() { expect(result, 1); expect( printBuffer.toString(), - matches(new RegExp('^action\\(\\)\nAction "no-op" took .+\$', multiLine: true)), + matches(RegExp('^action\\(\\)\nAction "no-op" took .+\$', multiLine: true)), ); }); test('returns failing future if action throws', () async { try { await debugInstrumentAction('throws', () async { - await new Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); throw 'Error'; }); fail('Error expected but not thrown'); diff --git a/packages/flutter/test/foundation/diagnostics_test.dart b/packages/flutter/test/foundation/diagnostics_test.dart index 962712a93e..d19511f130 100644 --- a/packages/flutter/test/foundation/diagnostics_test.dart +++ b/packages/flutter/test/foundation/diagnostics_test.dart @@ -184,18 +184,18 @@ void main() { {DiagnosticsTreeStyle style, DiagnosticsTreeStyle lastChildStyle, String golden = ''}) { - final TestTree tree = new TestTree(children: [ - new TestTree(name: 'node A', style: style), - new TestTree( + final TestTree tree = TestTree(children: [ + TestTree(name: 'node A', style: style), + TestTree( name: 'node B', children: [ - new TestTree(name: 'node B1', style: style), - new TestTree(name: 'node B2', style: style), - new TestTree(name: 'node B3', style: lastChildStyle ?? style), + TestTree(name: 'node B1', style: style), + TestTree(name: 'node B2', style: style), + TestTree(name: 'node B3', style: lastChildStyle ?? style), ], style: style, ), - new TestTree(name: 'node C', style: lastChildStyle ?? style), + TestTree(name: 'node C', style: lastChildStyle ?? style), ], style: lastChildStyle); expect(tree, hasAGoodToStringDeep); @@ -320,46 +320,46 @@ void main() { DiagnosticsTreeStyle lastChildStyle, @required String golden, }) { - final TestTree tree = new TestTree( + final TestTree tree = TestTree( properties: [ - new StringProperty('stringProperty1', 'value1', quoted: false), - new DoubleProperty('doubleProperty1', 42.5), - new DoubleProperty('roundedProperty', 1.0 / 3.0), - new StringProperty('DO_NOT_SHOW', 'DO_NOT_SHOW', level: DiagnosticLevel.hidden, quoted: false), - new DiagnosticsProperty('DO_NOT_SHOW_NULL', null, defaultValue: null), - new DiagnosticsProperty('nullProperty', null), - new StringProperty('node_type', '', showName: false, quoted: false), + StringProperty('stringProperty1', 'value1', quoted: false), + DoubleProperty('doubleProperty1', 42.5), + DoubleProperty('roundedProperty', 1.0 / 3.0), + StringProperty('DO_NOT_SHOW', 'DO_NOT_SHOW', level: DiagnosticLevel.hidden, quoted: false), + DiagnosticsProperty('DO_NOT_SHOW_NULL', null, defaultValue: null), + DiagnosticsProperty('nullProperty', null), + StringProperty('node_type', '', showName: false, quoted: false), ], children: [ - new TestTree(name: 'node A', style: style), - new TestTree( + TestTree(name: 'node A', style: style), + TestTree( name: 'node B', properties: [ - new StringProperty('p1', 'v1', quoted: false), - new StringProperty('p2', 'v2', quoted: false), + StringProperty('p1', 'v1', quoted: false), + StringProperty('p2', 'v2', quoted: false), ], children: [ - new TestTree(name: 'node B1', style: style), - new TestTree( + TestTree(name: 'node B1', style: style), + TestTree( name: 'node B2', - properties: [new StringProperty('property1', 'value1', quoted: false)], + properties: [StringProperty('property1', 'value1', quoted: false)], style: style, ), - new TestTree( + TestTree( name: 'node B3', properties: [ - new StringProperty('node_type', '', showName: false, quoted: false), - new IntProperty('foo', 42), + StringProperty('node_type', '', showName: false, quoted: false), + IntProperty('foo', 42), ], style: lastChildStyle ?? style, ), ], style: style, ), - new TestTree( + TestTree( name: 'node C', properties: [ - new StringProperty('foo', 'multi\nline\nvalue!', quoted: false), + StringProperty('foo', 'multi\nline\nvalue!', quoted: false), ], style: lastChildStyle ?? style, ), @@ -596,44 +596,44 @@ void main() { test('transition test', () { // Test multiple styles integrating together in the same tree due to using // transition to go between styles that would otherwise be incompatible. - final TestTree tree = new TestTree( + final TestTree tree = TestTree( style: DiagnosticsTreeStyle.sparse, properties: [ - new StringProperty('stringProperty1', 'value1'), + StringProperty('stringProperty1', 'value1'), ], children: [ - new TestTree( + TestTree( style: DiagnosticsTreeStyle.transition, name: 'node transition', properties: [ - new StringProperty('p1', 'v1'), - new TestTree( + StringProperty('p1', 'v1'), + TestTree( properties: [ - new DiagnosticsProperty('survived', true), + DiagnosticsProperty('survived', true), ], ).toDiagnosticsNode(name: 'tree property', style: DiagnosticsTreeStyle.whitespace), ], children: [ - new TestTree(name: 'dense child', style: DiagnosticsTreeStyle.dense), - new TestTree( + TestTree(name: 'dense child', style: DiagnosticsTreeStyle.dense), + TestTree( name: 'dense', - properties: [new StringProperty('property1', 'value1')], + properties: [StringProperty('property1', 'value1')], style: DiagnosticsTreeStyle.dense, ), - new TestTree( + TestTree( name: 'node B3', properties: [ - new StringProperty('node_type', '', showName: false, quoted: false), - new IntProperty('foo', 42), + StringProperty('node_type', '', showName: false, quoted: false), + IntProperty('foo', 42), ], style: DiagnosticsTreeStyle.dense ), ], ), - new TestTree( + TestTree( name: 'node C', properties: [ - new StringProperty('foo', 'multi\nline\nvalue!', quoted: false), + StringProperty('foo', 'multi\nline\nvalue!', quoted: false), ], style: DiagnosticsTreeStyle.sparse, ), @@ -672,11 +672,11 @@ void main() { test('string property test', () { expect( - new StringProperty('name', 'value', quoted: false).toString(), + StringProperty('name', 'value', quoted: false).toString(), equals('name: value'), ); - final StringProperty stringProperty = new StringProperty( + final StringProperty stringProperty = StringProperty( 'name', 'value', description: 'VALUE', @@ -687,7 +687,7 @@ void main() { validateStringPropertyJsonSerialization(stringProperty); expect( - new StringProperty( + StringProperty( 'name', 'value', showName: false, @@ -698,12 +698,12 @@ void main() { ); expect( - new StringProperty('name', '', ifEmpty: '').toString(), + StringProperty('name', '', ifEmpty: '').toString(), equals('name: '), ); expect( - new StringProperty( + StringProperty( 'name', '', ifEmpty: '', @@ -712,10 +712,10 @@ void main() { equals(''), ); - expect(new StringProperty('name', null).isFiltered(DiagnosticLevel.info), isFalse); - expect(new StringProperty('name', 'value', level: DiagnosticLevel.hidden).isFiltered(DiagnosticLevel.info), isTrue); - expect(new StringProperty('name', null, defaultValue: null).isFiltered(DiagnosticLevel.info), isTrue); - final StringProperty quoted = new StringProperty( + expect(StringProperty('name', null).isFiltered(DiagnosticLevel.info), isFalse); + expect(StringProperty('name', 'value', level: DiagnosticLevel.hidden).isFiltered(DiagnosticLevel.info), isTrue); + expect(StringProperty('name', null, defaultValue: null).isFiltered(DiagnosticLevel.info), isTrue); + final StringProperty quoted = StringProperty( 'name', 'value', quoted: true, @@ -724,12 +724,12 @@ void main() { validateStringPropertyJsonSerialization(quoted); expect( - new StringProperty('name', 'value', showName: false).toString(), + StringProperty('name', 'value', showName: false).toString(), equals('"value"'), ); expect( - new StringProperty( + StringProperty( 'name', null, showName: false, @@ -740,8 +740,8 @@ void main() { }); test('bool property test', () { - final DiagnosticsProperty trueProperty = new DiagnosticsProperty('name', true); - final DiagnosticsProperty falseProperty = new DiagnosticsProperty('name', false); + final DiagnosticsProperty trueProperty = DiagnosticsProperty('name', true); + final DiagnosticsProperty falseProperty = DiagnosticsProperty('name', false); expect(trueProperty.toString(), equals('name: true')); expect(trueProperty.isFiltered(DiagnosticLevel.info), isFalse); expect(trueProperty.value, isTrue); @@ -750,7 +750,7 @@ void main() { expect(falseProperty.isFiltered(DiagnosticLevel.info), isFalse); validatePropertyJsonSerialization(trueProperty); validatePropertyJsonSerialization(falseProperty); - final DiagnosticsProperty truthyProperty = new DiagnosticsProperty( + final DiagnosticsProperty truthyProperty = DiagnosticsProperty( 'name', true, description: 'truthy', @@ -761,14 +761,14 @@ void main() { ); validatePropertyJsonSerialization(truthyProperty); expect( - new DiagnosticsProperty('name', true, showName: false).toString(), + DiagnosticsProperty('name', true, showName: false).toString(), equals('true'), ); - expect(new DiagnosticsProperty('name', null).isFiltered(DiagnosticLevel.info), isFalse); - expect(new DiagnosticsProperty('name', true, level: DiagnosticLevel.hidden).isFiltered(DiagnosticLevel.info), isTrue); - expect(new DiagnosticsProperty('name', null, defaultValue: null).isFiltered(DiagnosticLevel.info), isTrue); - final DiagnosticsProperty missingBool = new DiagnosticsProperty('name', null, ifNull: 'missing'); + expect(DiagnosticsProperty('name', null).isFiltered(DiagnosticLevel.info), isFalse); + expect(DiagnosticsProperty('name', true, level: DiagnosticLevel.hidden).isFiltered(DiagnosticLevel.info), isTrue); + expect(DiagnosticsProperty('name', null, defaultValue: null).isFiltered(DiagnosticLevel.info), isTrue); + final DiagnosticsProperty missingBool = DiagnosticsProperty('name', null, ifNull: 'missing'); expect( missingBool.toString(), equals('name: missing'), @@ -777,12 +777,12 @@ void main() { }); test('flag property test', () { - final FlagProperty trueFlag = new FlagProperty( + final FlagProperty trueFlag = FlagProperty( 'myFlag', value: true, ifTrue: 'myFlag', ); - final FlagProperty falseFlag = new FlagProperty( + final FlagProperty falseFlag = FlagProperty( 'myFlag', value: false, ifTrue: 'myFlag', @@ -799,7 +799,7 @@ void main() { }); test('property with tooltip test', () { - final DiagnosticsProperty withTooltip = new DiagnosticsProperty( + final DiagnosticsProperty withTooltip = DiagnosticsProperty( 'name', 'value', tooltip: 'tooltip', @@ -814,7 +814,7 @@ void main() { }); test('double property test', () { - final DoubleProperty doubleProperty = new DoubleProperty( + final DoubleProperty doubleProperty = DoubleProperty( 'name', 42.0, ); @@ -823,24 +823,24 @@ void main() { expect(doubleProperty.value, equals(42.0)); validateDoublePropertyJsonSerialization(doubleProperty); - expect(new DoubleProperty('name', 1.3333).toString(), equals('name: 1.3')); + expect(DoubleProperty('name', 1.3333).toString(), equals('name: 1.3')); - expect(new DoubleProperty('name', null).toString(), equals('name: null')); - expect(new DoubleProperty('name', null).isFiltered(DiagnosticLevel.info), equals(false)); + expect(DoubleProperty('name', null).toString(), equals('name: null')); + expect(DoubleProperty('name', null).isFiltered(DiagnosticLevel.info), equals(false)); expect( - new DoubleProperty('name', null, ifNull: 'missing').toString(), + DoubleProperty('name', null, ifNull: 'missing').toString(), equals('name: missing'), ); - final DoubleProperty doubleWithUnit = new DoubleProperty('name', 42.0, unit: 'px'); + final DoubleProperty doubleWithUnit = DoubleProperty('name', 42.0, unit: 'px'); expect(doubleWithUnit.toString(), equals('name: 42.0px')); validateDoublePropertyJsonSerialization(doubleWithUnit); }); test('unsafe double property test', () { - final DoubleProperty safe = new DoubleProperty.lazy( + final DoubleProperty safe = DoubleProperty.lazy( 'name', () => 42.0, ); @@ -849,22 +849,22 @@ void main() { expect(safe.value, equals(42.0)); validateDoublePropertyJsonSerialization(safe); expect( - new DoubleProperty.lazy('name', () => 1.3333).toString(), + DoubleProperty.lazy('name', () => 1.3333).toString(), equals('name: 1.3'), ); expect( - new DoubleProperty.lazy('name', () => null).toString(), + DoubleProperty.lazy('name', () => null).toString(), equals('name: null'), ); expect( - new DoubleProperty.lazy('name', () => null).isFiltered(DiagnosticLevel.info), + DoubleProperty.lazy('name', () => null).isFiltered(DiagnosticLevel.info), equals(false), ); - final DoubleProperty throwingProperty = new DoubleProperty.lazy( + final DoubleProperty throwingProperty = DoubleProperty.lazy( 'name', - () => throw new FlutterError('Invalid constraints'), + () => throw FlutterError('Invalid constraints'), ); // TODO(jacobr): it would be better if throwingProperty.object threw an // exception. @@ -880,11 +880,11 @@ void main() { test('percent property', () { expect( - new PercentProperty('name', 0.4).toString(), + PercentProperty('name', 0.4).toString(), equals('name: 40.0%'), ); - final PercentProperty complexPercentProperty = new PercentProperty('name', 0.99, unit: 'invisible', tooltip: 'almost transparent'); + final PercentProperty complexPercentProperty = PercentProperty('name', 0.99, unit: 'invisible', tooltip: 'almost transparent'); expect( complexPercentProperty.toString(), equals('name: 99.0% invisible (almost transparent)'), @@ -892,36 +892,36 @@ void main() { validateDoublePropertyJsonSerialization(complexPercentProperty); expect( - new PercentProperty('name', null, unit: 'invisible', tooltip: '!').toString(), + PercentProperty('name', null, unit: 'invisible', tooltip: '!').toString(), equals('name: null (!)'), ); expect( - new PercentProperty('name', 0.4).value, + PercentProperty('name', 0.4).value, 0.4, ); expect( - new PercentProperty('name', 0.0).toString(), + PercentProperty('name', 0.0).toString(), equals('name: 0.0%'), ); expect( - new PercentProperty('name', -10.0).toString(), + PercentProperty('name', -10.0).toString(), equals('name: 0.0%'), ); expect( - new PercentProperty('name', 1.0).toString(), + PercentProperty('name', 1.0).toString(), equals('name: 100.0%'), ); expect( - new PercentProperty('name', 3.0).toString(), + PercentProperty('name', 3.0).toString(), equals('name: 100.0%'), ); expect( - new PercentProperty('name', null).toString(), + PercentProperty('name', null).toString(), equals('name: null'), ); expect( - new PercentProperty( + PercentProperty( 'name', null, ifNull: 'missing', @@ -929,7 +929,7 @@ void main() { equals('name: missing'), ); expect( - new PercentProperty( + PercentProperty( 'name', null, ifNull: 'missing', @@ -938,7 +938,7 @@ void main() { equals('missing'), ); expect( - new PercentProperty( + PercentProperty( 'name', 0.5, showName: false, @@ -949,12 +949,12 @@ void main() { test('callback property test', () { final Function onClick = () {}; - final ObjectFlagProperty present = new ObjectFlagProperty( + final ObjectFlagProperty present = ObjectFlagProperty( 'onClick', onClick, ifPresent: 'clickable', ); - final ObjectFlagProperty missing = new ObjectFlagProperty( + final ObjectFlagProperty missing = ObjectFlagProperty( 'onClick', null, ifPresent: 'clickable', @@ -972,12 +972,12 @@ void main() { test('missing callback property test', () { void onClick() { } - final ObjectFlagProperty present = new ObjectFlagProperty( + final ObjectFlagProperty present = ObjectFlagProperty( 'onClick', onClick, ifNull: 'disabled', ); - final ObjectFlagProperty missing = new ObjectFlagProperty( + final ObjectFlagProperty missing = ObjectFlagProperty( 'onClick', null, ifNull: 'disabled', @@ -993,14 +993,14 @@ void main() { }); test('describe bool property', () { - final FlagProperty yes = new FlagProperty( + final FlagProperty yes = FlagProperty( 'name', value: true, ifTrue: 'YES', ifFalse: 'NO', showName: true, ); - final FlagProperty no = new FlagProperty( + final FlagProperty no = FlagProperty( 'name', value: false, ifTrue: 'YES', @@ -1017,7 +1017,7 @@ void main() { validateFlagPropertyJsonSerialization(no); expect( - new FlagProperty( + FlagProperty( 'name', value: true, ifTrue: 'YES', @@ -1027,7 +1027,7 @@ void main() { ); expect( - new FlagProperty( + FlagProperty( 'name', value: false, ifTrue: 'YES', @@ -1037,7 +1037,7 @@ void main() { ); expect( - new FlagProperty( + FlagProperty( 'name', value: true, ifTrue: 'YES', @@ -1050,19 +1050,19 @@ void main() { }); test('enum property test', () { - final EnumProperty hello = new EnumProperty( + final EnumProperty hello = EnumProperty( 'name', ExampleEnum.hello, ); - final EnumProperty world = new EnumProperty( + final EnumProperty world = EnumProperty( 'name', ExampleEnum.world, ); - final EnumProperty deferToChild = new EnumProperty( + final EnumProperty deferToChild = EnumProperty( 'name', ExampleEnum.deferToChild, ); - final EnumProperty nullEnum = new EnumProperty( + final EnumProperty nullEnum = EnumProperty( 'name', null, ); @@ -1086,7 +1086,7 @@ void main() { expect(nullEnum.toString(), equals('name: null')); validatePropertyJsonSerialization(nullEnum); - final EnumProperty matchesDefault = new EnumProperty( + final EnumProperty matchesDefault = EnumProperty( 'name', ExampleEnum.hello, defaultValue: ExampleEnum.hello, @@ -1097,7 +1097,7 @@ void main() { validatePropertyJsonSerialization(matchesDefault); expect( - new EnumProperty( + EnumProperty( 'name', ExampleEnum.hello, level: DiagnosticLevel.hidden, @@ -1107,7 +1107,7 @@ void main() { }); test('int property test', () { - final IntProperty regular = new IntProperty( + final IntProperty regular = IntProperty( 'name', 42, ); @@ -1115,7 +1115,7 @@ void main() { expect(regular.value, equals(42)); expect(regular.level, equals(DiagnosticLevel.info)); - final IntProperty nullValue = new IntProperty( + final IntProperty nullValue = IntProperty( 'name', null, ); @@ -1123,7 +1123,7 @@ void main() { expect(nullValue.value, isNull); expect(nullValue.level, equals(DiagnosticLevel.info)); - final IntProperty hideNull = new IntProperty( + final IntProperty hideNull = IntProperty( 'name', null, defaultValue: null, @@ -1132,7 +1132,7 @@ void main() { expect(hideNull.value, isNull); expect(hideNull.isFiltered(DiagnosticLevel.info), isTrue); - final IntProperty nullDescription = new IntProperty( + final IntProperty nullDescription = IntProperty( 'name', null, ifNull: 'missing', @@ -1141,7 +1141,7 @@ void main() { expect(nullDescription.value, isNull); expect(nullDescription.level, equals(DiagnosticLevel.info)); - final IntProperty hideName = new IntProperty( + final IntProperty hideName = IntProperty( 'name', 42, showName: false, @@ -1150,7 +1150,7 @@ void main() { expect(hideName.value, equals(42)); expect(hideName.level, equals(DiagnosticLevel.info)); - final IntProperty withUnit = new IntProperty( + final IntProperty withUnit = IntProperty( 'name', 42, unit: 'pt', @@ -1159,7 +1159,7 @@ void main() { expect(withUnit.value, equals(42)); expect(withUnit.level, equals(DiagnosticLevel.info)); - final IntProperty defaultValue = new IntProperty( + final IntProperty defaultValue = IntProperty( 'name', 42, defaultValue: 42, @@ -1168,7 +1168,7 @@ void main() { expect(defaultValue.value, equals(42)); expect(defaultValue.isFiltered(DiagnosticLevel.info), isTrue); - final IntProperty notDefaultValue = new IntProperty( + final IntProperty notDefaultValue = IntProperty( 'name', 43, defaultValue: 42, @@ -1177,7 +1177,7 @@ void main() { expect(notDefaultValue.value, equals(43)); expect(notDefaultValue.level, equals(DiagnosticLevel.info)); - final IntProperty hidden = new IntProperty( + final IntProperty hidden = IntProperty( 'name', 42, level: DiagnosticLevel.hidden, @@ -1188,8 +1188,8 @@ void main() { }); test('object property test', () { - final Rect rect = new Rect.fromLTRB(0.0, 0.0, 20.0, 20.0); - final DiagnosticsNode simple = new DiagnosticsProperty( + final Rect rect = Rect.fromLTRB(0.0, 0.0, 20.0, 20.0); + final DiagnosticsNode simple = DiagnosticsProperty( 'name', rect, ); @@ -1198,7 +1198,7 @@ void main() { expect(simple.toString(), equals('name: Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)')); validatePropertyJsonSerialization(simple); - final DiagnosticsNode withDescription = new DiagnosticsProperty( + final DiagnosticsNode withDescription = DiagnosticsProperty( 'name', rect, description: 'small rect', @@ -1208,7 +1208,7 @@ void main() { expect(withDescription.toString(), equals('name: small rect')); validatePropertyJsonSerialization(withDescription); - final DiagnosticsProperty nullProperty = new DiagnosticsProperty( + final DiagnosticsProperty nullProperty = DiagnosticsProperty( 'name', null, ); @@ -1217,7 +1217,7 @@ void main() { expect(nullProperty.toString(), equals('name: null')); validatePropertyJsonSerialization(nullProperty); - final DiagnosticsProperty hideNullProperty = new DiagnosticsProperty( + final DiagnosticsProperty hideNullProperty = DiagnosticsProperty( 'name', null, defaultValue: null, @@ -1227,7 +1227,7 @@ void main() { expect(hideNullProperty.toString(), equals('name: null')); validatePropertyJsonSerialization(hideNullProperty); - final DiagnosticsNode nullDescription = new DiagnosticsProperty( + final DiagnosticsNode nullDescription = DiagnosticsProperty( 'name', null, ifNull: 'missing', @@ -1237,7 +1237,7 @@ void main() { expect(nullDescription.toString(), equals('name: missing')); validatePropertyJsonSerialization(nullDescription); - final DiagnosticsProperty hideName = new DiagnosticsProperty( + final DiagnosticsProperty hideName = DiagnosticsProperty( 'name', rect, showName: false, @@ -1248,7 +1248,7 @@ void main() { expect(hideName.toString(), equals('Rect.fromLTRB(0.0, 0.0, 20.0, 20.0)')); validatePropertyJsonSerialization(hideName); - final DiagnosticsProperty hideSeparator = new DiagnosticsProperty( + final DiagnosticsProperty hideSeparator = DiagnosticsProperty( 'Creator', rect, showSeparator: false, @@ -1263,8 +1263,8 @@ void main() { }); test('lazy object property test', () { - final Rect rect = new Rect.fromLTRB(0.0, 0.0, 20.0, 20.0); - final DiagnosticsNode simple = new DiagnosticsProperty.lazy( + final Rect rect = Rect.fromLTRB(0.0, 0.0, 20.0, 20.0); + final DiagnosticsNode simple = DiagnosticsProperty.lazy( 'name', () => rect, description: 'small rect', @@ -1274,7 +1274,7 @@ void main() { expect(simple.toString(), equals('name: small rect')); validatePropertyJsonSerialization(simple); - final DiagnosticsProperty nullProperty = new DiagnosticsProperty.lazy( + final DiagnosticsProperty nullProperty = DiagnosticsProperty.lazy( 'name', () => null, description: 'missing', @@ -1284,7 +1284,7 @@ void main() { expect(nullProperty.toString(), equals('name: missing')); validatePropertyJsonSerialization(nullProperty); - final DiagnosticsNode hideNullProperty = new DiagnosticsProperty.lazy( + final DiagnosticsNode hideNullProperty = DiagnosticsProperty.lazy( 'name', () => null, description: 'missing', @@ -1295,7 +1295,7 @@ void main() { expect(hideNullProperty.toString(), equals('name: missing')); validatePropertyJsonSerialization(hideNullProperty); - final DiagnosticsNode hideName = new DiagnosticsProperty.lazy( + final DiagnosticsNode hideName = DiagnosticsProperty.lazy( 'name', () => rect, description: 'small rect', @@ -1306,9 +1306,9 @@ void main() { expect(hideName.toString(), equals('small rect')); validatePropertyJsonSerialization(hideName); - final DiagnosticsProperty throwingWithDescription = new DiagnosticsProperty.lazy( + final DiagnosticsProperty throwingWithDescription = DiagnosticsProperty.lazy( 'name', - () => throw new FlutterError('Property not available'), + () => throw FlutterError('Property not available'), description: 'missing', defaultValue: null, ); @@ -1318,9 +1318,9 @@ void main() { expect(throwingWithDescription.toString(), equals('name: missing')); validatePropertyJsonSerialization(throwingWithDescription); - final DiagnosticsProperty throwingProperty = new DiagnosticsProperty.lazy( + final DiagnosticsProperty throwingProperty = DiagnosticsProperty.lazy( 'name', - () => throw new FlutterError('Property not available'), + () => throw FlutterError('Property not available'), defaultValue: null, ); expect(throwingProperty.value, isNull); @@ -1334,7 +1334,7 @@ void main() { // Add more tests if colorProperty becomes more than a wrapper around // objectProperty. const Color color = Color.fromARGB(255, 255, 255, 255); - final DiagnosticsProperty simple = new DiagnosticsProperty( + final DiagnosticsProperty simple = DiagnosticsProperty( 'name', color, ); @@ -1347,7 +1347,7 @@ void main() { }); test('flag property test', () { - final FlagProperty show = new FlagProperty( + final FlagProperty show = FlagProperty( 'wasLayout', value: true, ifTrue: 'layout computed', @@ -1358,7 +1358,7 @@ void main() { expect(show.toString(), equals('layout computed')); validateFlagPropertyJsonSerialization(show); - final FlagProperty hide = new FlagProperty( + final FlagProperty hide = FlagProperty( 'wasLayout', value: false, ifTrue: 'layout computed', @@ -1369,7 +1369,7 @@ void main() { expect(hide.toString(), equals('wasLayout: false')); validateFlagPropertyJsonSerialization(hide); - final FlagProperty hideTrue = new FlagProperty( + final FlagProperty hideTrue = FlagProperty( 'wasLayout', value: true, ifFalse: 'no layout computed', @@ -1383,7 +1383,7 @@ void main() { test('has property test', () { final Function onClick = () {}; - final ObjectFlagProperty has = new ObjectFlagProperty.has( + final ObjectFlagProperty has = ObjectFlagProperty.has( 'onClick', onClick, ); @@ -1393,7 +1393,7 @@ void main() { expect(has.toString(), equals('has onClick')); validateObjectFlagPropertyJsonSerialization(has); - final ObjectFlagProperty missing = new ObjectFlagProperty.has( + final ObjectFlagProperty missing = ObjectFlagProperty.has( 'onClick', null, ); @@ -1406,7 +1406,7 @@ void main() { test('iterable property test', () { final List ints = [1,2,3]; - final IterableProperty intsProperty = new IterableProperty( + final IterableProperty intsProperty = IterableProperty( 'ints', ints, ); @@ -1414,7 +1414,7 @@ void main() { expect(intsProperty.isFiltered(DiagnosticLevel.info), isFalse); expect(intsProperty.toString(), equals('ints: 1, 2, 3')); - final IterableProperty emptyProperty = new IterableProperty( + final IterableProperty emptyProperty = IterableProperty( 'name', [], ); @@ -1423,7 +1423,7 @@ void main() { expect(emptyProperty.toString(), equals('name: []')); validateIterablePropertyJsonSerialization(emptyProperty); - final IterableProperty nullProperty = new IterableProperty( + final IterableProperty nullProperty = IterableProperty( 'list', null, ); @@ -1432,7 +1432,7 @@ void main() { expect(nullProperty.toString(), equals('list: null')); validateIterablePropertyJsonSerialization(nullProperty); - final IterableProperty hideNullProperty = new IterableProperty( + final IterableProperty hideNullProperty = IterableProperty( 'list', null, defaultValue: null, @@ -1444,10 +1444,10 @@ void main() { validateIterablePropertyJsonSerialization(hideNullProperty); final List objects = [ - new Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), + Rect.fromLTRB(0.0, 0.0, 20.0, 20.0), const Color.fromARGB(255, 255, 255, 255), ]; - final IterableProperty objectsProperty = new IterableProperty( + final IterableProperty objectsProperty = IterableProperty( 'objects', objects, ); @@ -1459,7 +1459,7 @@ void main() { ); validateIterablePropertyJsonSerialization(objectsProperty); - final IterableProperty multiLineProperty = new IterableProperty( + final IterableProperty multiLineProperty = IterableProperty( 'objects', objects, style: DiagnosticsTreeStyle.whitespace, @@ -1485,7 +1485,7 @@ void main() { validateIterablePropertyJsonSerialization(multiLineProperty); expect( - new TestTree( + TestTree( properties: [multiLineProperty], ).toStringDeep(), equalsIgnoringHashCodes( @@ -1497,8 +1497,8 @@ void main() { ); expect( - new TestTree( - properties: [objectsProperty, new IntProperty('foo', 42)], + TestTree( + properties: [objectsProperty, IntProperty('foo', 42)], style: DiagnosticsTreeStyle.singleLine, ).toStringDeep(), equalsIgnoringHashCodes( @@ -1510,7 +1510,7 @@ void main() { // multi line rendering isn't used even though it is not helpful. final List singleElementList = [const Color.fromARGB(255, 255, 255, 255)]; - final IterableProperty objectProperty = new IterableProperty( + final IterableProperty objectProperty = IterableProperty( 'object', singleElementList, style: DiagnosticsTreeStyle.whitespace, @@ -1527,7 +1527,7 @@ void main() { ); validateIterablePropertyJsonSerialization(objectProperty); expect( - new TestTree( + TestTree( name: 'root', properties: [objectProperty], ).toStringDeep(), @@ -1539,14 +1539,14 @@ void main() { }); test('message test', () { - final DiagnosticsNode message = new DiagnosticsNode.message('hello world'); + final DiagnosticsNode message = DiagnosticsNode.message('hello world'); expect(message.toString(), equals('hello world')); expect(message.name, isEmpty); expect(message.value, isNull); expect(message.showName, isFalse); validateNodeJsonSerialization(message); - final DiagnosticsNode messageProperty = new MessageProperty('diagnostics', 'hello world'); + final DiagnosticsNode messageProperty = MessageProperty('diagnostics', 'hello world'); expect(messageProperty.toString(), equals('diagnostics: hello world')); expect(messageProperty.name, equals('diagnostics')); expect(messageProperty.value, isNull); diff --git a/packages/flutter/test/foundation/error_reporting_test.dart b/packages/flutter/test/foundation/error_reporting_test.dart index dabc49cd12..28dab80b2e 100644 --- a/packages/flutter/test/foundation/error_reporting_test.dart +++ b/packages/flutter/test/foundation/error_reporting_test.dart @@ -35,7 +35,7 @@ dynamic getAssertionErrorWithLongMessage() { } Future getSampleStack() async { - return await new Future.sync(() => StackTrace.current); + return await Future.sync(() => StackTrace.current); } Future main() async { @@ -52,7 +52,7 @@ Future main() async { test('Error reporting - assert with message', () async { expect(console, isEmpty); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: getAssertionErrorWithMessage(), stack: sampleStack, library: 'error handling test', @@ -86,7 +86,7 @@ Future main() async { '════════════════════════════════════════════════════════════════════════════════════════════════════\$', )); console.clear(); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: getAssertionErrorWithMessage(), )); expect(console.join('\n'), 'Another exception was thrown: Message goes here.'); @@ -96,7 +96,7 @@ Future main() async { test('Error reporting - assert with long message', () async { expect(console, isEmpty); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: getAssertionErrorWithLongMessage(), )); expect(console.join('\n'), matches( @@ -116,7 +116,7 @@ Future main() async { '════════════════════════════════════════════════════════════════════════════════════════════════════\$', )); console.clear(); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: getAssertionErrorWithLongMessage(), )); expect( @@ -134,7 +134,7 @@ Future main() async { test('Error reporting - assert with no message', () async { expect(console, isEmpty); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: getAssertionErrorWithoutMessage(), stack: sampleStack, library: 'error handling test', @@ -167,7 +167,7 @@ Future main() async { '════════════════════════════════════════════════════════════════════════════════════════════════════\$', )); console.clear(); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: getAssertionErrorWithoutMessage(), )); expect(console.join('\n'), matches('Another exception was thrown: \'[^\']+flutter/test/foundation/error_reporting_test\\.dart\': Failed assertion: line [0-9]+ pos [0-9]+: \'false\': is not true\\.')); @@ -177,8 +177,8 @@ Future main() async { test('Error reporting - NoSuchMethodError', () async { expect(console, isEmpty); - final dynamic exception = new NoSuchMethodError(5, #foo, [2, 4], null); // ignore: deprecated_member_use - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + final dynamic exception = NoSuchMethodError(5, #foo, [2, 4], null); // ignore: deprecated_member_use + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: exception, )); expect(console.join('\n'), matches( @@ -189,7 +189,7 @@ Future main() async { '════════════════════════════════════════════════════════════════════════════════════════════════════\$', )); console.clear(); - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: exception, )); expect(console.join('\n'), 'Another exception was thrown: NoSuchMethodError: Receiver: 5'); diff --git a/packages/flutter/test/foundation/print_test.dart b/packages/flutter/test/foundation/print_test.dart index c56135df9e..5813448296 100644 --- a/packages/flutter/test/foundation/print_test.dart +++ b/packages/flutter/test/foundation/print_test.dart @@ -39,7 +39,7 @@ void main() { }); test('debugPrint throttling', () { - new FakeAsync().run((FakeAsync async) { + FakeAsync().run((FakeAsync async) { List log = captureOutput(() { debugPrintThrottled('A' * (22 * 1024) + '\nB'); }); diff --git a/packages/flutter/test/foundation/reassemble_test.dart b/packages/flutter/test/foundation/reassemble_test.dart index 6c4ec7ea6d..f686ba34f6 100644 --- a/packages/flutter/test/foundation/reassemble_test.dart +++ b/packages/flutter/test/foundation/reassemble_test.dart @@ -17,10 +17,10 @@ class TestFoundationFlutterBinding extends BindingBase { } } -TestFoundationFlutterBinding binding = new TestFoundationFlutterBinding(); +TestFoundationFlutterBinding binding = TestFoundationFlutterBinding(); void main() { - binding ??= new TestFoundationFlutterBinding(); + binding ??= TestFoundationFlutterBinding(); test('Pointer events are locked during reassemble', () async { await binding.reassembleApplication(); diff --git a/packages/flutter/test/foundation/serialization_test.dart b/packages/flutter/test/foundation/serialization_test.dart index 73f9809fde..1510d20923 100644 --- a/packages/flutter/test/foundation/serialization_test.dart +++ b/packages/flutter/test/foundation/serialization_test.dart @@ -10,67 +10,67 @@ import '../flutter_test_alternative.dart'; void main() { group('Write and read buffer round-trip', () { test('of single byte', () { - final WriteBuffer write = new WriteBuffer(); + final WriteBuffer write = WriteBuffer(); write.putUint8(201); final ByteData written = write.done(); expect(written.lengthInBytes, equals(1)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); expect(read.getUint8(), equals(201)); }); test('of 32-bit integer', () { - final WriteBuffer write = new WriteBuffer(); + final WriteBuffer write = WriteBuffer(); write.putInt32(-9); final ByteData written = write.done(); expect(written.lengthInBytes, equals(4)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); expect(read.getInt32(), equals(-9)); }); test('of 64-bit integer', () { - final WriteBuffer write = new WriteBuffer(); + final WriteBuffer write = WriteBuffer(); write.putInt64(-9000000000000); final ByteData written = write.done(); expect(written.lengthInBytes, equals(8)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); expect(read.getInt64(), equals(-9000000000000)); }); test('of double', () { - final WriteBuffer write = new WriteBuffer(); + final WriteBuffer write = WriteBuffer(); write.putFloat64(3.14); final ByteData written = write.done(); expect(written.lengthInBytes, equals(8)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); expect(read.getFloat64(), equals(3.14)); }); test('of 32-bit int list when unaligned', () { - final Int32List integers = new Int32List.fromList([-99, 2, 99]); - final WriteBuffer write = new WriteBuffer(); + final Int32List integers = Int32List.fromList([-99, 2, 99]); + final WriteBuffer write = WriteBuffer(); write.putUint8(9); write.putInt32List(integers); final ByteData written = write.done(); expect(written.lengthInBytes, equals(16)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); read.getUint8(); expect(read.getInt32List(3), equals(integers)); }); test('of 64-bit int list when unaligned', () { - final Int64List integers = new Int64List.fromList([-99, 2, 99]); - final WriteBuffer write = new WriteBuffer(); + final Int64List integers = Int64List.fromList([-99, 2, 99]); + final WriteBuffer write = WriteBuffer(); write.putUint8(9); write.putInt64List(integers); final ByteData written = write.done(); expect(written.lengthInBytes, equals(32)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); read.getUint8(); expect(read.getInt64List(3), equals(integers)); }); test('of double list when unaligned', () { - final Float64List doubles = new Float64List.fromList([3.14, double.nan]); - final WriteBuffer write = new WriteBuffer(); + final Float64List doubles = Float64List.fromList([3.14, double.nan]); + final WriteBuffer write = WriteBuffer(); write.putUint8(9); write.putFloat64List(doubles); final ByteData written = write.done(); expect(written.lengthInBytes, equals(24)); - final ReadBuffer read = new ReadBuffer(written); + final ReadBuffer read = ReadBuffer(written); read.getUint8(); final Float64List readDoubles = read.getFloat64List(2); expect(readDoubles[0], equals(3.14)); diff --git a/packages/flutter/test/foundation/service_extensions_test.dart b/packages/flutter/test/foundation/service_extensions_test.dart index ee38039a63..6fcb04f0ed 100644 --- a/packages/flutter/test/foundation/service_extensions_test.dart +++ b/packages/flutter/test/foundation/service_extensions_test.dart @@ -75,7 +75,7 @@ class TestServiceExtensionsBinding extends BindingBase } Future flushMicrotasks() { - final Completer completer = new Completer(); + final Completer completer = Completer(); Timer.run(completer.complete); return completer.future; } @@ -102,7 +102,7 @@ void main() { final List console = []; test('Service extensions - pretest', () async { - binding = new TestServiceExtensionsBinding(); + binding = TestServiceExtensionsBinding(); expect(binding.frameScheduled, isTrue); await binding.doFrame(); // initial frame scheduled by creating the binding expect(binding.frameScheduled, isFalse); @@ -306,7 +306,7 @@ void main() { BinaryMessages.setMockMessageHandler('flutter/assets', (ByteData message) async { expect(utf8.decode(message.buffer.asUint8List()), 'test'); completed = true; - return new ByteData(5); // 0x0000000000 + return ByteData(5); // 0x0000000000 }); bool data; data = await rootBundle.loadStructuredData('test', (String value) async { expect(value, '\x00\x00\x00\x00\x00'); return true; }); diff --git a/packages/flutter/test/foundation/synchronous_future_test.dart b/packages/flutter/test/foundation/synchronous_future_test.dart index 73199ba23e..a768a21914 100644 --- a/packages/flutter/test/foundation/synchronous_future_test.dart +++ b/packages/flutter/test/foundation/synchronous_future_test.dart @@ -9,7 +9,7 @@ import '../flutter_test_alternative.dart'; void main() { test('SynchronousFuture control test', () async { - final Future future = new SynchronousFuture(42); + final Future future = SynchronousFuture(42); int result; future.then((int value) { result = value; }); @@ -31,7 +31,7 @@ void main() { bool ranAction = false; final Future completeResult = future.whenComplete(() { ranAction = true; - return new Future.value(31); + return Future.value(31); }); expect(ranAction, isTrue); diff --git a/packages/flutter/test/gestures/arena_test.dart b/packages/flutter/test/gestures/arena_test.dart index 437a1f12ce..160b77bcb5 100644 --- a/packages/flutter/test/gestures/arena_test.dart +++ b/packages/flutter/test/gestures/arena_test.dart @@ -28,9 +28,9 @@ class TestGestureArenaMember extends GestureArenaMember { } class GestureTester { - GestureArenaManager arena = new GestureArenaManager(); - TestGestureArenaMember first = new TestGestureArenaMember(); - TestGestureArenaMember second = new TestGestureArenaMember(); + GestureArenaManager arena = GestureArenaManager(); + TestGestureArenaMember first = TestGestureArenaMember(); + TestGestureArenaMember second = TestGestureArenaMember(); GestureArenaEntry firstEntry; void addFirst() { @@ -66,7 +66,7 @@ class GestureTester { void main() { test('Should win by accepting', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.arena.close(primaryKey); @@ -76,7 +76,7 @@ void main() { }); test('Should win by sweep', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.arena.close(primaryKey); @@ -86,7 +86,7 @@ void main() { }); test('Should win on release after hold sweep release', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.arena.close(primaryKey); @@ -100,7 +100,7 @@ void main() { }); test('Should win on sweep after hold release sweep', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.arena.close(primaryKey); @@ -114,7 +114,7 @@ void main() { }); test('Only first winner should win', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.arena.close(primaryKey); @@ -125,7 +125,7 @@ void main() { }); test('Only first winner should win, regardless of order', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.arena.close(primaryKey); @@ -136,7 +136,7 @@ void main() { }); test('Win before close is delayed to close', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.expectNothing(); @@ -147,7 +147,7 @@ void main() { }); test('Win before close is delayed to close, and only first winner should win', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.expectNothing(); @@ -159,7 +159,7 @@ void main() { }); test('Win before close is delayed to close, and only first winner should win, regardless of order', () { - final GestureTester tester = new GestureTester(); + final GestureTester tester = GestureTester(); tester.addFirst(); tester.addSecond(); tester.expectNothing(); diff --git a/packages/flutter/test/gestures/debug_test.dart b/packages/flutter/test/gestures/debug_test.dart index 2f0ab53c21..1a323758c5 100644 --- a/packages/flutter/test/gestures/debug_test.dart +++ b/packages/flutter/test/gestures/debug_test.dart @@ -14,7 +14,7 @@ void main() { final List log = []; debugPrint = (String s, { int wrapWidth }) { log.add(s); }; - final TapGestureRecognizer tap = new TapGestureRecognizer() + final TapGestureRecognizer tap = TapGestureRecognizer() ..onTapDown = (TapDownDetails details) { } ..onTapUp = (TapUpDetails details) { } ..onTap = () { } @@ -60,7 +60,7 @@ void main() { final List log = []; debugPrint = (String s, { int wrapWidth }) { log.add(s); }; - final TapGestureRecognizer tap = new TapGestureRecognizer() + final TapGestureRecognizer tap = TapGestureRecognizer() ..onTapDown = (TapDownDetails details) { } ..onTapUp = (TapUpDetails details) { } ..onTap = () { } @@ -103,7 +103,7 @@ void main() { final List log = []; debugPrint = (String s, { int wrapWidth }) { log.add(s); }; - final TapGestureRecognizer tap = new TapGestureRecognizer() + final TapGestureRecognizer tap = TapGestureRecognizer() ..onTapDown = (TapDownDetails details) { } ..onTapUp = (TapUpDetails details) { } ..onTap = () { } @@ -147,7 +147,7 @@ void main() { }); test('TapGestureRecognizer _sentTapDown toString', () { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); expect(tap.toString(), equalsIgnoringHashCodes('TapGestureRecognizer#00000(state: ready)')); const PointerEvent event = PointerDownEvent(pointer: 1, position: Offset(10.0, 10.0)); tap.addPointer(event); diff --git a/packages/flutter/test/gestures/double_tap_test.dart b/packages/flutter/test/gestures/double_tap_test.dart index 8f6a0193ce..43ca2b9469 100644 --- a/packages/flutter/test/gestures/double_tap_test.dart +++ b/packages/flutter/test/gestures/double_tap_test.dart @@ -87,7 +87,7 @@ void main() { ); testGesture('Should recognize double tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -120,7 +120,7 @@ void main() { }); testGesture('Inter-tap distance cancels double tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -153,7 +153,7 @@ void main() { }); testGesture('Intra-tap distance cancels double tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -188,7 +188,7 @@ void main() { }); testGesture('Inter-tap delay cancels double tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -222,7 +222,7 @@ void main() { }); testGesture('Inter-tap delay resets double tap, allowing third tap to be a double-tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -268,7 +268,7 @@ void main() { }); testGesture('Intra-tap delay does not cancel double tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -302,7 +302,7 @@ void main() { }); testGesture('Should not recognize two overlapping taps', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -335,7 +335,7 @@ void main() { }); testGesture('Should recognize one tap of group followed by second tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -380,7 +380,7 @@ void main() { }); testGesture('Should cancel on arena reject during first tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -388,7 +388,7 @@ void main() { }; tap.addPointer(down1); - final TestGestureArenaMember member = new TestGestureArenaMember(); + final TestGestureArenaMember member = TestGestureArenaMember(); final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member); tester.closeArena(1); expect(doubleTapRecognized, isFalse); @@ -418,7 +418,7 @@ void main() { }); testGesture('Should cancel on arena reject between taps', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -426,7 +426,7 @@ void main() { }; tap.addPointer(down1); - final TestGestureArenaMember member = new TestGestureArenaMember(); + final TestGestureArenaMember member = TestGestureArenaMember(); final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member); tester.closeArena(1); expect(doubleTapRecognized, isFalse); @@ -456,7 +456,7 @@ void main() { }); testGesture('Should cancel on arena reject during last tap', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { @@ -464,7 +464,7 @@ void main() { }; tap.addPointer(down1); - final TestGestureArenaMember member = new TestGestureArenaMember(); + final TestGestureArenaMember member = TestGestureArenaMember(); final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member); tester.closeArena(1); expect(doubleTapRecognized, isFalse); @@ -494,16 +494,16 @@ void main() { }); testGesture('Passive gesture should trigger on double tap cancel', (GestureTester tester) { - final DoubleTapGestureRecognizer tap = new DoubleTapGestureRecognizer(); + final DoubleTapGestureRecognizer tap = DoubleTapGestureRecognizer(); bool doubleTapRecognized = false; tap.onDoubleTap = () { doubleTapRecognized = true; }; - new FakeAsync().run((FakeAsync async) { + FakeAsync().run((FakeAsync async) { tap.addPointer(down1); - final TestGestureArenaMember member = new TestGestureArenaMember(); + final TestGestureArenaMember member = TestGestureArenaMember(); GestureBinding.instance.gestureArena.add(1, member); tester.closeArena(1); expect(doubleTapRecognized, isFalse); diff --git a/packages/flutter/test/gestures/drag_test.dart b/packages/flutter/test/gestures/drag_test.dart index 484a8eaaf9..4d9946669b 100644 --- a/packages/flutter/test/gestures/drag_test.dart +++ b/packages/flutter/test/gestures/drag_test.dart @@ -12,8 +12,8 @@ void main() { setUp(ensureGestureBinding); testGesture('Should recognize pan', (GestureTester tester) { - final PanGestureRecognizer pan = new PanGestureRecognizer(); - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final PanGestureRecognizer pan = PanGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool didStartPan = false; pan.onStart = (_) { @@ -35,7 +35,7 @@ void main() { didTap = true; }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0)); pan.addPointer(down); tap.addPointer(down); @@ -82,7 +82,7 @@ void main() { }); testGesture('Should recognize drag', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); bool didStartDrag = false; drag.onStart = (_) { @@ -99,7 +99,7 @@ void main() { didEndDrag = true; }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0)); drag.addPointer(down); tester.closeArena(5); @@ -135,7 +135,7 @@ void main() { }); testGesture('Should report original timestamps', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); Duration startTimestamp; drag.onStart = (DragStartDetails details) { @@ -147,7 +147,7 @@ void main() { updatedTimestamp = details.sourceTimeStamp; }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0), timeStamp: const Duration(milliseconds: 100)); drag.addPointer(down); tester.closeArena(5); @@ -166,8 +166,8 @@ void main() { }); testGesture('Drag with multiple pointers', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag1 = new HorizontalDragGestureRecognizer(); - final VerticalDragGestureRecognizer drag2 = new VerticalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag1 = HorizontalDragGestureRecognizer(); + final VerticalDragGestureRecognizer drag2 = VerticalDragGestureRecognizer(); final List log = []; drag1.onDown = (_) { log.add('drag1-down'); }; @@ -181,7 +181,7 @@ void main() { drag2.onEnd = (_) { log.add('drag2-end'); }; drag2.onCancel = () { log.add('drag2-cancel'); }; - final TestPointer pointer5 = new TestPointer(5); + final TestPointer pointer5 = TestPointer(5); final PointerDownEvent down5 = pointer5.down(const Offset(10.0, 10.0)); drag1.addPointer(down5); drag2.addPointer(down5); @@ -194,7 +194,7 @@ void main() { tester.route(pointer5.move(const Offset(50.0, 50.0))); log.add('-c'); - final TestPointer pointer6 = new TestPointer(6); + final TestPointer pointer6 = TestPointer(6); final PointerDownEvent down6 = pointer6.down(const Offset(20.0, 20.0)); drag1.addPointer(down6); drag2.addPointer(down6); @@ -235,7 +235,7 @@ void main() { }); testGesture('Clamp max velocity', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); Velocity velocity; double primaryVelocity; @@ -244,7 +244,7 @@ void main() { primaryVelocity = details.primaryVelocity; }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 25.0), timeStamp: const Duration(milliseconds: 10)); drag.addPointer(down); tester.closeArena(5); @@ -269,14 +269,14 @@ void main() { }); testGesture('Synthesized pointer events are ignored for velocity tracking', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); Velocity velocity; drag.onEnd = (DragEndDetails details) { velocity = details.velocity; }; - final TestPointer pointer = new TestPointer(1); + final TestPointer pointer = TestPointer(1); final PointerDownEvent down = pointer.down(const Offset(10.0, 25.0), timeStamp: const Duration(milliseconds: 10)); drag.addPointer(down); tester.closeArena(1); @@ -303,14 +303,14 @@ void main() { /// Checks that quick flick gestures with 1 down, 2 move and 1 up pointer /// events still have a velocity testGesture('Quick flicks have velocity', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); Velocity velocity; drag.onEnd = (DragEndDetails details) { velocity = details.velocity; }; - final TestPointer pointer = new TestPointer(1); + final TestPointer pointer = TestPointer(1); final PointerDownEvent down = pointer.down(const Offset(10.0, 25.0), timeStamp: const Duration(milliseconds: 10)); drag.addPointer(down); tester.closeArena(1); @@ -326,14 +326,14 @@ void main() { }); testGesture('Drag details', (GestureTester tester) { - expect(new DragDownDetails(), hasOneLineDescription); - expect(new DragStartDetails(), hasOneLineDescription); - expect(new DragUpdateDetails(globalPosition: Offset.zero), hasOneLineDescription); - expect(new DragEndDetails(), hasOneLineDescription); + expect(DragDownDetails(), hasOneLineDescription); + expect(DragStartDetails(), hasOneLineDescription); + expect(DragUpdateDetails(globalPosition: Offset.zero), hasOneLineDescription); + expect(DragEndDetails(), hasOneLineDescription); }); testGesture('Should recognize drag', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); bool didStartDrag = false; drag.onStart = (_) { @@ -350,7 +350,7 @@ void main() { didEndDrag = true; }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0)); drag.addPointer(down); tester.closeArena(5); @@ -386,14 +386,14 @@ void main() { }); testGesture('Should recognize drag', (GestureTester tester) { - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); Offset newGlobalPosition; drag.onUpdate = (DragUpdateDetails details) { newGlobalPosition = details.globalPosition; }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0)); drag.addPointer(down); tester.route(pointer.move(const Offset(20.0, 25.0))); diff --git a/packages/flutter/test/gestures/gesture_binding_test.dart b/packages/flutter/test/gestures/gesture_binding_test.dart index 0ed89703f3..a0f53f8825 100644 --- a/packages/flutter/test/gestures/gesture_binding_test.dart +++ b/packages/flutter/test/gestures/gesture_binding_test.dart @@ -22,10 +22,10 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding { } } -TestGestureFlutterBinding _binding = new TestGestureFlutterBinding(); +TestGestureFlutterBinding _binding = TestGestureFlutterBinding(); void ensureTestGestureBinding() { - _binding ??= new TestGestureFlutterBinding(); + _binding ??= TestGestureFlutterBinding(); assert(GestureBinding.instance != null); } @@ -69,14 +69,14 @@ void main() { }); test('Synthetic move events', () { - final ui.PointerDataPacket packet = new ui.PointerDataPacket( + final ui.PointerDataPacket packet = ui.PointerDataPacket( data: [ - new ui.PointerData( + ui.PointerData( change: ui.PointerChange.down, physicalX: 1.0 * ui.window.devicePixelRatio, physicalY: 3.0 * ui.window.devicePixelRatio, ), - new ui.PointerData( + ui.PointerData( change: ui.PointerChange.up, physicalX: 10.0 * ui.window.devicePixelRatio, physicalY: 15.0 * ui.window.devicePixelRatio, @@ -155,10 +155,10 @@ void main() { }); test('Synthetic hover and cancel for misplaced down and remove', () { - final ui.PointerDataPacket packet = new ui.PointerDataPacket( + final ui.PointerDataPacket packet = ui.PointerDataPacket( data: [ - new ui.PointerData(change: ui.PointerChange.add, device: 25, physicalX: 10.0 * ui.window.devicePixelRatio, physicalY: 10.0 * ui.window.devicePixelRatio), - new ui.PointerData(change: ui.PointerChange.down, device: 25, physicalX: 15.0 * ui.window.devicePixelRatio, physicalY: 17.0 * ui.window.devicePixelRatio), + ui.PointerData(change: ui.PointerChange.add, device: 25, physicalX: 10.0 * ui.window.devicePixelRatio, physicalY: 10.0 * ui.window.devicePixelRatio), + ui.PointerData(change: ui.PointerChange.down, device: 25, physicalX: 15.0 * ui.window.devicePixelRatio, physicalY: 17.0 * ui.window.devicePixelRatio), const ui.PointerData(change: ui.PointerChange.remove, device: 25), ] ); diff --git a/packages/flutter/test/gestures/gesture_tester.dart b/packages/flutter/test/gestures/gesture_tester.dart index 227b86a1e9..d282c051a6 100644 --- a/packages/flutter/test/gestures/gesture_tester.dart +++ b/packages/flutter/test/gestures/gesture_tester.dart @@ -13,7 +13,7 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding { } void ensureGestureBinding() { if (GestureBinding.instance == null) - new TestGestureFlutterBinding(); + TestGestureFlutterBinding(); assert(GestureBinding.instance != null); } @@ -37,8 +37,8 @@ typedef void GestureTest(GestureTester tester); @isTest void testGesture(String description, GestureTest callback) { test(description, () { - new FakeAsync().run((FakeAsync async) { - callback(new GestureTester._(async)); + FakeAsync().run((FakeAsync async) { + callback(GestureTester._(async)); }); }); } diff --git a/packages/flutter/test/gestures/locking_test.dart b/packages/flutter/test/gestures/locking_test.dart index e0cbf180a3..f08d714be9 100644 --- a/packages/flutter/test/gestures/locking_test.dart +++ b/packages/flutter/test/gestures/locking_test.dart @@ -38,10 +38,10 @@ class TestGestureFlutterBinding extends BindingBase with GestureBinding { } } -TestGestureFlutterBinding _binding = new TestGestureFlutterBinding(); +TestGestureFlutterBinding _binding = TestGestureFlutterBinding(); void ensureTestGestureBinding() { - _binding ??= new TestGestureFlutterBinding(); + _binding ??= TestGestureFlutterBinding(); assert(GestureBinding.instance != null); } diff --git a/packages/flutter/test/gestures/long_press_test.dart b/packages/flutter/test/gestures/long_press_test.dart index 524a4a71b1..bff22768f0 100644 --- a/packages/flutter/test/gestures/long_press_test.dart +++ b/packages/flutter/test/gestures/long_press_test.dart @@ -21,7 +21,7 @@ void main() { setUp(ensureGestureBinding); testGesture('Should recognize long press', (GestureTester tester) { - final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer(); + final LongPressGestureRecognizer longPress = LongPressGestureRecognizer(); bool longPressRecognized = false; longPress.onLongPress = () { @@ -42,7 +42,7 @@ void main() { }); testGesture('Up cancels long press', (GestureTester tester) { - final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer(); + final LongPressGestureRecognizer longPress = LongPressGestureRecognizer(); bool longPressRecognized = false; longPress.onLongPress = () { @@ -65,8 +65,8 @@ void main() { }); testGesture('Should recognize both tap down and long press', (GestureTester tester) { - final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer(); - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final LongPressGestureRecognizer longPress = LongPressGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapDownRecognized = false; tap.onTapDown = (_) { @@ -98,8 +98,8 @@ void main() { }); testGesture('Drag start delayed by microtask', (GestureTester tester) { - final LongPressGestureRecognizer longPress = new LongPressGestureRecognizer(); - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final LongPressGestureRecognizer longPress = LongPressGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); bool isDangerousStack = false; diff --git a/packages/flutter/test/gestures/lsq_solver_test.dart b/packages/flutter/test/gestures/lsq_solver_test.dart index 0fcf4923c3..a7b5912df1 100644 --- a/packages/flutter/test/gestures/lsq_solver_test.dart +++ b/packages/flutter/test/gestures/lsq_solver_test.dart @@ -17,7 +17,7 @@ void main() { final List y = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; final List w = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; - final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w); + final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w); final PolynomialFit fit = solver.solve(1); expect(fit.coefficients.length, 2); @@ -31,7 +31,7 @@ void main() { final List y = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]; final List w = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; - final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w); + final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w); final PolynomialFit fit = solver.solve(1); expect(fit.coefficients.length, 2); @@ -45,7 +45,7 @@ void main() { final List y = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; final List w = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; - final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w); + final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w); final PolynomialFit fit = solver.solve(2); expect(fit.coefficients.length, 3); @@ -60,7 +60,7 @@ void main() { final List y = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]; final List w = [1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]; - final LeastSquaresSolver solver = new LeastSquaresSolver(x, y, w); + final LeastSquaresSolver solver = LeastSquaresSolver(x, y, w); final PolynomialFit fit = solver.solve(2); expect(fit.coefficients.length, 3); diff --git a/packages/flutter/test/gestures/multidrag_test.dart b/packages/flutter/test/gestures/multidrag_test.dart index f3afca765d..207b3c0ff6 100644 --- a/packages/flutter/test/gestures/multidrag_test.dart +++ b/packages/flutter/test/gestures/multidrag_test.dart @@ -13,15 +13,15 @@ void main() { setUp(ensureGestureBinding); testGesture('MultiDrag: moving before delay rejects', (GestureTester tester) { - final DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer(); + final DelayedMultiDragGestureRecognizer drag = DelayedMultiDragGestureRecognizer(); bool didStartDrag = false; drag.onStart = (Offset position) { didStartDrag = true; - return new TestDrag(); + return TestDrag(); }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0)); drag.addPointer(down); tester.closeArena(5); @@ -38,15 +38,15 @@ void main() { }); testGesture('MultiDrag: delay triggers', (GestureTester tester) { - final DelayedMultiDragGestureRecognizer drag = new DelayedMultiDragGestureRecognizer(); + final DelayedMultiDragGestureRecognizer drag = DelayedMultiDragGestureRecognizer(); bool didStartDrag = false; drag.onStart = (Offset position) { didStartDrag = true; - return new TestDrag(); + return TestDrag(); }; - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(const Offset(10.0, 10.0)); drag.addPointer(down); tester.closeArena(5); diff --git a/packages/flutter/test/gestures/multitap_test.dart b/packages/flutter/test/gestures/multitap_test.dart index 8a8eaa508c..2482421c6e 100644 --- a/packages/flutter/test/gestures/multitap_test.dart +++ b/packages/flutter/test/gestures/multitap_test.dart @@ -14,7 +14,7 @@ void main() { setUp(ensureGestureBinding); testGesture('Should recognize pan', (GestureTester tester) { - final MultiTapGestureRecognizer tap = new MultiTapGestureRecognizer(longTapDelay: kLongPressTimeout); + final MultiTapGestureRecognizer tap = MultiTapGestureRecognizer(longTapDelay: kLongPressTimeout); final List log = []; @@ -25,7 +25,7 @@ void main() { tap.onTapCancel = (int pointer) { log.add('tap-cancel $pointer'); }; - final TestPointer pointer5 = new TestPointer(5); + final TestPointer pointer5 = TestPointer(5); final PointerDownEvent down5 = pointer5.down(const Offset(10.0, 10.0)); tap.addPointer(down5); tester.closeArena(5); @@ -34,7 +34,7 @@ void main() { tester.route(down5); expect(log, isEmpty); - final TestPointer pointer6 = new TestPointer(6); + final TestPointer pointer6 = TestPointer(6); final PointerDownEvent down6 = pointer6.down(const Offset(15.0, 15.0)); tap.addPointer(down6); tester.closeArena(6); diff --git a/packages/flutter/test/gestures/pointer_router_test.dart b/packages/flutter/test/gestures/pointer_router_test.dart index 1d984da107..46471faed8 100644 --- a/packages/flutter/test/gestures/pointer_router_test.dart +++ b/packages/flutter/test/gestures/pointer_router_test.dart @@ -13,10 +13,10 @@ void main() { callbackRan = true; } - final TestPointer pointer2 = new TestPointer(2); - final TestPointer pointer3 = new TestPointer(3); + final TestPointer pointer2 = TestPointer(2); + final TestPointer pointer3 = TestPointer(3); - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); router.addRoute(3, callback); router.route(pointer2.down(Offset.zero)); expect(callbackRan, isFalse); @@ -33,12 +33,12 @@ void main() { void callback(PointerEvent event) { callbackRan = true; } - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); router.addRoute(2, (PointerEvent event) { router.removeRoute(2, callback); }); router.addRoute(2, callback); - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); router.route(pointer2.down(Offset.zero)); expect(callbackRan, isFalse); }); @@ -50,13 +50,13 @@ void main() { } bool firstCallbackRan = false; - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); router.addGlobalRoute((PointerEvent event) { firstCallbackRan = true; router.addGlobalRoute(secondCallback); }); - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); router.route(pointer2.down(Offset.zero)); expect(firstCallbackRan, isTrue); expect(secondCallbackRan, isFalse); @@ -67,12 +67,12 @@ void main() { void callback(PointerEvent event) { callbackRan = true; } - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); router.addGlobalRoute((PointerEvent event) { router.removeGlobalRoute(callback); }); router.addGlobalRoute(callback); - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); router.route(pointer2.down(Offset.zero)); expect(callbackRan, isFalse); }); @@ -82,13 +82,13 @@ void main() { void callback(PointerEvent event) { callbackRan = true; } - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); bool perPointerCallbackRan = false; router.addRoute(2, (PointerEvent event) { perPointerCallbackRan = true; router.addGlobalRoute(callback); }); - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); router.route(pointer2.down(Offset.zero)); expect(perPointerCallbackRan, isTrue); expect(callbackRan, isFalse); @@ -96,7 +96,7 @@ void main() { test('Per-pointer callbacks happen before global callbacks', () { final List log = []; - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); router.addGlobalRoute((PointerEvent event) { log.add('global 1'); }); @@ -109,7 +109,7 @@ void main() { router.addRoute(2, (PointerEvent event) { log.add('per-pointer 2'); }); - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); router.route(pointer2.down(Offset.zero)); expect(log, equals([ 'per-pointer 1', @@ -121,7 +121,7 @@ void main() { test('Exceptions do not stop pointer routing', () { final List log = []; - final PointerRouter router = new PointerRouter(); + final PointerRouter router = PointerRouter(); router.addRoute(2, (PointerEvent event) { log.add('per-pointer 1'); }); @@ -138,7 +138,7 @@ void main() { log.add('error report'); }; - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); router.route(pointer2.down(Offset.zero)); expect(log, equals([ 'per-pointer 1', diff --git a/packages/flutter/test/gestures/recognizer_test.dart b/packages/flutter/test/gestures/recognizer_test.dart index 6ed13d4ff3..c9120499bd 100644 --- a/packages/flutter/test/gestures/recognizer_test.dart +++ b/packages/flutter/test/gestures/recognizer_test.dart @@ -23,7 +23,7 @@ class TestGestureRecognizer extends GestureRecognizer { void main() { test('GestureRecognizer smoketest', () { - final TestGestureRecognizer recognizer = new TestGestureRecognizer(debugOwner: 0); + final TestGestureRecognizer recognizer = TestGestureRecognizer(debugOwner: 0); expect(recognizer, hasAGoodToStringDeep); }); } diff --git a/packages/flutter/test/gestures/scale_test.dart b/packages/flutter/test/gestures/scale_test.dart index 5cda1fa6d7..8d61ee84cc 100644 --- a/packages/flutter/test/gestures/scale_test.dart +++ b/packages/flutter/test/gestures/scale_test.dart @@ -11,8 +11,8 @@ void main() { setUp(ensureGestureBinding); testGesture('Should recognize scale gestures', (GestureTester tester) { - final ScaleGestureRecognizer scale = new ScaleGestureRecognizer(); - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final ScaleGestureRecognizer scale = ScaleGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool didStartScale = false; Offset updatedFocalPoint; @@ -37,7 +37,7 @@ void main() { didTap = true; }; - final TestPointer pointer1 = new TestPointer(1); + final TestPointer pointer1 = TestPointer(1); final PointerDownEvent down = pointer1.down(const Offset(0.0, 0.0)); scale.addPointer(down); @@ -69,7 +69,7 @@ void main() { expect(didTap, isFalse); // Two-finger scaling - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); final PointerDownEvent down2 = pointer2.down(const Offset(10.0, 20.0)); scale.addPointer(down2); tap.addPointer(down2); @@ -102,7 +102,7 @@ void main() { expect(didTap, isFalse); // Three-finger scaling - final TestPointer pointer3 = new TestPointer(3); + final TestPointer pointer3 = TestPointer(3); final PointerDownEvent down3 = pointer3.down(const Offset(25.0, 35.0)); scale.addPointer(down3); tap.addPointer(down3); @@ -186,8 +186,8 @@ void main() { }); testGesture('Scale gesture competes with drag', (GestureTester tester) { - final ScaleGestureRecognizer scale = new ScaleGestureRecognizer(); - final HorizontalDragGestureRecognizer drag = new HorizontalDragGestureRecognizer(); + final ScaleGestureRecognizer scale = ScaleGestureRecognizer(); + final HorizontalDragGestureRecognizer drag = HorizontalDragGestureRecognizer(); final List log = []; @@ -198,7 +198,7 @@ void main() { drag.onStart = (DragStartDetails details) { log.add('drag-start'); }; drag.onEnd = (DragEndDetails details) { log.add('drag-end'); }; - final TestPointer pointer1 = new TestPointer(1); + final TestPointer pointer1 = TestPointer(1); final PointerDownEvent down = pointer1.down(const Offset(10.0, 10.0)); scale.addPointer(down); @@ -217,7 +217,7 @@ void main() { expect(log, equals(['scale-start', 'scale-update'])); log.clear(); - final TestPointer pointer2 = new TestPointer(2); + final TestPointer pointer2 = TestPointer(2); final PointerDownEvent down2 = pointer2.down(const Offset(10.0, 20.0)); scale.addPointer(down2); drag.addPointer(down2); @@ -246,7 +246,7 @@ void main() { // TODO(ianh): https://github.com/flutter/flutter/issues/11384 // In this case, we move fast, so that the scale wins. If we moved slowly, // the horizontal drag would win, since it was added first. - final TestPointer pointer3 = new TestPointer(3); + final TestPointer pointer3 = TestPointer(3); final PointerDownEvent down3 = pointer3.down(const Offset(30.0, 30.0)); scale.addPointer(down3); drag.addPointer(down3); diff --git a/packages/flutter/test/gestures/tap_test.dart b/packages/flutter/test/gestures/tap_test.dart index e0edb1ebb2..f09d46588b 100644 --- a/packages/flutter/test/gestures/tap_test.dart +++ b/packages/flutter/test/gestures/tap_test.dart @@ -74,7 +74,7 @@ void main() { ); testGesture('Should recognize tap', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapRecognized = false; tap.onTap = () { @@ -96,7 +96,7 @@ void main() { }); testGesture('No duplicate tap events', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); int tapsRecognized = 0; tap.onTap = () { @@ -129,7 +129,7 @@ void main() { }); testGesture('Should not recognize two overlapping taps', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); int tapsRecognized = 0; tap.onTap = () { @@ -163,7 +163,7 @@ void main() { }); testGesture('Distance cancels tap', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapRecognized = false; tap.onTap = () { @@ -196,7 +196,7 @@ void main() { }); testGesture('Short distance does not cancel tap', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapRecognized = false; tap.onTap = () { @@ -229,7 +229,7 @@ void main() { }); testGesture('Timeout does not cancel tap', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapRecognized = false; tap.onTap = () { @@ -253,7 +253,7 @@ void main() { }); testGesture('Should yield to other arena members', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapRecognized = false; tap.onTap = () { @@ -261,7 +261,7 @@ void main() { }; tap.addPointer(down1); - final TestGestureArenaMember member = new TestGestureArenaMember(); + final TestGestureArenaMember member = TestGestureArenaMember(); final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member); GestureBinding.instance.gestureArena.hold(1); tester.closeArena(1); @@ -281,7 +281,7 @@ void main() { }); testGesture('Should trigger on release of held arena', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); bool tapRecognized = false; tap.onTap = () { @@ -289,7 +289,7 @@ void main() { }; tap.addPointer(down1); - final TestGestureArenaMember member = new TestGestureArenaMember(); + final TestGestureArenaMember member = TestGestureArenaMember(); final GestureArenaEntry entry = GestureBinding.instance.gestureArena.add(1, member); GestureBinding.instance.gestureArena.hold(1); tester.closeArena(1); @@ -310,10 +310,10 @@ void main() { }); testGesture('Should log exceptions from callbacks', (GestureTester tester) { - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final TapGestureRecognizer tap = TapGestureRecognizer(); tap.onTap = () { - throw new Exception(test); + throw Exception(test); }; final FlutterExceptionHandler previousErrorHandler = FlutterError.onError; @@ -335,8 +335,8 @@ void main() { }); testGesture('No duplicate tap events', (GestureTester tester) { - final TapGestureRecognizer tapA = new TapGestureRecognizer(); - final TapGestureRecognizer tapB = new TapGestureRecognizer(); + final TapGestureRecognizer tapA = TapGestureRecognizer(); + final TapGestureRecognizer tapB = TapGestureRecognizer(); final List log = []; tapA.onTapDown = (TapDownDetails details) { log.add('tapA onTapDown'); }; diff --git a/packages/flutter/test/gestures/team_test.dart b/packages/flutter/test/gestures/team_test.dart index 9eadbab921..e39a494fa6 100644 --- a/packages/flutter/test/gestures/team_test.dart +++ b/packages/flutter/test/gestures/team_test.dart @@ -11,10 +11,10 @@ void main() { setUp(ensureGestureBinding); testGesture('GestureArenaTeam rejection test', (GestureTester tester) { - final GestureArenaTeam team = new GestureArenaTeam(); - final HorizontalDragGestureRecognizer horizontalDrag = new HorizontalDragGestureRecognizer()..team = team; - final VerticalDragGestureRecognizer verticalDrag = new VerticalDragGestureRecognizer()..team = team; - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final GestureArenaTeam team = GestureArenaTeam(); + final HorizontalDragGestureRecognizer horizontalDrag = HorizontalDragGestureRecognizer()..team = team; + final VerticalDragGestureRecognizer verticalDrag = VerticalDragGestureRecognizer()..team = team; + final TapGestureRecognizer tap = TapGestureRecognizer(); expect(horizontalDrag.team, equals(team)); expect(verticalDrag.team, equals(team)); @@ -28,7 +28,7 @@ void main() { void test(Offset delta) { const Offset origin = Offset(10.0, 10.0); - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(origin); horizontalDrag.addPointer(down); verticalDrag.addPointer(down); @@ -56,11 +56,11 @@ void main() { }); testGesture('GestureArenaTeam captain', (GestureTester tester) { - final GestureArenaTeam team = new GestureArenaTeam(); - final PassiveGestureRecognizer captain = new PassiveGestureRecognizer()..team = team; - final HorizontalDragGestureRecognizer horizontalDrag = new HorizontalDragGestureRecognizer()..team = team; - final VerticalDragGestureRecognizer verticalDrag = new VerticalDragGestureRecognizer()..team = team; - final TapGestureRecognizer tap = new TapGestureRecognizer(); + final GestureArenaTeam team = GestureArenaTeam(); + final PassiveGestureRecognizer captain = PassiveGestureRecognizer()..team = team; + final HorizontalDragGestureRecognizer horizontalDrag = HorizontalDragGestureRecognizer()..team = team; + final VerticalDragGestureRecognizer verticalDrag = VerticalDragGestureRecognizer()..team = team; + final TapGestureRecognizer tap = TapGestureRecognizer(); team.captain = captain; @@ -73,7 +73,7 @@ void main() { void test(Offset delta) { const Offset origin = Offset(10.0, 10.0); - final TestPointer pointer = new TestPointer(5); + final TestPointer pointer = TestPointer(5); final PointerDownEvent down = pointer.down(origin); captain.addPointer(down); horizontalDrag.addPointer(down); diff --git a/packages/flutter/test/gestures/velocity_tracker_test.dart b/packages/flutter/test/gestures/velocity_tracker_test.dart index ef6eea5264..06026defe7 100644 --- a/packages/flutter/test/gestures/velocity_tracker_test.dart +++ b/packages/flutter/test/gestures/velocity_tracker_test.dart @@ -36,7 +36,7 @@ void main() { ]; test('Velocity tracker gives expected results', () { - final VelocityTracker tracker = new VelocityTracker(); + final VelocityTracker tracker = VelocityTracker(); int i = 0; for (PointerEvent event in velocityEventData) { if (event is PointerDownEvent || event is PointerMoveEvent) @@ -62,7 +62,7 @@ void main() { test('Interrupted velocity estimation', () { // Regression test for https://github.com/flutter/flutter/pull/7510 - final VelocityTracker tracker = new VelocityTracker(); + final VelocityTracker tracker = VelocityTracker(); for (PointerEvent event in interruptedVelocityEventData) { if (event is PointerDownEvent || event is PointerMoveEvent) tracker.addPosition(event.timeStamp, event.position); @@ -73,7 +73,7 @@ void main() { }); test('No data velocity estimation', () { - final VelocityTracker tracker = new VelocityTracker(); + final VelocityTracker tracker = VelocityTracker(); expect(tracker.getVelocity(), Velocity.zero); }); } diff --git a/packages/flutter/test/material/about_test.dart b/packages/flutter/test/material/about_test.dart index 453db07005..a4134a53d5 100644 --- a/packages/flutter/test/material/about_test.dart +++ b/packages/flutter/test/material/about_test.dart @@ -11,14 +11,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('AboutListTile control test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( title: 'Pirate app', - home: new Scaffold( - appBar: new AppBar( + home: Scaffold( + appBar: AppBar( title: const Text('Home'), ), - drawer: new Drawer( - child: new ListView( + drawer: Drawer( + child: ListView( children: const [ AboutListTile( applicationVersion: '0.1.2', @@ -54,7 +54,7 @@ void main() { expect(find.text('About box'), findsOneWidget); LicenseRegistry.addLicense(() { - return new Stream.fromIterable([ + return Stream.fromIterable([ const LicenseEntryWithLineBreaks([ 'Pirate package '], 'Pirate license') ]); }); @@ -67,7 +67,7 @@ void main() { testWidgets('About box logic defaults to executable name for app name', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( title: 'flutter_tester', home: const Material(child: AboutListTile()), ), @@ -77,19 +77,19 @@ void main() { testWidgets('AboutListTile control test', (WidgetTester tester) async { LicenseRegistry.addLicense(() { - return new Stream.fromIterable([ + return Stream.fromIterable([ const LicenseEntryWithLineBreaks(['AAA'], 'BBB') ]); }); LicenseRegistry.addLicense(() { - return new Stream.fromIterable([ + return Stream.fromIterable([ const LicenseEntryWithLineBreaks(['Another package'], 'Another license') ]); }); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Center( child: LicensePage(), ), diff --git a/packages/flutter/test/material/animated_icons_private_test.dart b/packages/flutter/test/material/animated_icons_private_test.dart index 7d69c9a58d..b90e32da0c 100644 --- a/packages/flutter/test/material/animated_icons_private_test.dart +++ b/packages/flutter/test/material/animated_icons_private_test.dart @@ -81,10 +81,10 @@ void main () { group('_AnimatedIconPainter', () { const Size size = Size(48.0, 48.0); - final MockCanvas mockCanvas = new MockCanvas(); + final MockCanvas mockCanvas = MockCanvas(); List generatedPaths; final _UiPathFactory pathFactory = () { - final MockPath path = new MockPath(); + final MockPath path = MockPath(); generatedPaths.add(path); return path; }; @@ -94,7 +94,7 @@ void main () { }); test('progress 0', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: movingBar.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -116,7 +116,7 @@ void main () { }); test('progress 1', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: movingBar.paths, progress: const AlwaysStoppedAnimation(1.0), color: const Color(0xFF00FF00), @@ -138,7 +138,7 @@ void main () { }); test('clamped progress', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: movingBar.paths, progress: const AlwaysStoppedAnimation(1.5), color: const Color(0xFF00FF00), @@ -160,7 +160,7 @@ void main () { }); test('scale', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: movingBar.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -173,7 +173,7 @@ void main () { }); test('mirror', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: movingBar.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -189,7 +189,7 @@ void main () { }); test('interpolated frame', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: movingBar.paths, progress: const AlwaysStoppedAnimation(0.5), color: const Color(0xFF00FF00), @@ -211,7 +211,7 @@ void main () { }); test('curved frame', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(1.0), color: const Color(0xFF00FF00), @@ -231,7 +231,7 @@ void main () { }); test('interpolated curved frame', () { - final _AnimatedIconPainter painter = new _AnimatedIconPainter( + final _AnimatedIconPainter painter = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.25), color: const Color(0xFF00FF00), @@ -251,7 +251,7 @@ void main () { }); test('should not repaint same values', () { - final _AnimatedIconPainter painter1 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter1 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -260,7 +260,7 @@ void main () { uiPathFactory: pathFactory ); - final _AnimatedIconPainter painter2 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter2 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -273,7 +273,7 @@ void main () { }); test('should repaint on progress change', () { - final _AnimatedIconPainter painter1 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter1 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -282,7 +282,7 @@ void main () { uiPathFactory: pathFactory ); - final _AnimatedIconPainter painter2 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter2 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.1), color: const Color(0xFF00FF00), @@ -295,7 +295,7 @@ void main () { }); test('should repaint on color change', () { - final _AnimatedIconPainter painter1 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter1 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF00FF00), @@ -304,7 +304,7 @@ void main () { uiPathFactory: pathFactory ); - final _AnimatedIconPainter painter2 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter2 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFFFF0000), @@ -317,7 +317,7 @@ void main () { }); test('should repaint on paths change', () { - final _AnimatedIconPainter painter1 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter1 = _AnimatedIconPainter( paths: bow.paths, progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF0000FF), @@ -326,7 +326,7 @@ void main () { uiPathFactory: pathFactory ); - final _AnimatedIconPainter painter2 = new _AnimatedIconPainter( + final _AnimatedIconPainter painter2 = _AnimatedIconPainter( paths: const <_PathFrames> [], progress: const AlwaysStoppedAnimation(0.0), color: const Color(0xFF0000FF), diff --git a/packages/flutter/test/material/animated_icons_test.dart b/packages/flutter/test/material/animated_icons_test.dart index eb18415052..8ad20d6992 100644 --- a/packages/flutter/test/material/animated_icons_test.dart +++ b/packages/flutter/test/material/animated_icons_test.dart @@ -29,7 +29,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(48.0, 48.0)); verify(canvas.drawPath(any, argThat(hasColor(0xFF666666)))); }); @@ -51,7 +51,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(48.0, 48.0)); verify(canvas.drawPath(any, argThat(hasColor(0x80666666)))); }); @@ -73,7 +73,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(48.0, 48.0)); verify(canvas.drawPath(any, argThat(hasColor(0xFF0000FF)))); }); @@ -95,7 +95,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(12.0, 12.0)); // arrow_menu default size is 48x48 so we expect it to be scaled by 0.25. verify(canvas.scale(0.25, 0.25)); @@ -119,14 +119,14 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(12.0, 12.0)); // arrow_menu default size is 48x48 so we expect it to be scaled by 2. verify(canvas.scale(2.0, 2.0)); }); testWidgets('Semantic label', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const Directionality( @@ -161,7 +161,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(48.0, 48.0)); verifyInOrder([ canvas.rotate(math.pi), @@ -185,7 +185,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(48.0, 48.0)); verifyNever(canvas.rotate(any)); verifyNever(canvas.translate(any, any)); @@ -208,7 +208,7 @@ void main() { ), ); final CustomPaint customPaint = tester.widget(find.byType(CustomPaint)); - final MockCanvas canvas = new MockCanvas(); + final MockCanvas canvas = MockCanvas(); customPaint.painter.paint(canvas, const Size(48.0, 48.0)); verifyInOrder([ canvas.rotate(math.pi), @@ -218,7 +218,7 @@ void main() { } PaintColorMatcher hasColor(int color) { - return new PaintColorMatcher(color); + return PaintColorMatcher(color); } class PaintColorMatcher extends Matcher { @@ -233,6 +233,6 @@ class PaintColorMatcher extends Matcher { @override bool matches(dynamic item, Map matchState) { final Paint actualPaint = item; - return actualPaint.color == new Color(expectedColor); + return actualPaint.color == Color(expectedColor); } } diff --git a/packages/flutter/test/material/app_bar_test.dart b/packages/flutter/test/material/app_bar_test.dart index d888750156..b5f5dd9cc6 100644 --- a/packages/flutter/test/material/app_bar_test.dart +++ b/packages/flutter/test/material/app_bar_test.dart @@ -10,34 +10,34 @@ import 'package:flutter_test/flutter_test.dart'; import '../widgets/semantics_tester.dart'; Widget buildSliverAppBarApp({ bool floating, bool pinned, double expandedHeight, bool snap = false }) { - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scaffold( - body: new DefaultTabController( + child: Scaffold( + body: DefaultTabController( length: 3, - child: new CustomScrollView( + child: CustomScrollView( primary: true, slivers: [ - new SliverAppBar( + SliverAppBar( title: const Text('AppBar Title'), floating: floating, pinned: pinned, expandedHeight: expandedHeight, snap: snap, - bottom: new TabBar( - tabs: ['A','B','C'].map((String t) => new Tab(text: 'TAB $t')).toList(), + bottom: TabBar( + tabs: ['A','B','C'].map((String t) => Tab(text: 'TAB $t')).toList(), ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 1200.0, color: Colors.orange[400], ), @@ -68,10 +68,10 @@ void main() { testWidgets('AppBar centers title on iOS', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( title: const Text('X'), ), ), @@ -84,13 +84,13 @@ void main() { expect(center.dx, lessThan(400 - size.width / 2.0)); // Clear the widget tree to avoid animating between Android and iOS. - await tester.pumpWidget(new Container(key: new UniqueKey())); + await tester.pumpWidget(Container(key: UniqueKey())); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( title: const Text('X'), ), ), @@ -105,10 +105,10 @@ void main() { // One action is still centered. await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( title: const Text('X'), actions: const [ Icon(Icons.thumb_up), @@ -126,10 +126,10 @@ void main() { // Two actions is left aligned again. await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( title: const Text('X'), actions: const [ Icon(Icons.thumb_up), @@ -147,10 +147,10 @@ void main() { testWidgets('AppBar centerTitle:true centers on Android', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( centerTitle: true, title: const Text('X'), ) @@ -167,9 +167,9 @@ void main() { testWidgets('AppBar centerTitle:false title start edge is 16.0 (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + home: Scaffold( + appBar: AppBar( centerTitle: false, title: const Placeholder(key: Key('X')), ), @@ -184,11 +184,11 @@ void main() { testWidgets('AppBar centerTitle:false title start edge is 16.0 (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Directionality( + MaterialApp( + home: Directionality( textDirection: TextDirection.rtl, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( centerTitle: false, title: const Placeholder(key: Key('X')), ), @@ -204,9 +204,9 @@ void main() { testWidgets('AppBar titleSpacing:32 title start edge is 32.0 (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + home: Scaffold( + appBar: AppBar( centerTitle: false, titleSpacing: 32.0, title: const Placeholder(key: Key('X')), @@ -222,11 +222,11 @@ void main() { testWidgets('AppBar titleSpacing:32 title start edge is 32.0 (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Directionality( + MaterialApp( + home: Directionality( textDirection: TextDirection.rtl, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( centerTitle: false, titleSpacing: 32.0, title: const Placeholder(key: Key('X')), @@ -245,9 +245,9 @@ void main() { 'AppBar centerTitle:false leading button title left edge is 72.0 (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + home: Scaffold( + appBar: AppBar( centerTitle: false, title: const Text('X'), ), @@ -264,11 +264,11 @@ void main() { 'AppBar centerTitle:false leading button title left edge is 72.0 (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Directionality( + MaterialApp( + home: Directionality( textDirection: TextDirection.rtl, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( centerTitle: false, title: const Text('X'), ), @@ -286,19 +286,19 @@ void main() { // The app bar's title should be constrained to fit within the available space // between the leading and actions widgets. - final Key titleKey = new UniqueKey(); - Widget leading = new Container(); + final Key titleKey = UniqueKey(); + Widget leading = Container(); List actions; Widget buildApp() { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( leading: leading, centerTitle: false, - title: new Container( + title: Container( key: titleKey, - constraints: new BoxConstraints.loose(const Size(1000.0, 1000.0)), + constraints: BoxConstraints.loose(const Size(1000.0, 1000.0)), ), actions: actions, ), @@ -331,7 +331,7 @@ void main() { - 16.0 // Title to actions padding - 200.0)); // Actions' width. - leading = new Container(); // AppBar will constrain the width to 24.0 + leading = Container(); // AppBar will constrain the width to 24.0 await tester.pumpWidget(buildApp()); expect(tester.getTopLeft(title).dx, 72.0); // Adding a leading widget shouldn't effect the title's size @@ -343,20 +343,20 @@ void main() { // between the leading and actions widgets. When it's also centered it may // also be start or end justified if it doesn't fit in the overall center. - final Key titleKey = new UniqueKey(); + final Key titleKey = UniqueKey(); double titleWidth = 700.0; - Widget leading = new Container(); + Widget leading = Container(); List actions; Widget buildApp() { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + home: Scaffold( + appBar: AppBar( leading: leading, centerTitle: true, - title: new Container( + title: Container( key: titleKey, - constraints: new BoxConstraints.loose(new Size(titleWidth, 1000.0)), + constraints: BoxConstraints.loose(Size(titleWidth, 1000.0)), ), actions: actions, ), @@ -395,22 +395,22 @@ void main() { // between the leading and actions widgets. When it's also centered it may // also be start or end justified if it doesn't fit in the overall center. - final Key titleKey = new UniqueKey(); + final Key titleKey = UniqueKey(); double titleWidth = 700.0; - Widget leading = new Container(); + Widget leading = Container(); List actions; Widget buildApp() { - return new MaterialApp( - home: new Directionality( + return MaterialApp( + home: Directionality( textDirection: TextDirection.rtl, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( leading: leading, centerTitle: true, - title: new Container( + title: Container( key: titleKey, - constraints: new BoxConstraints.loose(new Size(titleWidth, 1000.0)), + constraints: BoxConstraints.loose(Size(titleWidth, 1000.0)), ), actions: actions, ), @@ -447,10 +447,10 @@ void main() { testWidgets('AppBar with no Scaffold', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new SizedBox( + MaterialApp( + home: SizedBox( height: kToolbarHeight, - child: new AppBar( + child: AppBar( leading: const Text('L'), title: const Text('No Scaffold'), actions: const [Text('A1'), Text('A2')], @@ -467,13 +467,13 @@ void main() { testWidgets('AppBar render at zero size', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Container( + MaterialApp( + home: Center( + child: Container( height: 0.0, width: 0.0, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('X'), ), ), @@ -487,22 +487,22 @@ void main() { }); testWidgets('AppBar actions are vertically centered', (WidgetTester tester) async { - final UniqueKey appBarKey = new UniqueKey(); - final UniqueKey leadingKey = new UniqueKey(); - final UniqueKey titleKey = new UniqueKey(); - final UniqueKey action0Key = new UniqueKey(); - final UniqueKey action1Key = new UniqueKey(); + final UniqueKey appBarKey = UniqueKey(); + final UniqueKey leadingKey = UniqueKey(); + final UniqueKey titleKey = UniqueKey(); + final UniqueKey action0Key = UniqueKey(); + final UniqueKey action1Key = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + home: Scaffold( + appBar: AppBar( key: appBarKey, - leading: new SizedBox(key: leadingKey, height: 50.0), - title: new SizedBox(key: titleKey, height: 40.0), + leading: SizedBox(key: leadingKey, height: 50.0), + title: SizedBox(key: titleKey, height: 40.0), actions: [ - new SizedBox(key: action0Key, height: 20.0), - new SizedBox(key: action1Key, height: 30.0), + SizedBox(key: action0Key, height: 20.0), + SizedBox(key: action1Key, height: 30.0), ], ), ), @@ -520,13 +520,13 @@ void main() { testWidgets('leading button extends to edge and is square', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( title: const Text('X'), ), - drawer: new Column(), // Doesn't really matter. Triggers a hamburger regardless. + drawer: Column(), // Doesn't really matter. Triggers a hamburger regardless. ), ), ); @@ -538,10 +538,10 @@ void main() { testWidgets('test action is 4dp from edge and 48dp min', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( title: const Text('X'), actions: const [ IconButton( @@ -845,13 +845,13 @@ void main() { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new Scaffold( + child: Scaffold( primary: false, - appBar: new AppBar(), + appBar: AppBar(), ), ), ), @@ -860,13 +860,13 @@ void main() { expect(appBarHeight(tester), kToolbarHeight); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new Scaffold( + child: Scaffold( primary: true, - appBar: new AppBar(title: const Text('title')) + appBar: AppBar(title: const Text('title')) ), ), ), @@ -876,16 +876,16 @@ void main() { expect(appBarHeight(tester), kToolbarHeight + 100.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new Scaffold( + child: Scaffold( primary: false, - appBar: new AppBar( - bottom: new PreferredSize( + appBar: AppBar( + bottom: PreferredSize( preferredSize: const Size.fromHeight(200.0), - child: new Container(), + child: Container(), ), ), ), @@ -896,16 +896,16 @@ void main() { expect(appBarHeight(tester), kToolbarHeight + 200.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new Scaffold( + child: Scaffold( primary: true, - appBar: new AppBar( - bottom: new PreferredSize( + appBar: AppBar( + bottom: PreferredSize( preferredSize: const Size.fromHeight(200.0), - child: new Container(), + child: Container(), ), ), ), @@ -916,11 +916,11 @@ void main() { expect(appBarHeight(tester), kToolbarHeight + 100.0 + 200.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new AppBar( + child: AppBar( primary: false, title: const Text('title'), ), @@ -933,18 +933,18 @@ void main() { testWidgets('AppBar updates when you add a drawer', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar(), + MaterialApp( + home: Scaffold( + appBar: AppBar(), ), ), ); expect(find.byIcon(Icons.menu), findsNothing); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( + MaterialApp( + home: Scaffold( drawer: const Drawer(), - appBar: new AppBar(), + appBar: AppBar(), ), ), ); @@ -953,10 +953,10 @@ void main() { testWidgets('AppBar does not draw menu for drawer if automaticallyImplyLeading is false', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( + MaterialApp( + home: Scaffold( drawer: const Drawer(), - appBar: new AppBar(automaticallyImplyLeading: false), + appBar: AppBar(automaticallyImplyLeading: false), ), ), ); @@ -964,12 +964,12 @@ void main() { }); testWidgets('AppBar handles loose children 0', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new AppBar( - leading: new Placeholder(key: key), + MaterialApp( + home: Center( + child: AppBar( + leading: Placeholder(key: key), title: const Text('Abc'), actions: const [ Placeholder(fallbackWidth: 10.0), @@ -985,21 +985,21 @@ void main() { }); testWidgets('AppBar handles loose children 1', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new AppBar( - leading: new Placeholder(key: key), + MaterialApp( + home: Center( + child: AppBar( + leading: Placeholder(key: key), title: const Text('Abc'), actions: const [ Placeholder(fallbackWidth: 10.0), Placeholder(fallbackWidth: 10.0), Placeholder(fallbackWidth: 10.0), ], - flexibleSpace: new DecoratedBox( - decoration: new BoxDecoration( - gradient: new LinearGradient( + flexibleSpace: DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( begin: const Alignment(0.0, -1.0), end: const Alignment(-0.04, 1.0), colors: [Colors.blue.shade500, Colors.blue.shade800], @@ -1015,30 +1015,30 @@ void main() { }); testWidgets('AppBar handles loose children 2', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new AppBar( - leading: new Placeholder(key: key), + MaterialApp( + home: Center( + child: AppBar( + leading: Placeholder(key: key), title: const Text('Abc'), actions: const [ Placeholder(fallbackWidth: 10.0), Placeholder(fallbackWidth: 10.0), Placeholder(fallbackWidth: 10.0), ], - flexibleSpace: new DecoratedBox( - decoration: new BoxDecoration( - gradient: new LinearGradient( + flexibleSpace: DecoratedBox( + decoration: BoxDecoration( + gradient: LinearGradient( begin: const Alignment(0.0, -1.0), end: const Alignment(-0.04, 1.0), colors: [Colors.blue.shade500, Colors.blue.shade800], ), ), ), - bottom: new PreferredSize( + bottom: PreferredSize( preferredSize: const Size(0.0, kToolbarHeight), - child: new Container( + child: Container( height: 50.0, padding: const EdgeInsets.all(4.0), child: const Placeholder( @@ -1056,21 +1056,21 @@ void main() { }); testWidgets('AppBar handles loose children 3', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new AppBar( - leading: new Placeholder(key: key), + MaterialApp( + home: Center( + child: AppBar( + leading: Placeholder(key: key), title: const Text('Abc'), actions: const [ Placeholder(fallbackWidth: 10.0), Placeholder(fallbackWidth: 10.0), Placeholder(fallbackWidth: 10.0), ], - bottom: new PreferredSize( + bottom: PreferredSize( preferredSize: const Size(0.0, kToolbarHeight), - child: new Container( + child: Container( height: 50.0, padding: const EdgeInsets.all(4.0), child: const Placeholder( @@ -1090,21 +1090,21 @@ void main() { testWidgets('AppBar positioning of leading and trailing widgets with top padding', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0)); - final Key leadingKey = new UniqueKey(); - final Key titleKey = new UniqueKey(); - final Key trailingKey = new UniqueKey(); + final Key leadingKey = UniqueKey(); + final Key titleKey = UniqueKey(); + final Key trailingKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new Scaffold( + child: Scaffold( primary: false, - appBar: new AppBar( - leading: new Placeholder(key: leadingKey), - title: new Placeholder(key: titleKey), - actions: [ new Placeholder(key: trailingKey) ], + appBar: AppBar( + leading: Placeholder(key: leadingKey), + title: Placeholder(key: titleKey), + actions: [ Placeholder(key: trailingKey) ], ), ), ), @@ -1119,22 +1119,22 @@ void main() { testWidgets('SliverAppBar positioning of leading and trailing widgets with top padding', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0)); - final Key leadingKey = new UniqueKey(); - final Key titleKey = new UniqueKey(); - final Key trailingKey = new UniqueKey(); + final Key leadingKey = UniqueKey(); + final Key titleKey = UniqueKey(); + final Key trailingKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new CustomScrollView( + child: CustomScrollView( primary: true, slivers: [ - new SliverAppBar( - leading: new Placeholder(key: leadingKey), - title: new Placeholder(key: titleKey), - actions: [ new Placeholder(key: trailingKey) ], + SliverAppBar( + leading: Placeholder(key: leadingKey), + title: Placeholder(key: titleKey), + actions: [ Placeholder(key: trailingKey) ], ), ], ), @@ -1150,40 +1150,40 @@ void main() { testWidgets('SliverAppBar positioning of leading and trailing widgets with bottom padding', (WidgetTester tester) async { const MediaQueryData topPadding100 = MediaQueryData(padding: EdgeInsets.only(top: 100.0, bottom: 50.0)); - final Key leadingKey = new UniqueKey(); - final Key titleKey = new UniqueKey(); - final Key trailingKey = new UniqueKey(); + final Key leadingKey = UniqueKey(); + final Key titleKey = UniqueKey(); + final Key trailingKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new MediaQuery( + child: MediaQuery( data: topPadding100, - child: new CustomScrollView( + child: CustomScrollView( primary: true, slivers: [ - new SliverAppBar( - leading: new Placeholder(key: leadingKey), - title: new Placeholder(key: titleKey), - actions: [ new Placeholder(key: trailingKey) ], + SliverAppBar( + leading: Placeholder(key: leadingKey), + title: Placeholder(key: titleKey), + actions: [ Placeholder(key: trailingKey) ], ), ], ), ), ), ); - expect(tester.getRect(find.byType(AppBar)), new Rect.fromLTRB(0.0, 0.0, 800.00, 100.0 + 56.0)); - expect(tester.getRect(find.byKey(leadingKey)), new Rect.fromLTRB(800.0 - 56.0, 100.0, 800.0, 100.0 + 56.0)); - expect(tester.getRect(find.byKey(trailingKey)), new Rect.fromLTRB(0.0, 100.0, 400.0, 100.0 + 56.0)); + expect(tester.getRect(find.byType(AppBar)), Rect.fromLTRB(0.0, 0.0, 800.00, 100.0 + 56.0)); + expect(tester.getRect(find.byKey(leadingKey)), Rect.fromLTRB(800.0 - 56.0, 100.0, 800.0, 100.0 + 56.0)); + expect(tester.getRect(find.byKey(trailingKey)), Rect.fromLTRB(0.0, 100.0, 400.0, 100.0 + 56.0)); }); testWidgets('SliverAppBar provides correct semantics in LTR', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new AppBar( + MaterialApp( + home: Center( + child: AppBar( leading: const Text('Leading'), title: const Text('Title'), actions: const [ @@ -1201,20 +1201,20 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: 'Leading', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -1222,19 +1222,19 @@ void main() { label: 'Title', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Action 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Action 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Action 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Bottom', textDirection: TextDirection.ltr, ), @@ -1255,16 +1255,16 @@ void main() { }); testWidgets('SliverAppBar provides correct semantics in RTL', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new Semantics( + MaterialApp( + home: Semantics( textDirection: TextDirection.rtl, - child: new Directionality( + child: Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new AppBar( + child: Center( + child: AppBar( leading: const Text('Leading'), title: const Text('Title'), actions: const [ @@ -1284,23 +1284,23 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.rtl, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: 'Leading', textDirection: TextDirection.rtl, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -1308,19 +1308,19 @@ void main() { label: 'Title', textDirection: TextDirection.rtl, ), - new TestSemantics( + TestSemantics( label: 'Action 1', textDirection: TextDirection.rtl, ), - new TestSemantics( + TestSemantics( label: 'Action 2', textDirection: TextDirection.rtl, ), - new TestSemantics( + TestSemantics( label: 'Action 3', textDirection: TextDirection.rtl, ), - new TestSemantics( + TestSemantics( label: 'Bottom', textDirection: TextDirection.rtl, ), @@ -1343,11 +1343,11 @@ void main() { }); testWidgets('AppBar draws a light system bar for a dark background', (WidgetTester tester) async { - final ThemeData darkTheme = new ThemeData.dark(); - await tester.pumpWidget(new MaterialApp( + final ThemeData darkTheme = ThemeData.dark(); + await tester.pumpWidget(MaterialApp( theme: darkTheme, home: Scaffold( - appBar: new AppBar(title: const Text('test')) + appBar: AppBar(title: const Text('test')) ), )); @@ -1359,11 +1359,11 @@ void main() { }); testWidgets('AppBar draws a dark system bar for a light background', (WidgetTester tester) async { - final ThemeData lightTheme = new ThemeData(primaryColor: Colors.white); - await tester.pumpWidget(new MaterialApp( + final ThemeData lightTheme = ThemeData(primaryColor: Colors.white); + await tester.pumpWidget(MaterialApp( theme: lightTheme, home: Scaffold( - appBar: new AppBar(title: const Text('test')) + appBar: AppBar(title: const Text('test')) ), )); diff --git a/packages/flutter/test/material/app_builder_test.dart b/packages/flutter/test/material/app_builder_test.dart index 84be833459..749b038e53 100644 --- a/packages/flutter/test/material/app_builder_test.dart +++ b/packages/flutter/test/material/app_builder_test.dart @@ -8,8 +8,8 @@ import 'package:flutter/material.dart'; void main() { testWidgets('builder doesn\'t get called if app doesn\'t change', (WidgetTester tester) async { final List log = []; - final Widget app = new MaterialApp( - theme: new ThemeData( + final Widget app = MaterialApp( + theme: ThemeData( primarySwatch: Colors.green, ), home: const Placeholder(), @@ -22,14 +22,14 @@ void main() { }, ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, child: app, ), ); expect(log, ['build']); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, child: app, ), @@ -40,11 +40,11 @@ void main() { testWidgets('builder doesn\'t get called if app doesn\'t change', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData( + MaterialApp( + theme: ThemeData( primarySwatch: Colors.yellow, ), - home: new Builder( + home: Builder( builder: (BuildContext context) { log.add('build'); expect(Theme.of(context).primaryColor, Colors.yellow); @@ -53,7 +53,7 @@ void main() { }, ), builder: (BuildContext context, Widget child) { - return new Directionality( + return Directionality( textDirection: TextDirection.rtl, child: child, ); diff --git a/packages/flutter/test/material/app_test.dart b/packages/flutter/test/material/app_test.dart index 5307e2598b..b42e86c847 100644 --- a/packages/flutter/test/material/app_test.dart +++ b/packages/flutter/test/material/app_test.dart @@ -11,7 +11,7 @@ class StateMarker extends StatefulWidget { final Widget child; @override - StateMarkerState createState() => new StateMarkerState(); + StateMarkerState createState() => StateMarkerState(); } class StateMarkerState extends State { @@ -21,15 +21,15 @@ class StateMarkerState extends State { Widget build(BuildContext context) { if (widget.child != null) return widget.child; - return new Container(); + return Container(); } } void main() { testWidgets('Can nest apps', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new MaterialApp( + MaterialApp( + home: MaterialApp( home: const Text('Home sweet home'), ), ), @@ -39,11 +39,11 @@ void main() { }); testWidgets('Focus handling', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new Center( - child: new TextField(focusNode: focusNode, autofocus: true), + final FocusNode focusNode = FocusNode(); + await tester.pumpWidget(MaterialApp( + home: Material( + child: Center( + child: TextField(focusNode: focusNode, autofocus: true), ), ), )); @@ -52,12 +52,12 @@ void main() { }); testWidgets('Can place app inside FocusScope', (WidgetTester tester) async { - final FocusScopeNode focusScopeNode = new FocusScopeNode(); + final FocusScopeNode focusScopeNode = FocusScopeNode(); - await tester.pumpWidget(new FocusScope( + await tester.pumpWidget(FocusScope( autofocus: true, node: focusScopeNode, - child: new MaterialApp( + child: MaterialApp( home: const Text('Home'), ), )); @@ -67,7 +67,7 @@ void main() { testWidgets('Can show grid without losing sync', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const StateMarker(), ), ); @@ -76,7 +76,7 @@ void main() { state1.marker = 'original'; await tester.pumpWidget( - new MaterialApp( + MaterialApp( debugShowMaterialGrid: true, home: const StateMarker(), ), @@ -90,11 +90,11 @@ void main() { testWidgets('Do not rebuild page during a route transition', (WidgetTester tester) async { int buildCounter = 0; await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Material( - child: new RaisedButton( + return Material( + child: RaisedButton( child: const Text('X'), onPressed: () { Navigator.of(context).pushNamed('/next'); }, ), @@ -103,7 +103,7 @@ void main() { ), routes: { '/next': (BuildContext context) { - return new Builder( + return Builder( builder: (BuildContext context) { ++buildCounter; return const Text('Y'); @@ -135,8 +135,8 @@ void main() { testWidgets('Do rebuild the home page if it changes', (WidgetTester tester) async { int buildCounter = 0; await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { ++buildCounter; return const Text('A'); @@ -147,8 +147,8 @@ void main() { expect(buildCounter, 1); expect(find.text('A'), findsOneWidget); await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { ++buildCounter; return const Text('B'); @@ -162,20 +162,20 @@ void main() { testWidgets('Do not rebuild the home page if it does not actually change', (WidgetTester tester) async { int buildCounter = 0; - final Widget home = new Builder( + final Widget home = Builder( builder: (BuildContext context) { ++buildCounter; return const Placeholder(); } ); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: home, ), ); expect(buildCounter, 1); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: home, ), ); @@ -191,13 +191,13 @@ void main() { }, }; await tester.pumpWidget( - new MaterialApp( + MaterialApp( routes: routes, ), ); expect(buildCounter, 1); await tester.pumpWidget( - new MaterialApp( + MaterialApp( routes: routes, ), ); @@ -205,7 +205,7 @@ void main() { }); testWidgets('Cannot pop the initial route', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: const Text('Home'))); + await tester.pumpWidget(MaterialApp(home: const Text('Home'))); expect(find.text('Home'), findsOneWidget); @@ -218,7 +218,7 @@ void main() { }); testWidgets('Default initialRoute', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(routes: { + await tester.pumpWidget(MaterialApp(routes: { '/': (BuildContext context) => const Text('route "/"'), })); @@ -227,7 +227,7 @@ void main() { testWidgets('One-step initial route', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( initialRoute: '/a', routes: { '/': (BuildContext context) => const Text('route "/"'), @@ -247,11 +247,11 @@ void main() { testWidgets('Return value from pop is correct', (WidgetTester tester) async { Future result; await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Material( - child: new RaisedButton( + return Material( + child: RaisedButton( child: const Text('X'), onPressed: () async { result = Navigator.of(context).pushNamed('/a'); @@ -262,8 +262,8 @@ void main() { ), routes: { '/a': (BuildContext context) { - return new Material( - child: new RaisedButton( + return Material( + child: RaisedButton( child: const Text('Y'), onPressed: () { Navigator.of(context).pop('all done'); @@ -293,7 +293,7 @@ void main() { }; await tester.pumpWidget( - new MaterialApp( + MaterialApp( initialRoute: '/a/b', routes: routes, ) @@ -313,7 +313,7 @@ void main() { }; await tester.pumpWidget( - new MaterialApp( + MaterialApp( initialRoute: '/a/b/c', routes: routes, ) @@ -335,7 +335,7 @@ void main() { }; await tester.pumpWidget( - new MaterialApp( + MaterialApp( initialRoute: '/a', routes: routes, ) @@ -346,7 +346,7 @@ void main() { // changing initialRoute has no effect await tester.pumpWidget( - new MaterialApp( + MaterialApp( initialRoute: '/b', routes: routes, ) @@ -356,7 +356,7 @@ void main() { expect(find.text('route "/b"'), findsNothing); // removing it has no effect - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(find.text('route "/"'), findsOneWidget); expect(find.text('route "/a"'), findsOneWidget); expect(find.text('route "/b"'), findsNothing); @@ -365,7 +365,7 @@ void main() { testWidgets('onGenerateRoute / onUnknownRoute', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( - new MaterialApp( + MaterialApp( onGenerateRoute: (RouteSettings settings) { log.add('onGenerateRoute ${settings.name}'); return null; @@ -382,10 +382,10 @@ void main() { testWidgets('Can get text scale from media query', (WidgetTester tester) async { double textScaleFactor; - await tester.pumpWidget(new MaterialApp( - home: new Builder(builder:(BuildContext context) { + await tester.pumpWidget(MaterialApp( + home: Builder(builder:(BuildContext context) { textScaleFactor = MediaQuery.of(context).textScaleFactor; - return new Container(); + return Container(); }), )); expect(textScaleFactor, isNotNull); @@ -393,19 +393,19 @@ void main() { }); testWidgets('MaterialApp.navigatorKey', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new MaterialApp( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(MaterialApp( navigatorKey: key, color: const Color(0xFF112233), home: const Placeholder(), )); expect(key.currentState, isInstanceOf()); - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( color: const Color(0xFF112233), home: const Placeholder(), )); expect(key.currentState, isNull); - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( navigatorKey: key, color: const Color(0xFF112233), home: const Placeholder(), diff --git a/packages/flutter/test/material/arc_test.dart b/packages/flutter/test/material/arc_test.dart index 5c331587f6..74041f4c91 100644 --- a/packages/flutter/test/material/arc_test.dart +++ b/packages/flutter/test/material/arc_test.dart @@ -7,12 +7,12 @@ import 'package:flutter/material.dart'; void main() { test('MaterialPointArcTween control test', () { - final MaterialPointArcTween a = new MaterialPointArcTween( + final MaterialPointArcTween a = MaterialPointArcTween( begin: Offset.zero, end: const Offset(0.0, 10.0) ); - final MaterialPointArcTween b = new MaterialPointArcTween( + final MaterialPointArcTween b = MaterialPointArcTween( begin: Offset.zero, end: const Offset(0.0, 10.0) ); @@ -23,14 +23,14 @@ void main() { }); test('MaterialRectArcTween control test', () { - final MaterialRectArcTween a = new MaterialRectArcTween( - begin: new Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), - end: new Rect.fromLTWH(0.0, 10.0, 10.0, 10.0) + final MaterialRectArcTween a = MaterialRectArcTween( + begin: Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), + end: Rect.fromLTWH(0.0, 10.0, 10.0, 10.0) ); - final MaterialRectArcTween b = new MaterialRectArcTween( - begin: new Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), - end: new Rect.fromLTWH(0.0, 10.0, 10.0, 10.0) + final MaterialRectArcTween b = MaterialRectArcTween( + begin: Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), + end: Rect.fromLTWH(0.0, 10.0, 10.0, 10.0) ); expect(a, hasOneLineDescription); expect(a, equals(b)); @@ -38,14 +38,14 @@ void main() { }); test('on-axis MaterialPointArcTween', () { - MaterialPointArcTween tween = new MaterialPointArcTween( + MaterialPointArcTween tween = MaterialPointArcTween( begin: Offset.zero, end: const Offset(0.0, 10.0) ); expect(tween.lerp(0.5), equals(const Offset(0.0, 5.0))); expect(tween, hasOneLineDescription); - tween = new MaterialPointArcTween( + tween = MaterialPointArcTween( begin: Offset.zero, end: const Offset(10.0, 0.0) ); @@ -53,31 +53,31 @@ void main() { }); test('on-axis MaterialRectArcTween', () { - MaterialRectArcTween tween = new MaterialRectArcTween( - begin: new Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), - end: new Rect.fromLTWH(0.0, 10.0, 10.0, 10.0) + MaterialRectArcTween tween = MaterialRectArcTween( + begin: Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), + end: Rect.fromLTWH(0.0, 10.0, 10.0, 10.0) ); - expect(tween.lerp(0.5), equals(new Rect.fromLTWH(0.0, 5.0, 10.0, 10.0))); + expect(tween.lerp(0.5), equals(Rect.fromLTWH(0.0, 5.0, 10.0, 10.0))); expect(tween, hasOneLineDescription); - tween = new MaterialRectArcTween( - begin: new Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), - end: new Rect.fromLTWH(10.0, 0.0, 10.0, 10.0) + tween = MaterialRectArcTween( + begin: Rect.fromLTWH(0.0, 0.0, 10.0, 10.0), + end: Rect.fromLTWH(10.0, 0.0, 10.0, 10.0) ); - expect(tween.lerp(0.5), equals(new Rect.fromLTWH(5.0, 0.0, 10.0, 10.0))); + expect(tween.lerp(0.5), equals(Rect.fromLTWH(5.0, 0.0, 10.0, 10.0))); }); test('MaterialPointArcTween', () { const Offset begin = Offset(180.0, 110.0); const Offset end = Offset(37.0, 250.0); - MaterialPointArcTween tween = new MaterialPointArcTween(begin: begin, end: end); + MaterialPointArcTween tween = MaterialPointArcTween(begin: begin, end: end); expect(tween.lerp(0.0), begin); expect(tween.lerp(0.25), within(distance: 2.0, from: const Offset(126.0, 120.0))); expect(tween.lerp(0.75), within(distance: 2.0, from: const Offset(48.0, 196.0))); expect(tween.lerp(1.0), end); - tween = new MaterialPointArcTween(begin: end, end: begin); + tween = MaterialPointArcTween(begin: end, end: begin); expect(tween.lerp(0.0), end); expect(tween.lerp(0.25), within(distance: 2.0, from: const Offset(91.0, 239.0))); expect(tween.lerp(0.75), within(distance: 2.0, from: const Offset(168.3, 163.8))); @@ -85,8 +85,8 @@ void main() { }); test('MaterialRectArcTween', () { - final Rect begin = new Rect.fromLTRB(180.0, 100.0, 330.0, 200.0); - final Rect end = new Rect.fromLTRB(32.0, 275.0, 132.0, 425.0); + final Rect begin = Rect.fromLTRB(180.0, 100.0, 330.0, 200.0); + final Rect end = Rect.fromLTRB(32.0, 275.0, 132.0, 425.0); bool sameRect(Rect a, Rect b) { return (a.left - b.left).abs() < 2.0 @@ -95,16 +95,16 @@ void main() { && (a.bottom - b.bottom).abs() < 2.0; } - MaterialRectArcTween tween = new MaterialRectArcTween(begin: begin, end: end); + MaterialRectArcTween tween = MaterialRectArcTween(begin: begin, end: end); expect(tween.lerp(0.0), begin); - expect(sameRect(tween.lerp(0.25), new Rect.fromLTRB(120.0, 113.0, 259.0, 237.0)), isTrue); - expect(sameRect(tween.lerp(0.75), new Rect.fromLTRB(42.3, 206.5, 153.5, 354.7)), isTrue); + expect(sameRect(tween.lerp(0.25), Rect.fromLTRB(120.0, 113.0, 259.0, 237.0)), isTrue); + expect(sameRect(tween.lerp(0.75), Rect.fromLTRB(42.3, 206.5, 153.5, 354.7)), isTrue); expect(tween.lerp(1.0), end); - tween = new MaterialRectArcTween(begin: end, end: begin); + tween = MaterialRectArcTween(begin: end, end: begin); expect(tween.lerp(0.0), end); - expect(sameRect(tween.lerp(0.25), new Rect.fromLTRB(92.0, 262.0, 203.0, 388.0)), isTrue); - expect(sameRect(tween.lerp(0.75), new Rect.fromLTRB(169.7, 168.5, 308.5, 270.3)), isTrue); + expect(sameRect(tween.lerp(0.25), Rect.fromLTRB(92.0, 262.0, 203.0, 388.0)), isTrue); + expect(sameRect(tween.lerp(0.75), Rect.fromLTRB(169.7, 168.5, 308.5, 270.3)), isTrue); expect(tween.lerp(1.0), begin); }); diff --git a/packages/flutter/test/material/back_button_test.dart b/packages/flutter/test/material/back_button_test.dart index 66b5ecac8c..3f50b7633c 100644 --- a/packages/flutter/test/material/back_button_test.dart +++ b/packages/flutter/test/material/back_button_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('BackButton control test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material(child: Text('Home')), routes: { '/next': (BuildContext context) { @@ -35,21 +35,21 @@ void main() { }); testWidgets('BackButton icon', (WidgetTester tester) async { - final Key iOSKey = new UniqueKey(); - final Key androidKey = new UniqueKey(); + final Key iOSKey = UniqueKey(); + final Key androidKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Column( + MaterialApp( + home: Column( children: [ - new Theme( - data: new ThemeData(platform: TargetPlatform.iOS), - child: new BackButtonIcon(key: iOSKey), + Theme( + data: ThemeData(platform: TargetPlatform.iOS), + child: BackButtonIcon(key: iOSKey), ), - new Theme( - data: new ThemeData(platform: TargetPlatform.android), - child: new BackButtonIcon(key: androidKey), + Theme( + data: ThemeData(platform: TargetPlatform.android), + child: BackButtonIcon(key: androidKey), ), ], ), @@ -64,7 +64,7 @@ void main() { testWidgets('BackButton semantics', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material(child: Text('Home')), routes: { '/next': (BuildContext context) { diff --git a/packages/flutter/test/material/bottom_app_bar_test.dart b/packages/flutter/test/material/bottom_app_bar_test.dart index 5c0d1de8ad..c783cc522b 100644 --- a/packages/flutter/test/material/bottom_app_bar_test.dart +++ b/packages/flutter/test/material/bottom_app_bar_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/rendering.dart'; void main() { testWidgets('no overlap with floating action button', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( floatingActionButton: FloatingActionButton( onPressed: null, @@ -25,7 +25,7 @@ void main() { final ShapeListenerState shapeListenerState = tester.state(find.byType(ShapeListener)); final RenderBox renderBox = tester.renderObject(find.byType(BottomAppBar)); - final Path expectedPath = new Path() + final Path expectedPath = Path() ..addRect(Offset.zero & renderBox.size); final Path actualPath = shapeListenerState.cache.value; @@ -40,10 +40,10 @@ void main() { testWidgets('color defaults to Theme.bottomAppBarColor', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Theme( + return Theme( data: Theme.of(context).copyWith(bottomAppBarColor: const Color(0xffffff00)), child: const Scaffold( floatingActionButton: FloatingActionButton( @@ -65,10 +65,10 @@ void main() { testWidgets('color overrides theme color', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Theme( + return Theme( data: Theme.of(context).copyWith(bottomAppBarColor: const Color(0xffffff00)), child: const Scaffold( floatingActionButton: FloatingActionButton( @@ -95,7 +95,7 @@ void main() { // _BottomAppBarClipper will try an illegal downcast. testWidgets('toggle shape to null', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: BottomAppBar( shape: RectangularNotch(), @@ -105,7 +105,7 @@ void main() { ); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: BottomAppBar( shape: null, @@ -115,7 +115,7 @@ void main() { ); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: BottomAppBar( shape: RectangularNotch(), @@ -127,7 +127,7 @@ void main() { testWidgets('no notch when notch param is null', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: ShapeListener(BottomAppBar( shape: null, @@ -143,7 +143,7 @@ void main() { final ShapeListenerState shapeListenerState = tester.state(find.byType(ShapeListener)); final RenderBox renderBox = tester.renderObject(find.byType(BottomAppBar)); - final Path expectedPath = new Path() + final Path expectedPath = Path() ..addRect(Offset.zero & renderBox.size); final Path actualPath = shapeListenerState.cache.value; @@ -159,7 +159,7 @@ void main() { testWidgets('notch no margin', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: ShapeListener( BottomAppBar( @@ -187,7 +187,7 @@ void main() { final double fabRight = fabLeft + fabSize.width; final double fabBottom = fabSize.height / 2.0; - final Path expectedPath = new Path() + final Path expectedPath = Path() ..moveTo(0.0, 0.0) ..lineTo(fabLeft, 0.0) ..lineTo(fabLeft, fabBottom) @@ -211,7 +211,7 @@ void main() { testWidgets('notch with margin', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: ShapeListener( BottomAppBar( @@ -239,7 +239,7 @@ void main() { final double fabRight = fabLeft + fabSize.width + 6.0; final double fabBottom = 6.0 + fabSize.height / 2.0; - final Path expectedPath = new Path() + final Path expectedPath = Path() ..moveTo(0.0, 0.0) ..lineTo(fabLeft, 0.0) ..lineTo(fabLeft, fabBottom) @@ -263,7 +263,7 @@ void main() { testWidgets('observes safe area', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const MediaQuery( data: MediaQueryData( padding: EdgeInsets.all(50.0), @@ -287,7 +287,7 @@ void main() { testWidgets('clipBehavior is propagated', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: BottomAppBar( @@ -303,7 +303,7 @@ void main() { expect(physicalShape.clipBehavior, Clip.none); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomNavigationBar: BottomAppBar( @@ -363,14 +363,14 @@ class ShapeListener extends StatefulWidget { final Widget child; @override - State createState() => new ShapeListenerState(); + State createState() => ShapeListenerState(); } class ShapeListenerState extends State { @override Widget build(BuildContext context) { - return new CustomPaint( + return CustomPaint( child: widget.child, painter: cache ); @@ -381,7 +381,7 @@ class ShapeListenerState extends State { @override void didChangeDependencies() { super.didChangeDependencies(); - cache = new ClipCachePainter(context); + cache = ClipCachePainter(context); } } @@ -391,7 +391,7 @@ class RectangularNotch implements NotchedShape { @override Path getOuterPath(Rect host, Rect guest) { - return new Path() + return Path() ..moveTo(host.left, host.top) ..lineTo(guest.left, host.top) ..lineTo(guest.left, guest.bottom) diff --git a/packages/flutter/test/material/bottom_navigation_bar_test.dart b/packages/flutter/test/material/bottom_navigation_bar_test.dart index 7e70e22cac..9acc86319d 100644 --- a/packages/flutter/test/material/bottom_navigation_bar_test.dart +++ b/packages/flutter/test/material/bottom_navigation_bar_test.dart @@ -15,9 +15,9 @@ void main() { int mutatedIndex; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( icon: Icon(Icons.ac_unit), @@ -43,9 +43,9 @@ void main() { testWidgets('BottomNavigationBar content test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( icon: Icon(Icons.ac_unit), @@ -69,11 +69,11 @@ void main() { testWidgets('BottomNavigationBar adds bottom padding to height', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new MediaQuery( + MaterialApp( + home: MediaQuery( data: const MediaQueryData(padding: EdgeInsets.only(bottom: 40.0)), - child: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + child: Scaffold( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( icon: Icon(Icons.ac_unit), @@ -98,9 +98,9 @@ void main() { testWidgets('BottomNavigationBar action size test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.shifting, items: const [ BottomNavigationBarItem( @@ -123,9 +123,9 @@ void main() { expect(actions.elementAt(1).size.width, 320.0); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( currentIndex: 1, type: BottomNavigationBarType.shifting, items: const [ @@ -153,9 +153,9 @@ void main() { testWidgets('BottomNavigationBar multiple taps test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.shifting, items: const [ BottomNavigationBarItem( @@ -211,12 +211,12 @@ void main() { testWidgets('BottomNavigationBar inherits shadowed app theme for shifting navbar', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.light), - home: new Theme( - data: new ThemeData(brightness: Brightness.dark), - child: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + theme: ThemeData(brightness: Brightness.light), + home: Theme( + data: ThemeData(brightness: Brightness.dark), + child: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.shifting, items: const [ BottomNavigationBarItem( @@ -249,12 +249,12 @@ void main() { testWidgets('BottomNavigationBar inherits shadowed app theme for fixed navbar', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.light), - home: new Theme( - data: new ThemeData(brightness: Brightness.dark), - child: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + theme: ThemeData(brightness: Brightness.light), + home: Theme( + data: ThemeData(brightness: Brightness.dark), + child: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, items: const [ BottomNavigationBarItem( @@ -288,21 +288,21 @@ void main() { testWidgets('BottomNavigationBar iconSize test', (WidgetTester tester) async { double builderIconSize; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( iconSize: 12.0, items: [ const BottomNavigationBarItem( title: Text('A'), icon: Icon(Icons.ac_unit), ), - new BottomNavigationBarItem( + BottomNavigationBarItem( title: const Text('B'), - icon: new Builder( + icon: Builder( builder: (BuildContext context) { builderIconSize = IconTheme.of(context).size; - return new SizedBox( + return SizedBox( width: builderIconSize, height: builderIconSize, ); @@ -324,9 +324,9 @@ void main() { testWidgets('BottomNavigationBar responds to textScaleFactor', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, items: const [ BottomNavigationBarItem( @@ -347,9 +347,9 @@ void main() { expect(defaultBox.size.height, equals(kBottomNavigationBarHeight)); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.shifting, items: const [ BottomNavigationBarItem( @@ -370,11 +370,11 @@ void main() { expect(shiftingBox.size.height, equals(kBottomNavigationBarHeight)); await tester.pumpWidget( - new MaterialApp( - home: new MediaQuery( + MaterialApp( + home: MediaQuery( data: const MediaQueryData(textScaleFactor: 2.0), - child: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + child: Scaffold( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( title: Text('A'), @@ -396,19 +396,19 @@ void main() { }); testWidgets('BottomNavigationBar limits width of tiles with long titles', (WidgetTester tester) async { - final Text longTextA = new Text(''.padLeft(100, 'A')); - final Text longTextB = new Text(''.padLeft(100, 'B')); + final Text longTextA = Text(''.padLeft(100, 'A')); + final Text longTextB = Text(''.padLeft(100, 'B')); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( items: [ - new BottomNavigationBarItem( + BottomNavigationBarItem( title: longTextA, icon: const Icon(Icons.ac_unit), ), - new BottomNavigationBarItem( + BottomNavigationBarItem( title: longTextB, icon: const Icon(Icons.battery_alert), ), @@ -431,7 +431,7 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.ltr, - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( title: Text('A'), @@ -463,7 +463,7 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.rtl, - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( title: Text('A'), @@ -505,7 +505,7 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.ltr, - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( currentIndex: selectedItem, items: const [ BottomNavigationBarItem( @@ -529,7 +529,7 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.ltr, - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( currentIndex: selectedItem, items: const [ BottomNavigationBarItem( @@ -551,12 +551,12 @@ void main() { }); testWidgets('BottomNavigationBar.fixed semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( boilerplate( textDirection: TextDirection.ltr, - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem( icon: Icon(Icons.ac_unit), @@ -575,13 +575,13 @@ void main() { ), ); - final TestSemantics expected = new TestSemantics.root( + final TestSemantics expected = TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isSelected, SemanticsFlag.isHeader, @@ -590,7 +590,7 @@ void main() { label: 'AC\nTab 1 of 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHeader, ], @@ -598,7 +598,7 @@ void main() { label: 'Alarm\nTab 2 of 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHeader, ], @@ -618,12 +618,12 @@ void main() { }); testWidgets('BottomNavigationBar.shifting semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( boilerplate( textDirection: TextDirection.ltr, - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.shifting, items: const [ BottomNavigationBarItem( @@ -643,13 +643,13 @@ void main() { ), ); - final TestSemantics expected = new TestSemantics.root( + final TestSemantics expected = TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isSelected, SemanticsFlag.isHeader, @@ -658,7 +658,7 @@ void main() { label: 'AC\nTab 1 of 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHeader, ], @@ -666,7 +666,7 @@ void main() { label: 'Alarm\nTab 2 of 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHeader, ], @@ -689,15 +689,15 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/10322 Widget buildFrame(int itemCount) { - return new MaterialApp( - home: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + return MaterialApp( + home: Scaffold( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.fixed, currentIndex: 0, - items: new List.generate(itemCount, (int itemIndex) { - return new BottomNavigationBarItem( + items: List.generate(itemCount, (int itemIndex) { + return BottomNavigationBarItem( icon: const Icon(Icons.android), - title: new Text('item $itemIndex'), + title: Text('item $itemIndex'), ); }), ), @@ -730,12 +730,12 @@ void main() { Color _backgroundColor = Colors.red; await tester.pumpWidget( - new MaterialApp( - home: new StatefulBuilder( + MaterialApp( + home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Scaffold( - body: new Center( - child: new RaisedButton( + return Scaffold( + body: Center( + child: RaisedButton( child: const Text('green'), onPressed: () { setState(() { @@ -744,15 +744,15 @@ void main() { }, ), ), - bottomNavigationBar: new BottomNavigationBar( + bottomNavigationBar: BottomNavigationBar( type: BottomNavigationBarType.shifting, items: [ - new BottomNavigationBarItem( + BottomNavigationBarItem( title: const Text('Page 1'), backgroundColor: _backgroundColor, icon: const Icon(Icons.dashboard), ), - new BottomNavigationBarItem( + BottomNavigationBarItem( title: const Text('Page 2'), backgroundColor: _backgroundColor, icon: const Icon(Icons.menu), @@ -785,18 +785,18 @@ void main() { Widget boilerplate({ Widget bottomNavigationBar, @required TextDirection textDirection }) { assert(textDirection != null); - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child: new Directionality( + child: Directionality( textDirection: textDirection, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Material( - child: new Scaffold( + child: Material( + child: Scaffold( bottomNavigationBar: bottomNavigationBar, ), ), diff --git a/packages/flutter/test/material/button_theme_test.dart b/packages/flutter/test/material/button_theme_test.dart index 87a6cd5dad..ff6749254f 100644 --- a/packages/flutter/test/material/button_theme_test.dart +++ b/packages/flutter/test/material/button_theme_test.dart @@ -40,15 +40,15 @@ void main() { ShapeBorder shape; await tester.pumpWidget( - new ButtonTheme( - child: new Builder( + ButtonTheme( + child: Builder( builder: (BuildContext context) { final ButtonThemeData theme = ButtonTheme.of(context); textTheme = theme.textTheme; constraints = theme.constraints; padding = theme.padding; shape = theme.shape; - return new Container( + return Container( alignment: Alignment.topLeft, child: const Directionality( textDirection: TextDirection.ltr, @@ -100,14 +100,14 @@ void main() { }); testWidgets('Theme buttonTheme defaults', (WidgetTester tester) async { - final ThemeData lightTheme = new ThemeData.light(); + final ThemeData lightTheme = ThemeData.light(); ButtonTextTheme textTheme; BoxConstraints constraints; EdgeInsets padding; ShapeBorder shape; await tester.pumpWidget( - new Theme( + Theme( data: lightTheme.copyWith( disabledColor: const Color(0xFF00FF00), // disabled RaisedButton fill color textTheme: lightTheme.textTheme.copyWith( @@ -118,14 +118,14 @@ void main() { ), ), ), - child: new Builder( + child: Builder( builder: (BuildContext context) { final ButtonThemeData theme = ButtonTheme.of(context); textTheme = theme.textTheme; constraints = theme.constraints; padding = theme.padding; shape = theme.shape; - return new Container( + return Container( alignment: Alignment.topLeft, child: const Directionality( textDirection: TextDirection.ltr, @@ -159,28 +159,28 @@ void main() { ShapeBorder shape; await tester.pumpWidget( - new Theme( - data: new ThemeData.light().copyWith( + Theme( + data: ThemeData.light().copyWith( buttonColor: const Color(0xFF00FF00), // enabled RaisedButton fill color ), - child: new ButtonTheme( + child: ButtonTheme( textTheme: ButtonTextTheme.primary, minWidth: 100.0, height: 200.0, padding: EdgeInsets.zero, shape: const RoundedRectangleBorder(), - child: new Builder( + child: Builder( builder: (BuildContext context) { final ButtonThemeData theme = ButtonTheme.of(context); textTheme = theme.textTheme; constraints = theme.constraints; padding = theme.padding; shape = theme.shape; - return new Container( + return Container( alignment: Alignment.topLeft, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new RaisedButton( + child: RaisedButton( onPressed: () { }, child: const Text('b'), // intrinsic width < minimum width ), @@ -203,27 +203,27 @@ void main() { }); testWidgets('ButtonTheme alignedDropdown', (WidgetTester tester) async { - final Key dropdownKey = new UniqueKey(); + final Key dropdownKey = UniqueKey(); Widget buildFrame({ bool alignedDropdown, TextDirection textDirection }) { - return new MaterialApp( + return MaterialApp( builder: (BuildContext context, Widget child) { - return new Directionality( + return Directionality( textDirection: textDirection, child: child, ); }, - home: new ButtonTheme( + home: ButtonTheme( alignedDropdown: alignedDropdown, - child: new Material( - child: new Builder( + child: Material( + child: Builder( builder: (BuildContext context) { - return new Container( + return Container( alignment: Alignment.center, - child: new DropdownButtonHideUnderline( - child: new Container( + child: DropdownButtonHideUnderline( + child: Container( width: 200.0, - child: new DropdownButton( + child: DropdownButton( key: dropdownKey, onChanged: (String value) { }, value: 'foo', diff --git a/packages/flutter/test/material/buttons_test.dart b/packages/flutter/test/material/buttons_test.dart index a99ea298e4..8d4d7f2c5c 100644 --- a/packages/flutter/test/material/buttons_test.dart +++ b/packages/flutter/test/material/buttons_test.dart @@ -16,13 +16,13 @@ void main() { }); testWidgets('Does FlatButton contribute semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new FlatButton( + child: Material( + child: Center( + child: FlatButton( onPressed: () { }, child: const Text('ABC') ), @@ -32,15 +32,15 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( actions: [ SemanticsAction.tap, ], label: 'ABC', - rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), - transform: new Matrix4.translationValues(356.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), + transform: Matrix4.translationValues(356.0, 276.0, 0.0), flags: [ SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, @@ -56,13 +56,13 @@ void main() { }); testWidgets('Does RaisedButton contribute semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new RaisedButton( + child: Material( + child: Center( + child: RaisedButton( onPressed: () { }, child: const Text('ABC') ), @@ -72,15 +72,15 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( actions: [ SemanticsAction.tap, ], label: 'ABC', - rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), - transform: new Matrix4.translationValues(356.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), + transform: Matrix4.translationValues(356.0, 276.0, 0.0), flags: [ SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, @@ -97,13 +97,13 @@ void main() { testWidgets('Does FlatButton scale with font scale changes', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new MediaQuery( + child: Material( + child: MediaQuery( data: const MediaQueryData(textScaleFactor: 1.0), - child: new Center( - child: new FlatButton( + child: Center( + child: FlatButton( onPressed: () { }, child: const Text('ABC'), ), @@ -118,13 +118,13 @@ void main() { // textScaleFactor expands text, but not button. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new MediaQuery( + child: Material( + child: MediaQuery( data: const MediaQueryData(textScaleFactor: 1.3), - child: new Center( - child: new FlatButton( + child: Center( + child: FlatButton( onPressed: () { }, child: const Text('ABC'), ), @@ -142,13 +142,13 @@ void main() { // Set text scale large enough to expand text and button. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new MediaQuery( + child: Material( + child: MediaQuery( data: const MediaQueryData(textScaleFactor: 3.0), - child: new Center( - child: new FlatButton( + child: Center( + child: FlatButton( onPressed: () { }, child: const Text('ABC'), ), @@ -172,9 +172,9 @@ void main() { const Color directSplashColor = Color(0xFF000011); const Color directHighlightColor = Color(0xFF000011); - Widget buttonWidget = new Material( - child: new Center( - child: new MaterialButton( + Widget buttonWidget = Material( + child: Center( + child: MaterialButton( splashColor: directSplashColor, highlightColor: directHighlightColor, onPressed: () { /* to make sure the button is enabled */ }, @@ -184,10 +184,10 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData( + child: Theme( + data: ThemeData( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), child: buttonWidget, @@ -200,9 +200,9 @@ void main() { await tester.pump(); // start gesture await tester.pump(const Duration(milliseconds: 200)); // wait for splash to be well under way - final Rect expectedClipRect = new Rect.fromLTRB(356.0, 282.0, 444.0, 318.0); - final Path expectedClipPath = new Path() - ..addRRect(new RRect.fromRectAndRadius( + final Rect expectedClipRect = Rect.fromLTRB(356.0, 282.0, 444.0, 318.0); + final Path expectedClipPath = Path() + ..addRRect(RRect.fromRectAndRadius( expectedClipRect, const Radius.circular(2.0), )); @@ -220,9 +220,9 @@ void main() { const Color themeSplashColor1 = Color(0xFF001100); const Color themeHighlightColor1 = Color(0xFF001100); - buttonWidget = new Material( - child: new Center( - child: new MaterialButton( + buttonWidget = Material( + child: Center( + child: MaterialButton( onPressed: () { /* to make sure the button is enabled */ }, clipBehavior: Clip.antiAlias, ), @@ -230,10 +230,10 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData( + child: Theme( + data: ThemeData( highlightColor: themeHighlightColor1, splashColor: themeSplashColor1, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, @@ -258,10 +258,10 @@ void main() { const Color themeHighlightColor2 = Color(0xFF002200); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData( + child: Theme( + data: ThemeData( highlightColor: themeHighlightColor2, splashColor: themeSplashColor2, materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, @@ -282,10 +282,10 @@ void main() { }); testWidgets('MaterialButton has no clip by default', (WidgetTester tester) async { - final GlobalKey buttonKey = new GlobalKey(); - final Widget buttonWidget = new Material( - child: new Center( - child: new MaterialButton( + final GlobalKey buttonKey = GlobalKey(); + final Widget buttonWidget = Material( + child: Center( + child: MaterialButton( key: buttonKey, onPressed: () { /* to make sure the button is enabled */ }, ), @@ -293,10 +293,10 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData( + child: Theme( + data: ThemeData( materialTapTargetSize: MaterialTapTargetSize.shrinkWrap, ), child: buttonWidget, @@ -331,22 +331,22 @@ void main() { }); testWidgets('Disabled MaterialButton has same semantic size as enabled and exposes disabled semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final Rect expectedButtonSize = new Rect.fromLTRB(0.0, 0.0, 116.0, 48.0); + final Rect expectedButtonSize = Rect.fromLTRB(0.0, 0.0, 116.0, 48.0); // Button is in center of screen - final Matrix4 expectedButtonTransform = new Matrix4.identity() + final Matrix4 expectedButtonTransform = Matrix4.identity() ..translate( TestSemantics.fullScreen.width / 2 - expectedButtonSize.width /2, TestSemantics.fullScreen.height / 2 - expectedButtonSize.height /2, ); // enabled button - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new MaterialButton( + child: Material( + child: Center( + child: MaterialButton( child: const Text('Button'), onPressed: () { /* to make sure the button is enabled */ }, ), @@ -355,9 +355,9 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: expectedButtonSize, transform: expectedButtonTransform, @@ -389,9 +389,9 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: expectedButtonSize, transform: expectedButtonTransform, @@ -410,15 +410,15 @@ void main() { }); testWidgets('MaterialButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); + final Key key1 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new MaterialButton( + child: Material( + child: Center( + child: MaterialButton( key: key1, child: const SizedBox(width: 50.0, height: 8.0), onPressed: () {}, @@ -431,15 +431,15 @@ void main() { expect(tester.getSize(find.byKey(key1)), const Size(88.0, 48.0)); - final Key key2 = new UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new MaterialButton( + child: Material( + child: Center( + child: MaterialButton( key: key2, child: const SizedBox(width: 50.0, height: 8.0), onPressed: () {}, @@ -454,15 +454,15 @@ void main() { }); testWidgets('FlatButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); + final Key key1 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new FlatButton( + child: Material( + child: Center( + child: FlatButton( key: key1, child: const SizedBox(width: 50.0, height: 8.0), onPressed: () {}, @@ -475,15 +475,15 @@ void main() { expect(tester.getSize(find.byKey(key1)), const Size(88.0, 48.0)); - final Key key2 = new UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new FlatButton( + child: Material( + child: Center( + child: FlatButton( key: key2, child: const SizedBox(width: 50.0, height: 8.0), onPressed: () {}, @@ -498,15 +498,15 @@ void main() { }); testWidgets('RaisedButton size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); + final Key key1 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new RaisedButton( + child: Material( + child: Center( + child: RaisedButton( key: key1, child: const SizedBox(width: 50.0, height: 8.0), onPressed: () {}, @@ -519,15 +519,15 @@ void main() { expect(tester.getSize(find.byKey(key1)), const Size(88.0, 48.0)); - final Key key2 = new UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new RaisedButton( + child: Material( + child: Center( + child: RaisedButton( key: key2, child: const SizedBox(width: 50.0, height: 8.0), onPressed: () {}, @@ -543,10 +543,10 @@ void main() { testWidgets('RaisedButton has no clip by default', (WidgetTester tester) async{ await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new RaisedButton( + child: Material( + child: RaisedButton( onPressed: () { /* to make sure the button is enabled */ }, ), ) diff --git a/packages/flutter/test/material/card_test.dart b/packages/flutter/test/material/card_test.dart index cbb84cfb8f..e396775c9b 100644 --- a/packages/flutter/test/material/card_test.dart +++ b/packages/flutter/test/material/card_test.dart @@ -11,19 +11,19 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Card can take semantic text from multiple children', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Card( + child: Material( + child: Center( + child: Card( semanticContainer: false, - child: new Column( + child: Column( children: [ const Text('I am text!'), const Text('Moar text!!1'), - new MaterialButton( + MaterialButton( child: const Text('Button'), onPressed: () { }, ) @@ -36,19 +36,19 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, label: 'I am text!', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 2, label: 'Moar text!!1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 3, label: 'Button', textDirection: TextDirection.ltr, @@ -71,17 +71,17 @@ void main() { }); testWidgets('Card merges children when it is a semanticContainer', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); debugResetSemanticsIdCounter(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Card( + child: Material( + child: Center( + child: Card( semanticContainer: true, - child: new Column( + child: Column( children: const [ Text('First child'), Text('Second child') @@ -94,9 +94,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, label: 'First child\nSecond child', textDirection: TextDirection.ltr, @@ -114,10 +114,10 @@ void main() { const Key contentsKey = ValueKey('contents'); await tester.pumpWidget( - new Container( + Container( alignment: Alignment.topLeft, - child: new Card( - child: new Container( + child: Card( + child: Container( key: contentsKey, color: const Color(0xFF00FF00), width: 100.0, @@ -135,11 +135,11 @@ void main() { expect(tester.getSize(find.byKey(contentsKey)), const Size(100.0, 100.0)); await tester.pumpWidget( - new Container( + Container( alignment: Alignment.topLeft, - child: new Card( + child: Card( margin: EdgeInsets.zero, - child: new Container( + child: Container( key: contentsKey, color: const Color(0xFF00FF00), width: 100.0, diff --git a/packages/flutter/test/material/checkbox_test.dart b/packages/flutter/test/material/checkbox_test.dart index 4fea49fb56..3d3a64e852 100644 --- a/packages/flutter/test/material/checkbox_test.dart +++ b/packages/flutter/test/material/checkbox_test.dart @@ -18,13 +18,13 @@ void main() { testWidgets('Checkbox size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Checkbox( + child: Material( + child: Center( + child: Checkbox( value: true, onChanged: (bool newValue) {}, ), @@ -37,13 +37,13 @@ void main() { expect(tester.getSize(find.byType(Checkbox)), const Size(48.0, 48.0)); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Checkbox( + child: Material( + child: Center( + child: Checkbox( value: true, onChanged: (bool newValue) {}, ), @@ -59,8 +59,8 @@ void main() { testWidgets('CheckBox semantics', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new Material( - child: new Checkbox( + await tester.pumpWidget(Material( + child: Checkbox( value: false, onChanged: (bool b) { }, ), @@ -73,8 +73,8 @@ void main() { hasTapAction: true, )); - await tester.pumpWidget(new Material( - child: new Checkbox( + await tester.pumpWidget(Material( + child: Checkbox( value: true, onChanged: (bool b) { }, ), @@ -118,11 +118,11 @@ void main() { testWidgets('Can wrap CheckBox with Semantics', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new Material( - child: new Semantics( + await tester.pumpWidget(Material( + child: Semantics( label: 'foo', textDirection: TextDirection.ltr, - child: new Checkbox( + child: Checkbox( value: false, onChanged: (bool b) { }, ), @@ -144,10 +144,10 @@ void main() { bool checkBoxValue; await tester.pumpWidget( - new Material( - child: new StatefulBuilder( + Material( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Checkbox( + return Checkbox( tristate: true, value: checkBoxValue, onChanged: (bool value) { @@ -185,10 +185,10 @@ void main() { }); testWidgets('has semantics for tristate', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Material( - child: new Checkbox( + Material( + child: Checkbox( tristate: true, value: null, onChanged: (bool newValue) {}, @@ -206,8 +206,8 @@ void main() { ), hasLength(1)); await tester.pumpWidget( - new Material( - child: new Checkbox( + Material( + child: Checkbox( tristate: true, value: true, onChanged: (bool newValue) {}, @@ -226,8 +226,8 @@ void main() { ), hasLength(1)); await tester.pumpWidget( - new Material( - child: new Checkbox( + Material( + child: Checkbox( tristate: true, value: false, onChanged: (bool newValue) {}, @@ -253,13 +253,13 @@ void main() { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { semanticEvent = message; }); - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); await tester.pumpWidget( - new Material( - child: new StatefulBuilder( + Material( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Checkbox( + return Checkbox( value: checkboxValue, onChanged: (bool value) { setState(() { diff --git a/packages/flutter/test/material/chip_test.dart b/packages/flutter/test/material/chip_test.dart index a220772c98..082e8aed30 100644 --- a/packages/flutter/test/material/chip_test.dart +++ b/packages/flutter/test/material/chip_test.dart @@ -66,12 +66,12 @@ Widget _wrapForChip({ TextDirection textDirection = TextDirection.ltr, double textScaleFactor = 1.0, }) { - return new MaterialApp( - home: new Directionality( + return MaterialApp( + home: Directionality( textDirection: textDirection, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window).copyWith(textScaleFactor: textScaleFactor), - child: new Material(child: child), + child: MediaQuery( + data: MediaQueryData.fromWindow(window).copyWith(textScaleFactor: textScaleFactor), + child: Material(child: child), ), ), ); @@ -90,17 +90,17 @@ Future _testConstrainedLabel( const double labelHeight = 50.0; const double chipParentWidth = 75.0; const double chipParentHeight = 25.0; - final Key labelKey = new UniqueKey(); + final Key labelKey = UniqueKey(); await tester.pumpWidget( _wrapForChip( - child: new Center( - child: new Container( + child: Center( + child: Container( width: chipParentWidth, height: chipParentHeight, - child: new Chip( + child: Chip( avatar: avatar, - label: new Container( + label: Container( key: labelKey, width: labelWidth, height: labelHeight, @@ -123,13 +123,13 @@ Future _testConstrainedLabel( void main() { testWidgets('Chip control test', (WidgetTester tester) async { - final FeedbackTester feedback = new FeedbackTester(); + final FeedbackTester feedback = FeedbackTester(); final List deletedChipLabels = []; await tester.pumpWidget( _wrapForChip( - child: new Column( + child: Column( children: [ - new Chip( + Chip( avatar: const CircleAvatar(child: Text('A')), label: const Text('Chip A'), onDeleted: () { @@ -137,7 +137,7 @@ void main() { }, deleteButtonTooltipMessage: 'Delete chip A', ), - new Chip( + Chip( avatar: const CircleAvatar(child: Text('B')), label: const Text('Chip B'), onDeleted: () { @@ -176,18 +176,18 @@ void main() { 'the available space', (WidgetTester tester) async { const double labelWidth = 50.0; const double labelHeight = 30.0; - final Key labelKey = new UniqueKey(); + final Key labelKey = UniqueKey(); await tester.pumpWidget( _wrapForChip( - child: new Center( - child: new Container( + child: Center( + child: Container( width: 500.0, height: 500.0, - child: new Column( + child: Column( children: [ - new Chip( - label: new Container( + Chip( + label: Container( key: labelKey, width: labelWidth, height: labelHeight, @@ -243,7 +243,7 @@ void main() { const TextStyle style = TextStyle(fontFamily: 'Ahem', fontSize: 10.0); await tester.pumpWidget( _wrapForChip( - child: new Row( + child: Row( children: const [ Chip(label: Text('Test'), labelStyle: style), ], @@ -254,7 +254,7 @@ void main() { expect(tester.getSize(find.byType(Chip)), const Size(64.0,48.0)); await tester.pumpWidget( _wrapForChip( - child: new Row( + child: Row( children: const [ Flexible(child: Chip(label: Text('Test'), labelStyle: style)), ], @@ -265,7 +265,7 @@ void main() { expect(tester.getSize(find.byType(Chip)), const Size(64.0, 48.0)); await tester.pumpWidget( _wrapForChip( - child: new Row( + child: Row( children: const [ Expanded(child: Chip(label: Text('Test'), labelStyle: style)), ], @@ -277,14 +277,14 @@ void main() { }); testWidgets('Chip elements are ordered horizontally for locale', (WidgetTester tester) async { - final UniqueKey iconKey = new UniqueKey(); - final Widget test = new Overlay( + final UniqueKey iconKey = UniqueKey(); + final Widget test = Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Material( - child: new Chip( - deleteIcon: new Icon(Icons.delete, key: iconKey), + return Material( + child: Chip( + deleteIcon: Icon(Icons.delete, key: iconKey), onDeleted: () {}, label: const Text('ABC'), ), @@ -315,7 +315,7 @@ void main() { testWidgets('Chip responds to textScaleFactor', (WidgetTester tester) async { await tester.pumpWidget( _wrapForChip( - child: new Column( + child: Column( children: const [ Chip( avatar: CircleAvatar(child: Text('A')), @@ -346,7 +346,7 @@ void main() { await tester.pumpWidget( _wrapForChip( textScaleFactor: 3.0, - child: new Column( + child: Column( children: const [ Chip( avatar: CircleAvatar(child: Text('A')), @@ -373,7 +373,7 @@ void main() { // Check that individual text scales are taken into account. await tester.pumpWidget( _wrapForChip( - child: new Column( + child: Column( children: const [ Chip( avatar: CircleAvatar(child: Text('A')), @@ -398,19 +398,19 @@ void main() { }); testWidgets('Labels can be non-text widgets', (WidgetTester tester) async { - final Key keyA = new GlobalKey(); - final Key keyB = new GlobalKey(); + final Key keyA = GlobalKey(); + final Key keyB = GlobalKey(); await tester.pumpWidget( _wrapForChip( - child: new Column( + child: Column( children: [ - new Chip( + Chip( avatar: const CircleAvatar(child: Text('A')), - label: new Text('Chip A', key: keyA), + label: Text('Chip A', key: keyA), ), - new Chip( + Chip( avatar: const CircleAvatar(child: Text('B')), - label: new Container(key: keyB, width: 10.0, height: 10.0), + label: Container(key: keyB, width: 10.0, height: 10.0), ), ], ), @@ -432,13 +432,13 @@ void main() { }); testWidgets('Avatars can be non-circle avatar widgets', (WidgetTester tester) async { - final Key keyA = new GlobalKey(); + final Key keyA = GlobalKey(); await tester.pumpWidget( _wrapForChip( - child: new Column( + child: Column( children: [ - new Chip( - avatar: new Container(key: keyA, width: 20.0, height: 20.0), + Chip( + avatar: Container(key: keyA, width: 20.0, height: 20.0), label: const Text('Chip A'), ), ], @@ -450,13 +450,13 @@ void main() { }); testWidgets('Delete icons can be non-icon widgets', (WidgetTester tester) async { - final Key keyA = new GlobalKey(); + final Key keyA = GlobalKey(); await tester.pumpWidget( _wrapForChip( - child: new Column( + child: Column( children: [ - new Chip( - deleteIcon: new Container(key: keyA, width: 20.0, height: 20.0), + Chip( + deleteIcon: Container(key: keyA, width: 20.0, height: 20.0), label: const Text('Chip A'), onDeleted: () {}, ), @@ -469,20 +469,20 @@ void main() { }); testWidgets('Chip padding - LTR', (WidgetTester tester) async { - final GlobalKey keyA = new GlobalKey(); - final GlobalKey keyB = new GlobalKey(); + final GlobalKey keyA = GlobalKey(); + final GlobalKey keyB = GlobalKey(); await tester.pumpWidget( _wrapForChip( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Material( - child: new Center( - child: new Chip( - avatar: new Placeholder(key: keyA), - label: new Container( + return Material( + child: Center( + child: Chip( + avatar: Placeholder(key: keyA), + label: Container( key: keyB, width: 40.0, height: 40.0, @@ -506,20 +506,20 @@ void main() { }); testWidgets('Chip padding - RTL', (WidgetTester tester) async { - final GlobalKey keyA = new GlobalKey(); - final GlobalKey keyB = new GlobalKey(); + final GlobalKey keyA = GlobalKey(); + final GlobalKey keyB = GlobalKey(); await tester.pumpWidget( _wrapForChip( textDirection: TextDirection.rtl, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Material( - child: new Center( - child: new Chip( - avatar: new Placeholder(key: keyA), - label: new Container( + return Material( + child: Center( + child: Chip( + avatar: Placeholder(key: keyA), + label: Container( key: keyB, width: 40.0, height: 40.0, @@ -544,15 +544,15 @@ void main() { }); testWidgets('Avatar drawer works as expected on RawChip', (WidgetTester tester) async { - final GlobalKey labelKey = new GlobalKey(); + final GlobalKey labelKey = GlobalKey(); Future pushChip({Widget avatar}) async { return tester.pumpWidget( _wrapForChip( - child: new Wrap( + child: Wrap( children: [ - new RawChip( + RawChip( avatar: avatar, - label: new Text('Chip', key: labelKey), + label: Text('Chip', key: labelKey), shape: const StadiumBorder(), ), ], @@ -564,11 +564,11 @@ void main() { // No avatar await pushChip(); expect(tester.getSize(find.byType(RawChip)), equals(const Size(80.0, 48.0))); - final GlobalKey avatarKey = new GlobalKey(); + final GlobalKey avatarKey = GlobalKey(); // Add an avatar await pushChip( - avatar: new Container( + avatar: Container( key: avatarKey, color: const Color(0xff000000), width: 40.0, @@ -656,16 +656,16 @@ void main() { }); testWidgets('Delete button drawer works as expected on RawChip', (WidgetTester tester) async { - final UniqueKey labelKey = new UniqueKey(); - final UniqueKey deleteButtonKey = new UniqueKey(); + final UniqueKey labelKey = UniqueKey(); + final UniqueKey deleteButtonKey = UniqueKey(); bool wasDeleted = false; Future pushChip({bool deletable = false}) async { return tester.pumpWidget( _wrapForChip( - child: new Wrap( + child: Wrap( children: [ - new StatefulBuilder(builder: (BuildContext context, StateSetter setState) { - return new RawChip( + StatefulBuilder(builder: (BuildContext context, StateSetter setState) { + return RawChip( onDeleted: deletable ? () { setState(() { @@ -673,8 +673,8 @@ void main() { }); } : null, - deleteIcon: new Container(width: 40.0, height: 40.0, key: deleteButtonKey), - label: new Text('Chip', key: labelKey), + deleteIcon: Container(width: 40.0, height: 40.0, key: deleteButtonKey), + label: Text('Chip', key: labelKey), shape: const StadiumBorder(), ); }), @@ -773,14 +773,14 @@ void main() { testWidgets('Selection with avatar works as expected on RawChip', (WidgetTester tester) async { bool selected = false; - final UniqueKey labelKey = new UniqueKey(); + final UniqueKey labelKey = UniqueKey(); Future pushChip({Widget avatar, bool selectable = false}) async { return tester.pumpWidget( _wrapForChip( - child: new Wrap( + child: Wrap( children: [ - new StatefulBuilder(builder: (BuildContext context, StateSetter setState) { - return new RawChip( + StatefulBuilder(builder: (BuildContext context, StateSetter setState) { + return RawChip( avatar: avatar, onSelected: selectable != null ? (bool value) { @@ -790,7 +790,7 @@ void main() { } : null, selected: selected, - label: new Text('Chip', key: labelKey), + label: Text('Chip', key: labelKey), shape: const StadiumBorder(), showCheckmark: true, tapEnabled: true, @@ -804,15 +804,15 @@ void main() { } // With avatar, but not selectable. - final UniqueKey avatarKey = new UniqueKey(); + final UniqueKey avatarKey = UniqueKey(); await pushChip( - avatar: new Container(width: 40.0, height: 40.0, key: avatarKey), + avatar: Container(width: 40.0, height: 40.0, key: avatarKey), ); expect(tester.getSize(find.byType(RawChip)), equals(const Size(104.0, 48.0))); // Turn on selection. await pushChip( - avatar: new Container(width: 40.0, height: 40.0, key: avatarKey), + avatar: Container(width: 40.0, height: 40.0, key: avatarKey), selectable: true, ); await tester.pumpAndSettle(); @@ -856,14 +856,14 @@ void main() { testWidgets('Selection without avatar works as expected on RawChip', (WidgetTester tester) async { bool selected = false; - final UniqueKey labelKey = new UniqueKey(); + final UniqueKey labelKey = UniqueKey(); Future pushChip({bool selectable = false}) async { return tester.pumpWidget( _wrapForChip( - child: new Wrap( + child: Wrap( children: [ - new StatefulBuilder(builder: (BuildContext context, StateSetter setState) { - return new RawChip( + StatefulBuilder(builder: (BuildContext context, StateSetter setState) { + return RawChip( onSelected: selectable != null ? (bool value) { setState(() { @@ -872,7 +872,7 @@ void main() { } : null, selected: selected, - label: new Text('Chip', key: labelKey), + label: Text('Chip', key: labelKey), shape: const StadiumBorder(), showCheckmark: true, tapEnabled: true, @@ -932,14 +932,14 @@ void main() { testWidgets('Activation works as expected on RawChip', (WidgetTester tester) async { bool selected = false; - final UniqueKey labelKey = new UniqueKey(); + final UniqueKey labelKey = UniqueKey(); Future pushChip({Widget avatar, bool selectable = false}) async { return tester.pumpWidget( _wrapForChip( - child: new Wrap( + child: Wrap( children: [ - new StatefulBuilder(builder: (BuildContext context, StateSetter setState) { - return new RawChip( + StatefulBuilder(builder: (BuildContext context, StateSetter setState) { + return RawChip( avatar: avatar, onSelected: selectable != null ? (bool value) { @@ -949,7 +949,7 @@ void main() { } : null, selected: selected, - label: new Text('Chip', key: labelKey), + label: Text('Chip', key: labelKey), shape: const StadiumBorder(), showCheckmark: false, tapEnabled: true, @@ -962,9 +962,9 @@ void main() { ); } - final UniqueKey avatarKey = new UniqueKey(); + final UniqueKey avatarKey = UniqueKey(); await pushChip( - avatar: new Container(width: 40.0, height: 40.0, key: avatarKey), + avatar: Container(width: 40.0, height: 40.0, key: avatarKey), selectable: true, ); await tester.pumpAndSettle(); @@ -989,7 +989,7 @@ void main() { }); testWidgets('Chip uses ThemeData chip theme if present', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, ); @@ -998,7 +998,7 @@ void main() { Widget buildChip(ChipThemeData data) { return _wrapForChip( textDirection: TextDirection.ltr, - child: new Theme( + child: Theme( data: theme, child: const InputChip( label: Text('Label'), @@ -1020,13 +1020,13 @@ void main() { }); testWidgets('Chip size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); + final Key key1 = UniqueKey(); await tester.pumpWidget( _wrapForChip( - child: new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Center( - child: new RawChip( + child: Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Center( + child: RawChip( key: key1, label: const Text('test'), ), @@ -1037,13 +1037,13 @@ void main() { expect(tester.getSize(find.byKey(key1)), const Size(80.0, 48.0)); - final Key key2 = new UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( _wrapForChip( - child: new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Center( - child: new RawChip( + child: Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Center( + child: RawChip( key: key2, label: const Text('test'), ), @@ -1056,7 +1056,7 @@ void main() { }); testWidgets('Chip uses the right theme colors for the right components', (WidgetTester tester) async { - final ThemeData themeData = new ThemeData( + final ThemeData themeData = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.blue, ); @@ -1073,12 +1073,12 @@ void main() { }) { chipTheme ??= defaultChipTheme; return _wrapForChip( - child: new Theme( + child: Theme( data: themeData, - child: new ChipTheme( + child: ChipTheme( data: chipTheme, - child: new StatefulBuilder(builder: (BuildContext context, StateSetter setState) { - return new RawChip( + child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { + return RawChip( showCheckmark: showCheckmark, onDeleted: isDeletable ? () {} : null, tapEnabled: true, @@ -1087,7 +1087,7 @@ void main() { isEnabled: isSelectable || isPressable, shape: chipTheme.shape, selected: isSelectable ? value : null, - label: new Text('$value'), + label: Text('$value'), onSelected: isSelectable ? (bool newValue) { setState(() { @@ -1179,9 +1179,9 @@ void main() { group('Chip semantics', () { testWidgets('label only', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: const Material( child: RawChip( label: Text('test'), @@ -1190,15 +1190,15 @@ void main() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'test', textDirection: TextDirection.ltr, ), @@ -1212,11 +1212,11 @@ void main() { }); testWidgets('with onPressed', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new RawChip( + await tester.pumpWidget(MaterialApp( + home: Material( + child: RawChip( label: const Text('test'), onPressed: () {}, ), @@ -1224,15 +1224,15 @@ void main() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'test', textDirection: TextDirection.ltr, flags: [ @@ -1253,12 +1253,12 @@ void main() { testWidgets('with onSelected', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); bool selected = false; - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new RawChip( + await tester.pumpWidget(MaterialApp( + home: Material( + child: RawChip( isEnabled: true, label: const Text('test'), selected: selected, @@ -1270,15 +1270,15 @@ void main() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'test', textDirection: TextDirection.ltr, flags: [ @@ -1295,9 +1295,9 @@ void main() { ), ignoreTransform: true, ignoreId: true, ignoreRect: true)); await tester.tap(find.byType(RawChip)); - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new RawChip( + await tester.pumpWidget(MaterialApp( + home: Material( + child: RawChip( isEnabled: true, label: const Text('test'), selected: selected, @@ -1310,15 +1310,15 @@ void main() { expect(selected, true); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'test', textDirection: TextDirection.ltr, flags: [ @@ -1339,11 +1339,11 @@ void main() { }); testWidgets('disabled', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new RawChip( + await tester.pumpWidget(MaterialApp( + home: Material( + child: RawChip( isEnabled: false, onPressed: () {}, label: const Text('test'), @@ -1352,15 +1352,15 @@ void main() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'test', textDirection: TextDirection.ltr, flags: [], @@ -1381,9 +1381,9 @@ void main() { bool deleted = false; await tester.pumpWidget( _wrapForChip( - child: new Row( + child: Row( children: [ - new Chip( + Chip( materialTapTargetSize: MaterialTapTargetSize.padded, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(0.0))), avatar: const CircleAvatar(child: Text('A')), @@ -1407,9 +1407,9 @@ void main() { bool pressed = false; await tester.pumpWidget( _wrapForChip( - child: new Row( + child: Row( children: [ - new InputChip( + InputChip( materialTapTargetSize: MaterialTapTargetSize.padded, shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(0.0))), avatar: const CircleAvatar(child: Text('A')), @@ -1431,7 +1431,7 @@ void main() { testWidgets('is hitTestable', (WidgetTester tester) async { await tester.pumpWidget( _wrapForChip( - child: new InputChip( + child: InputChip( shape: const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(0.0))), avatar: const CircleAvatar(child: Text('A')), label: const Text('Chip A'), @@ -1469,19 +1469,19 @@ void main() { testWidgets('FilterChip clipBehavior properly passes through to the Material', (WidgetTester tester) async { const Text label = Text('label'); - await tester.pumpWidget(_wrapForChip(child: new FilterChip(label: label, onSelected: (bool b){},))); + await tester.pumpWidget(_wrapForChip(child: FilterChip(label: label, onSelected: (bool b){},))); checkChipMaterialClipBehavior(tester, Clip.none); - await tester.pumpWidget(_wrapForChip(child: new FilterChip(label: label, onSelected: (bool b){}, clipBehavior: Clip.antiAlias))); + await tester.pumpWidget(_wrapForChip(child: FilterChip(label: label, onSelected: (bool b){}, clipBehavior: Clip.antiAlias))); checkChipMaterialClipBehavior(tester, Clip.antiAlias); }); testWidgets('ActionChip clipBehavior properly passes through to the Material', (WidgetTester tester) async { const Text label = Text('label'); - await tester.pumpWidget(_wrapForChip(child: new ActionChip(label: label, onPressed: (){},))); + await tester.pumpWidget(_wrapForChip(child: ActionChip(label: label, onPressed: (){},))); checkChipMaterialClipBehavior(tester, Clip.none); - await tester.pumpWidget(_wrapForChip(child: new ActionChip(label: label, clipBehavior: Clip.antiAlias, onPressed: (){}))); + await tester.pumpWidget(_wrapForChip(child: ActionChip(label: label, clipBehavior: Clip.antiAlias, onPressed: (){}))); checkChipMaterialClipBehavior(tester, Clip.antiAlias); }); diff --git a/packages/flutter/test/material/chip_theme_test.dart b/packages/flutter/test/material/chip_theme_test.dart index f2f9ae2e2e..9f6b2000cb 100644 --- a/packages/flutter/test/material/chip_theme_test.dart +++ b/packages/flutter/test/material/chip_theme_test.dart @@ -43,7 +43,7 @@ DefaultTextStyle getLabelStyle(WidgetTester tester) { void main() { testWidgets('Chip theme is built by ThemeData', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, ); @@ -55,7 +55,7 @@ void main() { }); testWidgets('Chip uses ThemeData chip theme if present', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, backgroundColor: Colors.blue, @@ -64,15 +64,15 @@ void main() { bool value; Widget buildChip(ChipThemeData data) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Theme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Theme( data: theme, - child: new RawChip( + child: RawChip( showCheckmark: true, onDeleted: () {}, tapEnabled: true, @@ -80,7 +80,7 @@ void main() { deleteIcon: const Placeholder(), isEnabled: true, selected: value, - label: new Text('$value'), + label: Text('$value'), onSelected: (bool newValue) {}, onPressed: null, ), @@ -100,7 +100,7 @@ void main() { }); testWidgets('Chip overrides ThemeData theme if ChipTheme present', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, ); @@ -111,17 +111,17 @@ void main() { ); const bool value = false; Widget buildChip(ChipThemeData data) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Theme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Theme( data: theme, - child: new ChipTheme( + child: ChipTheme( data: customTheme, - child: new RawChip( + child: RawChip( showCheckmark: true, onDeleted: () {}, tapEnabled: true, @@ -146,15 +146,15 @@ void main() { final RenderBox materialBox = getMaterialBox(tester); - expect(materialBox, paints..path(color: new Color(customTheme.backgroundColor.value))); + expect(materialBox, paints..path(color: Color(customTheme.backgroundColor.value))); }); testWidgets('ChipThemeData generates correct opacities for defaults', (WidgetTester tester) async { const Color customColor1 = Color(0xcafefeed); const Color customColor2 = Color(0xdeadbeef); - final TextStyle customStyle = new ThemeData.fallback().accentTextTheme.body2.copyWith(color: customColor2); + final TextStyle customStyle = ThemeData.fallback().accentTextTheme.body2.copyWith(color: customColor2); - final ChipThemeData lightTheme = new ChipThemeData.fromDefaults( + final ChipThemeData lightTheme = ChipThemeData.fromDefaults( secondaryColor: customColor1, brightness: Brightness.light, labelStyle: customStyle, @@ -172,7 +172,7 @@ void main() { expect(lightTheme.secondaryLabelStyle.color, equals(customColor1.withAlpha(0xde))); expect(lightTheme.brightness, equals(Brightness.light)); - final ChipThemeData darkTheme = new ChipThemeData.fromDefaults( + final ChipThemeData darkTheme = ChipThemeData.fromDefaults( secondaryColor: customColor1, brightness: Brightness.dark, labelStyle: customStyle, @@ -190,7 +190,7 @@ void main() { expect(darkTheme.secondaryLabelStyle.color, equals(customColor1.withAlpha(0xde))); expect(darkTheme.brightness, equals(Brightness.dark)); - final ChipThemeData customTheme = new ChipThemeData.fromDefaults( + final ChipThemeData customTheme = ChipThemeData.fromDefaults( primaryColor: customColor1, secondaryColor: customColor2, labelStyle: customStyle, @@ -210,15 +210,15 @@ void main() { }); testWidgets('ChipThemeData lerps correctly', (WidgetTester tester) async { - final ChipThemeData chipThemeBlack = new ChipThemeData.fromDefaults( + final ChipThemeData chipThemeBlack = ChipThemeData.fromDefaults( secondaryColor: Colors.black, brightness: Brightness.dark, - labelStyle: new ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.black), + labelStyle: ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.black), ); - final ChipThemeData chipThemeWhite = new ChipThemeData.fromDefaults( + final ChipThemeData chipThemeWhite = ChipThemeData.fromDefaults( secondaryColor: Colors.white, brightness: Brightness.light, - labelStyle: new ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.white), + labelStyle: ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.white), ).copyWith(padding: const EdgeInsets.all(2.0), labelPadding: const EdgeInsets.only(top: 8.0, bottom: 8.0)); final ChipThemeData lerp = ChipThemeData.lerp(chipThemeBlack, chipThemeWhite, 0.5); const Color middleGrey = Color(0xff7f7f7f); diff --git a/packages/flutter/test/material/circle_avatar_test.dart b/packages/flutter/test/material/circle_avatar_test.dart index d7e667018c..62f9e98d7a 100644 --- a/packages/flutter/test/material/circle_avatar_test.dart +++ b/packages/flutter/test/material/circle_avatar_test.dart @@ -15,7 +15,7 @@ void main() { final Color backgroundColor = Colors.blue.shade900; await tester.pumpWidget( wrap( - child: new CircleAvatar( + child: CircleAvatar( backgroundColor: backgroundColor, radius: 50.0, child: const Text('Z'), @@ -30,14 +30,14 @@ void main() { expect(decoration.color, equals(backgroundColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); - expect(paragraph.text.style.color, equals(new ThemeData.fallback().primaryColorLight)); + expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); }); testWidgets('CircleAvatar with light background color', (WidgetTester tester) async { final Color backgroundColor = Colors.blue.shade100; await tester.pumpWidget( wrap( - child: new CircleAvatar( + child: CircleAvatar( backgroundColor: backgroundColor, radius: 50.0, child: const Text('Z'), @@ -52,14 +52,14 @@ void main() { expect(decoration.color, equals(backgroundColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); - expect(paragraph.text.style.color, equals(new ThemeData.fallback().primaryColorDark)); + expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorDark)); }); testWidgets('CircleAvatar with image background', (WidgetTester tester) async { await tester.pumpWidget( wrap( - child: new CircleAvatar( - backgroundImage: new MemoryImage(new Uint8List.fromList(kTransparentImage)), + child: CircleAvatar( + backgroundImage: MemoryImage(Uint8List.fromList(kTransparentImage)), radius: 50.0, ), ), @@ -76,14 +76,14 @@ void main() { final Color foregroundColor = Colors.red.shade100; await tester.pumpWidget( wrap( - child: new CircleAvatar( + child: CircleAvatar( foregroundColor: foregroundColor, child: const Text('Z'), ), ), ); - final ThemeData fallback = new ThemeData.fallback(); + final ThemeData fallback = ThemeData.fallback(); final RenderConstrainedBox box = tester.renderObject(find.byType(CircleAvatar)); expect(box.size, equals(const Size(40.0, 40.0))); @@ -96,13 +96,13 @@ void main() { }); testWidgets('CircleAvatar with light theme', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( primaryColor: Colors.grey.shade100, primaryColorBrightness: Brightness.light, ); await tester.pumpWidget( wrap( - child: new Theme( + child: Theme( data: theme, child: const CircleAvatar( child: Text('Z'), @@ -121,13 +121,13 @@ void main() { }); testWidgets('CircleAvatar with dark theme', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( primaryColor: Colors.grey.shade800, primaryColorBrightness: Brightness.dark, ); await tester.pumpWidget( wrap( - child: new Theme( + child: Theme( data: theme, child: const CircleAvatar( child: Text('Z'), @@ -149,7 +149,7 @@ void main() { final Color foregroundColor = Colors.red.shade100; await tester.pumpWidget( wrap( - child: new CircleAvatar( + child: CircleAvatar( foregroundColor: foregroundColor, child: const Text('Z'), ), @@ -160,14 +160,14 @@ void main() { await tester.pumpWidget( wrap( - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( textScaleFactor: 2.0, size: Size(111.0, 111.0), devicePixelRatio: 1.1, padding: EdgeInsets.all(11.0)), - child: new CircleAvatar( - child: new Builder( + child: CircleAvatar( + child: Builder( builder: (BuildContext context) { final MediaQueryData data = MediaQuery.of(context); @@ -192,8 +192,8 @@ void main() { final Color backgroundColor = Colors.blue.shade900; await tester.pumpWidget( wrap( - child: new UnconstrainedBox( - child: new CircleAvatar( + child: UnconstrainedBox( + child: CircleAvatar( backgroundColor: backgroundColor, minRadius: 50.0, child: const Text('Z'), @@ -209,14 +209,14 @@ void main() { expect(decoration.color, equals(backgroundColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); - expect(paragraph.text.style.color, equals(new ThemeData.fallback().primaryColorLight)); + expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); }); testWidgets('CircleAvatar respects maxRadius', (WidgetTester tester) async { final Color backgroundColor = Colors.blue.shade900; await tester.pumpWidget( wrap( - child: new CircleAvatar( + child: CircleAvatar( backgroundColor: backgroundColor, maxRadius: 50.0, child: const Text('Z'), @@ -231,14 +231,14 @@ void main() { expect(decoration.color, equals(backgroundColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); - expect(paragraph.text.style.color, equals(new ThemeData.fallback().primaryColorLight)); + expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); }); testWidgets('CircleAvatar respects setting both minRadius and maxRadius', (WidgetTester tester) async { final Color backgroundColor = Colors.blue.shade900; await tester.pumpWidget( wrap( - child: new CircleAvatar( + child: CircleAvatar( backgroundColor: backgroundColor, maxRadius: 50.0, minRadius: 50.0, @@ -254,16 +254,16 @@ void main() { expect(decoration.color, equals(backgroundColor)); final RenderParagraph paragraph = tester.renderObject(find.text('Z')); - expect(paragraph.text.style.color, equals(new ThemeData.fallback().primaryColorLight)); + expect(paragraph.text.style.color, equals(ThemeData.fallback().primaryColorLight)); }); } Widget wrap({ Widget child }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Center(child: child), + child: Center(child: child), ), ); } diff --git a/packages/flutter/test/material/control_list_tile_test.dart b/packages/flutter/test/material/control_list_tile_test.dart index 6e62032147..ccd6beabd4 100644 --- a/packages/flutter/test/material/control_list_tile_test.dart +++ b/packages/flutter/test/material/control_list_tile_test.dart @@ -9,11 +9,11 @@ import 'package:flutter/rendering.dart'; import '../widgets/semantics_tester.dart'; Widget wrap({ Widget child }) { - return new MediaQuery( + return MediaQuery( data: const MediaQueryData(), - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new Material(child: child), + child: Material(child: child), ), ); } @@ -22,7 +22,7 @@ void main() { testWidgets('CheckboxListTile control test', (WidgetTester tester) async { final List log = []; await tester.pumpWidget(wrap( - child: new CheckboxListTile( + child: CheckboxListTile( value: true, onChanged: (bool value) { log.add(value); }, title: const Text('Hello'), @@ -37,7 +37,7 @@ void main() { testWidgets('RadioListTile control test', (WidgetTester tester) async { final List log = []; await tester.pumpWidget(wrap( - child: new RadioListTile( + child: RadioListTile( value: true, groupValue: false, onChanged: (bool value) { log.add(value); }, @@ -53,7 +53,7 @@ void main() { testWidgets('SwitchListTile control test', (WidgetTester tester) async { final List log = []; await tester.pumpWidget(wrap( - child: new SwitchListTile( + child: SwitchListTile( value: true, onChanged: (bool value) { log.add(value); }, title: const Text('Hello'), @@ -66,23 +66,23 @@ void main() { }); testWidgets('SwitchListTile control test', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(wrap( - child: new Column( + child: Column( children: [ - new SwitchListTile( + SwitchListTile( value: true, onChanged: (bool value) { }, title: const Text('AAA'), secondary: const Text('aaa'), ), - new CheckboxListTile( + CheckboxListTile( value: true, onChanged: (bool value) { }, title: const Text('BBB'), secondary: const Text('bbb'), ), - new RadioListTile( + RadioListTile( value: true, groupValue: false, onChanged: (bool value) { }, @@ -94,11 +94,11 @@ void main() { )); // This test verifies that the label and the control get merged. - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, - rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), + rect: Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), transform: null, flags: [ SemanticsFlag.hasToggledState, @@ -109,10 +109,10 @@ void main() { actions: SemanticsAction.tap.index, label: 'aaa\nAAA', ), - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 3, - rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), - transform: new Matrix4.translationValues(0.0, 56.0, 0.0), + rect: Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), + transform: Matrix4.translationValues(0.0, 56.0, 0.0), flags: [ SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, @@ -122,10 +122,10 @@ void main() { actions: SemanticsAction.tap.index, label: 'bbb\nBBB', ), - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 5, - rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), - transform: new Matrix4.translationValues(0.0, 112.0, 0.0), + rect: Rect.fromLTWH(0.0, 0.0, 800.0, 56.0), + transform: Matrix4.translationValues(0.0, 112.0, 0.0), flags: [ SemanticsFlag.hasCheckedState, SemanticsFlag.hasEnabledState, diff --git a/packages/flutter/test/material/data_table_test.dart b/packages/flutter/test/material/data_table_test.dart index d18aca37a9..88cf8e6db4 100644 --- a/packages/flutter/test/material/data_table_test.dart +++ b/packages/flutter/test/material/data_table_test.dart @@ -12,7 +12,7 @@ void main() { final List log = []; Widget buildTable({ int sortColumnIndex, bool sortAscending = true }) { - return new DataTable( + return DataTable( sortColumnIndex: sortColumnIndex, sortAscending: sortAscending, onSelectAll: (bool value) { @@ -23,7 +23,7 @@ void main() { label: Text('Name'), tooltip: 'Name', ), - new DataColumn( + DataColumn( label: const Text('Calories'), tooltip: 'Calories', numeric: true, @@ -33,17 +33,17 @@ void main() { ), ], rows: kDesserts.map((Dessert dessert) { - return new DataRow( - key: new Key(dessert.name), + return DataRow( + key: Key(dessert.name), onSelectChanged: (bool selected) { log.add('row-selected: ${dessert.name}'); }, cells: [ - new DataCell( - new Text(dessert.name), + DataCell( + Text(dessert.name), ), - new DataCell( - new Text('${dessert.calories}'), + DataCell( + Text('${dessert.calories}'), showEditIcon: true, onTap: () { log.add('cell-tap: ${dessert.calories}'); @@ -55,8 +55,8 @@ void main() { ); } - await tester.pumpWidget(new MaterialApp( - home: new Material(child: buildTable()) + await tester.pumpWidget(MaterialApp( + home: Material(child: buildTable()) )); await tester.tap(find.byType(Checkbox).first); @@ -74,8 +74,8 @@ void main() { expect(log, ['column-sort: 1 true']); log.clear(); - await tester.pumpWidget(new MaterialApp( - home: new Material(child: buildTable(sortColumnIndex: 1)) + await tester.pumpWidget(MaterialApp( + home: Material(child: buildTable(sortColumnIndex: 1)) )); await tester.pumpAndSettle(const Duration(milliseconds: 200)); await tester.tap(find.text('Calories')); @@ -83,8 +83,8 @@ void main() { expect(log, ['column-sort: 1 false']); log.clear(); - await tester.pumpWidget(new MaterialApp( - home: new Material(child: buildTable(sortColumnIndex: 1, sortAscending: false)) + await tester.pumpWidget(MaterialApp( + home: Material(child: buildTable(sortColumnIndex: 1, sortAscending: false)) )); await tester.pumpAndSettle(const Duration(milliseconds: 200)); @@ -101,12 +101,12 @@ void main() { testWidgets('DataTable overflow test - header', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new DataTable( + MaterialApp( + home: Material( + child: DataTable( columns: [ - new DataColumn( - label: new Text('X' * 2000), + DataColumn( + label: Text('X' * 2000), ), ], rows: const [ @@ -129,12 +129,12 @@ void main() { testWidgets('DataTable overflow test - header with spaces', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new DataTable( + MaterialApp( + home: Material( + child: DataTable( columns: [ - new DataColumn( - label: new Text('X ' * 2000), // has soft wrap points, but they should be ignored + DataColumn( + label: Text('X ' * 2000), // has soft wrap points, but they should be ignored ), ], rows: const [ @@ -157,19 +157,19 @@ void main() { testWidgets('DataTable overflow test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new DataTable( + MaterialApp( + home: Material( + child: DataTable( columns: const [ DataColumn( label: Text('X'), ), ], rows: [ - new DataRow( + DataRow( cells: [ - new DataCell( - new Text('X' * 2000), + DataCell( + Text('X' * 2000), ), ], ), @@ -185,19 +185,19 @@ void main() { testWidgets('DataTable overflow test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new DataTable( + MaterialApp( + home: Material( + child: DataTable( columns: const [ DataColumn( label: Text('X'), ), ], rows: [ - new DataRow( + DataRow( cells: [ - new DataCell( - new Text('X ' * 2000), // wraps + DataCell( + Text('X ' * 2000), // wraps ), ], ), diff --git a/packages/flutter/test/material/data_table_test_utils.dart b/packages/flutter/test/material/data_table_test_utils.dart index c0b56afb7f..8044c51cf4 100644 --- a/packages/flutter/test/material/data_table_test_utils.dart +++ b/packages/flutter/test/material/data_table_test_utils.dart @@ -16,14 +16,14 @@ class Dessert { } final List kDesserts = [ - new Dessert('Frozen yogurt', 159, 6.0, 24, 4.0, 87, 14, 1), - new Dessert('Ice cream sandwich', 237, 9.0, 37, 4.3, 129, 8, 1), - new Dessert('Eclair', 262, 16.0, 24, 6.0, 337, 6, 7), - new Dessert('Cupcake', 305, 3.7, 67, 4.3, 413, 3, 8), - new Dessert('Gingerbread', 356, 16.0, 49, 3.9, 327, 7, 16), - new Dessert('Jelly bean', 375, 0.0, 94, 0.0, 50, 0, 0), - new Dessert('Lollipop', 392, 0.2, 98, 0.0, 38, 0, 2), - new Dessert('Honeycomb', 408, 3.2, 87, 6.5, 562, 0, 45), - new Dessert('Donut', 452, 25.0, 51, 4.9, 326, 2, 22), - new Dessert('KitKat', 518, 26.0, 65, 7.0, 54, 12, 6), + Dessert('Frozen yogurt', 159, 6.0, 24, 4.0, 87, 14, 1), + Dessert('Ice cream sandwich', 237, 9.0, 37, 4.3, 129, 8, 1), + Dessert('Eclair', 262, 16.0, 24, 6.0, 337, 6, 7), + Dessert('Cupcake', 305, 3.7, 67, 4.3, 413, 3, 8), + Dessert('Gingerbread', 356, 16.0, 49, 3.9, 327, 7, 16), + Dessert('Jelly bean', 375, 0.0, 94, 0.0, 50, 0, 0), + Dessert('Lollipop', 392, 0.2, 98, 0.0, 38, 0, 2), + Dessert('Honeycomb', 408, 3.2, 87, 6.5, 562, 0, 45), + Dessert('Donut', 452, 25.0, 51, 4.9, 326, 2, 22), + Dessert('KitKat', 518, 26.0, 65, 7.0, 54, 12, 6), ]; diff --git a/packages/flutter/test/material/date_picker_test.dart b/packages/flutter/test/material/date_picker_test.dart index 43e9c4e577..920449a9f3 100644 --- a/packages/flutter/test/material/date_picker_test.dart +++ b/packages/flutter/test/material/date_picker_test.dart @@ -28,28 +28,28 @@ void _tests() { final Finder previousMonthIcon = find.byWidgetPredicate((Widget w) => w is IconButton && (w.tooltip?.startsWith('Previous month') ?? false)); setUp(() { - firstDate = new DateTime(2001, DateTime.january, 1); - lastDate = new DateTime(2031, DateTime.december, 31); - initialDate = new DateTime(2016, DateTime.january, 15); + firstDate = DateTime(2001, DateTime.january, 1); + lastDate = DateTime(2031, DateTime.december, 31); + initialDate = DateTime(2016, DateTime.january, 15); selectableDayPredicate = null; initialDatePickerMode = null; }); testWidgets('tap-select a day', (WidgetTester tester) async { - final Key _datePickerKey = new UniqueKey(); - DateTime _selectedDate = new DateTime(2016, DateTime.july, 26); + final Key _datePickerKey = UniqueKey(); + DateTime _selectedDate = DateTime(2016, DateTime.july, 26); await tester.pumpWidget( - new MaterialApp( - home: new StatefulBuilder( + MaterialApp( + home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Container( + return Container( width: 400.0, - child: new SingleChildScrollView( - child: new Material( - child: new MonthPicker( - firstDate: new DateTime(0), - lastDate: new DateTime(9999), + child: SingleChildScrollView( + child: Material( + child: MonthPicker( + firstDate: DateTime(0), + lastDate: DateTime(9999), key: _datePickerKey, selectedDate: _selectedDate, onChanged: (DateTime value) { @@ -66,7 +66,7 @@ void _tests() { ) ); - expect(_selectedDate, equals(new DateTime(2016, DateTime.july, 26))); + expect(_selectedDate, equals(DateTime(2016, DateTime.july, 26))); await tester.tapAt(const Offset(50.0, 100.0)); await tester.pumpAndSettle(); @@ -74,47 +74,47 @@ void _tests() { await tester.tap(find.text('1')); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.july, 1))); + expect(_selectedDate, equals(DateTime(2016, DateTime.july, 1))); await tester.tap(nextMonthIcon); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.july, 1))); + expect(_selectedDate, equals(DateTime(2016, DateTime.july, 1))); await tester.tap(find.text('5')); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.august, 5))); + expect(_selectedDate, equals(DateTime(2016, DateTime.august, 5))); await tester.drag(find.byKey(_datePickerKey), const Offset(-400.0, 0.0)); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.august, 5))); + expect(_selectedDate, equals(DateTime(2016, DateTime.august, 5))); await tester.tap(find.text('25')); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.september, 25))); + expect(_selectedDate, equals(DateTime(2016, DateTime.september, 25))); await tester.drag(find.byKey(_datePickerKey), const Offset(800.0, 0.0)); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.september, 25))); + expect(_selectedDate, equals(DateTime(2016, DateTime.september, 25))); await tester.tap(find.text('17')); await tester.pumpAndSettle(); - expect(_selectedDate, equals(new DateTime(2016, DateTime.august, 17))); + expect(_selectedDate, equals(DateTime(2016, DateTime.august, 17))); }); testWidgets('render picker with intrinsic dimensions', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new StatefulBuilder( + MaterialApp( + home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new IntrinsicWidth( - child: new IntrinsicHeight( - child: new Material( - child: new SingleChildScrollView( - child: new MonthPicker( - firstDate: new DateTime(0), - lastDate: new DateTime(9999), + return IntrinsicWidth( + child: IntrinsicHeight( + child: Material( + child: SingleChildScrollView( + child: MonthPicker( + firstDate: DateTime(0), + lastDate: DateTime(9999), onChanged: (DateTime value) { }, - selectedDate: new DateTime(2000, DateTime.january, 1), + selectedDate: DateTime(2000, DateTime.january, 1), ), ), ), @@ -129,11 +129,11 @@ void _tests() { Future preparePicker(WidgetTester tester, Future callback(Future date)) async { BuildContext buttonContext; - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new Builder( + await tester.pumpWidget(MaterialApp( + home: Material( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( onPressed: () { buttonContext = context; }, @@ -174,7 +174,7 @@ void _tests() { testWidgets('Initial date is the default', (WidgetTester tester) async { await preparePicker(tester, (Future date) async { await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2016, DateTime.january, 15))); + expect(await date, equals(DateTime(2016, DateTime.january, 15))); }); }); @@ -189,7 +189,7 @@ void _tests() { await preparePicker(tester, (Future date) async { await tester.tap(find.text('12')); await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2016, DateTime.january, 12))); + expect(await date, equals(DateTime(2016, DateTime.january, 12))); }); }); @@ -199,7 +199,7 @@ void _tests() { await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.tap(find.text('25')); await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2015, DateTime.december, 25))); + expect(await date, equals(DateTime(2015, DateTime.december, 25))); }); }); @@ -209,7 +209,7 @@ void _tests() { await tester.pump(); await tester.tap(find.text('2018')); await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2018, DateTime.january, 15))); + expect(await date, equals(DateTime(2018, DateTime.january, 15))); }); }); @@ -222,19 +222,19 @@ void _tests() { final MaterialLocalizations localizations = MaterialLocalizations.of( tester.element(find.byType(DayPicker)) ); - final String dayLabel = localizations.formatMediumDate(new DateTime(2017, DateTime.january, 15)); + final String dayLabel = localizations.formatMediumDate(DateTime(2017, DateTime.january, 15)); await tester.tap(find.text(dayLabel)); await tester.pump(); await tester.tap(find.text('19')); await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2017, DateTime.january, 19))); + expect(await date, equals(DateTime(2017, DateTime.january, 19))); }); }); testWidgets('Current year is initially visible in year picker', (WidgetTester tester) async { - initialDate = new DateTime(2000); - firstDate = new DateTime(1900); - lastDate = new DateTime(2100); + initialDate = DateTime(2000); + firstDate = DateTime(1900); + lastDate = DateTime(2100); await preparePicker(tester, (Future date) async { await tester.tap(find.text('2000')); await tester.pump(); @@ -243,7 +243,7 @@ void _tests() { }); testWidgets('Cannot select a day outside bounds', (WidgetTester tester) async { - initialDate = new DateTime(2017, DateTime.january, 15); + initialDate = DateTime(2017, DateTime.january, 15); firstDate = initialDate; lastDate = initialDate; await preparePicker(tester, (Future date) async { @@ -256,9 +256,9 @@ void _tests() { }); testWidgets('Cannot select a month past last date', (WidgetTester tester) async { - initialDate = new DateTime(2017, DateTime.january, 15); + initialDate = DateTime(2017, DateTime.january, 15); firstDate = initialDate; - lastDate = new DateTime(2017, DateTime.february, 20); + lastDate = DateTime(2017, DateTime.february, 20); await preparePicker(tester, (Future date) async { await tester.tap(nextMonthIcon); await tester.pumpAndSettle(const Duration(seconds: 1)); @@ -268,8 +268,8 @@ void _tests() { }); testWidgets('Cannot select a month before first date', (WidgetTester tester) async { - initialDate = new DateTime(2017, DateTime.january, 15); - firstDate = new DateTime(2016, DateTime.december, 10); + initialDate = DateTime(2017, DateTime.january, 15); + firstDate = DateTime(2016, DateTime.december, 10); lastDate = initialDate; await preparePicker(tester, (Future date) async { await tester.tap(previousMonthIcon); @@ -280,21 +280,21 @@ void _tests() { }); testWidgets('Only predicate days are selectable', (WidgetTester tester) async { - initialDate = new DateTime(2017, DateTime.january, 16); - firstDate = new DateTime(2017, DateTime.january, 10); - lastDate = new DateTime(2017, DateTime.january, 20); + initialDate = DateTime(2017, DateTime.january, 16); + firstDate = DateTime(2017, DateTime.january, 10); + lastDate = DateTime(2017, DateTime.january, 20); selectableDayPredicate = (DateTime day) => day.day.isEven; await preparePicker(tester, (Future date) async { await tester.tap(find.text('10')); // Even, works. await tester.tap(find.text('13')); // Odd, doesn't work. await tester.tap(find.text('17')); // Odd, doesn't work. await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2017, DateTime.january, 10))); + expect(await date, equals(DateTime(2017, DateTime.january, 10))); }); }); testWidgets('Can select initial date picker mode', (WidgetTester tester) async { - initialDate = new DateTime(2014, DateTime.january, 15); + initialDate = DateTime(2014, DateTime.january, 15); initialDatePickerMode = DatePickerMode.year; await preparePicker(tester, (Future date) async { await tester.pump(); @@ -302,7 +302,7 @@ void _tests() { // The initial current year is 2014. await tester.tap(find.text('2018')); await tester.tap(find.text('OK')); - expect(await date, equals(new DateTime(2018, DateTime.january, 15))); + expect(await date, equals(DateTime(2018, DateTime.january, 15))); }); }); @@ -311,10 +311,10 @@ void _tests() { FeedbackTester feedback; setUp(() { - feedback = new FeedbackTester(); - initialDate = new DateTime(2017, DateTime.january, 16); - firstDate = new DateTime(2017, DateTime.january, 10); - lastDate = new DateTime(2018, DateTime.january, 20); + feedback = FeedbackTester(); + initialDate = DateTime(2017, DateTime.january, 16); + firstDate = DateTime(2017, DateTime.january, 10); + lastDate = DateTime(2018, DateTime.january, 20); selectableDayPredicate = (DateTime date) => date.day.isEven; }); @@ -386,187 +386,187 @@ void _tests() { }); testWidgets('exports semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await preparePicker(tester, (Future date) async { - final TestSemantics expected = new TestSemantics( + final TestSemantics expected = TestSemantics( flags: [ SemanticsFlag.scopesRoute, ], children: [ - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isSelected], actions: [SemanticsAction.tap], label: 'Fri, Jan 15', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [SemanticsAction.scrollLeft, SemanticsAction.scrollRight], children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '1, Friday, January 1, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '2, Saturday, January 2, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '3, Sunday, January 3, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '4, Monday, January 4, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '5, Tuesday, January 5, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '6, Wednesday, January 6, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '7, Thursday, January 7, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '8, Friday, January 8, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '9, Saturday, January 9, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '10, Sunday, January 10, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '11, Monday, January 11, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '12, Tuesday, January 12, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '13, Wednesday, January 13, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '14, Thursday, January 14, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isSelected], actions: [SemanticsAction.tap], label: '15, Friday, January 15, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '16, Saturday, January 16, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '17, Sunday, January 17, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '18, Monday, January 18, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '19, Tuesday, January 19, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '20, Wednesday, January 20, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '21, Thursday, January 21, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '22, Friday, January 22, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '23, Saturday, January 23, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '24, Sunday, January 24, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '25, Monday, January 25, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '26, Tuesday, January 26, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '27, Wednesday, January 27, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '28, Thursday, January 28, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '29, Friday, January 29, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '30, Saturday, January 30, 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '31, Sunday, January 31, 2016', textDirection: TextDirection.ltr, @@ -581,25 +581,25 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], actions: [SemanticsAction.tap], label: 'Previous month December 2015', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], actions: [SemanticsAction.tap], label: 'Next month February 2016', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], actions: [SemanticsAction.tap], label: 'CANCEL', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled], actions: [SemanticsAction.tap], label: 'OK', @@ -609,8 +609,8 @@ void _tests() { ); expect(semantics, hasSemantics( - new TestSemantics.root(children: [ - new TestSemantics( + TestSemantics.root(children: [ + TestSemantics( children: [expected], ), ]), @@ -624,20 +624,20 @@ void _tests() { }); testWidgets('chervons animate when scrolling month picker', (WidgetTester tester) async { - final Key _datePickerKey = new UniqueKey(); - DateTime _selectedDate = new DateTime(2016, DateTime.july, 26); + final Key _datePickerKey = UniqueKey(); + DateTime _selectedDate = DateTime(2016, DateTime.july, 26); await tester.pumpWidget( - new MaterialApp( - home: new StatefulBuilder( + MaterialApp( + home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Container( + return Container( width: 400.0, - child: new SingleChildScrollView( - child: new Material( - child: new MonthPicker( - firstDate: new DateTime(0), - lastDate: new DateTime(9999), + child: SingleChildScrollView( + child: Material( + child: MonthPicker( + firstDate: DateTime(0), + lastDate: DateTime(9999), key: _datePickerKey, selectedDate: _selectedDate, onChanged: (DateTime value) { diff --git a/packages/flutter/test/material/dialog_test.dart b/packages/flutter/test/material/dialog_test.dart index 9bfbef369a..a275c4ae77 100644 --- a/packages/flutter/test/material/dialog_test.dart +++ b/packages/flutter/test/material/dialog_test.dart @@ -15,25 +15,25 @@ void main() { bool didPressOk = false; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Builder( + MaterialApp( + home: Material( + child: Builder( builder: (BuildContext context) { - return new Center( - child: new RaisedButton( + return Center( + child: RaisedButton( child: const Text('X'), onPressed: () { showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( - content: new Container( + return AlertDialog( + content: Container( height: 5000.0, width: 300.0, color: Colors.green[500], ), actions: [ - new FlatButton( + FlatButton( onPressed: () { didPressOk = true; }, @@ -64,13 +64,13 @@ void main() { testWidgets('Dialog background color', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.dark), - home: new Material( - child: new Builder( + MaterialApp( + theme: ThemeData(brightness: Brightness.dark), + home: Material( + child: Builder( builder: (BuildContext context) { - return new Center( - child: new RaisedButton( + return Center( + child: RaisedButton( child: const Text('X'), onPressed: () { showDialog( @@ -106,7 +106,7 @@ void main() { testWidgets('Simple dialog control test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: RaisedButton( @@ -123,10 +123,10 @@ void main() { final Future result = showDialog( context: context, builder: (BuildContext context) { - return new SimpleDialog( + return SimpleDialog( title: const Text('Title'), children: [ - new SimpleDialogOption( + SimpleDialogOption( onPressed: () { Navigator.pop(context, 42); }, @@ -149,7 +149,7 @@ void main() { testWidgets('Barrier dismissible', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: RaisedButton( @@ -166,7 +166,7 @@ void main() { showDialog( context: context, builder: (BuildContext context) { - return new Container( + return Container( width: 100.0, height: 100.0, alignment: Alignment.center, @@ -188,7 +188,7 @@ void main() { context: context, barrierDismissible: false, builder: (BuildContext context) { - return new Container( + return Container( width: 100.0, height: 100.0, alignment: Alignment.center, @@ -209,10 +209,10 @@ void main() { }); testWidgets('Dialog hides underlying semantics tree', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const String buttonText = 'A button covered by dialog overlay'; await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: RaisedButton( @@ -249,23 +249,23 @@ void main() { BuildContext routeContext; BuildContext dialogContext; - await tester.pumpWidget(new Localizations( + await tester.pumpWidget(Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.all(50.0), viewInsets: EdgeInsets.only(left: 25.0, bottom: 75.0), ), - child: new Navigator( + child: Navigator( onGenerateRoute: (_) { - return new PageRouteBuilder( + return PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { outerContext = context; - return new Container(); + return Container(); }, ); }, @@ -278,8 +278,8 @@ void main() { barrierDismissible: false, builder: (BuildContext context) { routeContext = context; - return new Dialog( - child: new Builder( + return Dialog( + child: Builder( builder: (BuildContext context) { dialogContext = context; return const Placeholder(); @@ -312,7 +312,7 @@ void main() { ); expect( tester.getRect(find.byType(Placeholder)), - new Rect.fromLTRB(10.0 + 40.0, 20.0 + 24.0, 800.0 - (40.0 + 30.0), 600.0 - (24.0 + 40.0)), + Rect.fromLTRB(10.0 + 40.0, 20.0 + 24.0, 800.0 - (40.0 + 30.0), 600.0 - (24.0 + 40.0)), ); await tester.pumpWidget( const MediaQuery( @@ -326,24 +326,24 @@ void main() { ); expect( // no change because this is an animation tester.getRect(find.byType(Placeholder)), - new Rect.fromLTRB(10.0 + 40.0, 20.0 + 24.0, 800.0 - (40.0 + 30.0), 600.0 - (24.0 + 40.0)), + Rect.fromLTRB(10.0 + 40.0, 20.0 + 24.0, 800.0 - (40.0 + 30.0), 600.0 - (24.0 + 40.0)), ); await tester.pump(const Duration(seconds: 1)); expect( // animation finished tester.getRect(find.byType(Placeholder)), - new Rect.fromLTRB(40.0, 24.0, 800.0 - 40.0, 600.0 - 24.0), + Rect.fromLTRB(40.0, 24.0, 800.0 - 40.0, 600.0 - 24.0), ); }); testWidgets('Dialog widget contains route semantics from title', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Builder( + MaterialApp( + home: Material( + child: Builder( builder: (BuildContext context) { - return new Center( - child: new RaisedButton( + return Center( + child: RaisedButton( child: const Text('X'), onPressed: () { showDialog( diff --git a/packages/flutter/test/material/drawer_test.dart b/packages/flutter/test/material/drawer_test.dart index 53dac4550d..ff29764e09 100644 --- a/packages/flutter/test/material/drawer_test.dart +++ b/packages/flutter/test/material/drawer_test.dart @@ -14,13 +14,13 @@ void main() { const Key containerKey = Key('container'); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - drawer: new Drawer( - child: new ListView( + MaterialApp( + home: Scaffold( + drawer: Drawer( + child: ListView( children: [ - new DrawerHeader( - child: new Container( + DrawerHeader( + child: Container( key: containerKey, child: const Text('header'), ), @@ -58,10 +58,10 @@ void main() { }); testWidgets('Drawer dismiss barrier has label on iOS', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); debugDefaultTargetPlatformOverride = TargetPlatform.iOS; await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( drawer: Drawer() ), @@ -84,9 +84,9 @@ void main() { }); testWidgets('Drawer dismiss barrier has no label on Android', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( drawer: Drawer() ), diff --git a/packages/flutter/test/material/dropdown_test.dart b/packages/flutter/test/material/dropdown_test.dart index 118e288a24..d499caa36f 100644 --- a/packages/flutter/test/material/dropdown_test.dart +++ b/packages/flutter/test/material/dropdown_test.dart @@ -14,7 +14,7 @@ import '../widgets/semantics_tester.dart'; const List menuItems = ['one', 'two', 'three', 'four']; -final Type dropdownButtonType = new DropdownButton( +final Type dropdownButtonType = DropdownButton( onChanged: (_) { }, items: const >[] ).runtimeType; @@ -30,13 +30,13 @@ Widget buildFrame({ Alignment alignment = Alignment.center, TextDirection textDirection = TextDirection.ltr, }) { - return new TestApp( + return TestApp( textDirection: textDirection, - child: new Material( - child: new Align( + child: Material( + child: Align( alignment: alignment, - child: new RepaintBoundary( - child: new DropdownButton( + child: RepaintBoundary( + child: DropdownButton( key: buttonKey, value: value, hint: hint, @@ -44,10 +44,10 @@ Widget buildFrame({ isDense: isDense, isExpanded: isExpanded, items: items.map((String item) { - return new DropdownMenuItem( - key: new ValueKey(item), + return DropdownMenuItem( + key: ValueKey(item), value: item, - child: new Text(item, key: new ValueKey(item + 'Text')), + child: Text(item, key: ValueKey(item + 'Text')), ); }).toList(), ) @@ -62,26 +62,26 @@ class TestApp extends StatefulWidget { final TextDirection textDirection; final Widget child; @override - _TestAppState createState() => new _TestAppState(); + _TestAppState createState() => _TestAppState(); } class _TestAppState extends State { @override Widget build(BuildContext context) { - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Directionality( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Directionality( textDirection: widget.textDirection, - child: new Navigator( + child: Navigator( onGenerateRoute: (RouteSettings settings) { assert(settings.name == '/'); - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, builder: (BuildContext context) => widget.child, ); @@ -98,7 +98,7 @@ class _TestAppState extends State { // The RenderParagraphs should be aligned, i.e. they should have the same // size and location. void checkSelectedItemTextGeometry(WidgetTester tester, String value) { - final List boxes = tester.renderObjectList(find.byKey(new ValueKey(value + 'Text'))).toList(); + final List boxes = tester.renderObjectList(find.byKey(ValueKey(value + 'Text'))).toList(); expect(boxes.length, equals(2)); final RenderBox box0 = boxes[0]; final RenderBox box1 = boxes[1]; @@ -114,7 +114,7 @@ bool sameGeometry(RenderBox box1, RenderBox box2) { void main() { testWidgets('Default dropdown golden', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); Widget build() => buildFrame(buttonKey: buttonKey, value: 'two'); await tester.pumpWidget(build()); final Finder buttonFinder = find.byKey(buttonKey); @@ -127,7 +127,7 @@ void main() { }); testWidgets('Expanded dropdown golden', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); Widget build() => buildFrame(buttonKey: buttonKey, value: 'two', isExpanded: true); await tester.pumpWidget(build()); final Finder buttonFinder = find.byKey(buttonKey); @@ -185,15 +185,15 @@ void main() { } Widget build() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( initialRoute: '/', onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, builder: (BuildContext context) { - return new Material( + return Material( child: buildFrame(value: 'one', onChanged: didChangeValue), ); }, @@ -239,16 +239,16 @@ void main() { // Positions a DropdownButton at the left and right edges of the screen, // forcing it to be sized down to the viewport width const String value = 'foo'; - final UniqueKey itemKey = new UniqueKey(); + final UniqueKey itemKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new ListView( + MaterialApp( + home: Material( + child: ListView( children: [ - new DropdownButton( + DropdownButton( value: value, items: >[ - new DropdownMenuItem( + DropdownMenuItem( key: itemKey, value: value, child: const Text(value), @@ -273,22 +273,22 @@ void main() { int value = 4; final List> items = >[]; for (int i = 0; i < 20; ++i) - items.add(new DropdownMenuItem(value: i, child: new Text('$i'))); + items.add(DropdownMenuItem(value: i, child: Text('$i'))); void handleChanged(int newValue) { value = newValue; } - final DropdownButton button = new DropdownButton( + final DropdownButton button = DropdownButton( value: value, onChanged: handleChanged, items: items, ); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Align( + MaterialApp( + home: Material( + child: Align( alignment: Alignment.topCenter, child: button, ), @@ -323,7 +323,7 @@ void main() { for (TextDirection textDirection in TextDirection.values) { testWidgets('Dropdown button aligns selected menu item ($textDirection)', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); const String value = 'two'; Widget build() => buildFrame(buttonKey: buttonKey, value: value, textDirection: textDirection); @@ -364,12 +364,12 @@ void main() { // should have the same size and location. checkSelectedItemTextGeometry(tester, 'two'); - await tester.pumpWidget(new Container()); // reset test + await tester.pumpWidget(Container()); // reset test }); } testWidgets('Arrow icon aligns with the edge of button when expanded', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); Widget build() => buildFrame(buttonKey: buttonKey, value: 'two', isExpanded: true); @@ -382,11 +382,11 @@ void main() { // Arrow icon should be aligned with far right of button when expanded expect(arrowIcon.localToGlobal(Offset.zero).dx, - buttonBox.size.centerRight(new Offset(-arrowIcon.size.width, 0.0)).dx); + buttonBox.size.centerRight(Offset(-arrowIcon.size.width, 0.0)).dx); }); testWidgets('Dropdown button with isDense:true aligns selected menu item', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); const String value = 'two'; Widget build() => buildFrame(buttonKey: buttonKey, value: value, isDense: true); @@ -423,7 +423,7 @@ void main() { }); testWidgets('Size of DropdownButton with null value', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); String value; Widget build() => buildFrame(buttonKey: buttonKey, value: value); @@ -445,7 +445,7 @@ void main() { }); testWidgets('Layout of a DropdownButton with null value', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); String value; void onChanged(String newValue) { @@ -473,7 +473,7 @@ void main() { }); testWidgets('Size of DropdownButton with null value and a hint', (WidgetTester tester) async { - final Key buttonKey = new UniqueKey(); + final Key buttonKey = UniqueKey(); String value; // The hint will define the dropdown's width @@ -546,18 +546,18 @@ void main() { buildFrame(alignment: Alignment.topLeft, value: menuItems.last) ); expect(menuRect.topLeft, Offset.zero); - expect(menuRect.topRight, new Offset(menuRect.width, 0.0)); + expect(menuRect.topRight, Offset(menuRect.width, 0.0)); await popUpAndDown( buildFrame(alignment: Alignment.topCenter, value: menuItems.last) ); - expect(menuRect.topLeft, new Offset(buttonRect.left, 0.0)); - expect(menuRect.topRight, new Offset(buttonRect.right, 0.0)); + expect(menuRect.topLeft, Offset(buttonRect.left, 0.0)); + expect(menuRect.topRight, Offset(buttonRect.right, 0.0)); await popUpAndDown( buildFrame(alignment: Alignment.topRight, value: menuItems.last) ); - expect(menuRect.topLeft, new Offset(800.0 - menuRect.width, 0.0)); + expect(menuRect.topLeft, Offset(800.0 - menuRect.width, 0.0)); expect(menuRect.topRight, const Offset(800.0, 0.0)); // Dropdown button is along the middle of the app. The top of the menu is @@ -567,8 +567,8 @@ void main() { await popUpAndDown( buildFrame(alignment: Alignment.centerLeft, value: menuItems.first) ); - expect(menuRect.topLeft, new Offset(0.0, buttonRect.top)); - expect(menuRect.topRight, new Offset(menuRect.width, buttonRect.top)); + expect(menuRect.topLeft, Offset(0.0, buttonRect.top)); + expect(menuRect.topRight, Offset(menuRect.width, buttonRect.top)); await popUpAndDown( buildFrame(alignment: Alignment.center, value: menuItems.first) @@ -579,8 +579,8 @@ void main() { await popUpAndDown( buildFrame(alignment: Alignment.centerRight, value: menuItems.first) ); - expect(menuRect.topLeft, new Offset(800.0 - menuRect.width, buttonRect.top)); - expect(menuRect.topRight, new Offset(800.0, buttonRect.top)); + expect(menuRect.topLeft, Offset(800.0 - menuRect.width, buttonRect.top)); + expect(menuRect.topRight, Offset(800.0, buttonRect.top)); // Dropdown button is along the bottom of the app. The bottom of the menu is // aligned with the bottom of the expanded button and shifted horizontally @@ -590,18 +590,18 @@ void main() { buildFrame(alignment: Alignment.bottomLeft, value: menuItems.first) ); expect(menuRect.bottomLeft, const Offset(0.0, 600.0)); - expect(menuRect.bottomRight, new Offset(menuRect.width, 600.0)); + expect(menuRect.bottomRight, Offset(menuRect.width, 600.0)); await popUpAndDown( buildFrame(alignment: Alignment.bottomCenter, value: menuItems.first) ); - expect(menuRect.bottomLeft, new Offset(buttonRect.left, 600.0)); - expect(menuRect.bottomRight, new Offset(buttonRect.right, 600.0)); + expect(menuRect.bottomLeft, Offset(buttonRect.left, 600.0)); + expect(menuRect.bottomRight, Offset(buttonRect.right, 600.0)); await popUpAndDown( buildFrame(alignment: Alignment.bottomRight, value: menuItems.first) ); - expect(menuRect.bottomLeft, new Offset(800.0 - menuRect.width, 600.0)); + expect(menuRect.bottomLeft, Offset(800.0 - menuRect.width, 600.0)); expect(menuRect.bottomRight, const Offset(800.0, 600.0)); }); @@ -618,7 +618,7 @@ void main() { testWidgets('Semantics Tree contains only selected element', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(buildFrame(items: menuItems)); expect(semantics, isNot(includesNodeWith(label: menuItems[0]))); @@ -665,7 +665,7 @@ void main() { }); testWidgets('Dropdown menu includes semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const Key key = Key('test'); await tester.pumpWidget(buildFrame( buttonKey: key, @@ -675,40 +675,40 @@ void main() { await tester.tap(find.byKey(key)); await tester.pumpAndSettle(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute, ], label: 'Popup menu', children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: 'one', textDirection: TextDirection.ltr, tags: [const SemanticsTag('RenderViewport.twoPane')], actions: [SemanticsAction.tap], ), - new TestSemantics( + TestSemantics( label: 'two', textDirection: TextDirection.ltr, tags: [const SemanticsTag('RenderViewport.twoPane')], actions: [SemanticsAction.tap], ), - new TestSemantics( + TestSemantics( label: 'three', textDirection: TextDirection.ltr, tags: [const SemanticsTag('RenderViewport.twoPane')], actions: [SemanticsAction.tap], ), - new TestSemantics( + TestSemantics( label: 'four', textDirection: TextDirection.ltr, tags: [const SemanticsTag('RenderViewport.twoPane')], diff --git a/packages/flutter/test/material/expand_icon_test.dart b/packages/flutter/test/material/expand_icon_test.dart index 592b5968a0..2b537eb0ea 100644 --- a/packages/flutter/test/material/expand_icon_test.dart +++ b/packages/flutter/test/material/expand_icon_test.dart @@ -11,7 +11,7 @@ void main() { await tester.pumpWidget( wrap( - child: new ExpandIcon( + child: ExpandIcon( onPressed: (bool isExpanded) { expanded = !expanded; } @@ -45,7 +45,7 @@ void main() { await tester.pumpWidget( wrap( - child: new ExpandIcon( + child: ExpandIcon( isExpanded: false, onPressed: (bool isExpanded) { expanded = !expanded; @@ -56,7 +56,7 @@ void main() { await tester.pumpWidget( wrap( - child: new ExpandIcon( + child: ExpandIcon( isExpanded: true, onPressed: (bool isExpanded) { expanded = !expanded; @@ -73,7 +73,7 @@ void main() { await tester.pumpWidget( wrap( - child: new ExpandIcon( + child: ExpandIcon( isExpanded: expanded, onPressed: (bool isExpanded) { expanded = !isExpanded; @@ -89,7 +89,7 @@ void main() { final SemanticsHandle handle = tester.ensureSemantics(); const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations(); await tester.pumpWidget(wrap( - child: new ExpandIcon( + child: ExpandIcon( isExpanded: true, onPressed: (bool _) {}, ) @@ -104,7 +104,7 @@ void main() { )); await tester.pumpWidget(wrap( - child: new ExpandIcon( + child: ExpandIcon( isExpanded: false, onPressed: (bool _) {}, ) @@ -122,9 +122,9 @@ void main() { } Widget wrap({ Widget child }) { - return new MaterialApp( - home: new Center( - child: new Material(child: child), + return MaterialApp( + home: Center( + child: Material(child: child), ), ); } diff --git a/packages/flutter/test/material/expansion_panel_test.dart b/packages/flutter/test/material/expansion_panel_test.dart index c6abbfbfdd..eb8725d146 100644 --- a/packages/flutter/test/material/expansion_panel_test.dart +++ b/packages/flutter/test/material/expansion_panel_test.dart @@ -11,17 +11,17 @@ void main() { bool isExpanded; await tester.pumpWidget( - new MaterialApp( - home: new SingleChildScrollView( - child: new ExpansionPanelList( + MaterialApp( + home: SingleChildScrollView( + child: ExpansionPanelList( expansionCallback: (int _index, bool _isExpanded) { index = _index; isExpanded = _isExpanded; }, children: [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'B' : 'A'); + return Text(isExpanded ? 'B' : 'A'); }, body: const SizedBox(height: 100.0), ), @@ -44,17 +44,17 @@ void main() { // now expand the child panel await tester.pumpWidget( - new MaterialApp( - home: new SingleChildScrollView( - child: new ExpansionPanelList( + MaterialApp( + home: SingleChildScrollView( + child: ExpansionPanelList( expansionCallback: (int _index, bool _isExpanded) { index = _index; isExpanded = _isExpanded; }, children: [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'B' : 'A'); + return Text(isExpanded ? 'B' : 'A'); }, body: const SizedBox(height: 100.0), isExpanded: true, // this is the addition @@ -74,25 +74,25 @@ void main() { testWidgets('Multiple Panel List test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new ListView( + MaterialApp( + home: ListView( children: [ - new ExpansionPanelList( + ExpansionPanelList( children: [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'B' : 'A'); + return Text(isExpanded ? 'B' : 'A'); }, body: const SizedBox(height: 100.0), isExpanded: true, ), ], ), - new ExpansionPanelList( + ExpansionPanelList( children: [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'D' : 'C'); + return Text(isExpanded ? 'D' : 'C'); }, body: const SizedBox(height: 100.0), isExpanded: true, @@ -119,13 +119,13 @@ void main() { expect(kThemeAnimationDuration, lessThan(kSizeAnimationDuration ~/ 2)); Widget build(bool a, bool b, bool c) { - return new MaterialApp( - home: new Column( + return MaterialApp( + home: Column( children: [ - new ExpansionPanelList( + ExpansionPanelList( animationDuration: kSizeAnimationDuration, children: [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) => const Placeholder( fallbackHeight: 12.0, ), @@ -134,14 +134,14 @@ void main() { )), isExpanded: a, ), - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) => const Placeholder( fallbackHeight: 12.0, ), body: const SizedBox(height: 100.0, child: Placeholder()), isExpanded: b, ), - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) => const Placeholder( fallbackHeight: 12.0, ), @@ -157,37 +157,37 @@ void main() { await tester.pumpWidget(build(false, false, false)); expect(tester.renderObjectList(find.byType(AnimatedSize)), hasLength(3)); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(1)), new Rect.fromLTWH(0.0, 113.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(2)), new Rect.fromLTWH(0.0, 170.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(1)), Rect.fromLTWH(0.0, 113.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(2)), Rect.fromLTWH(0.0, 170.0, 800.0, 0.0)); await tester.pump(const Duration(milliseconds: 200)); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(1)), new Rect.fromLTWH(0.0, 113.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(2)), new Rect.fromLTWH(0.0, 170.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(1)), Rect.fromLTWH(0.0, 113.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(2)), Rect.fromLTWH(0.0, 170.0, 800.0, 0.0)); await tester.pumpWidget(build(false, true, false)); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(1)), new Rect.fromLTWH(0.0, 113.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(2)), new Rect.fromLTWH(0.0, 170.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(1)), Rect.fromLTWH(0.0, 113.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(2)), Rect.fromLTWH(0.0, 170.0, 800.0, 0.0)); await tester.pump(kSizeAnimationDuration ~/ 2); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); final Rect rect1 = tester.getRect(find.byType(AnimatedSize).at(1)); expect(rect1.left, 0.0); expect(rect1.top, inExclusiveRange(113.0, 113.0 + 16.0 + 32.0)); // 16.0 material gap, plus 16.0 top and bottom margins added to the header expect(rect1.width, 800.0); expect(rect1.height, inExclusiveRange(0.0, 100.0)); final Rect rect2 = tester.getRect(find.byType(AnimatedSize).at(2)); - expect(rect2, new Rect.fromLTWH(0.0, rect1.bottom + 16.0 + 56.0, 800.0, 0.0)); // the 16.0 comes from the MaterialGap being introduced, the 56.0 is the header height. + expect(rect2, Rect.fromLTWH(0.0, rect1.bottom + 16.0 + 56.0, 800.0, 0.0)); // the 16.0 comes from the MaterialGap being introduced, the 56.0 is the header height. await tester.pumpWidget(build(false, false, false)); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); expect(tester.getRect(find.byType(AnimatedSize).at(1)), rect1); expect(tester.getRect(find.byType(AnimatedSize).at(2)), rect2); await tester.pumpWidget(build(false, false, true)); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); expect(tester.getRect(find.byType(AnimatedSize).at(1)), rect1); expect(tester.getRect(find.byType(AnimatedSize).at(2)), rect2); @@ -195,36 +195,36 @@ void main() { await tester.pump(); await tester.pump(); await tester.pump(); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); expect(tester.getRect(find.byType(AnimatedSize).at(1)), rect1); expect(tester.getRect(find.byType(AnimatedSize).at(2)), rect2); await tester.pumpAndSettle(); - expect(tester.getRect(find.byType(AnimatedSize).at(0)), new Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(1)), new Rect.fromLTWH(0.0, 56.0 + 1.0 + 56.0, 800.0, 0.0)); - expect(tester.getRect(find.byType(AnimatedSize).at(2)), new Rect.fromLTWH(0.0, 56.0 + 1.0 + 56.0 + 16.0 + 16.0 + 48.0 + 16.0, 800.0, 100.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(0)), Rect.fromLTWH(0.0, 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(1)), Rect.fromLTWH(0.0, 56.0 + 1.0 + 56.0, 800.0, 0.0)); + expect(tester.getRect(find.byType(AnimatedSize).at(2)), Rect.fromLTWH(0.0, 56.0 + 1.0 + 56.0 + 16.0 + 16.0 + 48.0 + 16.0, 800.0, 100.0)); }); testWidgets('Single Panel Open Test', (WidgetTester tester) async { final List _demoItemsRadio = [ - new ExpansionPanelRadio( + ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'B' : 'A'); + return Text(isExpanded ? 'B' : 'A'); }, body: const SizedBox(height: 100.0), value: 0, ), - new ExpansionPanelRadio( + ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'D' : 'C'); + return Text(isExpanded ? 'D' : 'C'); }, body: const SizedBox(height: 100.0), value: 1, ), - new ExpansionPanelRadio( + ExpansionPanelRadio( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'F' : 'E'); + return Text(isExpanded ? 'F' : 'E'); }, body: const SizedBox(height: 100.0), value: 2, @@ -236,8 +236,8 @@ void main() { ); await tester.pumpWidget( - new MaterialApp( - home: new SingleChildScrollView( + MaterialApp( + home: SingleChildScrollView( child: _expansionListRadio, ), ), @@ -304,36 +304,36 @@ void main() { final List _demoItems = [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'B' : 'A'); + return Text(isExpanded ? 'B' : 'A'); }, body: const SizedBox(height: 100.0), isExpanded: false, ), - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'D' : 'C'); + return Text(isExpanded ? 'D' : 'C'); }, body: const SizedBox(height: 100.0), isExpanded: false, ), - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { - return new Text(isExpanded ? 'F' : 'E'); + return Text(isExpanded ? 'F' : 'E'); }, body: const SizedBox(height: 100.0), isExpanded: false, ), ]; - final ExpansionPanelList _expansionList = new ExpansionPanelList( + final ExpansionPanelList _expansionList = ExpansionPanelList( children: _demoItems, ); await tester.pumpWidget( - new MaterialApp( - home: new SingleChildScrollView( + MaterialApp( + home: SingleChildScrollView( child: _expansionList, ), ), @@ -354,14 +354,14 @@ void main() { const DefaultMaterialLocalizations localizations = DefaultMaterialLocalizations(); final SemanticsHandle handle = tester.ensureSemantics(); final List _demoItems = [ - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { return const Text('Expanded', key: expandedKey); }, body: const SizedBox(height: 100.0), isExpanded: true, ), - new ExpansionPanel( + ExpansionPanel( headerBuilder: (BuildContext context, bool isExpanded) { return const Text('Collapsed', key: collapsedKey); }, @@ -370,13 +370,13 @@ void main() { ), ]; - final ExpansionPanelList _expansionList = new ExpansionPanelList( + final ExpansionPanelList _expansionList = ExpansionPanelList( children: _demoItems, ); await tester.pumpWidget( - new MaterialApp( - home: new SingleChildScrollView( + MaterialApp( + home: SingleChildScrollView( child: _expansionList, ), ), diff --git a/packages/flutter/test/material/expansion_tile_test.dart b/packages/flutter/test/material/expansion_tile_test.dart index 468c51490e..cd7313a17a 100644 --- a/packages/flutter/test/material/expansion_tile_test.dart +++ b/packages/flutter/test/material/expansion_tile_test.dart @@ -10,41 +10,41 @@ void main() { const Color _dividerColor = Color(0x1f333333); testWidgets('ExpansionTile initial state', (WidgetTester tester) async { - final Key topKey = new UniqueKey(); + final Key topKey = UniqueKey(); const Key expandedKey = PageStorageKey('expanded'); const Key collapsedKey = PageStorageKey('collapsed'); const Key defaultKey = PageStorageKey('default'); - final Key tileKey = new UniqueKey(); + final Key tileKey = UniqueKey(); - await tester.pumpWidget(new MaterialApp( - theme: new ThemeData( + await tester.pumpWidget(MaterialApp( + theme: ThemeData( platform: TargetPlatform.iOS, dividerColor: _dividerColor, ), - home: new Material( - child: new SingleChildScrollView( - child: new Column( + home: Material( + child: SingleChildScrollView( + child: Column( children: [ - new ListTile(title: const Text('Top'), key: topKey), - new ExpansionTile( + ListTile(title: const Text('Top'), key: topKey), + ExpansionTile( key: expandedKey, initiallyExpanded: true, title: const Text('Expanded'), backgroundColor: Colors.red, children: [ - new ListTile( + ListTile( key: tileKey, title: const Text('0') ) ] ), - new ExpansionTile( + ExpansionTile( key: collapsedKey, initiallyExpanded: false, title: const Text('Collapsed'), children: [ - new ListTile( + ListTile( key: tileKey, title: const Text('0') ) diff --git a/packages/flutter/test/material/feedback_test.dart b/packages/flutter/test/material/feedback_test.dart index d94cfc0b0c..c17e0e377c 100644 --- a/packages/flutter/test/material/feedback_test.dart +++ b/packages/flutter/test/material/feedback_test.dart @@ -17,7 +17,7 @@ void main () { FeedbackTester feedback; setUp(() { - feedback = new FeedbackTester(); + feedback = FeedbackTester(); }); tearDown(() { @@ -40,9 +40,9 @@ void main () { }); testWidgets('forTap', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new TestWidget( + await tester.pumpWidget(TestWidget( tapHandler: (BuildContext context) { return () => Feedback.forTap(context); }, @@ -69,14 +69,14 @@ void main () { }); testWidgets('forTap Wrapper', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); int callbackCount = 0; final VoidCallback callback = () { callbackCount++; }; - await tester.pumpWidget(new TestWidget( + await tester.pumpWidget(TestWidget( tapHandler: (BuildContext context) { return Feedback.wrapForTap(callback, context); }, @@ -104,9 +104,9 @@ void main () { }); testWidgets('forLongPress', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new TestWidget( + await tester.pumpWidget(TestWidget( longPressHandler: (BuildContext context) { return () => Feedback.forLongPress(context); }, @@ -132,13 +132,13 @@ void main () { }); testWidgets('forLongPress Wrapper', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); int callbackCount = 0; final VoidCallback callback = () { callbackCount++; }; - await tester.pumpWidget(new TestWidget( + await tester.pumpWidget(TestWidget( longPressHandler: (BuildContext context) { return Feedback.wrapForLongPress(callback, context); }, @@ -169,9 +169,9 @@ void main () { group('Feedback on iOS', () { testWidgets('forTap', (WidgetTester tester) async { - await tester.pumpWidget(new Theme( - data: new ThemeData(platform: TargetPlatform.iOS), - child: new TestWidget( + await tester.pumpWidget(Theme( + data: ThemeData(platform: TargetPlatform.iOS), + child: TestWidget( tapHandler: (BuildContext context) { return () => Feedback.forTap(context); }, @@ -185,9 +185,9 @@ void main () { }); testWidgets('forLongPress', (WidgetTester tester) async { - await tester.pumpWidget(new Theme( - data: new ThemeData(platform: TargetPlatform.iOS), - child: new TestWidget( + await tester.pumpWidget(Theme( + data: ThemeData(platform: TargetPlatform.iOS), + child: TestWidget( longPressHandler: (BuildContext context) { return () => Feedback.forLongPress(context); }, @@ -216,7 +216,7 @@ class TestWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: tapHandler(context), onLongPress: longPressHandler(context), child: const Text('X', textDirection: TextDirection.ltr), diff --git a/packages/flutter/test/material/flat_button_test.dart b/packages/flutter/test/material/flat_button_test.dart index 3a7535e5de..8fd9ae3a6f 100644 --- a/packages/flutter/test/material/flat_button_test.dart +++ b/packages/flutter/test/material/flat_button_test.dart @@ -10,8 +10,8 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('FlatButton implements debugFillDescription', (WidgetTester tester) async { - final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); - new FlatButton( + final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); + FlatButton( onPressed: () {}, textColor: const Color(0xFF00FF00), disabledTextColor: const Color(0xFFFF0000), @@ -34,11 +34,11 @@ void main() { testWidgets('FlatButton has no clip by default', (WidgetTester tester) async{ await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new FlatButton( - child: new Container(), + child: Material( + child: FlatButton( + child: Container(), onPressed: () { /* to make sure the button is enabled */ }, ), ) diff --git a/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart b/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart index e8ded69085..8786e03b51 100644 --- a/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_collapse_mode_test.dart @@ -5,31 +5,31 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; -final Key blockKey = new UniqueKey(); +final Key blockKey = UniqueKey(); const double expandedAppbarHeight = 250.0; -final Key appbarContainerKey = new UniqueKey(); +final Key appbarContainerKey = UniqueKey(); void main() { testWidgets('FlexibleSpaceBar collapse mode none on Android', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - body: new CustomScrollView( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + body: CustomScrollView( key: blockKey, slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: expandedAppbarHeight, pinned: true, - flexibleSpace: new FlexibleSpaceBar( - background: new Container( + flexibleSpace: FlexibleSpaceBar( + background: Container( key: appbarContainerKey, ), collapseMode: CollapseMode.none, ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 10000.0, ), ), @@ -50,24 +50,24 @@ void main() { testWidgets('FlexibleSpaceBar collapse mode none on IOS', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - body: new CustomScrollView( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + body: CustomScrollView( key: blockKey, slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: expandedAppbarHeight, pinned: true, - flexibleSpace: new FlexibleSpaceBar( - background: new Container( + flexibleSpace: FlexibleSpaceBar( + background: Container( key: appbarContainerKey, ), collapseMode: CollapseMode.none, ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 10000.0, ), ), @@ -88,24 +88,24 @@ void main() { testWidgets('FlexibleSpaceBar collapse mode pin on Android', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - body: new CustomScrollView( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + body: CustomScrollView( key: blockKey, slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: expandedAppbarHeight, pinned: true, - flexibleSpace: new FlexibleSpaceBar( - background: new Container( + flexibleSpace: FlexibleSpaceBar( + background: Container( key: appbarContainerKey, ), collapseMode: CollapseMode.pin, ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 10000.0, ), ), @@ -126,24 +126,24 @@ void main() { testWidgets('FlexibleSpaceBar collapse mode pin on IOS', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - body: new CustomScrollView( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + body: CustomScrollView( key: blockKey, slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: expandedAppbarHeight, pinned: true, - flexibleSpace: new FlexibleSpaceBar( - background: new Container( + flexibleSpace: FlexibleSpaceBar( + background: Container( key: appbarContainerKey, ), collapseMode: CollapseMode.pin, ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 10000.0, ), ), @@ -166,24 +166,24 @@ void main() { testWidgets('FlexibleSpaceBar collapse mode parallax on Android', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - body: new CustomScrollView( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + body: CustomScrollView( key: blockKey, slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: expandedAppbarHeight, pinned: true, - flexibleSpace: new FlexibleSpaceBar( - background: new Container( + flexibleSpace: FlexibleSpaceBar( + background: Container( key: appbarContainerKey, ), collapseMode: CollapseMode.parallax, ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 10000.0, ), ), @@ -205,24 +205,24 @@ void main() { testWidgets('FlexibleSpaceBar collapse mode parallax on IOS', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - body: new CustomScrollView( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + body: CustomScrollView( key: blockKey, slivers: [ - new SliverAppBar( + SliverAppBar( expandedHeight: expandedAppbarHeight, pinned: true, - flexibleSpace: new FlexibleSpaceBar( - background: new Container( + flexibleSpace: FlexibleSpaceBar( + background: Container( key: appbarContainerKey, ), collapseMode: CollapseMode.parallax, ), ), - new SliverToBoxAdapter( - child: new Container( + SliverToBoxAdapter( + child: Container( height: 10000.0, ), ), diff --git a/packages/flutter/test/material/flexible_space_bar_test.dart b/packages/flutter/test/material/flexible_space_bar_test.dart index 1bfa6ef905..1c04e39dc9 100644 --- a/packages/flutter/test/material/flexible_space_bar_test.dart +++ b/packages/flutter/test/material/flexible_space_bar_test.dart @@ -8,10 +8,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('FlexibleSpaceBar centers title on iOS', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( flexibleSpace: const FlexibleSpaceBar( title: Text('X') ) @@ -26,13 +26,13 @@ void main() { expect(center.dx, lessThan(400.0 - size.width / 2.0)); // Clear the widget tree to avoid animating between Android and iOS. - await tester.pumpWidget(new Container(key: new UniqueKey())); + await tester.pumpWidget(Container(key: UniqueKey())); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: Scaffold( + appBar: AppBar( flexibleSpace: const FlexibleSpaceBar( title: Text('X') ) diff --git a/packages/flutter/test/material/floating_action_button_location_test.dart b/packages/flutter/test/material/floating_action_button_location_test.dart index 895b9392d3..2e13fc409b 100644 --- a/packages/flutter/test/material/floating_action_button_location_test.dart +++ b/packages/flutter/test/material/floating_action_button_location_test.dart @@ -75,7 +75,7 @@ void main() { }); testWidgets('interrupts in-progress animations without jumps', (WidgetTester tester) async { - final _GeometryListener geometryListener = new _GeometryListener(); + final _GeometryListener geometryListener = _GeometryListener(); ScaffoldGeometry geometry; _GeometryListenerState listenerState; Size previousRect; @@ -176,13 +176,13 @@ void main() { class _GeometryListener extends StatefulWidget { @override - State createState() => new _GeometryListenerState(); + State createState() => _GeometryListenerState(); } class _GeometryListenerState extends State<_GeometryListener> { @override Widget build(BuildContext context) { - return new CustomPaint( + return CustomPaint( painter: cache ); } @@ -203,7 +203,7 @@ class _GeometryListenerState extends State<_GeometryListener> { geometryListenable = newListenable; geometryListenable.addListener(onGeometryChanged); - cache = new _GeometryCachePainter(geometryListenable); + cache = _GeometryCachePainter(geometryListenable); } void onGeometryChanged() { @@ -243,12 +243,12 @@ Widget buildFrame({ EdgeInsets viewInsets = const EdgeInsets.only(bottom: 200.0), Widget bab, }) { - return new Directionality( + return Directionality( textDirection: textDirection, - child: new MediaQuery( - data: new MediaQueryData(viewInsets: viewInsets), - child: new Scaffold( - appBar: new AppBar(title: const Text('FabLocation Test')), + child: MediaQuery( + data: MediaQueryData(viewInsets: viewInsets), + child: Scaffold( + appBar: AppBar(title: const Text('FabLocation Test')), floatingActionButtonLocation: location, floatingActionButton: fab, bottomNavigationBar: bab, @@ -276,6 +276,6 @@ class _StartTopFloatingActionButtonLocation extends FloatingActionButtonLocation break; } final double fabY = scaffoldGeometry.contentTop - (scaffoldGeometry.floatingActionButtonSize.height / 2.0); - return new Offset(fabX, fabY); + return Offset(fabX, fabY); } } diff --git a/packages/flutter/test/material/floating_action_button_test.dart b/packages/flutter/test/material/floating_action_button_test.dart index 09aa3fd5f4..63bf4ed616 100644 --- a/packages/flutter/test/material/floating_action_button_test.dart +++ b/packages/flutter/test/material/floating_action_button_test.dart @@ -16,10 +16,10 @@ void main() { testWidgets('Floating Action Button control test', (WidgetTester tester) async { bool didPressButton = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new FloatingActionButton( + child: Center( + child: FloatingActionButton( onPressed: () { didPressButton = true; }, @@ -36,7 +36,7 @@ void main() { testWidgets('Floating Action Button tooltip', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( floatingActionButton: FloatingActionButton( onPressed: null, @@ -54,7 +54,7 @@ void main() { // Regression test for: https://github.com/flutter/flutter/pull/21084 testWidgets('Floating Action Button tooltip (long press button edge)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( floatingActionButton: FloatingActionButton( onPressed: null, @@ -75,7 +75,7 @@ void main() { // Regression test for: https://github.com/flutter/flutter/pull/21084 testWidgets('Floating Action Button tooltip (long press button edge - no child)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( floatingActionButton: FloatingActionButton( onPressed: null, @@ -94,7 +94,7 @@ void main() { testWidgets('Floating Action Button tooltip (no child)', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( floatingActionButton: FloatingActionButton( onPressed: null, @@ -111,13 +111,13 @@ void main() { }); testWidgets('FlatActionButton mini size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); + final Key key1 = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Scaffold( - floatingActionButton: new FloatingActionButton( + MaterialApp( + home: Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Scaffold( + floatingActionButton: FloatingActionButton( key: key1, mini: true, onPressed: null, @@ -129,13 +129,13 @@ void main() { expect(tester.getSize(find.byKey(key1)), const Size(48.0, 48.0)); - final Key key2 = new UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Scaffold( - floatingActionButton: new FloatingActionButton( + MaterialApp( + home: Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Scaffold( + floatingActionButton: FloatingActionButton( key: key2, mini: true, onPressed: null, @@ -150,7 +150,7 @@ void main() { testWidgets('FloatingActionButton.isExtended', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( floatingActionButton: FloatingActionButton(onPressed: null), ), @@ -167,9 +167,9 @@ void main() { expect(getFabWidget().shape, const CircleBorder()); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - floatingActionButton: new FloatingActionButton.extended( + MaterialApp( + home: Scaffold( + floatingActionButton: FloatingActionButton.extended( label: const SizedBox( width: 100.0, child: Text('label'), @@ -210,9 +210,9 @@ void main() { testWidgets('Floating Action Button heroTag', (WidgetTester tester) async { BuildContext theContext; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { theContext = context; return const FloatingActionButton(heroTag: 1, onPressed: null); @@ -222,7 +222,7 @@ void main() { ), ), ); - Navigator.push(theContext, new PageRouteBuilder( + Navigator.push(theContext, PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { return const Placeholder(); }, @@ -233,9 +233,9 @@ void main() { testWidgets('Floating Action Button heroTag - with duplicate', (WidgetTester tester) async { BuildContext theContext; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { theContext = context; return const FloatingActionButton(onPressed: null); @@ -245,7 +245,7 @@ void main() { ), ), ); - Navigator.push(theContext, new PageRouteBuilder( + Navigator.push(theContext, PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { return const Placeholder(); }, @@ -257,9 +257,9 @@ void main() { testWidgets('Floating Action Button heroTag - with duplicate', (WidgetTester tester) async { BuildContext theContext; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { theContext = context; return const FloatingActionButton(heroTag: 'xyzzy', onPressed: null); @@ -269,7 +269,7 @@ void main() { ), ), ); - Navigator.push(theContext, new PageRouteBuilder( + Navigator.push(theContext, PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { return const Placeholder(); }, @@ -279,13 +279,13 @@ void main() { }); testWidgets('Floating Action Button semantics (enabled)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new FloatingActionButton( + child: Center( + child: FloatingActionButton( onPressed: () { }, child: const Icon(Icons.add, semanticLabel: 'Add'), ), @@ -293,9 +293,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Add', flags: [ SemanticsFlag.isButton, @@ -313,7 +313,7 @@ void main() { }); testWidgets('Floating Action Button semantics (disabled)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const Directionality( @@ -327,9 +327,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Add', flags: [ SemanticsFlag.isButton, @@ -343,12 +343,12 @@ void main() { }); testWidgets('Tooltip is used as semantics label', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - floatingActionButton: new FloatingActionButton( + MaterialApp( + home: Scaffold( + floatingActionButton: FloatingActionButton( onPressed: () { }, tooltip: 'Add Photo', child: const Icon(Icons.add_a_photo), @@ -357,16 +357,16 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.scopesRoute, ], children: [ - new TestSemantics( + TestSemantics( label: 'Add Photo', actions: [ SemanticsAction.tap @@ -391,24 +391,24 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/18782 await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - floatingActionButton: new Builder( + MaterialApp( + home: Scaffold( + floatingActionButton: Builder( builder: (BuildContext context) { // define context of Navigator.push() - return new FloatingActionButton.extended( + return FloatingActionButton.extended( icon: const Icon(Icons.add), label: const Text('A long FAB label'), onPressed: () { - Navigator.push(context, new MaterialPageRoute( + Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { - return new Scaffold( - floatingActionButton: new FloatingActionButton.extended( + return Scaffold( + floatingActionButton: FloatingActionButton.extended( icon: const Icon(Icons.add), label: const Text('X'), onPressed: () { }, ), - body: new Center( - child: new RaisedButton( + body: Center( + child: RaisedButton( child: const Text('POP'), onPressed: () { Navigator.pop(context); @@ -454,14 +454,14 @@ void main() { // This test prevents https://github.com/flutter/flutter/issues/20483 testWidgets('Floating Action Button clips ink splash and highlight', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Center( - child: new RepaintBoundary( + MaterialApp( + home: Scaffold( + body: Center( + child: RepaintBoundary( key: key, - child: new FloatingActionButton( + child: FloatingActionButton( onPressed: () {}, child: const Icon(Icons.add), ), @@ -483,10 +483,10 @@ void main() { testWidgets('Floating Action Button has no clip by default', (WidgetTester tester) async{ await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new FloatingActionButton( + child: Material( + child: FloatingActionButton( onPressed: () { /* to make sure the button is enabled */ }, ), ) diff --git a/packages/flutter/test/material/grid_title_test.dart b/packages/flutter/test/material/grid_title_test.dart index 6b117c8b6b..e5575f5575 100644 --- a/packages/flutter/test/material/grid_title_test.dart +++ b/packages/flutter/test/material/grid_title_test.dart @@ -7,24 +7,24 @@ import 'package:flutter/material.dart'; void main() { testWidgets('GridTile control test', (WidgetTester tester) async { - final Key headerKey = new UniqueKey(); - final Key footerKey = new UniqueKey(); + final Key headerKey = UniqueKey(); + final Key footerKey = UniqueKey(); - await tester.pumpWidget(new MaterialApp( - home: new GridTile( - header: new GridTileBar( + await tester.pumpWidget(MaterialApp( + home: GridTile( + header: GridTileBar( key: headerKey, leading: const Icon(Icons.thumb_up), title: const Text('Header'), subtitle: const Text('Subtitle'), trailing: const Icon(Icons.thumb_up), ), - child: new DecoratedBox( - decoration: new BoxDecoration( + child: DecoratedBox( + decoration: BoxDecoration( color: Colors.green[500], ), ), - footer: new GridTileBar( + footer: GridTileBar( key: footerKey, title: const Text('Footer'), backgroundColor: Colors.black38, diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index 70a8b179c3..1e3fdc78f4 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -23,13 +23,13 @@ void main() { MockOnPressedFunction mockOnPressedFunction; setUp(() { - mockOnPressedFunction = new MockOnPressedFunction(); + mockOnPressedFunction = MockOnPressedFunction(); }); testWidgets('test default icon buttons are sized up to 48', (WidgetTester tester) async { await tester.pumpWidget( wrap( - child: new IconButton( + child: IconButton( onPressed: mockOnPressedFunction, icon: const Icon(Icons.link), ), @@ -46,7 +46,7 @@ void main() { testWidgets('test small icons are sized up to 48dp', (WidgetTester tester) async { await tester.pumpWidget( wrap( - child: new IconButton( + child: IconButton( iconSize: 10.0, onPressed: mockOnPressedFunction, icon: const Icon(Icons.link), @@ -61,7 +61,7 @@ void main() { testWidgets('test icons can be small when total size is >48dp', (WidgetTester tester) async { await tester.pumpWidget( wrap( - child: new IconButton( + child: IconButton( iconSize: 10.0, padding: const EdgeInsets.all(30.0), onPressed: mockOnPressedFunction, @@ -77,7 +77,7 @@ void main() { testWidgets('test default icon buttons are constrained', (WidgetTester tester) async { await tester.pumpWidget( wrap( - child: new IconButton( + child: IconButton( padding: EdgeInsets.zero, onPressed: mockOnPressedFunction, icon: const Icon(Icons.ac_unit), @@ -94,13 +94,13 @@ void main() { 'test default icon buttons can be stretched if specified', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Row( + child: Material( + child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new IconButton( + IconButton( onPressed: mockOnPressedFunction, icon: const Icon(Icons.ac_unit), ), @@ -117,7 +117,7 @@ void main() { testWidgets('test default padding', (WidgetTester tester) async { await tester.pumpWidget( wrap( - child: new IconButton( + child: IconButton( onPressed: mockOnPressedFunction, icon: const Icon(Icons.ac_unit), iconSize: 80.0, @@ -131,10 +131,10 @@ void main() { testWidgets('test tooltip', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new IconButton( + MaterialApp( + home: Material( + child: Center( + child: IconButton( onPressed: mockOnPressedFunction, icon: const Icon(Icons.ac_unit), ), @@ -146,13 +146,13 @@ void main() { expect(find.byType(Tooltip), findsNothing); // Clear the widget tree. - await tester.pumpWidget(new Container(key: new UniqueKey())); + await tester.pumpWidget(Container(key: UniqueKey())); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new IconButton( + MaterialApp( + home: Material( + child: Center( + child: IconButton( onPressed: mockOnPressedFunction, icon: const Icon(Icons.ac_unit), tooltip: 'Test tooltip', @@ -171,11 +171,11 @@ void main() { testWidgets('IconButton AppBar size', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + home: Scaffold( + appBar: AppBar( actions: [ - new IconButton( + IconButton( padding: EdgeInsets.zero, onPressed: mockOnPressedFunction, icon: const Icon(Icons.ac_unit), @@ -198,7 +198,7 @@ void main() { const Color directHighlightColor = Color(0xFF0000F0); Widget buttonWidget = wrap( - child: new IconButton( + child: IconButton( icon: const Icon(Icons.android), splashColor: directSplashColor, highlightColor: directHighlightColor, @@ -207,8 +207,8 @@ void main() { ); await tester.pumpWidget( - new Theme( - data: new ThemeData(), + Theme( + data: ThemeData(), child: buttonWidget, ), ); @@ -229,15 +229,15 @@ void main() { const Color themeHighlightColor1 = Color(0xFF00FF00); buttonWidget = wrap( - child: new IconButton( + child: IconButton( icon: const Icon(Icons.android), onPressed: () { /* enable the button */ }, ), ); await tester.pumpWidget( - new Theme( - data: new ThemeData( + Theme( + data: ThemeData( highlightColor: themeHighlightColor1, splashColor: themeSplashColor1, ), @@ -256,8 +256,8 @@ void main() { const Color themeHighlightColor2 = Color(0xFF001100); await tester.pumpWidget( - new Theme( - data: new ThemeData( + Theme( + data: ThemeData( highlightColor: themeHighlightColor2, splashColor: themeSplashColor2, ), @@ -276,21 +276,21 @@ void main() { }); testWidgets('IconButton Semantics (enabled)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( wrap( - child: new IconButton( + child: IconButton( onPressed: mockOnPressedFunction, icon: const Icon(Icons.link, semanticLabel: 'link'), ), ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( - rect: new Rect.fromLTRB(0.0, 0.0, 48.0, 48.0), + TestSemantics.rootChild( + rect: Rect.fromLTRB(0.0, 0.0, 48.0, 48.0), actions: [ SemanticsAction.tap ], @@ -308,7 +308,7 @@ void main() { }); testWidgets('IconButton Semantics (disabled)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( wrap( @@ -319,10 +319,10 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( - rect: new Rect.fromLTRB(0.0, 0.0, 48.0, 48.0), + TestSemantics.rootChild( + rect: Rect.fromLTRB(0.0, 0.0, 48.0, 48.0), flags: [ SemanticsFlag.hasEnabledState, SemanticsFlag.isButton @@ -337,10 +337,10 @@ void main() { } Widget wrap({ Widget child }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center(child: child), + child: Material( + child: Center(child: child), ), ); } diff --git a/packages/flutter/test/material/ink_paint_test.dart b/packages/flutter/test/material/ink_paint_test.dart index 908b63a5c7..c610399a96 100644 --- a/packages/flutter/test/material/ink_paint_test.dart +++ b/packages/flutter/test/material/ink_paint_test.dart @@ -12,17 +12,17 @@ void main() { testWidgets('The InkWell widget renders an ink splash', (WidgetTester tester) async { const Color highlightColor = Color(0xAAFF0000); const Color splashColor = Color(0xAA0000FF); - final BorderRadius borderRadius = new BorderRadius.circular(6.0); + final BorderRadius borderRadius = BorderRadius.circular(6.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Container( + child: Material( + child: Center( + child: Container( width: 200.0, height: 60.0, - child: new InkWell( + child: InkWell( borderRadius: borderRadius, highlightColor: highlightColor, splashColor: splashColor, @@ -46,11 +46,11 @@ void main() { ..translate(x: 0.0, y: 0.0) ..save() ..translate(x: 300.0, y: 270.0) - ..clipRRect(rrect: new RRect.fromLTRBR(0.0, 0.0, 200.0, 60.0, const Radius.circular(6.0))) + ..clipRRect(rrect: RRect.fromLTRBR(0.0, 0.0, 200.0, 60.0, const Radius.circular(6.0))) ..circle(x: 100.0, y: 30.0, radius: 21.0, color: splashColor) ..restore() ..rrect( - rrect: new RRect.fromLTRBR(300.0, 270.0, 500.0, 330.0, const Radius.circular(6.0)), + rrect: RRect.fromLTRBR(300.0, 270.0, 500.0, 330.0, const Radius.circular(6.0)), color: highlightColor, ) ); @@ -61,17 +61,17 @@ void main() { testWidgets('The InkWell widget renders an ink ripple', (WidgetTester tester) async { const Color highlightColor = Color(0xAAFF0000); const Color splashColor = Color(0xB40000FF); - final BorderRadius borderRadius = new BorderRadius.circular(6.0); + final BorderRadius borderRadius = BorderRadius.circular(6.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Container( + child: Material( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new InkWell( + child: InkWell( borderRadius: borderRadius, highlightColor: highlightColor, splashColor: splashColor, @@ -144,15 +144,15 @@ void main() { testWidgets('Does the Ink widget render anything', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Ink( + child: Material( + child: Center( + child: Ink( color: Colors.blue, width: 200.0, height: 200.0, - child: new InkWell( + child: InkWell( splashColor: Colors.green, onTap: () { }, ), @@ -171,20 +171,20 @@ void main() { expect( box, paints - ..rect(rect: new Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), color: new Color(Colors.blue.value)) - ..circle(color: new Color(Colors.green.value)) + ..rect(rect: Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), color: Color(Colors.blue.value)) + ..circle(color: Color(Colors.green.value)) ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Ink( + child: Material( + child: Center( + child: Ink( color: Colors.red, width: 200.0, height: 200.0, - child: new InkWell( + child: InkWell( splashColor: Colors.green, onTap: () { }, ), @@ -199,16 +199,16 @@ void main() { expect( box, paints - ..rect(rect: new Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), color: new Color(Colors.red.value)) - ..circle(color: new Color(Colors.green.value)) + ..rect(rect: Rect.fromLTRB(300.0, 200.0, 500.0, 400.0), color: Color(Colors.red.value)) + ..circle(color: Color(Colors.green.value)) ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new InkWell( // this is at a different depth in the tree so it's now a new InkWell + child: Material( + child: Center( + child: InkWell( // this is at a different depth in the tree so it's now a new InkWell splashColor: Colors.green, onTap: () { }, ), @@ -228,14 +228,14 @@ void main() { testWidgets('Cancel an InkRipple that was disposed when its animation ended', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/14391 await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Container( + child: Material( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new InkWell( + child: InkWell( onTap: () { }, radius: 100.0, splashFactory: InkRipple.splashFactory, @@ -264,14 +264,14 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/14391 await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Container( + child: Material( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new InkWell( + child: InkWell( splashColor: splashColor, highlightColor: highlightColor, onTap: () { }, diff --git a/packages/flutter/test/material/ink_splash_test.dart b/packages/flutter/test/material/ink_splash_test.dart index c9119b1089..df38341c34 100644 --- a/packages/flutter/test/material/ink_splash_test.dart +++ b/packages/flutter/test/material/ink_splash_test.dart @@ -8,14 +8,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { // Regression test for https://github.com/flutter/flutter/issues/21506. testWidgets('InkSplash receives textDirection', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - appBar: new AppBar(title: const Text('Button Border Test')), - body: new Center( - child: new RaisedButton( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Button Border Test')), + body: Center( + child: RaisedButton( child: const Text('Test'), onPressed: () {}, - shape: new Border.all( + shape: Border.all( color: Colors.blue, ), ), diff --git a/packages/flutter/test/material/ink_well_test.dart b/packages/flutter/test/material/ink_well_test.dart index b0c921a7fd..89ba576c4d 100644 --- a/packages/flutter/test/material/ink_well_test.dart +++ b/packages/flutter/test/material/ink_well_test.dart @@ -15,11 +15,11 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new InkWell( + child: Material( + child: Center( + child: InkWell( onTap: () { log.add('tap'); }, @@ -94,7 +94,7 @@ void main() { FeedbackTester feedback; setUp(() { - feedback = new FeedbackTester(); + feedback = FeedbackTester(); }); tearDown(() { @@ -102,11 +102,11 @@ void main() { }); testWidgets('enabled (default)', (WidgetTester tester) async { - await tester.pumpWidget(new Material( - child: new Directionality( + await tester.pumpWidget(Material( + child: Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new InkWell( + child: Center( + child: InkWell( onTap: () {}, onLongPress: () {}, ), @@ -130,11 +130,11 @@ void main() { }); testWidgets('disabled', (WidgetTester tester) async { - await tester.pumpWidget(new Material( - child: new Directionality( + await tester.pumpWidget(Material( + child: Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new InkWell( + child: Center( + child: InkWell( onTap: () {}, onLongPress: () {}, enableFeedback: false, @@ -157,17 +157,17 @@ void main() { testWidgets('splashing survives scrolling when keep-alive is enabled', (WidgetTester tester) async { Future runTest(bool keepAlive) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new CompositedTransformFollower( // forces a layer, which makes the paints easier to separate out - link: new LayerLink(), - child: new ListView( + child: Material( + child: CompositedTransformFollower( // forces a layer, which makes the paints easier to separate out + link: LayerLink(), + child: ListView( addAutomaticKeepAlives: keepAlive, children: [ - new Container(height: 500.0, child: new InkWell(onTap: () { }, child: const Placeholder())), - new Container(height: 500.0), - new Container(height: 500.0), + Container(height: 500.0, child: InkWell(onTap: () { }, child: const Placeholder())), + Container(height: 500.0), + Container(height: 500.0), ], ), ), @@ -193,12 +193,12 @@ void main() { }); testWidgets('excludeFromSemantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new InkWell( + child: Material( + child: InkWell( onTap: () { }, child: const Text('Button'), ), @@ -206,10 +206,10 @@ void main() { )); expect(semantics, includesNodeWith(label: 'Button', actions: [SemanticsAction.tap])); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new InkWell( + child: Material( + child: InkWell( onTap: () { }, child: const Text('Button'), excludeFromSemantics: true, diff --git a/packages/flutter/test/material/input_decorator_test.dart b/packages/flutter/test/material/input_decorator_test.dart index fa650eed59..8efce8295b 100644 --- a/packages/flutter/test/material/input_decorator_test.dart +++ b/packages/flutter/test/material/input_decorator_test.dart @@ -22,19 +22,19 @@ Widget buildInputDecorator({ style: TextStyle(fontFamily: 'Ahem', fontSize: 16.0), ), }) { - return new MaterialApp( - home: new Material( - child: new Builder( + return MaterialApp( + home: Material( + child: Builder( builder: (BuildContext context) { - return new Theme( + return Theme( data: Theme.of(context).copyWith( inputDecorationTheme: inputDecorationTheme, ), - child: new Align( + child: Align( alignment: Alignment.topLeft, - child: new Directionality( + child: Directionality( textDirection: textDirection, - child: new InputDecorator( + child: InputDecorator( decoration: decoration, isEmpty: isEmpty, isFocused: isFocused, @@ -1344,7 +1344,7 @@ void main() { buildInputDecorator( isEmpty: true, // label appears, vertically centered // isFocused: false (default) - inputDecorationTheme: new InputDecorationTheme( + inputDecorationTheme: InputDecorationTheme( labelStyle: labelStyle, hintStyle: hintStyle, prefixStyle: prefixStyle, @@ -1448,7 +1448,7 @@ void main() { 'suffixIcon', ])); - final Set nodeValues = new Set.from( + final Set nodeValues = Set.from( renderer.debugDescribeChildren().map((DiagnosticsNode node) => node.value) ); expect(nodeValues.length, 11); @@ -1562,11 +1562,11 @@ void main() { buildInputDecorator( // isEmpty: false (default) // isFocused: false (default) - decoration: new InputDecoration( + decoration: InputDecoration( filled: true, fillColor: const Color(0xFF00FF00), - border: new OutlineInputBorder( - borderRadius: new BorderRadius.circular(12.0), + border: OutlineInputBorder( + borderRadius: BorderRadius.circular(12.0), ), ), ), @@ -1591,7 +1591,7 @@ void main() { expect(box, paints..rrect( style: PaintingStyle.stroke, strokeWidth: 1.0, - rrect: new RRect.fromLTRBR(0.5, 0.5, 799.5, 55.5, const Radius.circular(11.5)), + rrect: RRect.fromLTRBR(0.5, 0.5, 799.5, 55.5, const Radius.circular(11.5)), )); }); @@ -1630,11 +1630,11 @@ void main() { testWidgets('InputDecorator constrained to 0x0', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/17710 await tester.pumpWidget( - new Material( - child: new Directionality( + Material( + child: Directionality( textDirection: TextDirection.ltr, - child: new UnconstrainedBox(child: new ConstrainedBox( - constraints: new BoxConstraints.tight(Size.zero), + child: UnconstrainedBox(child: ConstrainedBox( + constraints: BoxConstraints.tight(Size.zero), child: const InputDecorator( decoration: InputDecoration( labelText: 'XP', @@ -1653,12 +1653,12 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/18111 Widget buildFrame(TextDirection textDirection) { - return new MaterialApp( - home: new Scaffold( - body: new Container( + return MaterialApp( + home: Scaffold( + body: Container( padding: const EdgeInsets.all(16.0), alignment: Alignment.center, - child: new Directionality( + child: Directionality( textDirection: textDirection, child: const RepaintBoundary( child: InputDecorator( diff --git a/packages/flutter/test/material/list_tile_test.dart b/packages/flutter/test/material/list_tile_test.dart index ae72b2fa63..39ecd205f2 100644 --- a/packages/flutter/test/material/list_tile_test.dart +++ b/packages/flutter/test/material/list_tile_test.dart @@ -14,7 +14,7 @@ class TestIcon extends StatefulWidget { const TestIcon({ Key key }) : super(key: key); @override - TestIconState createState() => new TestIconState(); + TestIconState createState() => TestIconState(); } class TestIconState extends State { @@ -33,7 +33,7 @@ class TestText extends StatefulWidget { final String text; @override - TestTextState createState() => new TestTextState(); + TestTextState createState() => TestTextState(); } class TestTextState extends State { @@ -42,7 +42,7 @@ class TestTextState extends State { @override Widget build(BuildContext context) { textStyle = DefaultTextStyle.of(context).style; - return new Text(widget.text); + return Text(widget.text); } } @@ -50,8 +50,8 @@ void main() { testWidgets('ListTile geometry (LTR)', (WidgetTester tester) async { // See https://material.io/go/design-lists - final Key leadingKey = new GlobalKey(); - final Key trailingKey = new GlobalKey(); + final Key leadingKey = GlobalKey(); + final Key trailingKey = GlobalKey(); bool hasSubtitle; const double leftPadding = 10.0; @@ -59,19 +59,19 @@ void main() { Widget buildFrame({ bool dense = false, bool isTwoLine = false, bool isThreeLine = false, double textScaleFactor = 1.0, double subtitleScaleFactor }) { hasSubtitle = isTwoLine || isThreeLine; subtitleScaleFactor ??= textScaleFactor; - return new MaterialApp( - home: new MediaQuery( - data: new MediaQueryData( + return MaterialApp( + home: MediaQuery( + data: MediaQueryData( padding: const EdgeInsets.only(left: leftPadding, right: rightPadding), textScaleFactor: textScaleFactor, ), - child: new Material( - child: new Center( - child: new ListTile( - leading: new Container(key: leadingKey, width: 24.0, height: 24.0), + child: Material( + child: Center( + child: ListTile( + leading: Container(key: leadingKey, width: 24.0, height: 24.0), title: const Text('title'), - subtitle: hasSubtitle ? new Text('subtitle', textScaleFactor: subtitleScaleFactor) : null, - trailing: new Container(key: trailingKey, width: 24.0, height: 24.0), + subtitle: hasSubtitle ? Text('subtitle', textScaleFactor: subtitleScaleFactor) : null, + trailing: Container(key: trailingKey, width: 24.0, height: 24.0), dense: dense, isThreeLine: isThreeLine, ), @@ -114,7 +114,7 @@ void main() { void testVerticalGeometry(double expectedHeight) { final Rect tileRect = tester.getRect(find.byType(ListTile)); - expect(tileRect.size, new Size(800.0, expectedHeight)); + expect(tileRect.size, Size(800.0, expectedHeight)); expect(top('title'), greaterThanOrEqualTo(tileRect.top)); if (hasSubtitle) { expect(top('subtitle'), greaterThanOrEqualTo(bottom('title'))); @@ -228,14 +228,14 @@ void main() { testWidgets('ListTile.divideTiles', (WidgetTester tester) async { final List titles = [ 'first', 'second', 'third' ]; - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new Builder( + await tester.pumpWidget(MaterialApp( + home: Material( + child: Builder( builder: (BuildContext context) { - return new ListView( + return ListView( children: ListTile.divideTiles( context: context, - tiles: titles.map((String title) => new ListTile(title: new Text(title))), + tiles: titles.map((String title) => ListTile(title: Text(title))), ).toList(), ); }, @@ -249,10 +249,10 @@ void main() { }); testWidgets('ListTileTheme', (WidgetTester tester) async { - final Key titleKey = new UniqueKey(); - final Key subtitleKey = new UniqueKey(); - final Key leadingKey = new UniqueKey(); - final Key trailingKey = new UniqueKey(); + final Key titleKey = UniqueKey(); + final Key subtitleKey = UniqueKey(); + final Key leadingKey = UniqueKey(); + final Key trailingKey = UniqueKey(); ThemeData theme; Widget buildFrame({ @@ -263,24 +263,24 @@ void main() { Color iconColor, Color textColor, }) { - return new MaterialApp( - home: new Material( - child: new Center( - child: new ListTileTheme( + return MaterialApp( + home: Material( + child: Center( + child: ListTileTheme( dense: dense, selectedColor: selectedColor, iconColor: iconColor, textColor: textColor, - child: new Builder( + child: Builder( builder: (BuildContext context) { theme = Theme.of(context); - return new ListTile( + return ListTile( enabled: enabled, selected: selected, - leading: new TestIcon(key: leadingKey), - trailing: new TestIcon(key: trailingKey), - title: new TestText('title', key: titleKey), - subtitle: new TestText('subtitle', key: subtitleKey), + leading: TestIcon(key: leadingKey), + trailing: TestIcon(key: trailingKey), + title: TestText('title', key: titleKey), + subtitle: TestText('subtitle', key: subtitleKey), ); } ), @@ -340,15 +340,15 @@ void main() { }); testWidgets('ListTile semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Material( - child: new Directionality( + Material( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Column( + child: Column( children: const [ ListTile( title: Text('one'), @@ -369,16 +369,16 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'one', flags: [ SemanticsFlag.hasEnabledState, SemanticsFlag.isEnabled, ], ), - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'two', flags: [ SemanticsFlag.isSelected, @@ -386,7 +386,7 @@ void main() { SemanticsFlag.isEnabled, ], ), - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'three', flags: [ SemanticsFlag.hasEnabledState, @@ -402,15 +402,15 @@ void main() { testWidgets('ListTile contentPadding', (WidgetTester tester) async { Widget buildFrame(TextDirection textDirection) { - return new MediaQuery( + return MediaQuery( data: const MediaQueryData( padding: EdgeInsets.zero, textScaleFactor: 1.0 ), - child: new Directionality( + child: Directionality( textDirection: textDirection, - child: new Material( - child: new Container( + child: Material( + child: Container( alignment: Alignment.topLeft, child: const ListTile( contentPadding: EdgeInsetsDirectional.only( @@ -447,15 +447,15 @@ void main() { testWidgets('ListTile contentPadding', (WidgetTester tester) async { Widget buildFrame(TextDirection textDirection) { - return new MediaQuery( + return MediaQuery( data: const MediaQueryData( padding: EdgeInsets.zero, textScaleFactor: 1.0 ), - child: new Directionality( + child: Directionality( textDirection: textDirection, - child: new Material( - child: new Container( + child: Material( + child: Container( alignment: Alignment.topLeft, child: const ListTile( contentPadding: EdgeInsetsDirectional.only( @@ -494,19 +494,19 @@ void main() { const Key leadingKey = ValueKey('L'); Widget buildFrame(double leadingWidth, TextDirection textDirection) { - return new MediaQuery( + return MediaQuery( data: const MediaQueryData( padding: EdgeInsets.zero, textScaleFactor: 1.0 ), - child: new Directionality( + child: Directionality( textDirection: textDirection, - child: new Material( - child: new Container( + child: Material( + child: Container( alignment: Alignment.topLeft, - child: new ListTile( + child: ListTile( contentPadding: EdgeInsets.zero, - leading: new SizedBox(key: leadingKey, width: leadingWidth, height: 32.0), + leading: SizedBox(key: leadingKey, width: leadingWidth, height: 32.0), title: const Text('title'), subtitle: const Text('subtitle'), ), diff --git a/packages/flutter/test/material/material_test.dart b/packages/flutter/test/material/material_test.dart index a656f052c3..202cd811b8 100644 --- a/packages/flutter/test/material/material_test.dart +++ b/packages/flutter/test/material/material_test.dart @@ -12,18 +12,18 @@ import '../rendering/mock_canvas.dart'; class NotifyMaterial extends StatelessWidget { @override Widget build(BuildContext context) { - new LayoutChangedNotification().dispatch(context); - return new Container(); + LayoutChangedNotification().dispatch(context); + return Container(); } } Widget buildMaterial( {double elevation = 0.0, Color shadowColor = const Color(0xFF00FF00)}) { - return new Center( - child: new SizedBox( + return Center( + child: SizedBox( height: 100.0, width: 100.0, - child: new Material( + child: Material( shadowColor: shadowColor, elevation: elevation, shape: const CircleBorder(), @@ -44,7 +44,7 @@ class PaintRecorder extends CustomPainter { @override void paint(Canvas canvas, Size size) { log.add(size); - final Paint paint = new Paint()..color = const Color(0xFF0000FF); + final Paint paint = Paint()..color = const Color(0xFF0000FF); canvas.drawRect(Offset.zero & size, paint); } @@ -55,8 +55,8 @@ class PaintRecorder extends CustomPainter { void main() { testWidgets('LayoutChangedNotification test', (WidgetTester tester) async { await tester.pumpWidget( - new Material( - child: new NotifyMaterial(), + Material( + child: NotifyMaterial(), ), ); }); @@ -65,36 +65,36 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new SizedBox( + SizedBox( width: 150.0, height: 150.0, - child: new CustomPaint( - painter: new PaintRecorder(log), + child: CustomPaint( + painter: PaintRecorder(log), ), ), - new Expanded( - child: new Material( - child: new Column( + Expanded( + child: Material( + child: Column( children: [ - new Expanded( - child: new ListView( + Expanded( + child: ListView( children: [ - new Container( + Container( height: 2000.0, color: const Color(0xFF00FF00), ), ], ), ), - new SizedBox( + SizedBox( width: 100.0, height: 100.0, - child: new CustomPaint( - painter: new PaintRecorder(log), + child: CustomPaint( + painter: PaintRecorder(log), ), ), ], @@ -172,9 +172,9 @@ void main() { group('Transparency clipping', () { testWidgets('No clip by default', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.transparency, child: const SizedBox(width: 100.0, height: 100.0), @@ -185,9 +185,9 @@ void main() { }); testWidgets('clips to bounding rect by default given Clip.antiAlias', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.transparency, child: const SizedBox(width: 100.0, height: 100.0), @@ -199,9 +199,9 @@ void main() { }); testWidgets('clips to rounded rect when borderRadius provided given Clip.antiAlias', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.transparency, borderRadius: const BorderRadius.all(Radius.circular(10.0)), @@ -219,9 +219,9 @@ void main() { }); testWidgets('clips to shape when provided given Clip.antiAlias', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.transparency, shape: const StadiumBorder(), @@ -241,9 +241,9 @@ void main() { group('PhysicalModels', () { testWidgets('canvas', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.canvas, child: const SizedBox(width: 100.0, height: 100.0) @@ -258,9 +258,9 @@ void main() { }); testWidgets('canvas with borderRadius and elevation', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.canvas, borderRadius: const BorderRadius.all(Radius.circular(5.0)), @@ -277,9 +277,9 @@ void main() { }); testWidgets('canvas with shape and elevation', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.canvas, shape: const StadiumBorder(), @@ -295,9 +295,9 @@ void main() { }); testWidgets('card', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.card, child: const SizedBox(width: 100.0, height: 100.0), @@ -312,9 +312,9 @@ void main() { }); testWidgets('card with borderRadius and elevation', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.card, borderRadius: const BorderRadius.all(Radius.circular(5.0)), @@ -331,9 +331,9 @@ void main() { }); testWidgets('card with shape and elevation', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.card, shape: const StadiumBorder(), @@ -349,9 +349,9 @@ void main() { }); testWidgets('circle', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.circle, child: const SizedBox(width: 100.0, height: 100.0), @@ -366,9 +366,9 @@ void main() { }); testWidgets('button', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.button, child: const SizedBox(width: 100.0, height: 100.0), @@ -384,9 +384,9 @@ void main() { }); testWidgets('button with elevation and borderRadius', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.button, child: const SizedBox(width: 100.0, height: 100.0), @@ -404,9 +404,9 @@ void main() { }); testWidgets('button with elevation and shape', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.button, child: const SizedBox(width: 100.0, height: 100.0), @@ -425,9 +425,9 @@ void main() { group('Border painting', () { testWidgets('border is painted on physical layers', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.button, child: const SizedBox(width: 100.0, height: 100.0), @@ -446,9 +446,9 @@ void main() { }); testWidgets('border is painted for transparent material', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.transparency, child: const SizedBox(width: 100.0, height: 100.0), @@ -466,9 +466,9 @@ void main() { }); testWidgets('border is not painted for when border side is none', (WidgetTester tester) async { - final GlobalKey materialKey = new GlobalKey(); + final GlobalKey materialKey = GlobalKey(); await tester.pumpWidget( - new Material( + Material( key: materialKey, type: MaterialType.transparency, child: const SizedBox(width: 100.0, height: 100.0), diff --git a/packages/flutter/test/material/mergeable_material_test.dart b/packages/flutter/test/material/mergeable_material_test.dart index 05add27a10..f671a5a2d2 100644 --- a/packages/flutter/test/material/mergeable_material_test.dart +++ b/packages/flutter/test/material/mergeable_material_test.dart @@ -67,9 +67,9 @@ BorderRadius getBorderRadius(WidgetTester tester, int index) { void main() { testWidgets('MergeableMaterial empty', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial() ), ), @@ -82,9 +82,9 @@ void main() { testWidgets('MergeableMaterial update slice', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -105,9 +105,9 @@ void main() { expect(box.size.height, equals(100.0)); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -130,9 +130,9 @@ void main() { testWidgets('MergeableMaterial swap slices', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -162,9 +162,9 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -200,9 +200,9 @@ void main() { testWidgets('MergeableMaterial paints shadows', (WidgetTester tester) async { debugDisableShadows = false; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -221,7 +221,7 @@ void main() { final BoxShadow boxShadow = kElevationToShadow[2][0]; final RRect rrect = kMaterialEdges[MaterialType.card].toRRect( - new Rect.fromLTRB(0.0, 0.0, 800.0, 100.0) + Rect.fromLTRB(0.0, 0.0, 800.0, 100.0) ); expect( find.byType(MergeableMaterial), @@ -232,9 +232,9 @@ void main() { testWidgets('MergeableMaterial merge gap', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -268,9 +268,9 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -309,9 +309,9 @@ void main() { testWidgets('MergeableMaterial separate slices', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -341,9 +341,9 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -385,9 +385,9 @@ void main() { testWidgets('MergeableMaterial separate merge separate', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -417,9 +417,9 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -459,9 +459,9 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -498,9 +498,9 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Sharp, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -542,9 +542,9 @@ void main() { testWidgets('MergeableMaterial insert slice', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -574,9 +574,9 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -614,9 +614,9 @@ void main() { testWidgets('MergeableMaterial remove slice', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -653,9 +653,9 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -687,9 +687,9 @@ void main() { testWidgets('MergeableMaterial insert chunk', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -719,9 +719,9 @@ void main() { matches(getBorderRadius(tester, 0), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -775,9 +775,9 @@ void main() { testWidgets('MergeableMaterial remove chunk', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -822,9 +822,9 @@ void main() { matches(getBorderRadius(tester, 2), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -863,9 +863,9 @@ void main() { testWidgets('MergeableMaterial replace gap with chunk', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -899,9 +899,9 @@ void main() { matches(getBorderRadius(tester, 1), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -955,9 +955,9 @@ void main() { testWidgets('MergeableMaterial replace chunk with gap', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -1002,9 +1002,9 @@ void main() { matches(getBorderRadius(tester, 2), RadiusType.Round, RadiusType.Round); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( children: [ MaterialSlice( @@ -1048,8 +1048,8 @@ void main() { final DecoratedBox box = widget; const BorderSide side = BorderSide(color: Color(0x1F000000), width: 0.5); - return box.decoration == new BoxDecoration( - border: new Border( + return box.decoration == BoxDecoration( + border: Border( top: top ? side : BorderSide.none, bottom: bottom ? side : BorderSide.none ) @@ -1058,9 +1058,9 @@ void main() { testWidgets('MergeableMaterial dividers', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( hasDividers: true, children: [ @@ -1108,9 +1108,9 @@ void main() { expect(isDivider(boxes[offset + 3], true, false), isTrue); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( child: const MergeableMaterial( hasDividers: true, children: [ diff --git a/packages/flutter/test/material/modal_bottom_sheet_test.dart b/packages/flutter/test/material/modal_bottom_sheet_test.dart index ca5861b82c..e9594e20bd 100644 --- a/packages/flutter/test/material/modal_bottom_sheet_test.dart +++ b/packages/flutter/test/material/modal_bottom_sheet_test.dart @@ -13,11 +13,11 @@ void main() { testWidgets('Verify that a tap dismisses a modal BottomSheet', (WidgetTester tester) async { BuildContext savedContext; - await tester.pumpWidget(new MaterialApp( - home: new Builder( + await tester.pumpWidget(MaterialApp( + home: Builder( builder: (BuildContext context) { savedContext = context; - return new Container(); + return Container(); } ) )); @@ -70,11 +70,11 @@ void main() { }); testWidgets('Verify that a downwards fling dismisses a persistent BottomSheet', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); bool showBottomSheetThenCalled = false; - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( + await tester.pumpWidget(MaterialApp( + home: Scaffold( key: scaffoldKey, body: const Center(child: Text('body')) ) @@ -84,7 +84,7 @@ void main() { expect(find.text('BottomSheet'), findsNothing); scaffoldKey.currentState.showBottomSheet((BuildContext context) { - return new Container( + return Container( margin: const EdgeInsets.all(40.0), child: const Text('BottomSheet') ); @@ -128,17 +128,17 @@ void main() { testWidgets('Verify that dragging past the bottom dismisses a persistent BottomSheet', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/5528 - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( + await tester.pumpWidget(MaterialApp( + home: Scaffold( key: scaffoldKey, body: const Center(child: Text('body')) ) )); scaffoldKey.currentState.showBottomSheet((BuildContext context) { - return new Container( + return Container( margin: const EdgeInsets.all(40.0), child: const Text('BottomSheet') ); @@ -160,24 +160,24 @@ void main() { BuildContext outerContext; BuildContext innerContext; - await tester.pumpWidget(new Localizations( + await tester.pumpWidget(Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.all(50.0), ), - child: new Navigator( + child: Navigator( onGenerateRoute: (_) { - return new PageRouteBuilder( + return PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { outerContext = context; - return new Container(); + return Container(); }, ); }, @@ -190,7 +190,7 @@ void main() { context: outerContext, builder: (BuildContext context) { innerContext = context; - return new Container(); + return Container(); }, ); await tester.pump(); @@ -207,11 +207,11 @@ void main() { }); testWidgets('modal BottomSheet has semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final GlobalKey scaffoldKey = new GlobalKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final GlobalKey scaffoldKey = GlobalKey(); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( + await tester.pumpWidget(MaterialApp( + home: Scaffold( key: scaffoldKey, body: const Center(child: Text('body')) ) @@ -219,7 +219,7 @@ void main() { showModalBottomSheet(context: scaffoldKey.currentContext, builder: (BuildContext context) { - return new Container( + return Container( child: const Text('BottomSheet') ); }); @@ -227,11 +227,11 @@ void main() { await tester.pump(); // bottom sheet show animation starts await tester.pump(const Duration(seconds: 1)); // animation done - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( label: 'Dialog', textDirection: TextDirection.ltr, flags: [ @@ -239,7 +239,7 @@ void main() { SemanticsFlag.namesRoute, ], children: [ - new TestSemantics( + TestSemantics( label: 'BottomSheet', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/material/outline_button_test.dart b/packages/flutter/test/material/outline_button_test.dart index ee9e3bdd4b..b3685a15c6 100644 --- a/packages/flutter/test/material/outline_button_test.dart +++ b/packages/flutter/test/material/outline_button_test.dart @@ -14,12 +14,12 @@ void main() { int pressedCount = 0; Widget buildFrame(VoidCallback onPressed) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData(), - child: new Center( - child: new OutlineButton(onPressed: onPressed), + child: Theme( + data: ThemeData(), + child: Center( + child: OutlineButton(onPressed: onPressed), ), ), ); @@ -54,9 +54,9 @@ void main() { Widget buildFrame({VoidCallback onPressed}) { return Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Container( + child: Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Container( alignment: Alignment.topLeft, child: OutlineButton( shape: const RoundedRectangleBorder(), // default border radius is 0 @@ -76,8 +76,8 @@ void main() { ); } - final Rect clipRect = new Rect.fromLTRB(0.0, 0.0, 116.0, 36.0); - final Path clipPath = new Path()..addRect(clipRect); + final Rect clipRect = Rect.fromLTRB(0.0, 0.0, 116.0, 36.0); + final Path clipPath = Path()..addRect(clipRect); final Finder outlineButton = find.byType(OutlineButton); @@ -137,13 +137,13 @@ void main() { }); testWidgets('OutlineButton has no clip by default', (WidgetTester tester) async { - final GlobalKey buttonKey = new GlobalKey(); + final GlobalKey buttonKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new OutlineButton( + child: Material( + child: Center( + child: OutlineButton( key: buttonKey, onPressed: () { }, child: const Text('ABC'), @@ -160,13 +160,13 @@ void main() { }); testWidgets('OutlineButton contributes semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new OutlineButton( + child: Material( + child: Center( + child: OutlineButton( onPressed: () { }, child: const Text('ABC'), ), @@ -176,15 +176,15 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( actions: [ SemanticsAction.tap, ], label: 'ABC', - rect: new Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), - transform: new Matrix4.translationValues(356.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 88.0, 48.0), + transform: Matrix4.translationValues(356.0, 276.0, 0.0), flags: [ SemanticsFlag.isButton, SemanticsFlag.hasEnabledState, @@ -202,13 +202,13 @@ void main() { testWidgets('OutlineButton scales textScaleFactor', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new MediaQuery( + child: Material( + child: MediaQuery( data: const MediaQueryData(textScaleFactor: 1.0), - child: new Center( - child: new OutlineButton( + child: Center( + child: OutlineButton( onPressed: () { }, child: const Text('ABC'), ), @@ -223,13 +223,13 @@ void main() { // textScaleFactor expands text, but not button. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new MediaQuery( + child: Material( + child: MediaQuery( data: const MediaQueryData(textScaleFactor: 1.3), - child: new Center( - child: new FlatButton( + child: Center( + child: FlatButton( onPressed: () { }, child: const Text('ABC'), ), @@ -247,13 +247,13 @@ void main() { // Set text scale large enough to expand text and button. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new MediaQuery( + child: Material( + child: MediaQuery( data: const MediaQueryData(textScaleFactor: 3.0), - child: new Center( - child: new FlatButton( + child: Center( + child: FlatButton( onPressed: () { }, child: const Text('ABC'), ), @@ -272,8 +272,8 @@ void main() { }); testWidgets('OutlineButton implements debugFillDescription', (WidgetTester tester) async { - final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); - new OutlineButton( + final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); + OutlineButton( onPressed: () {}, textColor: const Color(0xFF00FF00), disabledTextColor: const Color(0xFFFF0000), diff --git a/packages/flutter/test/material/page_selector_test.dart b/packages/flutter/test/material/page_selector_test.dart index 1902d492b5..42a1ae06c4 100644 --- a/packages/flutter/test/material/page_selector_test.dart +++ b/packages/flutter/test/material/page_selector_test.dart @@ -9,25 +9,25 @@ const Color kSelectedColor = Color(0xFF00FF00); const Color kUnselectedColor = Colors.transparent; Widget buildFrame(TabController tabController, { Color color, Color selectedColor, double indicatorSize = 12.0 }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData(accentColor: kSelectedColor), - child: new SizedBox.expand( - child: new Center( - child: new SizedBox( + child: Theme( + data: ThemeData(accentColor: kSelectedColor), + child: SizedBox.expand( + child: Center( + child: SizedBox( width: 400.0, height: 400.0, - child: new Column( + child: Column( children: [ - new TabPageSelector( + TabPageSelector( controller: tabController, color: color, selectedColor: selectedColor, indicatorSize: indicatorSize, ), - new Flexible( - child: new TabBarView( + Flexible( + child: TabBarView( controller: tabController, children: const [ Center(child: Text('0')), @@ -57,7 +57,7 @@ List indicatorColors(WidgetTester tester) { void main() { testWidgets('PageSelector responds correctly to setting the TabController index', (WidgetTester tester) async { - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), length: 3, ); @@ -78,7 +78,7 @@ void main() { }); testWidgets('PageSelector responds correctly to TabController.animateTo()', (WidgetTester tester) async { - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), length: 3, ); @@ -121,7 +121,7 @@ void main() { }); testWidgets('PageSelector responds correctly to TabBarView drags', (WidgetTester tester) async { - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), initialIndex: 1, length: 3, @@ -183,7 +183,7 @@ void main() { const Color kRed = Color(0xFFFF0000); const Color kBlue = Color(0xFF0000FF); - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), initialIndex: 1, length: 3, @@ -199,7 +199,7 @@ void main() { }); testWidgets('PageSelector indicatorSize', (WidgetTester tester) async { - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), initialIndex: 1, length: 3, diff --git a/packages/flutter/test/material/page_test.dart b/packages/flutter/test/material/page_test.dart index 4dfcd0c160..9540ad0cbd 100644 --- a/packages/flutter/test/material/page_test.dart +++ b/packages/flutter/test/material/page_test.dart @@ -11,8 +11,8 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('test Android page transition', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -68,14 +68,14 @@ void main() { }); testWidgets('test iOS page transition', (WidgetTester tester) async { - final Key page2Key = new UniqueKey(); + final Key page2Key = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { - return new Material( + return Material( key: page2Key, child: const Text('Page 2'), ); @@ -110,7 +110,7 @@ void main() { // width to the left of 0 offset box rect and nothing is drawn inside the // box's rect. expect(box, paints..rect( - rect: new Rect.fromLTWH(-800.0, 0.0, 800.0, 600.0) + rect: Rect.fromLTWH(-800.0, 0.0, 800.0, 600.0) )); await tester.pumpAndSettle(); @@ -148,15 +148,15 @@ void main() { testWidgets('test iOS fullscreen dialog transition', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Material(child: Text('Page 1')), ) ); final Offset widget1InitialTopLeft = tester.getTopLeft(find.text('Page 1')); - tester.state(find.byType(Navigator)).push(new MaterialPageRoute( + tester.state(find.byType(Navigator)).push(MaterialPageRoute( builder: (BuildContext context) { return const Material(child: Text('Page 2')); }, @@ -209,8 +209,8 @@ void main() { testWidgets('test no back gesture on Android', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: const Scaffold(body: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -240,8 +240,8 @@ void main() { testWidgets('test back gesture on iOS', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Scaffold(body: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -282,17 +282,17 @@ void main() { testWidgets('back gesture while OS changes', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new Material( - child: new FlatButton( + '/': (BuildContext context) => Material( + child: FlatButton( child: const Text('PUSH'), onPressed: () { Navigator.of(context).pushNamed('/b'); }, ), ), - '/b': (BuildContext context) => new Container(child: const Text('HELLO')), + '/b': (BuildContext context) => Container(child: const Text('HELLO')), }; await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), routes: routes, ), ); @@ -314,8 +314,8 @@ void main() { expect(helloPosition1.dy, helloPosition2.dy); expect(Theme.of(tester.element(find.text('HELLO'))).platform, TargetPlatform.iOS); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), routes: routes, ), ); @@ -349,13 +349,13 @@ void main() { testWidgets('test no back gesture on iOS fullscreen dialogs', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Scaffold(body: Text('Page 1')), ) ); - tester.state(find.byType(Navigator)).push(new MaterialPageRoute( + tester.state(find.byType(Navigator)).push(MaterialPageRoute( builder: (BuildContext context) { return const Scaffold(body: Text('Page 2')); }, @@ -380,8 +380,8 @@ void main() { testWidgets('test adaptable transitions switch during execution', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { @@ -415,8 +415,8 @@ void main() { // Re-pump the same app but with iOS instead of Android. await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), + MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), home: const Material(child: Text('Page 1')), routes: { '/next': (BuildContext context) { diff --git a/packages/flutter/test/material/paginated_data_table_test.dart b/packages/flutter/test/material/paginated_data_table_test.dart index e26b16b071..9221a6be44 100644 --- a/packages/flutter/test/material/paginated_data_table_test.dart +++ b/packages/flutter/test/material/paginated_data_table_test.dart @@ -21,12 +21,12 @@ class TestDataSource extends DataTableSource { DataRow getRow(int index) { final Dessert dessert = kDesserts[index % kDesserts.length]; final int page = index ~/ kDesserts.length; - return new DataRow.byIndex( + return DataRow.byIndex( index: index, cells: [ - new DataCell(new Text('${dessert.name} ($page)')), - new DataCell(new Text('${dessert.calories}')), - new DataCell(new Text('$generation')), + DataCell(Text('${dessert.name} ($page)')), + DataCell(Text('${dessert.calories}')), + DataCell(Text('$generation')), ], ); } @@ -43,12 +43,12 @@ class TestDataSource extends DataTableSource { void main() { testWidgets('PaginatedDataTable paging', (WidgetTester tester) async { - final TestDataSource source = new TestDataSource(); + final TestDataSource source = TestDataSource(); final List log = []; - await tester.pumpWidget(new MaterialApp( - home: new PaginatedDataTable( + await tester.pumpWidget(MaterialApp( + home: PaginatedDataTable( header: const Text('Test table'), source: source, rowsPerPage: 2, @@ -106,13 +106,13 @@ void main() { }); testWidgets('PaginatedDataTable control test', (WidgetTester tester) async { - TestDataSource source = new TestDataSource() + TestDataSource source = TestDataSource() ..generation = 42; final List log = []; Widget buildTable(TestDataSource source) { - return new PaginatedDataTable( + return PaginatedDataTable( header: const Text('Test table'), source: source, onPageChanged: (int rowIndex) { @@ -123,7 +123,7 @@ void main() { label: Text('Name'), tooltip: 'Name', ), - new DataColumn( + DataColumn( label: const Text('Calories'), tooltip: 'Calories', numeric: true, @@ -137,7 +137,7 @@ void main() { ), ], actions: [ - new IconButton( + IconButton( icon: const Icon(Icons.adjust), onPressed: () { log.add('action: adjust'); @@ -147,7 +147,7 @@ void main() { ); } - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: buildTable(source), )); @@ -164,10 +164,10 @@ void main() { expect(find.text('42'), findsNothing); expect(find.text('43'), findsNWidgets(10)); - source = new TestDataSource() + source = TestDataSource() ..generation = 15; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: buildTable(source), )); @@ -194,10 +194,10 @@ void main() { }); testWidgets('PaginatedDataTable text alignment', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new PaginatedDataTable( + await tester.pumpWidget(MaterialApp( + home: PaginatedDataTable( header: const Text('HEADER'), - source: new TestDataSource(), + source: TestDataSource(), rowsPerPage: 8, availableRowsPerPage: const [ 8, 9, @@ -216,13 +216,13 @@ void main() { }); testWidgets('PaginatedDataTable with large text', (WidgetTester tester) async { - final TestDataSource source = new TestDataSource(); - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + final TestDataSource source = TestDataSource(); + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData( textScaleFactor: 20.0, ), - child: new PaginatedDataTable( + child: PaginatedDataTable( header: const Text('HEADER'), source: source, rowsPerPage: 501, @@ -247,13 +247,13 @@ void main() { }); testWidgets('PaginatedDataTable footer scrolls', (WidgetTester tester) async { - final TestDataSource source = new TestDataSource(); - await tester.pumpWidget(new MaterialApp( - home: new Align( + final TestDataSource source = TestDataSource(); + await tester.pumpWidget(MaterialApp( + home: Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 100.0, - child: new PaginatedDataTable( + child: PaginatedDataTable( header: const Text('HEADER'), source: source, rowsPerPage: 5, @@ -271,7 +271,7 @@ void main() { expect(find.text('Rows per page:'), findsOneWidget); expect(tester.getTopLeft(find.text('Rows per page:')).dx, lessThan(0.0)); // off screen await tester.dragFrom( - new Offset(50.0, tester.getTopLeft(find.text('Rows per page:')).dy), + Offset(50.0, tester.getTopLeft(find.text('Rows per page:')).dy), const Offset(1000.0, 0.0), ); await tester.pump(); diff --git a/packages/flutter/test/material/persistent_bottom_sheet_test.dart b/packages/flutter/test/material/persistent_bottom_sheet_test.dart index 0a6bcc01cc..9b752168c3 100644 --- a/packages/flutter/test/material/persistent_bottom_sheet_test.dart +++ b/packages/flutter/test/material/persistent_bottom_sheet_test.dart @@ -7,22 +7,22 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Verify that a BottomSheet can be rebuilt with ScaffoldFeatureController.setState()', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); PersistentBottomSheetController bottomSheet; int buildCount = 0; - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( + await tester.pumpWidget(MaterialApp( + home: Scaffold( key: scaffoldKey, body: const Center(child: Text('body')) ) )); bottomSheet = scaffoldKey.currentState.showBottomSheet((_) { - return new Builder( + return Builder( builder: (BuildContext context) { buildCount += 1; - return new Container(height: 200.0); + return Container(height: 200.0); } ); }); @@ -36,23 +36,23 @@ void main() { }); testWidgets('Verify that a scrollable BottomSheet can be dismissed', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( + await tester.pumpWidget(MaterialApp( + home: Scaffold( key: scaffoldKey, body: const Center(child: Text('body')) ) )); scaffoldKey.currentState.showBottomSheet((BuildContext context) { - return new ListView( + return ListView( shrinkWrap: true, primary: false, children: [ - new Container(height: 100.0, child: const Text('One')), - new Container(height: 100.0, child: const Text('Two')), - new Container(height: 100.0, child: const Text('Three')), + Container(height: 100.0, child: const Text('One')), + Container(height: 100.0, child: const Text('Two')), + Container(height: 100.0, child: const Text('Three')), ], ); }); @@ -68,10 +68,10 @@ void main() { }); testWidgets('showBottomSheet()', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Placeholder(key: key), + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Placeholder(key: key), ) )); @@ -79,10 +79,10 @@ void main() { showBottomSheet( context: key.currentContext, builder: (BuildContext context) { - return new Builder( + return Builder( builder: (BuildContext context) { buildCount += 1; - return new Container(height: 200.0); + return Container(height: 200.0); } ); }, @@ -95,17 +95,17 @@ void main() { BuildContext scaffoldContext; BuildContext bottomSheetContext; - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.all(50.0), ), - child: new Scaffold( + child: Scaffold( resizeToAvoidBottomPadding: false, - body: new Builder( + body: Builder( builder: (BuildContext context) { scaffoldContext = context; - return new Container(); + return Container(); } ), ), @@ -118,7 +118,7 @@ void main() { context: scaffoldContext, builder: (BuildContext context) { bottomSheetContext = context; - return new Container(); + return Container(); }, ); @@ -135,19 +135,19 @@ void main() { }); testWidgets('Scaffold.bottomSheet', (WidgetTester tester) async { - final Key bottomSheetKey = new UniqueKey(); + final Key bottomSheetKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( + MaterialApp( + home: Scaffold( body: const Placeholder(), - bottomSheet: new Container( + bottomSheet: Container( key: bottomSheetKey, alignment: Alignment.center, height: 200.0, - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( child: const Text('showModalBottomSheet'), onPressed: () { showModalBottomSheet( @@ -180,7 +180,7 @@ void main() { // Remove the persistent bottomSheet await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( bottomSheet: null, body: Placeholder(), diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 40bf49b287..f6d6d2aa88 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -11,20 +11,20 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Navigator.push works within a PopupMenuButton', (WidgetTester tester) async { - final Key targetKey = new UniqueKey(); + final Key targetKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( + MaterialApp( routes: { '/next': (BuildContext context) { return const Text('Next'); }, }, - home: new Material( - child: new Center( - child: new Builder( + home: Material( + child: Center( + child: Builder( key: targetKey, builder: (BuildContext context) { - return new PopupMenuButton( + return PopupMenuButton( onSelected: (int value) { Navigator.pushNamed(context, '/next'); }, @@ -63,15 +63,15 @@ void main() { testWidgets('PopupMenuButton calls onCanceled callback when an item is not selected', (WidgetTester tester) async { int cancels = 0; BuildContext popupContext; - final Key noCallbackKey = new UniqueKey(); - final Key withCallbackKey = new UniqueKey(); + final Key noCallbackKey = UniqueKey(); + final Key withCallbackKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Column( + MaterialApp( + home: Material( + child: Column( children: [ - new PopupMenuButton( + PopupMenuButton( key: noCallbackKey, itemBuilder: (BuildContext context) { return >[ @@ -82,7 +82,7 @@ void main() { ]; }, ), - new PopupMenuButton( + PopupMenuButton( key: withCallbackKey, onCanceled: () => cancels++, itemBuilder: (BuildContext context) { @@ -128,12 +128,12 @@ void main() { testWidgets('PopupMenuButton is horizontal on iOS', (WidgetTester tester) async { Widget build(TargetPlatform platform) { - return new MaterialApp( - theme: new ThemeData(platform: platform), - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + theme: ThemeData(platform: platform), + home: Scaffold( + appBar: AppBar( actions: [ - new PopupMenuButton( + PopupMenuButton( itemBuilder: (BuildContext context) { return >[ const PopupMenuItem( @@ -174,7 +174,7 @@ void main() { testWidgets('PopupMenuButton fails when given both child and icon', (WidgetTester tester) async { expect(() { - new PopupMenuButton( + PopupMenuButton( child: const Text('heyo'), icon: const Icon(Icons.view_carousel), itemBuilder: simplePopupMenuItemBuilder, @@ -183,14 +183,14 @@ void main() { }); testWidgets('PopupMenuButton creates IconButton when given an icon', (WidgetTester tester) async { - final PopupMenuButton button = new PopupMenuButton( + final PopupMenuButton button = PopupMenuButton( icon: const Icon(Icons.view_carousel), itemBuilder: simplePopupMenuItemBuilder, ); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - appBar: new AppBar( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + appBar: AppBar( actions: [button], ), ), @@ -203,7 +203,7 @@ void main() { }); testWidgets('PopupMenu positioning', (WidgetTester tester) async { - final Widget testButton = new PopupMenuButton( + final Widget testButton = PopupMenuButton( itemBuilder: (BuildContext context) { return >[ const PopupMenuItem(value: 1, child: Text('AAA')), @@ -226,10 +226,10 @@ void main() { Future openMenu(TextDirection textDirection, Alignment alignment) async { return TestAsyncUtils.guard(() async { - await tester.pumpWidget(new Container()); // reset in case we had a menu up already - await tester.pumpWidget(new TestApp( + await tester.pumpWidget(Container()); // reset in case we had a menu up already + await tester.pumpWidget(TestApp( textDirection: textDirection, - child: new Align( + child: Align( alignment: alignment, child: testButton, ), @@ -369,42 +369,42 @@ void main() { }); } - await testPositioningDown(tester, TextDirection.ltr, Alignment.topRight, TextDirection.rtl, new Rect.fromLTWH(792.0, 8.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.rtl, Alignment.topRight, TextDirection.rtl, new Rect.fromLTWH(792.0, 8.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.ltr, Alignment.topLeft, TextDirection.ltr, new Rect.fromLTWH(8.0, 8.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.rtl, Alignment.topLeft, TextDirection.ltr, new Rect.fromLTWH(8.0, 8.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.ltr, Alignment.topCenter, TextDirection.ltr, new Rect.fromLTWH(350.0, 8.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.rtl, Alignment.topCenter, TextDirection.rtl, new Rect.fromLTWH(450.0, 8.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.ltr, Alignment.centerRight, TextDirection.rtl, new Rect.fromLTWH(792.0, 250.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.rtl, Alignment.centerRight, TextDirection.rtl, new Rect.fromLTWH(792.0, 250.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.ltr, Alignment.centerLeft, TextDirection.ltr, new Rect.fromLTWH(8.0, 250.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.rtl, Alignment.centerLeft, TextDirection.ltr, new Rect.fromLTWH(8.0, 250.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.ltr, Alignment.center, TextDirection.ltr, new Rect.fromLTWH(350.0, 250.0, 0.0, 0.0)); - await testPositioningDown(tester, TextDirection.rtl, Alignment.center, TextDirection.rtl, new Rect.fromLTWH(450.0, 250.0, 0.0, 0.0)); - await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomRight, TextDirection.rtl, new Rect.fromLTWH(792.0, 500.0, 0.0, 0.0)); - await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomRight, TextDirection.rtl, new Rect.fromLTWH(792.0, 500.0, 0.0, 0.0)); - await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomLeft, TextDirection.ltr, new Rect.fromLTWH(8.0, 500.0, 0.0, 0.0)); - await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomLeft, TextDirection.ltr, new Rect.fromLTWH(8.0, 500.0, 0.0, 0.0)); - await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomCenter, TextDirection.ltr, new Rect.fromLTWH(350.0, 500.0, 0.0, 0.0)); - await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomCenter, TextDirection.rtl, new Rect.fromLTWH(450.0, 500.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.ltr, Alignment.topRight, TextDirection.rtl, Rect.fromLTWH(792.0, 8.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.rtl, Alignment.topRight, TextDirection.rtl, Rect.fromLTWH(792.0, 8.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.ltr, Alignment.topLeft, TextDirection.ltr, Rect.fromLTWH(8.0, 8.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.rtl, Alignment.topLeft, TextDirection.ltr, Rect.fromLTWH(8.0, 8.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.ltr, Alignment.topCenter, TextDirection.ltr, Rect.fromLTWH(350.0, 8.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.rtl, Alignment.topCenter, TextDirection.rtl, Rect.fromLTWH(450.0, 8.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.ltr, Alignment.centerRight, TextDirection.rtl, Rect.fromLTWH(792.0, 250.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.rtl, Alignment.centerRight, TextDirection.rtl, Rect.fromLTWH(792.0, 250.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.ltr, Alignment.centerLeft, TextDirection.ltr, Rect.fromLTWH(8.0, 250.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.rtl, Alignment.centerLeft, TextDirection.ltr, Rect.fromLTWH(8.0, 250.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.ltr, Alignment.center, TextDirection.ltr, Rect.fromLTWH(350.0, 250.0, 0.0, 0.0)); + await testPositioningDown(tester, TextDirection.rtl, Alignment.center, TextDirection.rtl, Rect.fromLTWH(450.0, 250.0, 0.0, 0.0)); + await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomRight, TextDirection.rtl, Rect.fromLTWH(792.0, 500.0, 0.0, 0.0)); + await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomRight, TextDirection.rtl, Rect.fromLTWH(792.0, 500.0, 0.0, 0.0)); + await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomLeft, TextDirection.ltr, Rect.fromLTWH(8.0, 500.0, 0.0, 0.0)); + await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomLeft, TextDirection.ltr, Rect.fromLTWH(8.0, 500.0, 0.0, 0.0)); + await testPositioningDownThenUp(tester, TextDirection.ltr, Alignment.bottomCenter, TextDirection.ltr, Rect.fromLTWH(350.0, 500.0, 0.0, 0.0)); + await testPositioningDownThenUp(tester, TextDirection.rtl, Alignment.bottomCenter, TextDirection.rtl, Rect.fromLTWH(450.0, 500.0, 0.0, 0.0)); }); testWidgets('PopupMenu removes MediaQuery padding', (WidgetTester tester) async { BuildContext popupContext; - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.all(50.0), ), - child: new Material( - child: new PopupMenuButton( + child: Material( + child: PopupMenuButton( itemBuilder: (BuildContext context) { popupContext = context; return >[ - new PopupMenuItem( + PopupMenuItem( value: 1, - child: new Builder( + child: Builder( builder: (BuildContext context) { popupContext = context; return const Text('AAA'); @@ -431,10 +431,10 @@ void main() { }); testWidgets('open PopupMenu has correct semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new PopupMenuButton( + final SemanticsTester semantics = SemanticsTester(tester); + await tester.pumpWidget(MaterialApp( + home: Material( + child: PopupMenuButton( itemBuilder: (BuildContext context) { return >[ const PopupMenuItem(value: 1, child: Text('1')), @@ -456,12 +456,12 @@ void main() { await tester.pumpAndSettle(); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.scopesRoute, SemanticsFlag.namesRoute, @@ -469,29 +469,29 @@ void main() { label: 'Popup menu', textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( actions: [SemanticsAction.tap], label: '5', textDirection: TextDirection.ltr, @@ -516,28 +516,28 @@ class TestApp extends StatefulWidget { final TextDirection textDirection; final Widget child; @override - _TestAppState createState() => new _TestAppState(); + _TestAppState createState() => _TestAppState(); } class _TestAppState extends State { @override Widget build(BuildContext context) { - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultWidgetsLocalizations.delegate, DefaultMaterialLocalizations.delegate, ], - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Directionality( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Directionality( textDirection: widget.textDirection, - child: new Navigator( + child: Navigator( onGenerateRoute: (RouteSettings settings) { assert(settings.name == '/'); - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, - builder: (BuildContext context) => new Material( + builder: (BuildContext context) => Material( child: widget.child, ), ); diff --git a/packages/flutter/test/material/progress_indicator_test.dart b/packages/flutter/test/material/progress_indicator_test.dart index 81aa0d78f7..8b2424fe78 100644 --- a/packages/flutter/test/material/progress_indicator_test.dart +++ b/packages/flutter/test/material/progress_indicator_test.dart @@ -57,8 +57,8 @@ void main() { expect( find.byType(LinearProgressIndicator), paints - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 50.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 50.0, 6.0)) ); expect(tester.binding.transientCallbackCount, 0); @@ -80,8 +80,8 @@ void main() { expect( find.byType(LinearProgressIndicator), paints - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) - ..rect(rect: new Rect.fromLTRB(150.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(150.0, 0.0, 200.0, 6.0)) ); expect(tester.binding.transientCallbackCount, 0); @@ -107,8 +107,8 @@ void main() { expect( find.byType(LinearProgressIndicator), paints - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, animationValue * 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, animationValue * 200.0, 6.0)) ); expect(tester.binding.transientCallbackCount, 1); @@ -134,8 +134,8 @@ void main() { expect( find.byType(LinearProgressIndicator), paints - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) - ..rect(rect: new Rect.fromLTRB(200.0 - animationValue * 200.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(200.0 - animationValue * 200.0, 0.0, 200.0, 6.0)) ); expect(tester.binding.transientCallbackCount, 1); @@ -161,8 +161,8 @@ void main() { expect( find.byType(LinearProgressIndicator), paints - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 50.0, 6.0), color: Colors.white) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 200.0, 6.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 50.0, 6.0), color: Colors.white) ); }); @@ -183,14 +183,14 @@ void main() { }); testWidgets('LinearProgressIndicator causes a repaint when it changes', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: const [LinearProgressIndicator(value: 0.0)]), + child: ListView(children: const [LinearProgressIndicator(value: 0.0)]), )); final List layers1 = tester.layers; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: const [LinearProgressIndicator(value: 0.5)])), + child: ListView(children: const [LinearProgressIndicator(value: 0.5)])), ); final List layers2 = tester.layers; expect(layers1, isNot(equals(layers2))); diff --git a/packages/flutter/test/material/radio_test.dart b/packages/flutter/test/material/radio_test.dart index 81619fec7b..f0eee99ef5 100644 --- a/packages/flutter/test/material/radio_test.dart +++ b/packages/flutter/test/material/radio_test.dart @@ -13,12 +13,12 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Radio control test', (WidgetTester tester) async { - final Key key = new UniqueKey(); + final Key key = UniqueKey(); final List log = []; - await tester.pumpWidget(new Material( - child: new Center( - child: new Radio( + await tester.pumpWidget(Material( + child: Center( + child: Radio( key: key, value: 1, groupValue: 2, @@ -32,9 +32,9 @@ void main() { expect(log, equals([1])); log.clear(); - await tester.pumpWidget(new Material( - child: new Center( - child: new Radio( + await tester.pumpWidget(Material( + child: Center( + child: Radio( key: key, value: 1, groupValue: 1, @@ -48,9 +48,9 @@ void main() { expect(log, isEmpty); - await tester.pumpWidget(new Material( - child: new Center( - child: new Radio( + await tester.pumpWidget(Material( + child: Center( + child: Radio( key: key, value: 1, groupValue: 2, @@ -65,15 +65,15 @@ void main() { }); testWidgets('Radio size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); + final Key key1 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Radio( + child: Material( + child: Center( + child: Radio( key: key1, groupValue: true, value: true, @@ -87,15 +87,15 @@ void main() { expect(tester.getSize(find.byKey(key1)), const Size(48.0, 48.0)); - final Key key2 = new UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Radio( + child: Material( + child: Center( + child: Radio( key: key2, groupValue: true, value: true, @@ -112,19 +112,19 @@ void main() { testWidgets('Radio semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Material( - child: new Radio( + await tester.pumpWidget(Material( + child: Radio( value: 1, groupValue: 2, onChanged: (int i) { }, ), )); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: [ SemanticsFlag.isInMutuallyExclusiveGroup, @@ -139,17 +139,17 @@ void main() { ], ), ignoreRect: true, ignoreTransform: true)); - await tester.pumpWidget(new Material( - child: new Radio( + await tester.pumpWidget(Material( + child: Radio( value: 2, groupValue: 2, onChanged: (int i) { }, ), )); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: [ SemanticsFlag.isInMutuallyExclusiveGroup, @@ -173,9 +173,9 @@ void main() { ), )); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: [ SemanticsFlag.isInMutuallyExclusiveGroup, @@ -194,9 +194,9 @@ void main() { ), )); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: [ SemanticsFlag.isInMutuallyExclusiveGroup, @@ -212,16 +212,16 @@ void main() { }); testWidgets('has semantic events', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final Key key = new UniqueKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final Key key = UniqueKey(); dynamic semanticEvent; int radioValue = 2; SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { semanticEvent = message; }); - await tester.pumpWidget(new Material( - child: new Radio( + await tester.pumpWidget(Material( + child: Radio( key: key, value: 1, groupValue: radioValue, diff --git a/packages/flutter/test/material/raw_material_button_test.dart b/packages/flutter/test/material/raw_material_button_test.dart index 0d4a22f607..a38705f740 100644 --- a/packages/flutter/test/material/raw_material_button_test.dart +++ b/packages/flutter/test/material/raw_material_button_test.dart @@ -10,13 +10,13 @@ void main() { int pressed = 0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new RawMaterialButton( + child: RawMaterialButton( onPressed: () { pressed++; }, - constraints: new BoxConstraints.tight(const Size(10.0, 10.0)), + constraints: BoxConstraints.tight(const Size(10.0, 10.0)), materialTapTargetSize: MaterialTapTargetSize.padded, child: const Text('+'), ), @@ -29,14 +29,14 @@ void main() { }); testWidgets('materialTapTargetSize.padded expands semantics area', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new RawMaterialButton( + child: Center( + child: RawMaterialButton( onPressed: () {}, - constraints: new BoxConstraints.tight(const Size(10.0, 10.0)), + constraints: BoxConstraints.tight(const Size(10.0, 10.0)), materialTapTargetSize: MaterialTapTargetSize.padded, child: const Text('+'), ), @@ -45,9 +45,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, flags: [ SemanticsFlag.isButton, @@ -74,10 +74,10 @@ void main() { const Color fillColor = Color(0xFFEF5350); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new RawMaterialButton( + child: Center( + child: RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.padded, onPressed: () {}, fillColor: fillColor, @@ -106,10 +106,10 @@ void main() { const Color fillColor = Color(0xFFEF5350); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new RawMaterialButton( + child: Center( + child: RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.padded, onPressed: () {}, fillColor: fillColor, @@ -133,17 +133,17 @@ void main() { testWidgets('off-center child is hit testable', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Column( + MaterialApp( + home: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - new RawMaterialButton( + RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.padded, onPressed: () {}, - child: new Container( + child: Container( width: 400.0, height: 400.0, - child: new Column( + child: Column( mainAxisAlignment: MainAxisAlignment.end, children: const [ SizedBox( @@ -164,17 +164,17 @@ void main() { testWidgets('smaller child is hit testable', (WidgetTester tester) async { const Key key = Key('test'); await tester.pumpWidget( - new MaterialApp( - home: new Column( + MaterialApp( + home: Column( children: [ - new RawMaterialButton( + RawMaterialButton( materialTapTargetSize: MaterialTapTargetSize.padded, onPressed: () {}, - child: new SizedBox( + child: SizedBox( key: key, width: 8.0, height: 8.0, - child: new Container( + child: Container( color: const Color(0xFFAABBCC), ), ), @@ -188,11 +188,11 @@ void main() { testWidgets('RawMaterialButton can be expanded by parent constraints', (WidgetTester tester) async { const Key key = Key('test'); await tester.pumpWidget( - new MaterialApp( - home: new Column( + MaterialApp( + home: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new RawMaterialButton( + RawMaterialButton( key: key, onPressed: () {}, child: const SizedBox(), diff --git a/packages/flutter/test/material/refresh_indicator_test.dart b/packages/flutter/test/material/refresh_indicator_test.dart index 002c800133..ea49f94430 100644 --- a/packages/flutter/test/material/refresh_indicator_test.dart +++ b/packages/flutter/test/material/refresh_indicator_test.dart @@ -12,27 +12,27 @@ bool refreshCalled = false; Future refresh() { refreshCalled = true; - return new Future.value(); + return Future.value(); } Future holdRefresh() { refreshCalled = true; - return new Completer().future; + return Completer().future; } void main() { testWidgets('RefreshIndicator', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: ['A', 'B', 'C', 'D', 'E', 'F'].map((String item) { - return new SizedBox( + return SizedBox( height: 200.0, - child: new Text(item), + child: Text(item), ); }).toList(), ), @@ -51,20 +51,20 @@ void main() { testWidgets('Refresh Indicator - nested', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( notificationPredicate: (ScrollNotification notification) => notification.depth == 1, onRefresh: refresh, - child: new SingleChildScrollView( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: new Container( + child: Container( width: 600.0, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: ['A', 'B', 'C', 'D', 'E', 'F'].map((String item) { - return new SizedBox( + return SizedBox( height: 200.0, - child: new Text(item), + child: Text(item), ); }).toList(), ), @@ -93,10 +93,10 @@ void main() { testWidgets('RefreshIndicator - bottom', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( reverse: true, physics: const AlwaysScrollableScrollPhysics(), children: const [ @@ -121,10 +121,10 @@ void main() { testWidgets('RefreshIndicator - top - position', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: holdRefresh, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: const [ SizedBox( @@ -147,10 +147,10 @@ void main() { testWidgets('RefreshIndicator - bottom - position', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: holdRefresh, - child: new ListView( + child: ListView( reverse: true, physics: const AlwaysScrollableScrollPhysics(), children: const [ @@ -174,10 +174,10 @@ void main() { testWidgets('RefreshIndicator - no movement', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: const [ SizedBox( @@ -202,10 +202,10 @@ void main() { testWidgets('RefreshIndicator - not enough', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: const [ SizedBox( @@ -229,10 +229,10 @@ void main() { testWidgets('RefreshIndicator - show - slow', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: holdRefresh, // this one never returns - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: const [ SizedBox( @@ -272,10 +272,10 @@ void main() { testWidgets('RefreshIndicator - show - fast', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: const [ SizedBox( @@ -316,10 +316,10 @@ void main() { testWidgets('RefreshIndicator - show - fast - twice', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: const [ SizedBox( @@ -354,18 +354,18 @@ void main() { testWidgets('RefreshIndicator - onRefresh asserts', (WidgetTester tester) async { refreshCalled = false; await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: () { refreshCalled = true; return null; // Missing a returned Future value here, should cause framework to throw. }, - child: new ListView( + child: ListView( physics: const AlwaysScrollableScrollPhysics(), children: ['A', 'B', 'C', 'D', 'E', 'F'].map((String item) { - return new SizedBox( + return SizedBox( height: 200.0, - child: new Text(item), + child: Text(item), ); }).toList(), ), @@ -384,19 +384,19 @@ void main() { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; refreshCalled = false; double lastScrollOffset; - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new MaterialApp( - home: new RefreshIndicator( + MaterialApp( + home: RefreshIndicator( onRefresh: refresh, - child: new ListView( + child: ListView( controller: controller, physics: const AlwaysScrollableScrollPhysics(), children: ['A', 'B', 'C', 'D', 'E', 'F'].map((String item) { - return new SizedBox( + return SizedBox( height: 200.0, - child: new Text(item), + child: Text(item), ); }).toList(), ), diff --git a/packages/flutter/test/material/reorderable_list_test.dart b/packages/flutter/test/material/reorderable_list_test.dart index df38b3b4da..354277d6e8 100644 --- a/packages/flutter/test/material/reorderable_list_test.dart +++ b/packages/flutter/test/material/reorderable_list_test.dart @@ -22,22 +22,22 @@ void main() { } Widget listItemToWidget(String listItem) { - return new SizedBox( - key: new Key(listItem), + return SizedBox( + key: Key(listItem), height: itemHeight, width: itemHeight, - child: new Text(listItem), + child: Text(listItem), ); } Widget build({Widget header, Axis scrollDirection = Axis.vertical, TextDirection textDirection = TextDirection.ltr}) { - return new MaterialApp( - home: new Directionality( + return MaterialApp( + home: Directionality( textDirection: textDirection, - child: new SizedBox( + child: SizedBox( height: itemHeight * 10, width: itemHeight * 10, - child: new ReorderableListView( + child: ReorderableListView( header: header, children: listItems.map(listItemToWidget).toList(), scrollDirection: scrollDirection, @@ -113,7 +113,7 @@ void main() { }); testWidgets('properly determines the vertical drop area extents', (WidgetTester tester) async { - final Widget reorderableListView = new ReorderableListView( + final Widget reorderableListView = ReorderableListView( children: const [ SizedBox( key: Key('Normal item'), @@ -134,8 +134,8 @@ void main() { scrollDirection: Axis.vertical, onReorder: (int oldIndex, int newIndex) {}, ); - await tester.pumpWidget(new MaterialApp( - home: new SizedBox( + await tester.pumpWidget(MaterialApp( + home: SizedBox( height: itemHeight * 10, child: reorderableListView, ), @@ -191,12 +191,12 @@ void main() { .first .ancestorStateOfType(const TypeMatcher<_StatefulState>()); } - await tester.pumpWidget(new MaterialApp( - home: new ReorderableListView( + await tester.pumpWidget(MaterialApp( + home: ReorderableListView( children: [ - new _Stateful(key: const Key('A')), - new _Stateful(key: const Key('B')), - new _Stateful(key: const Key('C')), + _Stateful(key: const Key('A')), + _Stateful(key: const Key('B')), + _Stateful(key: const Key('C')), ], onReorder: (int oldIndex, int newIndex) {}, ), @@ -208,12 +208,12 @@ void main() { expect(findState(const Key('B')).checked, false); expect(findState(const Key('C')).checked, false); - await tester.pumpWidget(new MaterialApp( - home: new ReorderableListView( + await tester.pumpWidget(MaterialApp( + home: ReorderableListView( children: [ - new _Stateful(key: const Key('B')), - new _Stateful(key: const Key('C')), - new _Stateful(key: const Key('A')), + _Stateful(key: const Key('B')), + _Stateful(key: const Key('C')), + _Stateful(key: const Key('A')), ], onReorder: (int oldIndex, int newIndex) {}, ), @@ -225,8 +225,8 @@ void main() { }); testWidgets('Uses the PrimaryScrollController when available', (WidgetTester tester) async { - final ScrollController primary = new ScrollController(); - final Widget reorderableList = new ReorderableListView( + final ScrollController primary = ScrollController(); + final Widget reorderableList = ReorderableListView( children: const [ SizedBox(width: 100.0, height: 100.0, child: Text('C'), key: Key('C')), SizedBox(width: 100.0, height: 100.0, child: Text('B'), key: Key('B')), @@ -236,10 +236,10 @@ void main() { ); Widget buildWithScrollController(ScrollController controller) { - return new MaterialApp( - home: new PrimaryScrollController( + return MaterialApp( + home: PrimaryScrollController( controller: controller, - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, child: reorderableList, @@ -255,7 +255,7 @@ void main() { expect(scrollView.controller, primary); // Now try changing the primary scroll controller and checking that the scroll view gets updated. - final ScrollController primary2 = new ScrollController(); + final ScrollController primary2 = ScrollController(); await tester.pumpWidget(buildWithScrollController(primary2)); scrollView = tester.widget( find.byType(SingleChildScrollView), @@ -264,7 +264,7 @@ void main() { }); testWidgets('Still builds when no PrimaryScrollController is available', (WidgetTester tester) async { - final Widget reorderableList = new ReorderableListView( + final Widget reorderableList = ReorderableListView( children: const [ SizedBox(width: 100.0, height: 100.0, child: Text('C'), key: Key('C')), SizedBox(width: 100.0, height: 100.0, child: Text('B'), key: Key('B')), @@ -272,16 +272,16 @@ void main() { ], onReorder: (int oldIndex, int newIndex) {}, ); - final Widget boilerplate = new Localizations( + final Widget boilerplate = Localizations( locale: const Locale('en'), delegates: const >[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child:new SizedBox( + child:SizedBox( width: 100.0, height: 100.0, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, child: reorderableList, ), @@ -302,7 +302,7 @@ void main() { group('Accessibility (a11y/Semantics)', () { Map getSemanticsActions(int index) { final Semantics semantics = find.ancestor( - of: find.byKey(new Key(listItems[index])), + of: find.byKey(Key(listItems[index])), matching: find.byType(Semantics), ).evaluate().first.widget; return semantics.properties.customSemanticsActions; @@ -427,18 +427,18 @@ void main() { testWidgets("Doesn't hide accessibility when a child declares its own semantics", (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - final Widget reorderableListView = new ReorderableListView( + final Widget reorderableListView = ReorderableListView( children: [ const SizedBox( key: Key('List tile 1'), height: itemHeight, child: Text('List tile 1'), ), - new SizedBox( + SizedBox( key: const Key('Switch tile'), height: itemHeight, - child: new Material( - child: new SwitchListTile( + child: Material( + child: SwitchListTile( title: const Text('Switch tile'), value: true, onChanged: (bool newValue) {}, @@ -454,8 +454,8 @@ void main() { scrollDirection: Axis.vertical, onReorder: (int oldIndex, int newIndex) {}, ); - await tester.pumpWidget(new MaterialApp( - home: new SizedBox( + await tester.pumpWidget(MaterialApp( + home: SizedBox( height: itemHeight * 10, child: reorderableListView, ), @@ -541,7 +541,7 @@ void main() { }); testWidgets('properly determines the horizontal drop area extents', (WidgetTester tester) async { - final Widget reorderableListView = new ReorderableListView( + final Widget reorderableListView = ReorderableListView( children: const [ SizedBox( key: Key('Normal item'), @@ -562,8 +562,8 @@ void main() { scrollDirection: Axis.horizontal, onReorder: (int oldIndex, int newIndex) {}, ); - await tester.pumpWidget(new MaterialApp( - home: new SizedBox( + await tester.pumpWidget(MaterialApp( + home: SizedBox( width: itemHeight * 10, child: reorderableListView, ), @@ -620,12 +620,12 @@ void main() { .first .ancestorStateOfType(const TypeMatcher<_StatefulState>()); } - await tester.pumpWidget(new MaterialApp( - home: new ReorderableListView( + await tester.pumpWidget(MaterialApp( + home: ReorderableListView( children: [ - new _Stateful(key: const Key('A')), - new _Stateful(key: const Key('B')), - new _Stateful(key: const Key('C')), + _Stateful(key: const Key('A')), + _Stateful(key: const Key('B')), + _Stateful(key: const Key('C')), ], onReorder: (int oldIndex, int newIndex) {}, scrollDirection: Axis.horizontal, @@ -638,12 +638,12 @@ void main() { expect(findState(const Key('B')).checked, false); expect(findState(const Key('C')).checked, false); - await tester.pumpWidget(new MaterialApp( - home: new ReorderableListView( + await tester.pumpWidget(MaterialApp( + home: ReorderableListView( children: [ - new _Stateful(key: const Key('B')), - new _Stateful(key: const Key('C')), - new _Stateful(key: const Key('A')), + _Stateful(key: const Key('B')), + _Stateful(key: const Key('C')), + _Stateful(key: const Key('A')), ], onReorder: (int oldIndex, int newIndex) {}, scrollDirection: Axis.horizontal, @@ -658,7 +658,7 @@ void main() { group('Accessibility (a11y/Semantics)', () { Map getSemanticsActions(int index) { final Semantics semantics = find.ancestor( - of: find.byKey(new Key(listItems[index])), + of: find.byKey(Key(listItems[index])), matching: find.byType(Semantics), ).evaluate().first.widget; return semantics.properties.customSemanticsActions; @@ -919,7 +919,7 @@ class _Stateful extends StatefulWidget { _Stateful({Key key}) : super(key: key); @override - State createState() => new _StatefulState(); + State createState() => _StatefulState(); } class _StatefulState extends State<_Stateful> { @@ -927,11 +927,11 @@ class _StatefulState extends State<_Stateful> { @override Widget build(BuildContext context) { - return new Container( + return Container( width: 48.0, height: 48.0, - child: new Material( - child: new Checkbox( + child: Material( + child: Checkbox( value: checked, onChanged: (bool newValue) => checked = newValue, ), diff --git a/packages/flutter/test/material/scaffold_test.dart b/packages/flutter/test/material/scaffold_test.dart index f15e1a1a51..4d636b84bd 100644 --- a/packages/flutter/test/material/scaffold_test.dart +++ b/packages/flutter/test/material/scaffold_test.dart @@ -11,32 +11,32 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Scaffold control test', (WidgetTester tester) async { - final Key bodyKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key bodyKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Scaffold( - appBar: new AppBar(title: const Text('Title')), - body: new Container(key: bodyKey), + child: Scaffold( + appBar: AppBar(title: const Text('Title')), + body: Container(key: bodyKey), ), )); expect(tester.takeException(), isFlutterError); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - appBar: new AppBar(title: const Text('Title')), - body: new Container(key: bodyKey), + await tester.pumpWidget(MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Title')), + body: Container(key: bodyKey), ), )); RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey)); expect(bodyBox.size, equals(const Size(800.0, 544.0))); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 100.0)), - child: new Scaffold( - appBar: new AppBar(title: const Text('Title')), - body: new Container(key: bodyKey), + child: Scaffold( + appBar: AppBar(title: const Text('Title')), + body: Container(key: bodyKey), ), ), )); @@ -44,13 +44,13 @@ void main() { bodyBox = tester.renderObject(find.byKey(bodyKey)); expect(bodyBox.size, equals(const Size(800.0, 444.0))); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(viewInsets: EdgeInsets.only(bottom: 100.0)), - child: new Scaffold( - appBar: new AppBar(title: const Text('Title')), - body: new Container(key: bodyKey), + child: Scaffold( + appBar: AppBar(title: const Text('Title')), + body: Container(key: bodyKey), resizeToAvoidBottomPadding: false, ), ), @@ -61,15 +61,15 @@ void main() { }); testWidgets('Scaffold large bottom padding test', (WidgetTester tester) async { - final Key bodyKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key bodyKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( viewInsets: EdgeInsets.only(bottom: 700.0), ), - child: new Scaffold( - body: new Container(key: bodyKey), + child: Scaffold( + body: Container(key: bodyKey), ), ), )); @@ -77,31 +77,31 @@ void main() { final RenderBox bodyBox = tester.renderObject(find.byKey(bodyKey)); expect(bodyBox.size, equals(const Size(800.0, 0.0))); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( viewInsets: EdgeInsets.only(bottom: 500.0), ), - child: new Scaffold( - body: new Container(key: bodyKey), + child: Scaffold( + body: Container(key: bodyKey), ), ), )); expect(bodyBox.size, equals(const Size(800.0, 100.0))); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( viewInsets: EdgeInsets.only(bottom: 580.0), ), - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('Title'), ), - body: new Container(key: bodyKey), + body: Container(key: bodyKey), ), ), )); @@ -110,7 +110,7 @@ void main() { }); testWidgets('Floating action entrance/exit animation', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: const Scaffold( + await tester.pumpWidget(MaterialApp(home: const Scaffold( floatingActionButton: FloatingActionButton( key: Key('one'), onPressed: null, @@ -120,7 +120,7 @@ void main() { expect(tester.binding.transientCallbackCount, 0); - await tester.pumpWidget(new MaterialApp(home: const Scaffold( + await tester.pumpWidget(MaterialApp(home: const Scaffold( floatingActionButton: FloatingActionButton( key: Key('two'), onPressed: null, @@ -129,14 +129,14 @@ void main() { ))); expect(tester.binding.transientCallbackCount, greaterThan(0)); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(tester.binding.transientCallbackCount, 0); - await tester.pumpWidget(new MaterialApp(home: const Scaffold())); + await tester.pumpWidget(MaterialApp(home: const Scaffold())); expect(tester.binding.transientCallbackCount, 0); - await tester.pumpWidget(new MaterialApp(home: const Scaffold( + await tester.pumpWidget(MaterialApp(home: const Scaffold( floatingActionButton: FloatingActionButton( key: Key('one'), onPressed: null, @@ -149,7 +149,7 @@ void main() { testWidgets('Floating action button directionality', (WidgetTester tester) async { Widget build(TextDirection textDirection) { - return new Directionality( + return Directionality( textDirection: textDirection, child: const MediaQuery( data: MediaQueryData( @@ -176,24 +176,24 @@ void main() { }); testWidgets('Drawer scrolling', (WidgetTester tester) async { - final Key drawerKey = new UniqueKey(); + final Key drawerKey = UniqueKey(); const double appBarHeight = 256.0; - final ScrollController scrollOffset = new ScrollController(); + final ScrollController scrollOffset = ScrollController(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - drawer: new Drawer( + MaterialApp( + home: Scaffold( + drawer: Drawer( key: drawerKey, - child: new ListView( + child: ListView( controller: scrollOffset, - children: new List.generate(10, - (int index) => new SizedBox(height: 100.0, child: new Text('D$index')) + children: List.generate(10, + (int index) => SizedBox(height: 100.0, child: Text('D$index')) ) ) ), - body: new CustomScrollView( + body: CustomScrollView( slivers: [ const SliverAppBar( pinned: true, @@ -201,11 +201,11 @@ void main() { title: Text('Title'), flexibleSpace: FlexibleSpaceBar(title: Text('Title')), ), - new SliverPadding( + SliverPadding( padding: const EdgeInsets.only(top: appBarHeight), - sliver: new SliverList( - delegate: new SliverChildListDelegate(new List.generate( - 10, (int index) => new SizedBox(height: 100.0, child: new Text('B$index')), + sliver: SliverList( + delegate: SliverChildListDelegate(List.generate( + 10, (int index) => SizedBox(height: 100.0, child: Text('B$index')), )), ), ), @@ -234,20 +234,20 @@ void main() { }); Widget _buildStatusBarTestApp(TargetPlatform platform) { - return new MaterialApp( - theme: new ThemeData(platform: platform), - home: new MediaQuery( + return MaterialApp( + theme: ThemeData(platform: platform), + home: MediaQuery( data: const MediaQueryData(padding: EdgeInsets.only(top: 25.0)), // status bar - child: new Scaffold( - body: new CustomScrollView( + child: Scaffold( + body: CustomScrollView( primary: true, slivers: [ const SliverAppBar( title: Text('Title') ), - new SliverList( - delegate: new SliverChildListDelegate(new List.generate( - 20, (int index) => new SizedBox(height: 100.0, child: new Text('$index')), + SliverList( + delegate: SliverChildListDelegate(List.generate( + 20, (int index) => SizedBox(height: 100.0, child: Text('$index')), )), ), ], @@ -279,21 +279,21 @@ void main() { }); testWidgets('Bottom sheet cannot overlap app bar', (WidgetTester tester) async { - final Key sheetKey = new UniqueKey(); + final Key sheetKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( title: const Text('Title'), ), - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { Scaffold.of(context).showBottomSheet((BuildContext context) { - return new Container( + return Container( key: sheetKey, color: Colors.blue[500], ); @@ -323,17 +323,17 @@ void main() { testWidgets('Persistent bottom buttons are persistent', (WidgetTester tester) async { bool didPressButton = false; await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new SingleChildScrollView( - child: new Container( + MaterialApp( + home: Scaffold( + body: SingleChildScrollView( + child: Container( color: Colors.amber[500], height: 5000.0, child: const Text('body'), ), ), persistentFooterButtons: [ - new FlatButton( + FlatButton( onPressed: () { didPressButton = true; }, @@ -352,15 +352,15 @@ void main() { testWidgets('Persistent bottom buttons apply media padding', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.fromLTRB(10.0, 20.0, 30.0, 40.0), ), - child: new Scaffold( - body: new SingleChildScrollView( - child: new Container( + child: Scaffold( + body: SingleChildScrollView( + child: Container( color: Colors.amber[500], height: 5000.0, child: const Text('body'), @@ -377,16 +377,16 @@ void main() { group('back arrow', () { Future expectBackIcon(WidgetTester tester, TargetPlatform platform, IconData expectedIcon) async { - final GlobalKey rootKey = new GlobalKey(); + final GlobalKey rootKey = GlobalKey(); final Map routes = { - '/': (_) => new Container(key: rootKey, child: const Text('Home')), - '/scaffold': (_) => new Scaffold( - appBar: new AppBar(), + '/': (_) => Container(key: rootKey, child: const Text('Home')), + '/scaffold': (_) => Scaffold( + appBar: AppBar(), body: const Text('Scaffold'), ) }; await tester.pumpWidget( - new MaterialApp(theme: new ThemeData(platform: platform), routes: routes) + MaterialApp(theme: ThemeData(platform: platform), routes: routes) ); Navigator.pushNamed(rootKey.currentContext, '/scaffold'); @@ -413,9 +413,9 @@ void main() { group('close button', () { Future expectCloseIcon(WidgetTester tester, TargetPlatform platform, IconData expectedIcon, PageRoute routeBuilder()) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(platform: platform), - home: new Scaffold(appBar: new AppBar(), body: const Text('Page 1')), + MaterialApp( + theme: ThemeData(platform: platform), + home: Scaffold(appBar: AppBar(), body: const Text('Page 1')), ) ); @@ -430,18 +430,18 @@ void main() { } PageRoute materialRouteBuilder() { - return new MaterialPageRoute( + return MaterialPageRoute( builder: (BuildContext context) { - return new Scaffold(appBar: new AppBar(), body: const Text('Page 2')); + return Scaffold(appBar: AppBar(), body: const Text('Page 2')); }, fullscreenDialog: true, ); } PageRoute customPageRouteBuilder() { - return new _CustomPageRoute( + return _CustomPageRoute( builder: (BuildContext context) { - return new Scaffold(appBar: new AppBar(), body: const Text('Page 2')); + return Scaffold(appBar: AppBar(), body: const Text('Page 2')); }, fullscreenDialog: true, ); @@ -474,13 +474,13 @@ void main() { group('body size', () { testWidgets('body size with container', (WidgetTester tester) async { - final Key testKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key testKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scaffold( - body: new Container( + child: Scaffold( + body: Container( key: testKey, ), ), @@ -491,13 +491,13 @@ void main() { }); testWidgets('body size with sized container', (WidgetTester tester) async { - final Key testKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key testKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scaffold( - body: new Container( + child: Scaffold( + body: Container( key: testKey, height: 100.0, ), @@ -509,14 +509,14 @@ void main() { }); testWidgets('body size with centered container', (WidgetTester tester) async { - final Key testKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key testKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scaffold( - body: new Center( - child: new Container( + child: Scaffold( + body: Center( + child: Container( key: testKey, ), ), @@ -528,13 +528,13 @@ void main() { }); testWidgets('body size with button', (WidgetTester tester) async { - final Key testKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key testKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scaffold( - body: new FlatButton( + child: Scaffold( + body: FlatButton( key: testKey, onPressed: () { }, child: const Text(''), @@ -554,8 +554,8 @@ void main() { const String floatingActionButtonLabel = 'I float in space'; const String drawerLabel = 'I am the reason for this test'; - final SemanticsTester semantics = new SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp(home: const Scaffold( + final SemanticsTester semantics = SemanticsTester(tester); + await tester.pumpWidget(MaterialApp(home: const Scaffold( body: Text(bodyLabel), persistentFooterButtons: [Text(persistentFooterButtonLabel)], bottomNavigationBar: Text(bottomNavigationBarLabel), @@ -584,22 +584,22 @@ void main() { }); testWidgets('Scaffold and extreme window padding', (WidgetTester tester) async { - final Key appBar = new UniqueKey(); - final Key body = new UniqueKey(); - final Key floatingActionButton = new UniqueKey(); - final Key persistentFooterButton = new UniqueKey(); - final Key drawer = new UniqueKey(); - final Key bottomNavigationBar = new UniqueKey(); - final Key insideAppBar = new UniqueKey(); - final Key insideBody = new UniqueKey(); - final Key insideFloatingActionButton = new UniqueKey(); - final Key insidePersistentFooterButton = new UniqueKey(); - final Key insideDrawer = new UniqueKey(); - final Key insideBottomNavigationBar = new UniqueKey(); + final Key appBar = UniqueKey(); + final Key body = UniqueKey(); + final Key floatingActionButton = UniqueKey(); + final Key persistentFooterButton = UniqueKey(); + final Key drawer = UniqueKey(); + final Key bottomNavigationBar = UniqueKey(); + final Key insideAppBar = UniqueKey(); + final Key insideBody = UniqueKey(); + final Key insideFloatingActionButton = UniqueKey(); + final Key insidePersistentFooterButton = UniqueKey(); + final Key insideDrawer = UniqueKey(); + final Key insideBottomNavigationBar = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.only( left: 20.0, @@ -609,52 +609,52 @@ void main() { ), viewInsets: EdgeInsets.only(bottom: 200.0), ), - child: new Scaffold( - appBar: new PreferredSize( + child: Scaffold( + appBar: PreferredSize( preferredSize: const Size(11.0, 13.0), - child: new Container( + child: Container( key: appBar, - child: new SafeArea( - child: new Placeholder(key: insideAppBar), + child: SafeArea( + child: Placeholder(key: insideAppBar), ), ), ), - body: new Container( + body: Container( key: body, - child: new SafeArea( - child: new Placeholder(key: insideBody), + child: SafeArea( + child: Placeholder(key: insideBody), ), ), - floatingActionButton: new SizedBox( + floatingActionButton: SizedBox( key: floatingActionButton, width: 77.0, height: 77.0, - child: new SafeArea( - child: new Placeholder(key: insideFloatingActionButton), + child: SafeArea( + child: Placeholder(key: insideFloatingActionButton), ), ), persistentFooterButtons: [ - new SizedBox( + SizedBox( key: persistentFooterButton, width: 100.0, height: 90.0, - child: new SafeArea( - child: new Placeholder(key: insidePersistentFooterButton), + child: SafeArea( + child: Placeholder(key: insidePersistentFooterButton), ), ), ], - drawer: new Container( + drawer: Container( key: drawer, width: 204.0, - child: new SafeArea( - child: new Placeholder(key: insideDrawer), + child: SafeArea( + child: Placeholder(key: insideDrawer), ), ), - bottomNavigationBar: new SizedBox( + bottomNavigationBar: SizedBox( key: bottomNavigationBar, height: 85.0, - child: new SafeArea( - child: new Placeholder(key: insideBottomNavigationBar), + child: SafeArea( + child: Placeholder(key: insideBottomNavigationBar), ), ), ), @@ -666,35 +666,35 @@ void main() { await tester.pump(); await tester.pump(const Duration(seconds: 1)); - expect(tester.getRect(find.byKey(appBar)), new Rect.fromLTRB(0.0, 0.0, 800.0, 43.0)); - expect(tester.getRect(find.byKey(body)), new Rect.fromLTRB(0.0, 43.0, 800.0, 348.0)); - expect(tester.getRect(find.byKey(floatingActionButton)), new Rect.fromLTRB(36.0, 255.0, 113.0, 332.0)); - expect(tester.getRect(find.byKey(persistentFooterButton)), new Rect.fromLTRB(28.0, 357.0, 128.0, 447.0)); // Note: has 8px each top/bottom padding. - expect(tester.getRect(find.byKey(drawer)), new Rect.fromLTRB(596.0, 0.0, 800.0, 600.0)); - expect(tester.getRect(find.byKey(bottomNavigationBar)), new Rect.fromLTRB(0.0, 515.0, 800.0, 600.0)); - expect(tester.getRect(find.byKey(insideAppBar)), new Rect.fromLTRB(20.0, 30.0, 750.0, 43.0)); - expect(tester.getRect(find.byKey(insideBody)), new Rect.fromLTRB(20.0, 43.0, 750.0, 348.0)); - expect(tester.getRect(find.byKey(insideFloatingActionButton)), new Rect.fromLTRB(36.0, 255.0, 113.0, 332.0)); - expect(tester.getRect(find.byKey(insidePersistentFooterButton)), new Rect.fromLTRB(28.0, 357.0, 128.0, 447.0)); - expect(tester.getRect(find.byKey(insideDrawer)), new Rect.fromLTRB(596.0, 30.0, 750.0, 540.0)); - expect(tester.getRect(find.byKey(insideBottomNavigationBar)), new Rect.fromLTRB(20.0, 515.0, 750.0, 540.0)); + expect(tester.getRect(find.byKey(appBar)), Rect.fromLTRB(0.0, 0.0, 800.0, 43.0)); + expect(tester.getRect(find.byKey(body)), Rect.fromLTRB(0.0, 43.0, 800.0, 348.0)); + expect(tester.getRect(find.byKey(floatingActionButton)), Rect.fromLTRB(36.0, 255.0, 113.0, 332.0)); + expect(tester.getRect(find.byKey(persistentFooterButton)), Rect.fromLTRB(28.0, 357.0, 128.0, 447.0)); // Note: has 8px each top/bottom padding. + expect(tester.getRect(find.byKey(drawer)), Rect.fromLTRB(596.0, 0.0, 800.0, 600.0)); + expect(tester.getRect(find.byKey(bottomNavigationBar)), Rect.fromLTRB(0.0, 515.0, 800.0, 600.0)); + expect(tester.getRect(find.byKey(insideAppBar)), Rect.fromLTRB(20.0, 30.0, 750.0, 43.0)); + expect(tester.getRect(find.byKey(insideBody)), Rect.fromLTRB(20.0, 43.0, 750.0, 348.0)); + expect(tester.getRect(find.byKey(insideFloatingActionButton)), Rect.fromLTRB(36.0, 255.0, 113.0, 332.0)); + expect(tester.getRect(find.byKey(insidePersistentFooterButton)), Rect.fromLTRB(28.0, 357.0, 128.0, 447.0)); + expect(tester.getRect(find.byKey(insideDrawer)), Rect.fromLTRB(596.0, 30.0, 750.0, 540.0)); + expect(tester.getRect(find.byKey(insideBottomNavigationBar)), Rect.fromLTRB(20.0, 515.0, 750.0, 540.0)); }); testWidgets('Scaffold and extreme window padding - persistent footer buttons only', (WidgetTester tester) async { - final Key appBar = new UniqueKey(); - final Key body = new UniqueKey(); - final Key floatingActionButton = new UniqueKey(); - final Key persistentFooterButton = new UniqueKey(); - final Key drawer = new UniqueKey(); - final Key insideAppBar = new UniqueKey(); - final Key insideBody = new UniqueKey(); - final Key insideFloatingActionButton = new UniqueKey(); - final Key insidePersistentFooterButton = new UniqueKey(); - final Key insideDrawer = new UniqueKey(); + final Key appBar = UniqueKey(); + final Key body = UniqueKey(); + final Key floatingActionButton = UniqueKey(); + final Key persistentFooterButton = UniqueKey(); + final Key drawer = UniqueKey(); + final Key insideAppBar = UniqueKey(); + final Key insideBody = UniqueKey(); + final Key insideFloatingActionButton = UniqueKey(); + final Key insidePersistentFooterButton = UniqueKey(); + final Key insideDrawer = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.only( left: 20.0, @@ -704,45 +704,45 @@ void main() { ), viewInsets: EdgeInsets.only(bottom: 200.0), ), - child: new Scaffold( - appBar: new PreferredSize( + child: Scaffold( + appBar: PreferredSize( preferredSize: const Size(11.0, 13.0), - child: new Container( + child: Container( key: appBar, - child: new SafeArea( - child: new Placeholder(key: insideAppBar), + child: SafeArea( + child: Placeholder(key: insideAppBar), ), ), ), - body: new Container( + body: Container( key: body, - child: new SafeArea( - child: new Placeholder(key: insideBody), + child: SafeArea( + child: Placeholder(key: insideBody), ), ), - floatingActionButton: new SizedBox( + floatingActionButton: SizedBox( key: floatingActionButton, width: 77.0, height: 77.0, - child: new SafeArea( - child: new Placeholder(key: insideFloatingActionButton), + child: SafeArea( + child: Placeholder(key: insideFloatingActionButton), ), ), persistentFooterButtons: [ - new SizedBox( + SizedBox( key: persistentFooterButton, width: 100.0, height: 90.0, - child: new SafeArea( - child: new Placeholder(key: insidePersistentFooterButton), + child: SafeArea( + child: Placeholder(key: insidePersistentFooterButton), ), ), ], - drawer: new Container( + drawer: Container( key: drawer, width: 204.0, - child: new SafeArea( - child: new Placeholder(key: insideDrawer), + child: SafeArea( + child: Placeholder(key: insideDrawer), ), ), ), @@ -754,28 +754,28 @@ void main() { await tester.pump(); await tester.pump(const Duration(seconds: 1)); - expect(tester.getRect(find.byKey(appBar)), new Rect.fromLTRB(0.0, 0.0, 800.0, 43.0)); - expect(tester.getRect(find.byKey(body)), new Rect.fromLTRB(0.0, 43.0, 800.0, 400.0)); - expect(tester.getRect(find.byKey(floatingActionButton)), new Rect.fromLTRB(36.0, 307.0, 113.0, 384.0)); - expect(tester.getRect(find.byKey(persistentFooterButton)), new Rect.fromLTRB(28.0, 442.0, 128.0, 532.0)); // Note: has 8px each top/bottom padding. - expect(tester.getRect(find.byKey(drawer)), new Rect.fromLTRB(596.0, 0.0, 800.0, 600.0)); - expect(tester.getRect(find.byKey(insideAppBar)), new Rect.fromLTRB(20.0, 30.0, 750.0, 43.0)); - expect(tester.getRect(find.byKey(insideBody)), new Rect.fromLTRB(20.0, 43.0, 750.0, 400.0)); - expect(tester.getRect(find.byKey(insideFloatingActionButton)), new Rect.fromLTRB(36.0, 307.0, 113.0, 384.0)); - expect(tester.getRect(find.byKey(insidePersistentFooterButton)), new Rect.fromLTRB(28.0, 442.0, 128.0, 532.0)); - expect(tester.getRect(find.byKey(insideDrawer)), new Rect.fromLTRB(596.0, 30.0, 750.0, 540.0)); + expect(tester.getRect(find.byKey(appBar)), Rect.fromLTRB(0.0, 0.0, 800.0, 43.0)); + expect(tester.getRect(find.byKey(body)), Rect.fromLTRB(0.0, 43.0, 800.0, 400.0)); + expect(tester.getRect(find.byKey(floatingActionButton)), Rect.fromLTRB(36.0, 307.0, 113.0, 384.0)); + expect(tester.getRect(find.byKey(persistentFooterButton)), Rect.fromLTRB(28.0, 442.0, 128.0, 532.0)); // Note: has 8px each top/bottom padding. + expect(tester.getRect(find.byKey(drawer)), Rect.fromLTRB(596.0, 0.0, 800.0, 600.0)); + expect(tester.getRect(find.byKey(insideAppBar)), Rect.fromLTRB(20.0, 30.0, 750.0, 43.0)); + expect(tester.getRect(find.byKey(insideBody)), Rect.fromLTRB(20.0, 43.0, 750.0, 400.0)); + expect(tester.getRect(find.byKey(insideFloatingActionButton)), Rect.fromLTRB(36.0, 307.0, 113.0, 384.0)); + expect(tester.getRect(find.byKey(insidePersistentFooterButton)), Rect.fromLTRB(28.0, 442.0, 128.0, 532.0)); + expect(tester.getRect(find.byKey(insideDrawer)), Rect.fromLTRB(596.0, 30.0, 750.0, 540.0)); }); group('ScaffoldGeometry', () { testWidgets('bottomNavigationBar', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new Container(), - bottomNavigationBar: new ConstrainedBox( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: Container(), + bottomNavigationBar: ConstrainedBox( key: key, constraints: const BoxConstraints.expand(height: 80.0), - child: new _GeometryListener(), + child: _GeometryListener(), ), ))); @@ -791,10 +791,10 @@ void main() { }); testWidgets('no bottomNavigationBar', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new ConstrainedBox( + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: ConstrainedBox( constraints: const BoxConstraints.expand(height: 80.0), - child: new _GeometryListener(), + child: _GeometryListener(), ), ))); @@ -808,12 +808,12 @@ void main() { }); testWidgets('floatingActionButton', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new Container(), - floatingActionButton: new FloatingActionButton( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: Container(), + floatingActionButton: FloatingActionButton( key: key, - child: new _GeometryListener(), + child: _GeometryListener(), onPressed: () {}, ), ))); @@ -831,10 +831,10 @@ void main() { }); testWidgets('no floatingActionButton', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new ConstrainedBox( + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: ConstrainedBox( constraints: const BoxConstraints.expand(height: 80.0), - child: new _GeometryListener(), + child: _GeometryListener(), ), ))); @@ -848,19 +848,19 @@ void main() { }); testWidgets('floatingActionButton entrance/exit animation', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new ConstrainedBox( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: ConstrainedBox( constraints: const BoxConstraints.expand(height: 80.0), - child: new _GeometryListener(), + child: _GeometryListener(), ), ))); - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new Container(), - floatingActionButton: new FloatingActionButton( + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: Container(), + floatingActionButton: FloatingActionButton( key: key, - child: new _GeometryListener(), + child: _GeometryListener(), onPressed: () {}, ), ))); @@ -899,12 +899,12 @@ void main() { }); testWidgets('change notifications', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); int numNotificationsAtLastFrame = 0; - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new ConstrainedBox( + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: ConstrainedBox( constraints: const BoxConstraints.expand(height: 80.0), - child: new _GeometryListener(), + child: _GeometryListener(), ), ))); @@ -913,11 +913,11 @@ void main() { expect(listenerState.numNotifications, greaterThan(numNotificationsAtLastFrame)); numNotificationsAtLastFrame = listenerState.numNotifications; - await tester.pumpWidget(new MaterialApp(home: new Scaffold( - body: new Container(), - floatingActionButton: new FloatingActionButton( + await tester.pumpWidget(MaterialApp(home: Scaffold( + body: Container(), + floatingActionButton: FloatingActionButton( key: key, - child: new _GeometryListener(), + child: _GeometryListener(), onPressed: () {}, ), ))); @@ -941,8 +941,8 @@ void main() { const String drawerLabel = 'I am the label on start side'; const String endDrawerLabel = 'I am the label on end side'; - final SemanticsTester semantics = new SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp(home: const Scaffold( + final SemanticsTester semantics = SemanticsTester(tester); + await tester.pumpWidget(MaterialApp(home: const Scaffold( body: Text(bodyLabel), drawer: Drawer(child: Text(drawerLabel)), endDrawer: Drawer(child: Text(endDrawerLabel)), @@ -973,13 +973,13 @@ void main() { testWidgets('Dual Drawer Opening', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new SafeArea( + MaterialApp( + home: SafeArea( left: false, top: true, right: false, bottom: false, - child: new Scaffold( + child: Scaffold( endDrawer: const Drawer( child: Text('endDrawer'), ), @@ -987,7 +987,7 @@ void main() { child: Text('drawer'), ), body: const Text('scaffold body'), - appBar: new AppBar( + appBar: AppBar( centerTitle: true, title: const Text('Title') ) @@ -1028,13 +1028,13 @@ void main() { class _GeometryListener extends StatefulWidget { @override - _GeometryListenerState createState() => new _GeometryListenerState(); + _GeometryListenerState createState() => _GeometryListenerState(); } class _GeometryListenerState extends State<_GeometryListener> { @override Widget build(BuildContext context) { - return new CustomPaint( + return CustomPaint( painter: cache ); } @@ -1055,7 +1055,7 @@ class _GeometryListenerState extends State<_GeometryListener> { geometryListenable = newListenable; geometryListenable.addListener(onGeometryChanged); - cache = new _GeometryCachePainter(geometryListenable); + cache = _GeometryCachePainter(geometryListenable); } void onGeometryChanged() { diff --git a/packages/flutter/test/material/scrollbar_paint_test.dart b/packages/flutter/test/material/scrollbar_paint_test.dart index 05e080a575..39426b642d 100644 --- a/packages/flutter/test/material/scrollbar_paint_test.dart +++ b/packages/flutter/test/material/scrollbar_paint_test.dart @@ -9,30 +9,30 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Viewport basic test (LTR)', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Scrollbar( - child: new SingleChildScrollView( + child: Scrollbar( + child: SingleChildScrollView( child: const SizedBox(width: 4000.0, height: 4000.0), ), ), )); expect(find.byType(Scrollbar), isNot(paints..rect())); await tester.fling(find.byType(SingleChildScrollView), const Offset(0.0, -10.0), 10.0); - expect(find.byType(Scrollbar), paints..rect(rect: new Rect.fromLTRB(800.0 - 6.0, 1.5, 800.0, 91.5))); + expect(find.byType(Scrollbar), paints..rect(rect: Rect.fromLTRB(800.0 - 6.0, 1.5, 800.0, 91.5))); }); testWidgets('Viewport basic test (RTL)', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, - child: new Scrollbar( - child: new SingleChildScrollView( + child: Scrollbar( + child: SingleChildScrollView( child: const SizedBox(width: 4000.0, height: 4000.0), ), ), )); expect(find.byType(Scrollbar), isNot(paints..rect())); await tester.fling(find.byType(SingleChildScrollView), const Offset(0.0, -10.0), 10.0); - expect(find.byType(Scrollbar), paints..rect(rect: new Rect.fromLTRB(0.0, 1.5, 6.0, 91.5))); + expect(find.byType(Scrollbar), paints..rect(rect: Rect.fromLTRB(0.0, 1.5, 6.0, 91.5))); }); } diff --git a/packages/flutter/test/material/scrollbar_test.dart b/packages/flutter/test/material/scrollbar_test.dart index 9be3ef7f8f..7fc7469c7c 100644 --- a/packages/flutter/test/material/scrollbar_test.dart +++ b/packages/flutter/test/material/scrollbar_test.dart @@ -21,26 +21,26 @@ class TestCanvas implements Canvas { void main() { testWidgets('Scrollbar doesn\'t show when tapping list', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( - decoration: new BoxDecoration( - border: new Border.all(color: const Color(0xFFFFFF00)) + child: Center( + child: Container( + decoration: BoxDecoration( + border: Border.all(color: const Color(0xFFFFFF00)) ), height: 200.0, width: 300.0, - child: new Scrollbar( - child: new ListView( + child: Scrollbar( + child: ListView( children: [ - new Container(height: 40.0, child: const Text('0')), - new Container(height: 40.0, child: const Text('1')), - new Container(height: 40.0, child: const Text('2')), - new Container(height: 40.0, child: const Text('3')), - new Container(height: 40.0, child: const Text('4')), - new Container(height: 40.0, child: const Text('5')), - new Container(height: 40.0, child: const Text('6')), - new Container(height: 40.0, child: const Text('7')), + Container(height: 40.0, child: const Text('0')), + Container(height: 40.0, child: const Text('1')), + Container(height: 40.0, child: const Text('2')), + Container(height: 40.0, child: const Text('3')), + Container(height: 40.0, child: const Text('4')), + Container(height: 40.0, child: const Text('5')), + Container(height: 40.0, child: const Text('6')), + Container(height: 40.0, child: const Text('7')), ], ), ), @@ -64,15 +64,15 @@ void main() { }); testWidgets('ScrollbarPainter does not divide by zero', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Container( + child: Container( height: 200.0, width: 300.0, - child: new Scrollbar( - child: new ListView( + child: Scrollbar( + child: ListView( children: [ - new Container(height: 40.0, child: const Text('0')), + Container(height: 40.0, child: const Text('0')), ], ), ), @@ -89,7 +89,7 @@ void main() { await tester.pump(const Duration(milliseconds: 200)); await tester.pump(const Duration(milliseconds: 200)); - final ScrollMetrics metrics = new FixedScrollMetrics( + final ScrollMetrics metrics = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 0.0, pixels: 0.0, @@ -99,7 +99,7 @@ void main() { scrollPainter.update(metrics, AxisDirection.down); final List invocations = []; - final TestCanvas canvas = new TestCanvas(invocations); + final TestCanvas canvas = TestCanvas(invocations); scrollPainter.paint(canvas, const Size(10.0, 100.0)); final Rect thumbRect = invocations.single.positionalArguments[0]; expect(thumbRect.isFinite, isTrue); @@ -107,14 +107,14 @@ void main() { testWidgets('Adaptive scrollbar', (WidgetTester tester) async { Widget viewWithScroll(TargetPlatform platform) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Theme( - data: new ThemeData( + child: Theme( + data: ThemeData( platform: platform ), - child: new Scrollbar( - child: new SingleChildScrollView( + child: Scrollbar( + child: SingleChildScrollView( child: const SizedBox(width: 4000.0, height: 4000.0), ), ), diff --git a/packages/flutter/test/material/search_test.dart b/packages/flutter/test/material/search_test.dart index 8e4cf6884f..9f2454be34 100644 --- a/packages/flutter/test/material/search_test.dart +++ b/packages/flutter/test/material/search_test.dart @@ -11,10 +11,10 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Can open and close search', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); final List selectedResults = []; - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, results: selectedResults, )); @@ -49,10 +49,10 @@ void main() { testWidgets('Can close search with system back button to return null', (WidgetTester tester) async { // regression test for https://github.com/flutter/flutter/issues/18145 - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); final List selectedResults = []; - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, results: selectedResults, )); @@ -92,9 +92,9 @@ void main() { }); testWidgets('Requests suggestions', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, )); await tester.tap(find.byTooltip('Search')); @@ -121,10 +121,10 @@ void main() { }); testWidgets('Shows Results and closes search', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); final List selectedResults = []; - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, results: selectedResults, )); @@ -158,9 +158,9 @@ void main() { testWidgets('Can switch between results and suggestions', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, )); await tester.tap(find.byTooltip('Search')); @@ -229,9 +229,9 @@ void main() { testWidgets('Fresh search allways starts with empty query', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, )); await tester.tap(find.byTooltip('Search')); @@ -249,11 +249,11 @@ void main() { }); testWidgets('Initial queries are honored', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); expect(delegate.query, ''); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, passInInitialQuery: true, initialQuery: 'Foo', @@ -265,11 +265,11 @@ void main() { }); testWidgets('Initial query null re-used previous query', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); delegate.query = 'Foo'; - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, passInInitialQuery: true, initialQuery: null, @@ -281,9 +281,9 @@ void main() { }); testWidgets('Changing query shows up in search field', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, passInInitialQuery: true, initialQuery: null, @@ -303,9 +303,9 @@ void main() { }); testWidgets('transitionAnimation runs while search fades in/out', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, passInInitialQuery: true, initialQuery: null, @@ -333,17 +333,17 @@ void main() { testWidgets('Closing nested search returns to search', (WidgetTester tester) async { final List nestedSearchResults = []; - final _TestSearchDelegate nestedSearchDelegate = new _TestSearchDelegate( + final _TestSearchDelegate nestedSearchDelegate = _TestSearchDelegate( suggestions: 'Nested Suggestions', result: 'Nested Result', ); final List selectedResults = []; - final _TestSearchDelegate delegate = new _TestSearchDelegate( + final _TestSearchDelegate delegate = _TestSearchDelegate( actions: [ - new Builder( + Builder( builder: (BuildContext context) { - return new IconButton( + return IconButton( tooltip: 'Nested Search', icon: const Icon(Icons.search), onPressed: () async { @@ -359,7 +359,7 @@ void main() { ], ); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, results: selectedResults, )); @@ -398,13 +398,13 @@ void main() { testWidgets('Closing search with nested search shown goes back to underlying route', (WidgetTester tester) async { _TestSearchDelegate delegate; final List nestedSearchResults = []; - final _TestSearchDelegate nestedSearchDelegate = new _TestSearchDelegate( + final _TestSearchDelegate nestedSearchDelegate = _TestSearchDelegate( suggestions: 'Nested Suggestions', result: 'Nested Result', actions: [ - new Builder( + Builder( builder: (BuildContext context) { - return new IconButton( + return IconButton( tooltip: 'Close Search', icon: const Icon(Icons.close), onPressed: () async { @@ -417,11 +417,11 @@ void main() { ); final List selectedResults = []; - delegate = new _TestSearchDelegate( + delegate = _TestSearchDelegate( actions: [ - new Builder( + Builder( builder: (BuildContext context) { - return new IconButton( + return IconButton( tooltip: 'Nested Search', icon: const Icon(Icons.search), onPressed: () async { @@ -437,7 +437,7 @@ void main() { ], ); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, results: selectedResults, )); @@ -468,9 +468,9 @@ void main() { }); testWidgets('keyboard show search button', (WidgetTester tester) async { - final _TestSearchDelegate delegate = new _TestSearchDelegate(); + final _TestSearchDelegate delegate = _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + await tester.pumpWidget(TestHomePage( delegate: delegate, )); await tester.tap(find.byTooltip('Search')); @@ -483,13 +483,13 @@ void main() { group('contributes semantics', () { TestSemantics buildExpected({String routeName}) { - return new TestSemantics.root( + return TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 7, flags: [ SemanticsFlag.scopesRoute, @@ -498,10 +498,10 @@ void main() { label: routeName, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 9, children: [ - new TestSemantics( + TestSemantics( id: 10, flags: [ SemanticsFlag.isButton, @@ -512,7 +512,7 @@ void main() { label: 'Back', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 11, flags: [ SemanticsFlag.isTextField, @@ -530,7 +530,7 @@ void main() { ), ], ), - new TestSemantics( + TestSemantics( id: 8, flags: [ SemanticsFlag.isButton, @@ -550,9 +550,9 @@ void main() { } testWidgets('includes routeName on Android', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final _TestSearchDelegate delegate = new _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + final SemanticsTester semantics = SemanticsTester(tester); + final _TestSearchDelegate delegate = _TestSearchDelegate(); + await tester.pumpWidget(TestHomePage( delegate: delegate, )); @@ -567,9 +567,9 @@ void main() { testWidgets('does not include routeName on iOS', (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final SemanticsTester semantics = new SemanticsTester(tester); - final _TestSearchDelegate delegate = new _TestSearchDelegate(); - await tester.pumpWidget(new TestHomePage( + final SemanticsTester semantics = SemanticsTester(tester); + final _TestSearchDelegate delegate = _TestSearchDelegate(); + await tester.pumpWidget(TestHomePage( delegate: delegate, )); @@ -600,13 +600,13 @@ class TestHomePage extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( home: Builder(builder: (BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('HomeTitle'), actions: [ - new IconButton( + IconButton( tooltip: 'Search', icon: const Icon(Icons.search), onPressed: () async { @@ -649,7 +649,7 @@ class _TestSearchDelegate extends SearchDelegate { @override Widget buildLeading(BuildContext context) { - return new IconButton( + return IconButton( tooltip: 'Back', icon: const Icon(Icons.arrow_back), onPressed: () { @@ -664,11 +664,11 @@ class _TestSearchDelegate extends SearchDelegate { @override Widget buildSuggestions(BuildContext context) { querysForSuggestions.add(query); - return new MaterialButton( + return MaterialButton( onPressed: () { showResults(context); }, - child: new Text(suggestions), + child: Text(suggestions), ); } diff --git a/packages/flutter/test/material/slider_test.dart b/packages/flutter/test/material/slider_test.dart index 3ba44c0c5e..6db6c616d9 100644 --- a/packages/flutter/test/material/slider_test.dart +++ b/packages/flutter/test/material/slider_test.dart @@ -38,28 +38,28 @@ class LoggingThumbShape extends SliderComponentShape { double value, }) { log.add(thumbCenter); - final Paint thumbPaint = new Paint()..color = Colors.red; + final Paint thumbPaint = Paint()..color = Colors.red; context.canvas.drawCircle(thumbCenter, 5.0, thumbPaint); } } void main() { testWidgets('Slider can move when tapped (LTR)', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; double startValue; double endValue; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -105,19 +105,19 @@ void main() { }); testWidgets('Slider can move when tapped (RTL)', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -151,7 +151,7 @@ void main() { }); testWidgets("Slider doesn't send duplicate change events if tapped on the same value", (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; double startValue; double endValue; @@ -160,15 +160,15 @@ void main() { int endValueUpdates = 0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -209,19 +209,19 @@ void main() { }); testWidgets('Value indicator shows for a bit after being tapped', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( key: sliderKey, value: value, divisions: 4, @@ -260,23 +260,23 @@ void main() { }); testWidgets('Discrete Slider repaints and animates when dragged', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; final List log = []; - final LoggingThumbShape loggingThumb = new LoggingThumbShape(log); + final LoggingThumbShape loggingThumb = LoggingThumbShape(log); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { final SliderThemeData sliderTheme = SliderTheme.of(context).copyWith(thumbShape: loggingThumb); - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new SliderTheme( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: SliderTheme( data: sliderTheme, - child: new Slider( + child: Slider( key: sliderKey, value: value, divisions: 4, @@ -329,20 +329,20 @@ void main() { }); testWidgets("Slider doesn't send duplicate change events if tapped on the same value", (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; int updates = 0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( key: sliderKey, value: value, onChanged: (double newValue) { @@ -371,23 +371,23 @@ void main() { }); testWidgets('discrete Slider repaints when dragged', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; final List log = []; - final LoggingThumbShape loggingThumb = new LoggingThumbShape(log); + final LoggingThumbShape loggingThumb = LoggingThumbShape(log); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { final SliderThemeData sliderTheme = SliderTheme.of(context).copyWith(thumbShape: loggingThumb); - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new SliderTheme( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: SliderTheme( data: sliderTheme, - child: new Slider( + child: Slider( key: sliderKey, value: value, divisions: 4, @@ -440,21 +440,21 @@ void main() { }); testWidgets('Slider take on discrete values', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new SizedBox( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: SizedBox( width: 144.0 + 2 * 16.0, // _kPreferredTotalWidth - child: new Slider( + child: Slider( key: sliderKey, min: 0.0, max: 100.0, @@ -495,12 +495,12 @@ void main() { testWidgets('Slider can be given zero values', (WidgetTester tester) async { final List log = []; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Slider( value: 0.0, min: 0.0, max: 1.0, @@ -516,12 +516,12 @@ void main() { expect(log, [0.5]); log.clear(); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Slider( value: 0.0, min: 0.0, max: 0.0, @@ -541,7 +541,7 @@ void main() { testWidgets('Slider uses the right theme colors for the right components', (WidgetTester tester) async { const Color customColor1 = Color(0xcafefeed); const Color customColor2 = Color(0xdeadbeef); - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.blue, ); @@ -558,15 +558,15 @@ void main() { : (double d) { value = d; }; - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Theme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Theme( data: theme, - child: new Slider( + child: Slider( value: value, label: '$value', divisions: divisions, @@ -734,20 +734,20 @@ void main() { testWidgets('Slider can tap in vertical scroller', (WidgetTester tester) async { double value = 0.0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new ListView( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: ListView( children: [ - new Slider( + Slider( value: value, onChanged: (double newValue) { value = newValue; }, ), - new Container( + Container( height: 2000.0, ), ], @@ -762,13 +762,13 @@ void main() { testWidgets('Slider drags immediately (LTR)', (WidgetTester tester) async { double value = 0.0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( value: value, onChanged: (double newValue) { value = newValue; @@ -793,13 +793,13 @@ void main() { testWidgets('Slider drags immediately (RTL)', (WidgetTester tester) async { double value = 0.0; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( value: value, onChanged: (double newValue) { value = newValue; @@ -823,10 +823,10 @@ void main() { }); testWidgets('Slider sizing', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), + child: MediaQuery( + data: MediaQueryData.fromWindow(window), child: const Material( child: Center( child: Slider( @@ -839,10 +839,10 @@ void main() { )); expect(tester.renderObject(find.byType(Slider)).size, const Size(800.0, 600.0)); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), + child: MediaQuery( + data: MediaQueryData.fromWindow(window), child: const Material( child: Center( child: IntrinsicWidth( @@ -857,10 +857,10 @@ void main() { )); expect(tester.renderObject(find.byType(Slider)).size, const Size(144.0 + 2.0 * 16.0, 600.0)); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), + child: MediaQuery( + data: MediaQueryData.fromWindow(window), child: const Material( child: Center( child: OverflowBox( @@ -879,7 +879,7 @@ void main() { }); testWidgets('Slider respects textScaleFactor', (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; Widget buildSlider({ @@ -887,22 +887,22 @@ void main() { bool isDiscrete = true, ShowValueIndicator show = ShowValueIndicator.onlyForDiscrete, }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData(textScaleFactor: textScaleFactor), - child: new Material( - child: new Theme( + return MediaQuery( + data: MediaQueryData(textScaleFactor: textScaleFactor), + child: Material( + child: Theme( data: Theme.of(context).copyWith( sliderTheme: Theme.of(context).sliderTheme.copyWith(showValueIndicator: show), ), - child: new Center( - child: new OverflowBox( + child: Center( + child: OverflowBox( maxWidth: double.infinity, maxHeight: double.infinity, - child: new Slider( + child: Slider( key: sliderKey, min: 0.0, max: 100.0, @@ -976,12 +976,12 @@ void main() { }); testWidgets('Slider has correct animations when reparented', (WidgetTester tester) async { - final Key sliderKey = new GlobalKey(debugLabel: 'A'); + final Key sliderKey = GlobalKey(debugLabel: 'A'); double value = 0.0; Widget buildSlider(int parents) { Widget createParents(int parents, StateSetter setState) { - Widget slider = new Slider( + Widget slider = Slider( key: sliderKey, value: value, divisions: 4, @@ -993,18 +993,18 @@ void main() { ); for (int i = 0; i < parents; ++i) { - slider = new Column(children: [slider]); + slider = Column(children: [slider]); } return slider; } - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( child: createParents(parents, setState), ), ); @@ -1103,14 +1103,14 @@ void main() { }); testWidgets('Slider Semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Slider( value: 0.5, onChanged: (double v) {}, ), @@ -1121,8 +1121,8 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root(children: [ - new TestSemantics.rootChild( + TestSemantics.root(children: [ + TestSemantics.rootChild( id: 1, value: '50%', increasedValue: '55%', @@ -1136,10 +1136,10 @@ void main() { )); // Disable slider - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), + child: MediaQuery( + data: MediaQueryData.fromWindow(window), child: const Material( child: Slider( value: 0.5, @@ -1152,7 +1152,7 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root(), + TestSemantics.root(), ignoreRect: true, ignoreTransform: true, )); @@ -1161,19 +1161,19 @@ void main() { }); testWidgets('Slider Semantics - iOS', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Theme( + Theme( data: ThemeData.light().copyWith( platform: TargetPlatform.iOS, ), - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Slider( value: 100.0, min: 0.0, max: 200.0, @@ -1188,8 +1188,8 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root(children: [ - new TestSemantics.rootChild( + TestSemantics.root(children: [ + TestSemantics.rootChild( id: 2, value: '50%', increasedValue: '60%', @@ -1205,14 +1205,14 @@ void main() { }); testWidgets('Slider semantics with custom formatter', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Slider( value: 40.0, min: 0.0, max: 200.0, @@ -1227,8 +1227,8 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root(children: [ - new TestSemantics.rootChild( + TestSemantics.root(children: [ + TestSemantics.rootChild( id: 3, value: '40', increasedValue: '60', @@ -1244,7 +1244,7 @@ void main() { }); testWidgets('Value indicator appears when it should', (WidgetTester tester) async { - final ThemeData baseTheme = new ThemeData( + final ThemeData baseTheme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.blue, ); @@ -1252,17 +1252,17 @@ void main() { double value = 0.45; Widget buildApp({SliderThemeData sliderTheme, int divisions, bool enabled = true}) { final ValueChanged onChanged = enabled ? (double d) => value = d : null; - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Theme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Theme( data: baseTheme, - child: new SliderTheme( + child: SliderTheme( data: sliderTheme, - child: new Slider( + child: Slider( value: value, label: '$value', divisions: divisions, @@ -1328,18 +1328,18 @@ void main() { }); testWidgets("Slider doesn't start any animations after dispose", (WidgetTester tester) async { - final Key sliderKey = new UniqueKey(); + final Key sliderKey = UniqueKey(); double value = 0.0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + return MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( key: sliderKey, value: value, divisions: 4, @@ -1363,7 +1363,7 @@ void main() { await gesture.moveBy(const Offset(-500.0, 0.0)); await tester.pumpAndSettle(const Duration(milliseconds: 100)); // Change the tree to dispose the original widget. - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(await tester.pumpAndSettle(const Duration(milliseconds: 100)), equals(1)); await gesture.up(); }); diff --git a/packages/flutter/test/material/slider_theme_test.dart b/packages/flutter/test/material/slider_theme_test.dart index c61dcd0045..c054f08d73 100644 --- a/packages/flutter/test/material/slider_theme_test.dart +++ b/packages/flutter/test/material/slider_theme_test.dart @@ -13,7 +13,7 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Slider theme is built by ThemeData', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, ); @@ -24,20 +24,20 @@ void main() { }); testWidgets('Slider uses ThemeData slider theme if present', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, ); final SliderThemeData sliderTheme = theme.sliderTheme; Widget buildSlider(SliderThemeData data) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Theme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Theme( data: theme, child: const Slider( value: 0.5, @@ -59,7 +59,7 @@ void main() { }); testWidgets('Slider overrides ThemeData theme if SliderTheme present', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.red, ); @@ -70,15 +70,15 @@ void main() { ); Widget buildSlider(SliderThemeData data) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Theme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Theme( data: theme, - child: new SliderTheme( + child: SliderTheme( data: customTheme, child: const Slider( value: 0.5, @@ -106,11 +106,11 @@ void main() { const Color customColor3 = Color(0xdecaface); const Color customColor4 = Color(0xfeedcafe); - final SliderThemeData sliderTheme = new SliderThemeData.fromPrimaryColors( + final SliderThemeData sliderTheme = SliderThemeData.fromPrimaryColors( primaryColor: customColor1, primaryColorDark: customColor2, primaryColorLight: customColor3, - valueIndicatorTextStyle: new ThemeData.fallback().accentTextTheme.body2.copyWith(color: customColor4), + valueIndicatorTextStyle: ThemeData.fallback().accentTextTheme.body2.copyWith(color: customColor4), ); expect(sliderTheme.activeTrackColor, equals(customColor1.withAlpha(0xff))); @@ -132,17 +132,17 @@ void main() { }); testWidgets('SliderThemeData lerps correctly', (WidgetTester tester) async { - final SliderThemeData sliderThemeBlack = new SliderThemeData.fromPrimaryColors( + final SliderThemeData sliderThemeBlack = SliderThemeData.fromPrimaryColors( primaryColor: Colors.black, primaryColorDark: Colors.black, primaryColorLight: Colors.black, - valueIndicatorTextStyle: new ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.black), + valueIndicatorTextStyle: ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.black), ); - final SliderThemeData sliderThemeWhite = new SliderThemeData.fromPrimaryColors( + final SliderThemeData sliderThemeWhite = SliderThemeData.fromPrimaryColors( primaryColor: Colors.white, primaryColorDark: Colors.white, primaryColorLight: Colors.white, - valueIndicatorTextStyle: new ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.white), + valueIndicatorTextStyle: ThemeData.fallback().accentTextTheme.body2.copyWith(color: Colors.white), ); final SliderThemeData lerp = SliderThemeData.lerp(sliderThemeBlack, sliderThemeWhite, 0.5); const Color middleGrey = Color(0xff7f7f7f); @@ -162,7 +162,7 @@ void main() { }); testWidgets('Default slider thumb shape draws correctly', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.blue, ); @@ -173,15 +173,15 @@ void main() { bool enabled = true, }) { final ValueChanged onChanged = enabled ? (double d) => value = d : null; - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new SliderTheme( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: SliderTheme( data: sliderTheme, - child: new Slider( + child: Slider( value: value, label: '$value', divisions: divisions, @@ -227,23 +227,23 @@ void main() { }); testWidgets('Default slider value indicator shape draws correctly', (WidgetTester tester) async { - final ThemeData theme = new ThemeData( + final ThemeData theme = ThemeData( platform: TargetPlatform.android, primarySwatch: Colors.blue, ); final SliderThemeData sliderTheme = theme.sliderTheme.copyWith(thumbColor: Colors.red.shade500, showValueIndicator: ShowValueIndicator.always); Widget buildApp(String value, {double sliderValue = 0.5, double textScale = 1.0}) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window).copyWith(textScaleFactor: textScale), - child: new Material( - child: new Row( + child: MediaQuery( + data: MediaQueryData.fromWindow(window).copyWith(textScaleFactor: textScale), + child: Material( + child: Row( children: [ - new Expanded( - child: new SliderTheme( + Expanded( + child: SliderTheme( data: sliderTheme, - child: new Slider( + child: Slider( value: sliderValue, label: '$value', divisions: 3, diff --git a/packages/flutter/test/material/snack_bar_test.dart b/packages/flutter/test/material/snack_bar_test.dart index 0a5a9842dc..992c1326f0 100644 --- a/packages/flutter/test/material/snack_bar_test.dart +++ b/packages/flutter/test/material/snack_bar_test.dart @@ -9,11 +9,11 @@ void main() { testWidgets('SnackBar control test', (WidgetTester tester) async { const String helloSnackBar = 'Hello SnackBar'; const Key tapTarget = Key('tap-target'); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Builder( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { Scaffold.of(context).showSnackBar(const SnackBar( content: Text(helloSnackBar), @@ -21,7 +21,7 @@ void main() { )); }, behavior: HitTestBehavior.opaque, - child: new Container( + child: Container( height: 100.0, width: 100.0, key: tapTarget @@ -54,20 +54,20 @@ void main() { testWidgets('SnackBar twice test', (WidgetTester tester) async { int snackBarCount = 0; const Key tapTarget = Key('tap-target'); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Builder( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { snackBarCount += 1; - Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text('bar$snackBarCount'), + Scaffold.of(context).showSnackBar(SnackBar( + content: Text('bar$snackBarCount'), duration: const Duration(seconds: 2) )); }, behavior: HitTestBehavior.opaque, - child: new Container( + child: Container( height: 100.0, width: 100.0, key: tapTarget @@ -131,20 +131,20 @@ void main() { const Key tapTarget = Key('tap-target'); int time; ScaffoldFeatureController lastController; - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Builder( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { snackBarCount += 1; - lastController = Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text('bar$snackBarCount'), - duration: new Duration(seconds: time) + lastController = Scaffold.of(context).showSnackBar(SnackBar( + content: Text('bar$snackBarCount'), + duration: Duration(seconds: time) )); }, behavior: HitTestBehavior.opaque, - child: new Container( + child: Container( height: 100.0, width: 100.0, key: tapTarget @@ -215,20 +215,20 @@ void main() { testWidgets('SnackBar dismiss test', (WidgetTester tester) async { int snackBarCount = 0; const Key tapTarget = Key('tap-target'); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Builder( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { snackBarCount += 1; - Scaffold.of(context).showSnackBar(new SnackBar( - content: new Text('bar$snackBarCount'), + Scaffold.of(context).showSnackBar(SnackBar( + content: Text('bar$snackBarCount'), duration: const Duration(seconds: 2) )); }, behavior: HitTestBehavior.opaque, - child: new Container( + child: Container( height: 100.0, width: 100.0, key: tapTarget @@ -259,16 +259,16 @@ void main() { testWidgets('SnackBar cannot be tapped twice', (WidgetTester tester) async { int tapCount = 0; - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Builder( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('I am a snack bar.'), duration: const Duration(seconds: 2), - action: new SnackBarAction( + action: SnackBarAction( label: 'ACTION', onPressed: () { ++tapCount; @@ -297,8 +297,8 @@ void main() { }); testWidgets('SnackBar button text alignment', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.only( left: 10.0, @@ -307,15 +307,15 @@ void main() { bottom: 40.0, ), ), - child: new Scaffold( - body: new Builder( + child: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('I am a snack bar.'), duration: const Duration(seconds: 2), - action: new SnackBarAction(label: 'ACTION', onPressed: () {}) + action: SnackBarAction(label: 'ACTION', onPressed: () {}) )); }, child: const Text('X') @@ -348,8 +348,8 @@ void main() { }); testWidgets('SnackBar is positioned above BottomNavigationBar', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.only( left: 10.0, @@ -358,21 +358,21 @@ void main() { bottom: 40.0, ), ), - child: new Scaffold( - bottomNavigationBar: new BottomNavigationBar( + child: Scaffold( + bottomNavigationBar: BottomNavigationBar( items: const [ BottomNavigationBarItem(icon: Icon(Icons.favorite), title: Text('Animutation')), BottomNavigationBarItem(icon: Icon(Icons.block), title: Text('Zombo.com')), ], ), - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('I am a snack bar.'), duration: const Duration(seconds: 2), - action: new SnackBarAction(label: 'ACTION', onPressed: () {}) + action: SnackBarAction(label: 'ACTION', onPressed: () {}) )); }, child: const Text('X') @@ -405,21 +405,21 @@ void main() { }); testWidgets('SnackBarClosedReason', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); bool actionPressed = false; SnackBarClosedReason closedReason; - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( + await tester.pumpWidget(MaterialApp( + home: Scaffold( key: scaffoldKey, - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('snack'), duration: const Duration(seconds: 2), - action: new SnackBarAction( + action: SnackBarAction( label: 'ACTION', onPressed: () { actionPressed = true; @@ -483,21 +483,21 @@ void main() { }); testWidgets('accessible navigation behavior with action', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData(accessibleNavigation: true), child: Scaffold( key: scaffoldKey, - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('snack'), duration: const Duration(seconds: 1), - action: new SnackBarAction( + action: SnackBarAction( label: 'ACTION', onPressed: () {} ), @@ -525,21 +525,21 @@ void main() { testWidgets('contributes dismiss semantics', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( + await tester.pumpWidget(MaterialApp( + home: MediaQuery( data: const MediaQueryData(accessibleNavigation: true), child: Scaffold( key: scaffoldKey, - body: new Builder( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('snack'), duration: const Duration(seconds: 1), - action: new SnackBarAction( + action: SnackBarAction( label: 'ACTION', onPressed: () {} ), @@ -569,18 +569,18 @@ void main() { testWidgets('SnackBar default display duration test', (WidgetTester tester) async { const String helloSnackBar = 'Hello SnackBar'; const Key tapTarget = Key('tap-target'); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Builder( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { Scaffold.of(context).showSnackBar(const SnackBar( content: Text(helloSnackBar) )); }, behavior: HitTestBehavior.opaque, - child: new Container( + child: Container( height: 100.0, width: 100.0, key: tapTarget @@ -616,17 +616,17 @@ void main() { testWidgets('SnackBar handles updates to accessibleNavigation', (WidgetTester tester) async { Future boilerplate({bool accessibleNavigation}) { - return tester.pumpWidget(new MaterialApp( - home: new MediaQuery( - data: new MediaQueryData(accessibleNavigation: accessibleNavigation), - child: new Scaffold( - body: new Builder( + return tester.pumpWidget(MaterialApp( + home: MediaQuery( + data: MediaQueryData(accessibleNavigation: accessibleNavigation), + child: Scaffold( + body: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { - Scaffold.of(context).showSnackBar(new SnackBar( + Scaffold.of(context).showSnackBar(SnackBar( content: const Text('test'), - action: new SnackBarAction(label: 'foo', onPressed: () {}), + action: SnackBarAction(label: 'foo', onPressed: () {}), )); }, behavior: HitTestBehavior.opaque, diff --git a/packages/flutter/test/material/stepper_test.dart b/packages/flutter/test/material/stepper_test.dart index ec5f5134b5..6b1e912902 100644 --- a/packages/flutter/test/material/stepper_test.dart +++ b/packages/flutter/test/material/stepper_test.dart @@ -10,9 +10,9 @@ void main() { int index = 0; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( onStepTapped: (int i) { index = i; }, @@ -42,10 +42,10 @@ void main() { testWidgets('Stepper expansion test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Material( - child: new Stepper( + MaterialApp( + home: Center( + child: Material( + child: Stepper( steps: const [ Step( title: Text('Step 1'), @@ -72,10 +72,10 @@ void main() { expect(box.size.height, 332.0); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Material( - child: new Stepper( + MaterialApp( + home: Center( + child: Material( + child: Stepper( currentStep: 1, steps: const [ Step( @@ -109,10 +109,10 @@ void main() { testWidgets('Stepper horizontal size test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Material( - child: new Stepper( + MaterialApp( + home: Center( + child: Material( + child: Stepper( type: StepperType.horizontal, steps: const [ Step( @@ -135,9 +135,9 @@ void main() { testWidgets('Stepper visibility test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( type: StepperType.horizontal, steps: const [ Step( @@ -158,9 +158,9 @@ void main() { expect(find.text('B'), findsNothing); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( currentStep: 1, type: StepperType.horizontal, steps: const [ @@ -187,9 +187,9 @@ void main() { bool cancelPressed = false; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( type: StepperType.horizontal, onStepContinue: () { continuePressed = true; @@ -229,9 +229,9 @@ void main() { int index = 0; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( onStepTapped: (int i) { index = i; }, @@ -263,9 +263,9 @@ void main() { testWidgets('Stepper scroll test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( steps: const [ Step( title: Text('Step 1'), @@ -299,9 +299,9 @@ void main() { await tester.tap(find.text('Step 3')); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Stepper( + MaterialApp( + home: Material( + child: Stepper( currentStep: 2, steps: const [ Step( @@ -337,10 +337,10 @@ void main() { testWidgets('Stepper index test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Material( - child: new Stepper( + MaterialApp( + home: Center( + child: Material( + child: Stepper( steps: const [ Step( title: Text('A'), @@ -370,10 +370,10 @@ void main() { testWidgets('Stepper error test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Material( - child: new Stepper( + MaterialApp( + home: Center( + child: Material( + child: Stepper( steps: const [ Step( title: Text('A'), @@ -396,9 +396,9 @@ void main() { ///https://github.com/flutter/flutter/issues/16920 testWidgets('Stepper icons size test', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: Material( - child: new Stepper( + child: Stepper( steps: const [ Step( title: Text('A'), diff --git a/packages/flutter/test/material/switch_test.dart b/packages/flutter/test/material/switch_test.dart index 8ed7fba081..cf89d2aa44 100644 --- a/packages/flutter/test/material/switch_test.dart +++ b/packages/flutter/test/material/switch_test.dart @@ -12,17 +12,17 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Switch can toggle on tap', (WidgetTester tester) async { - final Key switchKey = new UniqueKey(); + final Key switchKey = UniqueKey(); bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( key: switchKey, value: value, onChanged: (bool newValue) { @@ -45,13 +45,13 @@ void main() { testWidgets('Switch size is configurable by ThemeData.materialTapTargetSize', (WidgetTester tester) async { await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.padded), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Switch( + child: Material( + child: Center( + child: Switch( value: true, onChanged: (bool newValue) {}, ), @@ -64,13 +64,13 @@ void main() { expect(tester.getSize(find.byType(Switch)), const Size(59.0, 48.0)); await tester.pumpWidget( - new Theme( - data: new ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), - child: new Directionality( + Theme( + data: ThemeData(materialTapTargetSize: MaterialTapTargetSize.shrinkWrap), + child: Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new Center( - child: new Switch( + child: Material( + child: Center( + child: Switch( value: true, onChanged: (bool newValue) {}, ), @@ -87,13 +87,13 @@ void main() { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( value: value, onChanged: (bool newValue) { setState(() { @@ -133,13 +133,13 @@ void main() { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( value: value, onChanged: (bool newValue) { setState(() { @@ -176,13 +176,13 @@ void main() { testWidgets('Switch has default colors when enabled', (WidgetTester tester) async { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( value: value, onChanged: (bool newValue) { setState(() { @@ -202,7 +202,7 @@ void main() { paints ..rrect( color: const Color(0x52000000), // Black with 32% opacity - rrect: new RRect.fromLTRBR( + rrect: RRect.fromLTRBR( 383.5, 293.0, 416.5, 307.0, const Radius.circular(7.0))) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) @@ -218,7 +218,7 @@ void main() { paints ..rrect( color: Colors.blue[600].withAlpha(0x80), - rrect: new RRect.fromLTRBR( + rrect: RRect.fromLTRBR( 383.5, 293.0, 416.5, 307.0, const Radius.circular(7.0))) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) @@ -230,9 +230,9 @@ void main() { testWidgets('Switch has default colors when disabled', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return const Material( child: Center( @@ -252,7 +252,7 @@ void main() { paints ..rrect( color: Colors.black12, - rrect: new RRect.fromLTRBR( + rrect: RRect.fromLTRBR( 383.5, 293.0, 416.5, 307.0, const Radius.circular(7.0))) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) @@ -262,9 +262,9 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { return const Material( child: Center( @@ -284,7 +284,7 @@ void main() { paints ..rrect( color: Colors.black12, - rrect: new RRect.fromLTRBR( + rrect: RRect.fromLTRBR( 383.5, 293.0, 416.5, 307.0, const Radius.circular(7.0))) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) @@ -297,13 +297,13 @@ void main() { testWidgets('Switch can be set color', (WidgetTester tester) async { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( value: value, onChanged: (bool newValue) { setState(() { @@ -327,7 +327,7 @@ void main() { paints ..rrect( color: Colors.blue[500], - rrect: new RRect.fromLTRBR( + rrect: RRect.fromLTRBR( 383.5, 293.0, 416.5, 307.0, const Radius.circular(7.0))) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) @@ -342,7 +342,7 @@ void main() { paints ..rrect( color: Colors.green[500], - rrect: new RRect.fromLTRBR( + rrect: RRect.fromLTRBR( 383.5, 293.0, 416.5, 307.0, const Radius.circular(7.0))) ..circle(color: const Color(0x33000000)) ..circle(color: const Color(0x24000000)) @@ -356,13 +356,13 @@ void main() { bool value = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( value: value, onChanged: (bool newValue) { setState(() { @@ -382,7 +382,7 @@ void main() { final Rect switchRect = tester.getRect(find.byType(Switch)); final TestGesture gesture = await tester.startGesture(switchRect.centerLeft); await tester.pump(); - await gesture.moveBy(new Offset(switchRect.width, 0.0)); + await gesture.moveBy(Offset(switchRect.width, 0.0)); await tester.pump(); await gesture.up(); await tester.pump(); @@ -398,16 +398,16 @@ void main() { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { semanticEvent = message; }); - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new Material( - child: new Center( - child: new Switch( + return Material( + child: Center( + child: Switch( value: value, onChanged: (bool newValue) { setState(() { @@ -442,25 +442,25 @@ void main() { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { semanticEvent = message; }); - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new StatefulBuilder( + MaterialApp( + home: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { void onChanged(bool newValue) { setState(() { value = newValue; }); } - return new Material( - child: new MergeSemantics( - child: new ListTile( + return Material( + child: MergeSemantics( + child: ListTile( leading: const Text('test'), onTap: () { onChanged(!value); }, - trailing: new Switch( + trailing: Switch( value: value, onChanged: onChanged, ), diff --git a/packages/flutter/test/material/tabbed_scrollview_warp_test.dart b/packages/flutter/test/material/tabbed_scrollview_warp_test.dart index 49824231cf..8d3f1ec891 100644 --- a/packages/flutter/test/material/tabbed_scrollview_warp_test.dart +++ b/packages/flutter/test/material/tabbed_scrollview_warp_test.dart @@ -25,7 +25,7 @@ class MySliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate { class MyHomePage extends StatefulWidget { @override - _MyHomePageState createState() => new _MyHomePageState(); + _MyHomePageState createState() => _MyHomePageState(); } class _MyHomePageState extends State with TickerProviderStateMixin { @@ -35,7 +35,7 @@ class _MyHomePageState extends State with TickerProviderStateMixin { @override void initState() { super.initState(); - tabController = new TabController(initialIndex: 0, length: tabCount, vsync: this); + tabController = TabController(initialIndex: 0, length: tabCount, vsync: this); } @override @@ -46,22 +46,22 @@ class _MyHomePageState extends State with TickerProviderStateMixin { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar( - bottom: new TabBar( + return Scaffold( + appBar: AppBar( + bottom: TabBar( controller: tabController, - tabs: new List.generate(tabCount, (int index) => new Tab(text: 'Tab $index')).toList(), + tabs: List.generate(tabCount, (int index) => Tab(text: 'Tab $index')).toList(), ), ), - body: new TabBarView( + body: TabBarView( controller: tabController, - children: new List.generate(tabCount, (int index) { - return new CustomScrollView( + children: List.generate(tabCount, (int index) { + return CustomScrollView( // The bug only occurs when this key is included - key: new ValueKey('Page $index'), + key: ValueKey('Page $index'), slivers: [ - new SliverPersistentHeader( - delegate: new MySliverPersistentHeaderDelegate(), + SliverPersistentHeader( + delegate: MySliverPersistentHeaderDelegate(), ), ], ); @@ -73,7 +73,7 @@ class _MyHomePageState extends State with TickerProviderStateMixin { void main() { testWidgets('Tabbed CustomScrollViews, warp from tab 1 to 3', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: new MyHomePage())); + await tester.pumpWidget(MaterialApp(home: MyHomePage())); // should not crash. await tester.tap(find.text('Tab 2')); diff --git a/packages/flutter/test/material/tabs_test.dart b/packages/flutter/test/material/tabs_test.dart index 827a6de212..0bfecfdd75 100644 --- a/packages/flutter/test/material/tabs_test.dart +++ b/packages/flutter/test/material/tabs_test.dart @@ -13,15 +13,15 @@ import '../rendering/recording_canvas.dart'; import '../widgets/semantics_tester.dart'; Widget boilerplate({ Widget child, TextDirection textDirection = TextDirection.ltr }) { - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child: new Directionality( + child: Directionality( textDirection: textDirection, - child: new Material( + child: Material( child: child, ), ), @@ -34,7 +34,7 @@ class StateMarker extends StatefulWidget { final Widget child; @override - StateMarkerState createState() => new StateMarkerState(); + StateMarkerState createState() => StateMarkerState(); } class StateMarkerState extends State { @@ -44,14 +44,14 @@ class StateMarkerState extends State { Widget build(BuildContext context) { if (widget.child != null) return widget.child; - return new Container(); + return Container(); } } class AlwaysKeepAliveWidget extends StatefulWidget { static String text = 'AlwaysKeepAlive'; @override - AlwaysKeepAliveState createState() => new AlwaysKeepAliveState(); + AlwaysKeepAliveState createState() => AlwaysKeepAliveState(); } class AlwaysKeepAliveState extends State @@ -61,7 +61,7 @@ class AlwaysKeepAliveState extends State @override Widget build(BuildContext context) { - return new Text(AlwaysKeepAliveWidget.text); + return Text(AlwaysKeepAliveWidget.text); } } @@ -73,12 +73,12 @@ Widget buildFrame({ Color indicatorColor, }) { return boilerplate( - child: new DefaultTabController( + child: DefaultTabController( initialIndex: tabs.indexOf(value), length: tabs.length, - child: new TabBar( + child: TabBar( key: tabBarKey, - tabs: tabs.map((String tab) => new Tab(text: tab)).toList(), + tabs: tabs.map((String tab) => Tab(text: tab)).toList(), isScrollable: isScrollable, indicatorColor: indicatorColor, ), @@ -96,7 +96,7 @@ class TabControllerFrame extends StatefulWidget { final TabControllerFrameBuilder builder; @override - TabControllerFrameState createState() => new TabControllerFrameState(); + TabControllerFrameState createState() => TabControllerFrameState(); } class TabControllerFrameState extends State with SingleTickerProviderStateMixin { @@ -105,7 +105,7 @@ class TabControllerFrameState extends State with SingleTicke @override void initState() { super.initState(); - _controller = new TabController( + _controller = TabController( vsync: this, length: widget.length, initialIndex: widget.initialIndex, @@ -125,16 +125,16 @@ class TabControllerFrameState extends State with SingleTicke } Widget buildLeftRightApp({ List tabs, String value }) { - return new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new DefaultTabController( + return MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: DefaultTabController( initialIndex: tabs.indexOf(value), length: tabs.length, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('tabs'), - bottom: new TabBar( - tabs: tabs.map((String tab) => new Tab(text: tab)).toList(), + bottom: TabBar( + tabs: tabs.map((String tab) => Tab(text: tab)).toList(), ), ), body: const TabBarView( @@ -159,7 +159,7 @@ class TabIndicatorRecordingCanvas extends TestRecordingCanvas { // Assuming that the indicatorWeight is 2.0, the default. const double indicatorWeight = 2.0; if (paint.color == indicatorColor) - indicatorRect = new Rect.fromPoints(p1, p2).inflate(indicatorWeight / 2.0); + indicatorRect = Rect.fromPoints(p1, p2).inflate(indicatorWeight / 2.0); } } @@ -168,10 +168,10 @@ class TestScrollPhysics extends ScrollPhysics { @override TestScrollPhysics applyTo(ScrollPhysics ancestor) { - return new TestScrollPhysics(parent: buildParent(ancestor)); + return TestScrollPhysics(parent: buildParent(ancestor)); } - static final SpringDescription _kDefaultSpring = new SpringDescription.withDampingRatio( + static final SpringDescription _kDefaultSpring = SpringDescription.withDampingRatio( mass: 0.5, stiffness: 500.0, ratio: 1.1, @@ -291,13 +291,13 @@ void main() { Widget builder() { return boilerplate( - child: new DefaultTabController( + child: DefaultTabController( initialIndex: tabs.indexOf(value), length: tabs.length, - child: new TabBarView( + child: TabBarView( children: tabs.map((String name) { - return new StateMarker( - child: new Text(name) + return StateMarker( + child: Text(name) ); }).toList() ), @@ -470,24 +470,24 @@ void main() { int index = 0; await tester.pumpWidget( - new MaterialApp( - home: new Align( + MaterialApp( + home: Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 300.0, height: 200.0, - child: new DefaultTabController( + child: DefaultTabController( length: tabs.length, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('tabs'), - bottom: new TabBar( + bottom: TabBar( isScrollable: true, - tabs: tabs.map((String tab) => new Tab(text: tab)).toList(), + tabs: tabs.map((String tab) => Tab(text: tab)).toList(), ), ), - body: new TabBarView( - children: tabs.map((String name) => new Text('${index++}')).toList(), + body: TabBarView( + children: tabs.map((String name) => Text('${index++}')).toList(), ), ), ), @@ -543,17 +543,17 @@ void main() { Widget buildTabControllerFrame(BuildContext context, TabController controller) { tabController = controller; - return new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( title: const Text('tabs'), - bottom: new TabBar( + bottom: TabBar( controller: controller, - tabs: tabs.map((String tab) => new Tab(text: tab)).toList(), + tabs: tabs.map((String tab) => Tab(text: tab)).toList(), ), ), - body: new TabBarView( + body: TabBarView( controller: controller, children: const [ Center(child: Text('LEFT CHILD')), @@ -564,7 +564,7 @@ void main() { ); } - await tester.pumpWidget(new TabControllerFrame( + await tester.pumpWidget(TabControllerFrame( builder: buildTabControllerFrame, length: tabs.length, initialIndex: 1, @@ -602,17 +602,17 @@ void main() { Widget buildTabControllerFrame(BuildContext context, TabController controller) { tabController = controller; - return new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.android), - home: new Scaffold( - appBar: new AppBar( + return MaterialApp( + theme: ThemeData(platform: TargetPlatform.android), + home: Scaffold( + appBar: AppBar( title: const Text('tabs'), - bottom: new TabBar( + bottom: TabBar( controller: controller, - tabs: tabs.map((String tab) => new Tab(text: tab)).toList(), + tabs: tabs.map((String tab) => Tab(text: tab)).toList(), ), ), - body: new TabBarView( + body: TabBarView( controller: controller, children: const [ Center(child: Text('CHILD A')), @@ -624,7 +624,7 @@ void main() { ); } - await tester.pumpWidget(new TabControllerFrame( + await tester.pumpWidget(TabControllerFrame( builder: buildTabControllerFrame, length: tabs.length, )); @@ -661,7 +661,7 @@ void main() { }); testWidgets('TabBar unselectedLabelColor control test', (WidgetTester tester) async { - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: 2, ); @@ -671,18 +671,18 @@ void main() { await tester.pumpWidget( boilerplate( - child: new TabBar( + child: TabBar( controller: controller, labelColor: Colors.green[500], unselectedLabelColor: Colors.blue[500], tabs: [ - new Builder( + Builder( builder: (BuildContext context) { firstColor = IconTheme.of(context).color; return const Text('First'); } ), - new Builder( + Builder( builder: (BuildContext context) { secondColor = IconTheme.of(context).color; return const Text('Second'); @@ -698,14 +698,14 @@ void main() { }); testWidgets('TabBarView page left and right test', (WidgetTester tester) async { - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: 2, ); await tester.pumpWidget( boilerplate( - child: new TabBarView( + child: TabBarView( controller: controller, children: const [ Text('First'), Text('Second') ], ), @@ -766,8 +766,8 @@ void main() { await tester.pumpWidget(buildFrame(tabs: tabs, value: 'A', indicatorColor: indicatorColor)); final RenderBox box = tester.renderObject(find.byType(TabBar)); - final TabIndicatorRecordingCanvas canvas = new TabIndicatorRecordingCanvas(indicatorColor); - final TestRecordingPaintingContext context = new TestRecordingPaintingContext(canvas); + final TabIndicatorRecordingCanvas canvas = TabIndicatorRecordingCanvas(indicatorColor); + final TestRecordingPaintingContext context = TestRecordingPaintingContext(canvas); box.paint(context, Offset.zero); final Rect indicatorRect0 = canvas.indicatorRect; @@ -796,15 +796,15 @@ void main() { // This is a regression test for this patch: // https://github.com/flutter/flutter/pull/9015 - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: 2, ); Widget buildFrame() { return boilerplate( - child: new TabBar( - key: new UniqueKey(), + child: TabBar( + key: UniqueKey(), controller: controller, tabs: const [ Text('A'), Text('B') ], ), @@ -824,20 +824,20 @@ void main() { testWidgets('TabBarView scrolls end close to a new page', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/9375 - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), initialIndex: 1, length: 3, ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new SizedBox.expand( - child: new Center( - child: new SizedBox( + child: SizedBox.expand( + child: Center( + child: SizedBox( width: 400.0, height: 400.0, - child: new TabBarView( + child: TabBarView( controller: tabController, children: const [ Center(child: Text('0')), @@ -879,20 +879,20 @@ void main() { }); testWidgets('TabBarView scrolls end close to a new page with custom physics', (WidgetTester tester) async { - final TabController tabController = new TabController( + final TabController tabController = TabController( vsync: const TestVSync(), initialIndex: 1, length: 3, ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new SizedBox.expand( - child: new Center( - child: new SizedBox( + child: SizedBox.expand( + child: Center( + child: SizedBox( width: 400.0, height: 400.0, - child: new TabBarView( + child: TabBarView( controller: tabController, physics: const TestScrollPhysics(), children: const [ @@ -937,11 +937,11 @@ void main() { testWidgets('Scrollable TabBar with a non-zero TabController initialIndex', (WidgetTester tester) async { // This is a regression test for https://github.com/flutter/flutter/issues/9374 - final List tabs = new List.generate(20, (int index) { - return new Tab(text: 'TAB #$index'); + final List tabs = List.generate(20, (int index) { + return Tab(text: 'TAB #$index'); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, initialIndex: tabs.length - 1, @@ -949,7 +949,7 @@ void main() { await tester.pumpWidget( boilerplate( - child: new TabBar( + child: TabBar( isScrollable: true, controller: controller, tabs: tabs, @@ -973,20 +973,20 @@ void main() { const double padLeft = 8.0; const double padRight = 4.0; - final List tabs = new List.generate(4, (int index) { - return new Tab(text: 'Tab $index'); + final List tabs = List.generate(4, (int index) { + return Tab(text: 'Tab $index'); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); await tester.pumpWidget( boilerplate( - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( indicatorWeight: indicatorWeight, indicatorColor: indicatorColor, indicatorPadding: const EdgeInsets.only(left: padLeft, right: padRight), @@ -1007,8 +1007,8 @@ void main() { expect(tabBarBox, paints..line( color: indicatorColor, strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); // Select tab 3 @@ -1021,8 +1021,8 @@ void main() { expect(tabBarBox, paints..line( color: indicatorColor, strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); @@ -1032,11 +1032,11 @@ void main() { const double padLeft = 8.0; const double padRight = 4.0; - final List tabs = new List.generate(4, (int index) { - return new Tab(text: 'Tab $index'); + final List tabs = List.generate(4, (int index) { + return Tab(text: 'Tab $index'); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); @@ -1044,9 +1044,9 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.rtl, - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( indicatorWeight: indicatorWeight, indicatorColor: indicatorColor, indicatorPadding: const EdgeInsets.only(left: padLeft, right: padRight), @@ -1068,8 +1068,8 @@ void main() { expect(tabBarBox, paints..line( color: indicatorColor, strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); // Select tab 3 @@ -1082,17 +1082,17 @@ void main() { expect(tabBarBox, paints..line( color: indicatorColor, strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); testWidgets('TabBar changes indicator attributes', (WidgetTester tester) async { - final List tabs = new List.generate(4, (int index) { - return new Tab(text: 'Tab $index'); + final List tabs = List.generate(4, (int index) { + return Tab(text: 'Tab $index'); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); @@ -1104,12 +1104,12 @@ void main() { Widget buildFrame() { return boilerplate( - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( indicatorWeight: indicatorWeight, indicatorColor: indicatorColor, - indicatorPadding: new EdgeInsets.only(left: padLeft, right: padRight), + indicatorPadding: EdgeInsets.only(left: padLeft, right: padRight), controller: controller, tabs: tabs, ), @@ -1129,8 +1129,8 @@ void main() { expect(tabBarBox, paints..line( color: indicatorColor, strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); indicatorColor = const Color(0xFF0000FF); @@ -1149,30 +1149,30 @@ void main() { expect(tabBarBox, paints..line( color: indicatorColor, strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); testWidgets('TabBar with directional indicatorPadding (LTR)', (WidgetTester tester) async { final List tabs = [ - new SizedBox(key: new UniqueKey(), width: 130.0, height: 30.0), - new SizedBox(key: new UniqueKey(), width: 140.0, height: 40.0), - new SizedBox(key: new UniqueKey(), width: 150.0, height: 50.0), + SizedBox(key: UniqueKey(), width: 130.0, height: 30.0), + SizedBox(key: UniqueKey(), width: 140.0, height: 40.0), + SizedBox(key: UniqueKey(), width: 150.0, height: 50.0), ]; const double indicatorWeight = 2.0; // the default - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); await tester.pumpWidget( boilerplate( - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( indicatorPadding: const EdgeInsetsDirectional.only(start: 100.0), isScrollable: true, controller: controller, @@ -1191,7 +1191,7 @@ void main() { double tabRight = tabLeft + 130.0; double tabTop = (tabBarHeight - indicatorWeight - 30.0) / 2.0; double tabBottom = tabTop + 30.0; - Rect tabRect = new Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); + Rect tabRect = Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); expect(tester.getRect(find.byKey(tabs[0].key)), tabRect); @@ -1200,7 +1200,7 @@ void main() { tabRight = tabLeft + 140.0; tabTop = (tabBarHeight - indicatorWeight - 40.0) / 2.0; tabBottom = tabTop + 40.0; - tabRect = new Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); + tabRect = Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); expect(tester.getRect(find.byKey(tabs[1].key)), tabRect); @@ -1209,7 +1209,7 @@ void main() { tabRight = tabLeft + 150.0; tabTop = (tabBarHeight - indicatorWeight - 50.0) / 2.0; tabBottom = tabTop + 50.0; - tabRect = new Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); + tabRect = Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); expect(tester.getRect(find.byKey(tabs[2].key)), tabRect); // Tab 0 selected, indicator padding resolves to left: 100.0 @@ -1218,21 +1218,21 @@ void main() { final double indicatorY = tabBottom + indicatorWeight / 2.0; expect(tabBarBox, paints..line( strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); testWidgets('TabBar with directional indicatorPadding (RTL)', (WidgetTester tester) async { final List tabs = [ - new SizedBox(key: new UniqueKey(), width: 130.0, height: 30.0), - new SizedBox(key: new UniqueKey(), width: 140.0, height: 40.0), - new SizedBox(key: new UniqueKey(), width: 150.0, height: 50.0), + SizedBox(key: UniqueKey(), width: 130.0, height: 30.0), + SizedBox(key: UniqueKey(), width: 140.0, height: 40.0), + SizedBox(key: UniqueKey(), width: 150.0, height: 50.0), ]; const double indicatorWeight = 2.0; // the default - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); @@ -1240,9 +1240,9 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.rtl, - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( indicatorPadding: const EdgeInsetsDirectional.only(start: 100.0), isScrollable: true, controller: controller, @@ -1261,7 +1261,7 @@ void main() { double tabRight = tabLeft + 150.0; double tabTop = (tabBarHeight - indicatorWeight - 50.0) / 2.0; double tabBottom = tabTop + 50.0; - Rect tabRect = new Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); + Rect tabRect = Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); expect(tester.getRect(find.byKey(tabs[2].key)), tabRect); // Tab1 width = 140, height = 40 @@ -1269,7 +1269,7 @@ void main() { tabRight = tabLeft + 140.0; tabTop = (tabBarHeight - indicatorWeight - 40.0) / 2.0; tabBottom = tabTop + 40.0; - tabRect = new Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); + tabRect = Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); expect(tester.getRect(find.byKey(tabs[1].key)), tabRect); // Tab0 width = 130, height = 30 @@ -1277,7 +1277,7 @@ void main() { tabRight = tabLeft + 130.0; tabTop = (tabBarHeight - indicatorWeight - 30.0) / 2.0; tabBottom = tabTop + 30.0; - tabRect = new Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); + tabRect = Rect.fromLTRB(tabLeft, tabTop, tabRight, tabBottom); expect(tester.getRect(find.byKey(tabs[0].key)), tabRect); // Tab 0 selected, indicator padding resolves to right: 100.0 @@ -1286,19 +1286,19 @@ void main() { const double indicatorY = 50.0 + indicatorWeight / 2.0; expect(tabBarBox, paints..line( strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); testWidgets('Overflowing RTL tab bar', (WidgetTester tester) async { - final List tabs = new List.filled(100, + final List tabs = List.filled(100, // For convenience padded width of each tab will equal 100: // 68 + kTabLabelPadding.horizontal(32) - new SizedBox(key: new UniqueKey(), width: 68.0, height: 40.0), + SizedBox(key: UniqueKey(), width: 68.0, height: 40.0), ); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); @@ -1308,9 +1308,9 @@ void main() { await tester.pumpWidget( boilerplate( textDirection: TextDirection.rtl, - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( isScrollable: true, controller: controller, tabs: tabs, @@ -1329,8 +1329,8 @@ void main() { const double indicatorY = 40.0 + indicatorWeight / 2.0; expect(tabBarBox, paints..line( strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); controller.animateTo(tabs.length - 1, duration: const Duration(seconds: 1), curve: Curves.linear); @@ -1351,19 +1351,19 @@ void main() { indicatorRight = 100.0 - indicatorWeight / 2.0; expect(tabBarBox, paints..line( strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); testWidgets('correct semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List tabs = new List.generate(2, (int index) { - return new Tab(text: 'TAB #$index'); + final List tabs = List.generate(2, (int index) { + return Tab(text: 'TAB #$index'); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, initialIndex: 0, @@ -1371,9 +1371,9 @@ void main() { await tester.pumpWidget( boilerplate( - child: new Semantics( + child: Semantics( container: true, - child: new TabBar( + child: TabBar( isScrollable: true, controller: controller, tabs: tabs, @@ -1382,34 +1382,34 @@ void main() { ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 2, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 3, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 4, actions: SemanticsAction.tap.index, flags: SemanticsFlag.isSelected.index, label: 'TAB #0\nTab 1 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(0.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), + transform: Matrix4.translationValues(0.0, 276.0, 0.0), ), - new TestSemantics( + TestSemantics( id: 5, actions: SemanticsAction.tap.index, label: 'TAB #1\nTab 2 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(116.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), + transform: Matrix4.translationValues(116.0, 276.0, 0.0), ), ] ) @@ -1426,13 +1426,13 @@ void main() { }); testWidgets('correct scrolling semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List tabs = new List.generate(20, (int index) { - return new Tab(text: 'This is a very wide tab #$index'); + final List tabs = List.generate(20, (int index) { + return Tab(text: 'This is a very wide tab #$index'); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, initialIndex: 0, @@ -1440,9 +1440,9 @@ void main() { await tester.pumpWidget( boilerplate( - child: new Semantics( + child: Semantics( container: true, - child: new TabBar( + child: TabBar( isScrollable: true, controller: controller, tabs: tabs, @@ -1481,21 +1481,21 @@ void main() { }); testWidgets('TabBar etc with zero tabs', (WidgetTester tester) async { - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: 0, ); await tester.pumpWidget( boilerplate( - child: new Column( + child: Column( children: [ - new TabBar( + TabBar( controller: controller, tabs: const [], ), - new Flexible( - child: new TabBarView( + Flexible( + child: TabBarView( controller: controller, children: const [], ), @@ -1521,21 +1521,21 @@ void main() { }); testWidgets('TabBar etc with one tab', (WidgetTester tester) async { - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: 1, ); await tester.pumpWidget( boilerplate( - child: new Column( + child: Column( children: [ - new TabBar( + TabBar( controller: controller, tabs: const [Tab(text: 'TAB')], ), - new Flexible( - child: new TabBarView( + Flexible( + child: TabBarView( controller: controller, children: const [Text('PAGE')], ), @@ -1576,7 +1576,7 @@ void main() { }); testWidgets('can tap on indicator at very bottom of TabBar to switch tabs', (WidgetTester tester) async { - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: 2, initialIndex: 0, @@ -1584,15 +1584,15 @@ void main() { await tester.pumpWidget( boilerplate( - child: new Column( + child: Column( children: [ - new TabBar( + TabBar( controller: controller, indicatorWeight: 30.0, tabs: const [Tab(text: 'TAB1'), Tab(text: 'TAB2')], ), - new Flexible( - child: new TabBarView( + Flexible( + child: TabBarView( controller: controller, children: const [Text('PAGE1'), Text('PAGE2')], ), @@ -1613,20 +1613,20 @@ void main() { }); testWidgets('can override semantics of tabs', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List tabs = new List.generate(2, (int index) { - return new Tab( - child: new Semantics( + final List tabs = List.generate(2, (int index) { + return Tab( + child: Semantics( label: 'Semantics override $index', - child: new ExcludeSemantics( - child: new Text('TAB #$index'), + child: ExcludeSemantics( + child: Text('TAB #$index'), ), ), ); }); - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, initialIndex: 0, @@ -1634,9 +1634,9 @@ void main() { await tester.pumpWidget( boilerplate( - child: new Semantics( + child: Semantics( container: true, - child: new TabBar( + child: TabBar( isScrollable: true, controller: controller, tabs: tabs, @@ -1645,34 +1645,34 @@ void main() { ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 2, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 3, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 4, actions: SemanticsAction.tap.index, flags: SemanticsFlag.isSelected.index, label: 'Semantics override 0\nTab 1 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(0.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), + transform: Matrix4.translationValues(0.0, 276.0, 0.0), ), - new TestSemantics( + TestSemantics( id: 5, actions: SemanticsAction.tap.index, label: 'Semantics override 1\nTab 2 of 2', - rect: new Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), - transform: new Matrix4.translationValues(116.0, 276.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 116.0, kTextTabBarHeight), + transform: Matrix4.translationValues(116.0, 276.0, 0.0), ), ] ) @@ -1689,9 +1689,9 @@ void main() { }); test('illegal constructor combinations', () { - expect(() => new Tab(icon: nonconst(null)), throwsAssertionError); - expect(() => new Tab(icon: new Container(), text: 'foo', child: new Container()), throwsAssertionError); - expect(() => new Tab(text: 'foo', child: new Container()), throwsAssertionError); + expect(() => Tab(icon: nonconst(null)), throwsAssertionError); + expect(() => Tab(icon: Container(), text: 'foo', child: Container()), throwsAssertionError); + expect(() => Tab(text: 'foo', child: Container()), throwsAssertionError); }); @@ -1700,9 +1700,9 @@ void main() { Widget buildFrame(TabController controller) { return boilerplate( - child: new Container( + child: Container( alignment: Alignment.topLeft, - child: new TabBar( + child: TabBar( controller: controller, tabs: const [ Tab(text: 'LEFT'), @@ -1713,13 +1713,13 @@ void main() { ); } - final TabController controller1 = new TabController( + final TabController controller1 = TabController( vsync: const TestVSync(), length: 2, initialIndex: 0, ); - final TabController controller2 = new TabController( + final TabController controller2 = TabController( vsync: const TestVSync(), length: 2, initialIndex: 0, @@ -1739,8 +1739,8 @@ void main() { double indicatorRight = 400.0 - indicatorWeight / 2.0; // 400 = screen_width / 2 expect(tabBarBox, paints..line( strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); await tester.tap(find.text('RIGHT')); @@ -1755,8 +1755,8 @@ void main() { indicatorRight = 800.0 - indicatorWeight / 2.0; expect(tabBarBox, paints..line( strokeWidth: indicatorWeight, - p1: new Offset(indicatorLeft, indicatorY), - p2: new Offset(indicatorRight, indicatorY), + p1: Offset(indicatorLeft, indicatorY), + p2: Offset(indicatorRight, indicatorY), )); }); @@ -1780,29 +1780,29 @@ void main() { 'Tab4', 'Tab5', ]; - final TabController controller = new TabController( + final TabController controller = TabController( vsync: const TestVSync(), length: tabs.length, ); await tester.pumpWidget( - new MaterialApp( - home: new Align( + MaterialApp( + home: Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 300.0, height: 200.0, - child: new Scaffold( - appBar: new AppBar( + child: Scaffold( + appBar: AppBar( title: const Text('tabs'), - bottom: new TabBar( + bottom: TabBar( controller: controller, - tabs: tabs.map((String tab) => new Tab(text: tab)).toList(), + tabs: tabs.map((String tab) => Tab(text: tab)).toList(), ), ), - body: new TabBarView( + body: TabBarView( controller: controller, children: [ - new AlwaysKeepAliveWidget(), + AlwaysKeepAliveWidget(), const Text('2'), const Text('3'), const Text('4'), diff --git a/packages/flutter/test/material/text_field_focus_test.dart b/packages/flutter/test/material/text_field_focus_test.dart index 8ae4fe6f0d..4bb79d6c4c 100644 --- a/packages/flutter/test/material/text_field_focus_test.dart +++ b/packages/flutter/test/material/text_field_focus_test.dart @@ -7,13 +7,13 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Request focus shows keyboard', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextField( + MaterialApp( + home: Material( + child: Center( + child: TextField( focusNode: focusNode, ), ), @@ -28,7 +28,7 @@ void main() { expect(tester.testTextInput.isVisible, isTrue); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(tester.testTextInput.isVisible, isFalse); }); @@ -37,7 +37,7 @@ void main() { expect(tester.testTextInput.isVisible, isFalse); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: TextField( @@ -50,7 +50,7 @@ void main() { expect(tester.testTextInput.isVisible, isTrue); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(tester.testTextInput.isVisible, isFalse); }); @@ -59,7 +59,7 @@ void main() { expect(tester.testTextInput.isVisible, isFalse); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: TextField(), @@ -84,7 +84,7 @@ void main() { expect(tester.testTextInput.isVisible, isTrue); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(tester.testTextInput.isVisible, isFalse); }); @@ -93,7 +93,7 @@ void main() { expect(tester.testTextInput.isVisible, isFalse); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: TextField( @@ -127,23 +127,23 @@ void main() { expect(tester.testTextInput.isVisible, isTrue); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(tester.testTextInput.isVisible, isFalse); }); testWidgets('Focus triggers keep-alive', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new ListView( + MaterialApp( + home: Material( + child: ListView( children: [ - new TextField( + TextField( focusNode: focusNode, ), - new Container( + Container( height: 1000.0, ), ], @@ -173,20 +173,20 @@ void main() { }); testWidgets('Focus keep-alive works with GlobalKey reparenting', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); Widget makeTest(String prefix) { - return new MaterialApp( - home: new Material( - child: new ListView( + return MaterialApp( + home: Material( + child: ListView( children: [ - new TextField( + TextField( focusNode: focusNode, - decoration: new InputDecoration( + decoration: InputDecoration( prefixText: prefix, ), ), - new Container( + Container( height: 1000.0, ), ], @@ -211,7 +211,7 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/16880 await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: Center( child: TextField( diff --git a/packages/flutter/test/material/text_field_helper_text_test.dart b/packages/flutter/test/material/text_field_helper_text_test.dart index 7886b04b2e..ff4d5cd33f 100644 --- a/packages/flutter/test/material/text_field_helper_text_test.dart +++ b/packages/flutter/test/material/text_field_helper_text_test.dart @@ -7,11 +7,11 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('TextField works correctly when changing helperText', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(home: const Material(child: TextField(decoration: InputDecoration(helperText: 'Awesome'))))); + await tester.pumpWidget(MaterialApp(home: const Material(child: TextField(decoration: InputDecoration(helperText: 'Awesome'))))); expect(find.text('Awesome'), findsNWidgets(1)); await tester.pump(const Duration(milliseconds: 100)); expect(find.text('Awesome'), findsNWidgets(1)); - await tester.pumpWidget(new MaterialApp(home: const Material(child: TextField(decoration: InputDecoration(errorText: 'Awesome'))))); + await tester.pumpWidget(MaterialApp(home: const Material(child: TextField(decoration: InputDecoration(errorText: 'Awesome'))))); expect(find.text('Awesome'), findsNWidgets(2)); }); } diff --git a/packages/flutter/test/material/text_field_splash_test.dart b/packages/flutter/test/material/text_field_splash_test.dart index 2cc920ca72..811a2b8227 100644 --- a/packages/flutter/test/material/text_field_splash_test.dart +++ b/packages/flutter/test/material/text_field_splash_test.dart @@ -67,7 +67,7 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory { VoidCallback onRemoved, TextDirection textDirection, }) { - return new TestInkSplash( + return TestInkSplash( controller: controller, referenceBox: referenceBox, position: position, @@ -85,25 +85,25 @@ class TestInkSplashFactory extends InteractiveInkFeatureFactory { void main() { testWidgets('Tap and no focus causes a splash', (WidgetTester tester) async { - final Key textField1 = new UniqueKey(); - final Key textField2 = new UniqueKey(); + final Key textField1 = UniqueKey(); + final Key textField2 = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - home: new Theme( - data: new ThemeData.light().copyWith(splashFactory: const TestInkSplashFactory()), - child: new Material( - child: new Container( + MaterialApp( + home: Theme( + data: ThemeData.light().copyWith(splashFactory: const TestInkSplashFactory()), + child: Material( + child: Container( alignment: Alignment.topLeft, - child: new Column( + child: Column( children: [ - new TextField( + TextField( key: textField1, decoration: const InputDecoration( labelText: 'label', ), ), - new TextField( + TextField( key: textField2, decoration: const InputDecoration( labelText: 'label', @@ -153,11 +153,11 @@ void main() { testWidgets('Splash cancel', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Theme( - data: new ThemeData.light().copyWith(splashFactory: const TestInkSplashFactory()), - child: new Material( - child: new ListView( + MaterialApp( + home: Theme( + data: ThemeData.light().copyWith(splashFactory: const TestInkSplashFactory()), + child: Material( + child: ListView( children: [ const TextField( decoration: InputDecoration( @@ -169,7 +169,7 @@ void main() { labelText: 'label2', ), ), - new Container( + Container( height: 1000.0, color: const Color(0xFF00FF00), ), diff --git a/packages/flutter/test/material/text_field_test.dart b/packages/flutter/test/material/text_field_test.dart index 8d33181ab6..34f2394ae8 100644 --- a/packages/flutter/test/material/text_field_test.dart +++ b/packages/flutter/test/material/text_field_test.dart @@ -52,21 +52,21 @@ class WidgetsLocalizationsDelegate extends LocalizationsDelegate>[ - new WidgetsLocalizationsDelegate(), - new MaterialLocalizationsDelegate(), + WidgetsLocalizationsDelegate(), + MaterialLocalizationsDelegate(), ], - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(size: Size(800.0, 600.0)), - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( - builder: (BuildContext context) => new Center( - child: new Material( + OverlayEntry( + builder: (BuildContext context) => Center( + child: Material( child: child, ), ), @@ -79,18 +79,18 @@ Widget overlay({ Widget child }) { } Widget boilerplate({ Widget child }) { - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: >[ - new WidgetsLocalizationsDelegate(), - new MaterialLocalizationsDelegate(), + WidgetsLocalizationsDelegate(), + MaterialLocalizationsDelegate(), ], - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(size: Size(800.0, 600.0)), - child: new Center( - child: new Material( + child: Center( + child: Material( child: child, ), ), @@ -114,7 +114,7 @@ double getOpacity(WidgetTester tester, Finder finder) { } void main() { - final MockClipboard mockClipboard = new MockClipboard(); + final MockClipboard mockClipboard = MockClipboard(); SystemChannels.platform.setMockMethodCallHandler(mockClipboard.handleMethodCall); const String kThreeLines = @@ -145,7 +145,7 @@ void main() { List globalize(Iterable points, RenderBox box) { return points.map((TextSelectionPoint point) { - return new TextSelectionPoint( + return TextSelectionPoint( box.localToGlobal(point.point), point.direction, ); @@ -156,7 +156,7 @@ void main() { final RenderEditable renderEditable = findRenderEditable(tester); final List endpoints = globalize( renderEditable.getEndpointsForSelection( - new TextSelection.collapsed(offset: offset), + TextSelection.collapsed(offset: offset), ), renderEditable, ); @@ -172,9 +172,9 @@ void main() { final VoidCallback onEditingComplete = () {}; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new TextField( + MaterialApp( + home: Material( + child: TextField( onEditingComplete: onEditingComplete, ), ), @@ -189,12 +189,12 @@ void main() { }); testWidgets('TextField has consistent size', (WidgetTester tester) async { - final Key textFieldKey = new UniqueKey(); + final Key textFieldKey = UniqueKey(); String textFieldValue; await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: textFieldKey, decoration: const InputDecoration( hintText: 'Placeholder', @@ -377,11 +377,11 @@ void main() { }); testWidgets('Caret position is updated on tap', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, ), ) @@ -404,11 +404,11 @@ void main() { }); testWidgets('Can long press to select', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, ), ) @@ -434,11 +434,11 @@ void main() { }); testWidgets('Can drag handles to change selection', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, ), ), @@ -495,11 +495,11 @@ void main() { }); testWidgets('Can use selection toolbar', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, ), ), @@ -553,11 +553,11 @@ void main() { }); testWidgets('Selection toolbar fades in', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, ), ), @@ -596,11 +596,11 @@ void main() { }); testWidgets('Multiline text will wrap up to maxLines', (WidgetTester tester) async { - final Key textFieldKey = new UniqueKey(); + final Key textFieldKey = UniqueKey(); Widget builder(int maxLines) { return boilerplate( - child: new TextField( + child: TextField( key: textFieldKey, style: const TextStyle(color: Colors.black, fontSize: 34.0), maxLines: maxLines, @@ -660,11 +660,11 @@ void main() { }); testWidgets('Can drag handles to change selection in multiline', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, style: const TextStyle(color: Colors.black, fontSize: 34.0), maxLines: 3, @@ -737,12 +737,12 @@ void main() { }); testWidgets('Can scroll multiline input', (WidgetTester tester) async { - final Key textFieldKey = new UniqueKey(); - final TextEditingController controller = new TextEditingController(); + final Key textFieldKey = UniqueKey(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: textFieldKey, controller: controller, style: const TextStyle(color: Colors.black, fontSize: 34.0), @@ -765,8 +765,8 @@ void main() { final Offset fourthPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('Fourth')); expect(firstPos.dx, fourthPos.dx); expect(firstPos.dy, lessThan(fourthPos.dy)); - expect(inputBox.hitTest(new HitTestResult(), position: inputBox.globalToLocal(firstPos)), isTrue); - expect(inputBox.hitTest(new HitTestResult(), position: inputBox.globalToLocal(fourthPos)), isFalse); + expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(firstPos)), isTrue); + expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(fourthPos)), isFalse); TestGesture gesture = await tester.startGesture(firstPos, pointer: 7); await tester.pump(); @@ -784,8 +784,8 @@ void main() { Offset newFourthPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('Fourth')); expect(newFirstPos.dy, lessThan(firstPos.dy)); - expect(inputBox.hitTest(new HitTestResult(), position: inputBox.globalToLocal(newFirstPos)), isFalse); - expect(inputBox.hitTest(new HitTestResult(), position: inputBox.globalToLocal(newFourthPos)), isTrue); + expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(newFirstPos)), isFalse); + expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(newFourthPos)), isTrue); // Now try scrolling by dragging the selection handle. @@ -819,8 +819,8 @@ void main() { newFirstPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('First')); newFourthPos = textOffsetToPosition(tester, kMoreThanFourLines.indexOf('Fourth')); expect(newFirstPos.dy, firstPos.dy); - expect(inputBox.hitTest(new HitTestResult(), position: inputBox.globalToLocal(newFirstPos)), isTrue); - expect(inputBox.hitTest(new HitTestResult(), position: inputBox.globalToLocal(newFourthPos)), isFalse); + expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(newFirstPos)), isTrue); + expect(inputBox.hitTest(HitTestResult(), position: inputBox.globalToLocal(newFourthPos)), isFalse); }, // This test fails on some Mac environments when libtxt is enabled. skip: Platform.isMacOS); @@ -830,7 +830,7 @@ void main() { await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( decoration: null, onChanged: (String value) { textFieldValue = value; @@ -854,12 +854,12 @@ void main() { }); testWidgets('TextField with global key', (WidgetTester tester) async { - final GlobalKey textFieldKey = new GlobalKey(debugLabel: 'textFieldKey'); + final GlobalKey textFieldKey = GlobalKey(debugLabel: 'textFieldKey'); String textFieldValue; await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: textFieldKey, decoration: const InputDecoration( hintText: 'Placeholder', @@ -899,10 +899,10 @@ void main() { }); testWidgets('TextField with default helperStyle', (WidgetTester tester) async { - final ThemeData themeData = new ThemeData(hintColor: Colors.blue[500]); + final ThemeData themeData = ThemeData(hintColor: Colors.blue[500]); await tester.pumpWidget( overlay( - child: new Theme( + child: Theme( data: themeData, child: const TextField( decoration: InputDecoration( @@ -918,7 +918,7 @@ void main() { }); testWidgets('TextField with specified helperStyle', (WidgetTester tester) async { - final TextStyle style = new TextStyle( + final TextStyle style = TextStyle( inherit: false, color: Colors.pink[500], fontSize: 10.0, @@ -926,8 +926,8 @@ void main() { await tester.pumpWidget( overlay( - child: new TextField( - decoration: new InputDecoration( + child: TextField( + decoration: InputDecoration( helperText: 'helper text', helperStyle: style, ), @@ -939,19 +939,19 @@ void main() { }); testWidgets('TextField with default hintStyle', (WidgetTester tester) async { - final TextStyle style = new TextStyle( + final TextStyle style = TextStyle( color: Colors.pink[500], fontSize: 10.0, ); - final ThemeData themeData = new ThemeData( + final ThemeData themeData = ThemeData( hintColor: Colors.blue[500], ); await tester.pumpWidget( overlay( - child: new Theme( + child: Theme( data: themeData, - child: new TextField( + child: TextField( decoration: const InputDecoration( hintText: 'Placeholder', ), @@ -967,7 +967,7 @@ void main() { }); testWidgets('TextField with specified hintStyle', (WidgetTester tester) async { - final TextStyle hintStyle = new TextStyle( + final TextStyle hintStyle = TextStyle( inherit: false, color: Colors.pink[500], fontSize: 10.0, @@ -975,8 +975,8 @@ void main() { await tester.pumpWidget( overlay( - child: new TextField( - decoration: new InputDecoration( + child: TextField( + decoration: InputDecoration( hintText: 'Placeholder', hintStyle: hintStyle, ), @@ -989,7 +989,7 @@ void main() { }); testWidgets('TextField with specified prefixStyle', (WidgetTester tester) async { - final TextStyle prefixStyle = new TextStyle( + final TextStyle prefixStyle = TextStyle( inherit: false, color: Colors.pink[500], fontSize: 10.0, @@ -997,8 +997,8 @@ void main() { await tester.pumpWidget( overlay( - child: new TextField( - decoration: new InputDecoration( + child: TextField( + decoration: InputDecoration( prefixText: 'Prefix:', prefixStyle: prefixStyle, ), @@ -1011,15 +1011,15 @@ void main() { }); testWidgets('TextField with specified suffixStyle', (WidgetTester tester) async { - final TextStyle suffixStyle = new TextStyle( + final TextStyle suffixStyle = TextStyle( color: Colors.pink[500], fontSize: 10.0, ); await tester.pumpWidget( overlay( - child: new TextField( - decoration: new InputDecoration( + child: TextField( + decoration: InputDecoration( suffixText: '.com', suffixStyle: suffixStyle, ), @@ -1033,18 +1033,18 @@ void main() { testWidgets('TextField prefix and suffix appear correctly with no hint or label', (WidgetTester tester) async { - final Key secondKey = new UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( overlay( - child: new Column( + child: Column( children: [ const TextField( decoration: InputDecoration( labelText: 'First', ), ), - new TextField( + TextField( key: secondKey, decoration: const InputDecoration( prefixText: 'Prefix', @@ -1077,25 +1077,25 @@ void main() { testWidgets('TextField prefix and suffix appear correctly with hint text', (WidgetTester tester) async { - final TextStyle hintStyle = new TextStyle( + final TextStyle hintStyle = TextStyle( inherit: false, color: Colors.pink[500], fontSize: 10.0, ); - final Key secondKey = new UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( overlay( - child: new Column( + child: Column( children: [ const TextField( decoration: InputDecoration( labelText: 'First', ), ), - new TextField( + TextField( key: secondKey, - decoration: new InputDecoration( + decoration: InputDecoration( hintText: 'Hint', hintStyle: hintStyle, prefixText: 'Prefix', @@ -1138,28 +1138,28 @@ void main() { testWidgets('TextField prefix and suffix appear correctly with label text', (WidgetTester tester) async { - final TextStyle prefixStyle = new TextStyle( + final TextStyle prefixStyle = TextStyle( color: Colors.pink[500], fontSize: 10.0, ); - final TextStyle suffixStyle = new TextStyle( + final TextStyle suffixStyle = TextStyle( color: Colors.green[500], fontSize: 12.0, ); - final Key secondKey = new UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( overlay( - child: new Column( + child: Column( children: [ const TextField( decoration: InputDecoration( labelText: 'First', ), ), - new TextField( + TextField( key: secondKey, - decoration: new InputDecoration( + decoration: InputDecoration( labelText: 'Label', prefixText: 'Prefix', prefixStyle: prefixStyle, @@ -1201,18 +1201,18 @@ void main() { }); testWidgets('TextField label text animates', (WidgetTester tester) async { - final Key secondKey = new UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( overlay( - child: new Column( + child: Column( children: [ const TextField( decoration: InputDecoration( labelText: 'First', ), ), - new TextField( + TextField( key: secondKey, decoration: const InputDecoration( labelText: 'Second', @@ -1279,7 +1279,7 @@ void main() { testWidgets('Can align to center', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: new Container( + child: Container( width: 300.0, child: const TextField( textAlign: TextAlign.center, @@ -1309,7 +1309,7 @@ void main() { testWidgets('Can align to center within center', (WidgetTester tester) async { await tester.pumpWidget( overlay( - child: new Container( + child: Container( width: 300.0, child: const Center( child: TextField( @@ -1339,10 +1339,10 @@ void main() { }); testWidgets('Controller can update server', (WidgetTester tester) async { - final TextEditingController controller1 = new TextEditingController( + final TextEditingController controller1 = TextEditingController( text: 'Initial Text', ); - final TextEditingController controller2 = new TextEditingController( + final TextEditingController controller2 = TextEditingController( text: 'More Text', ); @@ -1351,10 +1351,10 @@ void main() { await tester.pumpWidget( overlay( - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new TextField(controller: currentController); + return TextField(controller: currentController); } ), ), @@ -1422,10 +1422,10 @@ void main() { }); testWidgets('Cannot enter new lines onto single line TextField', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField(controller: textController, decoration: null), + child: TextField(controller: textController, decoration: null), )); await tester.enterText(find.byType(TextField), 'abc\ndef'); @@ -1434,15 +1434,15 @@ void main() { }); testWidgets('Injected formatters are chained', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( controller: textController, decoration: null, inputFormatters: [ - new BlacklistingTextInputFormatter( - new RegExp(r'[a-z]'), + BlacklistingTextInputFormatter( + RegExp(r'[a-z]'), replacementString: '#', ), ], @@ -1455,19 +1455,19 @@ void main() { }); testWidgets('Chained formatters are in sequence', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( controller: textController, decoration: null, maxLines: 2, inputFormatters: [ - new BlacklistingTextInputFormatter( - new RegExp(r'[a-z]'), + BlacklistingTextInputFormatter( + RegExp(r'[a-z]'), replacementString: '12\n', ), - new WhitelistingTextInputFormatter(new RegExp(r'\n[0-9]')), + WhitelistingTextInputFormatter(RegExp(r'\n[0-9]')), ], ), )); @@ -1482,11 +1482,11 @@ void main() { }); testWidgets('Pasted values are formatted', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: textController, decoration: null, inputFormatters: [ @@ -1520,13 +1520,13 @@ void main() { }); testWidgets('Text field scrolls the caret into view', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new Container( + child: Container( width: 100.0, - child: new TextField( + child: TextField( controller: controller, ), ), @@ -1542,7 +1542,7 @@ void main() { // Move the caret to the end of the text and check that the text field // scrolls to make the caret visible. - controller.selection = new TextSelection.collapsed(offset: longText.length); + controller.selection = TextSelection.collapsed(offset: longText.length); await tester.pump(); // TODO(ianh): Figure out why this extra pump is needed. await skipPastScrollingAnimation(tester); @@ -1551,14 +1551,14 @@ void main() { }); testWidgets('haptic feedback', (WidgetTester tester) async { - final FeedbackTester feedback = new FeedbackTester(); - final TextEditingController controller = new TextEditingController(); + final FeedbackTester feedback = FeedbackTester(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new Container( + child: Container( width: 100.0, - child: new TextField( + child: TextField( controller: controller, ), ), @@ -1579,19 +1579,19 @@ void main() { }); testWidgets('Text field drops selection when losing focus', (WidgetTester tester) async { - final Key key1 = new UniqueKey(); - final TextEditingController controller1 = new TextEditingController(); - final Key key2 = new UniqueKey(); + final Key key1 = UniqueKey(); + final TextEditingController controller1 = TextEditingController(); + final Key key2 = UniqueKey(); await tester.pumpWidget( overlay( - child: new Column( + child: Column( children: [ - new TextField( + TextField( key: key1, controller: controller1 ), - new TextField(key: key2), + TextField(key: key2), ], ), ), @@ -1610,7 +1610,7 @@ void main() { }); testWidgets('Selection is consistent with text length', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); controller.text = 'abcde'; controller.selection = const TextSelection.collapsed(offset: 5); @@ -1625,10 +1625,10 @@ void main() { }); testWidgets('maxLength limits input.', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( controller: textController, maxLength: 10, ), @@ -1639,10 +1639,10 @@ void main() { }); testWidgets('maxLength limits input length even if decoration is null.', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( controller: textController, decoration: null, maxLength: 10, @@ -1654,15 +1654,15 @@ void main() { }); testWidgets('maxLength still works with other formatters.', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( controller: textController, maxLength: 10, inputFormatters: [ - new BlacklistingTextInputFormatter( - new RegExp(r'[a-z]'), + BlacklistingTextInputFormatter( + RegExp(r'[a-z]'), replacementString: '#', ), ], @@ -1675,10 +1675,10 @@ void main() { }); testWidgets("maxLength isn't enforced when maxLengthEnforced is false.", (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( controller: textController, maxLength: 10, maxLengthEnforced: false, @@ -1690,11 +1690,11 @@ void main() { }); testWidgets('maxLength shows warning when maxLengthEnforced is false.', (WidgetTester tester) async { - final TextEditingController textController = new TextEditingController(); + final TextEditingController textController = TextEditingController(); const TextStyle testStyle = TextStyle(color: Colors.deepPurpleAccent); await tester.pumpWidget(boilerplate( - child: new TextField( + child: TextField( decoration: const InputDecoration(errorStyle: testStyle), controller: textController, maxLength: 10, @@ -1720,7 +1720,7 @@ void main() { }); testWidgets('setting maxLength shows counter', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: const Material( child: DefaultTextStyle( style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), @@ -1742,10 +1742,10 @@ void main() { }); testWidgets('TextField identifies as text field in semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Material( child: DefaultTextStyle( style: TextStyle(fontFamily: 'Ahem', fontSize: 10.0), @@ -1792,17 +1792,17 @@ void main() { TextEditingController controller; setUp( () { - controller = new TextEditingController(); + controller = TextEditingController(); }); MaterialApp setupWidget() { - final FocusNode focusNode = new FocusNode(); - controller = new TextEditingController(); + final FocusNode focusNode = FocusNode(); + controller = TextEditingController(); - return new MaterialApp( + return MaterialApp( home: Material( - child: new RawKeyboardListener( + child: RawKeyboardListener( focusNode: focusNode, onKey: null, child: TextField( @@ -1926,10 +1926,10 @@ void main() { const int _kDelKeyCode = 112; testWidgets('Copy paste test', (WidgetTester tester) async{ - final FocusNode focusNode = new FocusNode(); - final TextEditingController controller = new TextEditingController(); + final FocusNode focusNode = FocusNode(); + final TextEditingController controller = TextEditingController(); final TextField textField = - new TextField( + TextField( controller: controller, maxLines: 3, ); @@ -1945,9 +1945,9 @@ void main() { }); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new RawKeyboardListener( + MaterialApp( + home: Material( + child: RawKeyboardListener( focusNode: focusNode, onKey: null, child: textField, @@ -1997,10 +1997,10 @@ void main() { }); testWidgets('Cut test', (WidgetTester tester) async{ - final FocusNode focusNode = new FocusNode(); - final TextEditingController controller = new TextEditingController(); + final FocusNode focusNode = FocusNode(); + final TextEditingController controller = TextEditingController(); final TextField textField = - new TextField( + TextField( controller: controller, maxLines: 3, ); @@ -2015,9 +2015,9 @@ void main() { }); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new RawKeyboardListener( + MaterialApp( + home: Material( + child: RawKeyboardListener( focusNode: focusNode, onKey: null, child: textField, @@ -2069,18 +2069,18 @@ void main() { }); testWidgets('Select all test', (WidgetTester tester) async{ - final FocusNode focusNode = new FocusNode(); - final TextEditingController controller = new TextEditingController(); + final FocusNode focusNode = FocusNode(); + final TextEditingController controller = TextEditingController(); final TextField textField = - new TextField( + TextField( controller: controller, maxLines: 3, ); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new RawKeyboardListener( + MaterialApp( + home: Material( + child: RawKeyboardListener( focusNode: focusNode, onKey: null, child: textField, @@ -2115,18 +2115,18 @@ void main() { }); testWidgets('Delete test', (WidgetTester tester) async{ - final FocusNode focusNode = new FocusNode(); - final TextEditingController controller = new TextEditingController(); + final FocusNode focusNode = FocusNode(); + final TextEditingController controller = TextEditingController(); final TextField textField = - new TextField( + TextField( controller: controller, maxLines: 3, ); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new RawKeyboardListener( + MaterialApp( + home: Material( + child: RawKeyboardListener( focusNode: focusNode, onKey: null, child: textField, @@ -2170,22 +2170,22 @@ void main() { testWidgets('Changing positions of text fields', (WidgetTester tester) async{ - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); final List events = []; - final TextEditingController c1 = new TextEditingController(); - final TextEditingController c2 = new TextEditingController(); - final Key key1 = new UniqueKey(); - final Key key2 = new UniqueKey(); + final TextEditingController c1 = TextEditingController(); + final TextEditingController c2 = TextEditingController(); + final Key key1 = UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: Material( - child: new RawKeyboardListener( + child: RawKeyboardListener( focusNode: focusNode, onKey: events.add, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ TextField( @@ -2220,13 +2220,13 @@ void main() { expect(c1.selection.extentOffset - c1.selection.baseOffset, 5); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: Material( - child: new RawKeyboardListener( + child: RawKeyboardListener( focusNode: focusNode, onKey: events.add, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ TextField( @@ -2256,22 +2256,22 @@ void main() { testWidgets('Changing focus test', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); final List events = []; - final TextEditingController c1 = new TextEditingController(); - final TextEditingController c2 = new TextEditingController(); - final Key key1 = new UniqueKey(); - final Key key2 = new UniqueKey(); + final TextEditingController c1 = TextEditingController(); + final TextEditingController c2 = TextEditingController(); + final Key key1 = UniqueKey(); + final Key key2 = UniqueKey(); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: Material( - child: new RawKeyboardListener( + child: RawKeyboardListener( focusNode: focusNode, onKey: events.add, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ TextField( @@ -2324,11 +2324,11 @@ void main() { }); testWidgets('Caret works when maxLines is null', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(); + final TextEditingController controller = TextEditingController(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( controller: controller, maxLines: null, ), @@ -2350,19 +2350,19 @@ void main() { }); testWidgets('TextField baseline alignment', (WidgetTester tester) async { - final TextEditingController controllerA = new TextEditingController(text: 'A'); - final TextEditingController controllerB = new TextEditingController(text: 'B'); - final Key keyA = new UniqueKey(); - final Key keyB = new UniqueKey(); + final TextEditingController controllerA = TextEditingController(text: 'A'); + final TextEditingController controllerB = TextEditingController(text: 'B'); + final Key keyA = UniqueKey(); + final Key keyB = UniqueKey(); await tester.pumpWidget( overlay( - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.baseline, textBaseline: TextBaseline.alphabetic, children: [ - new Expanded( - child: new TextField( + Expanded( + child: TextField( key: keyA, decoration: null, controller: controllerA, @@ -2373,8 +2373,8 @@ void main() { 'abc', style: TextStyle(fontSize: 20.0), ), - new Expanded( - child: new TextField( + Expanded( + child: TextField( key: keyB, decoration: null, controller: controllerB, @@ -2401,22 +2401,22 @@ void main() { }); testWidgets('TextField semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final TextEditingController controller = new TextEditingController(); - final Key key = new UniqueKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final TextEditingController controller = TextEditingController(); + final Key key = UniqueKey(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: key, controller: controller, ), ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, textDirection: TextDirection.ltr, actions: [ @@ -2432,9 +2432,9 @@ void main() { controller.text = 'Guten Tag'; await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, textDirection: TextDirection.ltr, value: 'Guten Tag', @@ -2451,9 +2451,9 @@ void main() { await tester.tap(find.byKey(key)); await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, textDirection: TextDirection.ltr, value: 'Guten Tag', @@ -2476,9 +2476,9 @@ void main() { controller.selection = const TextSelection.collapsed(offset: 4); await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, textDirection: TextDirection.ltr, textSelection: const TextSelection.collapsed(offset: 4), @@ -2504,9 +2504,9 @@ void main() { controller.selection = const TextSelection.collapsed(offset: 0); await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, textDirection: TextDirection.ltr, textSelection: const TextSelection.collapsed(offset: 0), @@ -2530,23 +2530,23 @@ void main() { }); testWidgets('TextField semantics for selections', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final TextEditingController controller = new TextEditingController() + final SemanticsTester semantics = SemanticsTester(tester); + final TextEditingController controller = TextEditingController() ..text = 'Hello'; - final Key key = new UniqueKey(); + final Key key = UniqueKey(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: key, controller: controller, ), ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, value: 'Hello', textDirection: TextDirection.ltr, @@ -2564,9 +2564,9 @@ void main() { await tester.tap(find.byKey(key)); await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, value: 'Hello', textSelection: const TextSelection.collapsed(offset: 5), @@ -2589,9 +2589,9 @@ void main() { controller.selection = const TextSelection(baseOffset: 5, extentOffset: 3); await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, value: 'Hello', textSelection: const TextSelection(baseOffset: 5, extentOffset: 3), @@ -2619,15 +2619,15 @@ void main() { }); testWidgets('TextField change selection with semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner; - final TextEditingController controller = new TextEditingController() + final TextEditingController controller = TextEditingController() ..text = 'Hello'; - final Key key = new UniqueKey(); + final Key key = UniqueKey(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: key, controller: controller, ), @@ -2641,9 +2641,9 @@ void main() { const int inputFieldId = 1; expect(controller.selection, const TextSelection.collapsed(offset: 5, affinity: TextAffinity.upstream)); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: inputFieldId, value: 'Hello', textSelection: const TextSelection.collapsed(offset: 5), @@ -2686,9 +2686,9 @@ void main() { }); await tester.pump(); expect(controller.selection, const TextSelection(baseOffset: 0, extentOffset: 5)); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: inputFieldId, value: 'Hello', textSelection: const TextSelection(baseOffset: 0, extentOffset: 5), @@ -2718,15 +2718,15 @@ void main() { const String textInTextField = 'Hello'; - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final SemanticsOwner semanticsOwner = tester.binding.pipelineOwner.semanticsOwner; - final TextEditingController controller = new TextEditingController() + final TextEditingController controller = TextEditingController() ..text = textInTextField; - final Key key = new UniqueKey(); + final Key key = UniqueKey(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: key, controller: controller, ), @@ -2736,9 +2736,9 @@ void main() { const int inputFieldId = 1; expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: inputFieldId, flags: [SemanticsFlag.isTextField], actions: [SemanticsAction.tap], @@ -2754,9 +2754,9 @@ void main() { await tester.pump(); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: inputFieldId, flags: [ SemanticsFlag.isTextField, @@ -2794,11 +2794,11 @@ void main() { }); testWidgets('TextField loses focus when disabled', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); await tester.pumpWidget( boilerplate( - child: new TextField( + child: TextField( focusNode: focusNode, autofocus: true, enabled: true, @@ -2809,7 +2809,7 @@ void main() { await tester.pumpWidget( boilerplate( - child: new TextField( + child: TextField( focusNode: focusNode, autofocus: true, enabled: false, @@ -2820,13 +2820,13 @@ void main() { }); testWidgets('TextField semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final TextEditingController controller = new TextEditingController(); - final Key key = new UniqueKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final TextEditingController controller = TextEditingController(); + final Key key = UniqueKey(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: key, controller: controller, maxLength: 10, @@ -2839,9 +2839,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'label\nhelper', id: 1, textDirection: TextDirection.ltr, @@ -2852,7 +2852,7 @@ void main() { SemanticsFlag.isTextField, ], children: [ - new TestSemantics( + TestSemantics( id: 2, label: '10 characters remaining', textDirection: TextDirection.ltr, @@ -2865,9 +2865,9 @@ void main() { await tester.tap(find.byType(TextField)); await tester.pump(); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'hint\nhelper', id: 1, textDirection: TextDirection.ltr, @@ -2882,7 +2882,7 @@ void main() { SemanticsFlag.isFocused, ], children: [ - new TestSemantics( + TestSemantics( id: 2, label: '10 characters remaining', textDirection: TextDirection.ltr, @@ -2898,13 +2898,13 @@ void main() { }); testWidgets('InputDecoration counterText can have a semanticCounterText', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final TextEditingController controller = new TextEditingController(); - final Key key = new UniqueKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final TextEditingController controller = TextEditingController(); + final Key key = UniqueKey(); await tester.pumpWidget( overlay( - child: new TextField( + child: TextField( key: key, controller: controller, decoration: const InputDecoration( @@ -2918,9 +2918,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'label\nhelper', id: 1, textDirection: TextDirection.ltr, @@ -2931,7 +2931,7 @@ void main() { SemanticsFlag.isTextField, ], children: [ - new TestSemantics( + TestSemantics( label: '0 out of 10', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/material/text_form_field_test.dart b/packages/flutter/test/material/text_form_field_test.dart index c3c3b5cbed..b80e155806 100644 --- a/packages/flutter/test/material/text_form_field_test.dart +++ b/packages/flutter/test/material/text_form_field_test.dart @@ -11,10 +11,10 @@ void main() { const TextAlign alignment = TextAlign.center; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextFormField( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( textAlign: alignment, ), ), @@ -31,10 +31,10 @@ void main() { testWidgets('Passes textInputAction to underlying TextField', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextFormField( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( textInputAction: TextInputAction.next, ), ), @@ -53,10 +53,10 @@ void main() { final VoidCallback onEditingComplete = () {}; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextFormField( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( onEditingComplete: onEditingComplete, ), ), @@ -75,10 +75,10 @@ void main() { bool _called = false; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextFormField( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( onFieldSubmitted: (String value) { _called = true; }, ), ), @@ -96,10 +96,10 @@ void main() { int _validateCalled = 0; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextFormField( + MaterialApp( + home: Material( + child: Center( + child: TextFormField( autovalidate: true, validator: (String value) { _validateCalled++; return null; }, ), diff --git a/packages/flutter/test/material/theme_data_test.dart b/packages/flutter/test/material/theme_data_test.dart index dee28ce6cf..c56c6e1d61 100644 --- a/packages/flutter/test/material/theme_data_test.dart +++ b/packages/flutter/test/material/theme_data_test.dart @@ -7,13 +7,13 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('Theme data control test', () { - final ThemeData dark = new ThemeData.dark(); + final ThemeData dark = ThemeData.dark(); expect(dark, hasOneLineDescription); expect(dark, equals(dark.copyWith())); expect(dark.hashCode, equals(dark.copyWith().hashCode)); - final ThemeData light = new ThemeData.light(); + final ThemeData light = ThemeData.light(); final ThemeData dawn = ThemeData.lerp(dark, light, 0.25); expect(dawn.brightness, Brightness.dark); @@ -22,35 +22,35 @@ void main() { test('Defaults to the default typography for the platform', () { for (TargetPlatform platform in TargetPlatform.values) { - final ThemeData theme = new ThemeData(platform: platform); - final Typography typography = new Typography(platform: platform); + final ThemeData theme = ThemeData(platform: platform); + final Typography typography = Typography(platform: platform); expect(theme.textTheme, typography.black.apply(decoration: TextDecoration.none), reason: 'Not using default typography for $platform'); } }); test('Default text theme contrasts with brightness', () { - final ThemeData lightTheme = new ThemeData(brightness: Brightness.light); - final ThemeData darkTheme = new ThemeData(brightness: Brightness.dark); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(brightness: Brightness.light); + final ThemeData darkTheme = ThemeData(brightness: Brightness.dark); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.textTheme.title.color, typography.black.title.color); expect(darkTheme.textTheme.title.color, typography.white.title.color); }); test('Default primary text theme contrasts with primary brightness', () { - final ThemeData lightTheme = new ThemeData(primaryColorBrightness: Brightness.light); - final ThemeData darkTheme = new ThemeData(primaryColorBrightness: Brightness.dark); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(primaryColorBrightness: Brightness.light); + final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.primaryTextTheme.title.color, typography.black.title.color); expect(darkTheme.primaryTextTheme.title.color, typography.white.title.color); }); test('Default accent text theme contrasts with accent brightness', () { - final ThemeData lightTheme = new ThemeData(accentColorBrightness: Brightness.light); - final ThemeData darkTheme = new ThemeData(accentColorBrightness: Brightness.dark); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(accentColorBrightness: Brightness.light); + final ThemeData darkTheme = ThemeData(accentColorBrightness: Brightness.dark); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.accentTextTheme.title.color, typography.black.title.color); expect(darkTheme.accentTextTheme.title.color, typography.white.title.color); @@ -58,9 +58,9 @@ void main() { test('Default slider indicator style gets a default body2 if accentTextTheme.body2 is null', () { const TextTheme noBody2TextTheme = TextTheme(body2: null); - final ThemeData lightTheme = new ThemeData(brightness: Brightness.light, accentTextTheme: noBody2TextTheme); - final ThemeData darkTheme = new ThemeData(brightness: Brightness.dark, accentTextTheme: noBody2TextTheme); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(brightness: Brightness.light, accentTextTheme: noBody2TextTheme); + final ThemeData darkTheme = ThemeData(brightness: Brightness.dark, accentTextTheme: noBody2TextTheme); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.sliderTheme.valueIndicatorTextStyle, equals(typography.white.body2)); expect(darkTheme.sliderTheme.valueIndicatorTextStyle, equals(typography.black.body2)); @@ -68,49 +68,49 @@ void main() { test('Default chip label style gets a default body2 if textTheme.body2 is null', () { const TextTheme noBody2TextTheme = TextTheme(body2: null); - final ThemeData lightTheme = new ThemeData(brightness: Brightness.light, textTheme: noBody2TextTheme); - final ThemeData darkTheme = new ThemeData(brightness: Brightness.dark, textTheme: noBody2TextTheme); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(brightness: Brightness.light, textTheme: noBody2TextTheme); + final ThemeData darkTheme = ThemeData(brightness: Brightness.dark, textTheme: noBody2TextTheme); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.chipTheme.labelStyle.color, equals(typography.black.body2.color.withAlpha(0xde))); expect(darkTheme.chipTheme.labelStyle.color, equals(typography.white.body2.color.withAlpha(0xde))); }); test('Default icon theme contrasts with brightness', () { - final ThemeData lightTheme = new ThemeData(brightness: Brightness.light); - final ThemeData darkTheme = new ThemeData(brightness: Brightness.dark); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(brightness: Brightness.light); + final ThemeData darkTheme = ThemeData(brightness: Brightness.dark); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.textTheme.title.color, typography.black.title.color); expect(darkTheme.textTheme.title.color, typography.white.title.color); }); test('Default primary icon theme contrasts with primary brightness', () { - final ThemeData lightTheme = new ThemeData(primaryColorBrightness: Brightness.light); - final ThemeData darkTheme = new ThemeData(primaryColorBrightness: Brightness.dark); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(primaryColorBrightness: Brightness.light); + final ThemeData darkTheme = ThemeData(primaryColorBrightness: Brightness.dark); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.primaryTextTheme.title.color, typography.black.title.color); expect(darkTheme.primaryTextTheme.title.color, typography.white.title.color); }); test('Default accent icon theme contrasts with accent brightness', () { - final ThemeData lightTheme = new ThemeData(accentColorBrightness: Brightness.light); - final ThemeData darkTheme = new ThemeData(accentColorBrightness: Brightness.dark); - final Typography typography = new Typography(platform: lightTheme.platform); + final ThemeData lightTheme = ThemeData(accentColorBrightness: Brightness.light); + final ThemeData darkTheme = ThemeData(accentColorBrightness: Brightness.dark); + final Typography typography = Typography(platform: lightTheme.platform); expect(lightTheme.accentTextTheme.title.color, typography.black.title.color); expect(darkTheme.accentTextTheme.title.color, typography.white.title.color); }); test('Defaults to MaterialTapTargetBehavior.expanded', () { - final ThemeData themeData = new ThemeData(); + final ThemeData themeData = ThemeData(); expect(themeData.materialTapTargetSize, MaterialTapTargetSize.padded); }); test('Can control fontFamily', () { - final ThemeData themeData = new ThemeData(fontFamily: 'Ahem'); + final ThemeData themeData = ThemeData(fontFamily: 'Ahem'); expect(themeData.textTheme.body2.fontFamily, equals('Ahem')); expect(themeData.primaryTextTheme.title.fontFamily, equals('Ahem')); @@ -131,16 +131,16 @@ void main() { }); test('Can estimate brightness - indirectly', () { - expect(new ThemeData(primaryColor: Colors.white).primaryColorBrightness, equals(Brightness.light)); - expect(new ThemeData(primaryColor: Colors.black).primaryColorBrightness, equals(Brightness.dark)); - expect(new ThemeData(primaryColor: Colors.blue).primaryColorBrightness, equals(Brightness.dark)); - expect(new ThemeData(primaryColor: Colors.yellow).primaryColorBrightness, equals(Brightness.light)); - expect(new ThemeData(primaryColor: Colors.deepOrange).primaryColorBrightness, equals(Brightness.dark)); - expect(new ThemeData(primaryColor: Colors.orange).primaryColorBrightness, equals(Brightness.light)); - expect(new ThemeData(primaryColor: Colors.lime).primaryColorBrightness, equals(Brightness.light)); - expect(new ThemeData(primaryColor: Colors.grey).primaryColorBrightness, equals(Brightness.light)); - expect(new ThemeData(primaryColor: Colors.teal).primaryColorBrightness, equals(Brightness.dark)); - expect(new ThemeData(primaryColor: Colors.indigo).primaryColorBrightness, equals(Brightness.dark)); + expect(ThemeData(primaryColor: Colors.white).primaryColorBrightness, equals(Brightness.light)); + expect(ThemeData(primaryColor: Colors.black).primaryColorBrightness, equals(Brightness.dark)); + expect(ThemeData(primaryColor: Colors.blue).primaryColorBrightness, equals(Brightness.dark)); + expect(ThemeData(primaryColor: Colors.yellow).primaryColorBrightness, equals(Brightness.light)); + expect(ThemeData(primaryColor: Colors.deepOrange).primaryColorBrightness, equals(Brightness.dark)); + expect(ThemeData(primaryColor: Colors.orange).primaryColorBrightness, equals(Brightness.light)); + expect(ThemeData(primaryColor: Colors.lime).primaryColorBrightness, equals(Brightness.light)); + expect(ThemeData(primaryColor: Colors.grey).primaryColorBrightness, equals(Brightness.light)); + expect(ThemeData(primaryColor: Colors.teal).primaryColorBrightness, equals(Brightness.dark)); + expect(ThemeData(primaryColor: Colors.indigo).primaryColorBrightness, equals(Brightness.dark)); }); test('cursorColor', () { diff --git a/packages/flutter/test/material/theme_test.dart b/packages/flutter/test/material/theme_test.dart index 6dc7802495..0bcd342286 100644 --- a/packages/flutter/test/material/theme_test.dart +++ b/packages/flutter/test/material/theme_test.dart @@ -10,21 +10,21 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('ThemeDataTween control test', () { - final ThemeData light = new ThemeData.light(); - final ThemeData dark = new ThemeData.light(); - final ThemeDataTween tween = new ThemeDataTween(begin: light, end: dark); + final ThemeData light = ThemeData.light(); + final ThemeData dark = ThemeData.light(); + final ThemeDataTween tween = ThemeDataTween(begin: light, end: dark); expect(tween.lerp(0.25), equals(ThemeData.lerp(light, dark, 0.25))); }); testWidgets('PopupMenu inherits app theme', (WidgetTester tester) async { - final Key popupMenuButtonKey = new UniqueKey(); + final Key popupMenuButtonKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.dark), - home: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(brightness: Brightness.dark), + home: Scaffold( + appBar: AppBar( actions: [ - new PopupMenuButton( + PopupMenuButton( key: popupMenuButtonKey, itemBuilder: (BuildContext context) { return >[ @@ -47,21 +47,21 @@ void main() { testWidgets('Fallback theme', (WidgetTester tester) async { BuildContext capturedContext; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { capturedContext = context; - return new Container(); + return Container(); } ) ); - expect(Theme.of(capturedContext), equals(ThemeData.localize(new ThemeData.fallback(), MaterialTextGeometry.englishLike))); + expect(Theme.of(capturedContext), equals(ThemeData.localize(ThemeData.fallback(), MaterialTextGeometry.englishLike))); expect(Theme.of(capturedContext, shadowThemeOnly: true), isNull); }); testWidgets('ThemeData.localize memoizes the result', (WidgetTester tester) async { - final ThemeData light = new ThemeData.light(); - final ThemeData dark = new ThemeData.dark(); + final ThemeData light = ThemeData.light(); + final ThemeData dark = ThemeData.dark(); // Same input, same output. expect( @@ -84,16 +84,16 @@ void main() { testWidgets('PopupMenu inherits shadowed app theme', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/5572 - final Key popupMenuButtonKey = new UniqueKey(); + final Key popupMenuButtonKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.dark), - home: new Theme( - data: new ThemeData(brightness: Brightness.light), - child: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(brightness: Brightness.dark), + home: Theme( + data: ThemeData(brightness: Brightness.light), + child: Scaffold( + appBar: AppBar( actions: [ - new PopupMenuButton( + PopupMenuButton( key: popupMenuButtonKey, itemBuilder: (BuildContext context) { return >[ @@ -115,16 +115,16 @@ void main() { }); testWidgets('DropdownMenu inherits shadowed app theme', (WidgetTester tester) async { - final Key dropdownMenuButtonKey = new UniqueKey(); + final Key dropdownMenuButtonKey = UniqueKey(); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.dark), - home: new Theme( - data: new ThemeData(brightness: Brightness.light), - child: new Scaffold( - appBar: new AppBar( + MaterialApp( + theme: ThemeData(brightness: Brightness.dark), + home: Theme( + data: ThemeData(brightness: Brightness.light), + child: Scaffold( + appBar: AppBar( actions: [ - new DropdownButton( + DropdownButton( key: dropdownMenuButtonKey, onChanged: (String newValue) { }, value: 'menuItem', @@ -151,15 +151,15 @@ void main() { testWidgets('ModalBottomSheet inherits shadowed app theme', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.dark), - home: new Theme( - data: new ThemeData(brightness: Brightness.light), - child: new Scaffold( - body: new Center( - child: new Builder( + MaterialApp( + theme: ThemeData(brightness: Brightness.dark), + home: Theme( + data: ThemeData(brightness: Brightness.light), + child: Scaffold( + body: Center( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( onPressed: () { showModalBottomSheet( context: context, @@ -185,18 +185,18 @@ void main() { }); testWidgets('Dialog inherits shadowed app theme', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(brightness: Brightness.dark), - home: new Theme( - data: new ThemeData(brightness: Brightness.light), - child: new Scaffold( + MaterialApp( + theme: ThemeData(brightness: Brightness.dark), + home: Theme( + data: ThemeData(brightness: Brightness.light), + child: Scaffold( key: scaffoldKey, - body: new Center( - child: new Builder( + body: Center( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( onPressed: () { showDialog( context: context, @@ -222,13 +222,13 @@ void main() { const Color green = Color(0xFF00FF00); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(scaffoldBackgroundColor: green), - home: new Scaffold( - body: new Center( - child: new Builder( + MaterialApp( + theme: ThemeData(scaffoldBackgroundColor: green), + home: Scaffold( + body: Center( + child: Builder( builder: (BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { showDialog( context: context, @@ -262,8 +262,8 @@ void main() { testWidgets('IconThemes are applied', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(iconTheme: const IconThemeData(color: Colors.green, size: 10.0)), + MaterialApp( + theme: ThemeData(iconTheme: const IconThemeData(color: Colors.green, size: 10.0)), home: const Icon(Icons.computer), ) ); @@ -274,8 +274,8 @@ void main() { expect(glyphText.text.style.fontSize, 10.0); await tester.pumpWidget( - new MaterialApp( - theme: new ThemeData(iconTheme: const IconThemeData(color: Colors.orange, size: 20.0)), + MaterialApp( + theme: ThemeData(iconTheme: const IconThemeData(color: Colors.orange, size: 20.0)), home: const Icon(Icons.computer), ), ); @@ -297,10 +297,10 @@ void main() { 'Same ThemeData reapplied does not trigger descendants rebuilds', (WidgetTester tester) async { testBuildCalled = 0; - ThemeData themeData = new ThemeData(primaryColor: const Color(0xFF000000)); + ThemeData themeData = ThemeData(primaryColor: const Color(0xFF000000)); Widget buildTheme() { - return new Theme( + return Theme( data: themeData, child: const Test(), ); @@ -315,13 +315,13 @@ void main() { expect(testBuildCalled, 1); // New instance of theme data but still the same content. - themeData = new ThemeData(primaryColor: const Color(0xFF000000)); + themeData = ThemeData(primaryColor: const Color(0xFF000000)); await tester.pumpWidget(buildTheme()); // Still no repeated calls. expect(testBuildCalled, 1); // Different now. - themeData = new ThemeData(primaryColor: const Color(0xFF222222)); + themeData = ThemeData(primaryColor: const Color(0xFF222222)); await tester.pumpWidget(buildTheme()); // Should call build again. expect(testBuildCalled, 2); @@ -330,7 +330,7 @@ void main() { testWidgets('Text geometry set in Theme has higher precedence than that of Localizations', (WidgetTester tester) async { const double _kMagicFontSize = 4321.0; - final ThemeData fallback = new ThemeData.fallback(); + final ThemeData fallback = ThemeData.fallback(); final ThemeData customTheme = fallback.copyWith( primaryTextTheme: fallback.primaryTextTheme.copyWith( body1: fallback.primaryTextTheme.body1.copyWith( @@ -341,14 +341,14 @@ void main() { expect(customTheme.primaryTextTheme.body1.fontSize, _kMagicFontSize); double actualFontSize; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Theme( + child: Theme( data: customTheme, - child: new Builder(builder: (BuildContext context) { + child: Builder(builder: (BuildContext context) { final ThemeData theme = Theme.of(context); actualFontSize = theme.primaryTextTheme.body1.fontSize; - return new Text( + return Text( 'A', style: theme.primaryTextTheme.body1, ); @@ -361,9 +361,9 @@ void main() { testWidgets('Default Theme provides all basic TextStyle properties', (WidgetTester tester) async { ThemeData theme; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Builder( + child: Builder( builder: (BuildContext context) { theme = Theme.of(context); return const Text('A'); @@ -388,7 +388,7 @@ void main() { } for (TextTheme textTheme in [theme.textTheme, theme.primaryTextTheme, theme.accentTextTheme]) { - for (TextStyle style in extractStyles(textTheme).map((TextStyle style) => new _TextStyleProxy(style))) { + for (TextStyle style in extractStyles(textTheme).map((TextStyle style) => _TextStyleProxy(style))) { expect(style.inherit, false); expect(style.color, isNotNull); expect(style.fontFamily, isNotNull); @@ -417,15 +417,15 @@ class Test extends StatefulWidget { const Test(); @override - _TestState createState() => new _TestState(); + _TestState createState() => _TestState(); } class _TestState extends State { @override Widget build(BuildContext context) { testBuildCalled += 1; - return new Container( - decoration: new BoxDecoration( + return Container( + decoration: BoxDecoration( color: Theme.of(context).primaryColor, ), ); @@ -465,46 +465,46 @@ class _TextStyleProxy implements TextStyle { @override DiagnosticsNode toDiagnosticsNode({String name, DiagnosticsTreeStyle style}) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override String toStringShort() { - throw new UnimplementedError(); + throw UnimplementedError(); } @override TextStyle apply({Color color, TextDecoration decoration, Color decorationColor, TextDecorationStyle decorationStyle, String fontFamily, double fontSizeFactor = 1.0, double fontSizeDelta = 0.0, int fontWeightDelta = 0, double letterSpacingFactor = 1.0, double letterSpacingDelta = 0.0, double wordSpacingFactor = 1.0, double wordSpacingDelta = 0.0, double heightFactor = 1.0, double heightDelta = 0.0}) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override RenderComparison compareTo(TextStyle other) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override TextStyle copyWith({Color color, String fontFamily, double fontSize, FontWeight fontWeight, FontStyle fontStyle, double letterSpacing, double wordSpacing, TextBaseline textBaseline, double height, Locale locale, ui.Paint foreground, ui.Paint background, TextDecoration decoration, Color decorationColor, TextDecorationStyle decorationStyle, String debugLabel}) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override void debugFillProperties(DiagnosticPropertiesBuilder properties, {String prefix = ''}) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override ui.ParagraphStyle getParagraphStyle({TextAlign textAlign, TextDirection textDirection, double textScaleFactor = 1.0, String ellipsis, int maxLines, Locale locale}) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override ui.TextStyle getTextStyle({double textScaleFactor = 1.0}) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override TextStyle merge(TextStyle other) { - throw new UnimplementedError(); + throw UnimplementedError(); } } diff --git a/packages/flutter/test/material/time_picker_test.dart b/packages/flutter/test/material/time_picker_test.dart index 24a58e2bbc..f3b79e54ad 100644 --- a/packages/flutter/test/material/time_picker_test.dart +++ b/packages/flutter/test/material/time_picker_test.dart @@ -27,13 +27,13 @@ class _TimePickerLauncher extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( locale: locale, - home: new Material( - child: new Center( - child: new Builder( + home: Material( + child: Center( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( child: const Text('X'), onPressed: () async { onChanged(await showTimePicker( @@ -51,7 +51,7 @@ class _TimePickerLauncher extends StatelessWidget { } Future startPicker(WidgetTester tester, ValueChanged onChanged) async { - await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged, locale: const Locale('en', 'US'))); + await tester.pumpWidget(_TimePickerLauncher(onChanged: onChanged, locale: const Locale('en', 'US'))); await tester.tap(find.text('X')); await tester.pumpAndSettle(const Duration(seconds: 1)); return tester.getCenter(find.byKey(const ValueKey('time-picker-dial'))); @@ -74,23 +74,23 @@ void _tests() { TimeOfDay result; Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); - await tester.tapAt(new Offset(center.dx, center.dy - 50.0)); // 12:00 AM + await tester.tapAt(Offset(center.dx, center.dy - 50.0)); // 12:00 AM await finishPicker(tester); expect(result, equals(const TimeOfDay(hour: 0, minute: 0))); center = await startPicker(tester, (TimeOfDay time) { result = time; }); - await tester.tapAt(new Offset(center.dx + 50.0, center.dy)); + await tester.tapAt(Offset(center.dx + 50.0, center.dy)); await finishPicker(tester); expect(result, equals(const TimeOfDay(hour: 3, minute: 0))); center = await startPicker(tester, (TimeOfDay time) { result = time; }); - await tester.tapAt(new Offset(center.dx, center.dy + 50.0)); + await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await finishPicker(tester); expect(result, equals(const TimeOfDay(hour: 6, minute: 0))); center = await startPicker(tester, (TimeOfDay time) { result = time; }); - await tester.tapAt(new Offset(center.dx, center.dy + 50.0)); - await tester.tapAt(new Offset(center.dx - 50, center.dy)); + await tester.tapAt(Offset(center.dx, center.dy + 50.0)); + await tester.tapAt(Offset(center.dx - 50, center.dy)); await finishPicker(tester); expect(result, equals(const TimeOfDay(hour: 9, minute: 0))); }); @@ -99,10 +99,10 @@ void _tests() { TimeOfDay result; final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); - final Offset hour0 = new Offset(center.dx, center.dy - 50.0); // 12:00 AM - final Offset hour3 = new Offset(center.dx + 50.0, center.dy); - final Offset hour6 = new Offset(center.dx, center.dy + 50.0); - final Offset hour9 = new Offset(center.dx - 50.0, center.dy); + final Offset hour0 = Offset(center.dx, center.dy - 50.0); // 12:00 AM + final Offset hour3 = Offset(center.dx + 50.0, center.dy); + final Offset hour6 = Offset(center.dx, center.dy + 50.0); + final Offset hour9 = Offset(center.dx - 50.0, center.dy); TestGesture gesture; @@ -140,7 +140,7 @@ void _tests() { FeedbackTester feedback; setUp(() { - feedback = new FeedbackTester(); + feedback = FeedbackTester(); }); tearDown(() { @@ -149,35 +149,35 @@ void _tests() { testWidgets('tap-select vibrates once', (WidgetTester tester) async { final Offset center = await startPicker(tester, (TimeOfDay time) { }); - await tester.tapAt(new Offset(center.dx, center.dy - 50.0)); + await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await finishPicker(tester); expect(feedback.hapticCount, 1); }); testWidgets('quick successive tap-selects vibrate once', (WidgetTester tester) async { final Offset center = await startPicker(tester, (TimeOfDay time) { }); - await tester.tapAt(new Offset(center.dx, center.dy - 50.0)); + await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await tester.pump(kFastFeedbackInterval); - await tester.tapAt(new Offset(center.dx, center.dy + 50.0)); + await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await finishPicker(tester); expect(feedback.hapticCount, 1); }); testWidgets('slow successive tap-selects vibrate once per tap', (WidgetTester tester) async { final Offset center = await startPicker(tester, (TimeOfDay time) { }); - await tester.tapAt(new Offset(center.dx, center.dy - 50.0)); + await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await tester.pump(kSlowFeedbackInterval); - await tester.tapAt(new Offset(center.dx, center.dy + 50.0)); + await tester.tapAt(Offset(center.dx, center.dy + 50.0)); await tester.pump(kSlowFeedbackInterval); - await tester.tapAt(new Offset(center.dx, center.dy - 50.0)); + await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await finishPicker(tester); expect(feedback.hapticCount, 3); }); testWidgets('drag-select vibrates once', (WidgetTester tester) async { final Offset center = await startPicker(tester, (TimeOfDay time) { }); - final Offset hour0 = new Offset(center.dx, center.dy - 50.0); - final Offset hour3 = new Offset(center.dx + 50.0, center.dy); + final Offset hour0 = Offset(center.dx, center.dy - 50.0); + final Offset hour3 = Offset(center.dx + 50.0, center.dy); final TestGesture gesture = await tester.startGesture(hour3); await gesture.moveBy(hour0 - hour3); @@ -188,8 +188,8 @@ void _tests() { testWidgets('quick drag-select vibrates once', (WidgetTester tester) async { final Offset center = await startPicker(tester, (TimeOfDay time) { }); - final Offset hour0 = new Offset(center.dx, center.dy - 50.0); - final Offset hour3 = new Offset(center.dx + 50.0, center.dy); + final Offset hour0 = Offset(center.dx, center.dy - 50.0); + final Offset hour3 = Offset(center.dx + 50.0, center.dy); final TestGesture gesture = await tester.startGesture(hour3); await gesture.moveBy(hour0 - hour3); @@ -204,8 +204,8 @@ void _tests() { testWidgets('slow drag-select vibrates once', (WidgetTester tester) async { final Offset center = await startPicker(tester, (TimeOfDay time) { }); - final Offset hour0 = new Offset(center.dx, center.dy - 50.0); - final Offset hour3 = new Offset(center.dx + 50.0, center.dy); + final Offset hour0 = Offset(center.dx, center.dy - 50.0); + final Offset hour3 = Offset(center.dx + 50.0, center.dy); final TestGesture gesture = await tester.startGesture(hour3); await gesture.moveBy(hour0 - hour3); @@ -226,21 +226,21 @@ void _tests() { Future mediaQueryBoilerplate(WidgetTester tester, bool alwaysUse24HourFormat, { TimeOfDay initialTime = const TimeOfDay(hour: 7, minute: 0) }) async { await tester.pumpWidget( - new Localizations( + Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child: new MediaQuery( - data: new MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), - child: new Material( - child: new Directionality( + child: MediaQuery( + data: MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), + child: Material( + child: Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute(builder: (BuildContext context) { - return new FlatButton( + return MaterialPageRoute(builder: (BuildContext context) { + return FlatButton( onPressed: () { showTimePicker(context: context, initialTime: initialTime); }, @@ -290,7 +290,7 @@ void _tests() { }); testWidgets('provides semantics information for AM/PM indicator', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await mediaQueryBoilerplate(tester, false); expect(semantics, includesNodeWith(label: 'AM', actions: [SemanticsAction.tap])); @@ -300,7 +300,7 @@ void _tests() { }); testWidgets('provides semantics information for header and footer', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await mediaQueryBoilerplate(tester, true); expect(semantics, isNot(includesNodeWith(label: ':'))); @@ -319,12 +319,12 @@ void _tests() { }); testWidgets('provides semantics information for hours', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await mediaQueryBoilerplate(tester, true); final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey('time-picker-dial'))); final CustomPainter dialPainter = dialPaint.painter; - final _CustomPainterSemanticsTester painterTester = new _CustomPainterSemanticsTester(tester, dialPainter, semantics); + final _CustomPainterSemanticsTester painterTester = _CustomPainterSemanticsTester(tester, dialPainter, semantics); painterTester.addLabel('00', 86.0, 0.0, 134.0, 48.0); painterTester.addLabel('13', 129.0, 11.5, 177.0, 59.5); @@ -356,14 +356,14 @@ void _tests() { }); testWidgets('provides semantics information for minutes', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await mediaQueryBoilerplate(tester, true); await tester.tap(_minuteControl); await tester.pumpAndSettle(); final CustomPaint dialPaint = tester.widget(find.byKey(const ValueKey('time-picker-dial'))); final CustomPainter dialPainter = dialPaint.painter; - final _CustomPainterSemanticsTester painterTester = new _CustomPainterSemanticsTester(tester, dialPainter, semantics); + final _CustomPainterSemanticsTester painterTester = _CustomPainterSemanticsTester(tester, dialPainter, semantics); painterTester.addLabel('00', 86.0, 0.0, 134.0, 48.0); painterTester.addLabel('05', 129.0, 11.5, 177.0, 59.5); @@ -387,7 +387,7 @@ void _tests() { dynamic dialPaint = tester.widget(findDialPaint); expect('${dialPaint.painter.activeRing}', '_DialRing.inner'); - await tester.pumpWidget(new Container()); // make sure previous state isn't reused + await tester.pumpWidget(Container()); // make sure previous state isn't reused await mediaQueryBoilerplate(tester, true, initialTime: const TimeOfDay(hour: 0, minute: 0)); dialPaint = tester.widget(findDialPaint); @@ -395,7 +395,7 @@ void _tests() { }); testWidgets('can increment and decrement hours', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); Future actAndExpect({ String initialValue, SemanticsAction action, String finalValue }) async { final SemanticsNode elevenHours = semantics.nodesWith( @@ -432,7 +432,7 @@ void _tests() { action: SemanticsAction.decrease, finalValue: '12', ); - await tester.pumpWidget(new Container()); // clear old boilerplate + await tester.pumpWidget(Container()); // clear old boilerplate // 24-hour format await mediaQueryBoilerplate(tester, true, initialTime: const TimeOfDay(hour: 23, minute: 0)); @@ -461,7 +461,7 @@ void _tests() { }); testWidgets('can increment and decrement minutes', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); Future actAndExpect({ String initialValue, SemanticsAction action, String finalValue }) async { final SemanticsNode elevenHours = semantics.nodesWith( @@ -532,11 +532,11 @@ class _CustomPainterSemanticsTester { final List<_SemanticsNodeExpectation> expectedNodes = <_SemanticsNodeExpectation>[]; void addLabel(String label, double left, double top, double right, double bottom) { - expectedNodes.add(new _SemanticsNodeExpectation(label, left, top, right, bottom)); + expectedNodes.add(_SemanticsNodeExpectation(label, left, top, right, bottom)); } void assertExpectations() { - final TestRecordingCanvas canvasRecording = new TestRecordingCanvas(); + final TestRecordingCanvas canvasRecording = TestRecordingCanvas(); painter.paint(canvasRecording, const Size(220.0, 220.0)); final List paragraphs = canvasRecording.invocations .where((RecordedInvocation recordedInvocation) { @@ -556,7 +556,7 @@ class _CustomPainterSemanticsTester { .nodesWith(value: expectation.label) .where((SemanticsNode node) => node.tags?.contains(const SemanticsTag('dial-label')) ?? false); expect(dialLabelNodes, hasLength(1), reason: 'Expected exactly one label ${expectation.label}'); - final Rect rect = new Rect.fromLTRB(expectation.left, expectation.top, expectation.right, expectation.bottom); + final Rect rect = Rect.fromLTRB(expectation.left, expectation.top, expectation.right, expectation.bottom); expect(dialLabelNodes.single.rect, within(distance: 1.0, from: rect), reason: 'This is checking the node rectangle for label ${expectation.label}'); diff --git a/packages/flutter/test/material/time_test.dart b/packages/flutter/test/material/time_test.dart index 25bf7fe709..0ba00f1366 100644 --- a/packages/flutter/test/material/time_test.dart +++ b/packages/flutter/test/material/time_test.dart @@ -10,12 +10,12 @@ void main() { testWidgets('respects alwaysUse24HourFormat option', (WidgetTester tester) async { Future pumpTest(bool alwaysUse24HourFormat) async { String formattedValue; - await tester.pumpWidget(new MaterialApp( - home: new MediaQuery( - data: new MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), - child: new Builder(builder: (BuildContext context) { + await tester.pumpWidget(MaterialApp( + home: MediaQuery( + data: MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), + child: Builder(builder: (BuildContext context) { formattedValue = const TimeOfDay(hour: 7, minute: 0).format(context); - return new Container(); + return Container(); }), ), )); diff --git a/packages/flutter/test/material/tooltip_test.dart b/packages/flutter/test/material/tooltip_test.dart index 097eaba7aa..8c117f81d7 100644 --- a/packages/flutter/test/material/tooltip_test.dart +++ b/packages/flutter/test/material/tooltip_test.dart @@ -33,27 +33,27 @@ const String tooltipText = 'TIP'; void main() { testWidgets('Does tooltip end up in the right place - center', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 300.0, top: 0.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 20.0, padding: const EdgeInsets.all(5.0), verticalOffset: 20.0, preferBelow: false, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -89,27 +89,27 @@ void main() { }); testWidgets('Does tooltip end up in the right place - top left', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 0.0, top: 0.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 20.0, padding: const EdgeInsets.all(5.0), verticalOffset: 20.0, preferBelow: false, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -141,27 +141,27 @@ void main() { }); testWidgets('Does tooltip end up in the right place - center prefer above fits', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 400.0, top: 300.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 100.0, padding: const EdgeInsets.all(0.0), verticalOffset: 100.0, preferBelow: false, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -195,27 +195,27 @@ void main() { }); testWidgets('Does tooltip end up in the right place - center prefer above does not fit', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 400.0, top: 299.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 190.0, padding: const EdgeInsets.all(0.0), verticalOffset: 100.0, preferBelow: false, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -260,27 +260,27 @@ void main() { }); testWidgets('Does tooltip end up in the right place - center prefer below fits', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 400.0, top: 300.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 190.0, padding: const EdgeInsets.all(0.0), verticalOffset: 100.0, preferBelow: true, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -313,27 +313,27 @@ void main() { }); testWidgets('Does tooltip end up in the right place - way off to the right', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 1600.0, top: 300.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 10.0, padding: const EdgeInsets.all(0.0), verticalOffset: 10.0, preferBelow: true, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -368,27 +368,27 @@ void main() { }); testWidgets('Does tooltip end up in the right place - near the edge', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 780.0, top: 300.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, height: 10.0, padding: const EdgeInsets.all(0.0), verticalOffset: 10.0, preferBelow: true, - child: new Container( + child: Container( width: 0.0, height: 0.0, ), @@ -424,11 +424,11 @@ void main() { testWidgets('Tooltip stays around', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Tooltip( + MaterialApp( + home: Center( + child: Tooltip( message: tooltipText, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: Colors.green[500], @@ -458,25 +458,25 @@ void main() { }); testWidgets('Does tooltip contribute semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( left: 780.0, top: 300.0, - child: new Tooltip( + child: Tooltip( key: key, message: tooltipText, - child: new Container(width: 10.0, height: 10.0), + child: Container(width: 10.0, height: 10.0), ), ), ], @@ -488,9 +488,9 @@ void main() { ), ); - final TestSemantics expected = new TestSemantics.root( + final TestSemantics expected = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'TIP', textDirection: TextDirection.ltr, @@ -512,11 +512,11 @@ void main() { testWidgets('Tooltip overlay does not update', (WidgetTester tester) async { Widget buildApp(String text) { - return new MaterialApp( - home: new Center( - child: new Tooltip( + return MaterialApp( + home: Center( + child: Tooltip( message: text, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: Colors.green[500], @@ -541,18 +541,18 @@ void main() { testWidgets('Tooltip text scales with textScaleFactor', (WidgetTester tester) async { Widget buildApp(String text, { double textScaleFactor }) { - return new MediaQuery( - data: new MediaQueryData(textScaleFactor: textScaleFactor), - child: new Directionality( + return MediaQuery( + data: MediaQueryData(textScaleFactor: textScaleFactor), + child: Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute( + return MaterialPageRoute( builder: (BuildContext context) { - return new Center( - child: new Tooltip( + return Center( + child: Tooltip( message: text, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: Colors.green[500], @@ -583,13 +583,13 @@ void main() { }); testWidgets('Haptic feedback', (WidgetTester tester) async { - final FeedbackTester feedback = new FeedbackTester(); + final FeedbackTester feedback = FeedbackTester(); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Tooltip( + MaterialApp( + home: Center( + child: Tooltip( message: 'Foo', - child: new Container( + child: Container( width: 100.0, height: 100.0, color: Colors.green[500], @@ -607,10 +607,10 @@ void main() { }); testWidgets('Semantics included', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Center( child: Tooltip( message: 'Foo', @@ -620,14 +620,14 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'Foo\nBar', textDirection: TextDirection.ltr, ) @@ -642,10 +642,10 @@ void main() { }); testWidgets('Semantics excluded', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Center( child: Tooltip( message: 'Foo', @@ -656,14 +656,14 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'Bar', textDirection: TextDirection.ltr, ) @@ -682,14 +682,14 @@ void main() { SystemChannels.accessibility.setMockMessageHandler((dynamic message) async { semanticEvents.add(message); }); - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Tooltip( + MaterialApp( + home: Center( + child: Tooltip( message: 'Foo', - child: new Container( + child: Container( width: 100.0, height: 100.0, color: Colors.green[500], diff --git a/packages/flutter/test/material/two_level_list_test.dart b/packages/flutter/test/material/two_level_list_test.dart index d59c852175..5da8099c21 100644 --- a/packages/flutter/test/material/two_level_list_test.dart +++ b/packages/flutter/test/material/two_level_list_test.dart @@ -8,18 +8,18 @@ import 'package:flutter/material.dart'; void main() { testWidgets('TwoLevelList basics', (WidgetTester tester) async { - final Key topKey = new UniqueKey(); - final Key sublistKey = new UniqueKey(); - final Key bottomKey = new UniqueKey(); + final Key topKey = UniqueKey(); + final Key sublistKey = UniqueKey(); + final Key bottomKey = UniqueKey(); final Map routes = { '/': (_) { - return new Material( - child: new SingleChildScrollView( - child: new Column( + return Material( + child: SingleChildScrollView( + child: Column( children: [ - new ListTile(title: const Text('Top'), key: topKey), - new ExpansionTile( + ListTile(title: const Text('Top'), key: topKey), + ExpansionTile( key: sublistKey, title: const Text('Sublist'), children: const [ @@ -27,7 +27,7 @@ void main() { ListTile(title: Text('1')) ] ), - new ListTile(title: const Text('Bottom'), key: bottomKey) + ListTile(title: const Text('Bottom'), key: bottomKey) ] ) ) @@ -35,7 +35,7 @@ void main() { } }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(find.text('Top'), findsOneWidget); expect(find.text('Sublist'), findsOneWidget); @@ -72,11 +72,11 @@ void main() { final Map routes = { '/': (_) { - return new Material( - child: new SingleChildScrollView( - child: new Column( + return Material( + child: SingleChildScrollView( + child: Column( children: [ - new ExpansionTile( + ExpansionTile( title: const Text('Sublist'), onExpansionChanged: (bool opened) { didChangeOpen = opened; @@ -93,7 +93,7 @@ void main() { } }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(didChangeOpen, isNull); await tester.tap(find.text('Sublist')); @@ -107,9 +107,9 @@ void main() { testWidgets('trailing override', (WidgetTester tester) async { final Map routes = { '/': (_) { - return new Material( - child: new SingleChildScrollView( - child: new Column( + return Material( + child: SingleChildScrollView( + child: Column( children: const [ ListTile(title: Text('Top')), ExpansionTile( @@ -128,7 +128,7 @@ void main() { } }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(find.byIcon(Icons.inbox), findsOneWidget); expect(find.byIcon(Icons.expand_more), findsNothing); }); diff --git a/packages/flutter/test/material/typography_test.dart b/packages/flutter/test/material/typography_test.dart index 96f465f954..d93336389e 100644 --- a/packages/flutter/test/material/typography_test.dart +++ b/packages/flutter/test/material/typography_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('TextTheme control test', () { - final Typography typography = new Typography(platform: TargetPlatform.android); + final Typography typography = Typography(platform: TargetPlatform.android); expect(typography.black, equals(typography.black.copyWith())); expect(typography.black, equals(typography.black.apply())); expect(typography.black.hashCode, equals(typography.black.copyWith().hashCode)); @@ -16,7 +16,7 @@ void main() { test('Typography is defined for all target platforms', () { for (TargetPlatform platform in TargetPlatform.values) { - final Typography typography = new Typography(platform: platform); + final Typography typography = Typography(platform: platform); expect(typography, isNotNull, reason: 'null typography for $platform'); expect(typography.black, isNotNull, reason: 'null black typography for $platform'); expect(typography.white, isNotNull, reason: 'null white typography for $platform'); @@ -47,8 +47,8 @@ void main() { }); test('Typography on Android, Fuchsia defaults to Roboto', () { - expect(new Typography(platform: TargetPlatform.android).black.title.fontFamily, 'Roboto'); - expect(new Typography(platform: TargetPlatform.fuchsia).black.title.fontFamily, 'Roboto'); + expect(Typography(platform: TargetPlatform.android).black.title.fontFamily, 'Roboto'); + expect(Typography(platform: TargetPlatform.fuchsia).black.title.fontFamily, 'Roboto'); }); test('Typography on iOS defaults to the correct SF font family based on size', () { @@ -61,7 +61,7 @@ void main() { return s.fontFamily == '.SF UI Text'; }, 'Uses SF Text font'); - final Typography typography = new Typography(platform: TargetPlatform.iOS); + final Typography typography = Typography(platform: TargetPlatform.iOS); for (TextTheme textTheme in [typography.black, typography.white]) { expect(textTheme.display4, isDisplayFont); expect(textTheme.display3, isDisplayFont); diff --git a/packages/flutter/test/material/user_accounts_drawer_header_test.dart b/packages/flutter/test/material/user_accounts_drawer_header_test.dart index 46b0441d0c..25ea2bd3b3 100644 --- a/packages/flutter/test/material/user_accounts_drawer_header_test.dart +++ b/packages/flutter/test/material/user_accounts_drawer_header_test.dart @@ -18,8 +18,8 @@ Future pumpTestWidget(WidgetTester tester, { bool withOnDetailsPressedHandler = true, }) async { await tester.pumpWidget( - new MaterialApp( - home: new MediaQuery( + MaterialApp( + home: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.only( left: 10.0, @@ -28,9 +28,9 @@ Future pumpTestWidget(WidgetTester tester, { bottom: 40.0, ), ), - child: new Material( - child: new Center( - child: new UserAccountsDrawerHeader( + child: Material( + child: Center( + child: UserAccountsDrawerHeader( onDetailsPressed: withOnDetailsPressedHandler ? () {} : null, currentAccountPicture: const ExcludeSemantics( child: CircleAvatar( @@ -113,10 +113,10 @@ void main() { VoidCallback onDetailsPressed, EdgeInsets margin, }) { - return new MaterialApp( - home: new Material( - child: new Center( - child: new UserAccountsDrawerHeader( + return MaterialApp( + home: Material( + child: Center( + child: UserAccountsDrawerHeader( currentAccountPicture: currentAccountPicture, otherAccountsPictures: otherAccountsPictures, accountName: accountName, @@ -221,12 +221,12 @@ void main() { VoidCallback onDetailsPressed, EdgeInsets margin, }) { - return new MaterialApp( - home: new Directionality( + return MaterialApp( + home: Directionality( textDirection: TextDirection.rtl, - child: new Material( - child: new Center( - child: new UserAccountsDrawerHeader( + child: Material( + child: Center( + child: UserAccountsDrawerHeader( currentAccountPicture: currentAccountPicture, otherAccountsPictures: otherAccountsPictures, accountName: accountName, @@ -324,36 +324,36 @@ void main() { }); testWidgets('UserAccountsDrawerHeader provides semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await pumpTestWidget(tester); expect( semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'Signed in\nname\nemail', textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( label: r'B', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'C', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'D', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], actions: [SemanticsAction.tap], label: r'Show accounts', @@ -396,7 +396,7 @@ void main() { }); testWidgets('UserAccountsDrawerHeader provides semantics with missing properties', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await pumpTestWidget( tester, withEmail: false, @@ -407,26 +407,26 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( label: 'Signed in', textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( label: r'B', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'C', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'D', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/material/will_pop_test.dart b/packages/flutter/test/material/will_pop_test.dart index dc81b292cb..411270f8a6 100644 --- a/packages/flutter/test/material/will_pop_test.dart +++ b/packages/flutter/test/material/will_pop_test.dart @@ -9,7 +9,7 @@ bool willPopValue = false; class SamplePage extends StatefulWidget { @override - SamplePageState createState() => new SamplePageState(); + SamplePageState createState() => SamplePageState(); } class SamplePageState extends State { @@ -33,8 +33,8 @@ class SamplePageState extends State { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Sample Page')), + return Scaffold( + appBar: AppBar(title: const Text('Sample Page')), ); } } @@ -48,10 +48,10 @@ class SampleForm extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: const Text('Sample Form')), - body: new SizedBox.expand( - child: new Form( + return Scaffold( + appBar: AppBar(title: const Text('Sample Form')), + body: SizedBox.expand( + child: Form( onWillPop: () { willPopCount += 1; return callback(); @@ -75,18 +75,18 @@ class TestPageRoute extends MaterialPageRoute { void main() { testWidgets('ModalRoute scopedWillPopupCallback can inhibit back button', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - appBar: new AppBar(title: const Text('Home')), - body: new Builder( + MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Home')), + body: Builder( builder: (BuildContext context) { - return new Center( - child: new FlatButton( + return Center( + child: FlatButton( child: const Text('X'), onPressed: () { showDialog( context: context, - builder: (BuildContext context) => new SamplePage(), + builder: (BuildContext context) => SamplePage(), ); }, ), @@ -129,19 +129,19 @@ void main() { testWidgets('Form.willPop can inhibit back button', (WidgetTester tester) async { Widget buildFrame() { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar(title: const Text('Home')), - body: new Builder( + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Home')), + body: Builder( builder: (BuildContext context) { - return new Center( - child: new FlatButton( + return Center( + child: FlatButton( child: const Text('X'), onPressed: () { - Navigator.of(context).push(new MaterialPageRoute( + Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) { - return new SampleForm( - callback: () => new Future.value(willPopValue), + return SampleForm( + callback: () => Future.value(willPopValue), ); }, )); @@ -186,13 +186,13 @@ void main() { return showDialog( context: context, builder: (BuildContext context) { - return new AlertDialog( + return AlertDialog( actions: [ - new FlatButton( + FlatButton( child: const Text('YES'), onPressed: () { Navigator.of(context).pop(true); }, ), - new FlatButton( + FlatButton( child: const Text('NO'), onPressed: () { Navigator.of(context).pop(false); }, ), @@ -203,18 +203,18 @@ void main() { } Widget buildFrame() { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar(title: const Text('Home')), - body: new Builder( + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Home')), + body: Builder( builder: (BuildContext context) { - return new Center( - child: new FlatButton( + return Center( + child: FlatButton( child: const Text('X'), onPressed: () { - Navigator.of(context).push(new MaterialPageRoute( + Navigator.of(context).push(MaterialPageRoute( builder: (BuildContext context) { - return new SampleForm( + return SampleForm( callback: () => showYesNoAlert(context), ); } @@ -277,25 +277,25 @@ void main() { StateSetter contentsSetState; // call this to rebuild the route's SampleForm contents bool contentsEmpty = false; // when true, don't include the SampleForm in the route - final TestPageRoute route = new TestPageRoute( + final TestPageRoute route = TestPageRoute( builder: (BuildContext context) { - return new StatefulBuilder( + return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { contentsSetState = setState; - return contentsEmpty ? new Container() : new SampleForm(key: new UniqueKey()); + return contentsEmpty ? Container() : SampleForm(key: UniqueKey()); } ); }, ); Widget buildFrame() { - return new MaterialApp( - home: new Scaffold( - appBar: new AppBar(title: const Text('Home')), - body: new Builder( + return MaterialApp( + home: Scaffold( + appBar: AppBar(title: const Text('Home')), + body: Builder( builder: (BuildContext context) { - return new Center( - child: new FlatButton( + return Center( + child: FlatButton( child: const Text('X'), onPressed: () { Navigator.of(context).push(route); diff --git a/packages/flutter/test/painting/alignment_test.dart b/packages/flutter/test/painting/alignment_test.dart index 8034829c21..f8ae14c5fa 100644 --- a/packages/flutter/test/painting/alignment_test.dart +++ b/packages/flutter/test/painting/alignment_test.dart @@ -92,7 +92,7 @@ void main() { expect(const AlignmentDirectional(0.0, 0.0).resolve(TextDirection.rtl), const Alignment(0.0, 0.0)); expect(const AlignmentDirectional(1.0, 1.0).resolve(TextDirection.ltr), const Alignment(1.0, 1.0)); expect(const AlignmentDirectional(1.0, 1.0).resolve(TextDirection.rtl), const Alignment(-1.0, 1.0)); - expect(new AlignmentDirectional(nonconst(1.0), 2.0), new AlignmentDirectional(nonconst(1.0), 2.0)); + expect(AlignmentDirectional(nonconst(1.0), 2.0), AlignmentDirectional(nonconst(1.0), 2.0)); expect(const AlignmentDirectional(1.0, 2.0), isNot(const AlignmentDirectional(2.0, 1.0))); expect(const AlignmentDirectional(-1.0, 0.0).resolve(TextDirection.ltr), const AlignmentDirectional(1.0, 0.0).resolve(TextDirection.rtl)); diff --git a/packages/flutter/test/painting/beveled_rectangle_border_test.dart b/packages/flutter/test/painting/beveled_rectangle_border_test.dart index 63b0f272c5..27463b007f 100644 --- a/packages/flutter/test/painting/beveled_rectangle_border_test.dart +++ b/packages/flutter/test/painting/beveled_rectangle_border_test.dart @@ -9,9 +9,9 @@ import '../rendering/mock_canvas.dart'; void main() { test('BeveledRectangleBorder scale and lerp', () { - final BeveledRectangleBorder c10 = new BeveledRectangleBorder(side: const BorderSide(width: 10.0), borderRadius: new BorderRadius.circular(100.0)); - final BeveledRectangleBorder c15 = new BeveledRectangleBorder(side: const BorderSide(width: 15.0), borderRadius: new BorderRadius.circular(150.0)); - final BeveledRectangleBorder c20 = new BeveledRectangleBorder(side: const BorderSide(width: 20.0), borderRadius: new BorderRadius.circular(200.0)); + final BeveledRectangleBorder c10 = BeveledRectangleBorder(side: const BorderSide(width: 10.0), borderRadius: BorderRadius.circular(100.0)); + final BeveledRectangleBorder c15 = BeveledRectangleBorder(side: const BorderSide(width: 15.0), borderRadius: BorderRadius.circular(150.0)); + final BeveledRectangleBorder c20 = BeveledRectangleBorder(side: const BorderSide(width: 20.0), borderRadius: BorderRadius.circular(200.0)); expect(c10.dimensions, const EdgeInsets.all(10.0)); expect(c10.scale(2.0), c20); expect(c20.scale(0.5), c10); @@ -21,7 +21,7 @@ void main() { }); test('BeveledRectangleBorder BorderRadius.zero', () { - final Rect rect1 = new Rect.fromLTRB(10.0, 20.0, 30.0, 40.0); + final Rect rect1 = Rect.fromLTRB(10.0, 20.0, 30.0, 40.0); final Matcher looksLikeRect1 = isPathThat( includes: const [ Offset(10.0, 20.0), Offset(20.0, 30.0) ], excludes: const [ Offset(9.0, 19.0), Offset(31.0, 41.0) ], @@ -45,7 +45,7 @@ void main() { }); test('BeveledRectangleBorder non-zero BorderRadius', () { - final Rect rect = new Rect.fromLTRB(10.0, 20.0, 30.0, 40.0); + final Rect rect = Rect.fromLTRB(10.0, 20.0, 30.0, 40.0); final Matcher looksLikeRect = isPathThat( includes: const [ Offset(15.0, 25.0), Offset(20.0, 30.0) ], excludes: const [ Offset(10.0, 20.0), Offset(30.0, 40.0) ], diff --git a/packages/flutter/test/painting/border_radius_test.dart b/packages/flutter/test/painting/border_radius_test.dart index ff006f45f5..098b4d7b17 100644 --- a/packages/flutter/test/painting/border_radius_test.dart +++ b/packages/flutter/test/painting/border_radius_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('BorderRadius control test', () { - final Rect rect = new Rect.fromLTRB(19.0, 23.0, 29.0, 31.0); + final Rect rect = Rect.fromLTRB(19.0, 23.0, 29.0, 31.0); BorderRadius borderRadius; borderRadius = const BorderRadius.all(Radius.elliptical(5.0, 7.0)); @@ -16,15 +16,15 @@ void main() { expect(borderRadius.topRight, const Radius.elliptical(5.0, 7.0)); expect(borderRadius.bottomLeft, const Radius.elliptical(5.0, 7.0)); expect(borderRadius.bottomRight, const Radius.elliptical(5.0, 7.0)); - expect(borderRadius.toRRect(rect), new RRect.fromRectXY(rect, 5.0, 7.0)); + expect(borderRadius.toRRect(rect), RRect.fromRectXY(rect, 5.0, 7.0)); - borderRadius = new BorderRadius.circular(3.0); + borderRadius = BorderRadius.circular(3.0); expect(borderRadius, hasOneLineDescription); expect(borderRadius.topLeft, const Radius.elliptical(3.0, 3.0)); expect(borderRadius.topRight, const Radius.elliptical(3.0, 3.0)); expect(borderRadius.bottomLeft, const Radius.elliptical(3.0, 3.0)); expect(borderRadius.bottomRight, const Radius.elliptical(3.0, 3.0)); - expect(borderRadius.toRRect(rect), new RRect.fromRectXY(rect, 3.0, 3.0)); + expect(borderRadius.toRRect(rect), RRect.fromRectXY(rect, 3.0, 3.0)); const Radius radius1 = Radius.elliptical(89.0, 87.0); const Radius radius2 = Radius.elliptical(103.0, 107.0); @@ -35,7 +35,7 @@ void main() { expect(borderRadius.topRight, radius1); expect(borderRadius.bottomLeft, radius2); expect(borderRadius.bottomRight, radius2); - expect(borderRadius.toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius1, topRight: radius1, @@ -49,7 +49,7 @@ void main() { expect(borderRadius.topRight, radius2); expect(borderRadius.bottomLeft, radius1); expect(borderRadius.bottomRight, radius2); - expect(borderRadius.toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius1, topRight: radius2, @@ -63,7 +63,7 @@ void main() { expect(borderRadius.topRight, Radius.zero); expect(borderRadius.bottomLeft, Radius.zero); expect(borderRadius.bottomRight, Radius.zero); - expect(borderRadius.toRRect(rect), new RRect.fromRectAndCorners(rect)); + expect(borderRadius.toRRect(rect), RRect.fromRectAndCorners(rect)); borderRadius = const BorderRadius.only(topRight: radius1, bottomRight: radius2); expect(borderRadius, hasOneLineDescription); @@ -71,7 +71,7 @@ void main() { expect(borderRadius.topRight, radius1); expect(borderRadius.bottomLeft, Radius.zero); expect(borderRadius.bottomRight, radius2); - expect(borderRadius.toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: Radius.zero, topRight: radius1, @@ -113,28 +113,28 @@ void main() { ); expect( - new BorderRadius.circular(15.0) / 10.0, - new BorderRadius.circular(1.5), + BorderRadius.circular(15.0) / 10.0, + BorderRadius.circular(1.5), ); expect( - new BorderRadius.circular(15.0) ~/ 10.0, - new BorderRadius.circular(1.0), + BorderRadius.circular(15.0) ~/ 10.0, + BorderRadius.circular(1.0), ); expect( - new BorderRadius.circular(15.0) % 10.0, - new BorderRadius.circular(5.0), + BorderRadius.circular(15.0) % 10.0, + BorderRadius.circular(5.0), ); }); test('BorderRadius.lerp() invariants', () { - final BorderRadius a = new BorderRadius.circular(10.0); - final BorderRadius b = new BorderRadius.circular(20.0); + final BorderRadius a = BorderRadius.circular(10.0); + final BorderRadius b = BorderRadius.circular(20.0); expect(BorderRadius.lerp(a, b, 0.25), equals(a * 1.25)); expect(BorderRadius.lerp(a, b, 0.25), equals(b * 0.625)); - expect(BorderRadius.lerp(a, b, 0.25), equals(a + new BorderRadius.circular(2.5))); - expect(BorderRadius.lerp(a, b, 0.25), equals(b - new BorderRadius.circular(7.5))); + expect(BorderRadius.lerp(a, b, 0.25), equals(a + BorderRadius.circular(2.5))); + expect(BorderRadius.lerp(a, b, 0.25), equals(b - BorderRadius.circular(7.5))); expect(BorderRadius.lerp(null, null, 0.25), isNull); expect(BorderRadius.lerp(null, b, 0.25), equals(b * 0.25)); @@ -162,7 +162,7 @@ void main() { }); test('BorderRadiusDirectional control test', () { - final Rect rect = new Rect.fromLTRB(19.0, 23.0, 29.0, 31.0); + final Rect rect = Rect.fromLTRB(19.0, 23.0, 29.0, 31.0); BorderRadiusDirectional borderRadius; borderRadius = const BorderRadiusDirectional.all(Radius.elliptical(5.0, 7.0)); @@ -171,17 +171,17 @@ void main() { expect(borderRadius.topEnd, const Radius.elliptical(5.0, 7.0)); expect(borderRadius.bottomStart, const Radius.elliptical(5.0, 7.0)); expect(borderRadius.bottomEnd, const Radius.elliptical(5.0, 7.0)); - expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), new RRect.fromRectXY(rect, 5.0, 7.0)); - expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), new RRect.fromRectXY(rect, 5.0, 7.0)); + expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), RRect.fromRectXY(rect, 5.0, 7.0)); + expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), RRect.fromRectXY(rect, 5.0, 7.0)); - borderRadius = new BorderRadiusDirectional.circular(3.0); + borderRadius = BorderRadiusDirectional.circular(3.0); expect(borderRadius, hasOneLineDescription); expect(borderRadius.topStart, const Radius.elliptical(3.0, 3.0)); expect(borderRadius.topEnd, const Radius.elliptical(3.0, 3.0)); expect(borderRadius.bottomStart, const Radius.elliptical(3.0, 3.0)); expect(borderRadius.bottomEnd, const Radius.elliptical(3.0, 3.0)); - expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), new RRect.fromRectXY(rect, 3.0, 3.0)); - expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), new RRect.fromRectXY(rect, 3.0, 3.0)); + expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), RRect.fromRectXY(rect, 3.0, 3.0)); + expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), RRect.fromRectXY(rect, 3.0, 3.0)); const Radius radius1 = Radius.elliptical(89.0, 87.0); const Radius radius2 = Radius.elliptical(103.0, 107.0); @@ -192,14 +192,14 @@ void main() { expect(borderRadius.topEnd, radius1); expect(borderRadius.bottomStart, radius2); expect(borderRadius.bottomEnd, radius2); - expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius1, topRight: radius1, bottomLeft: radius2, bottomRight: radius2, )); - expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius1, topRight: radius1, @@ -213,14 +213,14 @@ void main() { expect(borderRadius.topEnd, radius2); expect(borderRadius.bottomStart, radius1); expect(borderRadius.bottomEnd, radius2); - expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius1, topRight: radius2, bottomLeft: radius1, bottomRight: radius2, )); - expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius2, topRight: radius1, @@ -234,8 +234,8 @@ void main() { expect(borderRadius.topEnd, Radius.zero); expect(borderRadius.bottomStart, Radius.zero); expect(borderRadius.bottomEnd, Radius.zero); - expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), new RRect.fromRectAndCorners(rect)); - expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), new RRect.fromRectAndCorners(rect)); + expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), RRect.fromRectAndCorners(rect)); + expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), RRect.fromRectAndCorners(rect)); borderRadius = const BorderRadiusDirectional.only(topEnd: radius1, bottomEnd: radius2); expect(borderRadius, hasOneLineDescription); @@ -243,14 +243,14 @@ void main() { expect(borderRadius.topEnd, radius1); expect(borderRadius.bottomStart, Radius.zero); expect(borderRadius.bottomEnd, radius2); - expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.resolve(TextDirection.ltr).toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: Radius.zero, topRight: radius1, bottomLeft: Radius.zero, bottomRight: radius2, )); - expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), new RRect.fromRectAndCorners( + expect(borderRadius.resolve(TextDirection.rtl).toRRect(rect), RRect.fromRectAndCorners( rect, topLeft: radius1, topRight: Radius.zero, @@ -292,28 +292,28 @@ void main() { ); expect( - new BorderRadiusDirectional.circular(15.0) / 10.0, - new BorderRadiusDirectional.circular(1.5), + BorderRadiusDirectional.circular(15.0) / 10.0, + BorderRadiusDirectional.circular(1.5), ); expect( - new BorderRadiusDirectional.circular(15.0) ~/ 10.0, - new BorderRadiusDirectional.circular(1.0), + BorderRadiusDirectional.circular(15.0) ~/ 10.0, + BorderRadiusDirectional.circular(1.0), ); expect( - new BorderRadiusDirectional.circular(15.0) % 10.0, - new BorderRadiusDirectional.circular(5.0), + BorderRadiusDirectional.circular(15.0) % 10.0, + BorderRadiusDirectional.circular(5.0), ); }); test('BorderRadiusDirectional.lerp() invariants', () { - final BorderRadiusDirectional a = new BorderRadiusDirectional.circular(10.0); - final BorderRadiusDirectional b = new BorderRadiusDirectional.circular(20.0); + final BorderRadiusDirectional a = BorderRadiusDirectional.circular(10.0); + final BorderRadiusDirectional b = BorderRadiusDirectional.circular(20.0); expect(BorderRadiusDirectional.lerp(a, b, 0.25), equals(a * 1.25)); expect(BorderRadiusDirectional.lerp(a, b, 0.25), equals(b * 0.625)); - expect(BorderRadiusDirectional.lerp(a, b, 0.25), equals(a + new BorderRadiusDirectional.circular(2.5))); - expect(BorderRadiusDirectional.lerp(a, b, 0.25), equals(b - new BorderRadiusDirectional.circular(7.5))); + expect(BorderRadiusDirectional.lerp(a, b, 0.25), equals(a + BorderRadiusDirectional.circular(2.5))); + expect(BorderRadiusDirectional.lerp(a, b, 0.25), equals(b - BorderRadiusDirectional.circular(7.5))); expect(BorderRadiusDirectional.lerp(null, null, 0.25), isNull); expect(BorderRadiusDirectional.lerp(null, b, 0.25), equals(b * 0.25)); @@ -380,13 +380,13 @@ void main() { bottomStart: Radius.elliptical(120.0, 130.0), bottomEnd: Radius.elliptical(140.0, 150.0), ); - expect((a.subtract(b)).resolve(TextDirection.ltr), new BorderRadius.only( + expect((a.subtract(b)).resolve(TextDirection.ltr), BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0) - Radius.zero, topRight: const Radius.elliptical(30.0, 40.0) - const Radius.elliptical(100.0, 110.0), bottomLeft: const Radius.elliptical(50.0, 60.0) - const Radius.elliptical(120.0, 130.0), bottomRight: Radius.zero - const Radius.elliptical(140.0, 150.0), )); - expect((a.subtract(b)).resolve(TextDirection.rtl), new BorderRadius.only( + expect((a.subtract(b)).resolve(TextDirection.rtl), BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0) - const Radius.elliptical(100.0, 110.0), topRight: const Radius.elliptical(30.0, 40.0) - Radius.zero, bottomLeft: const Radius.elliptical(50.0, 60.0) - const Radius.elliptical(140.0, 150.0), @@ -405,13 +405,13 @@ void main() { bottomStart: Radius.elliptical(120.0, 130.0), bottomEnd: Radius.elliptical(140.0, 150.0), ); - expect((a.add(b)).resolve(TextDirection.ltr), new BorderRadius.only( + expect((a.add(b)).resolve(TextDirection.ltr), BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0) + Radius.zero, topRight: const Radius.elliptical(30.0, 40.0) + const Radius.elliptical(100.0, 110.0), bottomLeft: const Radius.elliptical(50.0, 60.0) + const Radius.elliptical(120.0, 130.0), bottomRight: Radius.zero + const Radius.elliptical(140.0, 150.0), )); - expect((a.add(b)).resolve(TextDirection.rtl), new BorderRadius.only( + expect((a.add(b)).resolve(TextDirection.rtl), BorderRadius.only( topLeft: const Radius.elliptical(10.0, 20.0) + const Radius.elliptical(100.0, 110.0), topRight: const Radius.elliptical(30.0, 40.0) + Radius.zero, bottomLeft: const Radius.elliptical(50.0, 60.0) + const Radius.elliptical(140.0, 150.0), @@ -430,13 +430,13 @@ void main() { bottomStart: Radius.elliptical(120.0, 130.0), bottomEnd: Radius.elliptical(140.0, 150.0), ); - expect((a.add(b) * 0.5).resolve(TextDirection.ltr), new BorderRadius.only( + expect((a.add(b) * 0.5).resolve(TextDirection.ltr), BorderRadius.only( topLeft: (const Radius.elliptical(10.0, 20.0) + Radius.zero) / 2.0, topRight: (const Radius.elliptical(30.0, 40.0) + const Radius.elliptical(100.0, 110.0)) / 2.0, bottomLeft: (const Radius.elliptical(50.0, 60.0) + const Radius.elliptical(120.0, 130.0)) / 2.0, bottomRight: (Radius.zero + const Radius.elliptical(140.0, 150.0)) / 2.0, )); - expect((a.add(b) * 0.5).resolve(TextDirection.rtl), new BorderRadius.only( + expect((a.add(b) * 0.5).resolve(TextDirection.rtl), BorderRadius.only( topLeft: (const Radius.elliptical(10.0, 20.0) + const Radius.elliptical(100.0, 110.0)) / 2.0, topRight: (const Radius.elliptical(30.0, 40.0) + Radius.zero) / 2.0, bottomLeft: (const Radius.elliptical(50.0, 60.0) + const Radius.elliptical(140.0, 150.0)) / 2.0, diff --git a/packages/flutter/test/painting/border_rtl_test.dart b/packages/flutter/test/painting/border_rtl_test.dart index a894fdb767..a80a02c4b8 100644 --- a/packages/flutter/test/painting/border_rtl_test.dart +++ b/packages/flutter/test/painting/border_rtl_test.dart @@ -43,8 +43,8 @@ void main() { const BoxBorder visualWithYellowTop5At75 = Border(top: BorderSide(color: Color(0xBFBFBF00), width: 3.75)); expect(BoxBorder.lerp(null, null, -1.0), null); - expect(BoxBorder.lerp(new Border.all(width: 10.0), null, -1.0), new Border.all(width: 20.0)); - expect(BoxBorder.lerp(null, new Border.all(width: 10.0), -1.0), new Border.all(width: 0.0, style: BorderStyle.none)); + expect(BoxBorder.lerp(Border.all(width: 10.0), null, -1.0), Border.all(width: 20.0)); + expect(BoxBorder.lerp(null, Border.all(width: 10.0), -1.0), Border.all(width: 0.0, style: BorderStyle.none)); expect(BoxBorder.lerp(directionalWithTop10, null, -1.0), const BorderDirectional(top: BorderSide(width: 20.0))); expect(BoxBorder.lerp(null, directionalWithTop10, -1.0), const BorderDirectional()); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, -1.0), const Border()); @@ -52,11 +52,11 @@ void main() { expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, -1.0), const Border(top: BorderSide(color: Color(0xFFFFFF00), width: 5.0))); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, -1.0), visualWithSides30); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, -1.0), directionalWithYellowTop10); - expect(() => BoxBorder.lerp(new SillyBorder(), const Border(), -1.0), throwsFlutterError); + expect(() => BoxBorder.lerp(SillyBorder(), const Border(), -1.0), throwsFlutterError); expect(BoxBorder.lerp(null, null, 0.0), null); - expect(BoxBorder.lerp(new Border.all(width: 10.0), null, 0.0), new Border.all(width: 10.0)); - expect(BoxBorder.lerp(null, new Border.all(width: 10.0), 0.0), const Border()); + expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.0), Border.all(width: 10.0)); + expect(BoxBorder.lerp(null, Border.all(width: 10.0), 0.0), const Border()); expect(BoxBorder.lerp(directionalWithTop10, null, 0.0), const BorderDirectional(top: BorderSide(width: 10.0))); expect(BoxBorder.lerp(null, directionalWithTop10, 0.0), const BorderDirectional()); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.0), visualWithTop10); @@ -64,35 +64,35 @@ void main() { expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.0), const Border(top: BorderSide(color: Color(0xFFFFFF00), width: 5.0))); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.0), visualWithSides10); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.0), directionalWithYellowTop5); - expect(() => BoxBorder.lerp(new SillyBorder(), const Border(), 0.0), throwsFlutterError); + expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.0), throwsFlutterError); expect(BoxBorder.lerp(null, null, 0.25), null); - expect(BoxBorder.lerp(new Border.all(width: 10.0), null, 0.25), new Border.all(width: 7.5)); - expect(BoxBorder.lerp(null, new Border.all(width: 10.0), 0.25), new Border.all(width: 2.5)); + expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.25), Border.all(width: 7.5)); + expect(BoxBorder.lerp(null, Border.all(width: 10.0), 0.25), Border.all(width: 2.5)); expect(BoxBorder.lerp(directionalWithTop10, null, 0.25), const BorderDirectional(top: BorderSide(width: 7.5))); expect(BoxBorder.lerp(null, directionalWithTop10, 0.25), const BorderDirectional(top: BorderSide(width: 2.5))); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.25), const Border(top: BorderSide(width: 32.5))); expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.25), visualWithSides10At75 + directionalWithMagentaTop5At25); - expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), new Border(top: new BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)))); + expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.25), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.25)))); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.25), visualWithSides10At50); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.25), visualWithYellowTop5At75 + directionalWithSides10At25); - expect(() => BoxBorder.lerp(new SillyBorder(), const Border(), 0.25), throwsFlutterError); + expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.25), throwsFlutterError); expect(BoxBorder.lerp(null, null, 0.75), null); - expect(BoxBorder.lerp(new Border.all(width: 10.0), null, 0.75), new Border.all(width: 2.5)); - expect(BoxBorder.lerp(null, new Border.all(width: 10.0), 0.75), new Border.all(width: 7.5)); + expect(BoxBorder.lerp(Border.all(width: 10.0), null, 0.75), Border.all(width: 2.5)); + expect(BoxBorder.lerp(null, Border.all(width: 10.0), 0.75), Border.all(width: 7.5)); expect(BoxBorder.lerp(directionalWithTop10, null, 0.75), const BorderDirectional(top: BorderSide(width: 2.5))); expect(BoxBorder.lerp(null, directionalWithTop10, 0.75), const BorderDirectional(top: BorderSide(width: 7.5))); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 0.75), const Border(top: BorderSide(width: 77.5))); expect(BoxBorder.lerp(visualWithSides10, directionalWithMagentaTop5, 0.75), visualWithSides10At25 + directionalWithMagentaTop5At75); - expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), new Border(top: new BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)))); + expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 0.75), Border(top: BorderSide(width: 5.0, color: Color.lerp(const Color(0xFFFFFF00), const Color(0xFFFF00FF), 0.75)))); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 0.75), directionalWithSides10At50); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 0.75), visualWithYellowTop5At25 + directionalWithSides10At75); - expect(() => BoxBorder.lerp(new SillyBorder(), const Border(), 0.75), throwsFlutterError); + expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 0.75), throwsFlutterError); expect(BoxBorder.lerp(null, null, 1.0), null); - expect(BoxBorder.lerp(new Border.all(width: 10.0), null, 1.0), new Border.all(width: 0.0, style: BorderStyle.none)); - expect(BoxBorder.lerp(null, new Border.all(width: 10.0), 1.0), new Border.all(width: 10.0)); + expect(BoxBorder.lerp(Border.all(width: 10.0), null, 1.0), Border.all(width: 0.0, style: BorderStyle.none)); + expect(BoxBorder.lerp(null, Border.all(width: 10.0), 1.0), Border.all(width: 10.0)); expect(BoxBorder.lerp(directionalWithTop10, null, 1.0), const BorderDirectional()); expect(BoxBorder.lerp(null, directionalWithTop10, 1.0), const BorderDirectional(top: BorderSide(width: 10.0))); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 1.0), visualWithTop100); @@ -100,11 +100,11 @@ void main() { expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 1.0), visualWithMagentaTop5); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 1.0), directionalWithSides10); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 1.0), directionalWithSides10); - expect(() => BoxBorder.lerp(new SillyBorder(), const Border(), 1.0), throwsFlutterError); + expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 1.0), throwsFlutterError); expect(BoxBorder.lerp(null, null, 2.0), null); - expect(BoxBorder.lerp(new Border.all(width: 10.0), null, 2.0), new Border.all(width: 0.0, style: BorderStyle.none)); - expect(BoxBorder.lerp(null, new Border.all(width: 10.0), 2.0), new Border.all(width: 20.0)); + expect(BoxBorder.lerp(Border.all(width: 10.0), null, 2.0), Border.all(width: 0.0, style: BorderStyle.none)); + expect(BoxBorder.lerp(null, Border.all(width: 10.0), 2.0), Border.all(width: 20.0)); expect(BoxBorder.lerp(directionalWithTop10, null, 2.0), const BorderDirectional()); expect(BoxBorder.lerp(null, directionalWithTop10, 2.0), const BorderDirectional(top: BorderSide(width: 20.0))); expect(BoxBorder.lerp(directionalWithTop10, visualWithTop100, 2.0), visualWithTop190); @@ -112,7 +112,7 @@ void main() { expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithMagentaTop5, 2.0), visualWithMagentaTop5); expect(BoxBorder.lerp(visualWithSides10, directionalWithSides10, 2.0), directionalWithSides30); expect(BoxBorder.lerp(visualWithYellowTop5, directionalWithSides10, 2.0), directionalWithSides20); - expect(() => BoxBorder.lerp(new SillyBorder(), const Border(), 2.0), throwsFlutterError); + expect(() => BoxBorder.lerp(SillyBorder(), const Border(), 2.0), throwsFlutterError); }); test('BoxBorder.getInnerPath / BoxBorder.getOuterPath', () { @@ -120,7 +120,7 @@ void main() { const Border border = Border(top: BorderSide(width: 10.0), right: BorderSide(width: 20.0)); const BorderDirectional borderDirectional = BorderDirectional(top: BorderSide(width: 10.0), end: BorderSide(width: 20.0)); expect( - border.getOuterPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), + border.getOuterPath(Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), isPathThat( includes: [ const Offset(50.0, 60.0), @@ -146,7 +146,7 @@ void main() { ), ); expect( - border.getInnerPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), + border.getInnerPath(Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), // inner path is a rect from 50.0,70.0 to 90.0,190.0 isPathThat( includes: [ @@ -184,7 +184,7 @@ void main() { ) ); expect( - borderDirectional.getOuterPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), + borderDirectional.getOuterPath(Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), isPathThat( includes: [ const Offset(50.0, 60.0), @@ -210,7 +210,7 @@ void main() { ), ); expect( - borderDirectional.getInnerPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), + borderDirectional.getInnerPath(Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.rtl), // inner path is a rect from 70.0,70.0 to 110.0,190.0 isPathThat( includes: [ @@ -251,7 +251,7 @@ void main() { ), ); expect( - borderDirectional.getOuterPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.ltr), + borderDirectional.getOuterPath(Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.ltr), isPathThat( includes: [ const Offset(50.0, 60.0), @@ -277,7 +277,7 @@ void main() { ), ); expect( - borderDirectional.getInnerPath(new Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.ltr), + borderDirectional.getInnerPath(Rect.fromLTRB(50.0, 60.0, 110.0, 190.0), textDirection: TextDirection.ltr), // inner path is a rect from 50.0,70.0 to 90.0,190.0 isPathThat( includes: [ @@ -317,10 +317,10 @@ void main() { }); test('BorderDirectional constructor', () { - expect(() => new BorderDirectional(top: nonconst(null)), throwsAssertionError); - expect(() => new BorderDirectional(start: nonconst(null)), throwsAssertionError); - expect(() => new BorderDirectional(end: nonconst(null)), throwsAssertionError); - expect(() => new BorderDirectional(bottom: nonconst(null)), throwsAssertionError); + expect(() => BorderDirectional(top: nonconst(null)), throwsAssertionError); + expect(() => BorderDirectional(start: nonconst(null)), throwsAssertionError); + expect(() => BorderDirectional(end: nonconst(null)), throwsAssertionError); + expect(() => BorderDirectional(bottom: nonconst(null)), throwsAssertionError); }); test('BorderDirectional.merge', () { @@ -590,7 +590,7 @@ void main() { expect( (Canvas canvas) { const BorderDirectional(end: BorderSide(width: 10.0, color: Color(0xFF00FF00))) - .paint(canvas, new Rect.fromLTRB(10.0, 20.0, 30.0, 40.0), textDirection: TextDirection.rtl); + .paint(canvas, Rect.fromLTRB(10.0, 20.0, 30.0, 40.0), textDirection: TextDirection.rtl); }, paints ..path( @@ -602,7 +602,7 @@ void main() { expect( (Canvas canvas) { const BorderDirectional(end: BorderSide(width: 10.0, color: Color(0xFF00FF00))) - .paint(canvas, new Rect.fromLTRB(10.0, 20.0, 30.0, 40.0), textDirection: TextDirection.ltr); + .paint(canvas, Rect.fromLTRB(10.0, 20.0, 30.0, 40.0), textDirection: TextDirection.ltr); }, paints ..path( @@ -614,16 +614,16 @@ void main() { expect( (Canvas canvas) { const BorderDirectional(end: BorderSide(width: 10.0, color: Color(0xFF00FF00))) - .paint(canvas, new Rect.fromLTRB(10.0, 20.0, 30.0, 40.0)); + .paint(canvas, Rect.fromLTRB(10.0, 20.0, 30.0, 40.0)); }, paintsAssertion // no TextDirection ); }); test('BorderDirectional hashCode', () { - final BorderSide side = new BorderSide(width: nonconst(2.0)); - expect(new BorderDirectional(top: side).hashCode, new BorderDirectional(top: side).hashCode); - expect(new BorderDirectional(top: side).hashCode, isNot(new BorderDirectional(bottom: side).hashCode)); + final BorderSide side = BorderSide(width: nonconst(2.0)); + expect(BorderDirectional(top: side).hashCode, BorderDirectional(top: side).hashCode); + expect(BorderDirectional(top: side).hashCode, isNot(BorderDirectional(bottom: side).hashCode)); }); test('BoxDecoration.border takes a BorderDirectional', () { diff --git a/packages/flutter/test/painting/border_side_test.dart b/packages/flutter/test/painting/border_side_test.dart index 63f8854269..028ae77404 100644 --- a/packages/flutter/test/painting/border_side_test.dart +++ b/packages/flutter/test/painting/border_side_test.dart @@ -15,10 +15,10 @@ void main() { style: BorderStyle.solid, ), ); - expect(() => new BorderSide(color: nonconst(null)), throwsAssertionError); - expect(() => new BorderSide(width: nonconst(null)), throwsAssertionError); - expect(() => new BorderSide(style: nonconst(null)), throwsAssertionError); - expect(() => new BorderSide(width: nonconst(-1.0)), throwsAssertionError); + expect(() => BorderSide(color: nonconst(null)), throwsAssertionError); + expect(() => BorderSide(width: nonconst(null)), throwsAssertionError); + expect(() => BorderSide(style: nonconst(null)), throwsAssertionError); + expect(() => BorderSide(width: nonconst(-1.0)), throwsAssertionError); expect( const BorderSide(width: -0.0), const BorderSide( diff --git a/packages/flutter/test/painting/border_test.dart b/packages/flutter/test/painting/border_test.dart index 9456c6f5d1..6cc94bf688 100644 --- a/packages/flutter/test/painting/border_test.dart +++ b/packages/flutter/test/painting/border_test.dart @@ -7,10 +7,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('Border constructor', () { - expect(() => new Border(left: nonconst(null)), throwsAssertionError); - expect(() => new Border(top: nonconst(null)), throwsAssertionError); - expect(() => new Border(right: nonconst(null)), throwsAssertionError); - expect(() => new Border(bottom: nonconst(null)), throwsAssertionError); + expect(() => Border(left: nonconst(null)), throwsAssertionError); + expect(() => Border(top: nonconst(null)), throwsAssertionError); + expect(() => Border(right: nonconst(null)), throwsAssertionError); + expect(() => Border(bottom: nonconst(null)), throwsAssertionError); }); test('Border.merge', () { diff --git a/packages/flutter/test/painting/box_decoration_test.dart b/packages/flutter/test/painting/box_decoration_test.dart index 79d25e84cf..2906be3221 100644 --- a/packages/flutter/test/painting/box_decoration_test.dart +++ b/packages/flutter/test/painting/box_decoration_test.dart @@ -24,7 +24,7 @@ void main() { ); }, paints - ..rrect(rrect: new RRect.fromRectAndCorners(Offset.zero & size, topRight: const Radius.circular(100.0))) + ..rrect(rrect: RRect.fromRectAndCorners(Offset.zero & size, topRight: const Radius.circular(100.0))) ); expect(decoration.hitTest(size, const Offset(10.0, 10.0), textDirection: TextDirection.rtl), isTrue); expect(decoration.hitTest(size, const Offset(990.0, 10.0), textDirection: TextDirection.rtl), isFalse); @@ -37,7 +37,7 @@ void main() { ); }, paints - ..rrect(rrect: new RRect.fromRectAndCorners(Offset.zero & size, topLeft: const Radius.circular(100.0))) + ..rrect(rrect: RRect.fromRectAndCorners(Offset.zero & size, topLeft: const Radius.circular(100.0))) ); expect(decoration.hitTest(size, const Offset(10.0, 10.0), textDirection: TextDirection.ltr), isFalse); expect(decoration.hitTest(size, const Offset(990.0, 10.0), textDirection: TextDirection.ltr), isTrue); diff --git a/packages/flutter/test/painting/box_painter_test.dart b/packages/flutter/test/painting/box_painter_test.dart index a04325f63a..a5e7d48b32 100644 --- a/packages/flutter/test/painting/box_painter_test.dart +++ b/packages/flutter/test/painting/box_painter_test.dart @@ -23,7 +23,7 @@ void main() { expect(BorderSide.lerp(side1, side2, 0.0), equals(side1)); expect(BorderSide.lerp(side1, side2, 1.0), equals(side2)); - expect(BorderSide.lerp(side1, side2, 0.5), equals(new BorderSide( + expect(BorderSide.lerp(side1, side2, 0.5), equals(BorderSide( color: Color.lerp(const Color(0xFF000000), const Color(0xFF00FFFF), 0.5), width: 1.5, style: BorderStyle.solid, @@ -52,7 +52,7 @@ void main() { }); test('Border control test', () { - final Border border1 = new Border.all(width: 4.0); + final Border border1 = Border.all(width: 4.0); final Border border2 = Border.lerp(null, border1, 0.25); final Border border3 = Border.lerp(border1, null, 0.25); @@ -68,7 +68,7 @@ void main() { test('Border toString test', () { expect( - new Border.all(width: 4.0).toString(), + Border.all(width: 4.0).toString(), equals( 'Border.all(BorderSide(Color(0xff000000), 4.0, BorderStyle.solid))', ), diff --git a/packages/flutter/test/painting/circle_border_test.dart b/packages/flutter/test/painting/circle_border_test.dart index 3719f3dfd0..6cb4d4b2d1 100644 --- a/packages/flutter/test/painting/circle_border_test.dart +++ b/packages/flutter/test/painting/circle_border_test.dart @@ -19,10 +19,10 @@ void main() { expect(ShapeBorder.lerp(c10, c20, 0.0), c10); expect(ShapeBorder.lerp(c10, c20, 0.5), c15); expect(ShapeBorder.lerp(c10, c20, 1.0), c20); - expect(c10.getInnerPath(new Rect.fromCircle(center: Offset.zero, radius: 1.0).inflate(10.0)), isUnitCircle); - expect(c10.getOuterPath(new Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); + expect(c10.getInnerPath(Rect.fromCircle(center: Offset.zero, radius: 1.0).inflate(10.0)), isUnitCircle); + expect(c10.getOuterPath(Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); expect( - (Canvas canvas) => c10.paint(canvas, new Rect.fromLTWH(10.0, 20.0, 30.0, 40.0)), + (Canvas canvas) => c10.paint(canvas, Rect.fromLTWH(10.0, 20.0, 30.0, 40.0)), paints ..circle(x: 25.0, y: 40.0, radius: 10.0, strokeWidth: 10.0) ); diff --git a/packages/flutter/test/painting/colors_test.dart b/packages/flutter/test/painting/colors_test.dart index 65445366cd..5a92f69b64 100644 --- a/packages/flutter/test/painting/colors_test.dart +++ b/packages/flutter/test/painting/colors_test.dart @@ -32,13 +32,13 @@ void main() { test('HSVColor hue sweep test', () { final List output = []; for (double hue = 0.0; hue <= 360.0; hue += 36.0) { - final HSVColor hsvColor = new HSVColor.fromAHSV(1.0, hue, 1.0, 1.0); + final HSVColor hsvColor = HSVColor.fromAHSV(1.0, hue, 1.0, 1.0); final Color color = hsvColor.toColor(); output.add(color); if (hue != 360.0) { // Check that it's reversible. expect( - new HSVColor.fromColor(color), + HSVColor.fromColor(color), within(distance: _doubleColorPrecision, from: hsvColor), ); } @@ -62,12 +62,12 @@ void main() { test('HSVColor saturation sweep test', () { final List output = []; for (double saturation = 0.0; saturation < 1.0; saturation += 0.1) { - final HSVColor hslColor = new HSVColor.fromAHSV(1.0, 0.0, saturation, 1.0); + final HSVColor hslColor = HSVColor.fromAHSV(1.0, 0.0, saturation, 1.0); final Color color = hslColor.toColor(); output.add(color); // Check that it's reversible. expect( - new HSVColor.fromColor(color), + HSVColor.fromColor(color), within(distance: _doubleColorPrecision, from: hslColor), ); } @@ -90,14 +90,14 @@ void main() { test('HSVColor value sweep test', () { final List output = []; for (double value = 0.0; value < 1.0; value += 0.1) { - final HSVColor hsvColor = new HSVColor.fromAHSV(1.0, 0.0, 1.0, value); + final HSVColor hsvColor = HSVColor.fromAHSV(1.0, 0.0, 1.0, value); final Color color = hsvColor.toColor(); output.add(color); // Check that it's reversible. Discontinuities at the ends for saturation, // so we skip those. if (value >= _doubleColorPrecision && value <= (1.0 - _doubleColorPrecision)) { expect( - new HSVColor.fromColor(color), + HSVColor.fromColor(color), within(distance: _doubleColorPrecision, from: hsvColor), ); } @@ -228,13 +228,13 @@ void main() { test('HSLColor hue sweep test', () { final List output = []; for (double hue = 0.0; hue <= 360.0; hue += 36.0) { - final HSLColor hslColor = new HSLColor.fromAHSL(1.0, hue, 0.5, 0.5); + final HSLColor hslColor = HSLColor.fromAHSL(1.0, hue, 0.5, 0.5); final Color color = hslColor.toColor(); output.add(color); if (hue != 360.0) { // Check that it's reversible. expect( - new HSLColor.fromColor(color), + HSLColor.fromColor(color), within(distance: _doubleColorPrecision, from: hslColor), ); } @@ -258,12 +258,12 @@ void main() { test('HSLColor saturation sweep test', () { final List output = []; for (double saturation = 0.0; saturation < 1.0; saturation += 0.1) { - final HSLColor hslColor = new HSLColor.fromAHSL(1.0, 0.0, saturation, 0.5); + final HSLColor hslColor = HSLColor.fromAHSL(1.0, 0.0, saturation, 0.5); final Color color = hslColor.toColor(); output.add(color); // Check that it's reversible. expect( - new HSLColor.fromColor(color), + HSLColor.fromColor(color), within(distance: _doubleColorPrecision, from: hslColor), ); } @@ -286,14 +286,14 @@ void main() { test('HSLColor lightness sweep test', () { final List output = []; for (double lightness = 0.0; lightness < 1.0; lightness += 0.1) { - final HSLColor hslColor = new HSLColor.fromAHSL(1.0, 0.0, 0.5, lightness); + final HSLColor hslColor = HSLColor.fromAHSL(1.0, 0.0, 0.5, lightness); final Color color = hslColor.toColor(); output.add(color); // Check that it's reversible. Discontinuities at the ends for saturation, // so we skip those. if (lightness >= _doubleColorPrecision && lightness <= (1.0 - _doubleColorPrecision)) { expect( - new HSLColor.fromColor(color), + HSLColor.fromColor(color), within(distance: _doubleColorPrecision, from: hslColor), ); } @@ -401,7 +401,7 @@ void main() { test('ColorSwatch test', () { final int color = nonconst(0xFF027223); - final ColorSwatch greens1 = new ColorSwatch( + final ColorSwatch greens1 = ColorSwatch( color, const { '2259 C': Color(0xFF027223), @@ -410,7 +410,7 @@ void main() { '7732 XGC': Color(0xFF007940), }, ); - final ColorSwatch greens2 = new ColorSwatch( + final ColorSwatch greens2 = ColorSwatch( color, const { '2259 C': Color(0xFF027223), diff --git a/packages/flutter/test/painting/decoration_test.dart b/packages/flutter/test/painting/decoration_test.dart index 1c0dd12620..b05189cf9c 100644 --- a/packages/flutter/test/painting/decoration_test.dart +++ b/packages/flutter/test/painting/decoration_test.dart @@ -28,13 +28,13 @@ class TestCanvas implements Canvas { class SynchronousTestImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(1); + return SynchronousFuture(1); } @override ImageStreamCompleter load(int key) { - return new OneFrameImageStreamCompleter( - new SynchronousFuture(new TestImageInfo(key, image: new TestImage(), scale: 1.0)) + return OneFrameImageStreamCompleter( + SynchronousFuture(TestImageInfo(key, image: TestImage(), scale: 1.0)) ); } } @@ -42,23 +42,23 @@ class SynchronousTestImageProvider extends ImageProvider { class AsyncTestImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new Future.value(2); + return Future.value(2); } @override ImageStreamCompleter load(int key) { - return new OneFrameImageStreamCompleter( - new Future.value(new TestImageInfo(key)) + return OneFrameImageStreamCompleter( + Future.value(TestImageInfo(key)) ); } } class DelayedImageProvider extends ImageProvider { - final Completer _completer = new Completer(); + final Completer _completer = Completer(); @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override @@ -68,11 +68,11 @@ class DelayedImageProvider extends ImageProvider { @override ImageStreamCompleter load(DelayedImageProvider key) { - return new OneFrameImageStreamCompleter(_completer.future); + return OneFrameImageStreamCompleter(_completer.future); } void complete() { - _completer.complete(new ImageInfo(image: new TestImage())); + _completer.complete(ImageInfo(image: TestImage())); } @override @@ -91,12 +91,12 @@ class TestImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } } void main() { - new TestRenderingFlutterBinding(); // initializes the imageCache + TestRenderingFlutterBinding(); // initializes the imageCache test('Decoration.lerp()', () { const BoxDecoration a = BoxDecoration(color: Color(0xFFFFFFFF)); @@ -113,16 +113,16 @@ void main() { }); test('BoxDecorationImageListenerSync', () { - final ImageProvider imageProvider = new SynchronousTestImageProvider(); - final DecorationImage backgroundImage = new DecorationImage(image: imageProvider); + final ImageProvider imageProvider = SynchronousTestImageProvider(); + final DecorationImage backgroundImage = DecorationImage(image: imageProvider); - final BoxDecoration boxDecoration = new BoxDecoration(image: backgroundImage); + final BoxDecoration boxDecoration = BoxDecoration(image: backgroundImage); bool onChangedCalled = false; final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { onChangedCalled = true; }); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); const ImageConfiguration imageConfiguration = ImageConfiguration(size: Size.zero); boxPainter.paint(canvas, Offset.zero, imageConfiguration); @@ -131,17 +131,17 @@ void main() { }); test('BoxDecorationImageListenerAsync', () { - new FakeAsync().run((FakeAsync async) { - final ImageProvider imageProvider = new AsyncTestImageProvider(); - final DecorationImage backgroundImage = new DecorationImage(image: imageProvider); + FakeAsync().run((FakeAsync async) { + final ImageProvider imageProvider = AsyncTestImageProvider(); + final DecorationImage backgroundImage = DecorationImage(image: imageProvider); - final BoxDecoration boxDecoration = new BoxDecoration(image: backgroundImage); + final BoxDecoration boxDecoration = BoxDecoration(image: backgroundImage); bool onChangedCalled = false; final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { onChangedCalled = true; }); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); const ImageConfiguration imageConfiguration = ImageConfiguration(size: Size.zero); boxPainter.paint(canvas, Offset.zero, imageConfiguration); @@ -157,18 +157,18 @@ void main() { test('BoxDecoration backgroundImage clip', () { void testDecoration({ BoxShape shape = BoxShape.rectangle, BorderRadius borderRadius, bool expectClip}) { assert(shape != null); - new FakeAsync().run((FakeAsync async) { - final DelayedImageProvider imageProvider = new DelayedImageProvider(); - final DecorationImage backgroundImage = new DecorationImage(image: imageProvider); + FakeAsync().run((FakeAsync async) { + final DelayedImageProvider imageProvider = DelayedImageProvider(); + final DecorationImage backgroundImage = DecorationImage(image: imageProvider); - final BoxDecoration boxDecoration = new BoxDecoration( + final BoxDecoration boxDecoration = BoxDecoration( shape: shape, borderRadius: borderRadius, image: backgroundImage, ); final List invocations = []; - final TestCanvas canvas = new TestCanvas(invocations); + final TestCanvas canvas = TestCanvas(invocations); const ImageConfiguration imageConfiguration = ImageConfiguration( size: Size(100.0, 100.0) ); @@ -210,26 +210,26 @@ void main() { test('DecorationImage test', () { const ColorFilter colorFilter = ui.ColorFilter.mode(Color(0xFF00FF00), BlendMode.src); - final DecorationImage backgroundImage = new DecorationImage( - image: new SynchronousTestImageProvider(), + final DecorationImage backgroundImage = DecorationImage( + image: SynchronousTestImageProvider(), colorFilter: colorFilter, fit: BoxFit.contain, alignment: Alignment.bottomLeft, - centerSlice: new Rect.fromLTWH(10.0, 20.0, 30.0, 40.0), + centerSlice: Rect.fromLTWH(10.0, 20.0, 30.0, 40.0), repeat: ImageRepeat.repeatY, ); - final BoxDecoration boxDecoration = new BoxDecoration(image: backgroundImage); + final BoxDecoration boxDecoration = BoxDecoration(image: backgroundImage); final BoxPainter boxPainter = boxDecoration.createBoxPainter(() { assert(false); }); - final TestCanvas canvas = new TestCanvas([]); + final TestCanvas canvas = TestCanvas([]); boxPainter.paint(canvas, Offset.zero, const ImageConfiguration(size: Size(100.0, 100.0))); final Invocation call = canvas.invocations.singleWhere((Invocation call) => call.memberName == #drawImageNine); expect(call.isMethod, isTrue); expect(call.positionalArguments, hasLength(4)); expect(call.positionalArguments[0], isInstanceOf()); - expect(call.positionalArguments[1], new Rect.fromLTRB(10.0, 20.0, 40.0, 60.0)); - expect(call.positionalArguments[2], new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)); + expect(call.positionalArguments[1], Rect.fromLTRB(10.0, 20.0, 40.0, 60.0)); + expect(call.positionalArguments[2], Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)); expect(call.positionalArguments[3], isInstanceOf()); expect(call.positionalArguments[3].isAntiAlias, false); expect(call.positionalArguments[3].colorFilter, colorFilter); @@ -350,10 +350,10 @@ void main() { test('paintImage BoxFit.none scale test', () { for (double scale = 1.0; scale <= 4.0; scale += 1.0) { - final TestCanvas canvas = new TestCanvas([]); + final TestCanvas canvas = TestCanvas([]); - final Rect outputRect = new Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); - final ui.Image image = new TestImage(); + final Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); + final ui.Image image = TestImage(); paintImage( canvas: canvas, @@ -381,7 +381,7 @@ void main() { // Image should be scaled down (divided by scale) // and be positioned in the bottom right of the outputRect final Size expectedTileSize = imageSize / scale; - final Rect expectedTileRect = new Rect.fromPoints( + final Rect expectedTileRect = Rect.fromPoints( outputRect.bottomRight.translate(-expectedTileSize.width, -expectedTileSize.height), outputRect.bottomRight, ); @@ -393,11 +393,11 @@ void main() { test('paintImage BoxFit.scaleDown scale test', () { for (double scale = 1.0; scale <= 4.0; scale += 1.0) { - final TestCanvas canvas = new TestCanvas([]); + final TestCanvas canvas = TestCanvas([]); // container size > scaled image size - final Rect outputRect = new Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); - final ui.Image image = new TestImage(); + final Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); + final ui.Image image = TestImage(); paintImage( canvas: canvas, @@ -425,7 +425,7 @@ void main() { // Image should be scaled down (divided by scale) // and be positioned in the bottom right of the outputRect final Size expectedTileSize = imageSize / scale; - final Rect expectedTileRect = new Rect.fromPoints( + final Rect expectedTileRect = Rect.fromPoints( outputRect.bottomRight.translate(-expectedTileSize.width, -expectedTileSize.height), outputRect.bottomRight, ); @@ -436,11 +436,11 @@ void main() { }); test('paintImage BoxFit.scaleDown test', () { - final TestCanvas canvas = new TestCanvas([]); + final TestCanvas canvas = TestCanvas([]); // container height (20 px) < scaled image height (50 px) - final Rect outputRect = new Rect.fromLTWH(30.0, 30.0, 250.0, 20.0); - final ui.Image image = new TestImage(); + final Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 20.0); + final ui.Image image = TestImage(); paintImage( canvas: canvas, @@ -468,7 +468,7 @@ void main() { // Image should be scaled down to fit in hejght // and be positioned in the bottom right of the outputRect const Size expectedTileSize = Size(20.0, 20.0); - final Rect expectedTileRect = new Rect.fromPoints( + final Rect expectedTileRect = Rect.fromPoints( outputRect.bottomRight.translate(-expectedTileSize.width, -expectedTileSize.height), outputRect.bottomRight, ); @@ -489,10 +489,10 @@ void main() { ]; for(BoxFit boxFit in boxFits) { - final TestCanvas canvas = new TestCanvas([]); + final TestCanvas canvas = TestCanvas([]); - final Rect outputRect = new Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); - final ui.Image image = new TestImage(); + final Rect outputRect = Rect.fromLTWH(30.0, 30.0, 250.0, 250.0); + final ui.Image image = TestImage(); paintImage( canvas: canvas, diff --git a/packages/flutter/test/painting/edge_insets_test.dart b/packages/flutter/test/painting/edge_insets_test.dart index b978b8aaad..76c43438dd 100644 --- a/packages/flutter/test/painting/edge_insets_test.dart +++ b/packages/flutter/test/painting/edge_insets_test.dart @@ -23,11 +23,11 @@ void main() { expect(insets.along(Axis.horizontal), equals(16.0)); expect(insets.along(Axis.vertical), equals(20.0)); - expect(insets.inflateRect(new Rect.fromLTRB(23.0, 32.0, 124.0, 143.0)), - new Rect.fromLTRB(18.0, 25.0, 135.0, 156.0)); + expect(insets.inflateRect(Rect.fromLTRB(23.0, 32.0, 124.0, 143.0)), + Rect.fromLTRB(18.0, 25.0, 135.0, 156.0)); - expect(insets.deflateRect(new Rect.fromLTRB(23.0, 32.0, 124.0, 143.0)), - new Rect.fromLTRB(28.0, 39.0, 113.0, 130.0)); + expect(insets.deflateRect(Rect.fromLTRB(23.0, 32.0, 124.0, 143.0)), + Rect.fromLTRB(28.0, 39.0, 113.0, 130.0)); expect(insets.inflateSize(const Size(100.0, 125.0)), const Size(116.0, 145.0)); expect(insets.deflateSize(const Size(100.0, 125.0)), const Size(84.0, 105.0)); @@ -62,7 +62,7 @@ void main() { expect(const EdgeInsetsDirectional.only(top: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 963.25, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(end: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(963.25, 0.0, 0.0, 0.0)); expect(const EdgeInsetsDirectional.only(bottom: 963.25).resolve(TextDirection.rtl), const EdgeInsets.fromLTRB(0.0, 0.0, 0.0, 963.25)); - expect(new EdgeInsetsDirectional.only(), new EdgeInsetsDirectional.only()); // ignore: prefer_const_constructors + expect(EdgeInsetsDirectional.only(), EdgeInsetsDirectional.only()); // ignore: prefer_const_constructors expect(const EdgeInsetsDirectional.only(top: 1.0), isNot(const EdgeInsetsDirectional.only(bottom: 1.0))); expect(const EdgeInsetsDirectional.fromSTEB(10.0, 20.0, 30.0, 40.0).resolve(TextDirection.ltr), const EdgeInsetsDirectional.fromSTEB(30.0, 20.0, 10.0, 40.0).resolve(TextDirection.rtl)); @@ -74,18 +74,18 @@ void main() { test('EdgeInsets equality', () { final double $5 = nonconst(5.0); - expect(new EdgeInsetsDirectional.only(top: $5, bottom: 7.0), new EdgeInsetsDirectional.only(top: $5, bottom: 7.0)); - expect(new EdgeInsets.only(top: $5, bottom: 7.0), new EdgeInsetsDirectional.only(top: $5, bottom: 7.0)); - expect(new EdgeInsetsDirectional.only(top: $5, bottom: 7.0), new EdgeInsets.only(top: $5, bottom: 7.0)); - expect(new EdgeInsets.only(top: $5, bottom: 7.0), new EdgeInsets.only(top: $5, bottom: 7.0)); - expect(new EdgeInsetsDirectional.only(start: $5), new EdgeInsetsDirectional.only(start: $5)); + expect(EdgeInsetsDirectional.only(top: $5, bottom: 7.0), EdgeInsetsDirectional.only(top: $5, bottom: 7.0)); + expect(EdgeInsets.only(top: $5, bottom: 7.0), EdgeInsetsDirectional.only(top: $5, bottom: 7.0)); + expect(EdgeInsetsDirectional.only(top: $5, bottom: 7.0), EdgeInsets.only(top: $5, bottom: 7.0)); + expect(EdgeInsets.only(top: $5, bottom: 7.0), EdgeInsets.only(top: $5, bottom: 7.0)); + expect(EdgeInsetsDirectional.only(start: $5), EdgeInsetsDirectional.only(start: $5)); expect(const EdgeInsets.only(left: 5.0), isNot(const EdgeInsetsDirectional.only(start: 5.0))); expect(const EdgeInsetsDirectional.only(start: 5.0), isNot(const EdgeInsets.only(left: 5.0))); - expect(new EdgeInsets.only(left: $5), new EdgeInsets.only(left: $5)); - expect(new EdgeInsetsDirectional.only(end: $5), new EdgeInsetsDirectional.only(end: $5)); + expect(EdgeInsets.only(left: $5), EdgeInsets.only(left: $5)); + expect(EdgeInsetsDirectional.only(end: $5), EdgeInsetsDirectional.only(end: $5)); expect(const EdgeInsets.only(right: 5.0), isNot(const EdgeInsetsDirectional.only(end: 5.0))); expect(const EdgeInsetsDirectional.only(end: 5.0), isNot(const EdgeInsets.only(right: 5.0))); - expect(new EdgeInsets.only(right: $5), new EdgeInsets.only(right: $5)); + expect(EdgeInsets.only(right: $5), EdgeInsets.only(right: $5)); expect(const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(right: 5.0)), const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(right: 5.0))); expect(const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(right: 5.0)), isNot(const EdgeInsetsDirectional.only(end: 5.0).add(const EdgeInsets.only(left: 5.0)))); expect(const EdgeInsetsDirectional.only(top: 1.0).add(const EdgeInsets.only(top: 2.0)), const EdgeInsetsDirectional.only(top: 3.0).add(const EdgeInsets.only(top: 0.0))); diff --git a/packages/flutter/test/painting/fake_codec.dart b/packages/flutter/test/painting/fake_codec.dart index 0dd877fd1c..3ea014bb82 100644 --- a/packages/flutter/test/painting/fake_codec.dart +++ b/packages/flutter/test/painting/fake_codec.dart @@ -27,10 +27,10 @@ class FakeCodec implements ui.Codec { static Future fromData(Uint8List data) async { final ui.Codec codec = await ui.instantiateImageCodec(data); final int frameCount = codec.frameCount; - final List frameInfos = new List(frameCount); + final List frameInfos = List(frameCount); for (int i = 0; i < frameCount; i += 1) frameInfos[i] = await codec.getNextFrame(); - return new FakeCodec._(frameCount, codec.repetitionCount, frameInfos); + return FakeCodec._(frameCount, codec.repetitionCount, frameInfos); } @override @@ -42,7 +42,7 @@ class FakeCodec implements ui.Codec { @override Future getNextFrame() { final SynchronousFuture result = - new SynchronousFuture(_frameInfos[_nextFrame]); + SynchronousFuture(_frameInfos[_nextFrame]); _nextFrame = (_nextFrame + 1) % _frameCount; return result; } diff --git a/packages/flutter/test/painting/fake_image_provider.dart b/packages/flutter/test/painting/fake_image_provider.dart index 1aa1521259..c7d64891b1 100644 --- a/packages/flutter/test/painting/fake_image_provider.dart +++ b/packages/flutter/test/painting/fake_image_provider.dart @@ -22,14 +22,14 @@ class FakeImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(FakeImageProvider key) { assert(key == this); - return new MultiFrameImageStreamCompleter( - codec: new SynchronousFuture(_codec), + return MultiFrameImageStreamCompleter( + codec: SynchronousFuture(_codec), scale: scale ); } diff --git a/packages/flutter/test/painting/flutter_logo_test.dart b/packages/flutter/test/painting/flutter_logo_test.dart index 0758a69897..5591697306 100644 --- a/packages/flutter/test/painting/flutter_logo_test.dart +++ b/packages/flutter/test/painting/flutter_logo_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/painting.dart'; void main() { // Here and below, see: https://github.com/dart-lang/sdk/issues/26980 // ignore: prefer_const_constructors - final FlutterLogoDecoration start = new FlutterLogoDecoration( + final FlutterLogoDecoration start = FlutterLogoDecoration( lightColor: const Color(0xFF000000), darkColor: const Color(0xFFFFFFFF), textColor: const Color(0xFFD4F144), @@ -17,7 +17,7 @@ void main() { ); // ignore: prefer_const_constructors - final FlutterLogoDecoration end = new FlutterLogoDecoration( + final FlutterLogoDecoration end = FlutterLogoDecoration( lightColor: const Color(0xFFFFFFFF), darkColor: const Color(0xFF000000), textColor: const Color(0xFF81D4FA), diff --git a/packages/flutter/test/painting/fractional_offset_test.dart b/packages/flutter/test/painting/fractional_offset_test.dart index c184a89b9d..584a11fb63 100644 --- a/packages/flutter/test/painting/fractional_offset_test.dart +++ b/packages/flutter/test/painting/fractional_offset_test.dart @@ -34,12 +34,12 @@ void main() { }); test('FractionalOffset.fromOffsetAndSize()', () { - final FractionalOffset a = new FractionalOffset.fromOffsetAndSize(const Offset(100.0, 100.0), const Size(200.0, 400.0)); + final FractionalOffset a = FractionalOffset.fromOffsetAndSize(const Offset(100.0, 100.0), const Size(200.0, 400.0)); expect(a, const FractionalOffset(0.5, 0.25)); }); test('FractionalOffset.fromOffsetAndRect()', () { - final FractionalOffset a = new FractionalOffset.fromOffsetAndRect(const Offset(150.0, 120.0), new Rect.fromLTWH(50.0, 20.0, 200.0, 400.0)); + final FractionalOffset a = FractionalOffset.fromOffsetAndRect(const Offset(150.0, 120.0), Rect.fromLTWH(50.0, 20.0, 200.0, 400.0)); expect(a, const FractionalOffset(0.5, 0.25)); }); } diff --git a/packages/flutter/test/painting/gradient_test.dart b/packages/flutter/test/painting/gradient_test.dart index 3da6c3148b..f9eb55e97b 100644 --- a/packages/flutter/test/painting/gradient_test.dart +++ b/packages/flutter/test/painting/gradient_test.dart @@ -122,7 +122,7 @@ void main() { return const LinearGradient( begin: AlignmentDirectional.topStart, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); }, throwsAssertionError, ); @@ -131,7 +131,7 @@ void main() { return const LinearGradient( begin: AlignmentDirectional.topStart, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.rtl); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.rtl); }, returnsNormally, ); @@ -140,7 +140,7 @@ void main() { return const LinearGradient( begin: AlignmentDirectional.topStart, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr); }, returnsNormally, ); @@ -149,7 +149,7 @@ void main() { return const LinearGradient( begin: Alignment.topLeft, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); }, returnsNormally, ); @@ -161,7 +161,7 @@ void main() { return const RadialGradient( center: AlignmentDirectional.topStart, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); }, throwsAssertionError, ); @@ -171,7 +171,7 @@ void main() { return const RadialGradient( center: AlignmentDirectional.topStart, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.rtl); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.rtl); }, returnsNormally, ); @@ -180,7 +180,7 @@ void main() { return const RadialGradient( center: AlignmentDirectional.topStart, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr); }, returnsNormally, ); @@ -189,7 +189,7 @@ void main() { return const RadialGradient( center: Alignment.topLeft, colors: [ Color(0xFFFFFFFF), Color(0xFFFFFFFF) ] - ).createShader(new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + ).createShader(Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); }, returnsNormally, ); @@ -511,7 +511,7 @@ void main() { ], stops: [0.0, 1.0], ); - final Rect rect = new Rect.fromLTWH(1.0, 2.0, 3.0, 4.0); + final Rect rect = Rect.fromLTWH(1.0, 2.0, 3.0, 4.0); expect(test1a.createShader(rect), isNotNull); expect(test1b.createShader(rect), isNotNull); expect(() { test2a.createShader(rect); }, throwsArgumentError); diff --git a/packages/flutter/test/painting/image_cache_resize_test.dart b/packages/flutter/test/painting/image_cache_resize_test.dart index adbf16e3c0..1cf3ff44cb 100644 --- a/packages/flutter/test/painting/image_cache_resize_test.dart +++ b/packages/flutter/test/painting/image_cache_resize_test.dart @@ -9,7 +9,7 @@ import '../rendering/rendering_tester.dart'; import 'mocks_for_image_cache.dart'; void main() { - new TestRenderingFlutterBinding(); // initializes the imageCache + TestRenderingFlutterBinding(); // initializes the imageCache group(ImageCache, () { tearDown(() { imageCache.clear(); diff --git a/packages/flutter/test/painting/image_cache_test.dart b/packages/flutter/test/painting/image_cache_test.dart index a7b660a803..fd25ad6d06 100644 --- a/packages/flutter/test/painting/image_cache_test.dart +++ b/packages/flutter/test/painting/image_cache_test.dart @@ -9,7 +9,7 @@ import '../rendering/rendering_tester.dart'; import 'mocks_for_image_cache.dart'; void main() { - new TestRenderingFlutterBinding(); // initializes the imageCache + TestRenderingFlutterBinding(); // initializes the imageCache group(ImageCache, () { tearDown(() { imageCache.clear(); diff --git a/packages/flutter/test/painting/image_decoder_test.dart b/packages/flutter/test/painting/image_decoder_test.dart index 8fb8d2faa3..41d3b462e7 100644 --- a/packages/flutter/test/painting/image_decoder_test.dart +++ b/packages/flutter/test/painting/image_decoder_test.dart @@ -12,7 +12,7 @@ import 'image_data.dart'; void main() { test('Image decoder control test', () async { - final ui.Image image = await decodeImageFromList(new Uint8List.fromList(kTransparentImage)); + final ui.Image image = await decodeImageFromList(Uint8List.fromList(kTransparentImage)); expect(image, isNotNull); expect(image.width, 1); expect(image.height, 1); diff --git a/packages/flutter/test/painting/image_provider_test.dart b/packages/flutter/test/painting/image_provider_test.dart index 49a25f178f..67b8cfa979 100644 --- a/packages/flutter/test/painting/image_provider_test.dart +++ b/packages/flutter/test/painting/image_provider_test.dart @@ -12,7 +12,7 @@ import '../rendering/rendering_tester.dart'; import 'image_data.dart'; void main() { - new TestRenderingFlutterBinding(); // initializes the imageCache + TestRenderingFlutterBinding(); // initializes the imageCache group(ImageProvider, () { tearDown(() { imageCache.clear(); @@ -20,30 +20,30 @@ void main() { test('NetworkImage non-null url test', () { expect(() { - new NetworkImage(nonconst(null)); + NetworkImage(nonconst(null)); }, throwsAssertionError); }); test('ImageProvider can evict images', () async { - final Uint8List bytes = new Uint8List.fromList(kTransparentImage); - final MemoryImage imageProvider = new MemoryImage(bytes); + final Uint8List bytes = Uint8List.fromList(kTransparentImage); + final MemoryImage imageProvider = MemoryImage(bytes); final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty); - final Completer completer = new Completer(); + final Completer completer = Completer(); stream.addListener((ImageInfo info, bool syncCall) => completer.complete()); await completer.future; expect(imageCache.currentSize, 1); - expect(await new MemoryImage(bytes).evict(), true); + expect(await MemoryImage(bytes).evict(), true); expect(imageCache.currentSize, 0); }); test('ImageProvider.evict respects the provided ImageCache', () async { - final ImageCache otherCache = new ImageCache(); - final Uint8List bytes = new Uint8List.fromList(kTransparentImage); - final MemoryImage imageProvider = new MemoryImage(bytes); + final ImageCache otherCache = ImageCache(); + final Uint8List bytes = Uint8List.fromList(kTransparentImage); + final MemoryImage imageProvider = MemoryImage(bytes); otherCache.putIfAbsent(imageProvider, () => imageProvider.load(imageProvider)); final ImageStream stream = imageProvider.resolve(ImageConfiguration.empty); - final Completer completer = new Completer(); + final Completer completer = Completer(); stream.addListener((ImageInfo info, bool syncCall) => completer.complete()); await completer.future; diff --git a/packages/flutter/test/painting/image_resolution_test.dart b/packages/flutter/test/painting/image_resolution_test.dart index abd3e9e3d3..9099ae9974 100644 --- a/packages/flutter/test/painting/image_resolution_test.dart +++ b/packages/flutter/test/painting/image_resolution_test.dart @@ -27,14 +27,14 @@ class TestAssetBundle extends CachingAssetBundle { @override Future load(String key) async { if (key == 'AssetManifest.json') - return new ByteData.view(new Uint8List.fromList( + return ByteData.view(Uint8List.fromList( const Utf8Encoder().convert(_assetBundleContents)).buffer); loadCallCount[key] = loadCallCount[key] ?? 0 + 1; if (key == 'one') - return new ByteData(1) + return ByteData(1) ..setInt8(0, 49); - throw new FlutterError('key not found'); + throw FlutterError('key not found'); } } @@ -45,9 +45,9 @@ void main() { assetBundleMap[mainAssetPath] = []; - final AssetImage assetImage = new AssetImage( + final AssetImage assetImage = AssetImage( mainAssetPath, - bundle: new TestAssetBundle(assetBundleMap)); + bundle: TestAssetBundle(assetBundleMap)); const ImageConfiguration configuration = ImageConfiguration(); assetImage.obtainKey(configuration) @@ -111,10 +111,10 @@ void main() { assetBundleMap[mainAssetPath] = [mainAssetPath, variantPath]; - final TestAssetBundle testAssetBundle = new TestAssetBundle( + final TestAssetBundle testAssetBundle = TestAssetBundle( assetBundleMap); - final AssetImage assetImage = new AssetImage( + final AssetImage assetImage = AssetImage( mainAssetPath, bundle: testAssetBundle); @@ -126,7 +126,7 @@ void main() { })); // we also have the exact match for this scale, let's use it - assetImage.obtainKey(new ImageConfiguration( + assetImage.obtainKey(ImageConfiguration( bundle: testAssetBundle, devicePixelRatio: 3.0)) .then(expectAsync1((AssetBundleImageKey bundleKey) { @@ -144,12 +144,12 @@ void main() { assetBundleMap[mainAssetPath] = [mainAssetPath]; - final TestAssetBundle testAssetBundle = new TestAssetBundle( + final TestAssetBundle testAssetBundle = TestAssetBundle( assetBundleMap); - final AssetImage assetImage = new AssetImage( + final AssetImage assetImage = AssetImage( mainAssetPath, - bundle: new TestAssetBundle(assetBundleMap)); + bundle: TestAssetBundle(assetBundleMap)); assetImage.obtainKey(const ImageConfiguration()) @@ -158,7 +158,7 @@ void main() { expect(bundleKey.scale, 1.0); })); - assetImage.obtainKey(new ImageConfiguration( + assetImage.obtainKey(ImageConfiguration( bundle: testAssetBundle, devicePixelRatio: 3.0)) .then(expectAsync1((AssetBundleImageKey bundleKey) { @@ -181,15 +181,15 @@ void main() { assetBundleMap[mainAssetPath] = [mainAssetPath, variantPath]; - final TestAssetBundle testAssetBundle = new TestAssetBundle( + final TestAssetBundle testAssetBundle = TestAssetBundle( assetBundleMap); - final AssetImage assetImage = new AssetImage( + final AssetImage assetImage = AssetImage( mainAssetPath, bundle: testAssetBundle); // we have 1.0 and 3.0, asking for 1.5 should give - assetImage.obtainKey(new ImageConfiguration( + assetImage.obtainKey(ImageConfiguration( bundle: testAssetBundle, devicePixelRatio: deviceRatio)) .then(expectAsync1((AssetBundleImageKey bundleKey) { diff --git a/packages/flutter/test/painting/image_stream_test.dart b/packages/flutter/test/painting/image_stream_test.dart index e74f296f0f..6c54351843 100644 --- a/packages/flutter/test/painting/image_stream_test.dart +++ b/packages/flutter/test/painting/image_stream_test.dart @@ -15,7 +15,7 @@ class FakeFrameInfo implements FrameInfo { final Image _image; FakeFrameInfo(int width, int height, this._duration) : - _image = new FakeImage(width, height); + _image = FakeImage(width, height); @override Duration get duration => _duration; @@ -41,7 +41,7 @@ class FakeImage implements Image { @override Future toByteData({ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } } @@ -55,7 +55,7 @@ class MockCodec implements Codec { int numFramesAsked = 0; - Completer _nextFrameCompleter = new Completer(); + Completer _nextFrameCompleter = Completer(); @override Future getNextFrame() { @@ -65,7 +65,7 @@ class MockCodec implements Codec { void completeNextFrame(FrameInfo frameInfo) { _nextFrameCompleter.complete(frameInfo); - _nextFrameCompleter = new Completer(); + _nextFrameCompleter = Completer(); } void failNextFrame(String err) { @@ -79,8 +79,8 @@ class MockCodec implements Codec { void main() { testWidgets('Codec future fails', (WidgetTester tester) async { - final Completer completer = new Completer(); - new MultiFrameImageStreamCompleter( + final Completer completer = Completer(); + MultiFrameImageStreamCompleter( codec: completer.future, scale: 1.0, ); @@ -90,10 +90,10 @@ void main() { }); testWidgets('First frame decoding starts when codec is ready', (WidgetTester tester) async { - final Completer completer = new Completer(); - final MockCodec mockCodec = new MockCodec(); + final Completer completer = Completer(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 1; - new MultiFrameImageStreamCompleter( + MultiFrameImageStreamCompleter( codec: completer.future, scale: 1.0, ); @@ -104,11 +104,11 @@ void main() { }); testWidgets('getNextFrame future fails', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - new MultiFrameImageStreamCompleter( + MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -127,11 +127,11 @@ void main() { }); testWidgets('ImageStream emits frame (static image)', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -144,20 +144,20 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); mockCodec.completeNextFrame(frame); await tester.idle(); - expect(emittedImages, equals([new ImageInfo(image: frame.image)])); + expect(emittedImages, equals([ImageInfo(image: frame.image)])); }); testWidgets('ImageStream emits frames (animated images)', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = -1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -170,7 +170,7 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); mockCodec.completeNextFrame(frame1); await tester.idle(); // We are waiting for the next animation tick, so at this point no frames @@ -178,9 +178,9 @@ void main() { expect(emittedImages.length, 0); await tester.pump(); - expect(emittedImages, equals([new ImageInfo(image: frame1.image)])); + expect(emittedImages, equals([ImageInfo(image: frame1.image)])); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame2); await tester.pump(const Duration(milliseconds: 100)); @@ -190,8 +190,8 @@ void main() { await tester.pump(const Duration(milliseconds: 100)); expect(emittedImages, equals([ - new ImageInfo(image: frame1.image), - new ImageInfo(image: frame2.image), + ImageInfo(image: frame1.image), + ImageInfo(image: frame2.image), ])); // Let the pending timer for the next frame to complete so we can cleanly @@ -200,12 +200,12 @@ void main() { }); testWidgets('animation wraps back', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = -1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -218,8 +218,8 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame1); await tester.idle(); // let nextFrameFuture complete @@ -232,9 +232,9 @@ void main() { await tester.pump(const Duration(milliseconds: 400)); // emit 3rd frame expect(emittedImages, equals([ - new ImageInfo(image: frame1.image), - new ImageInfo(image: frame2.image), - new ImageInfo(image: frame1.image), + ImageInfo(image: frame1.image), + ImageInfo(image: frame2.image), + ImageInfo(image: frame1.image), ])); // Let the pending timer for the next frame to complete so we can cleanly @@ -243,12 +243,12 @@ void main() { }); testWidgets('animation doesnt repeat more than specified', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = 0; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -261,8 +261,8 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame1); await tester.idle(); // let nextFrameFuture complete @@ -277,18 +277,18 @@ void main() { await tester.pump(const Duration(milliseconds: 400)); expect(emittedImages, equals([ - new ImageInfo(image: frame1.image), - new ImageInfo(image: frame2.image), + ImageInfo(image: frame1.image), + ImageInfo(image: frame2.image), ])); }); testWidgets('frames are only decoded when there are active listeners', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = -1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -299,8 +299,8 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame1); await tester.idle(); // let nextFrameFuture complete @@ -320,12 +320,12 @@ void main() { }); testWidgets('multiple stream listeners', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = -1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -344,14 +344,14 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame1); await tester.idle(); // let nextFrameFuture complete await tester.pump(); // first animation frame shows on first app frame. - expect(emittedImages1, equals([new ImageInfo(image: frame1.image)])); - expect(emittedImages2, equals([new ImageInfo(image: frame1.image)])); + expect(emittedImages1, equals([ImageInfo(image: frame1.image)])); + expect(emittedImages2, equals([ImageInfo(image: frame1.image)])); mockCodec.completeNextFrame(frame2); await tester.idle(); // let nextFrameFuture complete @@ -359,20 +359,20 @@ void main() { imageStream.removeListener(listener1); await tester.pump(const Duration(milliseconds: 400)); // emit 2nd frame. - expect(emittedImages1, equals([new ImageInfo(image: frame1.image)])); + expect(emittedImages1, equals([ImageInfo(image: frame1.image)])); expect(emittedImages2, equals([ - new ImageInfo(image: frame1.image), - new ImageInfo(image: frame2.image), + ImageInfo(image: frame1.image), + ImageInfo(image: frame2.image), ])); }); testWidgets('timer is canceled when listeners are removed', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = -1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -383,8 +383,8 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame1); await tester.idle(); // let nextFrameFuture complete @@ -400,12 +400,12 @@ void main() { }); testWidgets('timeDilation affects animation frame timers', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 2; mockCodec.repetitionCount = -1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter imageStream = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter imageStream = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); @@ -416,8 +416,8 @@ void main() { codecCompleter.complete(mockCodec); await tester.idle(); - final FrameInfo frame1 = new FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); - final FrameInfo frame2 = new FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); + final FrameInfo frame1 = FakeFrameInfo(20, 10, const Duration(milliseconds: 200)); + final FrameInfo frame2 = FakeFrameInfo(200, 100, const Duration(milliseconds: 400)); mockCodec.completeNextFrame(frame1); await tester.idle(); // let nextFrameFuture complete @@ -436,11 +436,11 @@ void main() { }); testWidgets('error handlers can intercept errors', (WidgetTester tester) async { - final MockCodec mockCodec = new MockCodec(); + final MockCodec mockCodec = MockCodec(); mockCodec.frameCount = 1; - final Completer codecCompleter = new Completer(); + final Completer codecCompleter = Completer(); - final ImageStreamCompleter streamUnderTest = new MultiFrameImageStreamCompleter( + final ImageStreamCompleter streamUnderTest = MultiFrameImageStreamCompleter( codec: codecCompleter.future, scale: 1.0, ); diff --git a/packages/flutter/test/painting/image_test_utils.dart b/packages/flutter/test/painting/image_test_utils.dart index 8a8b5311e0..37fdc89063 100644 --- a/packages/flutter/test/painting/image_test_utils.dart +++ b/packages/flutter/test/painting/image_test_utils.dart @@ -16,12 +16,12 @@ class TestImageProvider extends ImageProvider { final ui.Image testImage; - final Completer _completer = new Completer.sync(); + final Completer _completer = Completer.sync(); ImageConfiguration configuration; @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override @@ -32,10 +32,10 @@ class TestImageProvider extends ImageProvider { @override ImageStreamCompleter load(TestImageProvider key) => - new OneFrameImageStreamCompleter(_completer.future); + OneFrameImageStreamCompleter(_completer.future); ImageInfo complete() { - final ImageInfo imageInfo = new ImageInfo(image: testImage); + final ImageInfo imageInfo = ImageInfo(image: testImage); _completer.complete(imageInfo); return imageInfo; } @@ -45,7 +45,7 @@ class TestImageProvider extends ImageProvider { } Future createTestImage() { - final Completer uiImage = new Completer(); - ui.decodeImageFromList(new Uint8List.fromList(kTransparentImage), uiImage.complete); + final Completer uiImage = Completer(); + ui.decodeImageFromList(Uint8List.fromList(kTransparentImage), uiImage.complete); return uiImage.future; } diff --git a/packages/flutter/test/painting/matrix_utils_test.dart b/packages/flutter/test/painting/matrix_utils_test.dart index 58268e3a23..a2bcff7bcd 100644 --- a/packages/flutter/test/painting/matrix_utils_test.dart +++ b/packages/flutter/test/painting/matrix_utils_test.dart @@ -11,30 +11,30 @@ import 'package:vector_math/vector_math_64.dart'; void main() { test('MatrixUtils.getAsTranslation()', () { Matrix4 test; - test = new Matrix4.identity(); + test = Matrix4.identity(); expect(MatrixUtils.getAsTranslation(test), equals(Offset.zero)); - test = new Matrix4.zero(); + test = Matrix4.zero(); expect(MatrixUtils.getAsTranslation(test), isNull); - test = new Matrix4.rotationX(1.0); + test = Matrix4.rotationX(1.0); expect(MatrixUtils.getAsTranslation(test), isNull); - test = new Matrix4.rotationZ(1.0); + test = Matrix4.rotationZ(1.0); expect(MatrixUtils.getAsTranslation(test), isNull); - test = new Matrix4.translationValues(1.0, 2.0, 0.0); + test = Matrix4.translationValues(1.0, 2.0, 0.0); expect(MatrixUtils.getAsTranslation(test), equals(const Offset(1.0, 2.0))); - test = new Matrix4.translationValues(1.0, 2.0, 3.0); + test = Matrix4.translationValues(1.0, 2.0, 3.0); expect(MatrixUtils.getAsTranslation(test), isNull); - test = new Matrix4.identity(); + test = Matrix4.identity(); expect(MatrixUtils.getAsTranslation(test), equals(Offset.zero)); test.rotateX(2.0); expect(MatrixUtils.getAsTranslation(test), isNull); - test = new Matrix4.identity(); + test = Matrix4.identity(); expect(MatrixUtils.getAsTranslation(test), equals(Offset.zero)); test.scale(2.0); expect(MatrixUtils.getAsTranslation(test), isNull); - test = new Matrix4.identity(); + test = Matrix4.identity(); expect(MatrixUtils.getAsTranslation(test), equals(Offset.zero)); test.translate(2.0, -2.0); expect(MatrixUtils.getAsTranslation(test), equals(const Offset(2.0, -2.0))); @@ -49,7 +49,7 @@ void main() { perspective: 0.0, ); - expect(initialState, new Matrix4.identity()); + expect(initialState, Matrix4.identity()); }); test('cylindricalProjectionTransform rotate with no radius', () { @@ -59,7 +59,7 @@ void main() { perspective: 0.0, ); - expect(simpleRotate, new Matrix4.rotationX(pi / 2.0)); + expect(simpleRotate, Matrix4.rotationX(pi / 2.0)); }); test('cylindricalProjectionTransform radius does not change scale', () { @@ -69,7 +69,7 @@ void main() { perspective: 0.0, ); - expect(noRotation, new Matrix4.identity()); + expect(noRotation, Matrix4.identity()); }); test('cylindricalProjectionTransform calculation spot check', () { diff --git a/packages/flutter/test/painting/mocks_for_image_cache.dart b/packages/flutter/test/painting/mocks_for_image_cache.dart index de2edcafb9..0c9fd4cc9e 100644 --- a/packages/flutter/test/painting/mocks_for_image_cache.dart +++ b/packages/flutter/test/painting/mocks_for_image_cache.dart @@ -33,13 +33,13 @@ class TestImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new Future.value(key); + return Future.value(key); } @override ImageStreamCompleter load(int key) { - return new OneFrameImageStreamCompleter( - new SynchronousFuture(new TestImageInfo(imageValue, image: image)) + return OneFrameImageStreamCompleter( + SynchronousFuture(TestImageInfo(imageValue, image: image)) ); } @@ -48,7 +48,7 @@ class TestImageProvider extends ImageProvider { } Future extractOneFrame(ImageStream stream) { - final Completer completer = new Completer(); + final Completer completer = Completer(); void listener(ImageInfo image, bool synchronousCall) { completer.complete(image); stream.removeListener(listener); @@ -69,6 +69,6 @@ class TestImage implements ui.Image { @override Future toByteData({ImageByteFormat format = ImageByteFormat.rawRgba}) { - throw new UnimplementedError(); + throw UnimplementedError(); } } diff --git a/packages/flutter/test/painting/notched_shapes_test.dart b/packages/flutter/test/painting/notched_shapes_test.dart index 2c1b0163db..7eadb0926f 100644 --- a/packages/flutter/test/painting/notched_shapes_test.dart +++ b/packages/flutter/test/painting/notched_shapes_test.dart @@ -11,11 +11,11 @@ void main() { group('CircularNotchedRectangle', () { test('guest and host don\'t overlap', () { const CircularNotchedRectangle shape = CircularNotchedRectangle(); - final Rect host = new Rect.fromLTRB(0.0, 100.0, 300.0, 300.0); - final Rect guest = new Rect.fromLTWH(50.0, 50.0, 10.0, 10.0); + final Rect host = Rect.fromLTRB(0.0, 100.0, 300.0, 300.0); + final Rect guest = Rect.fromLTWH(50.0, 50.0, 10.0, 10.0); final Path actualPath = shape.getOuterPath(host, guest); - final Path expectedPath = new Path()..addRect(host); + final Path expectedPath = Path()..addRect(host); expect( actualPath, @@ -29,8 +29,8 @@ void main() { test('guest center above host', () { const CircularNotchedRectangle shape = CircularNotchedRectangle(); - final Rect host = new Rect.fromLTRB(0.0, 100.0, 300.0, 300.0); - final Rect guest = new Rect.fromLTRB(190.0, 85.0, 210.0, 105.0); + final Rect host = Rect.fromLTRB(0.0, 100.0, 300.0, 300.0); + final Rect guest = Rect.fromLTRB(190.0, 85.0, 210.0, 105.0); final Path actualPath = shape.getOuterPath(host, guest); @@ -39,8 +39,8 @@ void main() { test('guest center below host', () { const CircularNotchedRectangle shape = CircularNotchedRectangle(); - final Rect host = new Rect.fromLTRB(0.0, 100.0, 300.0, 300.0); - final Rect guest = new Rect.fromLTRB(190.0, 95.0, 210.0, 115.0); + final Rect host = Rect.fromLTRB(0.0, 100.0, 300.0, 300.0); + final Rect guest = Rect.fromLTRB(190.0, 95.0, 210.0, 115.0); final Path actualPath = shape.getOuterPath(host, guest); @@ -58,7 +58,7 @@ bool pathDoesNotContainCircle(Path path, Rect circleBounds) { for (double i = 0.0; i < 1; i += 0.01) { final double x = i * radius * math.cos(theta); final double y = i * radius * math.sin(theta); - if (path.contains(new Offset(x,y) + circleBounds.center)) + if (path.contains(Offset(x,y) + circleBounds.center)) return false; } } diff --git a/packages/flutter/test/painting/paint_image_test.dart b/packages/flutter/test/painting/paint_image_test.dart index 6da7109fa1..0c9bf8228e 100644 --- a/packages/flutter/test/painting/paint_image_test.dart +++ b/packages/flutter/test/painting/paint_image_test.dart @@ -24,7 +24,7 @@ class TestImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } } @@ -39,11 +39,11 @@ class TestCanvas implements Canvas { void main() { test('Cover and align', () { - final TestImage image = new TestImage(width: 300, height: 300); - final TestCanvas canvas = new TestCanvas(); + final TestImage image = TestImage(width: 300, height: 300); + final TestCanvas canvas = TestCanvas(); paintImage( canvas: canvas, - rect: new Rect.fromLTWH(50.0, 75.0, 200.0, 100.0), + rect: Rect.fromLTWH(50.0, 75.0, 200.0, 100.0), image: image, fit: BoxFit.cover, alignment: const Alignment(-1.0, 0.0), @@ -55,8 +55,8 @@ void main() { expect(command, isNotNull); expect(command.positionalArguments[0], equals(image)); - expect(command.positionalArguments[1], equals(new Rect.fromLTWH(0.0, 75.0, 300.0, 150.0))); - expect(command.positionalArguments[2], equals(new Rect.fromLTWH(50.0, 75.0, 200.0, 100.0))); + expect(command.positionalArguments[1], equals(Rect.fromLTWH(0.0, 75.0, 300.0, 150.0))); + expect(command.positionalArguments[2], equals(Rect.fromLTWH(50.0, 75.0, 200.0, 100.0))); }); // See also the DecorationImage tests in: decoration_test.dart diff --git a/packages/flutter/test/painting/rounded_rectangle_border_test.dart b/packages/flutter/test/painting/rounded_rectangle_border_test.dart index 7340483903..c4e22261b1 100644 --- a/packages/flutter/test/painting/rounded_rectangle_border_test.dart +++ b/packages/flutter/test/painting/rounded_rectangle_border_test.dart @@ -10,9 +10,9 @@ import 'common_matchers.dart'; void main() { test('RoundedRectangleBorder', () { - final RoundedRectangleBorder c10 = new RoundedRectangleBorder(side: const BorderSide(width: 10.0), borderRadius: new BorderRadius.circular(100.0)); - final RoundedRectangleBorder c15 = new RoundedRectangleBorder(side: const BorderSide(width: 15.0), borderRadius: new BorderRadius.circular(150.0)); - final RoundedRectangleBorder c20 = new RoundedRectangleBorder(side: const BorderSide(width: 20.0), borderRadius: new BorderRadius.circular(200.0)); + final RoundedRectangleBorder c10 = RoundedRectangleBorder(side: const BorderSide(width: 10.0), borderRadius: BorderRadius.circular(100.0)); + final RoundedRectangleBorder c15 = RoundedRectangleBorder(side: const BorderSide(width: 15.0), borderRadius: BorderRadius.circular(150.0)); + final RoundedRectangleBorder c20 = RoundedRectangleBorder(side: const BorderSide(width: 20.0), borderRadius: BorderRadius.circular(200.0)); expect(c10.dimensions, const EdgeInsets.all(10.0)); expect(c10.scale(2.0), c20); expect(c20.scale(0.5), c10); @@ -20,26 +20,26 @@ void main() { expect(ShapeBorder.lerp(c10, c20, 0.5), c15); expect(ShapeBorder.lerp(c10, c20, 1.0), c20); - final RoundedRectangleBorder c1 = new RoundedRectangleBorder(side: const BorderSide(width: 1.0), borderRadius: new BorderRadius.circular(1.0)); - final RoundedRectangleBorder c2 = new RoundedRectangleBorder(side: const BorderSide(width: 1.0), borderRadius: new BorderRadius.circular(2.0)); - expect(c2.getInnerPath(new Rect.fromCircle(center: Offset.zero, radius: 2.0)), isUnitCircle); - expect(c1.getOuterPath(new Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); - final Rect rect = new Rect.fromLTRB(10.0, 20.0, 80.0, 190.0); + final RoundedRectangleBorder c1 = RoundedRectangleBorder(side: const BorderSide(width: 1.0), borderRadius: BorderRadius.circular(1.0)); + final RoundedRectangleBorder c2 = RoundedRectangleBorder(side: const BorderSide(width: 1.0), borderRadius: BorderRadius.circular(2.0)); + expect(c2.getInnerPath(Rect.fromCircle(center: Offset.zero, radius: 2.0)), isUnitCircle); + expect(c1.getOuterPath(Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); + final Rect rect = Rect.fromLTRB(10.0, 20.0, 80.0, 190.0); expect( (Canvas canvas) => c10.paint(canvas, rect), paints ..drrect( - outer: new RRect.fromRectAndRadius(rect, const Radius.circular(100.0)), - inner: new RRect.fromRectAndRadius(rect.deflate(10.0), const Radius.circular(90.0)), + outer: RRect.fromRectAndRadius(rect, const Radius.circular(100.0)), + inner: RRect.fromRectAndRadius(rect.deflate(10.0), const Radius.circular(90.0)), strokeWidth: 0.0, ) ); }); test('RoundedRectangleBorder and CircleBorder', () { - final RoundedRectangleBorder r = new RoundedRectangleBorder(side: BorderSide.none, borderRadius: new BorderRadius.circular(10.0)); + final RoundedRectangleBorder r = RoundedRectangleBorder(side: BorderSide.none, borderRadius: BorderRadius.circular(10.0)); const CircleBorder c = CircleBorder(side: BorderSide.none); - final Rect rect = new Rect.fromLTWH(0.0, 0.0, 100.0, 20.0); // center is x=40..60 y=10 + final Rect rect = Rect.fromLTWH(0.0, 0.0, 100.0, 20.0); // center is x=40..60 y=10 final Matcher looksLikeR = isPathThat( includes: const [ Offset(30.0, 10.0), Offset(50.0, 10.0), ], excludes: const [ Offset(1.0, 1.0), Offset(99.0, 19.0), ], diff --git a/packages/flutter/test/painting/shape_border_test.dart b/packages/flutter/test/painting/shape_border_test.dart index 06fca1d846..2532520553 100644 --- a/packages/flutter/test/painting/shape_border_test.dart +++ b/packages/flutter/test/painting/shape_border_test.dart @@ -9,8 +9,8 @@ import '../rendering/mock_canvas.dart'; void main() { test('Compound borders', () { - final Border b1 = new Border.all(color: const Color(0xFF00FF00)); - final Border b2 = new Border.all(color: const Color(0xFF0000FF)); + final Border b1 = Border.all(color: const Color(0xFF00FF00)); + final Border b2 = Border.all(color: const Color(0xFF0000FF)); expect( (b1 + b2).toString(), 'Border.all(BorderSide(Color(0xff00ff00), 1.0, BorderStyle.solid)) + ' @@ -58,7 +58,7 @@ void main() { 'Border.all(BorderSide(Color(0xff0000ff), 1.0, BorderStyle.solid))' ); expect((b1 + b2).dimensions, const EdgeInsets.all(2.0)); - final Rect rect = new Rect.fromLTRB(11.0, 15.0, 299.0, 175.0); + final Rect rect = Rect.fromLTRB(11.0, 15.0, 299.0, 175.0); expect((Canvas canvas) => (b1 + b2).paint(canvas, rect), paints ..rect(rect: rect.deflate(0.5), color: b2.top.color) ..rect(rect: rect.deflate(1.5), color: b1.top.color) @@ -123,7 +123,7 @@ void main() { 'BorderDirectional(top: BorderSide(Color(0xff0000ff), 1.0, BorderStyle.solid), start: BorderSide(Color(0xff0000ff), 1.0, BorderStyle.solid), end: BorderSide(Color(0xff0000ff), 1.0, BorderStyle.solid), bottom: BorderSide(Color(0xff0000ff), 1.0, BorderStyle.solid))' ); expect((b1 + b2).dimensions, const EdgeInsetsDirectional.fromSTEB(2.0, 2.0, 2.0, 2.0)); - final Rect rect = new Rect.fromLTRB(11.0, 15.0, 299.0, 175.0); + final Rect rect = Rect.fromLTRB(11.0, 15.0, 299.0, 175.0); expect((Canvas canvas) => (b1 + b2).paint(canvas, rect, textDirection: TextDirection.rtl), paints ..rect(rect: rect.deflate(0.5), color: b2.top.color) ..rect(rect: rect.deflate(1.5), color: b1.top.color) diff --git a/packages/flutter/test/painting/shape_decoration_test.dart b/packages/flutter/test/painting/shape_decoration_test.dart index cd2c0ebc48..3969963346 100644 --- a/packages/flutter/test/painting/shape_decoration_test.dart +++ b/packages/flutter/test/painting/shape_decoration_test.dart @@ -14,33 +14,33 @@ import '../rendering/mock_canvas.dart'; import '../rendering/rendering_tester.dart'; void main() { - new TestRenderingFlutterBinding(); // initializes the imageCache + TestRenderingFlutterBinding(); // initializes the imageCache test('ShapeDecoration constructor', () { const Color colorR = Color(0xffff0000); const Color colorG = Color(0xff00ff00); const Gradient gradient = LinearGradient(colors: [colorR, colorG]); expect(const ShapeDecoration(shape: Border()), const ShapeDecoration(shape: Border())); - expect(() => new ShapeDecoration(color: colorR, gradient: nonconst(gradient), shape: const Border()), throwsAssertionError); - expect(() => new ShapeDecoration(gradient: nonconst(gradient), shape: null), throwsAssertionError); + expect(() => ShapeDecoration(color: colorR, gradient: nonconst(gradient), shape: const Border()), throwsAssertionError); + expect(() => ShapeDecoration(gradient: nonconst(gradient), shape: null), throwsAssertionError); expect( - new ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.circle)), + ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.circle)), const ShapeDecoration(shape: CircleBorder(side: BorderSide.none)), ); expect( - new ShapeDecoration.fromBoxDecoration(new BoxDecoration(shape: BoxShape.rectangle, borderRadius: new BorderRadiusDirectional.circular(100.0))), - new ShapeDecoration(shape: new RoundedRectangleBorder(borderRadius: new BorderRadiusDirectional.circular(100.0))), + ShapeDecoration.fromBoxDecoration(BoxDecoration(shape: BoxShape.rectangle, borderRadius: BorderRadiusDirectional.circular(100.0))), + ShapeDecoration(shape: RoundedRectangleBorder(borderRadius: BorderRadiusDirectional.circular(100.0))), ); expect( - new ShapeDecoration.fromBoxDecoration(new BoxDecoration(shape: BoxShape.circle, border: new Border.all(color: colorG))), + ShapeDecoration.fromBoxDecoration(BoxDecoration(shape: BoxShape.circle, border: Border.all(color: colorG))), const ShapeDecoration(shape: CircleBorder(side: BorderSide(color: colorG))), ); expect( - new ShapeDecoration.fromBoxDecoration(new BoxDecoration(shape: BoxShape.rectangle, border: new Border.all(color: colorR))), - new ShapeDecoration(shape: new Border.all(color: colorR)), + ShapeDecoration.fromBoxDecoration(BoxDecoration(shape: BoxShape.rectangle, border: Border.all(color: colorR))), + ShapeDecoration(shape: Border.all(color: colorR)), ); expect( - new ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.rectangle, border: BorderDirectional(start: BorderSide()))), + ShapeDecoration.fromBoxDecoration(const BoxDecoration(shape: BoxShape.rectangle, border: BorderDirectional(start: BorderSide()))), const ShapeDecoration(shape: BorderDirectional(start: BorderSide())), ); }); @@ -60,10 +60,10 @@ void main() { test('ShapeDecoration.image RTL test', () { final List log = []; - final ShapeDecoration decoration = new ShapeDecoration( + final ShapeDecoration decoration = ShapeDecoration( shape: const CircleBorder(), - image: new DecorationImage( - image: new TestImageProvider(), + image: DecorationImage( + image: TestImageProvider(), alignment: AlignmentDirectional.bottomEnd, ), ); @@ -81,7 +81,7 @@ void main() { ); }, paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 100.0, 200.0), destination: new Rect.fromLTRB(20.0, 1000.0 - 40.0 - 200.0, 20.0 + 100.0, 1000.0 - 40.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 100.0, 200.0), destination: Rect.fromLTRB(20.0, 1000.0 - 40.0 - 200.0, 20.0 + 100.0, 1000.0 - 40.0)) ); expect( (Canvas canvas) { @@ -103,13 +103,13 @@ void main() { class TestImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(TestImageProvider key) { - return new OneFrameImageStreamCompleter( - new SynchronousFuture(new ImageInfo(image: new TestImage(), scale: 1.0)), + return OneFrameImageStreamCompleter( + SynchronousFuture(ImageInfo(image: TestImage(), scale: 1.0)), ); } } @@ -126,6 +126,6 @@ class TestImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } } diff --git a/packages/flutter/test/painting/stadium_border_test.dart b/packages/flutter/test/painting/stadium_border_test.dart index 0934771055..6d71e3ad59 100644 --- a/packages/flutter/test/painting/stadium_border_test.dart +++ b/packages/flutter/test/painting/stadium_border_test.dart @@ -21,15 +21,15 @@ void main() { expect(ShapeBorder.lerp(c10, c20, 1.0), c20); const StadiumBorder c1 = StadiumBorder(side: BorderSide(width: 1.0)); - expect(c1.getOuterPath(new Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); + expect(c1.getOuterPath(Rect.fromCircle(center: Offset.zero, radius: 1.0)), isUnitCircle); const StadiumBorder c2 = StadiumBorder(side: BorderSide(width: 1.0)); - expect(c2.getInnerPath(new Rect.fromCircle(center: Offset.zero, radius: 2.0)), isUnitCircle); - final Rect rect = new Rect.fromLTRB(10.0, 20.0, 100.0, 200.0); + expect(c2.getInnerPath(Rect.fromCircle(center: Offset.zero, radius: 2.0)), isUnitCircle); + final Rect rect = Rect.fromLTRB(10.0, 20.0, 100.0, 200.0); expect( (Canvas canvas) => c10.paint(canvas, rect), paints ..rrect( - rrect: new RRect.fromRectAndRadius(rect.deflate(5.0), new Radius.circular(rect.shortestSide / 2.0 - 5.0)), + rrect: RRect.fromRectAndRadius(rect.deflate(5.0), Radius.circular(rect.shortestSide / 2.0 - 5.0)), strokeWidth: 10.0, ) ); @@ -38,7 +38,7 @@ void main() { test('StadiumBorder and CircleBorder', () { const StadiumBorder stadium = StadiumBorder(side: BorderSide.none); const CircleBorder circle = CircleBorder(side: BorderSide.none); - final Rect rect = new Rect.fromLTWH(0.0, 0.0, 100.0, 20.0); + final Rect rect = Rect.fromLTWH(0.0, 0.0, 100.0, 20.0); final Matcher looksLikeS = isPathThat( includes: const [ Offset(30.0, 10.0), Offset(50.0, 10.0), ], excludes: const [ Offset(1.0, 1.0), Offset(99.0, 19.0), ], @@ -89,7 +89,7 @@ void main() { test('StadiumBorder and RoundedRectBorder', () { const StadiumBorder stadium = StadiumBorder(side: BorderSide.none); const RoundedRectangleBorder rrect = RoundedRectangleBorder(side: BorderSide.none); - final Rect rect = new Rect.fromLTWH(0.0, 0.0, 100.0, 50.0); + final Rect rect = Rect.fromLTWH(0.0, 0.0, 100.0, 50.0); final Matcher looksLikeS = isPathThat( includes: const [ Offset(25.0, 25.0), diff --git a/packages/flutter/test/painting/text_painter_rtl_test.dart b/packages/flutter/test/painting/text_painter_rtl_test.dart index cfc69438d9..e1d56c45dc 100644 --- a/packages/flutter/test/painting/text_painter_rtl_test.dart +++ b/packages/flutter/test/painting/text_painter_rtl_test.dart @@ -13,7 +13,7 @@ const bool skipExpectsWithKnownBugs = false; void main() { test('TextPainter - basic words', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -37,7 +37,7 @@ void main() { }); test('TextPainter - bidi overrides in LTR', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -130,7 +130,7 @@ void main() { final List> list = >[]; for (int index = 0; index < painter.text.text.length; index += 1) - list.add(painter.getBoxesForSelection(new TextSelection(baseOffset: index, extentOffset: index + 1))); + list.add(painter.getBoxesForSelection(TextSelection(baseOffset: index, extentOffset: index + 1))); expect(list, const >[ [], // U+202E, non-printing Unicode bidi formatting character [TextBox.fromLTRBD(230.0, 0.0, 240.0, 10.0, TextDirection.rtl)], @@ -166,7 +166,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - bidi overrides in RTL', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.rtl; painter.text = const TextSpan( @@ -256,7 +256,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - forced line-wrapping with bidi', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -324,7 +324,7 @@ void main() { skip: Platform.isWindows || Platform.isMacOS); test('TextPainter - line wrap mid-word', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -357,7 +357,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - line wrap mid-word, bidi - LTR base', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -390,7 +390,7 @@ void main() { final List> list = >[]; for (int index = 0; index < 5+4+5; index += 1) - list.add(painter.getBoxesForSelection(new TextSelection(baseOffset: index, extentOffset: index + 1))); + list.add(painter.getBoxesForSelection(TextSelection(baseOffset: index, extentOffset: index + 1))); print(list); expect(list, const >[ [TextBox.fromLTRBD(0.0, 8.0, 10.0, 18.0, TextDirection.ltr)], @@ -411,7 +411,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - line wrap mid-word, bidi - RTL base', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.rtl; painter.text = const TextSpan( @@ -446,18 +446,18 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - multiple levels', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.rtl; final String pyramid = rlo(lro(rlo(lro(rlo(''))))); - painter.text = new TextSpan( + painter.text = TextSpan( text: pyramid, style: const TextStyle(fontFamily: 'Ahem', fontSize: 10.0), ); painter.layout(); expect( - painter.getBoxesForSelection(new TextSelection(baseOffset: 0, extentOffset: pyramid.length)), + painter.getBoxesForSelection(TextSelection(baseOffset: 0, extentOffset: pyramid.length)), const [ TextBox.fromLTRBD(90.0, 0.0, 100.0, 10.0, TextDirection.rtl), // outer R, start (right) TextBox.fromLTRBD(10.0, 0.0, 20.0, 10.0, TextDirection.ltr), // level 1 L, start (left) @@ -477,7 +477,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - getPositionForOffset - RTL in LTR', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -559,7 +559,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - getPositionForOffset - LTR in RTL', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.rtl; painter.text = const TextSpan( @@ -604,7 +604,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - Spaces', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( @@ -665,7 +665,7 @@ void main() { }, skip: skipTestsWithKnownBugs); test('TextPainter - empty text baseline', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; painter.text = const TextSpan( text: '', diff --git a/packages/flutter/test/painting/text_painter_test.dart b/packages/flutter/test/painting/text_painter_test.dart index 933c7b35ac..3ce2837098 100644 --- a/packages/flutter/test/painting/text_painter_test.dart +++ b/packages/flutter/test/painting/text_painter_test.dart @@ -9,40 +9,40 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('TextPainter caret test', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; String text = 'A'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); Offset caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 0), ui.Rect.zero); expect(caretOffset.dx, 0); - caretOffset = painter.getOffsetForCaret(new ui.TextPosition(offset: text.length), ui.Rect.zero); + caretOffset = painter.getOffsetForCaret(ui.TextPosition(offset: text.length), ui.Rect.zero); expect(caretOffset.dx, painter.width); // Check that getOffsetForCaret handles a character that is encoded as a surrogate pair. text = 'A\u{1F600}'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); - caretOffset = painter.getOffsetForCaret(new ui.TextPosition(offset: text.length), ui.Rect.zero); + caretOffset = painter.getOffsetForCaret(ui.TextPosition(offset: text.length), ui.Rect.zero); expect(caretOffset.dx, painter.width); }); test('TextPainter error test', () { - final TextPainter painter = new TextPainter(textDirection: TextDirection.ltr); + final TextPainter painter = TextPainter(textDirection: TextDirection.ltr); expect(() { painter.paint(null, Offset.zero); }, throwsFlutterError); }); test('TextPainter requires textDirection', () { - final TextPainter painter1 = new TextPainter(text: const TextSpan(text: '')); + final TextPainter painter1 = TextPainter(text: const TextSpan(text: '')); expect(() { painter1.layout(); }, throwsAssertionError); - final TextPainter painter2 = new TextPainter(text: const TextSpan(text: ''), textDirection: TextDirection.rtl); + final TextPainter painter2 = TextPainter(text: const TextSpan(text: ''), textDirection: TextDirection.rtl); expect(() { painter2.layout(); }, isNot(throwsException)); }); test('TextPainter size test', () { - final TextPainter painter = new TextPainter( + final TextPainter painter = TextPainter( text: const TextSpan( text: 'X', style: TextStyle( @@ -58,7 +58,7 @@ void main() { }); test('TextPainter textScaleFactor test', () { - final TextPainter painter = new TextPainter( + final TextPainter painter = TextPainter( text: const TextSpan( text: 'X', style: TextStyle( @@ -75,7 +75,7 @@ void main() { }); test('TextPainter default text height is 14 pixels', () { - final TextPainter painter = new TextPainter( + final TextPainter painter = TextPainter( text: const TextSpan(text: 'x'), textDirection: TextDirection.ltr, ); @@ -85,7 +85,7 @@ void main() { }); test('TextPainter sets paragraph size from root', () { - final TextPainter painter = new TextPainter( + final TextPainter painter = TextPainter( text: const TextSpan(text: 'x', style: TextStyle(fontSize: 100.0)), textDirection: TextDirection.ltr, ); @@ -102,7 +102,7 @@ void main() { ); TextPainter painter; - painter = new TextPainter( + painter = TextPainter( text: const TextSpan( text: 'X X X', style: style, @@ -114,7 +114,7 @@ void main() { expect(painter.minIntrinsicWidth, 10.0); expect(painter.maxIntrinsicWidth, 50.0); - painter = new TextPainter( + painter = TextPainter( text: const TextSpan( text: 'X X X', style: style, @@ -127,7 +127,7 @@ void main() { expect(painter.minIntrinsicWidth, 50.0); expect(painter.maxIntrinsicWidth, 50.0); - painter = new TextPainter( + painter = TextPainter( text: const TextSpan( text: 'X X XXXX', style: style, @@ -140,7 +140,7 @@ void main() { expect(painter.minIntrinsicWidth, 40.0); expect(painter.maxIntrinsicWidth, 80.0); - painter = new TextPainter( + painter = TextPainter( text: const TextSpan( text: 'X X XXXX XX', style: style, @@ -153,7 +153,7 @@ void main() { expect(painter.minIntrinsicWidth, 70.0); expect(painter.maxIntrinsicWidth, 110.0); - painter = new TextPainter( + painter = TextPainter( text: const TextSpan( text: 'XXXXXXXX XXXX XX X', style: style, @@ -166,7 +166,7 @@ void main() { expect(painter.minIntrinsicWidth, 90.0); expect(painter.maxIntrinsicWidth, 180.0); - painter = new TextPainter( + painter = TextPainter( text: const TextSpan( text: 'X XX XXXX XXXXXXXX', style: style, @@ -181,38 +181,38 @@ void main() { }, skip: true); // https://github.com/flutter/flutter/issues/13512 test('TextPainter handles newlines properly', () { - final TextPainter painter = new TextPainter() + final TextPainter painter = TextPainter() ..textDirection = TextDirection.ltr; String text = 'aaa'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); Offset caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 0), ui.Rect.zero); expect(caretOffset.dx, closeTo(0.0, 0.0001)); - caretOffset = painter.getOffsetForCaret(new ui.TextPosition(offset: text.length), ui.Rect.zero); + caretOffset = painter.getOffsetForCaret(ui.TextPosition(offset: text.length), ui.Rect.zero); expect(caretOffset.dx, painter.width); expect(caretOffset.dy, closeTo(0.0, 0.0001)); // Check that getOffsetForCaret handles a trailing newline when affinity is downstream. text = 'aaa\n'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); - caretOffset = painter.getOffsetForCaret(new ui.TextPosition(offset: text.length), ui.Rect.zero); + caretOffset = painter.getOffsetForCaret(ui.TextPosition(offset: text.length), ui.Rect.zero); expect(caretOffset.dx, closeTo(0.0, 0.0001)); expect(caretOffset.dy, closeTo(14.0, 0.0001)); // Check that getOffsetForCaret handles a trailing newline when affinity is upstream. text = 'aaa\n'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); - caretOffset = painter.getOffsetForCaret(new ui.TextPosition(offset: text.length, affinity: TextAffinity.upstream), ui.Rect.zero); + caretOffset = painter.getOffsetForCaret(ui.TextPosition(offset: text.length, affinity: TextAffinity.upstream), ui.Rect.zero); expect(caretOffset.dx, painter.width); expect(caretOffset.dy, closeTo(0.0, 0.0001)); // Correctly moves through second line with downstream affinity. text = 'aaa\naaa'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 4), ui.Rect.zero); expect(caretOffset.dx, closeTo(0.0, 0.0001)); @@ -225,7 +225,7 @@ void main() { // Correctly handles multiple trailing newlines. text = 'aaa\n\n\n'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 4), ui.Rect.zero); expect(caretOffset.dx, closeTo(0.0, 0.0001)); @@ -257,7 +257,7 @@ void main() { // Correctly handles multiple leading newlines text = '\n\n\naaa'; - painter.text = new TextSpan(text: text); + painter.text = TextSpan(text: text); painter.layout(); caretOffset = painter.getOffsetForCaret(const ui.TextPosition(offset: 3), ui.Rect.zero); diff --git a/packages/flutter/test/painting/text_span_test.dart b/packages/flutter/test/painting/text_span_test.dart index 9b0126a198..023443b711 100644 --- a/packages/flutter/test/painting/text_span_test.dart +++ b/packages/flutter/test/painting/text_span_test.dart @@ -8,12 +8,12 @@ import '../flutter_test_alternative.dart'; void main() { test('TextSpan equals', () { - final TextSpan a1 = new TextSpan(text: nonconst('a')); - final TextSpan a2 = new TextSpan(text: nonconst('a')); - final TextSpan b1 = new TextSpan(children: [ a1 ]); - final TextSpan b2 = new TextSpan(children: [ a2 ]); - final TextSpan c1 = new TextSpan(text: nonconst(null)); - final TextSpan c2 = new TextSpan(text: nonconst(null)); + final TextSpan a1 = TextSpan(text: nonconst('a')); + final TextSpan a2 = TextSpan(text: nonconst('a')); + final TextSpan b1 = TextSpan(children: [ a1 ]); + final TextSpan b2 = TextSpan(children: [ a2 ]); + final TextSpan c1 = TextSpan(text: nonconst(null)); + final TextSpan c2 = TextSpan(text: nonconst(null)); expect(a1 == a2, isTrue); expect(b1 == b2, isTrue); diff --git a/packages/flutter/test/painting/text_style_test.dart b/packages/flutter/test/painting/text_style_test.dart index de4fb470db..61e4433414 100644 --- a/packages/flutter/test/painting/text_style_test.dart +++ b/packages/flutter/test/painting/text_style_test.dart @@ -162,27 +162,27 @@ void main() { expect(s9.color, isNull); final ui.TextStyle ts5 = s5.getTextStyle(); - expect(ts5, equals(new ui.TextStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0))); + expect(ts5, equals(ui.TextStyle(fontWeight: FontWeight.w700, fontSize: 12.0, height: 123.0))); expect(ts5.toString(), 'TextStyle(color: unspecified, decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontSize: 12.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 123.0x, locale: unspecified, background: unspecified, foreground: unspecified)'); final ui.TextStyle ts2 = s2.getTextStyle(); - expect(ts2, equals(new ui.TextStyle(color: const Color(0xFF00FF00), fontWeight: FontWeight.w800, fontSize: 10.0, height: 100.0))); + expect(ts2, equals(ui.TextStyle(color: const Color(0xFF00FF00), fontWeight: FontWeight.w800, fontSize: 10.0, height: 100.0))); expect(ts2.toString(), 'TextStyle(color: Color(0xff00ff00), decoration: unspecified, decorationColor: unspecified, decorationStyle: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, textBaseline: unspecified, fontFamily: unspecified, fontSize: 10.0, letterSpacing: unspecified, wordSpacing: unspecified, height: 100.0x, locale: unspecified, background: unspecified, foreground: unspecified)'); final ui.ParagraphStyle ps2 = s2.getParagraphStyle(textAlign: TextAlign.center); - expect(ps2, equals(new ui.ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontSize: 10.0, lineHeight: 100.0))); + expect(ps2, equals(ui.ParagraphStyle(textAlign: TextAlign.center, fontWeight: FontWeight.w800, fontSize: 10.0, lineHeight: 100.0))); expect(ps2.toString(), 'ParagraphStyle(textAlign: TextAlign.center, textDirection: unspecified, fontWeight: FontWeight.w800, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 10.0, lineHeight: 100.0x, ellipsis: unspecified, locale: unspecified)'); final ui.ParagraphStyle ps5 = s5.getParagraphStyle(); - expect(ps5, equals(new ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, lineHeight: 123.0))); + expect(ps5, equals(ui.ParagraphStyle(fontWeight: FontWeight.w700, fontSize: 12.0, lineHeight: 123.0))); expect(ps5.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: unspecified, fontWeight: FontWeight.w700, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 12.0, lineHeight: 123.0x, ellipsis: unspecified, locale: unspecified)'); }); test('TextStyle with text direction', () { final ui.ParagraphStyle ps6 = const TextStyle().getParagraphStyle(textDirection: TextDirection.ltr); - expect(ps6, equals(new ui.ParagraphStyle(textDirection: TextDirection.ltr, fontSize: 14.0))); + expect(ps6, equals(ui.ParagraphStyle(textDirection: TextDirection.ltr, fontSize: 14.0))); expect(ps6.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: TextDirection.ltr, fontWeight: unspecified, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 14.0, lineHeight: unspecified, ellipsis: unspecified, locale: unspecified)'); final ui.ParagraphStyle ps7 = const TextStyle().getParagraphStyle(textDirection: TextDirection.rtl); - expect(ps7, equals(new ui.ParagraphStyle(textDirection: TextDirection.rtl, fontSize: 14.0))); + expect(ps7, equals(ui.ParagraphStyle(textDirection: TextDirection.rtl, fontSize: 14.0))); expect(ps7.toString(), 'ParagraphStyle(textAlign: unspecified, textDirection: TextDirection.rtl, fontWeight: unspecified, fontStyle: unspecified, maxLines: unspecified, fontFamily: unspecified, fontSize: 14.0, lineHeight: unspecified, ellipsis: unspecified, locale: unspecified)'); }); @@ -222,8 +222,8 @@ void main() { const Color blue = Color.fromARGB(255, 0, 0, 255); const TextStyle redTextStyle = TextStyle(color: red); const TextStyle blueTextStyle = TextStyle(color: blue); - final TextStyle redPaintTextStyle = new TextStyle(foreground: new Paint()..color = red); - final TextStyle bluePaintTextStyle = new TextStyle(foreground: new Paint()..color = blue); + final TextStyle redPaintTextStyle = TextStyle(foreground: Paint()..color = red); + final TextStyle bluePaintTextStyle = TextStyle(foreground: Paint()..color = blue); // merge/copyWith final TextStyle redBlueBothForegroundMerged = redTextStyle.merge(blueTextStyle); diff --git a/packages/flutter/test/physics/clamped_simulation_test.dart b/packages/flutter/test/physics/clamped_simulation_test.dart index 392a628b40..7d8f04a9c5 100644 --- a/packages/flutter/test/physics/clamped_simulation_test.dart +++ b/packages/flutter/test/physics/clamped_simulation_test.dart @@ -7,8 +7,8 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('Clamped simulation', () { - final GravitySimulation gravity = new GravitySimulation(9.81, 10.0, 0.0, 0.0); - final ClampedSimulation clamped = new ClampedSimulation(gravity, xMin: 20.0, xMax: 100.0, dxMin: 7.0, dxMax: 11.0); + final GravitySimulation gravity = GravitySimulation(9.81, 10.0, 0.0, 0.0); + final ClampedSimulation clamped = ClampedSimulation(gravity, xMin: 20.0, xMax: 100.0, dxMin: 7.0, dxMax: 11.0); expect(clamped.x(0.0), equals(20.0)); expect(clamped.dx(0.0), equals(7.0)); diff --git a/packages/flutter/test/physics/friction_simulation_test.dart b/packages/flutter/test/physics/friction_simulation_test.dart index 6bd003f55b..6c3cd228f4 100644 --- a/packages/flutter/test/physics/friction_simulation_test.dart +++ b/packages/flutter/test/physics/friction_simulation_test.dart @@ -9,7 +9,7 @@ const double _kEpsilon = .00001; void main() { test('Friction simulation positive velocity', () { - final FrictionSimulation friction = new FrictionSimulation(0.135, 100.0, 100.0); + final FrictionSimulation friction = FrictionSimulation(0.135, 100.0, 100.0); expect(friction.x(0.0), closeTo(100.0, _kEpsilon)); expect(friction.dx(0.0), closeTo(100.0, _kEpsilon)); @@ -30,7 +30,7 @@ void main() { }); test('Friction simulation negative velocity', () { - final FrictionSimulation friction = new FrictionSimulation(0.135, 100.0, -100.0); + final FrictionSimulation friction = FrictionSimulation(0.135, 100.0, -100.0); expect(friction.x(0.0), closeTo(100.0, _kEpsilon)); expect(friction.dx(0.0), closeTo(-100.0, _kEpsilon)); diff --git a/packages/flutter/test/physics/gravity_simulation_test.dart b/packages/flutter/test/physics/gravity_simulation_test.dart index 0e4f2c0e05..118803d1e6 100644 --- a/packages/flutter/test/physics/gravity_simulation_test.dart +++ b/packages/flutter/test/physics/gravity_simulation_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('gravity simulation', () { - expect(new GravitySimulation(9.81, 10.0, 0.0, 0.0), hasOneLineDescription); - expect(new GravitySimulation(9.81, 10.0, 0.0, 0.0).x(10.0), moreOrLessEquals(50.0 * 9.81 + 10.0)); + expect(GravitySimulation(9.81, 10.0, 0.0, 0.0), hasOneLineDescription); + expect(GravitySimulation(9.81, 10.0, 0.0, 0.0).x(10.0), moreOrLessEquals(50.0 * 9.81 + 10.0)); }); } diff --git a/packages/flutter/test/physics/newton_test.dart b/packages/flutter/test/physics/newton_test.dart index c2b43583a9..d8f20f13c0 100644 --- a/packages/flutter/test/physics/newton_test.dart +++ b/packages/flutter/test/physics/newton_test.dart @@ -9,7 +9,7 @@ import '../flutter_test_alternative.dart'; void main() { test('test_friction', () { - final FrictionSimulation friction = new FrictionSimulation(0.3, 100.0, 400.0); + final FrictionSimulation friction = FrictionSimulation(0.3, 100.0, 400.0); friction.tolerance = const Tolerance(velocity: 1.0); @@ -33,7 +33,7 @@ void main() { // velocity and positions with drag = 0.025. double startPosition = 10.0; double startVelocity = 600.0; - FrictionSimulation f = new FrictionSimulation(0.025, startPosition, startVelocity); + FrictionSimulation f = FrictionSimulation(0.025, startPosition, startVelocity); double endPosition = f.x(1.0); double endVelocity = f.dx(1.0); expect(endPosition, greaterThan(startPosition)); @@ -42,7 +42,7 @@ void main() { // Verify that that the "through" FrictionSimulation ends up at // endPosition and endVelocity; implies that it computed the right // value for _drag. - FrictionSimulation friction = new FrictionSimulation.through( + FrictionSimulation friction = FrictionSimulation.through( startPosition, endPosition, startVelocity, endVelocity); expect(friction.isDone(0.0), false); expect(friction.x(0.0), 10.0); @@ -57,13 +57,13 @@ void main() { // are negative. startPosition = 1000.0; startVelocity = -500.0; - f = new FrictionSimulation(0.025, 1000.0, -500.0); + f = FrictionSimulation(0.025, 1000.0, -500.0); endPosition = f.x(1.0); endVelocity = f.dx(1.0); expect(endPosition, lessThan(startPosition)); expect(endVelocity, greaterThan(startVelocity)); - friction = new FrictionSimulation.through( + friction = FrictionSimulation.through( startPosition, endPosition, startVelocity, endVelocity); expect(friction.isDone(1.0 + epsilon), true); expect(friction.x(1.0), closeTo(endPosition, epsilon)); @@ -71,7 +71,7 @@ void main() { }); test('BoundedFrictionSimulation control test', () { - final BoundedFrictionSimulation friction = new BoundedFrictionSimulation(0.3, 100.0, 400.0, 50.0, 150.0); + final BoundedFrictionSimulation friction = BoundedFrictionSimulation(0.3, 100.0, 400.0, 50.0, 150.0); friction.tolerance = const Tolerance(velocity: 1.0); @@ -85,7 +85,7 @@ void main() { }); test('test_gravity', () { - final GravitySimulation gravity = new GravitySimulation(200.0, 100.0, 600.0, 0.0); + final GravitySimulation gravity = GravitySimulation(200.0, 100.0, 600.0, 0.0); expect(gravity.isDone(0.0), false); expect(gravity.x(0.0), 100.0); @@ -115,31 +115,31 @@ void main() { }); test('spring_types', () { - SpringSimulation crit = new SpringSimulation(new SpringDescription.withDampingRatio( + SpringSimulation crit = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0), 0.0, 300.0, 0.0); expect(crit.type, SpringType.criticallyDamped); - crit = new SpringSimulation(new SpringDescription.withDampingRatio( + crit = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0, ratio: 1.0), 0.0, 300.0, 0.0); expect(crit.type, SpringType.criticallyDamped); - final SpringSimulation under = new SpringSimulation(new SpringDescription.withDampingRatio( + final SpringSimulation under = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0, ratio: 0.75), 0.0, 300.0, 0.0); expect(under.type, SpringType.underDamped); - final SpringSimulation over = new SpringSimulation(new SpringDescription.withDampingRatio( + final SpringSimulation over = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0, ratio: 1.25), 0.0, 300.0, 0.0); expect(over.type, SpringType.overDamped); // Just so we don't forget how to create a desc without the ratio. - final SpringSimulation other = new SpringSimulation( + final SpringSimulation other = SpringSimulation( const SpringDescription(mass: 1.0, stiffness: 100.0, damping: 20.0), 0.0, 20.0, 20.0); expect(other.type, SpringType.criticallyDamped); }); test('crit_spring', () { - final SpringSimulation crit = new SpringSimulation(new SpringDescription.withDampingRatio( + final SpringSimulation crit = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0, ratio: 1.0), 0.0, 500.0, 0.0); crit.tolerance = const Tolerance(distance: 0.01, velocity: 0.01); @@ -164,7 +164,7 @@ void main() { }); test('overdamped_spring', () { - final SpringSimulation over = new SpringSimulation(new SpringDescription.withDampingRatio( + final SpringSimulation over = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0, ratio: 1.25), 0.0, 500.0, 0.0); over.tolerance = const Tolerance(distance: 0.01, velocity: 0.01); @@ -186,7 +186,7 @@ void main() { }); test('underdamped_spring', () { - final SpringSimulation under = new SpringSimulation(new SpringDescription.withDampingRatio( + final SpringSimulation under = SpringSimulation(SpringDescription.withDampingRatio( mass: 1.0, stiffness: 100.0, ratio: 0.25), 0.0, 300.0, 0.0); expect(under.type, SpringType.underDamped); @@ -203,10 +203,10 @@ void main() { }); test('test_kinetic_scroll', () { - final SpringDescription spring = new SpringDescription.withDampingRatio( + final SpringDescription spring = SpringDescription.withDampingRatio( mass: 1.0, stiffness: 50.0, ratio: 0.5); - final BouncingScrollSimulation scroll = new BouncingScrollSimulation( + final BouncingScrollSimulation scroll = BouncingScrollSimulation( position: 100.0, velocity: 800.0, leadingExtent: 0.0, @@ -218,7 +218,7 @@ void main() { expect(scroll.isDone(0.5), false); // switch from friction to spring expect(scroll.isDone(3.5), true); - final BouncingScrollSimulation scroll2 = new BouncingScrollSimulation( + final BouncingScrollSimulation scroll2 = BouncingScrollSimulation( position: 100.0, velocity: -800.0, leadingExtent: 0.0, @@ -232,10 +232,10 @@ void main() { }); test('scroll_with_inf_edge_ends', () { - final SpringDescription spring = new SpringDescription.withDampingRatio( + final SpringDescription spring = SpringDescription.withDampingRatio( mass: 1.0, stiffness: 50.0, ratio: 0.5); - final BouncingScrollSimulation scroll = new BouncingScrollSimulation( + final BouncingScrollSimulation scroll = BouncingScrollSimulation( position: 100.0, velocity: 400.0, leadingExtent: 0.0, @@ -259,8 +259,8 @@ void main() { }); test('over/under scroll spring', () { - final SpringDescription spring = new SpringDescription.withDampingRatio(mass: 1.0, stiffness: 170.0, ratio: 1.1); - final BouncingScrollSimulation scroll = new BouncingScrollSimulation( + final SpringDescription spring = SpringDescription.withDampingRatio(mass: 1.0, stiffness: 170.0, ratio: 1.1); + final BouncingScrollSimulation scroll = BouncingScrollSimulation( position: 500.0, velocity: -7500.0, leadingExtent: 0.0, diff --git a/packages/flutter/test/rendering/annotated_region_test.dart b/packages/flutter/test/rendering/annotated_region_test.dart index 3cb8a8b45b..807360839d 100644 --- a/packages/flutter/test/rendering/annotated_region_test.dart +++ b/packages/flutter/test/rendering/annotated_region_test.dart @@ -9,15 +9,15 @@ import '../flutter_test_alternative.dart'; void main() { group(AnnotatedRegion, () { test('finds the first value in a OffsetLayer when sized', () { - final ContainerLayer containerLayer = new ContainerLayer(); + final ContainerLayer containerLayer = ContainerLayer(); final List layers = [ - new OffsetLayer(offset: Offset.zero), - new OffsetLayer(offset: const Offset(0.0, 100.0)), - new OffsetLayer(offset: const Offset(0.0, 200.0)), + OffsetLayer(offset: Offset.zero), + OffsetLayer(offset: const Offset(0.0, 100.0)), + OffsetLayer(offset: const Offset(0.0, 200.0)), ]; int i = 0; for (OffsetLayer layer in layers) { - layer.append(new AnnotatedRegionLayer(i, size: const Size(200.0, 100.0))); + layer.append(AnnotatedRegionLayer(i, size: const Size(200.0, 100.0))); containerLayer.append(layer); i += 1; } @@ -28,15 +28,15 @@ void main() { }); test('finds a value within the clip in a ClipRectLayer', () { - final ContainerLayer containerLayer = new ContainerLayer(); + final ContainerLayer containerLayer = ContainerLayer(); final List layers = [ - new ClipRectLayer(clipRect: new Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)), - new ClipRectLayer(clipRect: new Rect.fromLTRB(0.0, 100.0, 100.0, 200.0)), - new ClipRectLayer(clipRect: new Rect.fromLTRB(0.0, 200.0, 100.0, 300.0)), + ClipRectLayer(clipRect: Rect.fromLTRB(0.0, 0.0, 100.0, 100.0)), + ClipRectLayer(clipRect: Rect.fromLTRB(0.0, 100.0, 100.0, 200.0)), + ClipRectLayer(clipRect: Rect.fromLTRB(0.0, 200.0, 100.0, 300.0)), ]; int i = 0; for (ClipRectLayer layer in layers) { - layer.append(new AnnotatedRegionLayer(i)); + layer.append(AnnotatedRegionLayer(i)); containerLayer.append(layer); i += 1; } @@ -48,15 +48,15 @@ void main() { test('finds a value within the clip in a ClipRRectLayer', () { - final ContainerLayer containerLayer = new ContainerLayer(); + final ContainerLayer containerLayer = ContainerLayer(); final List layers = [ - new ClipRRectLayer(clipRRect: new RRect.fromLTRBR(0.0, 0.0, 100.0, 100.0, const Radius.circular(4.0))), - new ClipRRectLayer(clipRRect: new RRect.fromLTRBR(0.0, 100.0, 100.0, 200.0, const Radius.circular(4.0))), - new ClipRRectLayer(clipRRect: new RRect.fromLTRBR(0.0, 200.0, 100.0, 300.0, const Radius.circular(4.0))), + ClipRRectLayer(clipRRect: RRect.fromLTRBR(0.0, 0.0, 100.0, 100.0, const Radius.circular(4.0))), + ClipRRectLayer(clipRRect: RRect.fromLTRBR(0.0, 100.0, 100.0, 200.0, const Radius.circular(4.0))), + ClipRRectLayer(clipRRect: RRect.fromLTRBR(0.0, 200.0, 100.0, 300.0, const Radius.circular(4.0))), ]; int i = 0; for (ClipRRectLayer layer in layers) { - layer.append(new AnnotatedRegionLayer(i)); + layer.append(AnnotatedRegionLayer(i)); containerLayer.append(layer); i += 1; } @@ -67,21 +67,21 @@ void main() { }); test('finds a value under a TransformLayer', () { - final Matrix4 transform = new Matrix4( + final Matrix4 transform = Matrix4( 2.625, 0.0, 0.0, 0.0, 0.0, 2.625, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, ); - final TransformLayer transformLayer = new TransformLayer(transform: transform); + final TransformLayer transformLayer = TransformLayer(transform: transform); final List layers = [ - new OffsetLayer(), - new OffsetLayer(offset: const Offset(0.0, 100.0)), - new OffsetLayer(offset: const Offset(0.0, 200.0)), + OffsetLayer(), + OffsetLayer(offset: const Offset(0.0, 100.0)), + OffsetLayer(offset: const Offset(0.0, 200.0)), ]; int i = 0; for (OffsetLayer layer in layers) { - final AnnotatedRegionLayer annotatedRegionLayer = new AnnotatedRegionLayer(i, size: const Size(100.0, 100.0)); + final AnnotatedRegionLayer annotatedRegionLayer = AnnotatedRegionLayer(i, size: const Size(100.0, 100.0)); layer.append(annotatedRegionLayer); transformLayer.append(layer); i += 1; @@ -95,9 +95,9 @@ void main() { }); test('looks for child AnnotatedRegions before parents', () { - final AnnotatedRegionLayer parent = new AnnotatedRegionLayer(1); - final AnnotatedRegionLayer child = new AnnotatedRegionLayer(2); - final ContainerLayer layer = new ContainerLayer(); + final AnnotatedRegionLayer parent = AnnotatedRegionLayer(1); + final AnnotatedRegionLayer child = AnnotatedRegionLayer(2); + final ContainerLayer layer = ContainerLayer(); parent.append(child); layer.append(parent); @@ -105,9 +105,9 @@ void main() { }); test('looks for correct type', () { - final AnnotatedRegionLayer child1 = new AnnotatedRegionLayer(1); - final AnnotatedRegionLayer child2 = new AnnotatedRegionLayer('hello'); - final ContainerLayer layer = new ContainerLayer(); + final AnnotatedRegionLayer child1 = AnnotatedRegionLayer(1); + final AnnotatedRegionLayer child2 = AnnotatedRegionLayer('hello'); + final ContainerLayer layer = ContainerLayer(); layer.append(child2); layer.append(child1); @@ -115,9 +115,9 @@ void main() { }); test('does not clip Layer.find on an AnnotatedRegion with an unrelated type', () { - final AnnotatedRegionLayer child = new AnnotatedRegionLayer(1); - final AnnotatedRegionLayer parent = new AnnotatedRegionLayer('hello', size: const Size(10.0, 10.0)); - final ContainerLayer layer = new ContainerLayer(); + final AnnotatedRegionLayer child = AnnotatedRegionLayer(1); + final AnnotatedRegionLayer parent = AnnotatedRegionLayer('hello', size: const Size(10.0, 10.0)); + final ContainerLayer layer = ContainerLayer(); parent.append(child); layer.append(parent); @@ -125,13 +125,13 @@ void main() { }); test('handles non-invertable transforms', () { - final AnnotatedRegionLayer child = new AnnotatedRegionLayer(1); - final TransformLayer parent = new TransformLayer(transform: new Matrix4.diagonal3Values(0.0, 1.0, 1.0)); + final AnnotatedRegionLayer child = AnnotatedRegionLayer(1); + final TransformLayer parent = TransformLayer(transform: Matrix4.diagonal3Values(0.0, 1.0, 1.0)); parent.append(child); expect(parent.find(const Offset(0.0, 0.0)), null); - parent.transform = new Matrix4.diagonal3Values(1.0, 1.0, 1.0); + parent.transform = Matrix4.diagonal3Values(1.0, 1.0, 1.0); expect(parent.find(const Offset(0.0, 0.0)), 1); }); diff --git a/packages/flutter/test/rendering/aspect_ratio_test.dart b/packages/flutter/test/rendering/aspect_ratio_test.dart index ff4aa6b5e6..47d8f58009 100644 --- a/packages/flutter/test/rendering/aspect_ratio_test.dart +++ b/packages/flutter/test/rendering/aspect_ratio_test.dart @@ -9,7 +9,7 @@ import 'rendering_tester.dart'; void main() { test('RenderAspectRatio: Intrinsic sizing 2.0', () { - final RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 2.0); + final RenderAspectRatio box = RenderAspectRatio(aspectRatio: 2.0); expect(box.getMinIntrinsicWidth(200.0), 400.0); expect(box.getMinIntrinsicWidth(400.0), 800.0); @@ -30,7 +30,7 @@ void main() { }); test('RenderAspectRatio: Intrinsic sizing 0.5', () { - final RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 0.5); + final RenderAspectRatio box = RenderAspectRatio(aspectRatio: 0.5); expect(box.getMinIntrinsicWidth(200.0), 100.0); expect(box.getMinIntrinsicWidth(400.0), 200.0); @@ -51,9 +51,9 @@ void main() { }); test('RenderAspectRatio: Intrinsic sizing 2.0', () { - final RenderAspectRatio box = new RenderAspectRatio( + final RenderAspectRatio box = RenderAspectRatio( aspectRatio: 2.0, - child: new RenderSizedBox(const Size(90.0, 70.0)) + child: RenderSizedBox(const Size(90.0, 70.0)) ); expect(box.getMinIntrinsicWidth(200.0), 400.0); @@ -75,9 +75,9 @@ void main() { }); test('RenderAspectRatio: Intrinsic sizing 0.5', () { - final RenderAspectRatio box = new RenderAspectRatio( + final RenderAspectRatio box = RenderAspectRatio( aspectRatio: 0.5, - child: new RenderSizedBox(const Size(90.0, 70.0)) + child: RenderSizedBox(const Size(90.0, 70.0)) ); expect(box.getMinIntrinsicWidth(200.0), 100.0); @@ -104,12 +104,12 @@ void main() { FlutterError.onError = (FlutterErrorDetails details) { hadError = true; }; - final RenderBox box = new RenderConstrainedOverflowBox( + final RenderBox box = RenderConstrainedOverflowBox( maxWidth: double.infinity, maxHeight: double.infinity, - child: new RenderAspectRatio( + child: RenderAspectRatio( aspectRatio: 0.5, - child: new RenderSizedBox(const Size(90.0, 70.0)) + child: RenderSizedBox(const Size(90.0, 70.0)) ), ); expect(hadError, false); @@ -121,8 +121,8 @@ void main() { test('RenderAspectRatio: Sizing', () { RenderConstrainedOverflowBox outside; RenderAspectRatio inside; - layout(outside = new RenderConstrainedOverflowBox( - child: inside = new RenderAspectRatio(aspectRatio: 1.0), + layout(outside = RenderConstrainedOverflowBox( + child: inside = RenderAspectRatio(aspectRatio: 1.0), )); pumpFrame(); expect(inside.size, const Size(800.0, 600.0)); diff --git a/packages/flutter/test/rendering/baseline_test.dart b/packages/flutter/test/rendering/baseline_test.dart index 02d7ea11ce..b9b15ec5fc 100644 --- a/packages/flutter/test/rendering/baseline_test.dart +++ b/packages/flutter/test/rendering/baseline_test.dart @@ -12,12 +12,12 @@ void main() { test('RenderBaseline', () { RenderBaseline parent; RenderSizedBox child; - final RenderBox root = new RenderPositionedBox( + final RenderBox root = RenderPositionedBox( alignment: Alignment.topLeft, - child: parent = new RenderBaseline( + child: parent = RenderBaseline( baseline: 0.0, baselineType: TextBaseline.alphabetic, - child: child = new RenderSizedBox(const Size(100.0, 100.0)) + child: child = RenderSizedBox(const Size(100.0, 100.0)) ) ); final BoxParentData childParentData = child.parentData; diff --git a/packages/flutter/test/rendering/box_test.dart b/packages/flutter/test/rendering/box_test.dart index 16893fb113..81043862f6 100644 --- a/packages/flutter/test/rendering/box_test.dart +++ b/packages/flutter/test/rendering/box_test.dart @@ -10,10 +10,10 @@ import 'rendering_tester.dart'; void main() { test('should size to render view', () { - final RenderBox root = new RenderDecoratedBox( - decoration: new BoxDecoration( + final RenderBox root = RenderDecoratedBox( + decoration: BoxDecoration( color: const Color(0xFF00FF00), - gradient: new RadialGradient( + gradient: RadialGradient( center: Alignment.topLeft, radius: 1.8, colors: [Colors.yellow[500], Colors.blue[500]], @@ -27,25 +27,25 @@ void main() { }); test('Flex and padding', () { - final RenderBox size = new RenderConstrainedBox( + final RenderBox size = RenderConstrainedBox( additionalConstraints: const BoxConstraints().tighten(height: 100.0), ); - final RenderBox inner = new RenderDecoratedBox( + final RenderBox inner = RenderDecoratedBox( decoration: const BoxDecoration( color: Color(0xFF00FF00), ), child: size, ); - final RenderBox padding = new RenderPadding( + final RenderBox padding = RenderPadding( padding: const EdgeInsets.all(50.0), child: inner, ); - final RenderBox flex = new RenderFlex( + final RenderBox flex = RenderFlex( children: [padding], direction: Axis.vertical, crossAxisAlignment: CrossAxisAlignment.stretch, ); - final RenderBox outer = new RenderDecoratedBox( + final RenderBox outer = RenderDecoratedBox( decoration: const BoxDecoration( color: Color(0xFF0000FF), ), @@ -67,7 +67,7 @@ void main() { }); test('should not have a 0 sized colored Box', () { - final RenderBox coloredBox = new RenderDecoratedBox( + final RenderBox coloredBox = RenderDecoratedBox( decoration: const BoxDecoration(), ); @@ -84,11 +84,11 @@ void main() { ' configuration: ImageConfiguration()\n'), ); - final RenderBox paddingBox = new RenderPadding( + final RenderBox paddingBox = RenderPadding( padding: const EdgeInsets.all(10.0), child: coloredBox, ); - final RenderBox root = new RenderDecoratedBox( + final RenderBox root = RenderDecoratedBox( decoration: const BoxDecoration(), child: paddingBox, ); @@ -112,11 +112,11 @@ void main() { }); test('reparenting should clear position', () { - final RenderDecoratedBox coloredBox = new RenderDecoratedBox( + final RenderDecoratedBox coloredBox = RenderDecoratedBox( decoration: const BoxDecoration(), ); - final RenderPadding paddedBox = new RenderPadding( + final RenderPadding paddedBox = RenderPadding( child: coloredBox, padding: const EdgeInsets.all(10.0), ); @@ -125,7 +125,7 @@ void main() { expect(parentData.offset.dx, isNot(equals(0.0))); paddedBox.child = null; - final RenderConstrainedBox constraintedBox = new RenderConstrainedBox( + final RenderConstrainedBox constraintedBox = RenderConstrainedBox( child: coloredBox, additionalConstraints: const BoxConstraints(), ); @@ -134,10 +134,10 @@ void main() { }); test('UnconstrainedBox expands to fit children', () { - final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( + final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox( constrainedAxis: Axis.horizontal, // This is reset to null below. textDirection: TextDirection.ltr, - child: new RenderConstrainedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 200.0, height: 200.0), ), alignment: Alignment.center, @@ -160,9 +160,9 @@ void main() { }); test('UnconstrainedBox handles vertical overflow', () { - final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( + final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox( textDirection: TextDirection.ltr, - child: new RenderConstrainedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 200.0), ), alignment: Alignment.center, @@ -176,9 +176,9 @@ void main() { }); test('UnconstrainedBox handles horizontal overflow', () { - final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( + final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox( textDirection: TextDirection.ltr, - child: new RenderConstrainedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 200.0), ), alignment: Alignment.center, @@ -192,7 +192,7 @@ void main() { }); test('UnconstrainedBox.toStringDeep returns useful information', () { - final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( + final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox( textDirection: TextDirection.ltr, alignment: Alignment.center, ); @@ -213,11 +213,11 @@ void main() { test('UnconstrainedBox honors constrainedAxis=Axis.horizontal', () { final RenderConstrainedBox flexible = - new RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(height: 200.0)); - final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( + RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(height: 200.0)); + final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox( constrainedAxis: Axis.horizontal, textDirection: TextDirection.ltr, - child: new RenderFlex( + child: RenderFlex( direction: Axis.horizontal, textDirection: TextDirection.ltr, children: [flexible], @@ -237,11 +237,11 @@ void main() { test('UnconstrainedBox honors constrainedAxis=Axis.vertical', () { final RenderConstrainedBox flexible = - new RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(width: 200.0)); - final RenderUnconstrainedBox unconstrained = new RenderUnconstrainedBox( + RenderConstrainedBox(additionalConstraints: const BoxConstraints.expand(width: 200.0)); + final RenderUnconstrainedBox unconstrained = RenderUnconstrainedBox( constrainedAxis: Axis.vertical, textDirection: TextDirection.ltr, - child: new RenderFlex( + child: RenderFlex( direction: Axis.vertical, textDirection: TextDirection.ltr, children: [flexible], diff --git a/packages/flutter/test/rendering/cached_intrinsics_test.dart b/packages/flutter/test/rendering/cached_intrinsics_test.dart index c167a639ce..241181b98c 100644 --- a/packages/flutter/test/rendering/cached_intrinsics_test.dart +++ b/packages/flutter/test/rendering/cached_intrinsics_test.dart @@ -16,7 +16,7 @@ class RenderTestBox extends RenderBox { void main() { test('Intrinsics cache', () { - final RenderBox test = new RenderTestBox(); + final RenderBox test = RenderTestBox(); expect(test.getMinIntrinsicWidth(0.0), equals(1.0)); expect(test.getMinIntrinsicWidth(100.0), equals(2.0)); diff --git a/packages/flutter/test/rendering/constraints_test.dart b/packages/flutter/test/rendering/constraints_test.dart index 4a8dbc026b..ea85b1a747 100644 --- a/packages/flutter/test/rendering/constraints_test.dart +++ b/packages/flutter/test/rendering/constraints_test.dart @@ -10,13 +10,13 @@ import 'rendering_tester.dart'; void main() { test('RenderFractionallySizedBox constraints', () { RenderBox root, leaf, test; - root = new RenderPositionedBox( - child: new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(200.0, 200.0)), - child: test = new RenderFractionallySizedOverflowBox( + root = RenderPositionedBox( + child: RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(200.0, 200.0)), + child: test = RenderFractionallySizedOverflowBox( widthFactor: 2.0, heightFactor: 0.5, - child: leaf = new RenderConstrainedBox( + child: leaf = RenderConstrainedBox( additionalConstraints: const BoxConstraints.expand() ) ) diff --git a/packages/flutter/test/rendering/debug_test.dart b/packages/flutter/test/rendering/debug_test.dart index f4a8d6dca5..4d1f8f9f7b 100644 --- a/packages/flutter/test/rendering/debug_test.dart +++ b/packages/flutter/test/rendering/debug_test.dart @@ -12,7 +12,7 @@ import 'rendering_tester.dart'; void main() { test('Describe transform control test', () { - final Matrix4 identity = new Matrix4.identity(); + final Matrix4 identity = Matrix4.identity(); final List description = debugDescribeTransform(identity); expect(description, equals([ '[0] 1.0,0.0,0.0,0.0', @@ -23,8 +23,8 @@ void main() { }); test('transform property test', () { - final Matrix4 transform = new Matrix4.diagonal3(new Vector3.all(2.0)); - final TransformProperty simple = new TransformProperty( + final Matrix4 transform = Matrix4.diagonal3(Vector3.all(2.0)); + final TransformProperty simple = TransformProperty( 'transform', transform, ); @@ -45,7 +45,7 @@ void main() { equals('transform: [2.0,0.0,0.0,0.0; 0.0,2.0,0.0,0.0; 0.0,0.0,2.0,0.0; 0.0,0.0,0.0,1.0]'), ); - final TransformProperty nullProperty = new TransformProperty( + final TransformProperty nullProperty = TransformProperty( 'transform', null, ); @@ -53,7 +53,7 @@ void main() { expect(nullProperty.value, isNull); expect(nullProperty.toString(), equals('transform: null')); - final TransformProperty hideNull = new TransformProperty( + final TransformProperty hideNull = TransformProperty( 'transform', null, defaultValue: null, @@ -64,28 +64,28 @@ void main() { test('debugPaintPadding', () { expect((Canvas canvas) { - debugPaintPadding(canvas, new Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), null); + debugPaintPadding(canvas, Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), null); }, paints..rect(color: const Color(0x90909090))); expect((Canvas canvas) { - debugPaintPadding(canvas, new Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), new Rect.fromLTRB(11.0, 11.0, 19.0, 19.0)); + debugPaintPadding(canvas, Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), Rect.fromLTRB(11.0, 11.0, 19.0, 19.0)); }, paints..path(color: const Color(0x900090FF))..path(color: const Color(0xFF0090FF))); expect((Canvas canvas) { - debugPaintPadding(canvas, new Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), new Rect.fromLTRB(15.0, 15.0, 15.0, 15.0)); - }, paints..rect(rect: new Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), color: const Color(0x90909090))); + debugPaintPadding(canvas, Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), Rect.fromLTRB(15.0, 15.0, 15.0, 15.0)); + }, paints..rect(rect: Rect.fromLTRB(10.0, 10.0, 20.0, 20.0), color: const Color(0x90909090))); }); test('debugPaintPadding from render objects', () { debugPaintSizeEnabled = true; RenderSliver s; RenderBox b; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - s = new RenderSliverPadding( + s = RenderSliverPadding( padding: const EdgeInsets.all(10.0), - child: new RenderSliverToBoxAdapter( - child: b = new RenderPadding( + child: RenderSliverToBoxAdapter( + child: b = RenderPadding( padding: const EdgeInsets.all(10.0), ), ), @@ -104,13 +104,13 @@ void main() { test('debugPaintPadding from render objects', () { debugPaintSizeEnabled = true; RenderSliver s; - final RenderBox b = new RenderPadding( + final RenderBox b = RenderPadding( padding: const EdgeInsets.all(10.0), - child: new RenderViewport( + child: RenderViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - s = new RenderSliverPadding( + s = RenderSliverPadding( padding: const EdgeInsets.all(10.0), ), ], diff --git a/packages/flutter/test/rendering/dynamic_intrinsics_test.dart b/packages/flutter/test/rendering/dynamic_intrinsics_test.dart index 4cc6a598b3..a8c0387094 100644 --- a/packages/flutter/test/rendering/dynamic_intrinsics_test.dart +++ b/packages/flutter/test/rendering/dynamic_intrinsics_test.dart @@ -22,7 +22,7 @@ class RenderFixedSize extends RenderBox { @override void performLayout() { - size = new Size.square(dimension); + size = Size.square(dimension); } } @@ -49,7 +49,7 @@ class RenderIntrinsicSize extends RenderProxyBox { @override void performLayout() { child.layout(constraints); - size = new Size( + size = Size( child.getMinIntrinsicWidth(double.infinity), child.getMinIntrinsicHeight(double.infinity) ); @@ -61,9 +61,9 @@ void main() { RenderBox root; RenderFixedSize inner; layout( - root = new RenderIntrinsicSize( - child: new RenderParentSize( - child: inner = new RenderFixedSize() + root = RenderIntrinsicSize( + child: RenderParentSize( + child: inner = RenderFixedSize() ) ), constraints: const BoxConstraints( diff --git a/packages/flutter/test/rendering/editable_test.dart b/packages/flutter/test/rendering/editable_test.dart index f19d122784..53b4ff05a4 100644 --- a/packages/flutter/test/rendering/editable_test.dart +++ b/packages/flutter/test/rendering/editable_test.dart @@ -22,8 +22,8 @@ class FakeEditableTextState extends TextSelectionDelegate { void main() { test('editable intrinsics', () { - final TextSelectionDelegate delegate = new FakeEditableTextState(); - final RenderEditable editable = new RenderEditable( + final TextSelectionDelegate delegate = FakeEditableTextState(); + final RenderEditable editable = RenderEditable( text: const TextSpan( style: TextStyle(height: 1.0, fontSize: 10.0, fontFamily: 'Ahem'), text: '12345', @@ -31,7 +31,7 @@ void main() { textAlign: TextAlign.start, textDirection: TextDirection.ltr, locale: const Locale('ja', 'JP'), - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), textSelectionDelegate: delegate, ); expect(editable.getMinIntrinsicWidth(double.infinity), 50.0); diff --git a/packages/flutter/test/rendering/error_test.dart b/packages/flutter/test/rendering/error_test.dart index 20b1d76118..52513463f4 100644 --- a/packages/flutter/test/rendering/error_test.dart +++ b/packages/flutter/test/rendering/error_test.dart @@ -13,10 +13,10 @@ void main() { const String errorMessage = 'Some error message'; testWidgets('test draw error paragraph', (WidgetTester tester) async { - await tester.pumpWidget(new ErrorWidget(new Exception(errorMessage))); + await tester.pumpWidget(ErrorWidget(Exception(errorMessage))); expect(find.byType(ErrorWidget), paints - ..rect(rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0)) + ..rect(rect: Rect.fromLTWH(0.0, 0.0, 800.0, 600.0)) ..paragraph(offset: Offset.zero)); }); } diff --git a/packages/flutter/test/rendering/flex_overflow_test.dart b/packages/flutter/test/rendering/flex_overflow_test.dart index 1f955464d3..ef4a45f827 100644 --- a/packages/flutter/test/rendering/flex_overflow_test.dart +++ b/packages/flutter/test/rendering/flex_overflow_test.dart @@ -10,8 +10,8 @@ import 'mock_canvas.dart'; void main() { testWidgets('Flex overflow indicator', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new Column( + Center( + child: Column( children: const [ SizedBox(width: 200.0, height: 200.0), ], @@ -22,10 +22,10 @@ void main() { expect(find.byType(Column), isNot(paints..rect())); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( height: 100.0, - child: new Column( + child: Column( children: const [ SizedBox(width: 200.0, height: 200.0), ], @@ -39,10 +39,10 @@ void main() { expect(find.byType(Column), paints..rect()); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( height: 0.0, - child: new Column( + child: Column( children: const [ SizedBox(width: 200.0, height: 200.0), ], diff --git a/packages/flutter/test/rendering/flex_test.dart b/packages/flutter/test/rendering/flex_test.dart index 801d9c9fa6..295ddfb4c2 100644 --- a/packages/flutter/test/rendering/flex_test.dart +++ b/packages/flutter/test/rendering/flex_test.dart @@ -10,8 +10,8 @@ import 'rendering_tester.dart'; void main() { test('Overconstrained flex', () { - final RenderDecoratedBox box = new RenderDecoratedBox(decoration: const BoxDecoration()); - final RenderFlex flex = new RenderFlex(textDirection: TextDirection.ltr, children: [box]); + final RenderDecoratedBox box = RenderDecoratedBox(decoration: const BoxDecoration()); + final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr, children: [box]); layout(flex, constraints: const BoxConstraints( minWidth: 200.0, maxWidth: 200.0, minHeight: 200.0, maxHeight: 200.0) ); @@ -21,14 +21,14 @@ void main() { }); test('Vertical Overflow', () { - final RenderConstrainedBox flexible = new RenderConstrainedBox( + final RenderConstrainedBox flexible = RenderConstrainedBox( additionalConstraints: const BoxConstraints.expand() ); - final RenderFlex flex = new RenderFlex( + final RenderFlex flex = RenderFlex( direction: Axis.vertical, verticalDirection: VerticalDirection.down, children: [ - new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 200.0)), + RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 200.0)), flexible, ] ); @@ -44,14 +44,14 @@ void main() { }); test('Horizontal Overflow', () { - final RenderConstrainedBox flexible = new RenderConstrainedBox( + final RenderConstrainedBox flexible = RenderConstrainedBox( additionalConstraints: const BoxConstraints.expand() ); - final RenderFlex flex = new RenderFlex( + final RenderFlex flex = RenderFlex( direction: Axis.horizontal, textDirection: TextDirection.ltr, children: [ - new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 200.0)), + RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 200.0)), flexible, ] ); @@ -67,11 +67,11 @@ void main() { }); test('Vertical Flipped Constraints', () { - final RenderFlex flex = new RenderFlex( + final RenderFlex flex = RenderFlex( direction: Axis.vertical, verticalDirection: VerticalDirection.down, children: [ - new RenderAspectRatio(aspectRatio: 1.0), + RenderAspectRatio(aspectRatio: 1.0), ] ); const BoxConstraints viewport = BoxConstraints(maxHeight: 200.0, maxWidth: 1000.0); @@ -83,7 +83,7 @@ void main() { // RenderAspectRatio being height-in, width-out. test('Defaults', () { - final RenderFlex flex = new RenderFlex(); + final RenderFlex flex = RenderFlex(); expect(flex.crossAxisAlignment, equals(CrossAxisAlignment.center)); expect(flex.direction, equals(Axis.horizontal)); expect(flex, hasAGoodToStringDeep); @@ -104,9 +104,9 @@ void main() { }); test('Parent data', () { - final RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: const BoxDecoration()); - final RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: const BoxDecoration()); - final RenderFlex flex = new RenderFlex(textDirection: TextDirection.ltr, children: [box1, box2]); + final RenderDecoratedBox box1 = RenderDecoratedBox(decoration: const BoxDecoration()); + final RenderDecoratedBox box2 = RenderDecoratedBox(decoration: const BoxDecoration()); + final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr, children: [box1, box2]); layout(flex, constraints: const BoxConstraints( minWidth: 0.0, maxWidth: 100.0, minHeight: 0.0, maxHeight: 100.0) ); @@ -126,9 +126,9 @@ void main() { }); test('Stretch', () { - final RenderDecoratedBox box1 = new RenderDecoratedBox(decoration: const BoxDecoration()); - final RenderDecoratedBox box2 = new RenderDecoratedBox(decoration: const BoxDecoration()); - final RenderFlex flex = new RenderFlex(textDirection: TextDirection.ltr); + final RenderDecoratedBox box1 = RenderDecoratedBox(decoration: const BoxDecoration()); + final RenderDecoratedBox box2 = RenderDecoratedBox(decoration: const BoxDecoration()); + final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr); flex.setupParentData(box2); final FlexParentData box2ParentData = box2.parentData; box2ParentData.flex = 2; @@ -157,10 +157,10 @@ void main() { }); test('Space evenly', () { - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderFlex flex = new RenderFlex(textDirection: TextDirection.ltr, mainAxisAlignment: MainAxisAlignment.spaceEvenly); + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr, mainAxisAlignment: MainAxisAlignment.spaceEvenly); flex.addAll([box1, box2, box3]); layout(flex, constraints: const BoxConstraints( minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0) @@ -187,10 +187,10 @@ void main() { }); test('Fit.loose', () { - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderFlex flex = new RenderFlex(textDirection: TextDirection.ltr, mainAxisAlignment: MainAxisAlignment.spaceBetween); + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr, mainAxisAlignment: MainAxisAlignment.spaceBetween); flex.addAll([box1, box2, box3]); layout(flex, constraints: const BoxConstraints( minWidth: 0.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: 400.0) @@ -235,10 +235,10 @@ void main() { }); test('Flexible with MainAxisSize.min', () { - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); - final RenderFlex flex = new RenderFlex( + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(width: 100.0, height: 100.0)); + final RenderFlex flex = RenderFlex( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.spaceBetween, @@ -293,14 +293,14 @@ void main() { test('MainAxisSize.min inside unconstrained', () { FlutterError.onError = (FlutterErrorDetails details) => throw details.exception; const BoxConstraints square = BoxConstraints.tightFor(width: 100.0, height: 100.0); - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); - final RenderFlex flex = new RenderFlex( + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: square); + final RenderFlex flex = RenderFlex( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, ); - final RenderConstrainedOverflowBox parent = new RenderConstrainedOverflowBox( + final RenderConstrainedOverflowBox parent = RenderConstrainedOverflowBox( minWidth: 0.0, maxWidth: double.infinity, minHeight: 0.0, @@ -338,14 +338,14 @@ void main() { exceptions.add(details.exception); }; const BoxConstraints square = BoxConstraints.tightFor(width: 100.0, height: 100.0); - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); - final RenderFlex flex = new RenderFlex( + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: square); + final RenderFlex flex = RenderFlex( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, ); - final RenderConstrainedOverflowBox parent = new RenderConstrainedOverflowBox( + final RenderConstrainedOverflowBox parent = RenderConstrainedOverflowBox( minWidth: 0.0, maxWidth: double.infinity, minHeight: 0.0, @@ -367,14 +367,14 @@ void main() { exceptions.add(details.exception); }; const BoxConstraints square = BoxConstraints.tightFor(width: 100.0, height: 100.0); - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); - final RenderFlex flex = new RenderFlex( + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: square); + final RenderFlex flex = RenderFlex( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.max, ); - final RenderConstrainedOverflowBox parent = new RenderConstrainedOverflowBox( + final RenderConstrainedOverflowBox parent = RenderConstrainedOverflowBox( minWidth: 0.0, maxWidth: double.infinity, minHeight: 0.0, @@ -393,10 +393,10 @@ void main() { test('MainAxisSize.min inside tightly constrained', () { const BoxConstraints square = BoxConstraints.tightFor(width: 100.0, height: 100.0); - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); - final RenderFlex flex = new RenderFlex( + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: square); + final RenderFlex flex = RenderFlex( textDirection: TextDirection.rtl, mainAxisSize: MainAxisSize.min, ); @@ -413,10 +413,10 @@ void main() { test('Flex RTL', () { const BoxConstraints square = BoxConstraints.tightFor(width: 100.0, height: 100.0); - final RenderConstrainedBox box1 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box2 = new RenderConstrainedBox(additionalConstraints: square); - final RenderConstrainedBox box3 = new RenderConstrainedBox(additionalConstraints: square); - final RenderFlex flex = new RenderFlex(textDirection: TextDirection.ltr, children: [box1, box2, box3]); + final RenderConstrainedBox box1 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box2 = RenderConstrainedBox(additionalConstraints: square); + final RenderConstrainedBox box3 = RenderConstrainedBox(additionalConstraints: square); + final RenderFlex flex = RenderFlex(textDirection: TextDirection.ltr, children: [box1, box2, box3]); layout(flex); expect(box1.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 250.0)); expect(box2.localToGlobal(const Offset(0.0, 0.0)), const Offset(100.0, 250.0)); diff --git a/packages/flutter/test/rendering/image_test.dart b/packages/flutter/test/rendering/image_test.dart index d9143a1a2a..ece64de3dc 100644 --- a/packages/flutter/test/rendering/image_test.dart +++ b/packages/flutter/test/rendering/image_test.dart @@ -20,7 +20,7 @@ class SquareImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } @override @@ -39,7 +39,7 @@ class WideImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } @override @@ -58,7 +58,7 @@ class TallImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } @override @@ -72,7 +72,7 @@ void main() { test('Image sizing', () { RenderImage image; - image = new RenderImage(image: new SquareImage()); + image = RenderImage(image: SquareImage()); layout(image, constraints: const BoxConstraints( minWidth: 25.0, @@ -95,7 +95,7 @@ void main() { ), ); - image = new RenderImage(image: new WideImage()); + image = RenderImage(image: WideImage()); layout(image, constraints: const BoxConstraints( minWidth: 5.0, @@ -105,7 +105,7 @@ void main() { expect(image.size.width, equals(60.0)); expect(image.size.height, equals(30.0)); - image = new RenderImage(image: new TallImage()); + image = RenderImage(image: TallImage()); layout(image, constraints: const BoxConstraints( minWidth: 50.0, @@ -115,7 +115,7 @@ void main() { expect(image.size.width, equals(50.0)); expect(image.size.height, equals(75.0)); - image = new RenderImage(image: new WideImage()); + image = RenderImage(image: WideImage()); layout(image, constraints: const BoxConstraints( minWidth: 5.0, @@ -125,7 +125,7 @@ void main() { expect(image.size.width, equals(20.0)); expect(image.size.height, equals(10.0)); - image = new RenderImage(image: new WideImage()); + image = RenderImage(image: WideImage()); layout(image, constraints: const BoxConstraints( minWidth: 5.0, @@ -135,7 +135,7 @@ void main() { expect(image.size.width, equals(16.0)); expect(image.size.height, equals(8.0)); - image = new RenderImage(image: new TallImage()); + image = RenderImage(image: TallImage()); layout(image, constraints: const BoxConstraints( minWidth: 5.0, @@ -145,7 +145,7 @@ void main() { expect(image.size.width, equals(8.0)); expect(image.size.height, equals(16.0)); - image = new RenderImage(image: new SquareImage()); + image = RenderImage(image: SquareImage()); layout(image, constraints: const BoxConstraints( minWidth: 4.0, @@ -155,7 +155,7 @@ void main() { expect(image.size.width, equals(8.0)); expect(image.size.height, equals(8.0)); - image = new RenderImage(image: new WideImage()); + image = RenderImage(image: WideImage()); layout(image, constraints: const BoxConstraints( minWidth: 20.0, @@ -165,7 +165,7 @@ void main() { expect(image.size.width, equals(30.0)); expect(image.size.height, equals(20.0)); - image = new RenderImage(image: new TallImage()); + image = RenderImage(image: TallImage()); layout(image, constraints: const BoxConstraints( minWidth: 20.0, @@ -179,7 +179,7 @@ void main() { test('Null image sizing', () { RenderImage image; - image = new RenderImage(); + image = RenderImage(); layout(image, constraints: const BoxConstraints( minWidth: 25.0, @@ -189,7 +189,7 @@ void main() { expect(image.size.width, equals(25.0)); expect(image.size.height, equals(25.0)); - image = new RenderImage(width: 50.0); + image = RenderImage(width: 50.0); layout(image, constraints: const BoxConstraints( minWidth: 25.0, @@ -199,7 +199,7 @@ void main() { expect(image.size.width, equals(50.0)); expect(image.size.height, equals(25.0)); - image = new RenderImage(height: 50.0); + image = RenderImage(height: 50.0); layout(image, constraints: const BoxConstraints( minWidth: 25.0, @@ -209,7 +209,7 @@ void main() { expect(image.size.width, equals(25.0)); expect(image.size.height, equals(50.0)); - image = new RenderImage(width: 100.0, height: 100.0); + image = RenderImage(width: 100.0, height: 100.0); layout(image, constraints: const BoxConstraints( minWidth: 25.0, @@ -221,7 +221,7 @@ void main() { }); test('update image colorBlendMode', () { - final RenderImage image = new RenderImage(); + final RenderImage image = RenderImage(); expect(image.colorBlendMode, isNull); image.colorBlendMode = BlendMode.color; expect(image.colorBlendMode, BlendMode.color); diff --git a/packages/flutter/test/rendering/independent_layout_test.dart b/packages/flutter/test/rendering/independent_layout_test.dart index 72fce9141a..dfd22e3a2e 100644 --- a/packages/flutter/test/rendering/independent_layout_test.dart +++ b/packages/flutter/test/rendering/independent_layout_test.dart @@ -11,14 +11,14 @@ import 'rendering_tester.dart'; class TestLayout { TestLayout() { // incoming constraints are tight 800x600 - root = new RenderPositionedBox( - child: new RenderConstrainedBox( + root = RenderPositionedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 800.0), - child: new RenderCustomPaint( - painter: new TestCallbackPainter( + child: RenderCustomPaint( + painter: TestCallbackPainter( onPaint: () { painted = true; } ), - child: child = new RenderConstrainedBox( + child: child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 10.0, width: 10.0), ), ), @@ -37,15 +37,15 @@ void main() { ); test('onscreen layout does not affect offscreen', () { - final TestLayout onscreen = new TestLayout(); - final TestLayout offscreen = new TestLayout(); + final TestLayout onscreen = TestLayout(); + final TestLayout offscreen = TestLayout(); expect(onscreen.child.hasSize, isFalse); expect(onscreen.painted, isFalse); expect(offscreen.child.hasSize, isFalse); expect(offscreen.painted, isFalse); // Attach the offscreen to a custom render view and owner - final RenderView renderView = new RenderView(configuration: testConfiguration); - final PipelineOwner pipelineOwner = new PipelineOwner(); + final RenderView renderView = RenderView(configuration: testConfiguration); + final PipelineOwner pipelineOwner = PipelineOwner(); renderView.attach(pipelineOwner); renderView.child = offscreen.root; renderView.scheduleInitialFrame(); @@ -66,15 +66,15 @@ void main() { expect(offscreen.painted, isTrue); }); test('offscreen layout does not affect onscreen', () { - final TestLayout onscreen = new TestLayout(); - final TestLayout offscreen = new TestLayout(); + final TestLayout onscreen = TestLayout(); + final TestLayout offscreen = TestLayout(); expect(onscreen.child.hasSize, isFalse); expect(onscreen.painted, isFalse); expect(offscreen.child.hasSize, isFalse); expect(offscreen.painted, isFalse); // Attach the offscreen to a custom render view and owner - final RenderView renderView = new RenderView(configuration: testConfiguration); - final PipelineOwner pipelineOwner = new PipelineOwner(); + final RenderView renderView = RenderView(configuration: testConfiguration); + final PipelineOwner pipelineOwner = PipelineOwner(); renderView.attach(pipelineOwner); renderView.child = offscreen.root; renderView.scheduleInitialFrame(); diff --git a/packages/flutter/test/rendering/intrinsic_width_test.dart b/packages/flutter/test/rendering/intrinsic_width_test.dart index abe4cfd66f..bb75387722 100644 --- a/packages/flutter/test/rendering/intrinsic_width_test.dart +++ b/packages/flutter/test/rendering/intrinsic_width_test.dart @@ -38,15 +38,15 @@ class RenderTestBox extends RenderBox { @override void performResize() { - size = constraints.constrain(new Size(_intrinsicDimensions.minWidth + (_intrinsicDimensions.maxWidth-_intrinsicDimensions.minWidth) / 2.0, + size = constraints.constrain(Size(_intrinsicDimensions.minWidth + (_intrinsicDimensions.maxWidth-_intrinsicDimensions.minWidth) / 2.0, _intrinsicDimensions.minHeight + (_intrinsicDimensions.maxHeight-_intrinsicDimensions.minHeight) / 2.0)); } } void main() { test('Shrink-wrapping width', () { - final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); - final RenderBox parent = new RenderIntrinsicWidth(child: child); + final RenderBox child = RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); + final RenderBox parent = RenderIntrinsicWidth(child: child); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -80,7 +80,7 @@ void main() { }); test('IntrinsicWidth without a child', () { - final RenderBox parent = new RenderIntrinsicWidth(); + final RenderBox parent = RenderIntrinsicWidth(); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -114,8 +114,8 @@ void main() { }); test('Shrink-wrapping width (stepped width)', () { - final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); - final RenderBox parent = new RenderIntrinsicWidth(child: child, stepWidth: 47.0); + final RenderBox child = RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); + final RenderBox parent = RenderIntrinsicWidth(child: child, stepWidth: 47.0); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -149,8 +149,8 @@ void main() { }); test('Shrink-wrapping width (stepped height)', () { - final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); - final RenderBox parent = new RenderIntrinsicWidth(child: child, stepHeight: 47.0); + final RenderBox child = RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); + final RenderBox parent = RenderIntrinsicWidth(child: child, stepHeight: 47.0); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -184,8 +184,8 @@ void main() { }); test('Shrink-wrapping width (stepped everything)', () { - final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); - final RenderBox parent = new RenderIntrinsicWidth(child: child, stepHeight: 47.0, stepWidth: 37.0); + final RenderBox child = RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); + final RenderBox parent = RenderIntrinsicWidth(child: child, stepHeight: 47.0, stepWidth: 37.0); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -219,8 +219,8 @@ void main() { }); test('Shrink-wrapping height', () { - final RenderBox child = new RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); - final RenderBox parent = new RenderIntrinsicHeight(child: child); + final RenderBox child = RenderTestBox(const BoxConstraints(minWidth: 10.0, maxWidth: 100.0, minHeight: 20.0, maxHeight: 200.0)); + final RenderBox parent = RenderIntrinsicHeight(child: child); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -254,7 +254,7 @@ void main() { }); test('IntrinsicHeight without a child', () { - final RenderBox parent = new RenderIntrinsicHeight(); + final RenderBox parent = RenderIntrinsicHeight(); layout(parent, constraints: const BoxConstraints( minWidth: 5.0, @@ -288,9 +288,9 @@ void main() { }); test('Padding and boring intrinsics', () { - final RenderBox box = new RenderPadding( + final RenderBox box = RenderPadding( padding: const EdgeInsets.all(15.0), - child: new RenderSizedBox(const Size(20.0, 20.0)) + child: RenderSizedBox(const Size(20.0, 20.0)) ); expect(box.getMinIntrinsicWidth(0.0), 50.0); @@ -326,9 +326,9 @@ void main() { }); test('Padding and interesting intrinsics', () { - final RenderBox box = new RenderPadding( + final RenderBox box = RenderPadding( padding: const EdgeInsets.all(15.0), - child: new RenderAspectRatio(aspectRatio: 1.0) + child: RenderAspectRatio(aspectRatio: 1.0) ); expect(box.getMinIntrinsicWidth(0.0), 30.0); @@ -364,9 +364,9 @@ void main() { }); test('Padding and boring intrinsics', () { - final RenderBox box = new RenderPadding( + final RenderBox box = RenderPadding( padding: const EdgeInsets.all(15.0), - child: new RenderSizedBox(const Size(20.0, 20.0)) + child: RenderSizedBox(const Size(20.0, 20.0)) ); expect(box.getMinIntrinsicWidth(0.0), 50.0); @@ -402,9 +402,9 @@ void main() { }); test('Padding and interesting intrinsics', () { - final RenderBox box = new RenderPadding( + final RenderBox box = RenderPadding( padding: const EdgeInsets.all(15.0), - child: new RenderAspectRatio(aspectRatio: 1.0) + child: RenderAspectRatio(aspectRatio: 1.0) ); expect(box.getMinIntrinsicWidth(0.0), 30.0); diff --git a/packages/flutter/test/rendering/layers_test.dart b/packages/flutter/test/rendering/layers_test.dart index c2dbc27781..727c655e3b 100644 --- a/packages/flutter/test/rendering/layers_test.dart +++ b/packages/flutter/test/rendering/layers_test.dart @@ -10,9 +10,9 @@ import 'rendering_tester.dart'; void main() { test('non-painted layers are detached', () { RenderObject boundary, inner; - final RenderOpacity root = new RenderOpacity( - child: boundary = new RenderRepaintBoundary( - child: inner = new RenderDecoratedBox( + final RenderOpacity root = RenderOpacity( + child: boundary = RenderRepaintBoundary( + child: inner = RenderDecoratedBox( decoration: const BoxDecoration(), ), ), diff --git a/packages/flutter/test/rendering/limited_box_test.dart b/packages/flutter/test/rendering/limited_box_test.dart index 7cfd4608ed..bcd4012c93 100644 --- a/packages/flutter/test/rendering/limited_box_test.dart +++ b/packages/flutter/test/rendering/limited_box_test.dart @@ -10,15 +10,15 @@ import 'rendering_tester.dart'; void main() { test('LimitedBox: parent max size is unconstrained', () { - final RenderBox child = new RenderConstrainedBox( + final RenderBox child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 300.0, height: 400.0) ); - final RenderBox parent = new RenderConstrainedOverflowBox( + final RenderBox parent = RenderConstrainedOverflowBox( minWidth: 0.0, maxWidth: double.infinity, minHeight: 0.0, maxHeight: double.infinity, - child: new RenderLimitedBox( + child: RenderLimitedBox( maxWidth: 100.0, maxHeight: 200.0, child: child @@ -59,15 +59,15 @@ void main() { }); test('LimitedBox: parent maxWidth is unconstrained', () { - final RenderBox child = new RenderConstrainedBox( + final RenderBox child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 300.0, height: 400.0) ); - final RenderBox parent = new RenderConstrainedOverflowBox( + final RenderBox parent = RenderConstrainedOverflowBox( minWidth: 0.0, maxWidth: double.infinity, minHeight: 500.0, maxHeight: 500.0, - child: new RenderLimitedBox( + child: RenderLimitedBox( maxWidth: 100.0, maxHeight: 200.0, child: child @@ -79,15 +79,15 @@ void main() { }); test('LimitedBox: parent maxHeight is unconstrained', () { - final RenderBox child = new RenderConstrainedBox( + final RenderBox child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 300.0, height: 400.0) ); - final RenderBox parent = new RenderConstrainedOverflowBox( + final RenderBox parent = RenderConstrainedOverflowBox( minWidth: 500.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: double.infinity, - child: new RenderLimitedBox( + child: RenderLimitedBox( maxWidth: 100.0, maxHeight: 200.0, child: child @@ -101,12 +101,12 @@ void main() { test('LimitedBox: no child', () { RenderBox box; - final RenderBox parent = new RenderConstrainedOverflowBox( + final RenderBox parent = RenderConstrainedOverflowBox( minWidth: 10.0, maxWidth: 500.0, minHeight: 0.0, maxHeight: double.infinity, - child: box = new RenderLimitedBox( + child: box = RenderLimitedBox( maxWidth: 100.0, maxHeight: 200.0, ) @@ -140,9 +140,9 @@ void main() { test('LimitedBox: no child use parent', () { RenderBox box; - final RenderBox parent = new RenderConstrainedOverflowBox( + final RenderBox parent = RenderConstrainedOverflowBox( minWidth: 10.0, - child: box = new RenderLimitedBox( + child: box = RenderLimitedBox( maxWidth: 100.0, maxHeight: 200.0, ) diff --git a/packages/flutter/test/rendering/localized_fonts_test.dart b/packages/flutter/test/rendering/localized_fonts_test.dart index c76c5b36e5..7ce046c1bc 100644 --- a/packages/flutter/test/rendering/localized_fonts_test.dart +++ b/packages/flutter/test/rendering/localized_fonts_test.dart @@ -16,28 +16,28 @@ void main() { (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( supportedLocales: const [ Locale('en', 'US'), Locale('ja'), Locale('zh'), ], - home: new Builder( + home: Builder( builder: (BuildContext context) { const String character = '骨'; final TextStyle style = Theme.of(context).textTheme.display3; - return new Scaffold( - body: new Container( + return Scaffold( + body: Container( padding: const EdgeInsets.all(48.0), alignment: Alignment.center, - child: new RepaintBoundary( + child: RepaintBoundary( // Expected result can be seen here: // https://user-images.githubusercontent.com/1377460/40503473-faad6f34-5f42-11e8-972b-d83b727c9d0e.png - child: new RichText( - text: new TextSpan( + child: RichText( + text: TextSpan( children: [ - new TextSpan(text: character, style: style.copyWith(locale: const Locale('ja'))), - new TextSpan(text: character, style: style.copyWith(locale: const Locale('zh'))), + TextSpan(text: character, style: style.copyWith(locale: const Locale('ja'))), + TextSpan(text: character, style: style.copyWith(locale: const Locale('zh'))), ], ), ), @@ -61,35 +61,35 @@ void main() { 'Text with locale-specific glyphs, ambient locale', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( supportedLocales: const [ Locale('en', 'US'), Locale('ja'), Locale('zh'), ], - home: new Builder( + home: Builder( builder: (BuildContext context) { const String character = '骨'; final TextStyle style = Theme.of(context).textTheme.display3; - return new Scaffold( - body: new Container( + return Scaffold( + body: Container( padding: const EdgeInsets.all(48.0), alignment: Alignment.center, - child: new RepaintBoundary( + child: RepaintBoundary( // Expected result can be seen here: // https://user-images.githubusercontent.com/1377460/40503473-faad6f34-5f42-11e8-972b-d83b727c9d0e.png - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new Localizations.override( + Localizations.override( context: context, locale: const Locale('ja'), - child: new Text(character, style: style), + child: Text(character, style: style), ), - new Localizations.override( + Localizations.override( context: context, locale: const Locale('zh'), - child: new Text(character, style: style), + child: Text(character, style: style), ), ], ), @@ -113,28 +113,28 @@ void main() { 'Text with locale-specific glyphs, explicit locale', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( supportedLocales: const [ Locale('en', 'US'), Locale('ja'), Locale('zh'), ], - home: new Builder( + home: Builder( builder: (BuildContext context) { const String character = '骨'; final TextStyle style = Theme.of(context).textTheme.display3; - return new Scaffold( - body: new Container( + return Scaffold( + body: Container( padding: const EdgeInsets.all(48.0), alignment: Alignment.center, - child: new RepaintBoundary( + child: RepaintBoundary( // Expected result can be seen here: // https://user-images.githubusercontent.com/1377460/40503473-faad6f34-5f42-11e8-972b-d83b727c9d0e.png - child: new Row( + child: Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new Text(character, style: style, locale: const Locale('ja')), - new Text(character, style: style, locale: const Locale('zh')), + Text(character, style: style, locale: const Locale('ja')), + Text(character, style: style, locale: const Locale('zh')), ], ), ), diff --git a/packages/flutter/test/rendering/mock_canvas.dart b/packages/flutter/test/rendering/mock_canvas.dart index 8cc5fbb146..de9410a96c 100644 --- a/packages/flutter/test/rendering/mock_canvas.dart +++ b/packages/flutter/test/rendering/mock_canvas.dart @@ -40,17 +40,17 @@ import 'recording_canvas.dart'; /// To match something which paints nothing, see [paintsNothing]. /// /// To match something which asserts instead of painting, see [paintsAssertion]. -PaintPattern get paints => new _TestRecordingCanvasPatternMatcher(); +PaintPattern get paints => _TestRecordingCanvasPatternMatcher(); /// Matches objects or functions that does not paint anything on the canvas. -Matcher get paintsNothing => new _TestRecordingCanvasPaintsNothingMatcher(); +Matcher get paintsNothing => _TestRecordingCanvasPaintsNothingMatcher(); /// Matches objects or functions that assert when they try to paint. -Matcher get paintsAssertion => new _TestRecordingCanvasPaintsAssertionMatcher(); +Matcher get paintsAssertion => _TestRecordingCanvasPaintsAssertionMatcher(); /// Matches objects or functions that draw `methodName` exactly `count` number of times Matcher paintsExactlyCountTimes(Symbol methodName, int count) { - return new _TestRecordingCanvasPaintsCountMatcher(methodName, count); + return _TestRecordingCanvasPaintsCountMatcher(methodName, count); } /// Signature for the [PaintPattern.something] and [PaintPattern.everything] @@ -428,7 +428,7 @@ Matcher isPathThat({ Iterable includes = const [], Iterable excludes = const [], }) { - return new _PathMatcher(includes.toList(), excludes.toList()); + return _PathMatcher(includes.toList(), excludes.toList()); } class _PathMatcher extends Matcher { @@ -514,9 +514,9 @@ bool _evaluatePainter(Object object, Canvas canvas, PaintingContext context) { abstract class _TestRecordingCanvasMatcher extends Matcher { @override bool matches(Object object, Map matchState) { - final TestRecordingCanvas canvas = new TestRecordingCanvas(); - final TestRecordingPaintingContext context = new TestRecordingPaintingContext(canvas); - final StringBuffer description = new StringBuffer(); + final TestRecordingCanvas canvas = TestRecordingCanvas(); + final TestRecordingPaintingContext context = TestRecordingPaintingContext(canvas); + final StringBuffer description = StringBuffer(); String prefixMessage = 'unexpectedly failed.'; bool result = false; try { @@ -619,9 +619,9 @@ class _TestRecordingCanvasPaintsNothingMatcher extends _TestRecordingCanvasMatch class _TestRecordingCanvasPaintsAssertionMatcher extends Matcher { @override bool matches(Object object, Map matchState) { - final TestRecordingCanvas canvas = new TestRecordingCanvas(); - final TestRecordingPaintingContext context = new TestRecordingPaintingContext(canvas); - final StringBuffer description = new StringBuffer(); + final TestRecordingCanvas canvas = TestRecordingCanvas(); + final TestRecordingPaintingContext context = TestRecordingPaintingContext(canvas); + final StringBuffer description = StringBuffer(); String prefixMessage = 'unexpectedly failed.'; bool result = false; try { @@ -670,117 +670,117 @@ class _TestRecordingCanvasPatternMatcher extends _TestRecordingCanvasMatcher imp @override void transform({ dynamic matrix4 }) { - _predicates.add(new _FunctionPaintPredicate(#transform, [matrix4])); + _predicates.add(_FunctionPaintPredicate(#transform, [matrix4])); } @override void translate({ double x, double y }) { - _predicates.add(new _FunctionPaintPredicate(#translate, [x, y])); + _predicates.add(_FunctionPaintPredicate(#translate, [x, y])); } @override void scale({ double x, double y }) { - _predicates.add(new _FunctionPaintPredicate(#scale, [x, y])); + _predicates.add(_FunctionPaintPredicate(#scale, [x, y])); } @override void rotate({ double angle }) { - _predicates.add(new _FunctionPaintPredicate(#rotate, [angle])); + _predicates.add(_FunctionPaintPredicate(#rotate, [angle])); } @override void save() { - _predicates.add(new _FunctionPaintPredicate(#save, [])); + _predicates.add(_FunctionPaintPredicate(#save, [])); } @override void restore() { - _predicates.add(new _FunctionPaintPredicate(#restore, [])); + _predicates.add(_FunctionPaintPredicate(#restore, [])); } @override void saveRestore() { - _predicates.add(new _SaveRestorePairPaintPredicate()); + _predicates.add(_SaveRestorePairPaintPredicate()); } @override void clipRect({ Rect rect }) { - _predicates.add(new _FunctionPaintPredicate(#clipRect, [rect])); + _predicates.add(_FunctionPaintPredicate(#clipRect, [rect])); } @override void clipPath({Matcher pathMatcher}) { - _predicates.add(new _FunctionPaintPredicate(#clipPath, [pathMatcher])); + _predicates.add(_FunctionPaintPredicate(#clipPath, [pathMatcher])); } @override void rect({ Rect rect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _RectPaintPredicate(rect: rect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_RectPaintPredicate(rect: rect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void clipRRect({ RRect rrect }) { - _predicates.add(new _FunctionPaintPredicate(#clipRRect, [rrect])); + _predicates.add(_FunctionPaintPredicate(#clipRRect, [rrect])); } @override void rrect({ RRect rrect, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _RRectPaintPredicate(rrect: rrect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_RRectPaintPredicate(rrect: rrect, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void drrect({ RRect outer, RRect inner, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _DRRectPaintPredicate(outer: outer, inner: inner, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_DRRectPaintPredicate(outer: outer, inner: inner, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void circle({ double x, double y, double radius, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _CirclePaintPredicate(x: x, y: y, radius: radius, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_CirclePaintPredicate(x: x, y: y, radius: radius, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void path({ Iterable includes, Iterable excludes, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _PathPaintPredicate(includes: includes, excludes: excludes, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_PathPaintPredicate(includes: includes, excludes: excludes, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void line({ Offset p1, Offset p2, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _LinePaintPredicate(p1: p1, p2: p2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_LinePaintPredicate(p1: p1, p2: p2, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void arc({ Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _ArcPaintPredicate(color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_ArcPaintPredicate(color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void paragraph({ ui.Paragraph paragraph, dynamic offset }) { - _predicates.add(new _FunctionPaintPredicate(#drawParagraph, [paragraph, offset])); + _predicates.add(_FunctionPaintPredicate(#drawParagraph, [paragraph, offset])); } @override void shadow({ Iterable includes, Iterable excludes, Color color, double elevation, bool transparentOccluder }) { - _predicates.add(new _ShadowPredicate(includes: includes, excludes: excludes, color: color, elevation: elevation, transparentOccluder: transparentOccluder)); + _predicates.add(_ShadowPredicate(includes: includes, excludes: excludes, color: color, elevation: elevation, transparentOccluder: transparentOccluder)); } @override void image({ ui.Image image, double x, double y, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _DrawImagePaintPredicate(image: image, x: x, y: y, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_DrawImagePaintPredicate(image: image, x: x, y: y, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void drawImageRect({ ui.Image image, Rect source, Rect destination, Color color, double strokeWidth, bool hasMaskFilter, PaintingStyle style }) { - _predicates.add(new _DrawImageRectPaintPredicate(image: image, source: source, destination: destination, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); + _predicates.add(_DrawImageRectPaintPredicate(image: image, source: source, destination: destination, color: color, strokeWidth: strokeWidth, hasMaskFilter: hasMaskFilter, style: style)); } @override void something(PaintPatternPredicate predicate) { - _predicates.add(new _SomethingPaintPredicate(predicate)); + _predicates.add(_SomethingPaintPredicate(predicate)); } @override void everything(PaintPatternPredicate predicate) { - _predicates.add(new _EverythingPaintPredicate(predicate)); + _predicates.add(_EverythingPaintPredicate(predicate)); } @override @@ -847,7 +847,7 @@ abstract class _PaintPredicate { while (!call.current.invocation.isMethod || call.current.invocation.memberName != symbol) { others += 1; if (!call.moveNext()) - throw new _MismatchedCall( + throw _MismatchedCall( 'It called $others other method${ others == 1 ? "" : "s" } on the canvas, ' 'the first of which was $firstCall, but did not ' 'call ${_symbolName(symbol)}() at the time where $this was expected.', @@ -860,7 +860,7 @@ abstract class _PaintPredicate { @override String toString() { - throw new FlutterError('$runtimeType does not implement toString.'); + throw FlutterError('$runtimeType does not implement toString.'); } } @@ -1063,7 +1063,7 @@ class _CirclePaintPredicate extends _DrawCommandPaintPredicate { super.verifyArguments(arguments); final Offset pointArgument = arguments[0]; if (x != null && y != null) { - final Offset point = new Offset(x, y); + final Offset point = Offset(x, y); if (point != pointArgument) throw 'It called $methodName with a center coordinate, $pointArgument, which was not exactly the expected coordinate ($point).'; } else { @@ -1081,7 +1081,7 @@ class _CirclePaintPredicate extends _DrawCommandPaintPredicate { void debugFillDescription(List description) { super.debugFillDescription(description); if (x != null && y != null) { - description.add('point ${new Offset(x, y)}'); + description.add('point ${Offset(x, y)}'); } else { if (x != null) description.add('x-coordinate ${x.toStringAsFixed(1)}'); @@ -1264,7 +1264,7 @@ class _DrawImagePaintPredicate extends _DrawCommandPaintPredicate { throw 'It called $methodName with an image, $imageArgument, which was not exactly the expected image ($image).'; final Offset pointArgument = arguments[0]; if (x != null && y != null) { - final Offset point = new Offset(x, y); + final Offset point = Offset(x, y); if (point != pointArgument) throw 'It called $methodName with an offset coordinate, $pointArgument, which was not exactly the expected coordinate ($point).'; } else { @@ -1281,7 +1281,7 @@ class _DrawImagePaintPredicate extends _DrawCommandPaintPredicate { if (image != null) description.add('image $image'); if (x != null && y != null) { - description.add('point ${new Offset(x, y)}'); + description.add('point ${Offset(x, y)}'); } else { if (x != null) description.add('x-coordinate ${x.toStringAsFixed(1)}'); diff --git a/packages/flutter/test/rendering/mutations_test.dart b/packages/flutter/test/rendering/mutations_test.dart index a554a29794..473a1fa02b 100644 --- a/packages/flutter/test/rendering/mutations_test.dart +++ b/packages/flutter/test/rendering/mutations_test.dart @@ -36,9 +36,9 @@ void main() { RenderBox child1, child2; bool movedChild1 = false; bool movedChild2 = false; - final RenderFlex block = new RenderFlex(textDirection: TextDirection.ltr); - block.add(child1 = new RenderLayoutTestBox(() { movedChild1 = true; })); - block.add(child2 = new RenderLayoutTestBox(() { movedChild2 = true; })); + final RenderFlex block = RenderFlex(textDirection: TextDirection.ltr); + block.add(child1 = RenderLayoutTestBox(() { movedChild1 = true; })); + block.add(child2 = RenderLayoutTestBox(() { movedChild2 = true; })); expect(movedChild1, isFalse); expect(movedChild2, isFalse); diff --git a/packages/flutter/test/rendering/non_render_object_root_test.dart b/packages/flutter/test/rendering/non_render_object_root_test.dart index 0ec6a3cd7d..d2e587ff00 100644 --- a/packages/flutter/test/rendering/non_render_object_root_test.dart +++ b/packages/flutter/test/rendering/non_render_object_root_test.dart @@ -39,20 +39,20 @@ class RealRoot extends AbstractNode { PipelineOwner get owner => super.owner; void layout() { - child?.layout(new BoxConstraints.tight(const Size(500.0, 500.0))); + child?.layout(BoxConstraints.tight(const Size(500.0, 500.0))); } } void main() { test('non-RenderObject roots', () { RenderPositionedBox child; - final RealRoot root = new RealRoot( - child = new RenderPositionedBox( + final RealRoot root = RealRoot( + child = RenderPositionedBox( alignment: Alignment.center, - child: new RenderSizedBox(const Size(100.0, 100.0)) + child: RenderSizedBox(const Size(100.0, 100.0)) ) ); - root.attach(new PipelineOwner()); + root.attach(PipelineOwner()); child.scheduleInitialLayout(); root.layout(); diff --git a/packages/flutter/test/rendering/object_test.dart b/packages/flutter/test/rendering/object_test.dart index afd2a3098f..209ce4953c 100644 --- a/packages/flutter/test/rendering/object_test.dart +++ b/packages/flutter/test/rendering/object_test.dart @@ -8,9 +8,9 @@ import '../flutter_test_alternative.dart'; void main() { test('ensure frame is scheduled for markNeedsSemanticsUpdate', () { - final TestRenderObject renderObject = new TestRenderObject(); + final TestRenderObject renderObject = TestRenderObject(); int onNeedVisualUpdateCallCount = 0; - final PipelineOwner owner = new PipelineOwner(onNeedVisualUpdate: () { + final PipelineOwner owner = PipelineOwner(onNeedVisualUpdate: () { onNeedVisualUpdateCallCount +=1; }); owner.ensureSemantics(); @@ -23,7 +23,7 @@ void main() { }); test('detached RenderObject does not do semantics', () { - final TestRenderObject renderObject = new TestRenderObject(); + final TestRenderObject renderObject = TestRenderObject(); expect(renderObject.attached, isFalse); expect(renderObject.describeSemanticsConfigurationCallCount, 0); @@ -46,7 +46,7 @@ class TestRenderObject extends RenderObject { void performResize() {} @override - Rect get semanticBounds => new Rect.fromLTWH(0.0, 0.0, 10.0, 20.0); + Rect get semanticBounds => Rect.fromLTWH(0.0, 0.0, 10.0, 20.0); int describeSemanticsConfigurationCallCount = 0; diff --git a/packages/flutter/test/rendering/offstage_test.dart b/packages/flutter/test/rendering/offstage_test.dart index a4a9f70dd1..2cb1a6da5c 100644 --- a/packages/flutter/test/rendering/offstage_test.dart +++ b/packages/flutter/test/rendering/offstage_test.dart @@ -13,15 +13,15 @@ void main() { RenderBox child; bool painted = false; // incoming constraints are tight 800x600 - final RenderBox root = new RenderPositionedBox( - child: new RenderConstrainedBox( + final RenderBox root = RenderPositionedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 800.0), - child: new RenderOffstage( - child: new RenderCustomPaint( - painter: new TestCallbackPainter( + child: RenderOffstage( + child: RenderCustomPaint( + painter: TestCallbackPainter( onPaint: () { painted = true; }, ), - child: child = new RenderConstrainedBox( + child: child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 10.0, width: 10.0), ), ), diff --git a/packages/flutter/test/rendering/overflow_test.dart b/packages/flutter/test/rendering/overflow_test.dart index 7303a36254..bec6d12be4 100644 --- a/packages/flutter/test/rendering/overflow_test.dart +++ b/packages/flutter/test/rendering/overflow_test.dart @@ -13,13 +13,13 @@ void main() { RenderBox root, child, text; double baseline1, baseline2, height1, height2; - root = new RenderPositionedBox( - child: new RenderCustomPaint( - child: child = text = new RenderParagraph( + root = RenderPositionedBox( + child: RenderCustomPaint( + child: child = text = RenderParagraph( const TextSpan(text: 'Hello World'), textDirection: TextDirection.ltr, ), - painter: new TestCallbackPainter( + painter: TestCallbackPainter( onPaint: () { baseline1 = child.getDistanceToBaseline(TextBaseline.alphabetic); height1 = text.size.height; @@ -29,17 +29,17 @@ void main() { ); layout(root, phase: EnginePhase.paint); - root = new RenderPositionedBox( - child: new RenderCustomPaint( - child: child = new RenderConstrainedOverflowBox( - child: text = new RenderParagraph( + root = RenderPositionedBox( + child: RenderCustomPaint( + child: child = RenderConstrainedOverflowBox( + child: text = RenderParagraph( const TextSpan(text: 'Hello World'), textDirection: TextDirection.ltr, ), maxHeight: height1 / 2.0, alignment: Alignment.topLeft, ), - painter: new TestCallbackPainter( + painter: TestCallbackPainter( onPaint: () { baseline2 = child.getDistanceToBaseline(TextBaseline.alphabetic); height2 = text.size.height; diff --git a/packages/flutter/test/rendering/paragraph_intrinsics_test.dart b/packages/flutter/test/rendering/paragraph_intrinsics_test.dart index d8f76bba56..091e342ca0 100644 --- a/packages/flutter/test/rendering/paragraph_intrinsics_test.dart +++ b/packages/flutter/test/rendering/paragraph_intrinsics_test.dart @@ -7,14 +7,14 @@ import '../flutter_test_alternative.dart'; void main() { test('list body and paragraph intrinsics', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan( style: TextStyle(height: 1.0), text: 'Hello World', ), textDirection: TextDirection.ltr, ); - final RenderListBody testBlock = new RenderListBody( + final RenderListBody testBlock = RenderListBody( children: [ paragraph, ], diff --git a/packages/flutter/test/rendering/paragraph_test.dart b/packages/flutter/test/rendering/paragraph_test.dart index e67419c5ed..da3bf087a7 100644 --- a/packages/flutter/test/rendering/paragraph_test.dart +++ b/packages/flutter/test/rendering/paragraph_test.dart @@ -15,13 +15,13 @@ const String _kText = 'I polished up that handle so carefullee\nThat now I am th void main() { test('getOffsetForCaret control test', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan(text: _kText), textDirection: TextDirection.ltr, ); layout(paragraph); - final Rect caret = new Rect.fromLTWH(0.0, 0.0, 2.0, 20.0); + final Rect caret = Rect.fromLTWH(0.0, 0.0, 2.0, 20.0); final Offset offset5 = paragraph.getOffsetForCaret(const TextPosition(offset: 5), caret); expect(offset5.dx, greaterThan(0.0)); @@ -34,7 +34,7 @@ void main() { }); test('getPositionForOffset control test', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan(text: _kText), textDirection: TextDirection.ltr, ); @@ -51,7 +51,7 @@ void main() { }); test('getBoxesForSelection control test', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan(text: _kText, style: TextStyle(fontSize: 10.0)), textDirection: TextDirection.ltr, ); @@ -74,7 +74,7 @@ void main() { skip: Platform.isWindows || Platform.isMacOS); test('getWordBoundary control test', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan(text: _kText), textDirection: TextDirection.ltr, ); @@ -91,7 +91,7 @@ void main() { }); test('overflow test', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan( text: 'This\n' // 4 characters * 10px font size = 40px width on the first line 'is a wrapping test. It should wrap at manual newlines, and if softWrap is true, also at spaces.', @@ -167,7 +167,7 @@ void main() { }); test('maxLines', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan( text: 'How do you write like you\'re running out of time? Write day and night like you\'re running out of time?', // 0123456789 0123456789 012 345 0123456 012345 01234 012345678 012345678 0123 012 345 0123456 012345 01234 @@ -196,7 +196,7 @@ void main() { }, skip: Platform.isWindows); // Ahem-based tests don't yet quite work on Windows test('changing color does not do layout', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan( text: 'Hello', style: TextStyle(color: Color(0xFF000000)), @@ -247,7 +247,7 @@ void main() { ), ], ); - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( testSpan, textDirection: TextDirection.ltr, textScaleFactor: 1.3 @@ -264,7 +264,7 @@ void main() { final String text = testSpan.toStringDeep(); for (int i = 0; i < text.length; ++i) { boxes.addAll(paragraph.getBoxesForSelection( - new TextSelection(baseOffset: i, extentOffset: i + 1) + TextSelection(baseOffset: i, extentOffset: i + 1) )); } expect(boxes.length, equals(4)); @@ -283,7 +283,7 @@ void main() { }); test('toStringDeep', () { - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan(text: _kText), textDirection: TextDirection.ltr, locale: const Locale('ja', 'JP'), @@ -314,7 +314,7 @@ void main() { test('locale setter', () { // Regression test for https://github.com/flutter/flutter/issues/18175 - final RenderParagraph paragraph = new RenderParagraph( + final RenderParagraph paragraph = RenderParagraph( const TextSpan(text: _kText), locale: const Locale('zh', 'HK'), textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/rendering/positioned_box_test.dart b/packages/flutter/test/rendering/positioned_box_test.dart index bb10b42f3a..9e102351cc 100644 --- a/packages/flutter/test/rendering/positioned_box_test.dart +++ b/packages/flutter/test/rendering/positioned_box_test.dart @@ -9,24 +9,24 @@ import 'rendering_tester.dart'; void main() { test('RenderPositionedBox expands', () { - final RenderConstrainedBox sizer = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)), - child: new RenderDecoratedBox(decoration: const BoxDecoration()) + final RenderConstrainedBox sizer = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)), + child: RenderDecoratedBox(decoration: const BoxDecoration()) ); - final RenderPositionedBox positioner = new RenderPositionedBox(child: sizer); - layout(positioner, constraints: new BoxConstraints.loose(const Size(200.0, 200.0))); + final RenderPositionedBox positioner = RenderPositionedBox(child: sizer); + layout(positioner, constraints: BoxConstraints.loose(const Size(200.0, 200.0))); expect(positioner.size.width, equals(200.0), reason: 'positioner width'); expect(positioner.size.height, equals(200.0), reason: 'positioner height'); }); test('RenderPositionedBox shrink wraps', () { - final RenderConstrainedBox sizer = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)), - child: new RenderDecoratedBox(decoration: const BoxDecoration()) + final RenderConstrainedBox sizer = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)), + child: RenderDecoratedBox(decoration: const BoxDecoration()) ); - final RenderPositionedBox positioner = new RenderPositionedBox(child: sizer, widthFactor: 1.0); - layout(positioner, constraints: new BoxConstraints.loose(const Size(200.0, 200.0))); + final RenderPositionedBox positioner = RenderPositionedBox(child: sizer, widthFactor: 1.0); + layout(positioner, constraints: BoxConstraints.loose(const Size(200.0, 200.0))); expect(positioner.size.width, equals(100.0), reason: 'positioner width'); expect(positioner.size.height, equals(200.0), reason: 'positioner height'); @@ -46,12 +46,12 @@ void main() { }); test('RenderPositionedBox width and height factors', () { - final RenderConstrainedBox sizer = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)), - child: new RenderDecoratedBox(decoration: const BoxDecoration()) + final RenderConstrainedBox sizer = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)), + child: RenderDecoratedBox(decoration: const BoxDecoration()) ); - final RenderPositionedBox positioner = new RenderPositionedBox(child: sizer, widthFactor: 1.0, heightFactor: 0.0); - layout(positioner, constraints: new BoxConstraints.loose(const Size(200.0, 200.0))); + final RenderPositionedBox positioner = RenderPositionedBox(child: sizer, widthFactor: 1.0, heightFactor: 0.0); + layout(positioner, constraints: BoxConstraints.loose(const Size(200.0, 200.0))); expect(positioner.size.width, equals(100.0)); expect(positioner.size.height, equals(0.0)); diff --git a/packages/flutter/test/rendering/proxy_box_test.dart b/packages/flutter/test/rendering/proxy_box_test.dart index 29389fd55c..8e62c45afd 100644 --- a/packages/flutter/test/rendering/proxy_box_test.dart +++ b/packages/flutter/test/rendering/proxy_box_test.dart @@ -18,9 +18,9 @@ void main() { test('RenderFittedBox paint', () { bool painted; RenderFittedBox makeFittedBox() { - return new RenderFittedBox( - child: new RenderCustomPaint( - painter: new TestCallbackPainter(onPaint: () { + return RenderFittedBox( + child: RenderCustomPaint( + painter: TestCallbackPainter(onPaint: () { painted = true; }), ), @@ -33,14 +33,14 @@ void main() { // The RenderFittedBox should not paint if it is empty. painted = false; - layout(makeFittedBox(), constraints: new BoxConstraints.tight(Size.zero), phase: EnginePhase.paint); + layout(makeFittedBox(), constraints: BoxConstraints.tight(Size.zero), phase: EnginePhase.paint); expect(painted, equals(false)); }); test('RenderPhysicalModel compositing on Fuchsia', () { debugDefaultTargetPlatformOverride = TargetPlatform.fuchsia; - final RenderPhysicalModel root = new RenderPhysicalModel(color: const Color(0xffff00ff)); + final RenderPhysicalModel root = RenderPhysicalModel(color: const Color(0xffff00ff)); layout(root, phase: EnginePhase.composite); expect(root.needsCompositing, isFalse); @@ -60,7 +60,7 @@ void main() { test('RenderPhysicalModel compositing on non-Fuchsia', () { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final RenderPhysicalModel root = new RenderPhysicalModel(color: const Color(0xffff00ff)); + final RenderPhysicalModel root = RenderPhysicalModel(color: const Color(0xffff00ff)); layout(root, phase: EnginePhase.composite); expect(root.needsCompositing, isFalse); @@ -77,18 +77,18 @@ void main() { }); test('RenderSemanticsGestureHandler adds/removes correct semantic actions', () { - final RenderSemanticsGestureHandler renderObj = new RenderSemanticsGestureHandler( + final RenderSemanticsGestureHandler renderObj = RenderSemanticsGestureHandler( onTap: () {}, onHorizontalDragUpdate: (DragUpdateDetails details) {}, ); - SemanticsConfiguration config = new SemanticsConfiguration(); + SemanticsConfiguration config = SemanticsConfiguration(); renderObj.describeSemanticsConfiguration(config); expect(config.getActionHandler(SemanticsAction.tap), isNotNull); expect(config.getActionHandler(SemanticsAction.scrollLeft), isNotNull); expect(config.getActionHandler(SemanticsAction.scrollRight), isNotNull); - config = new SemanticsConfiguration(); + config = SemanticsConfiguration(); renderObj.validActions = [SemanticsAction.tap, SemanticsAction.scrollLeft].toSet(); renderObj.describeSemanticsConfiguration(config); @@ -103,7 +103,7 @@ void main() { }); test('shape change triggers repaint', () { - final RenderPhysicalShape root = new RenderPhysicalShape( + final RenderPhysicalShape root = RenderPhysicalShape( color: const Color(0xffff00ff), clipper: const ShapeBorderClipper(shape: CircleBorder()), ); @@ -120,7 +120,7 @@ void main() { }); test('compositing on non-Fuchsia', () { - final RenderPhysicalShape root = new RenderPhysicalShape( + final RenderPhysicalShape root = RenderPhysicalShape( color: const Color(0xffff00ff), clipper: const ShapeBorderClipper(shape: CircleBorder()), ); @@ -141,38 +141,38 @@ void main() { }); test('RenderRepaintBoundary can capture images of itself', () async { - RenderRepaintBoundary boundary = new RenderRepaintBoundary(); - layout(boundary, constraints: new BoxConstraints.tight(const Size(100.0, 200.0))); + RenderRepaintBoundary boundary = RenderRepaintBoundary(); + layout(boundary, constraints: BoxConstraints.tight(const Size(100.0, 200.0))); pumpFrame(phase: EnginePhase.composite); ui.Image image = await boundary.toImage(); expect(image.width, equals(100)); expect(image.height, equals(200)); // Now with pixel ratio set to something other than 1.0. - boundary = new RenderRepaintBoundary(); - layout(boundary, constraints: new BoxConstraints.tight(const Size(100.0, 200.0))); + boundary = RenderRepaintBoundary(); + layout(boundary, constraints: BoxConstraints.tight(const Size(100.0, 200.0))); pumpFrame(phase: EnginePhase.composite); image = await boundary.toImage(pixelRatio: 2.0); expect(image.width, equals(200)); expect(image.height, equals(400)); // Try building one with two child layers and make sure it renders them both. - boundary = new RenderRepaintBoundary(); - final RenderStack stack = new RenderStack()..alignment = Alignment.topLeft; - final RenderDecoratedBox blackBox = new RenderDecoratedBox( + boundary = RenderRepaintBoundary(); + final RenderStack stack = RenderStack()..alignment = Alignment.topLeft; + final RenderDecoratedBox blackBox = RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0xff000000)), - child: new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size.square(20.0)), + child: RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size.square(20.0)), )); - stack.add(new RenderOpacity() + stack.add(RenderOpacity() ..opacity = 0.5 ..child = blackBox); - final RenderDecoratedBox whiteBox = new RenderDecoratedBox( + final RenderDecoratedBox whiteBox = RenderDecoratedBox( decoration: const BoxDecoration(color: Color(0xffffffff)), - child: new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size.square(10.0)), + child: RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size.square(10.0)), )); - final RenderPositionedBox positioned = new RenderPositionedBox( + final RenderPositionedBox positioned = RenderPositionedBox( widthFactor: 2.0, heightFactor: 2.0, alignment: Alignment.topRight, @@ -180,7 +180,7 @@ void main() { ); stack.add(positioned); boundary.child = stack; - layout(boundary, constraints: new BoxConstraints.tight(const Size(20.0, 20.0))); + layout(boundary, constraints: BoxConstraints.tight(const Size(20.0, 20.0))); pumpFrame(phase: EnginePhase.composite); image = await boundary.toImage(); expect(image.width, equals(20)); @@ -225,9 +225,9 @@ void main() { }); test('RenderOpacity does not composite if it is transparent', () { - final RenderOpacity renderOpacity = new RenderOpacity( + final RenderOpacity renderOpacity = RenderOpacity( opacity: 0.0, - child: new RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter + child: RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter ); layout(renderOpacity, phase: EnginePhase.composite); @@ -235,9 +235,9 @@ void main() { }); test('RenderOpacity does not composite if it is opaque', () { - final RenderOpacity renderOpacity = new RenderOpacity( + final RenderOpacity renderOpacity = RenderOpacity( opacity: 1.0, - child: new RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter + child: RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter ); layout(renderOpacity, phase: EnginePhase.composite); @@ -245,14 +245,14 @@ void main() { }); test('RenderAnimatedOpacity does not composite if it is transparent', () async { - final Animation opacityAnimation = new AnimationController( - vsync: new _FakeTickerProvider(), + final Animation opacityAnimation = AnimationController( + vsync: _FakeTickerProvider(), )..value = 0.0; - final RenderAnimatedOpacity renderAnimatedOpacity = new RenderAnimatedOpacity( + final RenderAnimatedOpacity renderAnimatedOpacity = RenderAnimatedOpacity( alwaysIncludeSemantics: false, opacity: opacityAnimation, - child: new RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter + child: RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter ); layout(renderAnimatedOpacity, phase: EnginePhase.composite); @@ -260,14 +260,14 @@ void main() { }); test('RenderAnimatedOpacity does not composite if it is opaque', () { - final Animation opacityAnimation = new AnimationController( - vsync: new _FakeTickerProvider(), + final Animation opacityAnimation = AnimationController( + vsync: _FakeTickerProvider(), )..value = 1.0; - final RenderAnimatedOpacity renderAnimatedOpacity = new RenderAnimatedOpacity( + final RenderAnimatedOpacity renderAnimatedOpacity = RenderAnimatedOpacity( alwaysIncludeSemantics: false, opacity: opacityAnimation, - child: new RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter + child: RenderSizedBox(const Size(1.0, 1.0)), // size doesn't matter ); layout(renderAnimatedOpacity, phase: EnginePhase.composite); @@ -278,7 +278,7 @@ void main() { class _FakeTickerProvider implements TickerProvider { @override Ticker createTicker(TickerCallback onTick, [bool disableAnimations = false]) { - return new _FakeTicker(); + return _FakeTicker(); } } diff --git a/packages/flutter/test/rendering/proxy_getters_and_setters_test.dart b/packages/flutter/test/rendering/proxy_getters_and_setters_test.dart index 6bddf6897e..cc5b5213a6 100644 --- a/packages/flutter/test/rendering/proxy_getters_and_setters_test.dart +++ b/packages/flutter/test/rendering/proxy_getters_and_setters_test.dart @@ -8,14 +8,14 @@ import '../flutter_test_alternative.dart'; void main() { test('RenderConstrainedBox getters and setters', () { - final RenderConstrainedBox box = new RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 10.0)); + final RenderConstrainedBox box = RenderConstrainedBox(additionalConstraints: const BoxConstraints.tightFor(height: 10.0)); expect(box.additionalConstraints, const BoxConstraints(minHeight: 10.0, maxHeight: 10.0)); box.additionalConstraints = const BoxConstraints.tightFor(width: 10.0); expect(box.additionalConstraints, const BoxConstraints(minWidth: 10.0, maxWidth: 10.0)); }); test('RenderLimitedBox getters and setters', () { - final RenderLimitedBox box = new RenderLimitedBox(); + final RenderLimitedBox box = RenderLimitedBox(); expect(box.maxWidth, double.infinity); expect(box.maxHeight, double.infinity); box.maxWidth = 0.0; @@ -25,7 +25,7 @@ void main() { }); test('RenderAspectRatio getters and setters', () { - final RenderAspectRatio box = new RenderAspectRatio(aspectRatio: 1.0); + final RenderAspectRatio box = RenderAspectRatio(aspectRatio: 1.0); expect(box.aspectRatio, 1.0); box.aspectRatio = 0.2; expect(box.aspectRatio, 0.2); @@ -34,7 +34,7 @@ void main() { }); test('RenderIntrinsicWidth getters and setters', () { - final RenderIntrinsicWidth box = new RenderIntrinsicWidth(); + final RenderIntrinsicWidth box = RenderIntrinsicWidth(); expect(box.stepWidth, isNull); box.stepWidth = 10.0; expect(box.stepWidth, 10.0); @@ -44,7 +44,7 @@ void main() { }); test('RenderOpacity getters and setters', () { - final RenderOpacity box = new RenderOpacity(); + final RenderOpacity box = RenderOpacity(); expect(box.opacity, 1.0); box.opacity = 0.0; expect(box.opacity, 0.0); @@ -53,7 +53,7 @@ void main() { test('RenderShaderMask getters and setters', () { final ShaderCallback callback1 = (Rect bounds) => null; final ShaderCallback callback2 = (Rect bounds) => null; - final RenderShaderMask box = new RenderShaderMask(shaderCallback: callback1); + final RenderShaderMask box = RenderShaderMask(shaderCallback: callback1); expect(box.shaderCallback, equals(callback1)); box.shaderCallback = callback2; expect(box.shaderCallback, equals(callback2)); diff --git a/packages/flutter/test/rendering/reattach_test.dart b/packages/flutter/test/rendering/reattach_test.dart index ca946d1d0f..0e927a3dea 100644 --- a/packages/flutter/test/rendering/reattach_test.dart +++ b/packages/flutter/test/rendering/reattach_test.dart @@ -11,25 +11,25 @@ import 'rendering_tester.dart'; class TestTree { TestTree() { // incoming constraints are tight 800x600 - root = new RenderPositionedBox( - child: new RenderConstrainedBox( + root = RenderPositionedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 800.0), // Place the child to be evaluated within both a repaint boundary and a // layout-root element (in this case a tightly constrained box). Otherwise // the act of transplanting the root into a new container will cause the // relayout/repaint of the new parent node to satisfy the test. - child: new RenderRepaintBoundary( - child: new RenderConstrainedBox( + child: RenderRepaintBoundary( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 20.0, width: 20.0), - child: new RenderRepaintBoundary( - child: new RenderCustomPaint( - painter: new TestCallbackPainter( + child: RenderRepaintBoundary( + child: RenderCustomPaint( + painter: TestCallbackPainter( onPaint: () { painted = true; }, ), - child: new RenderPositionedBox( - child: child = new RenderConstrainedBox( + child: RenderPositionedBox( + child: child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 20.0, width: 20.0), - child: new RenderSemanticsAnnotations(label: 'Hello there foo', textDirection: TextDirection.ltr) + child: RenderSemanticsAnnotations(label: 'Hello there foo', textDirection: TextDirection.ltr) ), ), ), @@ -54,19 +54,19 @@ class MutableCompositor extends RenderProxyBox { class TestCompositingBitsTree { TestCompositingBitsTree() { // incoming constraints are tight 800x600 - root = new RenderPositionedBox( - child: new RenderConstrainedBox( + root = RenderPositionedBox( + child: RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(width: 800.0), // Place the child to be evaluated within a repaint boundary. Otherwise // the act of transplanting the root into a new container will cause the // repaint of the new parent node to satisfy the test. - child: new RenderRepaintBoundary( - child: compositor = new MutableCompositor( - child: new RenderCustomPaint( - painter: new TestCallbackPainter( + child: RenderRepaintBoundary( + child: compositor = MutableCompositor( + child: RenderCustomPaint( + painter: TestCallbackPainter( onPaint: () { painted = true; }, ), - child: child = new RenderConstrainedBox( + child: child = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 20.0, width: 20.0) ), ), @@ -83,7 +83,7 @@ class TestCompositingBitsTree { void main() { test('objects can be detached and re-attached: layout', () { - final TestTree testTree = new TestTree(); + final TestTree testTree = TestTree(); // Lay out layout(testTree.root, phase: EnginePhase.layout); expect(testTree.child.size, equals(const Size(20.0, 20.0))); @@ -98,7 +98,7 @@ void main() { expect(testTree.child.size, equals(const Size(5.0, 5.0))); }); test('objects can be detached and re-attached: compositingBits', () { - final TestCompositingBitsTree testTree = new TestCompositingBitsTree(); + final TestCompositingBitsTree testTree = TestCompositingBitsTree(); // Lay out, composite, and paint layout(testTree.root, phase: EnginePhase.paint); expect(testTree.painted, isTrue); @@ -114,7 +114,7 @@ void main() { expect(testTree.painted, isTrue); }); test('objects can be detached and re-attached: paint', () { - final TestTree testTree = new TestTree(); + final TestTree testTree = TestTree(); // Lay out, composite, and paint layout(testTree.root, phase: EnginePhase.paint); expect(testTree.painted, isTrue); @@ -129,7 +129,7 @@ void main() { expect(testTree.painted, isTrue); }); test('objects can be detached and re-attached: semantics (no change)', () { - final TestTree testTree = new TestTree(); + final TestTree testTree = TestTree(); int semanticsUpdateCount = 0; final SemanticsHandle semanticsHandle = renderer.pipelineOwner.ensureSemantics( listener: () { @@ -152,7 +152,7 @@ void main() { semanticsHandle.dispose(); }); test('objects can be detached and re-attached: semantics (with change)', () { - final TestTree testTree = new TestTree(); + final TestTree testTree = TestTree(); int semanticsUpdateCount = 0; final SemanticsHandle semanticsHandle = renderer.pipelineOwner.ensureSemantics( listener: () { diff --git a/packages/flutter/test/rendering/recording_canvas.dart b/packages/flutter/test/rendering/recording_canvas.dart index 0e04296ad7..d8cae835c0 100644 --- a/packages/flutter/test/rendering/recording_canvas.dart +++ b/packages/flutter/test/rendering/recording_canvas.dart @@ -67,25 +67,25 @@ class TestRecordingCanvas implements Canvas { @override void save() { _saveCount += 1; - invocations.add(new RecordedInvocation(new _MethodCall(#save), stack: StackTrace.current)); + invocations.add(RecordedInvocation(_MethodCall(#save), stack: StackTrace.current)); } @override void saveLayer(Rect bounds, Paint paint) { _saveCount += 1; - invocations.add(new RecordedInvocation(new _MethodCall(#saveLayer, [bounds, paint]), stack: StackTrace.current)); + invocations.add(RecordedInvocation(_MethodCall(#saveLayer, [bounds, paint]), stack: StackTrace.current)); } @override void restore() { _saveCount -= 1; assert(_saveCount >= 0); - invocations.add(new RecordedInvocation(new _MethodCall(#restore), stack: StackTrace.current)); + invocations.add(RecordedInvocation(_MethodCall(#restore), stack: StackTrace.current)); } @override void noSuchMethod(Invocation invocation) { - invocations.add(new RecordedInvocation(invocation, stack: StackTrace.current)); + invocations.add(RecordedInvocation(invocation, stack: StackTrace.current)); } } @@ -181,7 +181,7 @@ String _symbolName(Symbol symbol) { // Workaround for https://github.com/dart-lang/sdk/issues/28373 String _describeInvocation(Invocation call) { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.write(_symbolName(call.memberName)); if (call.isSetter) { buffer.write(call.positionalArguments[0].toString()); diff --git a/packages/flutter/test/rendering/relative_rect_test.dart b/packages/flutter/test/rendering/relative_rect_test.dart index ef9e2e4a43..087ff32022 100644 --- a/packages/flutter/test/rendering/relative_rect_test.dart +++ b/packages/flutter/test/rendering/relative_rect_test.dart @@ -8,7 +8,7 @@ import '../flutter_test_alternative.dart'; void main() { test('RelativeRect.==', () { const RelativeRect r = RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); - expect(r, new RelativeRect.fromSize(new Rect.fromLTWH(10.0, 20.0, 0.0, 0.0), const Size(40.0, 60.0))); + expect(r, RelativeRect.fromSize(Rect.fromLTWH(10.0, 20.0, 0.0, 0.0), const Size(40.0, 60.0))); }); test('RelativeRect.shift', () { const RelativeRect r1 = RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); @@ -35,8 +35,8 @@ void main() { }); test('RelativeRect.toRect', () { const RelativeRect r1 = RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); - final Rect r2 = r1.toRect(new Rect.fromLTRB(10.0, 20.0, 90.0, 180.0)); - expect(r2, new Rect.fromLTRB(10.0, 20.0, 50.0, 120.0)); + final Rect r2 = r1.toRect(Rect.fromLTRB(10.0, 20.0, 90.0, 180.0)); + expect(r2, Rect.fromLTRB(10.0, 20.0, 50.0, 120.0)); }); test('RelativeRect.toSize', () { const RelativeRect r1 = RelativeRect.fromLTRB(10.0, 20.0, 30.0, 40.0); diff --git a/packages/flutter/test/rendering/rendering_tester.dart b/packages/flutter/test/rendering/rendering_tester.dart index 5c9d284cc3..c2924fadce 100644 --- a/packages/flutter/test/rendering/rendering_tester.dart +++ b/packages/flutter/test/rendering/rendering_tester.dart @@ -39,7 +39,7 @@ class TestRenderingFlutterBinding extends BindingBase with ServicesBinding, Gest TestRenderingFlutterBinding _renderer; TestRenderingFlutterBinding get renderer { - _renderer ??= new TestRenderingFlutterBinding(); + _renderer ??= TestRenderingFlutterBinding(); return _renderer; } @@ -65,9 +65,9 @@ void layout(RenderBox box, { renderer.renderView.child = null; if (constraints != null) { - box = new RenderPositionedBox( + box = RenderPositionedBox( alignment: alignment, - child: new RenderConstrainedBox( + child: RenderConstrainedBox( additionalConstraints: constraints, child: box ) diff --git a/packages/flutter/test/rendering/repaint_boundary_test.dart b/packages/flutter/test/rendering/repaint_boundary_test.dart index f9e145aec9..9f69d4333e 100644 --- a/packages/flutter/test/rendering/repaint_boundary_test.dart +++ b/packages/flutter/test/rendering/repaint_boundary_test.dart @@ -10,13 +10,13 @@ import 'rendering_tester.dart'; void main() { test('nested repaint boundaries - smoke test', () { RenderOpacity a, b, c; - a = new RenderOpacity( + a = RenderOpacity( opacity: 1.0, - child: new RenderRepaintBoundary( - child: b = new RenderOpacity( + child: RenderRepaintBoundary( + child: b = RenderOpacity( opacity: 1.0, - child: new RenderRepaintBoundary( - child: c = new RenderOpacity( + child: RenderRepaintBoundary( + child: c = RenderOpacity( opacity: 1.0 ) ) diff --git a/packages/flutter/test/rendering/semantics_and_children_test.dart b/packages/flutter/test/rendering/semantics_and_children_test.dart index 7bd70bb26c..39b9e775b5 100644 --- a/packages/flutter/test/rendering/semantics_and_children_test.dart +++ b/packages/flutter/test/rendering/semantics_and_children_test.dart @@ -19,8 +19,8 @@ int countSemanticsChildren(RenderObject object) { void main() { test('RenderOpacity and children and semantics', () { - final RenderOpacity box = new RenderOpacity( - child: new RenderParagraph( + final RenderOpacity box = RenderOpacity( + child: RenderParagraph( const TextSpan(), textDirection: TextDirection.ltr, ), @@ -41,11 +41,11 @@ void main() { }); test('RenderOpacity and children and semantics', () { - final AnimationController controller = new AnimationController(vsync: const TestVSync()); - final RenderAnimatedOpacity box = new RenderAnimatedOpacity( + final AnimationController controller = AnimationController(vsync: const TestVSync()); + final RenderAnimatedOpacity box = RenderAnimatedOpacity( alwaysIncludeSemantics: false, opacity: controller, - child: new RenderParagraph( + child: RenderParagraph( const TextSpan(), textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/rendering/simple_semantics_test.dart b/packages/flutter/test/rendering/simple_semantics_test.dart index b305db2e2d..5bfa735179 100644 --- a/packages/flutter/test/rendering/simple_semantics_test.dart +++ b/packages/flutter/test/rendering/simple_semantics_test.dart @@ -11,11 +11,11 @@ import 'rendering_tester.dart'; void main() { test('only send semantics update if semantics have changed', () { - final TestRender testRender = new TestRender() + final TestRender testRender = TestRender() ..label = 'hello' ..textDirection = TextDirection.ltr; - final RenderObject tree = new RenderConstrainedBox( + final RenderObject tree = RenderConstrainedBox( additionalConstraints: const BoxConstraints.tightFor(height: 20.0, width: 20.0), child: testRender, ); diff --git a/packages/flutter/test/rendering/size_test.dart b/packages/flutter/test/rendering/size_test.dart index 05fd72edfa..13e184ebd3 100644 --- a/packages/flutter/test/rendering/size_test.dart +++ b/packages/flutter/test/rendering/size_test.dart @@ -9,8 +9,8 @@ import 'rendering_tester.dart'; void main() { test('Stack can layout with top, right, bottom, left 0.0', () { - final RenderBox box = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0))); + final RenderBox box = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0))); layout(box, constraints: const BoxConstraints()); diff --git a/packages/flutter/test/rendering/sliver_cache_test.dart b/packages/flutter/test/rendering/sliver_cache_test.dart index 0f1e1aa316..a3f28c6e88 100644 --- a/packages/flutter/test/rendering/sliver_cache_test.dart +++ b/packages/flutter/test/rendering/sliver_cache_test.dart @@ -10,18 +10,18 @@ import 'rendering_tester.dart'; void main() { test('RenderViewport calculates correct constraints, RenderSliverToBoxAdapter calculates correct geometry', () { - final List children = new List.generate(30, (int index) { - return new RenderSliverToBoxAdapter( - child: new RenderSizedBox(const Size(400.0, 100.0)), + final List children = List.generate(30, (int index) { + return RenderSliverToBoxAdapter( + child: RenderSizedBox(const Size(400.0, 100.0)), ); }); // Viewport is 800x600, can show 6 children at a time. - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), cacheExtent: 250.0, children: children, ); @@ -103,7 +103,7 @@ void main() { ); // scroll down half a sliver - root.offset = new ViewportOffset.fixed(50.0); + root.offset = ViewportOffset.fixed(50.0); pumpFrame(); firstVisible = children[0]; @@ -182,7 +182,7 @@ void main() { ); // scroll down 1.5 slivers - root.offset = new ViewportOffset.fixed(150.0); + root.offset = ViewportOffset.fixed(150.0); pumpFrame(); RenderSliver firstInPreCache = children[0]; @@ -216,7 +216,7 @@ void main() { ); // scroll down 10 slivers - root.offset = new ViewportOffset.fixed(1000.0); + root.offset = ViewportOffset.fixed(1000.0); pumpFrame(); final RenderSliver first = children[0]; @@ -282,17 +282,17 @@ void main() { test('RenderSliverFixedExtentList calculates correct geometry', () { // Viewport is 800x600, can show 6 full children at a time - final List children = new List.generate(30, (int index) { - return new RenderSizedBox(const Size(400.0, 100.0)); + final List children = List.generate(30, (int index) { + return RenderSizedBox(const Size(400.0, 100.0)); }); - final TestRenderSliverBoxChildManager childManager = new TestRenderSliverBoxChildManager( + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( children: children, ); RenderSliverFixedExtentList inner; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), cacheExtent: 250.0, children: [ inner = childManager.createRenderSliverFixedExtentList(), @@ -317,7 +317,7 @@ void main() { expect(children.sublist(9, 30).any((RenderBox r) => r.attached), false); // scroll half an item down - root.offset = new ViewportOffset.fixed(50.0); + root.offset = ViewportOffset.fixed(50.0); pumpFrame(); expectSliverConstraints( @@ -338,7 +338,7 @@ void main() { // scroll to the middle - root.offset = new ViewportOffset.fixed(1500.0); + root.offset = ViewportOffset.fixed(1500.0); pumpFrame(); expectSliverConstraints( @@ -360,7 +360,7 @@ void main() { expect(children.sublist(24, 30).any((RenderBox r) => r.attached), false); // scroll to the end - root.offset = new ViewportOffset.fixed(2400.0); + root.offset = ViewportOffset.fixed(2400.0); pumpFrame(); expectSliverConstraints( @@ -382,17 +382,17 @@ void main() { test('RenderSliverList calculates correct geometry', () { // Viewport is 800x600, can show 6 full children at a time - final List children = new List.generate(30, (int index) { - return new RenderSizedBox(const Size(400.0, 100.0)); + final List children = List.generate(30, (int index) { + return RenderSizedBox(const Size(400.0, 100.0)); }); - final TestRenderSliverBoxChildManager childManager = new TestRenderSliverBoxChildManager( + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( children: children, ); RenderSliverList inner; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), cacheExtent: 250.0, children: [ inner = childManager.createRenderSliverList(), @@ -417,7 +417,7 @@ void main() { expect(children.sublist(9, 30).any((RenderBox r) => r.attached), false); // scroll half an item down - root.offset = new ViewportOffset.fixed(50.0); + root.offset = ViewportOffset.fixed(50.0); pumpFrame(); expectSliverConstraints( @@ -438,7 +438,7 @@ void main() { // scroll to the middle - root.offset = new ViewportOffset.fixed(1500.0); + root.offset = ViewportOffset.fixed(1500.0); pumpFrame(); expectSliverConstraints( @@ -460,7 +460,7 @@ void main() { expect(children.sublist(24, 30).any((RenderBox r) => r.attached), false); // scroll to the end - root.offset = new ViewportOffset.fixed(2400.0); + root.offset = ViewportOffset.fixed(2400.0); pumpFrame(); expectSliverConstraints( @@ -482,17 +482,17 @@ void main() { test('RenderSliverGrid calculates correct geometry', () { // Viewport is 800x600, each grid element is 400x100, giving us space for 12 visible children - final List children = new List.generate(60, (int index) { - return new RenderSizedBox(const Size(400.0, 100.0)); + final List children = List.generate(60, (int index) { + return RenderSizedBox(const Size(400.0, 100.0)); }); - final TestRenderSliverBoxChildManager childManager = new TestRenderSliverBoxChildManager( + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( children: children, ); RenderSliverGrid inner; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), cacheExtent: 250.0, children: [ inner = childManager.createRenderSliverGrid(), @@ -517,7 +517,7 @@ void main() { expect(children.sublist(18, 60).any((RenderBox r) => r.attached), false); // scroll half an item down - root.offset = new ViewportOffset.fixed(50.0); + root.offset = ViewportOffset.fixed(50.0); pumpFrame(); expectSliverConstraints( @@ -538,7 +538,7 @@ void main() { // scroll to the middle - root.offset = new ViewportOffset.fixed(1500.0); + root.offset = ViewportOffset.fixed(1500.0); pumpFrame(); expectSliverConstraints( @@ -560,7 +560,7 @@ void main() { expect(children.sublist(48, 60).any((RenderBox r) => r.attached), false); // scroll to the end - root.offset = new ViewportOffset.fixed(2400.0); + root.offset = ViewportOffset.fixed(2400.0); pumpFrame(); expectSliverConstraints( @@ -584,12 +584,12 @@ void main() { // Viewport is 800x600, each item is 100px high with 50px before and after = 200px final List adapters = []; - final List paddings = new List.generate(30, (int index) { + final List paddings = List.generate(30, (int index) { RenderSliverToBoxAdapter adapter; - final RenderSliverPadding padding = new RenderSliverPadding( + final RenderSliverPadding padding = RenderSliverPadding( padding: const EdgeInsets.symmetric(vertical: 50.0), - child: adapter = new RenderSliverToBoxAdapter( - child: new RenderSizedBox(const Size(400.0, 100.0)), + child: adapter = RenderSliverToBoxAdapter( + child: RenderSizedBox(const Size(400.0, 100.0)), ), ); adapters.add(adapter); @@ -597,10 +597,10 @@ void main() { }); - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), cacheExtent: 250.0, children: paddings, ); @@ -723,7 +723,7 @@ void main() { ); // scroll first padding off screen - root.offset = new ViewportOffset.fixed(50.0); + root.offset = ViewportOffset.fixed(50.0); pumpFrame(); firstVisiblePadding = paddings[0]; @@ -756,7 +756,7 @@ void main() { ); // scroll to the end - root.offset = new ViewportOffset.fixed(5400.0); + root.offset = ViewportOffset.fixed(5400.0); pumpFrame(); @@ -901,13 +901,13 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { RenderSliverList createRenderSliverList() { assert(_renderObject == null); - _renderObject = new RenderSliverList(childManager: this); + _renderObject = RenderSliverList(childManager: this); return _renderObject; } RenderSliverFixedExtentList createRenderSliverFixedExtentList() { assert(_renderObject == null); - _renderObject = new RenderSliverFixedExtentList( + _renderObject = RenderSliverFixedExtentList( childManager: this, itemExtent: 100.0, ); @@ -916,7 +916,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { RenderSliverGrid createRenderSliverGrid() { assert(_renderObject == null); - _renderObject = new RenderSliverGrid( + _renderObject = RenderSliverGrid( childManager: this, gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, diff --git a/packages/flutter/test/rendering/slivers_block_test.dart b/packages/flutter/test/rendering/slivers_block_test.dart index 52115dad3f..a1ff80106f 100644 --- a/packages/flutter/test/rendering/slivers_block_test.dart +++ b/packages/flutter/test/rendering/slivers_block_test.dart @@ -18,7 +18,7 @@ class TestRenderSliverBoxChildManager extends RenderSliverBoxChildManager { RenderSliverList createRenderObject() { assert(_renderObject == null); - _renderObject = new RenderSliverList(childManager: this); + _renderObject = RenderSliverList(childManager: this); return _renderObject; } @@ -70,19 +70,19 @@ void main() { test('RenderSliverList basic test - down', () { RenderObject inner; RenderBox a, b, c, d, e; - final TestRenderSliverBoxChildManager childManager = new TestRenderSliverBoxChildManager( + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( children: [ - a = new RenderSizedBox(const Size(100.0, 400.0)), - b = new RenderSizedBox(const Size(100.0, 400.0)), - c = new RenderSizedBox(const Size(100.0, 400.0)), - d = new RenderSizedBox(const Size(100.0, 400.0)), - e = new RenderSizedBox(const Size(100.0, 400.0)), + a = RenderSizedBox(const Size(100.0, 400.0)), + b = RenderSizedBox(const Size(100.0, 400.0)), + c = RenderSizedBox(const Size(100.0, 400.0)), + d = RenderSizedBox(const Size(100.0, 400.0)), + e = RenderSizedBox(const Size(100.0, 400.0)), ], ); - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), cacheExtent: 0.0, children: [ inner = childManager.createRenderObject(), @@ -109,7 +109,7 @@ void main() { expect(e.attached, false); // now try various scroll offsets - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 200.0)); @@ -117,7 +117,7 @@ void main() { expect(d.attached, false); expect(e.attached, false); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.attached, false); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); @@ -125,7 +125,7 @@ void main() { expect(d.attached, false); expect(e.attached, false); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.attached, false); expect(b.attached, false); @@ -134,7 +134,7 @@ void main() { expect(e.attached, false); // try going back up - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 200.0)); @@ -146,19 +146,19 @@ void main() { test('RenderSliverList basic test - up', () { RenderObject inner; RenderBox a, b, c, d, e; - final TestRenderSliverBoxChildManager childManager = new TestRenderSliverBoxChildManager( + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( children: [ - a = new RenderSizedBox(const Size(100.0, 400.0)), - b = new RenderSizedBox(const Size(100.0, 400.0)), - c = new RenderSizedBox(const Size(100.0, 400.0)), - d = new RenderSizedBox(const Size(100.0, 400.0)), - e = new RenderSizedBox(const Size(100.0, 400.0)), + a = RenderSizedBox(const Size(100.0, 400.0)), + b = RenderSizedBox(const Size(100.0, 400.0)), + c = RenderSizedBox(const Size(100.0, 400.0)), + d = RenderSizedBox(const Size(100.0, 400.0)), + e = RenderSizedBox(const Size(100.0, 400.0)), ], ); - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.up, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ inner = childManager.createRenderObject(), ], @@ -185,7 +185,7 @@ void main() { expect(e.attached, false); // now try various scroll offsets - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0)); @@ -193,7 +193,7 @@ void main() { expect(d.attached, false); expect(e.attached, false); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.attached, false); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); @@ -201,7 +201,7 @@ void main() { expect(d.attached, false); expect(e.attached, false); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.attached, false); expect(b.attached, false); @@ -210,7 +210,7 @@ void main() { expect(e.attached, false); // try going back up - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0)); @@ -222,19 +222,19 @@ void main() { test('SliverList - no zero scroll offset correction', () { RenderSliverList inner; RenderBox a; - final TestRenderSliverBoxChildManager childManager = new TestRenderSliverBoxChildManager( + final TestRenderSliverBoxChildManager childManager = TestRenderSliverBoxChildManager( children: [ - a = new RenderSizedBox(const Size(100.0, 400.0)), - new RenderSizedBox(const Size(100.0, 400.0)), - new RenderSizedBox(const Size(100.0, 400.0)), - new RenderSizedBox(const Size(100.0, 400.0)), - new RenderSizedBox(const Size(100.0, 400.0)), + a = RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), + RenderSizedBox(const Size(100.0, 400.0)), ], ); - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ inner = childManager.createRenderObject(), ], @@ -244,17 +244,17 @@ void main() { final SliverMultiBoxAdaptorParentData parentData = a.parentData; parentData.layoutOffset = 0.001; - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); - root.offset = new ViewportOffset.fixed(0.0); + root.offset = ViewportOffset.fixed(0.0); pumpFrame(); expect(inner.geometry.scrollOffsetCorrection, isNull); }); test('SliverMultiBoxAdaptorParentData.toString', () { - final SliverMultiBoxAdaptorParentData candidate = new SliverMultiBoxAdaptorParentData(); + final SliverMultiBoxAdaptorParentData candidate = SliverMultiBoxAdaptorParentData(); expect(candidate.keepAlive, isFalse); expect(candidate.index, isNull); expect(candidate.toString(), 'index=null; layoutOffset=0.0'); diff --git a/packages/flutter/test/rendering/slivers_layout_test.dart b/packages/flutter/test/rendering/slivers_layout_test.dart index 6f8fa0ce41..af12fea1ac 100644 --- a/packages/flutter/test/rendering/slivers_layout_test.dart +++ b/packages/flutter/test/rendering/slivers_layout_test.dart @@ -23,12 +23,12 @@ void main() { RenderSliverToBoxAdapter sliver; RenderViewport viewport; RenderBox box; - final RenderObject root = new RenderLayoutWatcher( - viewport = new RenderViewport( + final RenderObject root = RenderLayoutWatcher( + viewport = RenderViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - sliver = new RenderSliverToBoxAdapter(child: box = new RenderSizedBox(const Size(100.0, 400.0))), + sliver = RenderSliverToBoxAdapter(child: box = RenderSizedBox(const Size(100.0, 400.0))), ], ), ); @@ -37,19 +37,19 @@ void main() { expect(layouts, 1); expect(box.localToGlobal(box.size.center(Offset.zero)), const Offset(400.0, 200.0)); - sliver.child = box = new RenderSizedBox(const Size(100.0, 300.0)); + sliver.child = box = RenderSizedBox(const Size(100.0, 300.0)); expect(layouts, 1); pumpFrame(); expect(layouts, 1); expect(box.localToGlobal(box.size.center(Offset.zero)), const Offset(400.0, 150.0)); - viewport.offset = new ViewportOffset.fixed(20.0); + viewport.offset = ViewportOffset.fixed(20.0); expect(layouts, 1); pumpFrame(); expect(layouts, 1); expect(box.localToGlobal(box.size.center(Offset.zero)), const Offset(400.0, 130.0)); - viewport.offset = new ViewportOffset.fixed(-20.0); + viewport.offset = ViewportOffset.fixed(-20.0); expect(layouts, 1); pumpFrame(); expect(layouts, 1); diff --git a/packages/flutter/test/rendering/slivers_test.dart b/packages/flutter/test/rendering/slivers_test.dart index 7fa4f0e4f6..811ba15ae9 100644 --- a/packages/flutter/test/rendering/slivers_test.dart +++ b/packages/flutter/test/rendering/slivers_test.dart @@ -10,9 +10,9 @@ import 'rendering_tester.dart'; void main() { test('RenderViewport basic test - no children', () { - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), ); expect(root, hasAGoodToStringDeep); expect( @@ -29,7 +29,7 @@ void main() { ), ); layout(root); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); expect(root, hasAGoodToStringDeep); expect( root.toStringDeep(minLevel: DiagnosticLevel.info), @@ -50,15 +50,15 @@ void main() { test('RenderViewport basic test - down', () { RenderBox a, b, c, d, e; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(100.0, 400.0))), ], ); expect(root, hasAGoodToStringDeep); @@ -175,7 +175,7 @@ void main() { expect(d.localToGlobal(const Offset(800.0, 400.0)), const Offset(800.0, 1600.0)); expect(e.localToGlobal(const Offset(800.0, 400.0)), const Offset(800.0, 2000.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 200.0)); @@ -183,7 +183,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1000.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1400.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -600.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); @@ -191,7 +191,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 600.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1000.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -900.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -500.0)); @@ -199,23 +199,23 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 300.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 700.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(130.0, 150.0)); expect(result.path.first.target, equals(c)); }); test('RenderViewport basic test - up', () { RenderBox a, b, c, d, e; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.up, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(100.0, 400.0))), ], ); layout(root); @@ -229,7 +229,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -1000.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -1400.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0)); @@ -237,7 +237,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -800.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -1200.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 800.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); @@ -245,7 +245,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -400.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -800.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1100.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 700.0)); @@ -253,28 +253,28 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -100.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -500.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(150.0, 350.0)); expect(result.path.first.target, equals(c)); }); Offset _getPaintOrigin(RenderObject render) { - final Vector3 transformed3 = render.getTransformTo(null).perspectiveTransform(new Vector3(0.0, 0.0, 0.0)); - return new Offset(transformed3.x, transformed3.y); + final Vector3 transformed3 = render.getTransformTo(null).perspectiveTransform(Vector3(0.0, 0.0, 0.0)); + return Offset(transformed3.x, transformed3.y); } test('RenderViewport basic test - right', () { RenderBox a, b, c, d, e; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.right, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(400.0, 100.0))), ], ); layout(root); @@ -300,7 +300,7 @@ void main() { expect(_getPaintOrigin(sliverD), const Offset(1200.0, 0.0)); expect(_getPaintOrigin(sliverE), const Offset(1600.0, 0.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(-200.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(200.0, 0.0)); @@ -314,7 +314,7 @@ void main() { expect(_getPaintOrigin(sliverD), const Offset(1000.0, 0.0)); expect(_getPaintOrigin(sliverE), const Offset(1400.0, 0.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(-600.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(-200.0, 0.0)); @@ -328,7 +328,7 @@ void main() { expect(_getPaintOrigin(sliverD), const Offset(600.0, 0.0)); expect(_getPaintOrigin(sliverE), const Offset(1000.0, 0.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(-900.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(-500.0, 0.0)); @@ -342,23 +342,23 @@ void main() { expect(_getPaintOrigin(sliverD), const Offset(300.0, 0.0)); expect(_getPaintOrigin(sliverE), const Offset(700.0, 0.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(150.0, 450.0)); expect(result.path.first.target, equals(c)); }); test('RenderViewport basic test - left', () { RenderBox a, b, c, d, e; - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.left, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(400.0, 100.0))), ], ); layout(root); @@ -372,7 +372,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(-800.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-1200.0, 0.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(600.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(200.0, 0.0)); @@ -380,7 +380,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(-600.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-1000.0, 0.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(1000.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(600.0, 0.0)); @@ -388,7 +388,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(-200.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-600.0, 0.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(1300.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(900.0, 0.0)); @@ -396,7 +396,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(100.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-300.0, 0.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(550.0, 150.0)); expect(result.path.first.target, equals(c)); }); @@ -406,27 +406,27 @@ void main() { // TODO(ianh): test semantics test('RenderShrinkWrappingViewport basic test - no children', () { - final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport( + final RenderShrinkWrappingViewport root = RenderShrinkWrappingViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), ); expect(root, hasAGoodToStringDeep); layout(root); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); }); test('RenderShrinkWrappingViewport basic test - down', () { RenderBox a, b, c, d, e; - final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport( + final RenderShrinkWrappingViewport root = RenderShrinkWrappingViewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(100.0, 400.0))), ], ); layout(root); @@ -446,7 +446,7 @@ void main() { expect(d.localToGlobal(const Offset(800.0, 400.0)), const Offset(800.0, 1600.0)); expect(e.localToGlobal(const Offset(800.0, 400.0)), const Offset(800.0, 2000.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 200.0)); @@ -454,7 +454,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1000.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1400.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -600.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -200.0)); @@ -462,7 +462,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 600.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1000.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -900.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -500.0)); @@ -470,23 +470,23 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 300.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 700.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(130.0, 150.0)); expect(result.path.first.target, equals(c)); }); test('RenderShrinkWrappingViewport basic test - up', () { RenderBox a, b, c, d, e; - final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport( + final RenderShrinkWrappingViewport root = RenderShrinkWrappingViewport( axisDirection: AxisDirection.up, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(100.0, 400.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(100.0, 400.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(100.0, 400.0))), ], ); layout(root); @@ -500,7 +500,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -1000.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -1400.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 0.0)); @@ -508,7 +508,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -800.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -1200.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 800.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 400.0)); @@ -516,7 +516,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -400.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -800.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 1100.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, 700.0)); @@ -524,23 +524,23 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -100.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(0.0, -500.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(150.0, 350.0)); expect(result.path.first.target, equals(c)); }); test('RenderShrinkWrappingViewport basic test - right', () { RenderBox a, b, c, d, e; - final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport( + final RenderShrinkWrappingViewport root = RenderShrinkWrappingViewport( axisDirection: AxisDirection.right, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(400.0, 100.0))), ], ); layout(root); @@ -554,7 +554,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(1200.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(1600.0, 0.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(-200.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(200.0, 0.0)); @@ -562,7 +562,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(1000.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(1400.0, 0.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(-600.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(-200.0, 0.0)); @@ -570,7 +570,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(600.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(1000.0, 0.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(-900.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(-500.0, 0.0)); @@ -578,23 +578,23 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(300.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(700.0, 0.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(150.0, 450.0)); expect(result.path.first.target, equals(c)); }); test('RenderShrinkWrappingViewport basic test - left', () { RenderBox a, b, c, d, e; - final RenderShrinkWrappingViewport root = new RenderShrinkWrappingViewport( + final RenderShrinkWrappingViewport root = RenderShrinkWrappingViewport( axisDirection: AxisDirection.left, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ - new RenderSliverToBoxAdapter(child: a = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: b = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: c = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: d = new RenderSizedBox(const Size(400.0, 100.0))), - new RenderSliverToBoxAdapter(child: e = new RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: a = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: b = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: c = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: d = RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: e = RenderSizedBox(const Size(400.0, 100.0))), ], ); layout(root); @@ -608,7 +608,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(-800.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-1200.0, 0.0)); - root.offset = new ViewportOffset.fixed(200.0); + root.offset = ViewportOffset.fixed(200.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(600.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(200.0, 0.0)); @@ -616,7 +616,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(-600.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-1000.0, 0.0)); - root.offset = new ViewportOffset.fixed(600.0); + root.offset = ViewportOffset.fixed(600.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(1000.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(600.0, 0.0)); @@ -624,7 +624,7 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(-200.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-600.0, 0.0)); - root.offset = new ViewportOffset.fixed(900.0); + root.offset = ViewportOffset.fixed(900.0); pumpFrame(); expect(a.localToGlobal(const Offset(0.0, 0.0)), const Offset(1300.0, 0.0)); expect(b.localToGlobal(const Offset(0.0, 0.0)), const Offset(900.0, 0.0)); @@ -632,20 +632,20 @@ void main() { expect(d.localToGlobal(const Offset(0.0, 0.0)), const Offset(100.0, 0.0)); expect(e.localToGlobal(const Offset(0.0, 0.0)), const Offset(-300.0, 0.0)); - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); root.hitTest(result, position: const Offset(550.0, 150.0)); expect(result.path.first.target, equals(c)); }); test('RenderShrinkWrappingViewport shrinkwrap test - 1 child', () { RenderBox child; - final RenderBox root = new RenderPositionedBox( - child: child = new RenderShrinkWrappingViewport( + final RenderBox root = RenderPositionedBox( + child: child = RenderShrinkWrappingViewport( axisDirection: AxisDirection.left, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.fixed(200.0), + offset: ViewportOffset.fixed(200.0), children: [ - new RenderSliverToBoxAdapter(child: new RenderSizedBox(const Size(400.0, 100.0))), + RenderSliverToBoxAdapter(child: RenderSizedBox(const Size(400.0, 100.0))), ], ), ); @@ -659,14 +659,14 @@ void main() { test('RenderShrinkWrappingViewport shrinkwrap test - 2 children', () { RenderBox child; - final RenderBox root = new RenderPositionedBox( - child: child = new RenderShrinkWrappingViewport( + final RenderBox root = RenderPositionedBox( + child: child = RenderShrinkWrappingViewport( axisDirection: AxisDirection.right, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.fixed(200.0), + offset: ViewportOffset.fixed(200.0), children: [ - new RenderSliverToBoxAdapter(child: new RenderSizedBox(const Size(300.0, 100.0))), - new RenderSliverToBoxAdapter(child: new RenderSizedBox(const Size(150.0, 100.0))), + RenderSliverToBoxAdapter(child: RenderSizedBox(const Size(300.0, 100.0))), + RenderSliverToBoxAdapter(child: RenderSizedBox(const Size(150.0, 100.0))), ], ), ); @@ -709,20 +709,20 @@ void main() { test('Sliver paintBounds and semanticBounds - vertical', () { const double height = 150.0; - final RenderSliver sliver = new RenderSliverToBoxAdapter( - child: new RenderSizedBox(const Size(400.0, height)), + final RenderSliver sliver = RenderSliverToBoxAdapter( + child: RenderSizedBox(const Size(400.0, height)), ); - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.down, crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ sliver, ], ); layout(root); - final Rect expectedRect = new Rect.fromLTWH(0.0, 0.0, root.size.width, height); + final Rect expectedRect = Rect.fromLTWH(0.0, 0.0, root.size.width, height); expect(sliver.paintBounds, expectedRect); expect(sliver.semanticBounds, expectedRect); @@ -731,20 +731,20 @@ void main() { test('Sliver paintBounds and semanticBounds - horizontal', () { const double width = 150.0; - final RenderSliver sliver = new RenderSliverToBoxAdapter( - child: new RenderSizedBox(const Size(width, 400.0)), + final RenderSliver sliver = RenderSliverToBoxAdapter( + child: RenderSizedBox(const Size(width, 400.0)), ); - final RenderViewport root = new RenderViewport( + final RenderViewport root = RenderViewport( axisDirection: AxisDirection.right, crossAxisDirection: AxisDirection.down, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), children: [ sliver, ], ); layout(root); - final Rect expectedRect = new Rect.fromLTWH(0.0, 0.0, width, root.size.height); + final Rect expectedRect = Rect.fromLTWH(0.0, 0.0, width, root.size.height); expect(sliver.paintBounds, expectedRect); expect(sliver.semanticBounds, expectedRect); diff --git a/packages/flutter/test/rendering/stack_test.dart b/packages/flutter/test/rendering/stack_test.dart index a6fd9030d1..706737b6e1 100644 --- a/packages/flutter/test/rendering/stack_test.dart +++ b/packages/flutter/test/rendering/stack_test.dart @@ -9,24 +9,24 @@ import 'rendering_tester.dart'; void main() { test('Stack can layout with top, right, bottom, left 0.0', () { - final RenderBox size = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)) + final RenderBox size = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)) ); - final RenderBox red = new RenderDecoratedBox( + final RenderBox red = RenderDecoratedBox( decoration: const BoxDecoration( color: Color(0xFFFF0000), ), child: size ); - final RenderBox green = new RenderDecoratedBox( + final RenderBox green = RenderDecoratedBox( decoration: const BoxDecoration( color: Color(0xFFFF0000), ), ); - final RenderBox stack = new RenderStack( + final RenderBox stack = RenderStack( textDirection: TextDirection.ltr, children: [red, green], ); @@ -50,12 +50,12 @@ void main() { }); test('Stack can layout with no children', () { - final RenderBox stack = new RenderStack( + final RenderBox stack = RenderStack( textDirection: TextDirection.ltr, children: [], ); - layout(stack, constraints: new BoxConstraints.tight(const Size(100.0, 100.0))); + layout(stack, constraints: BoxConstraints.tight(const Size(100.0, 100.0))); expect(stack.size.width, equals(100.0)); expect(stack.size.height, equals(100.0)); @@ -63,16 +63,16 @@ void main() { group('RenderIndexedStack', () { test('visitChildrenForSemantics only visits displayed child', () { - final RenderBox child1 = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)) + final RenderBox child1 = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)) ); - final RenderBox child2 = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)) + final RenderBox child2 = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)) ); - final RenderBox child3 = new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(const Size(100.0, 100.0)) + final RenderBox child3 = RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(const Size(100.0, 100.0)) ); - final RenderBox stack = new RenderIndexedStack( + final RenderBox stack = RenderIndexedStack( index: 1, textDirection: TextDirection.ltr, children: [child1, child2, child3], diff --git a/packages/flutter/test/rendering/table_border_test.dart b/packages/flutter/test/rendering/table_border_test.dart index bc35e075c2..1062b6048d 100644 --- a/packages/flutter/test/rendering/table_border_test.dart +++ b/packages/flutter/test/rendering/table_border_test.dart @@ -28,7 +28,7 @@ void main() { }); test('TableBorder.all constructor', () { - final TableBorder border2 = new TableBorder.all( + final TableBorder border2 = TableBorder.all( width: 2.0, color: const Color(0xFF00FFFF), ); @@ -40,11 +40,11 @@ void main() { expect(border2.verticalInside, const BorderSide(width: 2.0, color: Color(0xFF00FFFF))); expect(border2.dimensions, const EdgeInsets.symmetric(horizontal: 2.0, vertical: 2.0)); expect(border2.isUniform, isTrue); - expect(border2.scale(0.5), new TableBorder.all(color: const Color(0xFF00FFFF))); + expect(border2.scale(0.5), TableBorder.all(color: const Color(0xFF00FFFF))); }); test('TableBorder.symmetric constructor', () { - final TableBorder border3 = new TableBorder.symmetric( + final TableBorder border3 = TableBorder.symmetric( inside: const BorderSide(width: 3.0), outside: const BorderSide(color: Color(0xFFFF0000)), ); @@ -56,7 +56,7 @@ void main() { expect(border3.verticalInside, const BorderSide(width: 3.0)); expect(border3.dimensions, const EdgeInsets.symmetric(horizontal: 1.0, vertical: 1.0)); expect(border3.isUniform, isFalse); - expect(border3.scale(0.0), new TableBorder.symmetric( + expect(border3.scale(0.0), TableBorder.symmetric( inside: const BorderSide(width: 0.0, style: BorderStyle.none), outside: const BorderSide(width: 0.0, color: Color(0xFFFF0000), style: BorderStyle.none), )); @@ -79,7 +79,7 @@ void main() { ); expect(tableA.isUniform, isFalse); expect(tableA.dimensions, const EdgeInsets.fromLTRB(4.0, 1.0, 2.0, 3.0)); - final TableBorder tableB = new TableBorder( + final TableBorder tableB = TableBorder( top: side1.scale(2.0), right: side2.scale(2.0), bottom: side3.scale(2.0), @@ -89,7 +89,7 @@ void main() { ); expect(tableB.isUniform, isFalse); expect(tableB.dimensions, const EdgeInsets.fromLTRB(4.0, 1.0, 2.0, 3.0) * 2.0); - final TableBorder tableC = new TableBorder( + final TableBorder tableC = TableBorder( top: side1.scale(3.0), right: side2.scale(3.0), bottom: side3.scale(3.0), @@ -108,8 +108,8 @@ void main() { }); test('TableBorder.lerp with nulls', () { - final TableBorder table2 = new TableBorder.all(width: 2.0); - final TableBorder table1 = new TableBorder.all(width: 1.0); + final TableBorder table2 = TableBorder.all(width: 2.0); + final TableBorder table1 = TableBorder.all(width: 1.0); expect(TableBorder.lerp(table2, null, 0.5), table1); expect(TableBorder.lerp(null, table2, 0.5), table1); expect(TableBorder.lerp(null, null, 0.5), null); diff --git a/packages/flutter/test/rendering/table_test.dart b/packages/flutter/test/rendering/table_test.dart index 4681912c6a..e8708da8fb 100644 --- a/packages/flutter/test/rendering/table_test.dart +++ b/packages/flutter/test/rendering/table_test.dart @@ -9,15 +9,15 @@ import 'mock_canvas.dart'; import 'rendering_tester.dart'; RenderBox sizedBox(double width, double height) { - return new RenderConstrainedBox( - additionalConstraints: new BoxConstraints.tight(new Size(width, height)) + return RenderConstrainedBox( + additionalConstraints: BoxConstraints.tight(Size(width, height)) ); } void main() { test('Table control test; tight', () { RenderTable table; - layout(table = new RenderTable(textDirection: TextDirection.ltr)); + layout(table = RenderTable(textDirection: TextDirection.ltr)); expect(table.size.width, equals(800.0)); expect(table.size.height, equals(600.0)); @@ -42,14 +42,14 @@ void main() { test('Table control test; loose', () { RenderTable table; - layout(new RenderPositionedBox(child: table = new RenderTable(textDirection: TextDirection.ltr))); + layout(RenderPositionedBox(child: table = RenderTable(textDirection: TextDirection.ltr))); expect(table.size, equals(const Size(0.0, 0.0))); }); test('Table test: combinations', () { RenderTable table; - layout(new RenderPositionedBox(child: table = new RenderTable( + layout(RenderPositionedBox(child: table = RenderTable( columns: 5, rows: 5, defaultColumnWidth: const IntrinsicColumnWidth(), @@ -143,7 +143,7 @@ void main() { test('Table test: removing cells', () { RenderTable table; RenderBox child; - table = new RenderTable( + table = RenderTable( columns: 5, rows: 5, textDirection: TextDirection.ltr, @@ -159,48 +159,48 @@ void main() { test('Table test: replacing cells', () { RenderTable table; - final RenderBox child1 = new RenderPositionedBox(); - final RenderBox child2 = new RenderPositionedBox(); - final RenderBox child3 = new RenderPositionedBox(); - table = new RenderTable(textDirection: TextDirection.ltr); - table.setFlatChildren(3, [child1, new RenderPositionedBox(), child2, - new RenderPositionedBox(), child3, new RenderPositionedBox()]); + final RenderBox child1 = RenderPositionedBox(); + final RenderBox child2 = RenderPositionedBox(); + final RenderBox child3 = RenderPositionedBox(); + table = RenderTable(textDirection: TextDirection.ltr); + table.setFlatChildren(3, [child1, RenderPositionedBox(), child2, + RenderPositionedBox(), child3, RenderPositionedBox()]); expect(table.rows, equals(2)); layout(table); - table.setFlatChildren(3, [new RenderPositionedBox(), child1, new RenderPositionedBox(), - child2, new RenderPositionedBox(), child3]); + table.setFlatChildren(3, [RenderPositionedBox(), child1, RenderPositionedBox(), + child2, RenderPositionedBox(), child3]); pumpFrame(); - table.setFlatChildren(3, [new RenderPositionedBox(), child1, new RenderPositionedBox(), - child2, new RenderPositionedBox(), child3]); + table.setFlatChildren(3, [RenderPositionedBox(), child1, RenderPositionedBox(), + child2, RenderPositionedBox(), child3]); pumpFrame(); expect(table.columns, equals(3)); expect(table.rows, equals(2)); }); test('Table border painting', () { - final RenderTable table = new RenderTable( + final RenderTable table = RenderTable( textDirection: TextDirection.rtl, - border: new TableBorder.all(), + border: TableBorder.all(), ); layout(table); table.setFlatChildren(1, [ ]); pumpFrame(); expect(table, paints..path()..path()..path()..path()); - table.setFlatChildren(1, [ new RenderPositionedBox() ]); + table.setFlatChildren(1, [ RenderPositionedBox() ]); pumpFrame(); expect(table, paints..path()..path()..path()..path()); - table.setFlatChildren(1, [ new RenderPositionedBox(), new RenderPositionedBox() ]); + table.setFlatChildren(1, [ RenderPositionedBox(), RenderPositionedBox() ]); pumpFrame(); expect(table, paints..path()..path()..path()..path()..path()); - table.setFlatChildren(2, [ new RenderPositionedBox(), new RenderPositionedBox() ]); + table.setFlatChildren(2, [ RenderPositionedBox(), RenderPositionedBox() ]); pumpFrame(); expect(table, paints..path()..path()..path()..path()..path()); - table.setFlatChildren(2, [ new RenderPositionedBox(), new RenderPositionedBox(), - new RenderPositionedBox(), new RenderPositionedBox() ]); + table.setFlatChildren(2, [ RenderPositionedBox(), RenderPositionedBox(), + RenderPositionedBox(), RenderPositionedBox() ]); pumpFrame(); expect(table, paints..path()..path()..path()..path()..path()..path()); - table.setFlatChildren(3, [ new RenderPositionedBox(), new RenderPositionedBox(), new RenderPositionedBox(), - new RenderPositionedBox(), new RenderPositionedBox(), new RenderPositionedBox() ]); + table.setFlatChildren(3, [ RenderPositionedBox(), RenderPositionedBox(), RenderPositionedBox(), + RenderPositionedBox(), RenderPositionedBox(), RenderPositionedBox() ]); pumpFrame(); expect(table, paints..path()..path()..path()..path()..path()..path()); }); diff --git a/packages/flutter/test/rendering/transform_test.dart b/packages/flutter/test/rendering/transform_test.dart index 8b10bed50a..4ee5f53433 100644 --- a/packages/flutter/test/rendering/transform_test.dart +++ b/packages/flutter/test/rendering/transform_test.dart @@ -10,18 +10,18 @@ import '../flutter_test_alternative.dart'; import 'rendering_tester.dart'; Offset round(Offset value) { - return new Offset(value.dx.roundToDouble(), value.dy.roundToDouble()); + return Offset(value.dx.roundToDouble(), value.dy.roundToDouble()); } void main() { test('RenderTransform - identity', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( - transform: new Matrix4.identity(), + final RenderBox sizer = RenderTransform( + transform: Matrix4.identity(), alignment: Alignment.center, - child: inner = new RenderSizedBox(const Size(100.0, 100.0)), + child: inner = RenderSizedBox(const Size(100.0, 100.0)), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(0.0, 0.0))); expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(100.0, 100.0))); expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(25.0, 75.0))); @@ -34,15 +34,15 @@ void main() { test('RenderTransform - identity with internal offset', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( - transform: new Matrix4.identity(), + final RenderBox sizer = RenderTransform( + transform: Matrix4.identity(), alignment: Alignment.center, - child: new RenderPadding( + child: RenderPadding( padding: const EdgeInsets.only(left: 20.0), - child: inner = new RenderSizedBox(const Size(80.0, 100.0)), + child: inner = RenderSizedBox(const Size(80.0, 100.0)), ), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(-20.0, 0.0))); expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(80.0, 100.0))); expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(5.0, 75.0))); @@ -55,12 +55,12 @@ void main() { test('RenderTransform - translation', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( - transform: new Matrix4.translationValues(50.0, 200.0, 0.0), + final RenderBox sizer = RenderTransform( + transform: Matrix4.translationValues(50.0, 200.0, 0.0), alignment: Alignment.center, - child: inner = new RenderSizedBox(const Size(100.0, 100.0)), + child: inner = RenderSizedBox(const Size(100.0, 100.0)), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(-50.0, -200.0))); expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(50.0, -100.0))); expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(-25.0, -125.0))); @@ -73,15 +73,15 @@ void main() { test('RenderTransform - translation with internal offset', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( - transform: new Matrix4.translationValues(50.0, 200.0, 0.0), + final RenderBox sizer = RenderTransform( + transform: Matrix4.translationValues(50.0, 200.0, 0.0), alignment: Alignment.center, - child: new RenderPadding( + child: RenderPadding( padding: const EdgeInsets.only(left: 20.0), - child: inner = new RenderSizedBox(const Size(80.0, 100.0)), + child: inner = RenderSizedBox(const Size(80.0, 100.0)), ), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(inner.globalToLocal(const Offset(0.0, 0.0)), equals(const Offset(-70.0, -200.0))); expect(inner.globalToLocal(const Offset(100.0, 100.0)), equals(const Offset(30.0, -100.0))); expect(inner.globalToLocal(const Offset(25.0, 75.0)), equals(const Offset(-45.0, -125.0))); @@ -94,12 +94,12 @@ void main() { test('RenderTransform - rotation', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( - transform: new Matrix4.rotationZ(math.pi), + final RenderBox sizer = RenderTransform( + transform: Matrix4.rotationZ(math.pi), alignment: Alignment.center, - child: inner = new RenderSizedBox(const Size(100.0, 100.0)), + child: inner = RenderSizedBox(const Size(100.0, 100.0)), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(round(inner.globalToLocal(const Offset(0.0, 0.0))), equals(const Offset(100.0, 100.0))); expect(round(inner.globalToLocal(const Offset(100.0, 100.0))), equals(const Offset(0.0, 0.0))); expect(round(inner.globalToLocal(const Offset(25.0, 75.0))), equals(const Offset(75.0, 25.0))); @@ -112,15 +112,15 @@ void main() { test('RenderTransform - rotation with internal offset', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( - transform: new Matrix4.rotationZ(math.pi), + final RenderBox sizer = RenderTransform( + transform: Matrix4.rotationZ(math.pi), alignment: Alignment.center, - child: new RenderPadding( + child: RenderPadding( padding: const EdgeInsets.only(left: 20.0), - child: inner = new RenderSizedBox(const Size(80.0, 100.0)), + child: inner = RenderSizedBox(const Size(80.0, 100.0)), ), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(round(inner.globalToLocal(const Offset(0.0, 0.0))), equals(const Offset(80.0, 100.0))); expect(round(inner.globalToLocal(const Offset(100.0, 100.0))), equals(const Offset(-20.0, 0.0))); expect(round(inner.globalToLocal(const Offset(25.0, 75.0))), equals(const Offset(55.0, 25.0))); @@ -133,12 +133,12 @@ void main() { test('RenderTransform - perspective - globalToLocal', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( + final RenderBox sizer = RenderTransform( transform: rotateAroundXAxis(math.pi * 0.25), // at pi/4, we are about 70 pixels high alignment: Alignment.center, - child: inner = new RenderSizedBox(const Size(100.0, 100.0)), + child: inner = RenderSizedBox(const Size(100.0, 100.0)), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); expect(round(inner.globalToLocal(const Offset(25.0, 50.0))), equals(const Offset(25.0, 50.0))); expect(inner.globalToLocal(const Offset(25.0, 17.0)).dy, greaterThan(0.0)); @@ -150,12 +150,12 @@ void main() { test('RenderTransform - perspective - localToGlobal', () { RenderBox inner; - final RenderBox sizer = new RenderTransform( + final RenderBox sizer = RenderTransform( transform: rotateAroundXAxis(math.pi * 0.4999), // at pi/2, we're seeing the box on its edge, alignment: Alignment.center, - child: inner = new RenderSizedBox(const Size(100.0, 100.0)), + child: inner = RenderSizedBox(const Size(100.0, 100.0)), ); - layout(sizer, constraints: new BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); + layout(sizer, constraints: BoxConstraints.tight(const Size(100.0, 100.0)), alignment: Alignment.topLeft); // the inner widget has a height of about half a pixel at this rotation, so // everything should end up around the middle of the outer box. @@ -172,7 +172,7 @@ Matrix4 rotateAroundXAxis(double a) { const double z = 0.0; final double sc = math.sin(a / 2.0) * math.cos(a / 2.0); final double sq = math.sin(a / 2.0) * math.sin(a / 2.0); - return new Matrix4.fromList([ + return Matrix4.fromList([ // col 1 1.0 - 2.0 * (y * y + z * z) * sq, 2.0 * (x * y * sq + z * sc), diff --git a/packages/flutter/test/rendering/view_test.dart b/packages/flutter/test/rendering/view_test.dart index 7da7bad3c9..330c8884f0 100644 --- a/packages/flutter/test/rendering/view_test.dart +++ b/packages/flutter/test/rendering/view_test.dart @@ -10,7 +10,7 @@ import 'rendering_tester.dart'; void main() { group('RenderView', () { test('accounts for device pixel ratio in paintBounds', () { - layout(new RenderAspectRatio(aspectRatio: 1.0)); + layout(RenderAspectRatio(aspectRatio: 1.0)); pumpFrame(); final Size logicalSize = renderer.renderView.configuration.size; final double devicePixelRatio = renderer.renderView.configuration.devicePixelRatio; diff --git a/packages/flutter/test/rendering/viewport_test.dart b/packages/flutter/test/rendering/viewport_test.dart index a2dfa7c79c..c97bbe8d57 100644 --- a/packages/flutter/test/rendering/viewport_test.dart +++ b/packages/flutter/test/rendering/viewport_test.dart @@ -12,19 +12,19 @@ void main() { testWidgets('Viewport getOffsetToReveal - down', (WidgetTester tester) async { List children; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 300.0, - child: new ListView( - controller: new ScrollController(initialScrollOffset: 300.0), - children: children = new List.generate(20, (int i) { - return new Container( + child: ListView( + controller: ScrollController(initialScrollOffset: 300.0), + children: children = List.generate(20, (int i) { + return Container( height: 100.0, width: 300.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -38,39 +38,39 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5], skipOffstage: false)); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 540.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 350.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); }); testWidgets('Viewport getOffsetToReveal - right', (WidgetTester tester) async { List children; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 300.0, width: 200.0, - child: new ListView( + child: ListView( scrollDirection: Axis.horizontal, - controller: new ScrollController(initialScrollOffset: 300.0), - children: children = new List.generate(20, (int i) { - return new Container( + controller: ScrollController(initialScrollOffset: 300.0), + children: children = List.generate(20, (int i) { + return Container( height: 300.0, width: 100.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -84,39 +84,39 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5], skipOffstage: false)); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 540.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 350.0); - expect(revealed.rect, new Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); }); testWidgets('Viewport getOffsetToReveal - up', (WidgetTester tester) async { List children; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 300.0, - child: new ListView( - controller: new ScrollController(initialScrollOffset: 300.0), + child: ListView( + controller: ScrollController(initialScrollOffset: 300.0), reverse: true, - children: children = new List.generate(20, (int i) { - return new Container( + children: children = List.generate(20, (int i) { + return Container( height: 100.0, width: 300.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -130,40 +130,40 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5], skipOffstage: false)); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 550.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 360.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); }); testWidgets('Viewport getOffsetToReveal - left', (WidgetTester tester) async { List children; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 300.0, width: 200.0, - child: new ListView( + child: ListView( scrollDirection: Axis.horizontal, reverse: true, - controller: new ScrollController(initialScrollOffset: 300.0), - children: children = new List.generate(20, (int i) { - return new Container( + controller: ScrollController(initialScrollOffset: 300.0), + children: children = List.generate(20, (int i) { + return Container( height: 300.0, width: 100.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -177,25 +177,25 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5], skipOffstage: false)); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 550.0); - expect(revealed.rect, new Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 360.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); }); testWidgets('Nested Viewports showOnScreen', (WidgetTester tester) async { - final List> children = new List>(10); - final List controllersX = new List.generate(10, (int i) => new ScrollController(initialScrollOffset: 400.0)); - final ScrollController controllerY = new ScrollController(initialScrollOffset: 400.0); + final List> children = List>(10); + final List controllersX = List.generate(10, (int i) => ScrollController(initialScrollOffset: 400.0)); + final ScrollController controllerY = ScrollController(initialScrollOffset: 400.0); /// Builds a gird: /// @@ -216,25 +216,25 @@ void main() { /// viewport. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 200.0, - child: new ListView( + child: ListView( controller: controllerY, - children: new List.generate(10, (int y) { + children: List.generate(10, (int y) { return Container( height: 100.0, - child: new ListView( + child: ListView( scrollDirection: Axis.horizontal, controller: controllersX[y], - children: children[y] = new List.generate(10, (int x) { - return new Container( + children: children[y] = List.generate(10, (int x) { + return Container( height: 100.0, width: 100.0, - child: new Text('$x,$y'), + child: Text('$x,$y'), ); }), ), @@ -355,33 +355,33 @@ void main() { Future buildNestedScroller({WidgetTester tester, ScrollController inner, ScrollController outer}) { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 300.0, - child: new ListView( + child: ListView( controller: outer, children: [ - new Container( + Container( height: 200.0, ), - new Container( + Container( height: 200.0, width: 300.0, - child: new ListView( + child: ListView( controller: inner, - children: children = new List.generate(10, (int i) { - return new Container( + children: children = List.generate(10, (int i) { + return Container( height: 100.0, width: 300.0, - child: new Text('$i'), + child: Text('$i'), ); }), ), ), - new Container( + Container( height: 200.0, ) ], @@ -393,8 +393,8 @@ void main() { } testWidgets('in view in inner, but not in outer', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(); - final ScrollController outer = new ScrollController(); + final ScrollController inner = ScrollController(); + final ScrollController outer = ScrollController(); await buildNestedScroller( tester: tester, inner: inner, @@ -410,8 +410,8 @@ void main() { }); testWidgets('not in view of neither inner nor outer', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(); - final ScrollController outer = new ScrollController(); + final ScrollController inner = ScrollController(); + final ScrollController outer = ScrollController(); await buildNestedScroller( tester: tester, inner: inner, @@ -427,8 +427,8 @@ void main() { }); testWidgets('in view in inner and outer', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(initialScrollOffset: 200.0); - final ScrollController outer = new ScrollController(initialScrollOffset: 200.0); + final ScrollController inner = ScrollController(initialScrollOffset: 200.0); + final ScrollController outer = ScrollController(initialScrollOffset: 200.0); await buildNestedScroller( tester: tester, inner: inner, @@ -444,8 +444,8 @@ void main() { }); testWidgets('inner shown in outer, but item not visible', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(initialScrollOffset: 200.0); - final ScrollController outer = new ScrollController(initialScrollOffset: 200.0); + final ScrollController inner = ScrollController(initialScrollOffset: 200.0); + final ScrollController outer = ScrollController(initialScrollOffset: 200.0); await buildNestedScroller( tester: tester, inner: inner, @@ -461,8 +461,8 @@ void main() { }); testWidgets('inner half shown in outer, item only visible in inner', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(); - final ScrollController outer = new ScrollController(initialScrollOffset: 100.0); + final ScrollController inner = ScrollController(); + final ScrollController outer = ScrollController(initialScrollOffset: 100.0); await buildNestedScroller( tester: tester, inner: inner, @@ -483,17 +483,17 @@ void main() { ScrollController controller; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, - child: new ListView( - controller: controller = new ScrollController(initialScrollOffset: 300.0), - children: children = new List.generate(20, (int i) { - return new Container( + child: ListView( + controller: controller = ScrollController(initialScrollOffset: 300.0), + children: children = List.generate(20, (int i) { + return Container( height: 300.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), diff --git a/packages/flutter/test/rendering/wrap_test.dart b/packages/flutter/test/rendering/wrap_test.dart index 6aa1c2f9af..9d8c618a69 100644 --- a/packages/flutter/test/rendering/wrap_test.dart +++ b/packages/flutter/test/rendering/wrap_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('Wrap test; toStringDeep', () { - final RenderWrap renderWrap = new RenderWrap(); + final RenderWrap renderWrap = RenderWrap(); expect(renderWrap, hasAGoodToStringDeep); expect( renderWrap.toStringDeep(minLevel: DiagnosticLevel.info), diff --git a/packages/flutter/test/scheduler/animation_test.dart b/packages/flutter/test/scheduler/animation_test.dart index da766b0df8..418a807a30 100644 --- a/packages/flutter/test/scheduler/animation_test.dart +++ b/packages/flutter/test/scheduler/animation_test.dart @@ -13,7 +13,7 @@ import 'scheduler_tester.dart'; class TestSchedulerBinding extends BindingBase with ServicesBinding, SchedulerBinding { } void main() { - final SchedulerBinding scheduler = new TestSchedulerBinding(); + final SchedulerBinding scheduler = TestSchedulerBinding(); test('Check for a time dilation being in effect', () { expect(timeDilation, equals(1.0)); diff --git a/packages/flutter/test/scheduler/scheduler_test.dart b/packages/flutter/test/scheduler/scheduler_test.dart index 87f37ef004..60c5178191 100644 --- a/packages/flutter/test/scheduler/scheduler_test.dart +++ b/packages/flutter/test/scheduler/scheduler_test.dart @@ -22,11 +22,11 @@ class TestStrategy { void main() { SchedulerBinding scheduler; setUpAll(() { - scheduler = new TestSchedulerBinding(); + scheduler = TestSchedulerBinding(); }); test('Tasks are executed in the right order', () { - final TestStrategy strategy = new TestStrategy(); + final TestStrategy strategy = TestStrategy(); scheduler.schedulingStrategy = strategy.shouldRunTaskWithPriority; final List input = [2, 23, 23, 11, 0, 80, 3]; final List executedTasks = []; @@ -101,7 +101,7 @@ void main() { scheduler.scheduleWarmUpFrame(); scheduler.scheduleTask(() { taskExecuted = true; }, Priority.touch); }, - zoneSpecification: new ZoneSpecification( + zoneSpecification: ZoneSpecification( createTimer: (Zone self, ZoneDelegate parent, Zone zone, Duration duration, void f()) { // Don't actually run the tasks, just record that it was scheduled. timerQueueTasks.add(f); diff --git a/packages/flutter/test/scheduler/ticker_test.dart b/packages/flutter/test/scheduler/ticker_test.dart index 272753efc5..2d141da994 100644 --- a/packages/flutter/test/scheduler/ticker_test.dart +++ b/packages/flutter/test/scheduler/ticker_test.dart @@ -13,7 +13,7 @@ void main() { tickCount += 1; } - final Ticker ticker = new Ticker(handleTick); + final Ticker ticker = Ticker(handleTick); expect(ticker.isTicking, isFalse); expect(ticker.isActive, isFalse); @@ -74,7 +74,7 @@ void main() { Ticker ticker; void testFunction() { - ticker = new Ticker(null); + ticker = Ticker(null); } testFunction(); @@ -90,7 +90,7 @@ void main() { lastDuration = duration; } - final Ticker ticker = new Ticker(handleTick); + final Ticker ticker = Ticker(handleTick); ticker.start(); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); @@ -106,7 +106,7 @@ void main() { lastDuration = duration; } - final Ticker ticker = new Ticker(handleTick); + final Ticker ticker = Ticker(handleTick); ticker.start(); await tester.pump(const Duration(milliseconds: 10)); await tester.pump(const Duration(milliseconds: 10)); @@ -121,7 +121,7 @@ void main() { tickCount += 1; } - final Ticker ticker = new Ticker(handleTick); + final Ticker ticker = Ticker(handleTick); ticker.start(); expect(ticker.isTicking, isTrue); @@ -145,7 +145,7 @@ void main() { tickCount += 1; } - final Ticker ticker = new Ticker(handleTick); + final Ticker ticker = Ticker(handleTick); ticker.start(); expect(tickCount, equals(0)); diff --git a/packages/flutter/test/semantics/custom_semantics_action_test.dart b/packages/flutter/test/semantics/custom_semantics_action_test.dart index 06f6ea9279..9a779fe816 100644 --- a/packages/flutter/test/semantics/custom_semantics_action_test.dart +++ b/packages/flutter/test/semantics/custom_semantics_action_test.dart @@ -10,9 +10,9 @@ void main() { group(CustomSemanticsAction, () { test('is provided a canonical id based on the label', () { - final CustomSemanticsAction action1 = new CustomSemanticsAction(label: _nonconst('test')); - final CustomSemanticsAction action2 = new CustomSemanticsAction(label: _nonconst('test')); - final CustomSemanticsAction action3 = new CustomSemanticsAction(label: _nonconst('not test')); + final CustomSemanticsAction action1 = CustomSemanticsAction(label: _nonconst('test')); + final CustomSemanticsAction action2 = CustomSemanticsAction(label: _nonconst('test')); + final CustomSemanticsAction action3 = CustomSemanticsAction(label: _nonconst('not test')); final int id1 = CustomSemanticsAction.getIdentifier(action1); final int id2 = CustomSemanticsAction.getIdentifier(action2); final int id3 = CustomSemanticsAction.getIdentifier(action3); diff --git a/packages/flutter/test/semantics/semantics_test.dart b/packages/flutter/test/semantics/semantics_test.dart index 9ef64e83c2..8749185bca 100644 --- a/packages/flutter/test/semantics/semantics_test.dart +++ b/packages/flutter/test/semantics/semantics_test.dart @@ -21,12 +21,12 @@ void main() { const SemanticsTag tag3 = SemanticsTag('Tag Three'); test('tagging', () { - final SemanticsNode node = new SemanticsNode(); + final SemanticsNode node = SemanticsNode(); expect(node.isTagged(tag1), isFalse); expect(node.isTagged(tag2), isFalse); - node.tags = new Set()..add(tag1); + node.tags = Set()..add(tag1); expect(node.isTagged(tag1), isTrue); expect(node.isTagged(tag2), isFalse); @@ -36,28 +36,28 @@ void main() { }); test('getSemanticsData includes tags', () { - final Set tags = new Set() + final Set tags = Set() ..add(tag1) ..add(tag2); - final SemanticsNode node = new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) + final SemanticsNode node = SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) ..tags = tags; expect(node.getSemanticsData().tags, tags); tags.add(tag3); - final SemanticsConfiguration config = new SemanticsConfiguration() + final SemanticsConfiguration config = SemanticsConfiguration() ..isSemanticBoundary = true ..isMergingSemanticsOfDescendants = true; node.updateWith( config: config, childrenInInversePaintOrder: [ - new SemanticsNode() + SemanticsNode() ..isMergedIntoParent = true - ..rect = new Rect.fromLTRB(5.0, 5.0, 10.0, 10.0) + ..rect = Rect.fromLTRB(5.0, 5.0, 10.0, 10.0) ..tags = tags, ], ); @@ -69,19 +69,19 @@ void main() { renderer.pipelineOwner.ensureSemantics(); TestRender middle; - final TestRender root = new TestRender( + final TestRender root = TestRender( hasTapAction: true, isSemanticBoundary: true, - child: new TestRender( + child: TestRender( hasLongPressAction: true, isSemanticBoundary: false, - child: middle = new TestRender( + child: middle = TestRender( hasScrollLeftAction: true, isSemanticBoundary: false, - child: new TestRender( + child: TestRender( hasScrollRightAction: true, isSemanticBoundary: false, - child: new TestRender( + child: TestRender( hasScrollUpAction: true, isSemanticBoundary: true, ) @@ -109,12 +109,12 @@ void main() { }); test('toStringDeep() does not throw with transform == null', () { - final SemanticsNode child1 = new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 5.0, 5.0); - final SemanticsNode child2 = new SemanticsNode() - ..rect = new Rect.fromLTRB(5.0, 0.0, 10.0, 5.0); - final SemanticsNode root = new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 10.0, 5.0); + final SemanticsNode child1 = SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 5.0, 5.0); + final SemanticsNode child2 = SemanticsNode() + ..rect = Rect.fromLTRB(5.0, 0.0, 10.0, 5.0); + final SemanticsNode root = SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 10.0, 5.0); root.updateWith( config: null, childrenInInversePaintOrder: [child1, child2], @@ -188,12 +188,12 @@ void main() { }); test('toStringDeep respects childOrder parameter', () { - final SemanticsNode child1 = new SemanticsNode() - ..rect = new Rect.fromLTRB(15.0, 0.0, 20.0, 5.0); - final SemanticsNode child2 = new SemanticsNode() - ..rect = new Rect.fromLTRB(10.0, 0.0, 15.0, 5.0); - final SemanticsNode root = new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 20.0, 5.0); + final SemanticsNode child1 = SemanticsNode() + ..rect = Rect.fromLTRB(15.0, 0.0, 20.0, 5.0); + final SemanticsNode child2 = SemanticsNode() + ..rect = Rect.fromLTRB(10.0, 0.0, 15.0, 5.0); + final SemanticsNode root = SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 20.0, 5.0); root.updateWith( config: null, childrenInInversePaintOrder: [child1, child2], @@ -234,20 +234,20 @@ void main() { ' Rect.fromLTRB(10.0, 0.0, 15.0, 5.0)\n' ); - final SemanticsNode child3 = new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 10.0, 5.0); + final SemanticsNode child3 = SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 10.0, 5.0); child3.updateWith( config: null, childrenInInversePaintOrder: [ - new SemanticsNode() - ..rect = new Rect.fromLTRB(5.0, 0.0, 10.0, 5.0), - new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 5.0, 5.0), + SemanticsNode() + ..rect = Rect.fromLTRB(5.0, 0.0, 10.0, 5.0), + SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 5.0, 5.0), ], ); - final SemanticsNode rootComplex = new SemanticsNode() - ..rect = new Rect.fromLTRB(0.0, 0.0, 25.0, 5.0); + final SemanticsNode rootComplex = SemanticsNode() + ..rect = Rect.fromLTRB(0.0, 0.0, 25.0, 5.0); rootComplex.updateWith( config: null, childrenInInversePaintOrder: [child1, child2, child3] @@ -321,7 +321,7 @@ void main() { }); test('debug properties', () { - final SemanticsNode minimalProperties = new SemanticsNode(); + final SemanticsNode minimalProperties = SemanticsNode(); expect( minimalProperties.toStringDeep(), 'SemanticsNode#1\n' @@ -353,7 +353,7 @@ void main() { ' scrollExtentMax: null\n' ); - final SemanticsConfiguration config = new SemanticsConfiguration() + final SemanticsConfiguration config = SemanticsConfiguration() ..isSemanticBoundary = true ..isMergingSemanticsOfDescendants = true ..onScrollUp = () { } @@ -365,9 +365,9 @@ void main() { ..label = 'Use all the properties' ..textDirection = TextDirection.rtl ..sortKey = const OrdinalSortKey(1.0); - final SemanticsNode allProperties = new SemanticsNode() - ..rect = new Rect.fromLTWH(50.0, 10.0, 20.0, 30.0) - ..transform = new Matrix4.translation(new Vector3(10.0, 10.0, 0.0)) + final SemanticsNode allProperties = SemanticsNode() + ..rect = Rect.fromLTWH(50.0, 10.0, 20.0, 30.0) + ..transform = Matrix4.translation(Vector3(10.0, 10.0, 0.0)) ..updateWith(config: config, childrenInInversePaintOrder: null); expect( allProperties.toStringDeep(), @@ -389,9 +389,9 @@ void main() { 'SemanticsData(Rect.fromLTRB(50.0, 10.0, 70.0, 40.0), [1.0,0.0,0.0,10.0; 0.0,1.0,0.0,10.0; 0.0,0.0,1.0,0.0; 0.0,0.0,0.0,1.0], actions: [longPress, scrollUp, showOnScreen], flags: [hasCheckedState, isSelected, isButton], label: "Use all the properties", textDirection: rtl)', ); - final SemanticsNode scaled = new SemanticsNode() - ..rect = new Rect.fromLTWH(50.0, 10.0, 20.0, 30.0) - ..transform = new Matrix4.diagonal3(new Vector3(10.0, 10.0, 1.0)); + final SemanticsNode scaled = SemanticsNode() + ..rect = Rect.fromLTWH(50.0, 10.0, 20.0, 30.0) + ..transform = Matrix4.diagonal3(Vector3(10.0, 10.0, 1.0)); expect( scaled.toStringDeep(), 'SemanticsNode#3\n' @@ -406,7 +406,7 @@ void main() { }); test('Custom actions debug properties', () { - final SemanticsConfiguration configuration = new SemanticsConfiguration(); + final SemanticsConfiguration configuration = SemanticsConfiguration(); const CustomSemanticsAction action1 = CustomSemanticsAction(label: 'action1'); const CustomSemanticsAction action2 = CustomSemanticsAction(label: 'action2'); const CustomSemanticsAction action3 = CustomSemanticsAction(label: 'action3'); @@ -415,7 +415,7 @@ void main() { action2: () {}, action3: () {}, }; - final SemanticsNode actionNode = new SemanticsNode(); + final SemanticsNode actionNode = SemanticsNode(); actionNode.updateWith(config: configuration); expect( @@ -446,7 +446,7 @@ void main() { }); test('SemanticsConfiguration getter/setter', () { - final SemanticsConfiguration config = new SemanticsConfiguration(); + final SemanticsConfiguration config = SemanticsConfiguration(); const CustomSemanticsAction customAction = CustomSemanticsAction(label: 'test'); expect(config.isSemanticBoundary, isFalse); diff --git a/packages/flutter/test/semantics/traversal_order_test.dart b/packages/flutter/test/semantics/traversal_order_test.dart index 7e2afd78b0..18712d5dd0 100644 --- a/packages/flutter/test/semantics/traversal_order_test.dart +++ b/packages/flutter/test/semantics/traversal_order_test.dart @@ -10,17 +10,17 @@ import '../widgets/semantics_tester.dart'; void main() { testWidgets('Traversal order handles touching elements', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MaterialApp( - home: new Column( - children: new List.generate(3, (int column) { - return new Row(children: List.generate(3, (int row) { - return new Semantics( - child: new SizedBox( + MaterialApp( + home: Column( + children: List.generate(3, (int column) { + return Row(children: List.generate(3, (int row) { + return Semantics( + child: SizedBox( width: 50.0, height: 50.0, - child: new Text('$column - $row'), + child: Text('$column - $row'), ), ); })); @@ -28,57 +28,57 @@ void main() { ), )); - final TestSemantics expected = new TestSemantics.root( + final TestSemantics expected = TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( id: 3, label: '0 - 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 4, label: '0 - 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, label: '0 - 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, label: '1 - 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 7, label: '1 - 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 8, label: '1 - 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 9, label: '2 - 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 10, label: '2 - 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 11, label: '2 - 2', textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/services/asset_bundle_test.dart b/packages/flutter/test/services/asset_bundle_test.dart index 9be659004e..a11163a680 100644 --- a/packages/flutter/test/services/asset_bundle_test.dart +++ b/packages/flutter/test/services/asset_bundle_test.dart @@ -17,18 +17,18 @@ class TestAssetBundle extends CachingAssetBundle { @override Future load(String key) async { if (key == 'AssetManifest.json') - return new ByteData.view(new Uint8List.fromList(const Utf8Encoder().convert('{"one": ["one"]}')).buffer); + return ByteData.view(Uint8List.fromList(const Utf8Encoder().convert('{"one": ["one"]}')).buffer); loadCallCount[key] = loadCallCount[key] ?? 0 + 1; if (key == 'one') - return new ByteData(1)..setInt8(0, 49); - throw new FlutterError('key not found'); + return ByteData(1)..setInt8(0, 49); + throw FlutterError('key not found'); } } void main() { test('Caching asset bundle test', () async { - final TestAssetBundle bundle = new TestAssetBundle(); + final TestAssetBundle bundle = TestAssetBundle(); final ByteData assetData = await bundle.load('one'); expect(assetData.getInt8(0), equals(49)); @@ -51,7 +51,7 @@ void main() { test('AssetImage.obtainKey succeeds with ImageConfiguration.empty', () async { // This is a regression test for https://github.com/flutter/flutter/issues/12392 - final AssetImage assetImage = new AssetImage('one', bundle: new TestAssetBundle()); + final AssetImage assetImage = AssetImage('one', bundle: TestAssetBundle()); final AssetBundleImageKey key = await assetImage.obtainKey(ImageConfiguration.empty); expect(key.name, 'one'); expect(key.scale, 1.0); diff --git a/packages/flutter/test/services/fake_platform_views.dart b/packages/flutter/test/services/fake_platform_views.dart index ad50c3247c..a53229596d 100644 --- a/packages/flutter/test/services/fake_platform_views.dart +++ b/packages/flutter/test/services/fake_platform_views.dart @@ -22,7 +22,7 @@ class FakePlatformViewsController { final Map> motionEvents = >{}; - final Set _registeredViewTypes = new Set(); + final Set _registeredViewTypes = Set(); int _textureCounter = 0; @@ -35,7 +35,7 @@ class FakePlatformViewsController { Future _onMethodCall(MethodCall call) { if (targetPlatform == TargetPlatform.android) return _onMethodCallAndroid(call); - return new Future.sync(() => null); + return Future.sync(() => null); } Future _onMethodCallAndroid(MethodCall call) { @@ -51,7 +51,7 @@ class FakePlatformViewsController { case 'setDirection': return _setDirection(call); } - return new Future.sync(() => null); + return Future.sync(() => null); } Future _create(MethodCall call) { @@ -64,33 +64,33 @@ class FakePlatformViewsController { final Uint8List creationParams = args['params']; if (_views.containsKey(id)) - throw new PlatformException( + throw PlatformException( code: 'error', message: 'Trying to create an already created platform view, view id: $id', ); if (!_registeredViewTypes.contains(viewType)) - throw new PlatformException( + throw PlatformException( code: 'error', message: 'Trying to create a platform view of unregistered type: $viewType', ); - _views[id] = new FakePlatformView(id, viewType, new Size(width, height), layoutDirection, creationParams); + _views[id] = FakePlatformView(id, viewType, Size(width, height), layoutDirection, creationParams); final int textureId = _textureCounter++; - return new Future.sync(() => textureId); + return Future.sync(() => textureId); } Future _dispose(MethodCall call) { final int id = call.arguments; if (!_views.containsKey(id)) - throw new PlatformException( + throw PlatformException( code: 'error', message: 'Trying to dispose a platform view with unknown id: $id', ); _views.remove(id); - return new Future.sync(() => null); + return Future.sync(() => null); } Future _resize(MethodCall call) async { @@ -100,7 +100,7 @@ class FakePlatformViewsController { final double height = args['height']; if (!_views.containsKey(id)) - throw new PlatformException( + throw PlatformException( code: 'error', message: 'Trying to resize a platform view with unknown id: $id', ); @@ -108,9 +108,9 @@ class FakePlatformViewsController { if (resizeCompleter != null) { await resizeCompleter.future; } - _views[id].size = new Size(width, height); + _views[id].size = Size(width, height); - return new Future.sync(() => null); + return Future.sync(() => null); } Future _touch(MethodCall call) { @@ -125,14 +125,14 @@ class FakePlatformViewsController { pointerIds.add(pointerProperties[i][0]); final double x = pointerCoords[i][7]; final double y = pointerCoords[i][8]; - pointerOffsets.add(new Offset(x, y)); + pointerOffsets.add(Offset(x, y)); } if (!motionEvents.containsKey(id)) motionEvents[id] = []; - motionEvents[id].add(new FakeMotionEvent(action, pointerIds, pointerOffsets)); - return new Future.sync(() => null); + motionEvents[id].add(FakeMotionEvent(action, pointerIds, pointerOffsets)); + return Future.sync(() => null); } Future _setDirection(MethodCall call) async { @@ -141,14 +141,14 @@ class FakePlatformViewsController { final int layoutDirection = args['direction']; if (!_views.containsKey(id)) - throw new PlatformException( + throw PlatformException( code: 'error', message: 'Trying to resize a platform view with unknown id: $id', ); _views[id].layoutDirection = layoutDirection; - return new Future.sync(() => null); + return Future.sync(() => null); } } diff --git a/packages/flutter/test/services/message_codecs_test.dart b/packages/flutter/test/services/message_codecs_test.dart index 108d66be52..ab60c0dedc 100644 --- a/packages/flutter/test/services/message_codecs_test.dart +++ b/packages/flutter/test/services/message_codecs_test.dart @@ -12,8 +12,8 @@ void main() { const MessageCodec binary = BinaryCodec(); test('should encode and decode simple messages', () { _checkEncodeDecode(binary, null); - _checkEncodeDecode(binary, new ByteData(0)); - _checkEncodeDecode(binary, new ByteData(4)..setInt32(0, -7)); + _checkEncodeDecode(binary, ByteData(0)); + _checkEncodeDecode(binary, ByteData(4)..setInt32(0, -7)); }); }); group('String codec', () { @@ -29,7 +29,7 @@ void main() { final ByteData helloWorldByteData = string.encodeMessage('hello world'); final ByteData helloByteData = string.encodeMessage('hello'); - final ByteData offsetByteData = new ByteData.view( + final ByteData offsetByteData = ByteData.view( helloWorldByteData.buffer, helloByteData.lengthInBytes, helloWorldByteData.lengthInBytes - helloByteData.lengthInBytes @@ -120,23 +120,23 @@ void main() { test('should encode sizes correctly at boundary cases', () { _checkEncoding( standard, - new Uint8List(253), - [8, 253]..addAll(new List.filled(253, 0)), + Uint8List(253), + [8, 253]..addAll(List.filled(253, 0)), ); _checkEncoding( standard, - new Uint8List(254), - [8, 254, 254, 0]..addAll(new List.filled(254, 0)), + Uint8List(254), + [8, 254, 254, 0]..addAll(List.filled(254, 0)), ); _checkEncoding( standard, - new Uint8List(0xffff), - [8, 254, 0xff, 0xff]..addAll(new List.filled(0xffff, 0)), + Uint8List(0xffff), + [8, 254, 0xff, 0xff]..addAll(List.filled(0xffff, 0)), ); _checkEncoding( standard, - new Uint8List(0xffff + 1), - [8, 255, 0, 0, 1, 0]..addAll(new List.filled(0xffff + 1, 0)), + Uint8List(0xffff + 1), + [8, 255, 0, 0, 1, 0]..addAll(List.filled(0xffff + 1, 0)), ); }); test('should encode and decode simple messages', () { @@ -167,13 +167,13 @@ void main() { -3.14, '', 'hello', - new Uint8List.fromList([0xBA, 0x5E, 0xBA, 0x11]), - new Int32List.fromList([-0x7fffffff - 1, 0, 0x7fffffff]), + Uint8List.fromList([0xBA, 0x5E, 0xBA, 0x11]), + Int32List.fromList([-0x7fffffff - 1, 0, 0x7fffffff]), null, // ensures the offset of the following list is unaligned. - new Int64List.fromList( + Int64List.fromList( [-0x7fffffffffffffff - 1, 0, 0x7fffffffffffffff]), null, // ensures the offset of the following list is unaligned. - new Float64List.fromList([ + Float64List.fromList([ double.negativeInfinity, -double.maxFinite, -double.minPositive, diff --git a/packages/flutter/test/services/platform_channel_test.dart b/packages/flutter/test/services/platform_channel_test.dart index 7b3c4ccd6a..b7cf0dc564 100644 --- a/packages/flutter/test/services/platform_channel_test.dart +++ b/packages/flutter/test/services/platform_channel_test.dart @@ -100,7 +100,7 @@ void main() { }); test('can handle method call of unimplemented method', () async { channel.setMethodCallHandler((MethodCall call) async { - throw new MissingPluginException(); + throw MissingPluginException(); }); final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; @@ -120,7 +120,7 @@ void main() { }); test('can handle method call with expressive error result', () async { channel.setMethodCallHandler((MethodCall call) async { - throw new PlatformException(code: 'bad', message: 'sayHello failed', details: null); + throw PlatformException(code: 'bad', message: 'sayHello failed', details: null); }); final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; @@ -139,7 +139,7 @@ void main() { }); test('can handle method call with other error result', () async { channel.setMethodCallHandler((MethodCall call) async { - throw new ArgumentError('bad'); + throw ArgumentError('bad'); }); final ByteData call = jsonMethod.encodeMethodCall(const MethodCall('sayHello', 'hello')); ByteData envelope; @@ -190,7 +190,7 @@ void main() { ); final List events = await channel.receiveBroadcastStream('hello').toList(); expect(events, orderedEquals(['hello1', 'hello2'])); - await new Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect(canceled, isTrue); }); test('can receive error event', () async { @@ -212,7 +212,7 @@ void main() { final List events = []; final List errors = []; channel.receiveBroadcastStream('hello').listen(events.add, onError: errors.add); - await new Future.delayed(Duration.zero); + await Future.delayed(Duration.zero); expect(events, isEmpty); expect(errors, hasLength(1)); expect(errors[0], isInstanceOf()); diff --git a/packages/flutter/test/services/platform_messages_test.dart b/packages/flutter/test/services/platform_messages_test.dart index 969de60923..70d20bd74b 100644 --- a/packages/flutter/test/services/platform_messages_test.dart +++ b/packages/flutter/test/services/platform_messages_test.dart @@ -16,7 +16,7 @@ void main() { return null; }); - final ByteData message = new ByteData(2)..setUint16(0, 0xABCD); + final ByteData message = ByteData(2)..setUint16(0, 0xABCD); await BinaryMessages.send('test1', message); expect(log, equals([message])); log.clear(); diff --git a/packages/flutter/test/services/platform_views_test.dart b/packages/flutter/test/services/platform_views_test.dart index d8866e5279..b39032a399 100644 --- a/packages/flutter/test/services/platform_views_test.dart +++ b/packages/flutter/test/services/platform_views_test.dart @@ -14,7 +14,7 @@ void main() { group('Android', () { setUp(() { - viewsController = new FakePlatformViewsController(TargetPlatform.android); + viewsController = FakePlatformViewsController(TargetPlatform.android); }); test('create Android view of unregistered type', () async { @@ -39,8 +39,8 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), - new FakePlatformView(1, 'webview', const Size(200.0, 300.0), AndroidViewController.kAndroidLayoutDirectionRtl), + FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), + FakePlatformView(1, 'webview', const Size(200.0, 300.0), AndroidViewController.kAndroidLayoutDirectionRtl), ])); }); @@ -69,7 +69,7 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), + FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), ])); }); @@ -95,8 +95,8 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), - new FakePlatformView(1, 'webview', const Size(500.0, 500.0), AndroidViewController.kAndroidLayoutDirectionLtr), + FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), + FakePlatformView(1, 'webview', const Size(500.0, 500.0), AndroidViewController.kAndroidLayoutDirectionLtr), ])); }); @@ -130,7 +130,7 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), + FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr), ])); }); @@ -143,7 +143,7 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl), + FakePlatformView(0, 'webview', const Size(100.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl), ])); }); }); diff --git a/packages/flutter/test/widgets/absorb_pointer_test.dart b/packages/flutter/test/widgets/absorb_pointer_test.dart index 5faa6d9406..c05370102d 100644 --- a/packages/flutter/test/widgets/absorb_pointer_test.dart +++ b/packages/flutter/test/widgets/absorb_pointer_test.dart @@ -11,10 +11,10 @@ void main() { testWidgets('AbsorbPointers do not block siblings', (WidgetTester tester) async { bool tapped = false; await tester.pumpWidget( - new Column( + Column( children: [ - new Expanded( - child: new GestureDetector( + Expanded( + child: GestureDetector( onTap: () => tapped = true, ), ), @@ -32,23 +32,23 @@ void main() { }); testWidgets('AbsorbPointers semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new AbsorbPointer( + AbsorbPointer( absorbing: true, - child: new Semantics( + child: Semantics( label: 'test', textDirection: TextDirection.ltr, ), ), ); expect(semantics, hasSemantics( - new TestSemantics.root(), ignoreId: true, ignoreRect: true, ignoreTransform: true)); + TestSemantics.root(), ignoreId: true, ignoreRect: true, ignoreTransform: true)); await tester.pumpWidget( - new AbsorbPointer( + AbsorbPointer( absorbing: false, - child: new Semantics( + child: Semantics( label: 'test', textDirection: TextDirection.ltr, ), @@ -56,9 +56,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'test', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/widgets/align_test.dart b/packages/flutter/test/widgets/align_test.dart index e41f39b44e..9213e775be 100644 --- a/packages/flutter/test/widgets/align_test.dart +++ b/packages/flutter/test/widgets/align_test.dart @@ -9,15 +9,15 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Align smoke test', (WidgetTester tester) async { await tester.pumpWidget( - new Align( - child: new Container(), + Align( + child: Container(), alignment: const Alignment(0.50, 0.50), ), ); await tester.pumpWidget( - new Align( - child: new Container(), + Align( + child: Container(), alignment: const Alignment(0.0, 0.0), ), ); @@ -44,10 +44,10 @@ void main() { }); testWidgets('Align control test (LTR)', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Align( - child: new Container(width: 100.0, height: 80.0), + child: Align( + child: Container(width: 100.0, height: 80.0), alignment: AlignmentDirectional.topStart, ), )); @@ -55,10 +55,10 @@ void main() { expect(tester.getTopLeft(find.byType(Container)).dx, 0.0); expect(tester.getBottomRight(find.byType(Container)).dx, 100.0); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Align( - child: new Container(width: 100.0, height: 80.0), + child: Align( + child: Container(width: 100.0, height: 80.0), alignment: Alignment.topLeft, ), )); @@ -68,10 +68,10 @@ void main() { }); testWidgets('Align control test (RTL)', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, - child: new Align( - child: new Container(width: 100.0, height: 80.0), + child: Align( + child: Container(width: 100.0, height: 80.0), alignment: AlignmentDirectional.topStart, ), )); @@ -79,10 +79,10 @@ void main() { expect(tester.getTopLeft(find.byType(Container)).dx, 700.0); expect(tester.getBottomRight(find.byType(Container)).dx, 800.0); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Align( - child: new Container(width: 100.0, height: 80.0), + child: Align( + child: Container(width: 100.0, height: 80.0), alignment: Alignment.topLeft, ), )); @@ -92,12 +92,12 @@ void main() { }); testWidgets('Shrink wraps in finite space', (WidgetTester tester) async { - final GlobalKey alignKey = new GlobalKey(); + final GlobalKey alignKey = GlobalKey(); await tester.pumpWidget( - new SingleChildScrollView( - child: new Align( + SingleChildScrollView( + child: Align( key: alignKey, - child: new Container( + child: Container( width: 10.0, height: 10.0 ), diff --git a/packages/flutter/test/widgets/animated_align_test.dart b/packages/flutter/test/widgets/animated_align_test.dart index bb31370de3..9c314d156f 100644 --- a/packages/flutter/test/widgets/animated_align_test.dart +++ b/packages/flutter/test/widgets/animated_align_test.dart @@ -17,15 +17,15 @@ void main() { }); testWidgets('AnimatedAlign alignment visual-to-directional animation', (WidgetTester tester) async { - final Key target = new UniqueKey(); + final Key target = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedAlign( + child: AnimatedAlign( duration: const Duration(milliseconds: 200), alignment: Alignment.topRight, - child: new SizedBox(key: target, width: 100.0, height: 200.0), + child: SizedBox(key: target, width: 100.0, height: 200.0), ), ), ); @@ -34,12 +34,12 @@ void main() { expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedAlign( + child: AnimatedAlign( duration: const Duration(milliseconds: 200), alignment: AlignmentDirectional.bottomStart, - child: new SizedBox(key: target, width: 100.0, height: 200.0), + child: SizedBox(key: target, width: 100.0, height: 200.0), ), ), ); diff --git a/packages/flutter/test/widgets/animated_container_test.dart b/packages/flutter/test/widgets/animated_container_test.dart index bfaa8ff8bf..568460111b 100644 --- a/packages/flutter/test/widgets/animated_container_test.dart +++ b/packages/flutter/test/widgets/animated_container_test.dart @@ -8,13 +8,13 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('AnimatedContainer.debugFillProperties', (WidgetTester tester) async { - final AnimatedContainer container = new AnimatedContainer( + final AnimatedContainer container = AnimatedContainer( constraints: const BoxConstraints.tightFor(width: 17.0, height: 23.0), decoration: const BoxDecoration(color: Color(0xFF00FF00)), foregroundDecoration: const BoxDecoration(color: Color(0x7F0000FF)), margin: const EdgeInsets.all(10.0), padding: const EdgeInsets.all(7.0), - transform: new Matrix4.translationValues(4.0, 3.0, 0.0), + transform: Matrix4.translationValues(4.0, 3.0, 0.0), width: 50.0, height: 75.0, curve: Curves.ease, @@ -25,7 +25,7 @@ void main() { }); testWidgets('AnimatedContainer control test', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); const BoxDecoration decorationA = BoxDecoration( color: Color(0xFF00FF00), @@ -38,7 +38,7 @@ void main() { BoxDecoration actualDecoration; await tester.pumpWidget( - new AnimatedContainer( + AnimatedContainer( key: key, duration: const Duration(milliseconds: 200), decoration: decorationA @@ -50,7 +50,7 @@ void main() { expect(actualDecoration.color, equals(decorationA.color)); await tester.pumpWidget( - new AnimatedContainer( + AnimatedContainer( key: key, duration: const Duration(milliseconds: 200), decoration: decorationB @@ -98,7 +98,7 @@ void main() { testWidgets('AnimatedContainer overanimate test', (WidgetTester tester) async { await tester.pumpWidget( - new AnimatedContainer( + AnimatedContainer( duration: const Duration(milliseconds: 200), color: const Color(0xFF00FF00), ) @@ -107,7 +107,7 @@ void main() { await tester.pump(const Duration(seconds: 1)); expect(tester.binding.transientCallbackCount, 0); await tester.pumpWidget( - new AnimatedContainer( + AnimatedContainer( duration: const Duration(milliseconds: 200), color: const Color(0xFF00FF00), ) @@ -116,7 +116,7 @@ void main() { await tester.pump(const Duration(seconds: 1)); expect(tester.binding.transientCallbackCount, 0); await tester.pumpWidget( - new AnimatedContainer( + AnimatedContainer( duration: const Duration(milliseconds: 200), color: const Color(0xFF0000FF), ) @@ -125,7 +125,7 @@ void main() { await tester.pump(const Duration(seconds: 1)); expect(tester.binding.transientCallbackCount, 0); await tester.pumpWidget( - new AnimatedContainer( + AnimatedContainer( duration: const Duration(milliseconds: 200), color: const Color(0xFF0000FF), ) @@ -134,15 +134,15 @@ void main() { }); testWidgets('AnimatedContainer padding visual-to-directional animation', (WidgetTester tester) async { - final Key target = new UniqueKey(); + final Key target = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), padding: const EdgeInsets.only(right: 50.0), - child: new SizedBox.expand(key: target), + child: SizedBox.expand(key: target), ), ), ); @@ -151,12 +151,12 @@ void main() { expect(tester.getTopRight(find.byKey(target)), const Offset(750.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), padding: const EdgeInsetsDirectional.only(start: 100.0), - child: new SizedBox.expand(key: target), + child: SizedBox.expand(key: target), ), ), ); @@ -176,15 +176,15 @@ void main() { }); testWidgets('AnimatedContainer alignment visual-to-directional animation', (WidgetTester tester) async { - final Key target = new UniqueKey(); + final Key target = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), alignment: Alignment.topRight, - child: new SizedBox(key: target, width: 100.0, height: 200.0), + child: SizedBox(key: target, width: 100.0, height: 200.0), ), ), ); @@ -193,12 +193,12 @@ void main() { expect(tester.getTopRight(find.byKey(target)), const Offset(800.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), alignment: AlignmentDirectional.bottomStart, - child: new SizedBox(key: target, width: 100.0, height: 200.0), + child: SizedBox(key: target, width: 100.0, height: 200.0), ), ), ); @@ -219,8 +219,8 @@ void main() { testWidgets('Animation rerun', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new AnimatedContainer( + Center( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), width: 100.0, height: 100.0, @@ -239,8 +239,8 @@ void main() { await tester.pump(const Duration(milliseconds: 1000)); await tester.pumpWidget( - new Center( - child: new AnimatedContainer( + Center( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), width: 200.0, height: 200.0, @@ -263,8 +263,8 @@ void main() { expect(text.size.height, equals(200.0)); await tester.pumpWidget( - new Center( - child: new AnimatedContainer( + Center( + child: AnimatedContainer( duration: const Duration(milliseconds: 200), width: 200.0, height: 100.0, diff --git a/packages/flutter/test/widgets/animated_cross_fade_test.dart b/packages/flutter/test/widgets/animated_cross_fade_test.dart index 327377a408..280fd908b3 100644 --- a/packages/flutter/test/widgets/animated_cross_fade_test.dart +++ b/packages/flutter/test/widgets/animated_cross_fade_test.dart @@ -90,21 +90,21 @@ void main() { }); testWidgets('AnimatedCrossFade alignment (VISUAL)', (WidgetTester tester) async { - final Key firstKey = new UniqueKey(); - final Key secondKey = new UniqueKey(); + final Key firstKey = UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new AnimatedCrossFade( + child: Center( + child: AnimatedCrossFade( alignment: Alignment.bottomRight, - firstChild: new SizedBox( + firstChild: SizedBox( key: firstKey, width: 100.0, height: 100.0, ), - secondChild: new SizedBox( + secondChild: SizedBox( key: secondKey, width: 200.0, height: 200.0, @@ -117,17 +117,17 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new AnimatedCrossFade( + child: Center( + child: AnimatedCrossFade( alignment: Alignment.bottomRight, - firstChild: new SizedBox( + firstChild: SizedBox( key: firstKey, width: 100.0, height: 100.0, ), - secondChild: new SizedBox( + secondChild: SizedBox( key: secondKey, width: 200.0, height: 200.0, @@ -148,21 +148,21 @@ void main() { }); testWidgets('AnimatedCrossFade alignment (LTR)', (WidgetTester tester) async { - final Key firstKey = new UniqueKey(); - final Key secondKey = new UniqueKey(); + final Key firstKey = UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new AnimatedCrossFade( + child: Center( + child: AnimatedCrossFade( alignment: AlignmentDirectional.bottomEnd, - firstChild: new SizedBox( + firstChild: SizedBox( key: firstKey, width: 100.0, height: 100.0, ), - secondChild: new SizedBox( + secondChild: SizedBox( key: secondKey, width: 200.0, height: 200.0, @@ -175,17 +175,17 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new AnimatedCrossFade( + child: Center( + child: AnimatedCrossFade( alignment: AlignmentDirectional.bottomEnd, - firstChild: new SizedBox( + firstChild: SizedBox( key: firstKey, width: 100.0, height: 100.0, ), - secondChild: new SizedBox( + secondChild: SizedBox( key: secondKey, width: 200.0, height: 200.0, @@ -206,21 +206,21 @@ void main() { }); testWidgets('AnimatedCrossFade alignment (RTL)', (WidgetTester tester) async { - final Key firstKey = new UniqueKey(); - final Key secondKey = new UniqueKey(); + final Key firstKey = UniqueKey(); + final Key secondKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new AnimatedCrossFade( + child: Center( + child: AnimatedCrossFade( alignment: AlignmentDirectional.bottomEnd, - firstChild: new SizedBox( + firstChild: SizedBox( key: firstKey, width: 100.0, height: 100.0, ), - secondChild: new SizedBox( + secondChild: SizedBox( key: secondKey, width: 200.0, height: 200.0, @@ -233,17 +233,17 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new AnimatedCrossFade( + child: Center( + child: AnimatedCrossFade( alignment: AlignmentDirectional.bottomEnd, - firstChild: new SizedBox( + firstChild: SizedBox( key: firstKey, width: 100.0, height: 100.0, ), - secondChild: new SizedBox( + secondChild: SizedBox( key: secondKey, width: 200.0, height: 200.0, @@ -264,11 +264,11 @@ void main() { }); Widget crossFadeWithWatcher({bool towardsSecond = false}) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new AnimatedCrossFade( + child: AnimatedCrossFade( firstChild: const _TickerWatchingWidget(), - secondChild: new Container(), + secondChild: Container(), crossFadeState: towardsSecond ? CrossFadeState.showSecond : CrossFadeState.showFirst, duration: const Duration(milliseconds: 50), ), @@ -333,9 +333,9 @@ void main() { expect(find.text('AAA'), findsOneWidget); expect(find.text('BBB'), findsOneWidget); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new AnimatedCrossFade( + child: AnimatedCrossFade( firstChild: const Text('AAA', textDirection: TextDirection.ltr), secondChild: const Text('BBB', textDirection: TextDirection.ltr), crossFadeState: CrossFadeState.showFirst, @@ -347,9 +347,9 @@ void main() { expect(find.text('AAA'), findsOneWidget); expect(find.text('BBB'), findsNothing); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new AnimatedCrossFade( + child: AnimatedCrossFade( firstChild: const Text('AAA', textDirection: TextDirection.ltr), secondChild: const Text('BBB', textDirection: TextDirection.ltr), crossFadeState: CrossFadeState.showSecond, @@ -367,7 +367,7 @@ class _TickerWatchingWidget extends StatefulWidget { const _TickerWatchingWidget(); @override - State createState() => new _TickerWatchingWidgetState(); + State createState() => _TickerWatchingWidgetState(); } class _TickerWatchingWidgetState extends State<_TickerWatchingWidget> with SingleTickerProviderStateMixin { @@ -380,7 +380,7 @@ class _TickerWatchingWidgetState extends State<_TickerWatchingWidget> with Singl } @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); @override void dispose() { diff --git a/packages/flutter/test/widgets/animated_list_test.dart b/packages/flutter/test/widgets/animated_list_test.dart index ffd43ed37f..2e9c31eb9e 100644 --- a/packages/flutter/test/widgets/animated_list_test.dart +++ b/packages/flutter/test/widgets/animated_list_test.dart @@ -10,16 +10,16 @@ void main() { final Map> animations = >{}; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new AnimatedList( + child: AnimatedList( initialItemCount: 2, itemBuilder: (BuildContext context, int index, Animation animation) { animations[index] = animation; - return new SizedBox( + return SizedBox( height: 100.0, - child: new Center( - child: new Text('item $index'), + child: Center( + child: Text('item $index'), ), ); }, @@ -36,22 +36,22 @@ void main() { }); testWidgets('AnimatedList insert', (WidgetTester tester) async { - final GlobalKey listKey = new GlobalKey(); + final GlobalKey listKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new AnimatedList( + child: AnimatedList( key: listKey, itemBuilder: (BuildContext context, int index, Animation animation) { - return new SizeTransition( - key: new ValueKey(index), + return SizeTransition( + key: ValueKey(index), axis: Axis.vertical, sizeFactor: animation, - child: new SizedBox( + child: SizedBox( height: 100.0, - child: new Center( - child: new Text('item $index'), + child: Center( + child: Text('item $index'), ), ), ); @@ -60,9 +60,9 @@ void main() { ), ); - double itemHeight(int index) => tester.getSize(find.byKey(new ValueKey(index), skipOffstage: false)).height; - double itemTop(int index) => tester.getTopLeft(find.byKey(new ValueKey(index), skipOffstage: false)).dy; - double itemBottom(int index) => tester.getBottomLeft(find.byKey(new ValueKey(index), skipOffstage: false)).dy; + double itemHeight(int index) => tester.getSize(find.byKey(ValueKey(index), skipOffstage: false)).height; + double itemTop(int index) => tester.getTopLeft(find.byKey(ValueKey(index), skipOffstage: false)).dy; + double itemBottom(int index) => tester.getBottomLeft(find.byKey(ValueKey(index), skipOffstage: false)).dy; listKey.currentState.insertItem(0, duration: const Duration(milliseconds: 100)); await tester.pump(); @@ -110,27 +110,27 @@ void main() { }); testWidgets('AnimatedList remove', (WidgetTester tester) async { - final GlobalKey listKey = new GlobalKey(); + final GlobalKey listKey = GlobalKey(); final List items = [0, 1, 2]; Widget buildItem(BuildContext context, int item, Animation animation) { - return new SizeTransition( - key: new ValueKey(item), + return SizeTransition( + key: ValueKey(item), axis: Axis.vertical, sizeFactor: animation, - child: new SizedBox( + child: SizedBox( height: 100.0, - child: new Center( - child: new Text('item $item', textDirection: TextDirection.ltr), + child: Center( + child: Text('item $item', textDirection: TextDirection.ltr), ), ), ); } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new AnimatedList( + child: AnimatedList( key: listKey, initialItemCount: 3, itemBuilder: (BuildContext context, int index, Animation animation) { @@ -140,8 +140,8 @@ void main() { ), ); - double itemTop(int index) => tester.getTopLeft(find.byKey(new ValueKey(index))).dy; - double itemBottom(int index) => tester.getBottomLeft(find.byKey(new ValueKey(index))).dy; + double itemTop(int index) => tester.getTopLeft(find.byKey(ValueKey(index))).dy; + double itemBottom(int index) => tester.getBottomLeft(find.byKey(ValueKey(index))).dy; expect(find.text('item 0'), findsOneWidget); expect(find.text('item 1'), findsOneWidget); diff --git a/packages/flutter/test/widgets/animated_padding_test.dart b/packages/flutter/test/widgets/animated_padding_test.dart index e28ad56a2f..f9a1aa416d 100644 --- a/packages/flutter/test/widgets/animated_padding_test.dart +++ b/packages/flutter/test/widgets/animated_padding_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('AnimatedPadding.debugFillProperties', (WidgetTester tester) async { - final AnimatedPadding padding = new AnimatedPadding( + final AnimatedPadding padding = AnimatedPadding( padding: const EdgeInsets.all(7.0), curve: Curves.ease, duration: const Duration(milliseconds: 200), @@ -18,15 +18,15 @@ void main() { }); testWidgets('AnimatedPadding padding visual-to-directional animation', (WidgetTester tester) async { - final Key target = new UniqueKey(); + final Key target = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedPadding( + child: AnimatedPadding( duration: const Duration(milliseconds: 200), padding: const EdgeInsets.only(right: 50.0), - child: new SizedBox.expand(key: target), + child: SizedBox.expand(key: target), ), ), ); @@ -35,12 +35,12 @@ void main() { expect(tester.getTopRight(find.byKey(target)), const Offset(750.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedPadding( + child: AnimatedPadding( duration: const Duration(milliseconds: 200), padding: const EdgeInsetsDirectional.only(start: 100.0), - child: new SizedBox.expand(key: target), + child: SizedBox.expand(key: target), ), ), ); diff --git a/packages/flutter/test/widgets/animated_positioned_test.dart b/packages/flutter/test/widgets/animated_positioned_test.dart index 461cbc5b54..f7246e4701 100644 --- a/packages/flutter/test/widgets/animated_positioned_test.dart +++ b/packages/flutter/test/widgets/animated_positioned_test.dart @@ -8,8 +8,8 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('AnimatedPositioned.fromRect control test', (WidgetTester tester) async { - final AnimatedPositioned positioned = new AnimatedPositioned.fromRect( - rect: new Rect.fromLTWH(7.0, 5.0, 12.0, 16.0), + final AnimatedPositioned positioned = AnimatedPositioned.fromRect( + rect: Rect.fromLTWH(7.0, 5.0, 12.0, 16.0), duration: const Duration(milliseconds: 200), ); @@ -21,16 +21,16 @@ void main() { }); testWidgets('AnimatedPositioned - basics (VISUAL)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 50.0, top: 30.0, width: 70.0, @@ -50,11 +50,11 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0))); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 37.0, top: 31.0, width: 59.0, @@ -103,17 +103,17 @@ void main() { }); testWidgets('AnimatedPositionedDirectional - basics (LTR)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 50.0, top: 30.0, width: 70.0, @@ -134,12 +134,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0 + 70.0 / 2.0, 30.0 + 110.0 / 2.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 37.0, top: 31.0, width: 59.0, @@ -189,17 +189,17 @@ void main() { }); testWidgets('AnimatedPositionedDirectional - basics (RTL)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 50.0, top: 30.0, width: 70.0, @@ -220,12 +220,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(800.0 - 50.0 - 70.0 / 2.0, 30.0 + 110.0 / 2.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 37.0, top: 31.0, width: 59.0, @@ -275,16 +275,16 @@ void main() { }); testWidgets('AnimatedPositioned - interrupted animation (VISUAL)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 0.0, top: 0.0, width: 100.0, @@ -304,11 +304,11 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 100.0, top: 100.0, width: 100.0, @@ -328,11 +328,11 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0))); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 150.0, top: 150.0, width: 100.0, @@ -358,16 +358,16 @@ void main() { }); testWidgets('AnimatedPositioned - switching variables (VISUAL)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 0.0, top: 0.0, width: 100.0, @@ -387,11 +387,11 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new AnimatedPositioned( - child: new Container(key: key), + AnimatedPositioned( + child: Container(key: key), left: 0.0, top: 100.0, right: 100.0, // 700.0 from the left @@ -417,17 +417,17 @@ void main() { }); testWidgets('AnimatedPositionedDirectional - interrupted animation (LTR)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 0.0, top: 0.0, width: 100.0, @@ -448,12 +448,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 100.0, top: 100.0, width: 100.0, @@ -474,12 +474,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(100.0, 100.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 150.0, top: 150.0, width: 100.0, @@ -506,17 +506,17 @@ void main() { }); testWidgets('AnimatedPositionedDirectional - switching variables (LTR)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 0.0, top: 0.0, width: 100.0, @@ -537,12 +537,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(50.0, 50.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 0.0, top: 100.0, end: 100.0, // 700.0 from the start @@ -569,17 +569,17 @@ void main() { }); testWidgets('AnimatedPositionedDirectional - interrupted animation (RTL)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 0.0, top: 0.0, width: 100.0, @@ -600,12 +600,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 100.0, top: 100.0, width: 100.0, @@ -626,12 +626,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(700.0, 100.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 150.0, top: 150.0, width: 100.0, @@ -658,17 +658,17 @@ void main() { }); testWidgets('AnimatedPositionedDirectional - switching variables (RTL)', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); RenderBox box; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 0.0, top: 0.0, width: 100.0, @@ -689,12 +689,12 @@ void main() { expect(box.localToGlobal(box.size.center(Offset.zero)), equals(const Offset(750.0, 50.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new AnimatedPositionedDirectional( - child: new Container(key: key), + AnimatedPositionedDirectional( + child: Container(key: key), start: 0.0, top: 100.0, end: 100.0, // 700.0 from the start diff --git a/packages/flutter/test/widgets/animated_size_test.dart b/packages/flutter/test/widgets/animated_size_test.dart index 05ae5d55b4..5fbab15918 100644 --- a/packages/flutter/test/widgets/animated_size_test.dart +++ b/packages/flutter/test/widgets/animated_size_test.dart @@ -19,8 +19,8 @@ void main() { group('AnimatedSize', () { testWidgets('animates forwards then backwards with stable-sized children', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( @@ -36,8 +36,8 @@ void main() { expect(box.size.height, equals(100.0)); await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( @@ -53,7 +53,7 @@ void main() { expect(box.size.width, equals(150.0)); expect(box.size.height, equals(150.0)); - TestPaintingContext context = new TestPaintingContext(); + TestPaintingContext context = TestPaintingContext(); box.paint(context, Offset.zero); expect(context.invocations.first.memberName, equals(#pushClipRect)); @@ -63,8 +63,8 @@ void main() { expect(box.size.height, equals(200.0)); await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( @@ -80,7 +80,7 @@ void main() { expect(box.size.width, equals(150.0)); expect(box.size.height, equals(150.0)); - context = new TestPaintingContext(); + context = TestPaintingContext(); box.paint(context, Offset.zero); expect(context.invocations.first.memberName, equals(#paintChild)); @@ -92,11 +92,11 @@ void main() { testWidgets('clamps animated size to constraints', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new SizedBox ( + Center( + child: SizedBox ( width: 100.0, height: 100.0, - child: new AnimatedSize( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( @@ -114,11 +114,11 @@ void main() { // Attempt to animate beyond the outer SizedBox. await tester.pumpWidget( - new Center( - child: new SizedBox ( + Center( + child: SizedBox ( width: 100.0, height: 100.0, - child: new AnimatedSize( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( @@ -139,7 +139,7 @@ void main() { testWidgets('tracks unstable child, then resumes animation when child stabilizes', (WidgetTester tester) async { Future pumpMillis(int millis) async { - await tester.pump(new Duration(milliseconds: millis)); + await tester.pump(Duration(milliseconds: millis)); } void verify({double size, RenderAnimatedSizeState state}) { @@ -155,11 +155,11 @@ void main() { } await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 100), width: 100.0, height: 100.0, @@ -172,11 +172,11 @@ void main() { // Animate child size from 100 to 200 slowly (100ms). await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 100), width: 200.0, height: 200.0, @@ -201,11 +201,11 @@ void main() { // Quickly (in 1ms) change size back to 100 await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, - child: new AnimatedContainer( + child: AnimatedContainer( duration: const Duration(milliseconds: 1), width: 100.0, height: 100.0, @@ -238,8 +238,8 @@ void main() { ); await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( @@ -258,8 +258,8 @@ void main() { testWidgets('does not run animation unnecessarily', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new AnimatedSize( + Center( + child: AnimatedSize( duration: const Duration(milliseconds: 200), vsync: tester, child: const SizedBox( diff --git a/packages/flutter/test/widgets/animated_switcher_test.dart b/packages/flutter/test/widgets/animated_switcher_test.dart index d3765705ed..8edbb52c48 100644 --- a/packages/flutter/test/widgets/animated_switcher_test.dart +++ b/packages/flutter/test/widgets/animated_switcher_test.dart @@ -7,13 +7,13 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('AnimatedSwitcher fades in a new child.', (WidgetTester tester) async { - final UniqueKey containerOne = new UniqueKey(); - final UniqueKey containerTwo = new UniqueKey(); - final UniqueKey containerThree = new UniqueKey(); + final UniqueKey containerOne = UniqueKey(); + final UniqueKey containerTwo = UniqueKey(); + final UniqueKey containerThree = UniqueKey(); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(key: containerOne, color: const Color(0x00000000)), + child: Container(key: containerOne, color: const Color(0x00000000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -24,9 +24,9 @@ void main() { expect(transition.opacity.value, equals(1.0)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(key: containerTwo, color: const Color(0xff000000)), + child: Container(key: containerTwo, color: const Color(0xff000000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -38,9 +38,9 @@ void main() { expect(transition.opacity.value, equals(0.5)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(key: containerThree, color: const Color(0xffff0000)), + child: Container(key: containerThree, color: const Color(0xffff0000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -58,9 +58,9 @@ void main() { testWidgets("AnimatedSwitcher doesn't transition in a new child of the same type.", (WidgetTester tester) async { await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0x00000000)), + child: Container(color: const Color(0x00000000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -71,9 +71,9 @@ void main() { expect(transition.opacity.value, equals(1.0)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0xff000000)), + child: Container(color: const Color(0xff000000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -99,9 +99,9 @@ void main() { expect(find.byType(FadeTransition), findsNothing); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0xff000000)), + child: Container(color: const Color(0xff000000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -113,9 +113,9 @@ void main() { await tester.pumpAndSettle(); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0x00000000)), + child: Container(color: const Color(0x00000000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -155,29 +155,29 @@ void main() { }); testWidgets("AnimatedSwitcher doesn't start any animations after dispose.", (WidgetTester tester) async { - await tester.pumpWidget(new AnimatedSwitcher( + await tester.pumpWidget(AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0xff000000)), + child: Container(color: const Color(0xff000000)), switchInCurve: Curves.linear, )); await tester.pump(const Duration(milliseconds: 50)); // Change the widget tree in the middle of the animation. - await tester.pumpWidget(new Container(color: const Color(0xffff0000))); + await tester.pumpWidget(Container(color: const Color(0xffff0000))); expect(await tester.pumpAndSettle(const Duration(milliseconds: 100)), equals(1)); }); testWidgets('AnimatedSwitcher uses custom layout.', (WidgetTester tester) async { Widget newLayoutBuilder(Widget currentChild, List previousChildren) { - return new Column( + return Column( children: previousChildren + [currentChild], ); } await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0x00000000)), + child: Container(color: const Color(0x00000000)), switchInCurve: Curves.linear, layoutBuilder: newLayoutBuilder, ), @@ -194,24 +194,24 @@ void main() { foundChildren.add(currentChild); } foundChildren.addAll(previousChildren); - return new Column( + return Column( children: foundChildren, ); } Widget newTransitionBuilder(Widget child, Animation animation) { - return new SizeTransition( + return SizeTransition( sizeFactor: animation, child: child, ); } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedSwitcher( + child: AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0x00000000)), + child: Container(color: const Color(0x00000000)), switchInCurve: Curves.linear, layoutBuilder: newLayoutBuilder, transitionBuilder: newTransitionBuilder, @@ -225,9 +225,9 @@ void main() { } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedSwitcher( + child: AnimatedSwitcher( duration: const Duration(milliseconds: 100), child: null, switchInCurve: Curves.linear, @@ -248,16 +248,16 @@ void main() { }); testWidgets("AnimatedSwitcher doesn't reset state of the children in transitions.", (WidgetTester tester) async { - final UniqueKey statefulOne = new UniqueKey(); - final UniqueKey statefulTwo = new UniqueKey(); - final UniqueKey statefulThree = new UniqueKey(); + final UniqueKey statefulOne = UniqueKey(); + final UniqueKey statefulTwo = UniqueKey(); + final UniqueKey statefulThree = UniqueKey(); StatefulTestState.generation = 0; await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new StatefulTest(key: statefulOne), + child: StatefulTest(key: statefulOne), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -269,9 +269,9 @@ void main() { expect(StatefulTestState.generation, equals(1)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new StatefulTest(key: statefulTwo), + child: StatefulTest(key: statefulTwo), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -284,9 +284,9 @@ void main() { expect(StatefulTestState.generation, equals(2)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new StatefulTest(key: statefulThree), + child: StatefulTest(key: statefulThree), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, ), @@ -307,9 +307,9 @@ void main() { testWidgets('AnimatedSwitcher updates widgets without animating if they are isomorphic.', (WidgetTester tester) async { Future pumpChild(Widget child) async { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new AnimatedSwitcher( + child: AnimatedSwitcher( duration: const Duration(milliseconds: 100), child: child, switchInCurve: Curves.linear, @@ -334,9 +334,9 @@ void main() { }); testWidgets('AnimatedSwitcher updates previous child transitions if the transitionBuilder changes.', (WidgetTester tester) async { - final UniqueKey containerOne = new UniqueKey(); - final UniqueKey containerTwo = new UniqueKey(); - final UniqueKey containerThree = new UniqueKey(); + final UniqueKey containerOne = UniqueKey(); + final UniqueKey containerTwo = UniqueKey(); + final UniqueKey containerThree = UniqueKey(); final List foundChildren = []; Widget newLayoutBuilder(Widget currentChild, List previousChildren) { @@ -345,16 +345,16 @@ void main() { foundChildren.add(currentChild); } foundChildren.addAll(previousChildren); - return new Column( + return Column( children: foundChildren, ); } // Insert three unique children so that we have some previous children. await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(key: containerOne, color: const Color(0xFFFF0000)), + child: Container(key: containerOne, color: const Color(0xFFFF0000)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, layoutBuilder: newLayoutBuilder, @@ -364,9 +364,9 @@ void main() { await tester.pump(const Duration(milliseconds: 10)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(key: containerTwo, color: const Color(0xFF00FF00)), + child: Container(key: containerTwo, color: const Color(0xFF00FF00)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, layoutBuilder: newLayoutBuilder, @@ -376,9 +376,9 @@ void main() { await tester.pump(const Duration(milliseconds: 10)); await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(key: containerThree, color: const Color(0xFF0000FF)), + child: Container(key: containerThree, color: const Color(0xFF0000FF)), switchInCurve: Curves.linear, switchOutCurve: Curves.linear, layoutBuilder: newLayoutBuilder, @@ -397,7 +397,7 @@ void main() { } Widget newTransitionBuilder(Widget child, Animation animation) { - return new ScaleTransition( + return ScaleTransition( scale: animation, child: child, ); @@ -406,9 +406,9 @@ void main() { // Now set a new transition builder and make sure all the previous // transitions are replaced. await tester.pumpWidget( - new AnimatedSwitcher( + AnimatedSwitcher( duration: const Duration(milliseconds: 100), - child: new Container(color: const Color(0x00000000)), + child: Container(color: const Color(0x00000000)), switchInCurve: Curves.linear, layoutBuilder: newLayoutBuilder, transitionBuilder: newTransitionBuilder, @@ -432,7 +432,7 @@ class StatefulTest extends StatefulWidget { const StatefulTest({Key key}) : super(key: key); @override - StatefulTestState createState() => new StatefulTestState(); + StatefulTestState createState() => StatefulTestState(); } class StatefulTestState extends State { @@ -446,5 +446,5 @@ class StatefulTestState extends State { } @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } diff --git a/packages/flutter/test/widgets/app_navigator_key_test.dart b/packages/flutter/test/widgets/app_navigator_key_test.dart index 48d5f59380..babc8d09a0 100644 --- a/packages/flutter/test/widgets/app_navigator_key_test.dart +++ b/packages/flutter/test/widgets/app_navigator_key_test.dart @@ -5,7 +5,7 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; -final RouteFactory generateRoute = (RouteSettings settings) => new PageRouteBuilder( +final RouteFactory generateRoute = (RouteSettings settings) => PageRouteBuilder( settings: settings, pageBuilder: (BuildContext context, Animation animation1, Animation animation2) { return const Placeholder(); @@ -14,19 +14,19 @@ final RouteFactory generateRoute = (RouteSettings settings) => new PageRouteBuil void main() { testWidgets('WidgetsApp.navigatorKey', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new WidgetsApp( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(WidgetsApp( navigatorKey: key, color: const Color(0xFF112233), onGenerateRoute: generateRoute, )); expect(key.currentState, isInstanceOf()); - await tester.pumpWidget(new WidgetsApp( + await tester.pumpWidget(WidgetsApp( color: const Color(0xFF112233), onGenerateRoute: generateRoute, )); expect(key.currentState, isNull); - await tester.pumpWidget(new WidgetsApp( + await tester.pumpWidget(WidgetsApp( navigatorKey: key, color: const Color(0xFF112233), onGenerateRoute: generateRoute, diff --git a/packages/flutter/test/widgets/app_overrides_test.dart b/packages/flutter/test/widgets/app_overrides_test.dart index f0f053e902..b6319c8e10 100644 --- a/packages/flutter/test/widgets/app_overrides_test.dart +++ b/packages/flutter/test/widgets/app_overrides_test.dart @@ -30,10 +30,10 @@ class TestRoute extends PageRoute { Future pumpApp(WidgetTester tester) async { await tester.pumpWidget( - new WidgetsApp( + WidgetsApp( color: const Color(0xFF333333), onGenerateRoute: (RouteSettings settings) { - return new TestRoute(settings: settings, child: new Container()); + return TestRoute(settings: settings, child: Container()); }, ), ); diff --git a/packages/flutter/test/widgets/app_title_test.dart b/packages/flutter/test/widgets/app_title_test.dart index 705142e1de..18b897250c 100644 --- a/packages/flutter/test/widgets/app_title_test.dart +++ b/packages/flutter/test/widgets/app_title_test.dart @@ -10,7 +10,7 @@ const String kTitleString = 'Hello World'; Future pumpApp(WidgetTester tester, { GenerateAppTitle onGenerateTitle }) async { await tester.pumpWidget( - new WidgetsApp( + WidgetsApp( supportedLocales: const [ Locale('en', 'US'), Locale('en', 'GB'), @@ -19,9 +19,9 @@ Future pumpApp(WidgetTester tester, { GenerateAppTitle onGenerateTitle }) color: kTitleColor, onGenerateTitle: onGenerateTitle, onGenerateRoute: (RouteSettings settings) { - return new PageRouteBuilder( + return PageRouteBuilder( pageBuilder: (BuildContext context, Animation animation, Animation secondaryAnimation) { - return new Container(); + return Container(); } ); }, diff --git a/packages/flutter/test/widgets/aspect_ratio_test.dart b/packages/flutter/test/widgets/aspect_ratio_test.dart index 2c64044b63..e9db7ce663 100644 --- a/packages/flutter/test/widgets/aspect_ratio_test.dart +++ b/packages/flutter/test/widgets/aspect_ratio_test.dart @@ -7,14 +7,14 @@ import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; Future _getSize(WidgetTester tester, BoxConstraints constraints, double aspectRatio) async { - final Key childKey = new UniqueKey(); + final Key childKey = UniqueKey(); await tester.pumpWidget( - new Center( - child: new ConstrainedBox( + Center( + child: ConstrainedBox( constraints: constraints, - child: new AspectRatio( + child: AspectRatio( aspectRatio: aspectRatio, - child: new Container( + child: Container( key: childKey ) ) @@ -27,20 +27,20 @@ Future _getSize(WidgetTester tester, BoxConstraints constraints, double as void main() { testWidgets('Aspect ratio control test', (WidgetTester tester) async { - expect(await _getSize(tester, new BoxConstraints.loose(const Size(500.0, 500.0)), 2.0), equals(const Size(500.0, 250.0))); - expect(await _getSize(tester, new BoxConstraints.loose(const Size(500.0, 500.0)), 0.5), equals(const Size(250.0, 500.0))); + expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 2.0), equals(const Size(500.0, 250.0))); + expect(await _getSize(tester, BoxConstraints.loose(const Size(500.0, 500.0)), 0.5), equals(const Size(250.0, 500.0))); }); testWidgets('Aspect ratio infinite width', (WidgetTester tester) async { - final Key childKey = new UniqueKey(); - await tester.pumpWidget(new Directionality( + final Key childKey = UniqueKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SingleChildScrollView( + child: Center( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: new AspectRatio( + child: AspectRatio( aspectRatio: 2.0, - child: new Container( + child: Container( key: childKey ) ) diff --git a/packages/flutter/test/widgets/async_lifecycle_test.dart b/packages/flutter/test/widgets/async_lifecycle_test.dart index a8870809ac..16d5528567 100644 --- a/packages/flutter/test/widgets/async_lifecycle_test.dart +++ b/packages/flutter/test/widgets/async_lifecycle_test.dart @@ -5,7 +5,7 @@ class InvalidOnInitLifecycleWidget extends StatefulWidget { const InvalidOnInitLifecycleWidget({Key key}) : super(key: key); @override - InvalidOnInitLifecycleWidgetState createState() => new InvalidOnInitLifecycleWidgetState(); + InvalidOnInitLifecycleWidgetState createState() => InvalidOnInitLifecycleWidgetState(); } class InvalidOnInitLifecycleWidgetState extends State { @@ -16,7 +16,7 @@ class InvalidOnInitLifecycleWidgetState extends State new InvalidDidUpdateWidgetLifecycleWidgetState(); + InvalidDidUpdateWidgetLifecycleWidgetState createState() => InvalidDidUpdateWidgetLifecycleWidgetState(); } class InvalidDidUpdateWidgetLifecycleWidgetState extends State { @@ -37,7 +37,7 @@ class InvalidDidUpdateWidgetLifecycleWidgetState extends State snapshot) { - return new Text(snapshot.toString(), textDirection: TextDirection.ltr); + return Text(snapshot.toString(), textDirection: TextDirection.ltr); } group('AsyncSnapshot', () { test('requiring data succeeds if data is present', () { @@ -33,47 +33,47 @@ void main() { }); group('Async smoke tests', () { testWidgets('FutureBuilder', (WidgetTester tester) async { - await tester.pumpWidget(new FutureBuilder( - future: new Future.value('hello'), + await tester.pumpWidget(FutureBuilder( + future: Future.value('hello'), builder: snapshotText )); await eventFiring(tester); }); testWidgets('StreamBuilder', (WidgetTester tester) async { - await tester.pumpWidget(new StreamBuilder( - stream: new Stream.fromIterable(['hello', 'world']), + await tester.pumpWidget(StreamBuilder( + stream: Stream.fromIterable(['hello', 'world']), builder: snapshotText )); await eventFiring(tester); }); testWidgets('StreamFold', (WidgetTester tester) async { - await tester.pumpWidget(new StringCollector( - stream: new Stream.fromIterable(['hello', 'world']) + await tester.pumpWidget(StringCollector( + stream: Stream.fromIterable(['hello', 'world']) )); await eventFiring(tester); }); }); group('FutureBuilder', () { testWidgets('gracefully handles transition from null future', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new FutureBuilder( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(FutureBuilder( key: key, future: null, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.none, null, null)'), findsOneWidget); - final Completer completer = new Completer(); - await tester.pumpWidget(new FutureBuilder( + final Completer completer = Completer(); + await tester.pumpWidget(FutureBuilder( key: key, future: completer.future, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); }); testWidgets('gracefully handles transition to null future', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final Completer completer = new Completer(); - await tester.pumpWidget(new FutureBuilder( + final GlobalKey key = GlobalKey(); + final Completer completer = Completer(); + await tester.pumpWidget(FutureBuilder( key: key, future: completer.future, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); - await tester.pumpWidget(new FutureBuilder( + await tester.pumpWidget(FutureBuilder( key: key, future: null, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.none, null, null)'), findsOneWidget); @@ -82,14 +82,14 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.none, null, null)'), findsOneWidget); }); testWidgets('gracefully handles transition to other future', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final Completer completerA = new Completer(); - final Completer completerB = new Completer(); - await tester.pumpWidget(new FutureBuilder( + final GlobalKey key = GlobalKey(); + final Completer completerA = Completer(); + final Completer completerB = Completer(); + await tester.pumpWidget(FutureBuilder( key: key, future: completerA.future, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); - await tester.pumpWidget(new FutureBuilder( + await tester.pumpWidget(FutureBuilder( key: key, future: completerB.future, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); @@ -99,8 +99,8 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.done, B, null)'), findsOneWidget); }); testWidgets('tracks life-cycle of Future to success', (WidgetTester tester) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new FutureBuilder( + final Completer completer = Completer(); + await tester.pumpWidget(FutureBuilder( future: completer.future, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); @@ -109,8 +109,8 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.done, hello, null)'), findsOneWidget); }); testWidgets('tracks life-cycle of Future to error', (WidgetTester tester) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new FutureBuilder( + final Completer completer = Completer(); + await tester.pumpWidget(FutureBuilder( future: completer.future, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); @@ -119,8 +119,8 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.done, null, bad)'), findsOneWidget); }); testWidgets('runs the builder using given initial data', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new FutureBuilder( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(FutureBuilder( key: key, future: null, builder: snapshotText, @@ -129,16 +129,16 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.none, I, null)'), findsOneWidget); }); testWidgets('ignores initialData when reconfiguring', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new FutureBuilder( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(FutureBuilder( key: key, future: null, builder: snapshotText, initialData: 'I', )); expect(find.text('AsyncSnapshot(ConnectionState.none, I, null)'), findsOneWidget); - final Completer completer = new Completer(); - await tester.pumpWidget(new FutureBuilder( + final Completer completer = Completer(); + await tester.pumpWidget(FutureBuilder( key: key, future: completer.future, builder: snapshotText, @@ -149,38 +149,38 @@ void main() { }); group('StreamBuilder', () { testWidgets('gracefully handles transition from null stream', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new StreamBuilder( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(StreamBuilder( key: key, stream: null, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.none, null, null)'), findsOneWidget); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StreamBuilder( + final StreamController controller = StreamController(); + await tester.pumpWidget(StreamBuilder( key: key, stream: controller.stream, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); }); testWidgets('gracefully handles transition to null stream', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StreamBuilder( + final GlobalKey key = GlobalKey(); + final StreamController controller = StreamController(); + await tester.pumpWidget(StreamBuilder( key: key, stream: controller.stream, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); - await tester.pumpWidget(new StreamBuilder( + await tester.pumpWidget(StreamBuilder( key: key, stream: null, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.none, null, null)'), findsOneWidget); }); testWidgets('gracefully handles transition to other stream', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final StreamController controllerA = new StreamController(); - final StreamController controllerB = new StreamController(); - await tester.pumpWidget(new StreamBuilder( + final GlobalKey key = GlobalKey(); + final StreamController controllerA = StreamController(); + final StreamController controllerB = StreamController(); + await tester.pumpWidget(StreamBuilder( key: key, stream: controllerA.stream, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); - await tester.pumpWidget(new StreamBuilder( + await tester.pumpWidget(StreamBuilder( key: key, stream: controllerB.stream, builder: snapshotText )); controllerB.add('B'); @@ -189,9 +189,9 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.active, B, null)'), findsOneWidget); }); testWidgets('tracks events and errors of stream until completion', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StreamBuilder( + final GlobalKey key = GlobalKey(); + final StreamController controller = StreamController(); + await tester.pumpWidget(StreamBuilder( key: key, stream: controller.stream, builder: snapshotText )); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsOneWidget); @@ -209,8 +209,8 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.done, 4, null)'), findsOneWidget); }); testWidgets('runs the builder using given initial data', (WidgetTester tester) async { - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StreamBuilder( + final StreamController controller = StreamController(); + await tester.pumpWidget(StreamBuilder( stream: controller.stream, builder: snapshotText, initialData: 'I', @@ -218,16 +218,16 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.waiting, I, null)'), findsOneWidget); }); testWidgets('ignores initialData when reconfiguring', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new StreamBuilder( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(StreamBuilder( key: key, stream: null, builder: snapshotText, initialData: 'I', )); expect(find.text('AsyncSnapshot(ConnectionState.none, I, null)'), findsOneWidget); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StreamBuilder( + final StreamController controller = StreamController(); + await tester.pumpWidget(StreamBuilder( key: key, stream: controller.stream, builder: snapshotText, @@ -238,10 +238,10 @@ void main() { }); group('FutureBuilder and StreamBuilder behave identically on Stream from Future', () { testWidgets('when completing with data', (WidgetTester tester) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new Column(children: [ - new FutureBuilder(future: completer.future, builder: snapshotText), - new StreamBuilder(stream: completer.future.asStream(), builder: snapshotText), + final Completer completer = Completer(); + await tester.pumpWidget(Column(children: [ + FutureBuilder(future: completer.future, builder: snapshotText), + StreamBuilder(stream: completer.future.asStream(), builder: snapshotText), ])); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsNWidgets(2)); completer.complete('hello'); @@ -249,10 +249,10 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.done, hello, null)'), findsNWidgets(2)); }); testWidgets('when completing with error', (WidgetTester tester) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new Column(children: [ - new FutureBuilder(future: completer.future, builder: snapshotText), - new StreamBuilder(stream: completer.future.asStream(), builder: snapshotText), + final Completer completer = Completer(); + await tester.pumpWidget(Column(children: [ + FutureBuilder(future: completer.future, builder: snapshotText), + StreamBuilder(stream: completer.future.asStream(), builder: snapshotText), ])); expect(find.text('AsyncSnapshot(ConnectionState.waiting, null, null)'), findsNWidgets(2)); completer.completeError('bad'); @@ -260,24 +260,24 @@ void main() { expect(find.text('AsyncSnapshot(ConnectionState.done, null, bad)'), findsNWidgets(2)); }); testWidgets('when Future is null', (WidgetTester tester) async { - await tester.pumpWidget(new Column(children: [ - new FutureBuilder(future: null, builder: snapshotText), - new StreamBuilder(stream: null, builder: snapshotText), + await tester.pumpWidget(Column(children: [ + FutureBuilder(future: null, builder: snapshotText), + StreamBuilder(stream: null, builder: snapshotText), ])); expect(find.text('AsyncSnapshot(ConnectionState.none, null, null)'), findsNWidgets(2)); }); testWidgets('when initialData is used with null Future and Stream', (WidgetTester tester) async { - await tester.pumpWidget(new Column(children: [ - new FutureBuilder(future: null, builder: snapshotText, initialData: 'I'), - new StreamBuilder(stream: null, builder: snapshotText, initialData: 'I'), + await tester.pumpWidget(Column(children: [ + FutureBuilder(future: null, builder: snapshotText, initialData: 'I'), + StreamBuilder(stream: null, builder: snapshotText, initialData: 'I'), ])); expect(find.text('AsyncSnapshot(ConnectionState.none, I, null)'), findsNWidgets(2)); }); testWidgets('when using initialData and completing with data', (WidgetTester tester) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new Column(children: [ - new FutureBuilder(future: completer.future, builder: snapshotText, initialData: 'I'), - new StreamBuilder(stream: completer.future.asStream(), builder: snapshotText, initialData: 'I'), + final Completer completer = Completer(); + await tester.pumpWidget(Column(children: [ + FutureBuilder(future: completer.future, builder: snapshotText, initialData: 'I'), + StreamBuilder(stream: completer.future.asStream(), builder: snapshotText, initialData: 'I'), ])); expect(find.text('AsyncSnapshot(ConnectionState.waiting, I, null)'), findsNWidgets(2)); completer.complete('hello'); @@ -287,36 +287,36 @@ void main() { }); group('StreamBuilderBase', () { testWidgets('gracefully handles transition from null stream', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new StringCollector(key: key, stream: null)); + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(StringCollector(key: key, stream: null)); expect(find.text(''), findsOneWidget); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StringCollector(key: key, stream: controller.stream)); + final StreamController controller = StreamController(); + await tester.pumpWidget(StringCollector(key: key, stream: controller.stream)); expect(find.text('conn'), findsOneWidget); }); testWidgets('gracefully handles transition to null stream', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StringCollector(key: key, stream: controller.stream)); + final GlobalKey key = GlobalKey(); + final StreamController controller = StreamController(); + await tester.pumpWidget(StringCollector(key: key, stream: controller.stream)); expect(find.text('conn'), findsOneWidget); - await tester.pumpWidget(new StringCollector(key: key, stream: null)); + await tester.pumpWidget(StringCollector(key: key, stream: null)); expect(find.text('conn, disc'), findsOneWidget); }); testWidgets('gracefully handles transition to other stream', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final StreamController controllerA = new StreamController(); - final StreamController controllerB = new StreamController(); - await tester.pumpWidget(new StringCollector(key: key, stream: controllerA.stream)); - await tester.pumpWidget(new StringCollector(key: key, stream: controllerB.stream)); + final GlobalKey key = GlobalKey(); + final StreamController controllerA = StreamController(); + final StreamController controllerB = StreamController(); + await tester.pumpWidget(StringCollector(key: key, stream: controllerA.stream)); + await tester.pumpWidget(StringCollector(key: key, stream: controllerB.stream)); controllerA.add('A'); controllerB.add('B'); await eventFiring(tester); expect(find.text('conn, disc, conn, data:B'), findsOneWidget); }); testWidgets('tracks events and errors until completion', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final StreamController controller = new StreamController(); - await tester.pumpWidget(new StringCollector(key: key, stream: controller.stream)); + final GlobalKey key = GlobalKey(); + final StreamController controller = StreamController(); + await tester.pumpWidget(StringCollector(key: key, stream: controller.stream)); controller.add('1'); controller.addError('bad'); controller.add('2'); @@ -353,5 +353,5 @@ class StringCollector extends StreamBuilderBase> { List afterDisconnected(List current) => current..add('disc'); @override - Widget build(BuildContext context, List currentSummary) => new Text(currentSummary.join(', '), textDirection: TextDirection.ltr); + Widget build(BuildContext context, List currentSummary) => Text(currentSummary.join(', '), textDirection: TextDirection.ltr); } diff --git a/packages/flutter/test/widgets/automatic_keep_alive_test.dart b/packages/flutter/test/widgets/automatic_keep_alive_test.dart index ecc8781d4e..69b0014206 100644 --- a/packages/flutter/test/widgets/automatic_keep_alive_test.dart +++ b/packages/flutter/test/widgets/automatic_keep_alive_test.dart @@ -9,7 +9,7 @@ class Leaf extends StatefulWidget { const Leaf({ Key key, this.child }) : super(key: key); final Widget child; @override - _LeafState createState() => new _LeafState(); + _LeafState createState() => _LeafState(); } class _LeafState extends State { @@ -27,8 +27,8 @@ class _LeafState extends State { _keepAlive = value; if (_keepAlive) { if (_handle == null) { - _handle = new KeepAliveHandle(); - new KeepAliveNotification(_handle).dispatch(context); + _handle = KeepAliveHandle(); + KeepAliveNotification(_handle).dispatch(context); } } else { _handle?.release(); @@ -39,24 +39,24 @@ class _LeafState extends State { @override Widget build(BuildContext context) { if (_keepAlive && _handle == null) { - _handle = new KeepAliveHandle(); - new KeepAliveNotification(_handle).dispatch(context); + _handle = KeepAliveHandle(); + KeepAliveNotification(_handle).dispatch(context); } return widget.child; } } List generateList(Widget child, { @required bool impliedMode }) { - return new List.generate( + return List.generate( 100, (int index) { - final Widget result = new Leaf( - key: new GlobalObjectKey<_LeafState>(index), + final Widget result = Leaf( + key: GlobalObjectKey<_LeafState>(index), child: child, ); if (impliedMode) return result; - return new AutomaticKeepAlive(child: result); + return AutomaticKeepAlive(child: result); }, growable: false, ); @@ -65,9 +65,9 @@ List generateList(Widget child, { @required bool impliedMode }) { void tests({ @required bool impliedMode }) { testWidgets('AutomaticKeepAlive with ListView with itemExtent', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: impliedMode, addRepaintBoundaries: impliedMode, itemExtent: 12.3, // about 50 widgets visible @@ -112,14 +112,14 @@ void tests({ @required bool impliedMode }) { testWidgets('AutomaticKeepAlive with ListView without itemExtent', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: impliedMode, addRepaintBoundaries: impliedMode, cacheExtent: 0.0, children: generateList( - new Container(height: 12.3, child: const Placeholder()), // about 50 widgets visible + Container(height: 12.3, child: const Placeholder()), // about 50 widgets visible impliedMode: impliedMode, ), ), @@ -161,16 +161,16 @@ void tests({ @required bool impliedMode }) { testWidgets('AutomaticKeepAlive with GridView', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( addAutomaticKeepAlives: impliedMode, addRepaintBoundaries: impliedMode, crossAxisCount: 2, childAspectRatio: 400.0 / 24.6, // about 50 widgets visible cacheExtent: 0.0, children: generateList( - new Container(child: const Placeholder()), + Container(child: const Placeholder()), impliedMode: impliedMode, ), ), @@ -217,30 +217,30 @@ void main() { testWidgets('AutomaticKeepAlive double', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: false, addRepaintBoundaries: false, cacheExtent: 0.0, children: [ - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(0), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(1), child: Placeholder()), ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( key: const GlobalObjectKey<_LeafState>(2), height: 400.0, ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( key: const GlobalObjectKey<_LeafState>(3), height: 400.0, ), @@ -300,35 +300,35 @@ void main() { testWidgets('AutomaticKeepAlive double 2', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: false, addRepaintBoundaries: false, cacheExtent: 0.0, children: [ - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(0), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(1), child: Placeholder()), ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(2), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(3), child: Placeholder()), ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(4), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(5), child: Placeholder()), ]), @@ -355,34 +355,34 @@ void main() { expect(find.byKey(const GlobalObjectKey<_LeafState>(3)), findsOneWidget); expect(find.byKey(const GlobalObjectKey<_LeafState>(4)), findsOneWidget); expect(find.byKey(const GlobalObjectKey<_LeafState>(5)), findsOneWidget); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: false, addRepaintBoundaries: false, cacheExtent: 0.0, children: [ - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(1), child: Placeholder()), ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(2), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(3), child: Placeholder()), ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(4), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(5), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(0), child: Placeholder()), @@ -418,33 +418,33 @@ void main() { expect(find.byKey(const GlobalObjectKey<_LeafState>(4), skipOffstage: false), findsNothing); expect(find.byKey(const GlobalObjectKey<_LeafState>(5), skipOffstage: false), findsNothing); expect(find.byKey(const GlobalObjectKey<_LeafState>(0), skipOffstage: false), findsNothing); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: false, addRepaintBoundaries: false, cacheExtent: 0.0, children: [ - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(1), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(2), child: Placeholder()), ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ ]), ), ), - new AutomaticKeepAlive( - child: new Container( + AutomaticKeepAlive( + child: Container( height: 400.0, - child: new Stack(children: const [ + child: Stack(children: const [ Leaf(key: GlobalObjectKey<_LeafState>(3), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(4), child: Placeholder()), Leaf(key: GlobalObjectKey<_LeafState>(5), child: Placeholder()), @@ -465,9 +465,9 @@ void main() { }); testWidgets('AutomaticKeepAlive with keepAlive set to true before initState', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemCount: 50, itemBuilder: (BuildContext context, int index){ if (index == 0){ @@ -475,9 +475,9 @@ void main() { key: GlobalObjectKey<_AlwaysKeepAliveState>(0), ); } - return new Container( + return Container( height: 44.0, - child: new Text('FooBar $index'), + child: Text('FooBar $index'), ); }, ), @@ -498,19 +498,19 @@ void main() { }); testWidgets('AutomaticKeepAlive with keepAlive set to true before initState and widget goes out of scope', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemCount: 250, itemBuilder: (BuildContext context, int index){ if (index % 2 == 0){ - return new _AlwaysKeepAlive( + return _AlwaysKeepAlive( key: GlobalObjectKey<_AlwaysKeepAliveState>(index), ); } - return new Container( + return Container( height: 44.0, - child: new Text('FooBar $index'), + child: Text('FooBar $index'), ); }, ), @@ -540,7 +540,7 @@ class _AlwaysKeepAlive extends StatefulWidget { const _AlwaysKeepAlive({Key key}) : super(key: key); @override - State createState() => new _AlwaysKeepAliveState(); + State createState() => _AlwaysKeepAliveState(); } class _AlwaysKeepAliveState extends State<_AlwaysKeepAlive> with AutomaticKeepAliveClientMixin<_AlwaysKeepAlive> { @@ -550,7 +550,7 @@ class _AlwaysKeepAliveState extends State<_AlwaysKeepAlive> with AutomaticKeepAl @override Widget build(BuildContext context) { super.build(context); - return new Container( + return Container( height: 48.0, child: const Text('keep me alive'), ); diff --git a/packages/flutter/test/widgets/banner_test.dart b/packages/flutter/test/widgets/banner_test.dart index a698135d3e..c11a6e09b6 100644 --- a/packages/flutter/test/widgets/banner_test.dart +++ b/packages/flutter/test/widgets/banner_test.dart @@ -24,14 +24,14 @@ void main() { // affect the layout. test('A Banner with a location of topStart paints in the top left (LTR)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.rtl, location: BannerLocation.topStart, layoutDirection: TextDirection.ltr, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -52,14 +52,14 @@ void main() { }); test('A Banner with a location of topStart paints in the top right (RTL)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.ltr, location: BannerLocation.topStart, layoutDirection: TextDirection.rtl, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -80,14 +80,14 @@ void main() { }); test('A Banner with a location of topEnd paints in the top right (LTR)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.ltr, location: BannerLocation.topEnd, layoutDirection: TextDirection.ltr, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -108,14 +108,14 @@ void main() { }); test('A Banner with a location of topEnd paints in the top left (RTL)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.rtl, location: BannerLocation.topEnd, layoutDirection: TextDirection.rtl, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -136,14 +136,14 @@ void main() { }); test('A Banner with a location of bottomStart paints in the bottom left (LTR)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.ltr, location: BannerLocation.bottomStart, layoutDirection: TextDirection.ltr, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -164,14 +164,14 @@ void main() { }); test('A Banner with a location of bottomStart paints in the bottom right (RTL)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.rtl, location: BannerLocation.bottomStart, layoutDirection: TextDirection.rtl, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -192,14 +192,14 @@ void main() { }); test('A Banner with a location of bottomEnd paints in the bottom right (LTR)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.rtl, location: BannerLocation.bottomEnd, layoutDirection: TextDirection.ltr, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -220,14 +220,14 @@ void main() { }); test('A Banner with a location of bottomEnd paints in the bottom left (RTL)', () { - final BannerPainter bannerPainter = new BannerPainter( + final BannerPainter bannerPainter = BannerPainter( message: 'foo', textDirection: TextDirection.ltr, location: BannerLocation.bottomEnd, layoutDirection: TextDirection.rtl, ); - final TestCanvas canvas = new TestCanvas(); + final TestCanvas canvas = TestCanvas(); bannerPainter.paint(canvas, const Size(1000.0, 1000.0)); @@ -259,8 +259,8 @@ void main() { ..save() ..translate(x: 800.0, y: 0.0) ..rotate(angle: math.pi / 4.0) - ..rect(rect: new Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0x7f000000), hasMaskFilter: true) - ..rect(rect: new Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0xa0b71c1c), hasMaskFilter: false) + ..rect(rect: Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0x7f000000), hasMaskFilter: true) + ..rect(rect: Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0xa0b71c1c), hasMaskFilter: false) ..paragraph(offset: const Offset(-40.0, 29.0)) ..restore() ); @@ -269,13 +269,13 @@ void main() { testWidgets('Banner widget in MaterialApp', (WidgetTester tester) async { debugDisableShadows = false; - await tester.pumpWidget(new MaterialApp(home: const Placeholder())); + await tester.pumpWidget(MaterialApp(home: const Placeholder())); expect(find.byType(CheckedModeBanner), paints ..save() ..translate(x: 800.0, y: 0.0) ..rotate(angle: math.pi / 4.0) - ..rect(rect: new Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0x7f000000), hasMaskFilter: true) - ..rect(rect: new Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0xa0b71c1c), hasMaskFilter: false) + ..rect(rect: Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0x7f000000), hasMaskFilter: true) + ..rect(rect: Rect.fromLTRB(-40.0, 28.0, 40.0, 40.0), color: const Color(0xa0b71c1c), hasMaskFilter: false) ..paragraph(offset: const Offset(-40.0, 29.0)) ..restore() ); diff --git a/packages/flutter/test/widgets/baseline_test.dart b/packages/flutter/test/widgets/baseline_test.dart index 8b7abba692..1af069b77d 100644 --- a/packages/flutter/test/widgets/baseline_test.dart +++ b/packages/flutter/test/widgets/baseline_test.dart @@ -45,13 +45,13 @@ void main() { testWidgets('Chip caches baseline', (WidgetTester tester) async { int calls = 0; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Baseline( + MaterialApp( + home: Material( + child: Baseline( baseline: 100.0, baselineType: TextBaseline.alphabetic, - child: new Chip( - label: new BaselineDetector(() { + child: Chip( + label: BaselineDetector(() { calls += 1; }), ), @@ -70,13 +70,13 @@ void main() { testWidgets('ListTile caches baseline', (WidgetTester tester) async { int calls = 0; await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Baseline( + MaterialApp( + home: Material( + child: Baseline( baseline: 100.0, baselineType: TextBaseline.alphabetic, - child: new ListTile( - title: new BaselineDetector(() { + child: ListTile( + title: BaselineDetector(() { calls += 1; }), ), @@ -99,7 +99,7 @@ class BaselineDetector extends LeafRenderObjectWidget { final VoidCallback callback; @override - RenderBaselineDetector createRenderObject(BuildContext context) => new RenderBaselineDetector(callback); + RenderBaselineDetector createRenderObject(BuildContext context) => RenderBaselineDetector(callback); @override void updateRenderObject(BuildContext context, RenderBaselineDetector renderObject) { diff --git a/packages/flutter/test/widgets/basic_test.dart b/packages/flutter/test/widgets/basic_test.dart index 4e3df9c94a..95d491a384 100644 --- a/packages/flutter/test/widgets/basic_test.dart +++ b/packages/flutter/test/widgets/basic_test.dart @@ -27,12 +27,12 @@ void main() { testWidgets('hit test', (WidgetTester tester) async { await tester.pumpWidget( - new PhysicalShape( + PhysicalShape( clipper: const ShapeBorderClipper(shape: CircleBorder()), elevation: 2.0, color: const Color(0xFF0000FF), shadowColor: const Color(0xFF00FF00), - child: new Container(color: const Color(0xFF0000FF)), + child: Container(color: const Color(0xFF0000FF)), ) ); @@ -56,23 +56,23 @@ void main() { group('FractionalTranslation', () { testWidgets('hit test - entirely inside the bounding box', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); bool _pointerDown = false; await tester.pumpWidget( - new Center( - child: new FractionalTranslation( + Center( + child: FractionalTranslation( translation: Offset.zero, transformHitTests: true, - child: new Listener( + child: Listener( onPointerDown: (PointerDownEvent event) { _pointerDown = true; }, - child: new SizedBox( + child: SizedBox( key: key1, width: 100.0, height: 100.0, - child: new Container( + child: Container( color: const Color(0xFF0000FF) ), ), @@ -86,23 +86,23 @@ void main() { }); testWidgets('hit test - partially inside the bounding box', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); bool _pointerDown = false; await tester.pumpWidget( - new Center( - child: new FractionalTranslation( + Center( + child: FractionalTranslation( translation: const Offset(0.5, 0.5), transformHitTests: true, - child: new Listener( + child: Listener( onPointerDown: (PointerDownEvent event) { _pointerDown = true; }, - child: new SizedBox( + child: SizedBox( key: key1, width: 100.0, height: 100.0, - child: new Container( + child: Container( color: const Color(0xFF0000FF) ), ), @@ -116,23 +116,23 @@ void main() { }); testWidgets('hit test - completely outside the bounding box', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); bool _pointerDown = false; await tester.pumpWidget( - new Center( - child: new FractionalTranslation( + Center( + child: FractionalTranslation( translation: const Offset(1.0, 1.0), transformHitTests: true, - child: new Listener( + child: Listener( onPointerDown: (PointerDownEvent event) { _pointerDown = true; }, - child: new SizedBox( + child: SizedBox( key: key1, width: 100.0, height: 100.0, - child: new Container( + child: Container( color: const Color(0xFF0000FF) ), ), @@ -147,7 +147,7 @@ void main() { }); } -HitsRenderBox hits(RenderBox renderBox) => new HitsRenderBox(renderBox); +HitsRenderBox hits(RenderBox renderBox) => HitsRenderBox(renderBox); class HitsRenderBox extends Matcher { const HitsRenderBox(this.renderBox); @@ -167,7 +167,7 @@ class HitsRenderBox extends Matcher { } } -DoesNotHitRenderBox doesNotHit(RenderBox renderBox) => new DoesNotHitRenderBox(renderBox); +DoesNotHitRenderBox doesNotHit(RenderBox renderBox) => DoesNotHitRenderBox(renderBox); class DoesNotHitRenderBox extends Matcher { const DoesNotHitRenderBox(this.renderBox); diff --git a/packages/flutter/test/widgets/binding_test.dart b/packages/flutter/test/widgets/binding_test.dart index 907be29576..d1abbe8369 100644 --- a/packages/flutter/test/widgets/binding_test.dart +++ b/packages/flutter/test/widgets/binding_test.dart @@ -42,7 +42,7 @@ void main() { }); testWidgets('didHaveMemoryPressure callback', (WidgetTester tester) async { - final MemoryPressureObserver observer = new MemoryPressureObserver(); + final MemoryPressureObserver observer = MemoryPressureObserver(); WidgetsBinding.instance.addObserver(observer); final ByteData message = const JSONMessageCodec().encodeMessage( {'type': 'memoryPressure'}); @@ -52,7 +52,7 @@ void main() { }); testWidgets('handleLifecycleStateChanged callback', (WidgetTester tester) async { - final AppLifecycleStateObserver observer = new AppLifecycleStateObserver(); + final AppLifecycleStateObserver observer = AppLifecycleStateObserver(); WidgetsBinding.instance.addObserver(observer); ByteData message = const StringCodec().encodeMessage('AppLifecycleState.paused'); @@ -73,7 +73,7 @@ void main() { }); testWidgets('didPushRoute callback', (WidgetTester tester) async { - final PushRouteObserver observer = new PushRouteObserver(); + final PushRouteObserver observer = PushRouteObserver(); WidgetsBinding.instance.addObserver(observer); const String testRouteName = 'testRouteName'; diff --git a/packages/flutter/test/widgets/box_decoration_test.dart b/packages/flutter/test/widgets/box_decoration_test.dart index 5f4b15e493..c3d4eafc4d 100644 --- a/packages/flutter/test/widgets/box_decoration_test.dart +++ b/packages/flutter/test/widgets/box_decoration_test.dart @@ -24,30 +24,30 @@ class TestImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(TestImageProvider key) { - return new OneFrameImageStreamCompleter( - future.then((Null value) => new ImageInfo(image: image)) + return OneFrameImageStreamCompleter( + future.then((Null value) => ImageInfo(image: image)) ); } } Future main() async { - TestImageProvider.image = await decodeImageFromList(new Uint8List.fromList(kTransparentImage)); + TestImageProvider.image = await decodeImageFromList(Uint8List.fromList(kTransparentImage)); testWidgets('DecoratedBox handles loading images', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final Completer completer = new Completer(); + final GlobalKey key = GlobalKey(); + final Completer completer = Completer(); await tester.pumpWidget( - new KeyedSubtree( + KeyedSubtree( key: key, - child: new DecoratedBox( - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(completer.future), + child: DecoratedBox( + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(completer.future), ), ), ), @@ -62,14 +62,14 @@ Future main() async { }); testWidgets('Moving a DecoratedBox', (WidgetTester tester) async { - final Completer completer = new Completer(); - final Widget subtree = new KeyedSubtree( - key: new GlobalKey(), - child: new RepaintBoundary( - child: new DecoratedBox( - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(completer.future), + final Completer completer = Completer(); + final Widget subtree = KeyedSubtree( + key: GlobalKey(), + child: RepaintBoundary( + child: DecoratedBox( + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(completer.future), ), ), ), @@ -78,7 +78,7 @@ Future main() async { await tester.pumpWidget(subtree); await tester.idle(); expect(tester.binding.hasScheduledFrame, isFalse); - await tester.pumpWidget(new Container(child: subtree)); + await tester.pumpWidget(Container(child: subtree)); await tester.idle(); expect(tester.binding.hasScheduledFrame, isFalse); completer.complete(); // schedules microtask, does not run it @@ -92,11 +92,11 @@ Future main() async { testWidgets('Circles can have uniform borders', (WidgetTester tester) async { await tester.pumpWidget( - new Container( + Container( padding: const EdgeInsets.all(50.0), - decoration: new BoxDecoration( + decoration: BoxDecoration( shape: BoxShape.circle, - border: new Border.all(width: 10.0, color: const Color(0x80FF00FF)), + border: Border.all(width: 10.0, color: const Color(0x80FF00FF)), color: Colors.teal[600] ) ) @@ -106,11 +106,11 @@ Future main() async { testWidgets('Bordered Container insets its child', (WidgetTester tester) async { const Key key = Key('outerContainer'); await tester.pumpWidget( - new Center( - child: new Container( + Center( + child: Container( key: key, - decoration: new BoxDecoration(border: new Border.all(width: 10.0)), - child: new Container( + decoration: BoxDecoration(border: Border.all(width: 10.0)), + child: Container( width: 25.0, height: 25.0 ) @@ -125,23 +125,23 @@ Future main() async { const Key key = Key('Container with BoxDecoration'); Widget buildFrame(Border border) { - return new Center( - child: new Container( + return Center( + child: Container( key: key, width: 100.0, height: 50.0, - decoration: new BoxDecoration(border: border), + decoration: BoxDecoration(border: border), ), ); } const Color black = Color(0xFF000000); - await tester.pumpWidget(buildFrame(new Border.all())); + await tester.pumpWidget(buildFrame(Border.all())); expect(find.byKey(key), paints ..rect(color: black, style: PaintingStyle.stroke, strokeWidth: 1.0)); - await tester.pumpWidget(buildFrame(new Border.all(width: 0.0))); + await tester.pumpWidget(buildFrame(Border.all(width: 0.0))); expect(find.byKey(key), paints ..rect(color: black, style: PaintingStyle.stroke, strokeWidth: 0.0)); @@ -173,9 +173,9 @@ Future main() async { testWidgets('BoxDecoration paints its border correctly', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/12165 await tester.pumpWidget( - new Column( + Column( children: [ - new Container( + Container( // There's not currently a way to verify that this paints the same size as the others, // so the pattern below just asserts that there's four paths but doesn't check the geometry. width: 100.0, @@ -201,21 +201,21 @@ Future main() async { ), ), ), - new Container( + Container( width: 100.0, height: 100.0, - decoration: new BoxDecoration( - border: new Border.all( + decoration: BoxDecoration( + border: Border.all( width: 10.0, color: const Color(0xFFFFFFFF), ), ), ), - new Container( + Container( width: 100.0, height: 100.0, - decoration: new BoxDecoration( - border: new Border.all( + decoration: BoxDecoration( + border: Border.all( width: 10.0, color: const Color(0xFFFFFFFF), ), @@ -224,11 +224,11 @@ Future main() async { ), ), ), - new Container( + Container( width: 100.0, height: 100.0, - decoration: new BoxDecoration( - border: new Border.all( + decoration: BoxDecoration( + border: Border.all( width: 10.0, color: const Color(0xFFFFFFFF), ), @@ -243,16 +243,16 @@ Future main() async { ..path() ..path() ..path() - ..rect(rect: new Rect.fromLTRB(355.0, 105.0, 445.0, 195.0)) + ..rect(rect: Rect.fromLTRB(355.0, 105.0, 445.0, 195.0)) ..drrect( - outer: new RRect.fromLTRBAndCorners( + outer: RRect.fromLTRBAndCorners( 350.0, 200.0, 450.0, 300.0, topLeft: Radius.zero, topRight: const Radius.circular(10.0), bottomRight: Radius.zero, bottomLeft: Radius.zero, ), - inner: new RRect.fromLTRBAndCorners( + inner: RRect.fromLTRBAndCorners( 360.0, 210.0, 440.0, 290.0, topLeft: const Radius.circular(-10.0), topRight: Radius.zero, @@ -271,14 +271,14 @@ Future main() async { const Key key = Key('Container with BoxDecoration'); Widget buildFrame(Border border) { itemsTapped = []; - return new Center( - child: new GestureDetector( + return Center( + child: GestureDetector( behavior: HitTestBehavior.deferToChild, - child: new Container( + child: Container( key: key, width: 100.0, height: 50.0, - decoration: new BoxDecoration(border: border), + decoration: BoxDecoration(border: border), ), onTap: () { itemsTapped.add(1); @@ -287,7 +287,7 @@ Future main() async { ); } - await tester.pumpWidget(buildFrame(new Border.all())); + await tester.pumpWidget(buildFrame(Border.all())); expect(itemsTapped, isEmpty); await tester.tap(find.byKey(key)); @@ -308,14 +308,14 @@ Future main() async { const Key key = Key('Container with BoxDecoration'); Widget buildFrame(Border border) { itemsTapped = []; - return new Center( - child: new GestureDetector( + return Center( + child: GestureDetector( behavior: HitTestBehavior.deferToChild, - child: new Container( + child: Container( key: key, width: 100.0, height: 50.0, - decoration: new BoxDecoration(border: border, shape: BoxShape.circle), + decoration: BoxDecoration(border: border, shape: BoxShape.circle), ), onTap: () { itemsTapped.add(1); @@ -324,7 +324,7 @@ Future main() async { ); } - await tester.pumpWidget(buildFrame(new Border.all())); + await tester.pumpWidget(buildFrame(Border.all())); expect(itemsTapped, isEmpty); await tester.tapAt(const Offset(0.0, 0.0)); diff --git a/packages/flutter/test/widgets/box_sliver_mismatch_test.dart b/packages/flutter/test/widgets/box_sliver_mismatch_test.dart index 7f5dc40dc6..fe93c90ea9 100644 --- a/packages/flutter/test/widgets/box_sliver_mismatch_test.dart +++ b/packages/flutter/test/widgets/box_sliver_mismatch_test.dart @@ -20,7 +20,7 @@ void main() { expect(tester.takeException(), isFlutterError); await tester.pumpWidget( - new Row( + Row( children: const [ SliverList( delegate: SliverChildListDelegate([]), @@ -34,9 +34,9 @@ void main() { testWidgets('Box in a sliver', (WidgetTester tester) async { await tester.pumpWidget( - new Viewport( + Viewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), slivers: const [ SizedBox(), ], @@ -46,9 +46,9 @@ void main() { expect(tester.takeException(), isFlutterError); await tester.pumpWidget( - new Viewport( + Viewport( crossAxisDirection: AxisDirection.right, - offset: new ViewportOffset.zero(), + offset: ViewportOffset.zero(), slivers: const [ SliverPadding( padding: EdgeInsets.zero, diff --git a/packages/flutter/test/widgets/build_scope_test.dart b/packages/flutter/test/widgets/build_scope_test.dart index 1d506f7912..c1407d76e9 100644 --- a/packages/flutter/test/widgets/build_scope_test.dart +++ b/packages/flutter/test/widgets/build_scope_test.dart @@ -9,7 +9,7 @@ import 'test_widgets.dart'; class ProbeWidget extends StatefulWidget { @override - ProbeWidgetState createState() => new ProbeWidgetState(); + ProbeWidgetState createState() => ProbeWidgetState(); } class ProbeWidgetState extends State { @@ -31,7 +31,7 @@ class ProbeWidgetState extends State { Widget build(BuildContext context) { setState(() {}); buildCount++; - return new Container(); + return Container(); } } @@ -43,13 +43,13 @@ class BadWidget extends StatelessWidget { @override Widget build(BuildContext context) { parentState._markNeedsBuild(); - return new Container(); + return Container(); } } class BadWidgetParent extends StatefulWidget { @override - BadWidgetParentState createState() => new BadWidgetParentState(); + BadWidgetParentState createState() => BadWidgetParentState(); } class BadWidgetParentState extends State { @@ -62,19 +62,19 @@ class BadWidgetParentState extends State { @override Widget build(BuildContext context) { - return new BadWidget(this); + return BadWidget(this); } } class BadDisposeWidget extends StatefulWidget { @override - BadDisposeWidgetState createState() => new BadDisposeWidgetState(); + BadDisposeWidgetState createState() => BadDisposeWidgetState(); } class BadDisposeWidgetState extends State { @override Widget build(BuildContext context) { - return new Container(); + return Container(); } @override @@ -93,7 +93,7 @@ class StatefulWrapper extends StatefulWidget { final Widget child; @override - StatefulWrapperState createState() => new StatefulWrapperState(); + StatefulWrapperState createState() => StatefulWrapperState(); } class StatefulWrapperState extends State { @@ -131,16 +131,16 @@ class Wrapper extends StatelessWidget { void main() { testWidgets('Legal times for setState', (WidgetTester tester) async { - final GlobalKey flipKey = new GlobalKey(); + final GlobalKey flipKey = GlobalKey(); expect(ProbeWidgetState.buildCount, equals(0)); - await tester.pumpWidget(new ProbeWidget()); + await tester.pumpWidget(ProbeWidget()); expect(ProbeWidgetState.buildCount, equals(1)); - await tester.pumpWidget(new ProbeWidget()); + await tester.pumpWidget(ProbeWidget()); expect(ProbeWidgetState.buildCount, equals(2)); - await tester.pumpWidget(new FlipWidget( + await tester.pumpWidget(FlipWidget( key: flipKey, - left: new Container(), - right: new ProbeWidget() + left: Container(), + right: ProbeWidget() )); expect(ProbeWidgetState.buildCount, equals(2)); final FlipWidgetState flipState1 = flipKey.currentState; @@ -151,26 +151,26 @@ void main() { flipState2.flip(); await tester.pump(); expect(ProbeWidgetState.buildCount, equals(3)); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(ProbeWidgetState.buildCount, equals(3)); }); testWidgets('Setting parent state during build is forbidden', (WidgetTester tester) async { - await tester.pumpWidget(new BadWidgetParent()); + await tester.pumpWidget(BadWidgetParent()); expect(tester.takeException(), isFlutterError); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); }); testWidgets('Setting state during dispose is forbidden', (WidgetTester tester) async { - await tester.pumpWidget(new BadDisposeWidget()); + await tester.pumpWidget(BadDisposeWidget()); expect(tester.takeException(), isNull); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(tester.takeException(), isNotNull); }); testWidgets('Dirty element list sort order', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(debugLabel: 'key1'); - final GlobalKey key2 = new GlobalKey(debugLabel: 'key2'); + final GlobalKey key1 = GlobalKey(debugLabel: 'key1'); + final GlobalKey key2 = GlobalKey(debugLabel: 'key2'); bool didMiddle = false; Widget middle; @@ -179,26 +179,26 @@ void main() { setStates.add(setState); final bool returnMiddle = !didMiddle; didMiddle = true; - return new Wrapper( - child: new Wrapper( - child: new StatefulWrapper( - child: returnMiddle ? middle : new Container(), + return Wrapper( + child: Wrapper( + child: StatefulWrapper( + child: returnMiddle ? middle : Container(), ), ), ); } - final Widget part1 = new Wrapper( - child: new KeyedSubtree( + final Widget part1 = Wrapper( + child: KeyedSubtree( key: key1, - child: new StatefulBuilder( + child: StatefulBuilder( builder: builder, ), ), ); - final Widget part2 = new Wrapper( - child: new KeyedSubtree( + final Widget part2 = Wrapper( + child: KeyedSubtree( key: key2, - child: new StatefulBuilder( + child: StatefulBuilder( builder: builder, ), ), diff --git a/packages/flutter/test/widgets/center_test.dart b/packages/flutter/test/widgets/center_test.dart index f2d8677301..47e9766887 100644 --- a/packages/flutter/test/widgets/center_test.dart +++ b/packages/flutter/test/widgets/center_test.dart @@ -8,9 +8,9 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Can be placed in an infinite box', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: const [Center()]) + child: ListView(children: const [Center()]) ), ); }); diff --git a/packages/flutter/test/widgets/clamp_overscrolls_test.dart b/packages/flutter/test/widgets/clamp_overscrolls_test.dart index d365ad38ec..83f8b426ee 100644 --- a/packages/flutter/test/widgets/clamp_overscrolls_test.dart +++ b/packages/flutter/test/widgets/clamp_overscrolls_test.dart @@ -12,17 +12,17 @@ import 'package:flutter/widgets.dart'; // is at 0). The top of the bottom widget is 500 when it has been // scrolled completely into view. Widget buildFrame(ScrollPhysics physics) { - return new SingleChildScrollView( - key: new UniqueKey(), + return SingleChildScrollView( + key: UniqueKey(), physics: physics, - child: new SizedBox( + child: SizedBox( height: 650.0, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, textDirection: TextDirection.ltr, children: [ const SizedBox(height: 100.0, child: Text('top', textDirection: TextDirection.ltr)), - new Expanded(child: new Container()), + Expanded(child: Container()), const SizedBox(height: 100.0, child: Text('bottom', textDirection: TextDirection.ltr)), ], ), @@ -41,7 +41,7 @@ void main() { final RenderBox textBox = tester.renderObject(find.text(target)); final Offset widgetOrigin = textBox.localToGlobal(Offset.zero); await tester.pump(const Duration(seconds: 1)); // Allow overscroll to settle - return new Future.value(widgetOrigin); + return Future.value(widgetOrigin); } await tester.pumpWidget(buildFrame(const BouncingScrollPhysics())); diff --git a/packages/flutter/test/widgets/clip_test.dart b/packages/flutter/test/widgets/clip_test.dart index 544e63de31..30c5646db6 100644 --- a/packages/flutter/test/widgets/clip_test.dart +++ b/packages/flutter/test/widgets/clip_test.dart @@ -14,8 +14,8 @@ class PathClipper extends CustomClipper { @override Path getClip(Size size) { log.add('getClip'); - return new Path() - ..addRect(new Rect.fromLTWH(50.0, 50.0, 100.0, 100.0)); + return Path() + ..addRect(Rect.fromLTWH(50.0, 50.0, 100.0, 100.0)); } @override bool shouldReclip(PathClipper oldClipper) => false; @@ -42,9 +42,9 @@ class ValueClipper extends CustomClipper { void main() { testWidgets('ClipPath', (WidgetTester tester) async { await tester.pumpWidget( - new ClipPath( - clipper: new PathClipper(), - child: new GestureDetector( + ClipPath( + clipper: PathClipper(), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -63,8 +63,8 @@ void main() { testWidgets('ClipOval', (WidgetTester tester) async { await tester.pumpWidget( - new ClipOval( - child: new GestureDetector( + ClipOval( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -83,10 +83,10 @@ void main() { testWidgets('Transparent ClipOval hit test', (WidgetTester tester) async { await tester.pumpWidget( - new Opacity( + Opacity( opacity: 0.0, - child: new ClipOval( - child: new GestureDetector( + child: ClipOval( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -106,14 +106,14 @@ void main() { testWidgets('ClipRect', (WidgetTester tester) async { await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 100.0, height: 100.0, - child: new ClipRect( - clipper: new ValueClipper('a', new Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), - child: new GestureDetector( + child: ClipRect( + clipper: ValueClipper('a', Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -130,14 +130,14 @@ void main() { expect(log, equals(['a', 'tap'])); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 100.0, height: 100.0, - child: new ClipRect( - clipper: new ValueClipper('a', new Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), - child: new GestureDetector( + child: ClipRect( + clipper: ValueClipper('a', Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -148,14 +148,14 @@ void main() { expect(log, equals(['a', 'tap'])); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 200.0, height: 200.0, - child: new ClipRect( - clipper: new ValueClipper('a', new Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), - child: new GestureDetector( + child: ClipRect( + clipper: ValueClipper('a', Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -166,14 +166,14 @@ void main() { expect(log, equals(['a', 'tap', 'a'])); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 200.0, height: 200.0, - child: new ClipRect( - clipper: new ValueClipper('a', new Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), - child: new GestureDetector( + child: ClipRect( + clipper: ValueClipper('a', Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -184,14 +184,14 @@ void main() { expect(log, equals(['a', 'tap', 'a'])); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 200.0, height: 200.0, - child: new ClipRect( - clipper: new ValueClipper('b', new Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), - child: new GestureDetector( + child: ClipRect( + clipper: ValueClipper('b', Rect.fromLTWH(5.0, 5.0, 10.0, 10.0)), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -202,14 +202,14 @@ void main() { expect(log, equals(['a', 'tap', 'a', 'b'])); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new SizedBox( + child: SizedBox( width: 200.0, height: 200.0, - child: new ClipRect( - clipper: new ValueClipper('c', new Rect.fromLTWH(25.0, 25.0, 10.0, 10.0)), - child: new GestureDetector( + child: ClipRect( + clipper: ValueClipper('c', Rect.fromLTWH(25.0, 25.0, 10.0, 10.0)), + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('tap'); }, ) @@ -234,7 +234,7 @@ void main() { ); expect(tester.renderObject(find.byType(ClipRect)).paint, paints ..save() - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0)) ..save() ..path() // Placeholder ..restore() @@ -242,7 +242,7 @@ void main() { ); debugPaintSizeEnabled = true; expect(tester.renderObject(find.byType(ClipRect)).debugPaint, paints // ignore: INVALID_USE_OF_PROTECTED_MEMBER - ..rect(rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0)) + ..rect(rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0)) ..paragraph() ); debugPaintSizeEnabled = false; @@ -250,25 +250,25 @@ void main() { testWidgets('ClipRect painting', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new ClipRect( - child: new Container( + child: ClipRect( + child: Container( color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -293,30 +293,30 @@ void main() { testWidgets('ClipRect save, overlay, and antialiasing', (WidgetTester tester) async { await tester.pumpWidget( - new RepaintBoundary( - child: new Stack( + RepaintBoundary( + child: Stack( textDirection: TextDirection.ltr, children: [ - new Positioned( + Positioned( top: 0.0, left: 0.0, width: 100.0, height: 100.0, - child: new ClipRect( - child: new Container( + child: ClipRect( + child: Container( color: Colors.blue, ), clipBehavior: Clip.hardEdge, ), ), - new Positioned( + Positioned( top: 50.0, left: 50.0, width: 100.0, height: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, - child: new Container( + child: Container( color: Colors.red, ), ), @@ -333,31 +333,31 @@ void main() { testWidgets('ClipRRect painting', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new ClipRRect( + child: ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.elliptical(10.0, 20.0), topRight: Radius.elliptical(5.0, 30.0), bottomLeft: Radius.elliptical(2.5, 12.0), bottomRight: Radius.elliptical(15.0, 6.0), ), - child: new Container( + child: Container( color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -382,25 +382,25 @@ void main() { testWidgets('ClipOval painting', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new ClipOval( - child: new Container( + child: ClipOval( + child: Container( color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -425,30 +425,30 @@ void main() { testWidgets('ClipPath painting', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new ClipPath( - clipper: new ShapeBorderClipper( - shape: new BeveledRectangleBorder( - borderRadius: new BorderRadius.circular(20.0), + child: ClipPath( + clipper: ShapeBorderClipper( + shape: BeveledRectangleBorder( + borderRadius: BorderRadius.circular(20.0), ), ), - child: new Container( + child: Container( color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -472,26 +472,26 @@ void main() { }); Center genPhysicalModel(Clip clipBehavior) { - return new Center( - child: new RepaintBoundary( - child: new Container( + return Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new PhysicalModel( - borderRadius: new BorderRadius.circular(20.0), + child: PhysicalModel( + borderRadius: BorderRadius.circular(20.0), color: Colors.red, clipBehavior: clipBehavior, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -536,25 +536,25 @@ void main() { testWidgets('Default PhysicalModel painting', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new PhysicalModel( - borderRadius: new BorderRadius.circular(20.0), + child: PhysicalModel( + borderRadius: BorderRadius.circular(20.0), color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -577,30 +577,30 @@ void main() { }); Center genPhysicalShape(Clip clipBehavior) { - return new Center( - child: new RepaintBoundary( - child: new Container( + return Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new PhysicalShape( - clipper: new ShapeBorderClipper( - shape: new BeveledRectangleBorder( - borderRadius: new BorderRadius.circular(20.0), + child: PhysicalShape( + clipper: ShapeBorderClipper( + shape: BeveledRectangleBorder( + borderRadius: BorderRadius.circular(20.0), ), ), clipBehavior: clipBehavior, color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -643,29 +643,29 @@ void main() { testWidgets('PhysicalShape painting', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( color: Colors.white, - child: new Padding( + child: Padding( padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new PhysicalShape( - clipper: new ShapeBorderClipper( - shape: new BeveledRectangleBorder( - borderRadius: new BorderRadius.circular(20.0), + child: PhysicalShape( + clipper: ShapeBorderClipper( + shape: BeveledRectangleBorder( + borderRadius: BorderRadius.circular(20.0), ), ), color: Colors.red, - child: new Container( + child: Container( color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, diff --git a/packages/flutter/test/widgets/column_test.dart b/packages/flutter/test/widgets/column_test.dart index 49ab3b4634..18168cf095 100644 --- a/packages/flutter/test/widgets/column_test.dart +++ b/packages/flutter/test/widgets/column_test.dart @@ -18,13 +18,13 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisAlignment.start so children so the children's // top edges should be at 0, 100, 500, child2's height should be 400. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0)), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0)), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -64,13 +64,13 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisAlignment.start so children so the children's // top edges should be at 0, 100, 200 - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -108,13 +108,13 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's top edges should be at 200, 300 - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), ] ) )); @@ -147,14 +147,14 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's top edges should be at 300, 400, 500. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.end, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -193,14 +193,14 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's top edges should be at 0, 250, 500 - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -240,15 +240,15 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's top edges should be at 25, 175, 325, 475 - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), - new Container(key: child3Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child3Key, width: 100.0, height: 100.0), ] ) )); @@ -293,14 +293,14 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x20 children's top edges should be at 135, 290, 445 - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new Container(key: child0Key, width: 100.0, height: 20.0), - new Container(key: child1Key, width: 100.0, height: 20.0), - new Container(key: child2Key, width: 100.0, height: 20.0), + Container(key: child0Key, width: 100.0, height: 20.0), + Container(key: child1Key, width: 100.0, height: 20.0), + Container(key: child2Key, width: 100.0, height: 20.0), ] ) )); @@ -335,12 +335,12 @@ void main() { const Key flexKey = Key('flexKey'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: flexKey, children: [ - new Container(width: 100.0, height: 100.0), - new Container(width: 100.0, height: 150.0) + Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 150.0) ] ) )); @@ -349,13 +349,13 @@ void main() { expect(renderBox.size.height, equals(600.0)); // Column with MainAxisSize.min without flexible children shrink wraps. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: flexKey, mainAxisSize: MainAxisSize.min, children: [ - new Container(width: 100.0, height: 100.0), - new Container(width: 100.0, height: 150.0) + Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 150.0) ] ) )); @@ -367,14 +367,14 @@ void main() { testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { const Key childKey = Key('childKey'); - await tester.pumpWidget(new Center( - child: new Container( + await tester.pumpWidget(Center( + child: Container( width: 0.0, height: 0.0, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, children: [ - new Container( + Container( key: childKey, width: 100.0, height: 100.0 @@ -401,14 +401,14 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisAlignment.start so children so the children's // bottom edges should be at 0, 100, 500 from bottom, child2's height should be 400. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0)), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0)), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -448,14 +448,14 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // Default is MainAxisAlignment.start so children so the children's // bottom edges should be at 0, 100, 200 from bottom - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -493,14 +493,14 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 200, 300 from bottom - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.center, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), ] ) )); @@ -533,15 +533,15 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 300, 400, 500 from bottom. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.end, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -580,15 +580,15 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 0, 250, 500 from bottom - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), ] ) )); @@ -628,16 +628,16 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x100 children's bottom edges should be at 25, 175, 325, 475 from bottom - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceAround, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0), - new Container(key: child1Key, width: 100.0, height: 100.0), - new Container(key: child2Key, width: 100.0, height: 100.0), - new Container(key: child3Key, width: 100.0, height: 100.0), + Container(key: child0Key, width: 100.0, height: 100.0), + Container(key: child1Key, width: 100.0, height: 100.0), + Container(key: child2Key, width: 100.0, height: 100.0), + Container(key: child3Key, width: 100.0, height: 100.0), ] ) )); @@ -682,15 +682,15 @@ void main() { // Default is MainAxisSize.max so the Column should be as high as the test: 600. // The 100x20 children's bottom edges should be at 135, 290, 445 from bottom - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: columnKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, verticalDirection: VerticalDirection.up, children: [ - new Container(key: child0Key, width: 100.0, height: 20.0), - new Container(key: child1Key, width: 100.0, height: 20.0), - new Container(key: child2Key, width: 100.0, height: 20.0), + Container(key: child0Key, width: 100.0, height: 20.0), + Container(key: child1Key, width: 100.0, height: 20.0), + Container(key: child2Key, width: 100.0, height: 20.0), ] ) )); @@ -725,13 +725,13 @@ void main() { const Key flexKey = Key('flexKey'); // Default is MainAxisSize.max so the Column should be as high as the test: 600. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: flexKey, verticalDirection: VerticalDirection.up, children: [ - new Container(width: 100.0, height: 100.0), - new Container(width: 100.0, height: 150.0) + Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 150.0) ] ) )); @@ -740,14 +740,14 @@ void main() { expect(renderBox.size.height, equals(600.0)); // Column with MainAxisSize.min without flexible children shrink wraps. - await tester.pumpWidget(new Center( - child: new Column( + await tester.pumpWidget(Center( + child: Column( key: flexKey, mainAxisSize: MainAxisSize.min, verticalDirection: VerticalDirection.up, children: [ - new Container(width: 100.0, height: 100.0), - new Container(width: 100.0, height: 150.0) + Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 150.0) ] ) )); @@ -759,15 +759,15 @@ void main() { testWidgets('Column MainAxisSize.min layout at zero size', (WidgetTester tester) async { const Key childKey = Key('childKey'); - await tester.pumpWidget(new Center( - child: new Container( + await tester.pumpWidget(Center( + child: Container( width: 0.0, height: 0.0, - child: new Column( + child: Column( mainAxisSize: MainAxisSize.min, verticalDirection: VerticalDirection.up, children: [ - new Container( + Container( key: childKey, width: 100.0, height: 100.0 diff --git a/packages/flutter/test/widgets/composited_transform_test.dart b/packages/flutter/test/widgets/composited_transform_test.dart index 89cff1b00a..809cc39d91 100644 --- a/packages/flutter/test/widgets/composited_transform_test.dart +++ b/packages/flutter/test/widgets/composited_transform_test.dart @@ -8,27 +8,27 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Composited transforms - only offsets', (WidgetTester tester) async { - final LayerLink link = new LayerLink(); - final GlobalKey key = new GlobalKey(); + final LayerLink link = LayerLink(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( left: 123.0, top: 456.0, - child: new CompositedTransformTarget( + child: CompositedTransformTarget( link: link, - child: new Container(height: 10.0, width: 10.0), + child: Container(height: 10.0, width: 10.0), ), ), - new Positioned( + Positioned( left: 787.0, top: 343.0, - child: new CompositedTransformFollower( + child: CompositedTransformFollower( link: link, - child: new Container(key: key, height: 10.0, width: 10.0), + child: Container(key: key, height: 10.0, width: 10.0), ), ), ], @@ -40,33 +40,33 @@ void main() { }); testWidgets('Composited transforms - with rotations', (WidgetTester tester) async { - final LayerLink link = new LayerLink(); - final GlobalKey key1 = new GlobalKey(); - final GlobalKey key2 = new GlobalKey(); + final LayerLink link = LayerLink(); + final GlobalKey key1 = GlobalKey(); + final GlobalKey key2 = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 123.0, left: 456.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new CompositedTransformTarget( + child: CompositedTransformTarget( link: link, - child: new Container(key: key1, height: 10.0, width: 10.0), + child: Container(key: key1, height: 10.0, width: 10.0), ), ), ), - new Positioned( + Positioned( top: 787.0, left: 343.0, - child: new Transform.rotate( + child: Transform.rotate( angle: -0.3, // radians - child: new CompositedTransformFollower( + child: CompositedTransformFollower( link: link, - child: new Container(key: key2, height: 10.0, width: 10.0), + child: Container(key: key2, height: 10.0, width: 10.0), ), ), ), @@ -83,41 +83,41 @@ void main() { }); testWidgets('Composited transforms - nested', (WidgetTester tester) async { - final LayerLink link = new LayerLink(); - final GlobalKey key1 = new GlobalKey(); - final GlobalKey key2 = new GlobalKey(); + final LayerLink link = LayerLink(); + final GlobalKey key1 = GlobalKey(); + final GlobalKey key2 = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 123.0, left: 456.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new CompositedTransformTarget( + child: CompositedTransformTarget( link: link, - child: new Container(key: key1, height: 10.0, width: 10.0), + child: Container(key: key1, height: 10.0, width: 10.0), ), ), ), - new Positioned( + Positioned( top: 787.0, left: 343.0, - child: new Transform.rotate( + child: Transform.rotate( angle: -0.3, // radians - child: new Padding( + child: Padding( padding: const EdgeInsets.all(20.0), - child: new CompositedTransformFollower( - link: new LayerLink(), - child: new Transform( - transform: new Matrix4.skew(0.9, 1.1), - child: new Padding( + child: CompositedTransformFollower( + link: LayerLink(), + child: Transform( + transform: Matrix4.skew(0.9, 1.1), + child: Padding( padding: const EdgeInsets.all(20.0), - child: new CompositedTransformFollower( + child: CompositedTransformFollower( link: link, - child: new Container(key: key2, height: 10.0, width: 10.0), + child: Container(key: key2, height: 10.0, width: 10.0), ), ), ), @@ -138,31 +138,31 @@ void main() { }); testWidgets('Composited transforms - hit testing', (WidgetTester tester) async { - final LayerLink link = new LayerLink(); - final GlobalKey key1 = new GlobalKey(); - final GlobalKey key2 = new GlobalKey(); - final GlobalKey key3 = new GlobalKey(); + final LayerLink link = LayerLink(); + final GlobalKey key1 = GlobalKey(); + final GlobalKey key2 = GlobalKey(); + final GlobalKey key3 = GlobalKey(); bool _tapped = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( left: 123.0, top: 456.0, - child: new CompositedTransformTarget( + child: CompositedTransformTarget( link: link, - child: new Container(key: key1, height: 10.0, width: 10.0), + child: Container(key: key1, height: 10.0, width: 10.0), ), ), - new CompositedTransformFollower( + CompositedTransformFollower( link: link, - child: new GestureDetector( + child: GestureDetector( key: key2, behavior: HitTestBehavior.opaque, onTap: () { _tapped = true; }, - child: new Container(key: key3, height: 10.0, width: 10.0), + child: Container(key: key3, height: 10.0, width: 10.0), ), ), ], diff --git a/packages/flutter/test/widgets/constrained_box_test.dart b/packages/flutter/test/widgets/constrained_box_test.dart index 6c8aadd917..07d03088fe 100644 --- a/packages/flutter/test/widgets/constrained_box_test.dart +++ b/packages/flutter/test/widgets/constrained_box_test.dart @@ -16,7 +16,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - minHeight', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints( minHeight: 20.0, ), @@ -31,7 +31,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - minWidth', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints( minWidth: 20.0, ), @@ -46,7 +46,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - maxHeight', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints( maxHeight: 20.0, ), @@ -61,7 +61,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - maxWidth', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints( maxWidth: 20.0, ), @@ -76,7 +76,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - tight', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints.tightFor(width: 10.0, height: 30.0), child: const Placeholder(), ), @@ -90,7 +90,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - minHeight - with infinite width', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints( minWidth: double.infinity, minHeight: 20.0, @@ -106,7 +106,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - minWidth - with infinite height', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints( minWidth: 20.0, minHeight: double.infinity, @@ -122,7 +122,7 @@ void main() { testWidgets('ConstrainedBox intrinsics - infinite', (WidgetTester tester) async { await tester.pumpWidget( - new ConstrainedBox( + ConstrainedBox( constraints: const BoxConstraints.tightFor(width: double.infinity, height: double.infinity), child: const Placeholder(), ), diff --git a/packages/flutter/test/widgets/container_test.dart b/packages/flutter/test/widgets/container_test.dart index 4370a92035..84947e636f 100644 --- a/packages/flutter/test/widgets/container_test.dart +++ b/packages/flutter/test/widgets/container_test.dart @@ -9,7 +9,7 @@ import '../rendering/mock_canvas.dart'; void main() { testWidgets('Container control test', (WidgetTester tester) async { - final Container container = new Container( + final Container container = Container( alignment: Alignment.bottomRight, padding: const EdgeInsets.all(7.0), // uses color, not decoration: @@ -36,7 +36,7 @@ void main() { expect(container, hasOneLineDescription); - await tester.pumpWidget(new Align( + await tester.pumpWidget(Align( alignment: Alignment.topLeft, child: container )); @@ -45,9 +45,9 @@ void main() { expect(box, isNotNull); expect(box, paints - ..rect(rect: new Rect.fromLTWH(5.0, 5.0, 53.0, 78.0), color: const Color(0xFF00FF00)) - ..rect(rect: new Rect.fromLTWH(26.0, 43.0, 25.0, 33.0), color: const Color(0xFFFFFF00)) - ..rect(rect: new Rect.fromLTWH(5.0, 5.0, 53.0, 78.0), color: const Color(0x7F0000FF)) + ..rect(rect: Rect.fromLTWH(5.0, 5.0, 53.0, 78.0), color: const Color(0xFF00FF00)) + ..rect(rect: Rect.fromLTWH(26.0, 43.0, 25.0, 33.0), color: const Color(0xFFFFFF00)) + ..rect(rect: Rect.fromLTWH(5.0, 5.0, 53.0, 78.0), color: const Color(0x7F0000FF)) ); expect(box, hasAGoodToStringDeep); @@ -457,9 +457,9 @@ void main() { testWidgets('Can be placed in an infinite box', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: [new Container()]), + child: ListView(children: [Container()]), ), ); }); diff --git a/packages/flutter/test/widgets/coordinates_test.dart b/packages/flutter/test/widgets/coordinates_test.dart index 498c87237c..874153b9f9 100644 --- a/packages/flutter/test/widgets/coordinates_test.dart +++ b/packages/flutter/test/widgets/coordinates_test.dart @@ -8,26 +8,26 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Comparing coordinates', (WidgetTester tester) async { - final Key keyA = new GlobalKey(); - final Key keyB = new GlobalKey(); + final Key keyA = GlobalKey(); + final Key keyB = GlobalKey(); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new SizedBox( + child: SizedBox( key: keyA, width: 10.0, height: 10.0, ), ), - new Positioned( + Positioned( left: 100.0, top: 200.0, - child: new SizedBox( + child: SizedBox( key: keyB, width: 20.0, height: 10.0, diff --git a/packages/flutter/test/widgets/custom_multi_child_layout_test.dart b/packages/flutter/test/widgets/custom_multi_child_layout_test.dart index 9736908bbd..f7782f292b 100644 --- a/packages/flutter/test/widgets/custom_multi_child_layout_test.dart +++ b/packages/flutter/test/widgets/custom_multi_child_layout_test.dart @@ -26,7 +26,7 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate { assert(!RenderObject.debugCheckingIntrinsics); expect(() { performLayoutSize = size; - final BoxConstraints constraints = new BoxConstraints.loose(size); + final BoxConstraints constraints = BoxConstraints.loose(size); performLayoutSize0 = layoutChild(0, constraints); performLayoutSize1 = layoutChild(1, constraints); performLayoutIsChild = hasChild('fred'); @@ -45,11 +45,11 @@ class TestMultiChildLayoutDelegate extends MultiChildLayoutDelegate { } Widget buildFrame(MultiChildLayoutDelegate delegate) { - return new Center( - child: new CustomMultiChildLayout( + return Center( + child: CustomMultiChildLayout( children: [ - new LayoutId(id: 0, child: new Container(width: 150.0, height: 100.0)), - new LayoutId(id: 1, child: new Container(width: 100.0, height: 200.0)), + LayoutId(id: 0, child: Container(width: 150.0, height: 100.0)), + LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)), ], delegate: delegate ) @@ -75,7 +75,7 @@ class PreferredSizeDelegate extends MultiChildLayoutDelegate { void main() { testWidgets('Control test for CustomMultiChildLayout', (WidgetTester tester) async { - final TestMultiChildLayoutDelegate delegate = new TestMultiChildLayoutDelegate(); + final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate(); await tester.pumpWidget(buildFrame(delegate)); expect(delegate.getSizeConstraints.minWidth, 0.0); @@ -93,7 +93,7 @@ void main() { }); testWidgets('Test MultiChildDelegate shouldRelayout method', (WidgetTester tester) async { - TestMultiChildLayoutDelegate delegate = new TestMultiChildLayoutDelegate(); + TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate(); await tester.pumpWidget(buildFrame(delegate)); // Layout happened because the delegate was set. @@ -101,14 +101,14 @@ void main() { expect(delegate.shouldRelayoutCalled, isFalse); // Layout did not happen because shouldRelayout() returned false. - delegate = new TestMultiChildLayoutDelegate(); + delegate = TestMultiChildLayoutDelegate(); delegate.shouldRelayoutValue = false; await tester.pumpWidget(buildFrame(delegate)); expect(delegate.shouldRelayoutCalled, isTrue); expect(delegate.performLayoutSize, isNull); // Layout happened because shouldRelayout() returned true. - delegate = new TestMultiChildLayoutDelegate(); + delegate = TestMultiChildLayoutDelegate(); delegate.shouldRelayoutValue = true; await tester.pumpWidget(buildFrame(delegate)); expect(delegate.shouldRelayoutCalled, isTrue); @@ -116,21 +116,21 @@ void main() { }); testWidgets('Nested CustomMultiChildLayouts', (WidgetTester tester) async { - final TestMultiChildLayoutDelegate delegate = new TestMultiChildLayoutDelegate(); - await tester.pumpWidget(new Center( - child: new CustomMultiChildLayout( + final TestMultiChildLayoutDelegate delegate = TestMultiChildLayoutDelegate(); + await tester.pumpWidget(Center( + child: CustomMultiChildLayout( children: [ - new LayoutId( + LayoutId( id: 0, - child: new CustomMultiChildLayout( + child: CustomMultiChildLayout( children: [ - new LayoutId(id: 0, child: new Container(width: 150.0, height: 100.0)), - new LayoutId(id: 1, child: new Container(width: 100.0, height: 200.0)), + LayoutId(id: 0, child: Container(width: 150.0, height: 100.0)), + LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)), ], delegate: delegate ) ), - new LayoutId(id: 1, child: new Container(width: 100.0, height: 200.0)), + LayoutId(id: 1, child: Container(width: 100.0, height: 200.0)), ], delegate: delegate ) @@ -139,11 +139,11 @@ void main() { }); testWidgets('Loose constraints', (WidgetTester tester) async { - final Key key = new UniqueKey(); - await tester.pumpWidget(new Center( - child: new CustomMultiChildLayout( + final Key key = UniqueKey(); + await tester.pumpWidget(Center( + child: CustomMultiChildLayout( key: key, - delegate: new PreferredSizeDelegate(preferredSize: const Size(300.0, 200.0)) + delegate: PreferredSizeDelegate(preferredSize: const Size(300.0, 200.0)) ) )); @@ -151,10 +151,10 @@ void main() { expect(box.size.width, equals(300.0)); expect(box.size.height, equals(200.0)); - await tester.pumpWidget(new Center( - child: new CustomMultiChildLayout( + await tester.pumpWidget(Center( + child: CustomMultiChildLayout( key: key, - delegate: new PreferredSizeDelegate(preferredSize: const Size(350.0, 250.0)) + delegate: PreferredSizeDelegate(preferredSize: const Size(350.0, 250.0)) ) )); diff --git a/packages/flutter/test/widgets/custom_paint_test.dart b/packages/flutter/test/widgets/custom_paint_test.dart index 7bdd94adba..6877fd3849 100644 --- a/packages/flutter/test/widgets/custom_paint_test.dart +++ b/packages/flutter/test/widgets/custom_paint_test.dart @@ -24,17 +24,17 @@ class TestCustomPainter extends CustomPainter { void main() { testWidgets('Control test for custom painting', (WidgetTester tester) async { final List log = []; - await tester.pumpWidget(new CustomPaint( - painter: new TestCustomPainter( + await tester.pumpWidget(CustomPaint( + painter: TestCustomPainter( log: log, name: 'background' ), - foregroundPainter: new TestCustomPainter( + foregroundPainter: TestCustomPainter( log: log, name: 'foreground' ), - child: new CustomPaint( - painter: new TestCustomPainter( + child: CustomPaint( + painter: TestCustomPainter( log: log, name: 'child' ) @@ -45,57 +45,57 @@ void main() { }); testWidgets('CustomPaint sizing', (WidgetTester tester) async { - final GlobalKey target = new GlobalKey(); + final GlobalKey target = GlobalKey(); - await tester.pumpWidget(new Center( - child: new CustomPaint(key: target) + await tester.pumpWidget(Center( + child: CustomPaint(key: target) )); expect(target.currentContext.size, Size.zero); - await tester.pumpWidget(new Center( - child: new CustomPaint(key: target, child: new Container()) + await tester.pumpWidget(Center( + child: CustomPaint(key: target, child: Container()) )); expect(target.currentContext.size, const Size(800.0, 600.0)); - await tester.pumpWidget(new Center( - child: new CustomPaint(key: target, size: const Size(20.0, 20.0)) + await tester.pumpWidget(Center( + child: CustomPaint(key: target, size: const Size(20.0, 20.0)) )); expect(target.currentContext.size, const Size(20.0, 20.0)); - await tester.pumpWidget(new Center( - child: new CustomPaint(key: target, size: const Size(2000.0, 100.0)) + await tester.pumpWidget(Center( + child: CustomPaint(key: target, size: const Size(2000.0, 100.0)) )); expect(target.currentContext.size, const Size(800.0, 100.0)); - await tester.pumpWidget(new Center( - child: new CustomPaint(key: target, size: Size.zero, child: new Container()) + await tester.pumpWidget(Center( + child: CustomPaint(key: target, size: Size.zero, child: Container()) )); expect(target.currentContext.size, const Size(800.0, 600.0)); - await tester.pumpWidget(new Center( - child: new CustomPaint(key: target, child: new Container(height: 0.0, width: 0.0)) + await tester.pumpWidget(Center( + child: CustomPaint(key: target, child: Container(height: 0.0, width: 0.0)) )); expect(target.currentContext.size, Size.zero); }); testWidgets('Raster cache hints', (WidgetTester tester) async { - final GlobalKey target = new GlobalKey(); + final GlobalKey target = GlobalKey(); final List log = []; - await tester.pumpWidget(new CustomPaint( + await tester.pumpWidget(CustomPaint( key: target, isComplex: true, - painter: new TestCustomPainter(log: log), + painter: TestCustomPainter(log: log), )); RenderCustomPaint renderCustom = target.currentContext.findRenderObject(); expect(renderCustom.isComplex, true); expect(renderCustom.willChange, false); - await tester.pumpWidget(new CustomPaint( + await tester.pumpWidget(CustomPaint( key: target, willChange: true, - foregroundPainter: new TestCustomPainter(log: log), + foregroundPainter: TestCustomPainter(log: log), )); renderCustom = target.currentContext.findRenderObject(); expect(renderCustom.isComplex, false); diff --git a/packages/flutter/test/widgets/custom_painter_test.dart b/packages/flutter/test/widgets/custom_painter_test.dart index 444fce52cc..52369b900a 100644 --- a/packages/flutter/test/widgets/custom_painter_test.dart +++ b/packages/flutter/test/widgets/custom_painter_test.dart @@ -26,14 +26,14 @@ void main() { void _defineTests() { testWidgets('builds no semantics by default', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithoutSemantics(), + await tester.pumpWidget(CustomPaint( + painter: _PainterWithoutSemantics(), )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: const [], ), )); @@ -42,12 +42,12 @@ void _defineTests() { }); testWidgets('provides foreground semantics', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new CustomPaint( - foregroundPainter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + await tester.pumpWidget(CustomPaint( + foregroundPainter: _PainterWithSemantics( + semantics: CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'foreground', textDirection: TextDirection.rtl, @@ -57,16 +57,16 @@ void _defineTests() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 2, label: 'foreground', - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), ), ], ), @@ -78,12 +78,12 @@ void _defineTests() { }); testWidgets('provides background semantics', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'background', textDirection: TextDirection.rtl, @@ -93,16 +93,16 @@ void _defineTests() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 2, label: 'background', - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), ), ], ), @@ -114,25 +114,25 @@ void _defineTests() { }); testWidgets('combines background, child and foreground semantics', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'background', textDirection: TextDirection.rtl, ), ), ), - child: new Semantics( + child: Semantics( container: true, child: const Text('Hello', textDirection: TextDirection.ltr), ), - foregroundPainter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + foregroundPainter: _PainterWithSemantics( + semantics: CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'foreground', textDirection: TextDirection.rtl, @@ -142,26 +142,26 @@ void _defineTests() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 3, label: 'background', - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), ), - new TestSemantics( + TestSemantics( id: 2, label: 'Hello', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), ), - new TestSemantics( + TestSemantics( id: 4, label: 'foreground', - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), ), ], ), @@ -173,13 +173,13 @@ void _defineTests() { }); testWidgets('applies $SemanticsProperties', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( key: const ValueKey(1), - rect: new Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), + rect: Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), properties: const SemanticsProperties( checked: false, selected: false, @@ -196,14 +196,14 @@ void _defineTests() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( - rect: new Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), + TestSemantics( + rect: Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), id: 2, flags: 1, label: 'label-before', @@ -219,12 +219,12 @@ void _defineTests() { ), )); - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( key: const ValueKey(1), - rect: new Rect.fromLTRB(5.0, 6.0, 7.0, 8.0), - properties: new SemanticsProperties( + rect: Rect.fromLTRB(5.0, 6.0, 7.0, 8.0), + properties: SemanticsProperties( checked: true, selected: true, button: true, @@ -248,14 +248,14 @@ void _defineTests() { )); expect(semanticsTester, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( - rect: new Rect.fromLTRB(5.0, 6.0, 7.0, 8.0), + TestSemantics( + rect: Rect.fromLTRB(5.0, 6.0, 7.0, 8.0), actions: 255, id: 2, flags: 15, @@ -276,11 +276,11 @@ void _defineTests() { }); testWidgets('Can toggle semantics on, off, on without crash', (WidgetTester tester) async { - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( key: const ValueKey(1), - rect: new Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), + rect: Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), properties: const SemanticsProperties( checked: false, selected: false, @@ -300,7 +300,7 @@ void _defineTests() { expect(tester.binding.pipelineOwner.semanticsOwner, isNull); // Semantics on - SemanticsTester semantics = new SemanticsTester(tester); + SemanticsTester semantics = SemanticsTester(tester); await tester.pumpAndSettle(); expect(tester.binding.pipelineOwner.semanticsOwner, isNotNull); @@ -310,7 +310,7 @@ void _defineTests() { expect(tester.binding.pipelineOwner.semanticsOwner, isNull); // Semantics on - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); await tester.pumpAndSettle(); expect(tester.binding.pipelineOwner.semanticsOwner, isNotNull); @@ -318,15 +318,15 @@ void _defineTests() { }); testWidgets('Supports all actions', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final List performedActions = []; - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( key: const ValueKey(1), - rect: new Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), - properties: new SemanticsProperties( + rect: Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), + properties: SemanticsProperties( onDismiss: () => performedActions.add(SemanticsAction.dismiss), onTap: () => performedActions.add(SemanticsAction.tap), onLongPress: () => performedActions.add(SemanticsAction.longPress), @@ -355,12 +355,12 @@ void _defineTests() { ..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed const int expectedId = 2; - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: expectedId, rect: TestSemantics.fullScreen, actions: allActions.fold(0, (int previous, SemanticsAction action) => previous | action.index), @@ -398,13 +398,13 @@ void _defineTests() { }); testWidgets('Supports all flags', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // checked state and toggled state are mutually exclusive. - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( key: const ValueKey(1), - rect: new Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), + rect: Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), properties: const SemanticsProperties( enabled: true, checked: true, @@ -430,12 +430,12 @@ void _defineTests() { ..remove(SemanticsFlag.hasToggledState) ..remove(SemanticsFlag.hasImplicitScrolling) ..remove(SemanticsFlag.isToggled); - TestSemantics expectedSemantics = new TestSemantics.root( + TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, rect: TestSemantics.fullScreen, flags: flags, @@ -446,11 +446,11 @@ void _defineTests() { ); expect(semantics, hasSemantics(expectedSemantics, ignoreRect: true, ignoreTransform: true)); - await tester.pumpWidget(new CustomPaint( - painter: new _PainterWithSemantics( - semantics: new CustomPainterSemantics( + await tester.pumpWidget(CustomPaint( + painter: _PainterWithSemantics( + semantics: CustomPainterSemantics( key: const ValueKey(1), - rect: new Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), + rect: Rect.fromLTRB(1.0, 2.0, 3.0, 4.0), properties: const SemanticsProperties( enabled: true, toggled: true, @@ -477,12 +477,12 @@ void _defineTests() { ..remove(SemanticsFlag.hasImplicitScrolling) ..remove(SemanticsFlag.isChecked); - expectedSemantics = new TestSemantics.root( + expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, rect: TestSemantics.fullScreen, flags: flags, @@ -497,9 +497,9 @@ void _defineTests() { group('diffing', () { testWidgets('complains about duplicate keys', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); - await tester.pumpWidget(new CustomPaint( - painter: new _SemanticsDiffTest([ + final SemanticsTester semanticsTester = SemanticsTester(tester); + await tester.pumpWidget(CustomPaint( + painter: _SemanticsDiffTest([ 'a-k', 'a-k', ]), @@ -594,11 +594,11 @@ void _defineTests() { }); testWidgets('rebuilds semantics upon resize', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - final _PainterWithSemantics painter = new _PainterWithSemantics( - semantics: new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + final _PainterWithSemantics painter = _PainterWithSemantics( + semantics: CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'background', textDirection: TextDirection.rtl, @@ -606,9 +606,9 @@ void _defineTests() { ), ); - final CustomPaint paint = new CustomPaint(painter: painter); + final CustomPaint paint = CustomPaint(painter: painter); - await tester.pumpWidget(new SizedBox( + await tester.pumpWidget(SizedBox( height: 20.0, width: 20.0, child: paint, @@ -617,7 +617,7 @@ void _defineTests() { expect(_PainterWithSemantics.buildSemanticsCallCount, 1); expect(_PainterWithSemantics.semanticsBuilderCallCount, 4); - await tester.pumpWidget(new SizedBox( + await tester.pumpWidget(SizedBox( height: 20.0, width: 20.0, child: paint, @@ -626,7 +626,7 @@ void _defineTests() { expect(_PainterWithSemantics.buildSemanticsCallCount, 1); expect(_PainterWithSemantics.semanticsBuilderCallCount, 4); - await tester.pumpWidget(new SizedBox( + await tester.pumpWidget(SizedBox( height: 40.0, width: 40.0, child: paint, @@ -639,39 +639,39 @@ void _defineTests() { }); testWidgets('does not rebuild when shouldRebuildSemantics is false', (WidgetTester tester) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); - final CustomPainterSemantics testSemantics = new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + final CustomPainterSemantics testSemantics = CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'background', textDirection: TextDirection.rtl, ), ); - await tester.pumpWidget(new CustomPaint(painter: new _PainterWithSemantics( + await tester.pumpWidget(CustomPaint(painter: _PainterWithSemantics( semantics: testSemantics, ))); expect(_PainterWithSemantics.shouldRebuildSemanticsCallCount, 0); expect(_PainterWithSemantics.buildSemanticsCallCount, 1); expect(_PainterWithSemantics.semanticsBuilderCallCount, 4); - await tester.pumpWidget(new CustomPaint(painter: new _PainterWithSemantics( + await tester.pumpWidget(CustomPaint(painter: _PainterWithSemantics( semantics: testSemantics, ))); expect(_PainterWithSemantics.shouldRebuildSemanticsCallCount, 1); expect(_PainterWithSemantics.buildSemanticsCallCount, 1); expect(_PainterWithSemantics.semanticsBuilderCallCount, 4); - final CustomPainterSemantics testSemantics2 = new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + final CustomPainterSemantics testSemantics2 = CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), properties: const SemanticsProperties( label: 'background', textDirection: TextDirection.rtl, ), ); - await tester.pumpWidget(new CustomPaint(painter: new _PainterWithSemantics( + await tester.pumpWidget(CustomPaint(painter: _PainterWithSemantics( semantics: testSemantics2, ))); expect(_PainterWithSemantics.shouldRebuildSemanticsCallCount, 2); @@ -684,7 +684,7 @@ void _defineTests() { void testDiff(String description, Future Function(_DiffTester tester) testFunction) { testWidgets(description, (WidgetTester tester) async { - await testFunction(new _DiffTester(tester)); + await testFunction(_DiffTester(tester)); }); } @@ -701,22 +701,22 @@ class _DiffTester { /// - checks that initial and final configurations are in the desired states. /// - checks that keyed nodes have stable IDs. Future diff({List from, List to}) async { - final SemanticsTester semanticsTester = new SemanticsTester(tester); + final SemanticsTester semanticsTester = SemanticsTester(tester); TestSemantics createExpectations(List labels) { final List children = []; for (String label in labels) { children.add( - new TestSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + TestSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), label: label, ), ); } - return new TestSemantics.root( + return TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( rect: TestSemantics.fullScreen, children: children, ), @@ -724,8 +724,8 @@ class _DiffTester { ); } - await tester.pumpWidget(new CustomPaint( - painter: new _SemanticsDiffTest(from), + await tester.pumpWidget(CustomPaint( + painter: _SemanticsDiffTest(from), )); expect(semanticsTester, hasSemantics(createExpectations(from), ignoreId: true)); @@ -741,8 +741,8 @@ class _DiffTester { return true; }); - await tester.pumpWidget(new CustomPaint( - painter: new _SemanticsDiffTest(to), + await tester.pumpWidget(CustomPaint( + painter: _SemanticsDiffTest(to), )); await tester.pumpAndSettle(); expect(semanticsTester, hasSemantics(createExpectations(to), ignoreId: true)); @@ -783,13 +783,13 @@ class _SemanticsDiffTest extends CustomPainter { for (String label in data) { Key key; if (label.endsWith('-k')) { - key = new ValueKey(label); + key = ValueKey(label); } semantics.add( - new CustomPainterSemantics( - rect: new Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), + CustomPainterSemantics( + rect: Rect.fromLTRB(1.0, 1.0, 2.0, 2.0), key: key, - properties: new SemanticsProperties( + properties: SemanticsProperties( label: label, textDirection: TextDirection.rtl, ), diff --git a/packages/flutter/test/widgets/custom_single_child_layout_test.dart b/packages/flutter/test/widgets/custom_single_child_layout_test.dart index d48908781b..3f9e9978f4 100644 --- a/packages/flutter/test/widgets/custom_single_child_layout_test.dart +++ b/packages/flutter/test/widgets/custom_single_child_layout_test.dart @@ -56,7 +56,7 @@ class FixedSizeLayoutDelegate extends SingleChildLayoutDelegate { @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { - return new BoxConstraints.tight(size); + return BoxConstraints.tight(size); } @override @@ -75,7 +75,7 @@ class NotifierLayoutDelegate extends SingleChildLayoutDelegate { @override BoxConstraints getConstraintsForChild(BoxConstraints constraints) { - return new BoxConstraints.tight(size.value); + return BoxConstraints.tight(size.value); } @override @@ -85,10 +85,10 @@ class NotifierLayoutDelegate extends SingleChildLayoutDelegate { } Widget buildFrame(SingleChildLayoutDelegate delegate) { - return new Center( - child: new CustomSingleChildLayout( + return Center( + child: CustomSingleChildLayout( delegate: delegate, - child: new Container(), + child: Container(), ), ); } @@ -97,7 +97,7 @@ void main() { testWidgets('Control test for CustomSingleChildLayout', (WidgetTester tester) async { final TestSingleChildLayoutDelegate delegate = - new TestSingleChildLayoutDelegate(); + TestSingleChildLayoutDelegate(); await tester.pumpWidget(buildFrame(delegate)); expect(delegate.constraintsFromGetSize.minWidth, 0.0); @@ -120,7 +120,7 @@ void main() { testWidgets('Test SingleChildDelegate shouldRelayout method', (WidgetTester tester) async { TestSingleChildLayoutDelegate delegate = - new TestSingleChildLayoutDelegate(); + TestSingleChildLayoutDelegate(); await tester.pumpWidget(buildFrame(delegate)); // Layout happened because the delegate was set. @@ -129,14 +129,14 @@ void main() { expect(delegate.shouldRelayoutCalled, isFalse); // Layout did not happen because shouldRelayout() returned false. - delegate = new TestSingleChildLayoutDelegate(); + delegate = TestSingleChildLayoutDelegate(); delegate.shouldRelayoutValue = false; await tester.pumpWidget(buildFrame(delegate)); expect(delegate.shouldRelayoutCalled, isTrue); expect(delegate.constraintsFromGetConstraintsForChild, isNull); // Layout happened because shouldRelayout() returned true. - delegate = new TestSingleChildLayoutDelegate(); + delegate = TestSingleChildLayoutDelegate(); delegate.shouldRelayoutValue = true; await tester.pumpWidget(buildFrame(delegate)); expect(delegate.shouldRelayoutCalled, isTrue); @@ -145,22 +145,22 @@ void main() { testWidgets('Delegate can change size', (WidgetTester tester) async { await tester.pumpWidget( - buildFrame(new FixedSizeLayoutDelegate(const Size(100.0, 200.0)))); + buildFrame(FixedSizeLayoutDelegate(const Size(100.0, 200.0)))); RenderBox box = tester.renderObject(find.byType(CustomSingleChildLayout)); expect(box.size, equals(const Size(100.0, 200.0))); await tester.pumpWidget( - buildFrame(new FixedSizeLayoutDelegate(const Size(150.0, 240.0)))); + buildFrame(FixedSizeLayoutDelegate(const Size(150.0, 240.0)))); box = tester.renderObject(find.byType(CustomSingleChildLayout)); expect(box.size, equals(const Size(150.0, 240.0))); }); testWidgets('Can use listener for relayout', (WidgetTester tester) async { - final ValueNotifier size = new ValueNotifier(const Size(100.0, 200.0)); + final ValueNotifier size = ValueNotifier(const Size(100.0, 200.0)); - await tester.pumpWidget(buildFrame(new NotifierLayoutDelegate(size))); + await tester.pumpWidget(buildFrame(NotifierLayoutDelegate(size))); RenderBox box = tester.renderObject(find.byType(CustomSingleChildLayout)); expect(box.size, equals(const Size(100.0, 200.0))); diff --git a/packages/flutter/test/widgets/directionality_test.dart b/packages/flutter/test/widgets/directionality_test.dart index 98960607d2..bed685e07b 100644 --- a/packages/flutter/test/widgets/directionality_test.dart +++ b/packages/flutter/test/widgets/directionality_test.dart @@ -8,42 +8,42 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Directionality', (WidgetTester tester) async { final List log = []; - final Widget inner = new Builder( + final Widget inner = Builder( builder: (BuildContext context) { log.add(Directionality.of(context)); return const Placeholder(); } ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, child: inner, ), ); expect(log, [TextDirection.ltr]); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, child: inner, ), ); expect(log, [TextDirection.ltr]); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, child: inner, ), ); expect(log, [TextDirection.ltr, TextDirection.rtl]); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, child: inner, ), ); expect(log, [TextDirection.ltr, TextDirection.rtl]); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, child: inner, ), @@ -53,7 +53,7 @@ void main() { testWidgets('Directionality default', (WidgetTester tester) async { bool good = false; - await tester.pumpWidget(new Builder( + await tester.pumpWidget(Builder( builder: (BuildContext context) { expect(Directionality.of(context), isNull); good = true; @@ -65,7 +65,7 @@ void main() { testWidgets('Directionality can\'t be null', (WidgetTester tester) async { expect(() { - new Directionality(textDirection: nonconst(null), child: const Placeholder()); + Directionality(textDirection: nonconst(null), child: const Placeholder()); }, throwsAssertionError); }); } diff --git a/packages/flutter/test/widgets/dismissible_test.dart b/packages/flutter/test/widgets/dismissible_test.dart index 9da435c315..2745af0046 100644 --- a/packages/flutter/test/widgets/dismissible_test.dart +++ b/packages/flutter/test/widgets/dismissible_test.dart @@ -15,13 +15,13 @@ Widget background; const double crossAxisEndOffset = 0.5; Widget buildTest({ double startToEndThreshold, TextDirection textDirection = TextDirection.ltr }) { - return new Directionality( + return Directionality( textDirection: textDirection, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { Widget buildDismissibleItem(int item) { - return new Dismissible( - key: new ValueKey(item), + return Dismissible( + key: ValueKey(item), direction: dismissDirection, onDismissed: (DismissDirection direction) { setState(() { @@ -38,17 +38,17 @@ Widget buildTest({ double startToEndThreshold, TextDirection textDirection = Tex ? {} : {DismissDirection.startToEnd: startToEndThreshold}, crossAxisEndOffset: crossAxisEndOffset, - child: new Container( + child: Container( width: itemExtent, height: itemExtent, - child: new Text(item.toString()), + child: Text(item.toString()), ), ); } - return new Container( + return Container( padding: const EdgeInsets.all(10.0), - child: new ListView( + child: ListView( scrollDirection: scrollDirection, itemExtent: itemExtent, children: [0, 1, 2, 3, 4] @@ -198,11 +198,11 @@ class Test1215DismissibleWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return new Dismissible( - key: new ObjectKey(text), - child: new AspectRatio( + return Dismissible( + key: ObjectKey(text), + child: AspectRatio( aspectRatio: 1.0, - child: new Text(text), + child: Text(text), ), ); } @@ -559,13 +559,13 @@ void main() { // Dismissible contract. This is not an example of good practice. testWidgets('dismissing bottom then top (smoketest)', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 1000.0, - child: new Column( + child: Column( children: const [ Test1215DismissibleWidget('1'), Test1215DismissibleWidget('2'), diff --git a/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart b/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart index 91e16cb4af..a9e4c5662b 100644 --- a/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart +++ b/packages/flutter/test/widgets/dispose_ancestor_lookup_test.dart @@ -13,7 +13,7 @@ class TestWidget extends StatefulWidget { final TestCallback callback; @override - TestWidgetState createState() => new TestWidgetState(); + TestWidgetState createState() => TestWidgetState(); } class TestWidgetState extends State { @@ -31,12 +31,12 @@ void main() { testWidgets('inheritFromWidgetOfExactType() called from dispose() throws error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; context.inheritFromWidgetOfExactType(Container); }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); expect(tester.takeException(), isFlutterError); }); @@ -44,12 +44,12 @@ void main() { testWidgets('ancestorInheritedElementForWidgetOfExactType() called from dispose() throws error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; context.ancestorInheritedElementForWidgetOfExactType(Container); }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); expect(tester.takeException(), isFlutterError); }); @@ -57,12 +57,12 @@ void main() { testWidgets('ancestorWidgetOfExactType() called from dispose() throws error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; context.ancestorWidgetOfExactType(Container); }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); expect(tester.takeException(), isFlutterError); }); @@ -70,12 +70,12 @@ void main() { testWidgets('ancestorStateOfType() called from dispose() throws error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; context.ancestorStateOfType(const TypeMatcher()); }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); expect(tester.takeException(), isFlutterError); }); @@ -83,12 +83,12 @@ void main() { testWidgets('ancestorRenderObjectOfType() called from dispose() throws error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; context.ancestorRenderObjectOfType(const TypeMatcher()); }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); expect(tester.takeException(), isFlutterError); }); @@ -96,12 +96,12 @@ void main() { testWidgets('visitAncestorElements() called from dispose() throws error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; context.visitAncestorElements((Element element) => true); }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); expect(tester.takeException(), isFlutterError); }); @@ -109,11 +109,11 @@ void main() { testWidgets('dispose() method does not unconditionally throw an error', (WidgetTester tester) async { bool disposeCalled = false; await tester.pumpWidget( - new TestWidget((BuildContext context) { + TestWidget((BuildContext context) { disposeCalled = true; }), ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(disposeCalled, isTrue); }); diff --git a/packages/flutter/test/widgets/draggable_test.dart b/packages/flutter/test/widgets/draggable_test.dart index 323c15e712..42b58f0293 100644 --- a/packages/flutter/test/widgets/draggable_test.dart +++ b/packages/flutter/test/widgets/draggable_test.dart @@ -15,10 +15,10 @@ void main() { final List accepted = []; int dragStartedCount = 0; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -26,9 +26,9 @@ void main() { ++dragStartedCount; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -78,23 +78,23 @@ void main() { 'Target 2': 0, }; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const Draggable( data: 1, child: Text('Source'), feedback: Text('Dragging'), ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target 1')); + return Container(height: 100.0, child: const Text('Target 1')); }, onLeave: (int data) => leftBehind['Target 1'] = leftBehind['Target 1'] + data, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target 2')); + return Container(height: 100.0, child: const Text('Target 2')); }, onLeave: (int data) => leftBehind['Target 2'] = leftBehind['Target 2'] + data, ), @@ -143,28 +143,28 @@ void main() { final List events = []; Offset firstLocation, secondLocation; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const Draggable( data: 1, child: Text('Source'), feedback: Text('Dragging'), ), - new Stack( + Stack( children: [ - new GestureDetector( + GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { events.add('tap'); }, - child: new Container(child: const Text('Button'), + child: Container(child: const Text('Button'), ), ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new IgnorePointer( - child: new Container(child: const Text('Target')), + return IgnorePointer( + child: Container(child: const Text('Target')), ); }, onAccept: (int data) { @@ -233,21 +233,21 @@ void main() { final List events = []; Offset firstLocation, secondLocation; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { events.add('tap'); }, - child: new Container(child: const Text('Button')), + child: Container(child: const Text('Button')), ), feedback: const Text('Dragging'), ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -287,15 +287,15 @@ void main() { final List events = []; Offset firstLocation, secondLocation; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const LongPressDraggable( data: 1, child: Text('Source'), feedback: Text('Dragging'), ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -333,15 +333,15 @@ void main() { final List events = []; Offset firstLocation, secondLocation; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const Draggable( data: 1, child: Text('Source'), feedback: Text('Dragging'), ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -381,10 +381,10 @@ void main() { final List events = []; Offset firstLocation, secondLocation, thirdLocation; - await tester.pumpWidget(new MaterialApp( - home: new ListView( + await tester.pumpWidget(MaterialApp( + home: ListView( children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -392,7 +392,7 @@ void main() { events.add('drop $data'); } ), - new Container(height: 400.0), + Container(height: 400.0), const Draggable( data: 1, child: Text('H'), @@ -405,10 +405,10 @@ void main() { feedback: Text('Dragging'), affinity: Axis.vertical, ), - new Container(height: 500.0), - new Container(height: 500.0), - new Container(height: 500.0), - new Container(height: 500.0), + Container(height: 500.0), + Container(height: 500.0), + Container(height: 500.0), + Container(height: 500.0), ], ), )); @@ -487,11 +487,11 @@ void main() { final List events = []; Offset firstLocation, secondLocation, thirdLocation; - await tester.pumpWidget(new MaterialApp( - home: new ListView( + await tester.pumpWidget(MaterialApp( + home: ListView( scrollDirection: Axis.horizontal, children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -499,7 +499,7 @@ void main() { events.add('drop $data'); } ), - new Container(width: 400.0), + Container(width: 400.0), const Draggable( data: 1, child: Text('H'), @@ -512,10 +512,10 @@ void main() { feedback: Text('Dragging'), affinity: Axis.vertical, ), - new Container(width: 500.0), - new Container(width: 500.0), - new Container(width: 500.0), - new Container(width: 500.0), + Container(width: 500.0), + Container(width: 500.0), + Container(width: 500.0), + Container(width: 500.0), ], ), )); @@ -594,11 +594,11 @@ void main() { final List events = []; Widget build() { - return new MaterialApp( - home: new ListView( + return MaterialApp( + home: ListView( scrollDirection: Axis.horizontal, children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -606,7 +606,7 @@ void main() { events.add('drop $data'); } ), - new Container(width: 400.0), + Container(width: 400.0), const Draggable( data: 1, child: Text('H'), @@ -627,10 +627,10 @@ void main() { feedback: Text('N'), childWhenDragging: SizedBox(), ), - new Container(width: 500.0), - new Container(width: 500.0), - new Container(width: 500.0), - new Container(width: 500.0), + Container(width: 500.0), + Container(width: 500.0), + Container(width: 500.0), + Container(width: 500.0), ], ), ); @@ -722,10 +722,10 @@ void main() { final List accepted = []; bool onDraggableCanceledCalled = false; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -733,9 +733,9 @@ void main() { onDraggableCanceledCalled = true; } ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -785,10 +785,10 @@ void main() { Velocity onDraggableCanceledVelocity; Offset onDraggableCanceledOffset; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -798,9 +798,9 @@ void main() { onDraggableCanceledOffset = offset; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container( + return Container( height: 100.0, child: const Text('Target') ); @@ -846,7 +846,7 @@ void main() { expect(find.text('Target'), findsOneWidget); expect(onDraggableCanceledCalled, isTrue); expect(onDraggableCanceledVelocity, equals(Velocity.zero)); - expect(onDraggableCanceledOffset, equals(new Offset(secondLocation.dx, secondLocation.dy))); + expect(onDraggableCanceledOffset, equals(Offset(secondLocation.dx, secondLocation.dy))); }); testWidgets('Drag and drop - onDraggableCanceled called if dropped on non-accepting target with correct velocity', (WidgetTester tester) async { @@ -855,9 +855,9 @@ void main() { Velocity onDraggableCanceledVelocity; Offset onDraggableCanceledOffset; - await tester.pumpWidget(new MaterialApp( - home: new Column(children: [ - new Draggable( + await tester.pumpWidget(MaterialApp( + home: Column(children: [ + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Source'), @@ -867,9 +867,9 @@ void main() { onDraggableCanceledOffset = offset; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container( + return Container( height: 100.0, child: const Text('Target'), ); @@ -896,17 +896,17 @@ void main() { expect(onDraggableCanceledCalled, isTrue); expect(onDraggableCanceledVelocity.pixelsPerSecond.dx.abs(), lessThan(0.0000001)); expect((onDraggableCanceledVelocity.pixelsPerSecond.dy - 1000.0).abs(), lessThan(0.0000001)); - expect(onDraggableCanceledOffset, equals(new Offset(flingStart.dx, flingStart.dy) + const Offset(0.0, 100.0))); + expect(onDraggableCanceledOffset, equals(Offset(flingStart.dx, flingStart.dy) + const Offset(0.0, 100.0))); }); testWidgets('Drag and drop - onDragCompleted not called if dropped on non-accepting target', (WidgetTester tester) async { final List accepted = []; bool onDragCompletedCalled = false; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -914,9 +914,9 @@ void main() { onDragCompletedCalled = true; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container( + return Container( height: 100.0, child: const Text('Target'), ); @@ -967,10 +967,10 @@ void main() { final List accepted = []; bool onDragCompletedCalled = false; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -978,9 +978,9 @@ void main() { onDragCompletedCalled = true; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -1028,8 +1028,8 @@ void main() { final List acceptedInts = []; final List acceptedDoubles = []; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const Draggable( data: 1, @@ -1041,12 +1041,12 @@ void main() { child: Text('DoubleSource'), feedback: Text('DoubleDragging'), ), - new Stack( + Stack( children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new IgnorePointer( - child: new Container( + return IgnorePointer( + child: Container( height: 100.0, child: const Text('Target1'), ), @@ -1054,10 +1054,10 @@ void main() { }, onAccept: acceptedInts.add, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new IgnorePointer( - child: new Container( + return IgnorePointer( + child: Container( height: 100.0, child: const Text('Target2'), ), @@ -1140,31 +1140,31 @@ void main() { testWidgets('Drag and drop - allow pass thru of unaccepted data twice test', (WidgetTester tester) async { final List acceptedDragTargetDatas = []; final List acceptedExtendedDragTargetDatas = []; - final DragTargetData dragTargetData = new DragTargetData(); - await tester.pumpWidget(new MaterialApp( - home: new Column( + final DragTargetData dragTargetData = DragTargetData(); + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: dragTargetData, child: const Text('Source'), feedback: const Text('Dragging'), ), - new Stack( + Stack( children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new IgnorePointer( - child: new Container( + return IgnorePointer( + child: Container( height: 100.0, child: const Text('Target1'), ), ); }, onAccept: acceptedDragTargetDatas.add, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new IgnorePointer( - child: new Container( + return IgnorePointer( + child: Container( height: 100.0, child: const Text('Target2'), ), @@ -1201,18 +1201,18 @@ void main() { final List accepted = []; Widget build(int maxSimultaneousDrags) { - return new MaterialApp( - home: new Column( + return MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, maxSimultaneousDrags: maxSimultaneousDrags, child: const Text('Source'), feedback: const Text('Dragging'), ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -1310,20 +1310,20 @@ void main() { testWidgets('Draggable disposes recognizer', (WidgetTester tester) async { bool didTap = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( - builder: (BuildContext context) => new GestureDetector( + OverlayEntry( + builder: (BuildContext context) => GestureDetector( onTap: () { didTap = true; }, - child: new Draggable( - child: new Container( + child: Draggable( + child: Container( color: const Color(0xFFFFFF00), ), - feedback: new Container( + feedback: Container( width: 100.0, height: 100.0, color: const Color(0xFFFF0000), @@ -1341,25 +1341,25 @@ void main() { // This tears down the draggable without terminating the gesture sequence, // which used to trigger asserts in the multi-drag gesture recognizer. - await tester.pumpWidget(new Container(key: new UniqueKey())); + await tester.pumpWidget(Container(key: UniqueKey())); expect(didTap, isFalse); }); // Regression test for https://github.com/flutter/flutter/issues/6128. testWidgets('Draggable plays nice with onTap', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( - builder: (BuildContext context) => new GestureDetector( + OverlayEntry( + builder: (BuildContext context) => GestureDetector( onTap: () { /* registers a tap recognizer */ }, - child: new Draggable( - child: new Container( + child: Draggable( + child: Container( color: const Color(0xFFFFFF00), ), - feedback: new Container( + feedback: Container( width: 100.0, height: 100.0, color: const Color(0xFFFF0000), @@ -1383,15 +1383,15 @@ void main() { final List events = []; Offset firstLocation, secondLocation; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const Draggable( data: 1, child: Text('Source'), feedback: Text('Dragging') ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, @@ -1421,8 +1421,8 @@ void main() { await gesture.moveTo(secondLocation); await tester.pump(); - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: const [ Draggable( data: 1, @@ -1441,17 +1441,17 @@ void main() { testWidgets('Drag and drop - remove draggable', (WidgetTester tester) async { final List accepted = []; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ const Draggable( data: 1, child: Text('Source'), feedback: Text('Dragging') ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -1473,12 +1473,12 @@ void main() { expect(find.text('Dragging'), findsOneWidget); expect(find.text('Target'), findsOneWidget); - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -1512,10 +1512,10 @@ void main() { testWidgets('Tap above long-press draggable works', (WidgetTester tester) async { final List events = []; - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new Center( - child: new GestureDetector( + await tester.pumpWidget(MaterialApp( + home: Material( + child: Center( + child: GestureDetector( onTap: () { events.add('tap'); }, @@ -1537,10 +1537,10 @@ void main() { final List accepted = []; bool onDragCompletedCalled = false; - await tester.pumpWidget(new MaterialApp( - home: new Column( + await tester.pumpWidget(MaterialApp( + home: Column( children: [ - new LongPressDraggable( + LongPressDraggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -1548,9 +1548,9 @@ void main() { onDragCompletedCalled = true; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), @@ -1606,8 +1606,8 @@ void main() { testWidgets('long-press draggable calls onDragStartedCalled after long press', (WidgetTester tester) async { bool onDragStartedCalled = false; - await tester.pumpWidget(new MaterialApp( - home: new LongPressDraggable( + await tester.pumpWidget(MaterialApp( + home: LongPressDraggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -1654,17 +1654,17 @@ void main() { testWidgets('Drag and drop can contribute semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - await tester.pumpWidget(new MaterialApp( - home: new ListView( + final SemanticsTester semantics = SemanticsTester(tester); + await tester.pumpWidget(MaterialApp( + home: ListView( scrollDirection: Axis.horizontal, children: [ - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { return const Text('Target'); }, ), - new Container(width: 400.0), + Container(width: 400.0), const Draggable( data: 1, child: Text('H'), @@ -1692,42 +1692,42 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( id: 3, children: [ - new TestSemantics( + TestSemantics( id: 8, actions: [SemanticsAction.scrollLeft], children: [ - new TestSemantics( + TestSemantics( id: 4, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'Target', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'H', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'V', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 7, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'N', @@ -1752,35 +1752,35 @@ void main() { await tester.pump(); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( id: 3, children: [ - new TestSemantics( + TestSemantics( id: 8, children: [ - new TestSemantics( + TestSemantics( id: 4, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'Target', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'H', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'V', @@ -1812,8 +1812,8 @@ Future _testLongPressDraggableHapticFeedback({WidgetTester tester, bool ha } }); - await tester.pumpWidget(new MaterialApp( - home: new LongPressDraggable( + await tester.pumpWidget(MaterialApp( + home: LongPressDraggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -1849,18 +1849,18 @@ Future _testChildAnchorFeedbackPosition({WidgetTester tester, double top = int dragStartedCount = 0; await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Positioned( + Positioned( left: left, top: top, right: 0.0, bottom: 0.0, - child: new MaterialApp( - home: new Column( + child: MaterialApp( + home: Column( children: [ - new Draggable( + Draggable( data: 1, child: const Text('Source'), feedback: const Text('Dragging'), @@ -1868,9 +1868,9 @@ Future _testChildAnchorFeedbackPosition({WidgetTester tester, double top = ++dragStartedCount; }, ), - new DragTarget( + DragTarget( builder: (BuildContext context, List data, List rejects) { - return new Container(height: 100.0, child: const Text('Target')); + return Container(height: 100.0, child: const Text('Target')); }, onAccept: accepted.add, ), diff --git a/packages/flutter/test/widgets/drawer_test.dart b/packages/flutter/test/widgets/drawer_test.dart index a8f12eda70..30868b09ba 100644 --- a/packages/flutter/test/widgets/drawer_test.dart +++ b/packages/flutter/test/widgets/drawer_test.dart @@ -15,17 +15,17 @@ import 'semantics_tester.dart'; void main() { testWidgets('Drawer control test', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); BuildContext savedContext; await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { savedContext = context; - return new Scaffold( + return Scaffold( key: scaffoldKey, drawer: const Text('drawer'), - body: new Container(), + body: Container(), ); }, ), @@ -46,13 +46,13 @@ void main() { }); testWidgets('Drawer tap test', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( + MaterialApp( + home: Scaffold( key: scaffoldKey, drawer: const Text('drawer'), - body: new Container(), + body: Container(), ), ), ); @@ -78,23 +78,23 @@ void main() { }); testWidgets('Drawer drag cancel resume (LTR)', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( + MaterialApp( + home: Scaffold( key: scaffoldKey, - drawer: new Drawer( - child: new ListView( + drawer: Drawer( + child: ListView( children: [ const Text('drawer'), - new Container( + Container( height: 1000.0, color: Colors.blue[500], ), ], ), ), - body: new Container(), + body: Container(), ), ), ); @@ -128,25 +128,25 @@ void main() { }); testWidgets('Drawer drag cancel resume (RTL)', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Directionality( + MaterialApp( + home: Directionality( textDirection: TextDirection.rtl, - child: new Scaffold( + child: Scaffold( key: scaffoldKey, - drawer: new Drawer( - child: new ListView( + drawer: Drawer( + child: ListView( children: [ const Text('drawer'), - new Container( + Container( height: 1000.0, color: Colors.blue[500], ), ], ), ), - body: new Container(), + body: Container(), ), ), ), @@ -181,28 +181,28 @@ void main() { }); testWidgets('Drawer navigator back button', (WidgetTester tester) async { - final GlobalKey scaffoldKey = new GlobalKey(); + final GlobalKey scaffoldKey = GlobalKey(); bool buttonPressed = false; await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Scaffold( + return Scaffold( key: scaffoldKey, - drawer: new Drawer( - child: new ListView( + drawer: Drawer( + child: ListView( children: [ const Text('drawer'), - new FlatButton( + FlatButton( child: const Text('close'), onPressed: () => Navigator.pop(context), ), ], ), ), - body: new Container( - child: new FlatButton( + body: Container( + child: FlatButton( child: const Text('button'), onPressed: () { buttonPressed = true; }, ), @@ -233,14 +233,14 @@ void main() { testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final SemanticsTester semantics = new SemanticsTester(tester); - final GlobalKey scaffoldKey = new GlobalKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Scaffold( + return Scaffold( key: scaffoldKey, drawer: const Drawer(), ); @@ -261,17 +261,17 @@ void main() { }); testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final GlobalKey scaffoldKey = new GlobalKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Scaffold( + return Scaffold( key: scaffoldKey, drawer: const Drawer(), - body: new Container(), + body: Container(), ); }, ), @@ -288,17 +288,17 @@ void main() { }); testWidgets('Drawer contains route semantics flags', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final GlobalKey scaffoldKey = new GlobalKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final GlobalKey scaffoldKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Builder( + MaterialApp( + home: Builder( builder: (BuildContext context) { - return new Scaffold( + return Scaffold( key: scaffoldKey, drawer: const Drawer(), - body: new Container(), + body: Container(), ); }, ), diff --git a/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart b/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart index 653af01c7c..63be25b338 100644 --- a/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart +++ b/packages/flutter/test/widgets/editable_text_show_on_screen_test.dart @@ -14,24 +14,24 @@ void main() { const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00); testWidgets('tapping on a partly visible editable brings it fully on screen', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); + final ScrollController scrollController = ScrollController(); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Container( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Container( height: 300.0, - child: new ListView( + child: ListView( controller: scrollController, children: [ - new EditableText( + EditableText( controller: controller, focusNode: focusNode, style: textStyle, cursorColor: cursorColor, ), - new Container( + Container( height: 350.0, ), ], @@ -52,28 +52,28 @@ void main() { }); testWidgets('tapping on a partly visible editable brings it fully on screen with scrollInsets', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); + final ScrollController scrollController = ScrollController(); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Container( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Container( height: 300.0, - child: new ListView( + child: ListView( controller: scrollController, children: [ - new Container( + Container( height: 200.0, ), - new EditableText( + EditableText( scrollPadding: const EdgeInsets.all(50.0), controller: controller, focusNode: focusNode, style: textStyle, cursorColor: cursorColor, ), - new Container( + Container( height: 850.0, ), ], @@ -97,27 +97,27 @@ void main() { }); testWidgets('editable comes back on screen when entering text while it is off-screen', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(initialScrollOffset: 100.0); - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); + final ScrollController scrollController = ScrollController(initialScrollOffset: 100.0); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Container( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Container( height: 300.0, - child: new ListView( + child: ListView( controller: scrollController, children: [ - new Container( + Container( height: 350.0, ), - new EditableText( + EditableText( controller: controller, focusNode: focusNode, style: textStyle, cursorColor: cursorColor, ), - new Container( + Container( height: 350.0, ), ], @@ -145,28 +145,28 @@ void main() { testWidgets('entering text does not scroll when scrollPhysics.allowImplicitScrolling = false', (WidgetTester tester) async { // regression test for https://github.com/flutter/flutter/issues/19523 - final ScrollController scrollController = new ScrollController(initialScrollOffset: 100.0); - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); + final ScrollController scrollController = ScrollController(initialScrollOffset: 100.0); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Container( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Container( height: 300.0, - child: new ListView( + child: ListView( physics: const NoImplicitScrollPhysics(), controller: scrollController, children: [ - new Container( + Container( height: 350.0, ), - new EditableText( + EditableText( controller: controller, focusNode: focusNode, style: textStyle, cursorColor: cursorColor, ), - new Container( + Container( height: 350.0, ), ], @@ -194,25 +194,25 @@ void main() { testWidgets('entering text does not scroll a sourrounding PageView', (WidgetTester tester) async { // regression test for https://github.com/flutter/flutter/issues/19523 - final TextEditingController textController = new TextEditingController(); - final PageController pageController = new PageController(initialPage: 1); + final TextEditingController textController = TextEditingController(); + final PageController pageController = PageController(initialPage: 1); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new PageView( + child: Material( + child: PageView( controller: pageController, children: [ - new Container( + Container( color: Colors.red, ), - new Container( - child: new TextField( + Container( + child: TextField( controller: textController, ), color: Colors.green, ), - new Container( + Container( color: Colors.red, ), ], @@ -234,19 +234,19 @@ void main() { }); testWidgets('focused multi-line editable scrolls caret back into view when typing', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); + final ScrollController scrollController = ScrollController(); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); controller.text = 'Start\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nEnd'; - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Container( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Container( height: 300.0, - child: new ListView( + child: ListView( controller: scrollController, children: [ - new EditableText( + EditableText( maxLines: null, // multi-line controller: controller, focusNode: focusNode, @@ -270,9 +270,9 @@ void main() { // Enter text at end, which is off-screen. final String textToEnter = '${controller.text} HELLO'; - tester.testTextInput.updateEditingValue(new TextEditingValue( + tester.testTextInput.updateEditingValue(TextEditingValue( text: textToEnter, - selection: new TextSelection.collapsed(offset: textToEnter.length), + selection: TextSelection.collapsed(offset: textToEnter.length), )); await tester.pumpAndSettle(); @@ -283,32 +283,32 @@ void main() { }); testWidgets('scrolls into view with scrollInserts after the keyboard pops up', (WidgetTester tester) async { - final ScrollController scrollController = new ScrollController(); - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); + final ScrollController scrollController = ScrollController(); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); const Key container = Key('container'); - await tester.pumpWidget(new MaterialApp( - home: new Align( + await tester.pumpWidget(MaterialApp( + home: Align( alignment: Alignment.bottomCenter, - child: new Container( + child: Container( height: 300.0, - child: new ListView( + child: ListView( controller: scrollController, children: [ - new Container( + Container( key: container, height: 200.0, ), - new EditableText( + EditableText( scrollPadding: const EdgeInsets.only(bottom: 300.0), controller: controller, focusNode: focusNode, style: textStyle, cursorColor: cursorColor, ), - new Container( + Container( height: 400.0, ), ], @@ -334,6 +334,6 @@ class NoImplicitScrollPhysics extends AlwaysScrollableScrollPhysics { @override NoImplicitScrollPhysics applyTo(ScrollPhysics ancestor) { - return new NoImplicitScrollPhysics(parent: buildParent(ancestor)); + return NoImplicitScrollPhysics(parent: buildParent(ancestor)); } } diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index ae16a9e12b..2dba2fe4d4 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -15,9 +15,9 @@ import 'package:mockito/mockito.dart'; import 'semantics_tester.dart'; void main() { - final TextEditingController controller = new TextEditingController(); - final FocusNode focusNode = new FocusNode(); - final FocusScopeNode focusScopeNode = new FocusScopeNode(); + final TextEditingController controller = TextEditingController(); + final FocusNode focusNode = FocusNode(); + final FocusScopeNode focusScopeNode = FocusScopeNode(); const TextStyle textStyle = TextStyle(); const Color cursorColor = Color.fromARGB(0xFF, 0xFF, 0x00, 0x00); @@ -36,12 +36,12 @@ void main() { String serializedActionName, }) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, textInputAction: action, @@ -63,9 +63,9 @@ void main() { testWidgets('has expected defaults', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -84,9 +84,9 @@ void main() { testWidgets('cursor has expected width and radius', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -104,12 +104,12 @@ void main() { testWidgets('text keyboard is requested when maxLines is default', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -265,12 +265,12 @@ void main() { testWidgets('multiline keyboard is requested when set explicitly', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, keyboardType: TextInputType.multiline, @@ -294,12 +294,12 @@ void main() { testWidgets('Multiline keyboard with newline action is requested when maxLines = null', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, maxLines: null, @@ -323,12 +323,12 @@ void main() { testWidgets('Text keyboard is requested when explicitly set and maxLines = null', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, maxLines: null, @@ -355,12 +355,12 @@ void main() { 'Correct keyboard is requested when set explicitly and maxLines > 1', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, keyboardType: TextInputType.phone, @@ -386,12 +386,12 @@ void main() { testWidgets('multiline keyboard is requested when set implicitly', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, maxLines: 3, // Sets multiline keyboard implicitly. @@ -416,12 +416,12 @@ void main() { testWidgets('single line inputs have correct default keyboard', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, maxLines: 1, // Sets text keyboard implicitly. @@ -446,15 +446,15 @@ void main() { testWidgets('Fires onChanged when text changes via TextSelectionOverlay', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); + GlobalKey(); String changedValue; - final Widget widget = new MaterialApp( - home: new EditableText( + final Widget widget = MaterialApp( + home: EditableText( key: editableTextKey, - controller: new TextEditingController(), - focusNode: new FocusNode(), - style: new Typography(platform: TargetPlatform.android).black.subhead, + controller: TextEditingController(), + focusNode: FocusNode(), + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, selectionControls: materialTextSelectionControls, keyboardType: TextInputType.text, @@ -487,17 +487,17 @@ void main() { testWidgets('cursor layout has correct width', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); + GlobalKey(); String changedValue; - final Widget widget = new MaterialApp( - home: new RepaintBoundary( + final Widget widget = MaterialApp( + home: RepaintBoundary( key: const ValueKey(1), - child: new EditableText( + child: EditableText( key: editableTextKey, - controller: new TextEditingController(), - focusNode: new FocusNode(), - style: new Typography(platform: TargetPlatform.android).black.subhead, + controller: TextEditingController(), + focusNode: FocusNode(), + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, selectionControls: materialTextSelectionControls, keyboardType: TextInputType.text, @@ -537,17 +537,17 @@ void main() { testWidgets('cursor layout has correct radius', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); + GlobalKey(); String changedValue; - final Widget widget = new MaterialApp( - home: new RepaintBoundary( + final Widget widget = MaterialApp( + home: RepaintBoundary( key: const ValueKey(1), - child: new EditableText( + child: EditableText( key: editableTextKey, - controller: new TextEditingController(), - focusNode: new FocusNode(), - style: new Typography(platform: TargetPlatform.android).black.subhead, + controller: TextEditingController(), + focusNode: FocusNode(), + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, selectionControls: materialTextSelectionControls, keyboardType: TextInputType.text, @@ -589,15 +589,15 @@ void main() { testWidgets('Does not lose focus by default when "next" action is pressed', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); - final FocusNode focusNode = new FocusNode(); + GlobalKey(); + final FocusNode focusNode = FocusNode(); - final Widget widget = new MaterialApp( - home: new EditableText( + final Widget widget = MaterialApp( + home: EditableText( key: editableTextKey, - controller: new TextEditingController(), + controller: TextEditingController(), focusNode: focusNode, - style: new Typography(platform: TargetPlatform.android).black.subhead, + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, selectionControls: materialTextSelectionControls, keyboardType: TextInputType.text, @@ -623,15 +623,15 @@ void main() { 'Does not lose focus by default when "done" action is pressed and onEditingComplete is provided', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); - final FocusNode focusNode = new FocusNode(); + GlobalKey(); + final FocusNode focusNode = FocusNode(); - final Widget widget = new MaterialApp( - home: new EditableText( + final Widget widget = MaterialApp( + home: EditableText( key: editableTextKey, - controller: new TextEditingController(), + controller: TextEditingController(), focusNode: focusNode, - style: new Typography(platform: TargetPlatform.android).black.subhead, + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, selectionControls: materialTextSelectionControls, keyboardType: TextInputType.text, @@ -661,18 +661,18 @@ void main() { 'When "done" is pressed callbacks are invoked: onEditingComplete > onSubmitted', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); - final FocusNode focusNode = new FocusNode(); + GlobalKey(); + final FocusNode focusNode = FocusNode(); bool onEditingCompleteCalled = false; bool onSubmittedCalled = false; - final Widget widget = new MaterialApp( - home: new EditableText( + final Widget widget = MaterialApp( + home: EditableText( key: editableTextKey, - controller: new TextEditingController(), + controller: TextEditingController(), focusNode: focusNode, - style: new Typography(platform: TargetPlatform.android).black.subhead, + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, onEditingComplete: () { onEditingCompleteCalled = true; @@ -705,18 +705,18 @@ void main() { 'When "next" is pressed callbacks are invoked: onEditingComplete > onSubmitted', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); - final FocusNode focusNode = new FocusNode(); + GlobalKey(); + final FocusNode focusNode = FocusNode(); bool onEditingCompleteCalled = false; bool onSubmittedCalled = false; - final Widget widget = new MaterialApp( - home: new EditableText( + final Widget widget = MaterialApp( + home: EditableText( key: editableTextKey, - controller: new TextEditingController(), + controller: TextEditingController(), focusNode: focusNode, - style: new Typography(platform: TargetPlatform.android).black.subhead, + style: Typography(platform: TargetPlatform.android).black.subhead, cursorColor: Colors.blue, onEditingComplete: () { onEditingCompleteCalled = true; @@ -748,27 +748,27 @@ void main() { testWidgets('Changing controller updates EditableText', (WidgetTester tester) async { final GlobalKey editableTextKey = - new GlobalKey(); + GlobalKey(); final TextEditingController controller1 = - new TextEditingController(text: 'Wibble'); + TextEditingController(text: 'Wibble'); final TextEditingController controller2 = - new TextEditingController(text: 'Wobble'); + TextEditingController(text: 'Wobble'); TextEditingController currentController = controller1; StateSetter setState; Widget builder() { - return new StatefulBuilder( + return StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new EditableText( + child: Center( + child: Material( + child: EditableText( key: editableTextKey, controller: currentController, - focusNode: new FocusNode(), - style: new Typography(platform: TargetPlatform.android) + focusNode: FocusNode(), + style: Typography(platform: TargetPlatform.android) .black .subhead, cursorColor: Colors.blue, @@ -815,15 +815,15 @@ void main() { testWidgets('EditableText identifies as text field (w/ focus) in semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -852,18 +852,18 @@ void main() { testWidgets('EditableText includes text as value in semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const String value1 = 'EditableText content'; controller.text = value1; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -902,8 +902,8 @@ void main() { controller.text = value1; await tester.pumpWidget( - new MaterialApp( - home: new EditableText( + MaterialApp( + home: EditableText( controller: controller, selectionControls: materialTextSelectionControls, focusNode: focusNode, @@ -940,12 +940,12 @@ void main() { testWidgets('exposes correct cursor movement semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); controller.text = 'test'; - await tester.pumpWidget(new MaterialApp( - home: new EditableText( + await tester.pumpWidget(MaterialApp( + home: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -960,7 +960,7 @@ void main() { )); controller.selection = - new TextSelection.collapsed(offset: controller.text.length); + TextSelection.collapsed(offset: controller.text.length); await tester.pumpAndSettle(); // At end, can only go backwards. @@ -976,7 +976,7 @@ void main() { )); controller.selection = - new TextSelection.collapsed(offset: controller.text.length - 2); + TextSelection.collapsed(offset: controller.text.length - 2); await tester.pumpAndSettle(); // Somewhere in the middle, can go in both directions. @@ -1012,15 +1012,15 @@ void main() { }); testWidgets('can move cursor with a11y means - character', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const bool doNotExtendSelection = false; controller.text = 'test'; controller.selection = - new TextSelection.collapsed(offset: controller.text.length); + TextSelection.collapsed(offset: controller.text.length); - await tester.pumpWidget(new MaterialApp( - home: new EditableText( + await tester.pumpWidget(MaterialApp( + home: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -1101,15 +1101,15 @@ void main() { }); testWidgets('can move cursor with a11y means - word', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const bool doNotExtendSelection = false; controller.text = 'test for words'; controller.selection = - new TextSelection.collapsed(offset: controller.text.length); + TextSelection.collapsed(offset: controller.text.length); - await tester.pumpWidget(new MaterialApp( - home: new EditableText( + await tester.pumpWidget(MaterialApp( + home: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -1199,16 +1199,16 @@ void main() { testWidgets('can extend selection with a11y means - character', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const bool extendSelection = true; const bool doNotExtendSelection = false; controller.text = 'test'; controller.selection = - new TextSelection.collapsed(offset: controller.text.length); + TextSelection.collapsed(offset: controller.text.length); - await tester.pumpWidget(new MaterialApp( - home: new EditableText( + await tester.pumpWidget(MaterialApp( + home: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -1297,16 +1297,16 @@ void main() { testWidgets('can extend selection with a11y means - word', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const bool extendSelection = true; const bool doNotExtendSelection = false; controller.text = 'test for words'; controller.selection = - new TextSelection.collapsed(offset: controller.text.length); + TextSelection.collapsed(offset: controller.text.length); - await tester.pumpWidget(new MaterialApp( - home: new EditableText( + await tester.pumpWidget(MaterialApp( + home: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -1396,12 +1396,12 @@ void main() { testWidgets('password fields have correct semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); controller.text = 'super-secret-password!!1'; - await tester.pumpWidget(new MaterialApp( - home: new EditableText( + await tester.pumpWidget(MaterialApp( + home: EditableText( obscureText: true, controller: controller, focusNode: focusNode, @@ -1415,14 +1415,14 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isTextField, SemanticsFlag.isObscured @@ -1446,8 +1446,8 @@ void main() { group('a11y copy/cut/paste', () { Future _buildApp( MockTextSelectionControls controls, WidgetTester tester) { - return tester.pumpWidget(new MaterialApp( - home: new EditableText( + return tester.pumpWidget(MaterialApp( + home: EditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -1462,16 +1462,16 @@ void main() { setUp(() { controller.text = 'test'; controller.selection = - new TextSelection.collapsed(offset: controller.text.length); + TextSelection.collapsed(offset: controller.text.length); - controls = new MockTextSelectionControls(); - when(controls.buildHandle(any, any, any)).thenReturn(new Container()); + controls = MockTextSelectionControls(); + when(controls.buildHandle(any, any, any)).thenReturn(Container()); when(controls.buildToolbar(any, any, any, any)) - .thenReturn(new Container()); + .thenReturn(Container()); }); testWidgets('are exposed', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); when(controls.canCopy(any)).thenReturn(false); when(controls.canCut(any)).thenReturn(false); @@ -1558,7 +1558,7 @@ void main() { }); testWidgets('can copy/cut/paste with a11y', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); when(controls.canCopy(any)).thenReturn(true); when(controls.canCut(any)).thenReturn(true); @@ -1573,16 +1573,16 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, children: [ - new TestSemantics( + TestSemantics( id: 2, flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: expectedNodeId, flags: [ SemanticsFlag.isTextField, @@ -1597,7 +1597,7 @@ void main() { SemanticsAction.paste ], value: 'test', - textSelection: new TextSelection.collapsed( + textSelection: TextSelection.collapsed( offset: controller.text.length), textDirection: TextDirection.ltr, ), @@ -1627,8 +1627,8 @@ void main() { (WidgetTester tester) async { controller.text = 'Hello World'; - await tester.pumpWidget(new MaterialApp( - home: new CustomStyleEditableText( + await tester.pumpWidget(MaterialApp( + home: CustomStyleEditableText( controller: controller, focusNode: focusNode, style: textStyle, @@ -1645,16 +1645,16 @@ void main() { testWidgets('autofocus sets cursor to the end of text', (WidgetTester tester) async { const String text = 'hello world'; - final FocusScopeNode focusScopeNode = new FocusScopeNode(); - final FocusNode focusNode = new FocusNode(); + final FocusScopeNode focusScopeNode = FocusScopeNode(); + final FocusNode focusNode = FocusNode(); controller.text = text; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new FocusScope( + child: FocusScope( node: focusScopeNode, autofocus: true, - child: new EditableText( + child: EditableText( controller: controller, focusNode: focusNode, autofocus: true, @@ -1686,13 +1686,13 @@ class CustomStyleEditableText extends EditableText { ); @override CustomStyleEditableTextState createState() => - new CustomStyleEditableTextState(); + CustomStyleEditableTextState(); } class CustomStyleEditableTextState extends EditableTextState { @override TextSpan buildTextSpan() { - return new TextSpan( + return TextSpan( style: const TextStyle(fontStyle: FontStyle.italic), text: widget.controller.value.text, ); diff --git a/packages/flutter/test/widgets/ensure_visible_test.dart b/packages/flutter/test/widgets/ensure_visible_test.dart index fb88890c62..4d6531b4fd 100644 --- a/packages/flutter/test/widgets/ensure_visible_test.dart +++ b/packages/flutter/test/widgets/ensure_visible_test.dart @@ -8,28 +8,28 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; -Finder findKey(int i) => find.byKey(new ValueKey(i)); +Finder findKey(int i) => find.byKey(ValueKey(i)); Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse = false }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new SingleChildScrollView( + child: SingleChildScrollView( scrollDirection: scrollDirection, reverse: reverse, - child: new ListBody( + child: ListBody( mainAxis: scrollDirection, children: [ - new Container(key: const ValueKey(0), width: 200.0, height: 200.0), - new Container(key: const ValueKey(1), width: 200.0, height: 200.0), - new Container(key: const ValueKey(2), width: 200.0, height: 200.0), - new Container(key: const ValueKey(3), width: 200.0, height: 200.0), - new Container(key: const ValueKey(4), width: 200.0, height: 200.0), - new Container(key: const ValueKey(5), width: 200.0, height: 200.0), - new Container(key: const ValueKey(6), width: 200.0, height: 200.0), + Container(key: const ValueKey(0), width: 200.0, height: 200.0), + Container(key: const ValueKey(1), width: 200.0, height: 200.0), + Container(key: const ValueKey(2), width: 200.0, height: 200.0), + Container(key: const ValueKey(3), width: 200.0, height: 200.0), + Container(key: const ValueKey(4), width: 200.0, height: 200.0), + Container(key: const ValueKey(5), width: 200.0, height: 200.0), + Container(key: const ValueKey(6), width: 200.0, height: 200.0), ], ), ), @@ -39,24 +39,24 @@ Widget buildSingleChildScrollView(Axis scrollDirection, { bool reverse = false } } Widget buildListView(Axis scrollDirection, { bool reverse = false, bool shrinkWrap = false }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new ListView( + child: ListView( scrollDirection: scrollDirection, reverse: reverse, shrinkWrap: shrinkWrap, children: [ - new Container(key: const ValueKey(0), width: 200.0, height: 200.0), - new Container(key: const ValueKey(1), width: 200.0, height: 200.0), - new Container(key: const ValueKey(2), width: 200.0, height: 200.0), - new Container(key: const ValueKey(3), width: 200.0, height: 200.0), - new Container(key: const ValueKey(4), width: 200.0, height: 200.0), - new Container(key: const ValueKey(5), width: 200.0, height: 200.0), - new Container(key: const ValueKey(6), width: 200.0, height: 200.0), + Container(key: const ValueKey(0), width: 200.0, height: 200.0), + Container(key: const ValueKey(1), width: 200.0, height: 200.0), + Container(key: const ValueKey(2), width: 200.0, height: 200.0), + Container(key: const ValueKey(3), width: 200.0, height: 200.0), + Container(key: const ValueKey(4), width: 200.0, height: 200.0), + Container(key: const ValueKey(5), width: 200.0, height: 200.0), + Container(key: const ValueKey(6), width: 200.0, height: 200.0), ], ), ), @@ -179,22 +179,22 @@ void main() { BuildContext findContext(int i) => tester.element(findKey(i)); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new SingleChildScrollView( - child: new ListBody( + child: SingleChildScrollView( + child: ListBody( children: [ - new Container(height: 200.0), - new Container(height: 200.0), - new Container(height: 200.0), - new Container( + Container(height: 200.0), + Container(height: 200.0), + Container(height: 200.0), + Container( height: 200.0, - child: new Center( - child: new Transform( - transform: new Matrix4.rotationZ(math.pi), - child: new Container( + child: Center( + child: Transform( + transform: Matrix4.rotationZ(math.pi), + child: Container( key: const ValueKey(0), width: 100.0, height: 100.0, @@ -203,9 +203,9 @@ void main() { ), ), ), - new Container(height: 200.0), - new Container(height: 200.0), - new Container(height: 200.0), + Container(height: 200.0), + Container(height: 200.0), + Container(height: 200.0), ], ), ), @@ -381,22 +381,22 @@ void main() { } Widget buildSliver(int i) { - return new SliverToBoxAdapter( - key: new ValueKey(i), - child: new Container(width: 200.0, height: 200.0), + return SliverToBoxAdapter( + key: ValueKey(i), + child: Container(width: 200.0, height: 200.0), ); } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new Scrollable( + child: Scrollable( viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( offset: offset, center: const ValueKey(4), slivers: [ @@ -434,23 +434,23 @@ void main() { await tester.pump(); } - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new ListView( + child: ListView( children: [ - new Container(height: 200.0), - new Container(height: 200.0), - new Container(height: 200.0), - new Container( + Container(height: 200.0), + Container(height: 200.0), + Container(height: 200.0), + Container( height: 200.0, - child: new Center( - child: new Transform( - transform: new Matrix4.rotationZ(math.pi), - child: new Container( + child: Center( + child: Transform( + transform: Matrix4.rotationZ(math.pi), + child: Container( key: const ValueKey(0), width: 100.0, height: 100.0, @@ -459,9 +459,9 @@ void main() { ), ), ), - new Container(height: 200.0), - new Container(height: 200.0), - new Container(height: 200.0), + Container(height: 200.0), + Container(height: 200.0), + Container(height: 200.0), ], ), ), @@ -634,31 +634,31 @@ void main() { } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new Scrollable( + child: Scrollable( viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( offset: offset, center: const ValueKey('center'), slivers: [ - new SliverToBoxAdapter(child: new Container(key: const ValueKey(-6), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(-5), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(-4), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(-3), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(-2), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(-1), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(0), width: 200.0, height: 200.0), key: const ValueKey('center')), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(1), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(2), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(3), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(4), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(5), width: 200.0, height: 200.0)), - new SliverToBoxAdapter(child: new Container(key: const ValueKey(6), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(-6), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(-5), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(-4), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(-3), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(-2), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(-1), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(0), width: 200.0, height: 200.0), key: const ValueKey('center')), + SliverToBoxAdapter(child: Container(key: const ValueKey(1), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(2), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(3), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(4), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(5), width: 200.0, height: 200.0)), + SliverToBoxAdapter(child: Container(key: const ValueKey(6), width: 200.0, height: 200.0)), ], ); }, diff --git a/packages/flutter/test/widgets/error_widget_builder_test.dart b/packages/flutter/test/widgets/error_widget_builder_test.dart index 73cc9e775b..b0372d4a09 100644 --- a/packages/flutter/test/widgets/error_widget_builder_test.dart +++ b/packages/flutter/test/widgets/error_widget_builder_test.dart @@ -11,8 +11,8 @@ void main() { return const Text('oopsie!', textDirection: TextDirection.ltr); }; await tester.pumpWidget( - new SizedBox( - child: new Builder( + SizedBox( + child: Builder( builder: (BuildContext context) { throw 'test'; }, diff --git a/packages/flutter/test/widgets/fade_in_image_test.dart b/packages/flutter/test/widgets/fade_in_image_test.dart index 475151c8a6..1c74010472 100644 --- a/packages/flutter/test/widgets/fade_in_image_test.dart +++ b/packages/flutter/test/widgets/fade_in_image_test.dart @@ -23,12 +23,12 @@ Future main() async { RawImage displayedImage() => tester.widget(find.byType(RawImage)); // The placeholder is expected to be already loaded - final TestImageProvider placeholderProvider = new TestImageProvider(placeholderImage); + final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage); // Test case: long loading image - final TestImageProvider imageProvider = new TestImageProvider(targetImage); + final TestImageProvider imageProvider = TestImageProvider(targetImage); - await tester.pumpWidget(new FadeInImage( + await tester.pumpWidget(FadeInImage( placeholder: placeholderProvider, image: imageProvider, fadeOutDuration: const Duration(milliseconds: 50), @@ -59,7 +59,7 @@ Future main() async { // Test case: re-use state object (didUpdateWidget) final dynamic stateBeforeDidUpdateWidget = state(); - await tester.pumpWidget(new FadeInImage( + await tester.pumpWidget(FadeInImage( placeholder: placeholderProvider, image: imageProvider, )); @@ -70,8 +70,8 @@ Future main() async { // Test case: new state object but cached image final dynamic stateBeforeRecreate = state(); - await tester.pumpWidget(new Container()); // clear widget tree to prevent state reuse - await tester.pumpWidget(new FadeInImage( + await tester.pumpWidget(Container()); // clear widget tree to prevent state reuse + await tester.pumpWidget(FadeInImage( placeholder: placeholderProvider, image: imageProvider, )); @@ -86,13 +86,13 @@ Future main() async { RawImage displayedImage() => tester.widget(find.byType(RawImage)); // The placeholder is expected to be already loaded - final TestImageProvider placeholderProvider = new TestImageProvider(placeholderImage); - final TestImageProvider secondPlaceholderProvider = new TestImageProvider(secondPlaceholderImage); + final TestImageProvider placeholderProvider = TestImageProvider(placeholderImage); + final TestImageProvider secondPlaceholderProvider = TestImageProvider(secondPlaceholderImage); // Test case: long loading image - final TestImageProvider imageProvider = new TestImageProvider(targetImage); + final TestImageProvider imageProvider = TestImageProvider(targetImage); - await tester.pumpWidget(new FadeInImage( + await tester.pumpWidget(FadeInImage( placeholder: placeholderProvider, image: imageProvider, fadeOutDuration: const Duration(milliseconds: 50), @@ -104,7 +104,7 @@ Future main() async { expect(displayedImage().image, same(placeholderImage)); // placeholder completed expect(displayedImage().image, isNot(same(secondPlaceholderImage))); - await tester.pumpWidget(new FadeInImage( + await tester.pumpWidget(FadeInImage( placeholder: secondPlaceholderProvider, image: imageProvider, fadeOutDuration: const Duration(milliseconds: 50), diff --git a/packages/flutter/test/widgets/fade_transition_test.dart b/packages/flutter/test/widgets/fade_transition_test.dart index 7a27f4fc38..32ee892352 100644 --- a/packages/flutter/test/widgets/fade_transition_test.dart +++ b/packages/flutter/test/widgets/fade_transition_test.dart @@ -14,11 +14,11 @@ void main() { log.add(message); }; debugPrintBuildScope = true; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), duration: const Duration(seconds: 2), ); - await tester.pumpWidget(new FadeTransition( + await tester.pumpWidget(FadeTransition( opacity: controller, child: const Placeholder(), )); diff --git a/packages/flutter/test/widgets/fitted_box_test.dart b/packages/flutter/test/widgets/fitted_box_test.dart index 895d36ff97..9612c672c8 100644 --- a/packages/flutter/test/widgets/fitted_box_test.dart +++ b/packages/flutter/test/widgets/fitted_box_test.dart @@ -8,16 +8,16 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Can size according to aspect ratio', (WidgetTester tester) async { - final Key outside = new UniqueKey(); - final Key inside = new UniqueKey(); + final Key outside = UniqueKey(); + final Key inside = UniqueKey(); await tester.pumpWidget( - new Center( - child: new Container( + Center( + child: Container( width: 200.0, - child: new FittedBox( + child: FittedBox( key: outside, - child: new Container( + child: Container( key: inside, width: 100.0, height: 50.0, @@ -43,17 +43,17 @@ void main() { }); testWidgets('Can contain child', (WidgetTester tester) async { - final Key outside = new UniqueKey(); - final Key inside = new UniqueKey(); + final Key outside = UniqueKey(); + final Key inside = UniqueKey(); await tester.pumpWidget( - new Center( - child: new Container( + Center( + child: Container( width: 200.0, height: 200.0, - child: new FittedBox( + child: FittedBox( key: outside, - child: new Container( + child: Container( key: inside, width: 100.0, height: 50.0, @@ -78,18 +78,18 @@ void main() { }); testWidgets('Child can conver', (WidgetTester tester) async { - final Key outside = new UniqueKey(); - final Key inside = new UniqueKey(); + final Key outside = UniqueKey(); + final Key inside = UniqueKey(); await tester.pumpWidget( - new Center( - child: new Container( + Center( + child: Container( width: 200.0, height: 200.0, - child: new FittedBox( + child: FittedBox( key: outside, fit: BoxFit.cover, - child: new Container( + child: Container( key: inside, width: 100.0, height: 50.0, @@ -114,10 +114,10 @@ void main() { }); testWidgets('FittedBox with no child', (WidgetTester tester) async { - final Key key = new UniqueKey(); + final Key key = UniqueKey(); await tester.pumpWidget( - new Center( - child: new FittedBox( + Center( + child: FittedBox( key: key, fit: BoxFit.cover, ), @@ -130,23 +130,23 @@ void main() { }); testWidgets('Child can be aligned multiple ways in a row', (WidgetTester tester) async { - final Key outside = new UniqueKey(); - final Key inside = new UniqueKey(); + final Key outside = UniqueKey(); + final Key inside = UniqueKey(); { // align RTL await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new FittedBox( + child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.bottomEnd, - child: new Container( + child: Container( key: inside, width: 10.0, height: 10.0, @@ -177,17 +177,17 @@ void main() { { // change direction await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new FittedBox( + child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.bottomEnd, - child: new Container( + child: Container( key: inside, width: 10.0, height: 10.0, @@ -218,17 +218,17 @@ void main() { { // change alignment await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new FittedBox( + child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.center, - child: new Container( + child: Container( key: inside, width: 10.0, height: 10.0, @@ -259,17 +259,17 @@ void main() { { // change size await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new FittedBox( + child: FittedBox( key: outside, fit: BoxFit.scaleDown, alignment: AlignmentDirectional.center, - child: new Container( + child: Container( key: inside, width: 30.0, height: 10.0, @@ -300,17 +300,17 @@ void main() { { // change fit await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 100.0, - child: new FittedBox( + child: FittedBox( key: outside, fit: BoxFit.fill, alignment: AlignmentDirectional.center, - child: new Container( + child: Container( key: inside, width: 30.0, height: 10.0, @@ -412,13 +412,13 @@ void main() { for (double c in values) { for (double d in values) { await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( width: a, height: b, - child: new FittedBox( + child: FittedBox( fit: BoxFit.none, - child: new SizedBox( + child: SizedBox( width: c, height: d, child: const RepaintBoundary( @@ -441,24 +441,24 @@ void main() { }); testWidgets('Big child into small fitted box - hit testing', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); bool _pointerDown = false; await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( width: 100.0, height: 100.0, - child: new FittedBox( + child: FittedBox( fit: BoxFit.contain, alignment: FractionalOffset.center, - child: new SizedBox( + child: SizedBox( width: 1000.0, height: 1000.0, - child: new Listener( + child: Listener( onPointerDown: (PointerDownEvent event) { _pointerDown = true; }, - child: new Container( + child: Container( key: key1, color: const Color(0xFF000000), ) diff --git a/packages/flutter/test/widgets/flex_test.dart b/packages/flutter/test/widgets/flex_test.dart index f124ebd892..f1ae4d7762 100644 --- a/packages/flutter/test/widgets/flex_test.dart +++ b/packages/flutter/test/widgets/flex_test.dart @@ -10,22 +10,22 @@ void main() { testWidgets('Can hit test flex children of stacks', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Container( + child: Container( color: const Color(0xFF00FF00), - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 10.0, left: 10.0, - child: new Column( + child: Column( children: [ - new GestureDetector( + GestureDetector( onTap: () { didReceiveTap = true; }, - child: new Container( + child: Container( color: const Color(0xFF0000FF), width: 100.0, height: 100.0, @@ -49,7 +49,7 @@ void main() { testWidgets('Flexible defaults to loose', (WidgetTester tester) async { await tester.pumpWidget( - new Row( + Row( textDirection: TextDirection.ltr, children: const [ Flexible(child: SizedBox(width: 100.0, height: 200.0)), @@ -63,7 +63,7 @@ void main() { testWidgets('Can pass null for flex', (WidgetTester tester) async { await tester.pumpWidget( - new Row( + Row( textDirection: TextDirection.ltr, children: const [ Expanded(flex: null, child: Text('one', textDirection: TextDirection.ltr)), @@ -76,34 +76,34 @@ void main() { testWidgets('Doesn\'t overflow because of floating point accumulated error', (WidgetTester tester) async { // both of these cases have failed in the past due to floating point issues await tester.pumpWidget( - new Center( - child: new Container( + Center( + child: Container( height: 400.0, - child: new Column( + child: Column( children: [ - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), ], ), ), ), ); await tester.pumpWidget( - new Center( - child: new Container( + Center( + child: Container( height: 199.0, - child: new Column( + child: Column( children: [ - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), - new Expanded(child: new Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), + Expanded(child: Container()), ], ), ), @@ -116,20 +116,20 @@ void main() { // we only get a single exception. Otherwise we'd get two, the one we want and // an extra one when we discover we never computed a size. await tester.pumpWidget( - new Column( + Column( children: [ - new Column(), + Column(), ], ), Duration.zero, EnginePhase.layout, ); await tester.pumpWidget( - new Column( + Column( children: [ - new Column( + Column( children: [ - new Expanded(child: new Container()), + Expanded(child: Container()), ], ), ], diff --git a/packages/flutter/test/widgets/flow_test.dart b/packages/flutter/test/widgets/flow_test.dart index adc55a9127..90c31f3592 100644 --- a/packages/flutter/test/widgets/flow_test.dart +++ b/packages/flutter/test/widgets/flow_test.dart @@ -20,7 +20,7 @@ class TestFlowDelegate extends FlowDelegate { void paintChildren(FlowPaintingContext context) { double dy = startOffset.value; for (int i = 0; i < context.childCount; ++i) { - context.paintChild(i, transform: new Matrix4.translationValues(0.0, dy, 0.0)); + context.paintChild(i, transform: Matrix4.translationValues(0.0, dy, 0.0)); dy += 0.75 * context.getChildSize(i).height; } } @@ -47,28 +47,28 @@ class OpacityFlowDelegate extends FlowDelegate { void main() { testWidgets('Flow control test', (WidgetTester tester) async { - final AnimationController startOffset = new AnimationController.unbounded( + final AnimationController startOffset = AnimationController.unbounded( vsync: tester, ); final List log = []; Widget buildBox(int i) { - return new GestureDetector( + return GestureDetector( onTap: () { log.add(i); }, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: const Color(0xFF0000FF), - child: new Text('$i', textDirection: TextDirection.ltr) + child: Text('$i', textDirection: TextDirection.ltr) ) ); } await tester.pumpWidget( - new Flow( - delegate: new TestFlowDelegate(startOffset: startOffset), + Flow( + delegate: TestFlowDelegate(startOffset: startOffset), children: [ buildBox(0), buildBox(1), @@ -103,10 +103,10 @@ void main() { testWidgets('Flow opacity layer', (WidgetTester tester) async { const double opacity = 0.2; await tester.pumpWidget( - new Flow( - delegate: new OpacityFlowDelegate(opacity), + Flow( + delegate: OpacityFlowDelegate(opacity), children: [ - new Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 100.0), ] ) ); diff --git a/packages/flutter/test/widgets/focus_test.dart b/packages/flutter/test/widgets/focus_test.dart index 274d8a0755..c02633bb62 100644 --- a/packages/flutter/test/widgets/focus_test.dart +++ b/packages/flutter/test/widgets/focus_test.dart @@ -18,11 +18,11 @@ class TestFocusable extends StatefulWidget { final bool autofocus; @override - TestFocusableState createState() => new TestFocusableState(); + TestFocusableState createState() => TestFocusableState(); } class TestFocusableState extends State { - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); bool _didAutofocus = false; @override @@ -42,12 +42,12 @@ class TestFocusableState extends State { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { FocusScope.of(context).requestFocus(focusNode); }, - child: new AnimatedBuilder( + child: AnimatedBuilder( animation: focusNode, builder: (BuildContext context, Widget child) { - return new Text(focusNode.hasFocus ? widget.yes : widget.no, textDirection: TextDirection.ltr); + return Text(focusNode.hasFocus ? widget.yes : widget.no, textDirection: TextDirection.ltr); }, ), ); @@ -57,7 +57,7 @@ class TestFocusableState extends State { void main() { testWidgets('Can have multiple focused children and they update accordingly', (WidgetTester tester) async { await tester.pumpWidget( - new Column( + Column( children: const [ TestFocusable( no: 'a', @@ -137,14 +137,14 @@ void main() { }); testWidgets('Can move focus to scope', (WidgetTester tester) async { - final FocusScopeNode parentFocusScope = new FocusScopeNode(); - final FocusScopeNode childFocusScope = new FocusScopeNode(); + final FocusScopeNode parentFocusScope = FocusScopeNode(); + final FocusScopeNode childFocusScope = FocusScopeNode(); await tester.pumpWidget( - new FocusScope( + FocusScope( node: parentFocusScope, autofocus: true, - child: new Row( + child: Row( textDirection: TextDirection.ltr, children: const [ TestFocusable( @@ -191,9 +191,9 @@ void main() { await tester.idle(); await tester.pumpWidget( - new FocusScope( + FocusScope( node: parentFocusScope, - child: new Row( + child: Row( textDirection: TextDirection.ltr, children: [ const TestFocusable( @@ -201,9 +201,9 @@ void main() { yes: 'A FOCUSED', autofocus: false, ), - new FocusScope( + FocusScope( node: childFocusScope, - child: new Container( + child: Container( width: 50.0, height: 50.0, ), @@ -217,9 +217,9 @@ void main() { expect(find.text('A FOCUSED'), findsNothing); await tester.pumpWidget( - new FocusScope( + FocusScope( node: parentFocusScope, - child: new Row( + child: Row( textDirection: TextDirection.ltr, children: const [ TestFocusable( diff --git a/packages/flutter/test/widgets/form_test.dart b/packages/flutter/test/widgets/form_test.dart index 526e1e1527..fae19d9de0 100644 --- a/packages/flutter/test/widgets/form_test.dart +++ b/packages/flutter/test/widgets/form_test.dart @@ -7,17 +7,17 @@ import 'package:flutter/material.dart'; void main() { testWidgets('onSaved callback is called', (WidgetTester tester) async { - final GlobalKey formKey = new GlobalKey(); + final GlobalKey formKey = GlobalKey(); String fieldValue; Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( + child: Center( + child: Material( + child: Form( key: formKey, - child: new TextFormField( + child: TextFormField( onSaved: (String value) { fieldValue = value; }, ), ), @@ -45,12 +45,12 @@ void main() { String fieldValue; Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( - child: new TextField( + child: Center( + child: Material( + child: Form( + child: TextField( onChanged: (String value) { fieldValue = value; }, ), ), @@ -74,18 +74,18 @@ void main() { }); testWidgets('Validator sets the error text only when validate is called', (WidgetTester tester) async { - final GlobalKey formKey = new GlobalKey(); + final GlobalKey formKey = GlobalKey(); String errorText(String value) => value + '/error'; Widget builder(bool autovalidate) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( + child: Center( + child: Material( + child: Form( key: formKey, autovalidate: autovalidate, - child: new TextFormField( + child: TextFormField( validator: errorText, ), ), @@ -123,25 +123,25 @@ void main() { }); testWidgets('Multiple TextFormFields communicate', (WidgetTester tester) async { - final GlobalKey formKey = new GlobalKey(); - final GlobalKey> fieldKey = new GlobalKey>(); + final GlobalKey formKey = GlobalKey(); + final GlobalKey> fieldKey = GlobalKey>(); // Input 2's validator depends on a input 1's value. String errorText(String input) => '${fieldKey.currentState.value}/error'; Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( + child: Center( + child: Material( + child: Form( key: formKey, autovalidate: true, - child: new ListView( + child: ListView( children: [ - new TextFormField( + TextFormField( key: fieldKey, ), - new TextFormField( + TextFormField( validator: errorText, ), ], @@ -169,15 +169,15 @@ void main() { testWidgets('Provide initial value to input when no controller is specified', (WidgetTester tester) async { const String initialValue = 'hello'; - final GlobalKey> inputKey = new GlobalKey>(); + final GlobalKey> inputKey = GlobalKey>(); Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( - child: new TextFormField( + child: Center( + child: Material( + child: Form( + child: TextFormField( key: inputKey, initialValue: 'hello', ), @@ -207,17 +207,17 @@ void main() { }); testWidgets('Controller defines initial value', (WidgetTester tester) async { - final TextEditingController controller = new TextEditingController(text: 'hello'); + final TextEditingController controller = TextEditingController(text: 'hello'); const String initialValue = 'hello'; - final GlobalKey> inputKey = new GlobalKey>(); + final GlobalKey> inputKey = GlobalKey>(); Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( - child: new TextFormField( + child: Center( + child: Material( + child: Form( + child: TextFormField( key: inputKey, controller: controller, ), @@ -249,18 +249,18 @@ void main() { }); testWidgets('TextFormField resets to its initial value', (WidgetTester tester) async { - final GlobalKey formKey = new GlobalKey(); - final GlobalKey> inputKey = new GlobalKey>(); - final TextEditingController controller = new TextEditingController(text: 'Plover'); + final GlobalKey formKey = GlobalKey(); + final GlobalKey> inputKey = GlobalKey>(); + final TextEditingController controller = TextEditingController(text: 'Plover'); Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( + child: Center( + child: Material( + child: Form( key: formKey, - child: new TextFormField( + child: TextFormField( key: inputKey, controller: controller, // initialValue is 'Plover' @@ -290,23 +290,23 @@ void main() { }); testWidgets('TextEditingController updates to/from form field value', (WidgetTester tester) async { - final TextEditingController controller1 = new TextEditingController(text: 'Foo'); - final TextEditingController controller2 = new TextEditingController(text: 'Bar'); - final GlobalKey> inputKey = new GlobalKey>(); + final TextEditingController controller1 = TextEditingController(text: 'Foo'); + final TextEditingController controller2 = TextEditingController(text: 'Bar'); + final GlobalKey> inputKey = GlobalKey>(); TextEditingController currentController; StateSetter setState; Widget builder() { - return new StatefulBuilder( + return StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( - child: new TextFormField( + child: Center( + child: Material( + child: Form( + child: TextFormField( key: inputKey, controller: currentController, ), @@ -392,17 +392,17 @@ void main() { }); testWidgets('No crash when a TextFormField is removed from the tree', (WidgetTester tester) async { - final GlobalKey formKey = new GlobalKey(); + final GlobalKey formKey = GlobalKey(); String fieldValue; Widget builder(bool remove) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Material( - child: new Form( + child: Center( + child: Material( + child: Form( key: formKey, - child: remove ? new Container() : new TextFormField( + child: remove ? Container() : TextFormField( autofocus: true, onSaved: (String value) { fieldValue = value; }, validator: (String value) { return value.isEmpty ? null : 'yes'; } diff --git a/packages/flutter/test/widgets/fractionally_sized_box_test.dart b/packages/flutter/test/widgets/fractionally_sized_box_test.dart index 10e12f9cd4..2feb6b5046 100644 --- a/packages/flutter/test/widgets/fractionally_sized_box_test.dart +++ b/packages/flutter/test/widgets/fractionally_sized_box_test.dart @@ -8,18 +8,18 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('FractionallySizedBox', (WidgetTester tester) async { - final GlobalKey inner = new GlobalKey(); - await tester.pumpWidget(new OverflowBox( + final GlobalKey inner = GlobalKey(); + await tester.pumpWidget(OverflowBox( minWidth: 0.0, maxWidth: 100.0, minHeight: 0.0, maxHeight: 100.0, alignment: const Alignment(-1.0, -1.0), - child: new Center( - child: new FractionallySizedBox( + child: Center( + child: FractionallySizedBox( widthFactor: 0.5, heightFactor: 0.25, - child: new Container( + child: Container( key: inner ) ) diff --git a/packages/flutter/test/widgets/framework_test.dart b/packages/flutter/test/widgets/framework_test.dart index dcd6d103db..7656ab6652 100644 --- a/packages/flutter/test/widgets/framework_test.dart +++ b/packages/flutter/test/widgets/framework_test.dart @@ -18,17 +18,17 @@ class _MyGlobalObjectKey> extends GlobalObjectKe void main() { testWidgets('UniqueKey control test', (WidgetTester tester) async { - final Key key = new UniqueKey(); + final Key key = UniqueKey(); expect(key, hasOneLineDescription); - expect(key, isNot(equals(new UniqueKey()))); + expect(key, isNot(equals(UniqueKey()))); }); testWidgets('ObjectKey control test', (WidgetTester tester) async { - final Object a = new Object(); - final Object b = new Object(); - final Key keyA = new ObjectKey(a); - final Key keyA2 = new ObjectKey(a); - final Key keyB = new ObjectKey(b); + final Object a = Object(); + final Object b = Object(); + final Key keyA = ObjectKey(a); + final Key keyA2 = ObjectKey(a); + final Key keyB = ObjectKey(b); expect(keyA, hasOneLineDescription); expect(keyA, equals(keyA2)); @@ -49,11 +49,11 @@ void main() { }); testWidgets('GlobalObjectKey control test', (WidgetTester tester) async { - final Object a = new Object(); - final Object b = new Object(); - final Key keyA = new GlobalObjectKey(a); - final Key keyA2 = new GlobalObjectKey(a); - final Key keyB = new GlobalObjectKey(b); + final Object a = Object(); + final Object b = Object(); + final Key keyA = GlobalObjectKey(a); + final Key keyA2 = GlobalObjectKey(a); + final Key keyB = GlobalObjectKey(b); expect(keyA, hasOneLineDescription); expect(keyA, equals(keyA2)); @@ -62,17 +62,17 @@ void main() { }); testWidgets('GlobalKey duplication 1 - double appearance', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container( + Container( key: const ValueKey(1), - child: new SizedBox(key: key), + child: SizedBox(key: key), ), - new Container( + Container( key: const ValueKey(2), - child: new Placeholder(key: key), + child: Placeholder(key: key), ), ], )); @@ -80,33 +80,33 @@ void main() { }); testWidgets('GlobalKey duplication 2 - splitting and changing type', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); + final Key key = GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container( + Container( key: const ValueKey(1), ), - new Container( + Container( key: const ValueKey(2), ), - new Container( + Container( key: key ), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container( + Container( key: const ValueKey(1), - child: new SizedBox(key: key), + child: SizedBox(key: key), ), - new Container( + Container( key: const ValueKey(2), - child: new Placeholder(key: key), + child: Placeholder(key: key), ), ], )); @@ -115,322 +115,322 @@ void main() { }); testWidgets('GlobalKey duplication 3 - splitting and changing type', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), + Container(key: key), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new SizedBox(key: key), - new Placeholder(key: key), + SizedBox(key: key), + Placeholder(key: key), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 4 - splitting and half changing type', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), + Container(key: key), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), - new Placeholder(key: key), + Container(key: key), + Placeholder(key: key), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 5 - splitting and half changing type', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), + Container(key: key), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Placeholder(key: key), - new Container(key: key), + Placeholder(key: key), + Container(key: key), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 6 - splitting and not changing type', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), + Container(key: key), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), - new Container(key: key), + Container(key: key), + Container(key: key), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 7 - appearing later', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(1), child: new Container(key: key)), - new Container(key: const ValueKey(2)), + Container(key: const ValueKey(1), child: Container(key: key)), + Container(key: const ValueKey(2)), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(1), child: new Container(key: key)), - new Container(key: const ValueKey(2), child: new Container(key: key)), + Container(key: const ValueKey(1), child: Container(key: key)), + Container(key: const ValueKey(2), child: Container(key: key)), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 8 - appearing earlier', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(1)), - new Container(key: const ValueKey(2), child: new Container(key: key)), + Container(key: const ValueKey(1)), + Container(key: const ValueKey(2), child: Container(key: key)), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(1), child: new Container(key: key)), - new Container(key: const ValueKey(2), child: new Container(key: key)), + Container(key: const ValueKey(1), child: Container(key: key)), + Container(key: const ValueKey(2), child: Container(key: key)), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 9 - moving and appearing later', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0), child: new Container(key: key)), - new Container(key: const ValueKey(1)), - new Container(key: const ValueKey(2)), + Container(key: const ValueKey(0), child: Container(key: key)), + Container(key: const ValueKey(1)), + Container(key: const ValueKey(2)), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1), child: new Container(key: key)), - new Container(key: const ValueKey(2), child: new Container(key: key)), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1), child: Container(key: key)), + Container(key: const ValueKey(2), child: Container(key: key)), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 10 - moving and appearing earlier', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(1)), - new Container(key: const ValueKey(2)), - new Container(key: const ValueKey(3), child: new Container(key: key)), + Container(key: const ValueKey(1)), + Container(key: const ValueKey(2)), + Container(key: const ValueKey(3), child: Container(key: key)), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(1), child: new Container(key: key)), - new Container(key: const ValueKey(2), child: new Container(key: key)), - new Container(key: const ValueKey(3)), + Container(key: const ValueKey(1), child: Container(key: key)), + Container(key: const ValueKey(2), child: Container(key: key)), + Container(key: const ValueKey(3)), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 11 - double sibling appearance', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), - new Container(key: key), + Container(key: key), + Container(key: key), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 12 - all kinds of badness at once', (WidgetTester tester) async { - final Key key1 = new GlobalKey(debugLabel: 'problematic'); - final Key key2 = new GlobalKey(debugLabel: 'problematic'); // intentionally the same label - final Key key3 = new GlobalKey(debugLabel: 'also problematic'); - await tester.pumpWidget(new Stack( + final Key key1 = GlobalKey(debugLabel: 'problematic'); + final Key key2 = GlobalKey(debugLabel: 'problematic'); // intentionally the same label + final Key key3 = GlobalKey(debugLabel: 'also problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key1), - new Container(key: key1), - new Container(key: key2), - new Container(key: key1), - new Container(key: key1), - new Container(key: key2), - new Container(key: key1), - new Container(key: key1), - new Row( + Container(key: key1), + Container(key: key1), + Container(key: key2), + Container(key: key1), + Container(key: key1), + Container(key: key2), + Container(key: key1), + Container(key: key1), + Row( children: [ - new Container(key: key1), - new Container(key: key1), - new Container(key: key2), - new Container(key: key2), - new Container(key: key2), - new Container(key: key3), - new Container(key: key2), + Container(key: key1), + Container(key: key1), + Container(key: key2), + Container(key: key2), + Container(key: key2), + Container(key: key3), + Container(key: key2), ], ), - new Row( + Row( children: [ - new Container(key: key1), - new Container(key: key1), - new Container(key: key3), + Container(key: key1), + Container(key: key1), + Container(key: key3), ], ), - new Container(key: key3), + Container(key: key3), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 13 - all kinds of badness at once', (WidgetTester tester) async { - final Key key1 = new GlobalKey(debugLabel: 'problematic'); - final Key key2 = new GlobalKey(debugLabel: 'problematic'); // intentionally the same label - final Key key3 = new GlobalKey(debugLabel: 'also problematic'); - await tester.pumpWidget(new Stack( + final Key key1 = GlobalKey(debugLabel: 'problematic'); + final Key key2 = GlobalKey(debugLabel: 'problematic'); // intentionally the same label + final Key key3 = GlobalKey(debugLabel: 'also problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key1), - new Container(key: key2), - new Container(key: key3), + Container(key: key1), + Container(key: key2), + Container(key: key3), ]), ); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key1), - new Container(key: key1), - new Container(key: key2), - new Container(key: key1), - new Container(key: key1), - new Container(key: key2), - new Container(key: key1), - new Container(key: key1), - new Row( + Container(key: key1), + Container(key: key1), + Container(key: key2), + Container(key: key1), + Container(key: key1), + Container(key: key2), + Container(key: key1), + Container(key: key1), + Row( children: [ - new Container(key: key1), - new Container(key: key1), - new Container(key: key2), - new Container(key: key2), - new Container(key: key2), - new Container(key: key3), - new Container(key: key2), + Container(key: key1), + Container(key: key1), + Container(key: key2), + Container(key: key2), + Container(key: key2), + Container(key: key3), + Container(key: key2), ], ), - new Row( + Row( children: [ - new Container(key: key1), - new Container(key: key1), - new Container(key: key3), + Container(key: key1), + Container(key: key1), + Container(key: key3), ], ), - new Container(key: key3), + Container(key: key3), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 14 - moving during build - before', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1)), + Container(key: key), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1)), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1), child: new Container(key: key)), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1), child: Container(key: key)), ], )); }); testWidgets('GlobalKey duplication 15 - duplicating during build - before', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1)), + Container(key: key), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1)), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: key), - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1), child: new Container(key: key)), + Container(key: key), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1), child: Container(key: key)), ], )); expect(tester.takeException(), isFlutterError); }); testWidgets('GlobalKey duplication 16 - moving during build - after', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1)), - new Container(key: key), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1)), + Container(key: key), ], )); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1), child: new Container(key: key)), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1), child: Container(key: key)), ], )); }); testWidgets('GlobalKey duplication 17 - duplicating during build - after', (WidgetTester tester) async { - final Key key = new GlobalKey(debugLabel: 'problematic'); - await tester.pumpWidget(new Stack( + final Key key = GlobalKey(debugLabel: 'problematic'); + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1)), - new Container(key: key), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1)), + Container(key: key), ], )); int count = 0; @@ -439,12 +439,12 @@ void main() { expect(details.exception, isFlutterError); count += 1; }; - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(key: const ValueKey(0)), - new Container(key: const ValueKey(1), child: new Container(key: key)), - new Container(key: key), + Container(key: const ValueKey(0)), + Container(key: const ValueKey(1), child: Container(key: key)), + Container(key: key), ], )); FlutterError.onError = oldHandler; @@ -454,23 +454,23 @@ void main() { testWidgets('Defunct setState throws exception', (WidgetTester tester) async { StateSetter setState; - await tester.pumpWidget(new StatefulBuilder( + await tester.pumpWidget(StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new Container(); + return Container(); }, )); // Control check that setState doesn't throw an exception. setState(() { }); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(() { setState(() { }); }, throwsFlutterError); }); testWidgets('State toString', (WidgetTester tester) async { - final TestState state = new TestState(); + final TestState state = TestState(); expect(state.toString(), contains('no widget')); }); @@ -485,8 +485,8 @@ void main() { log.add(message); }; - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new Container(key: key)); + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(Container(key: key)); expect(log, isEmpty); await tester.pumpWidget(const Placeholder()); debugPrint = oldCallback; @@ -499,14 +499,14 @@ void main() { testWidgets('MultiChildRenderObjectElement.children', (WidgetTester tester) async { GlobalKey key0, key1, key2; - await tester.pumpWidget(new Column( - key: key0 = new GlobalKey(), + await tester.pumpWidget(Column( + key: key0 = GlobalKey(), children: [ - new Container(), - new Container(key: key1 = new GlobalKey()), - new Container(child: new Container()), - new Container(key: key2 = new GlobalKey()), - new Container(), + Container(), + Container(key: key1 = GlobalKey()), + Container(child: Container()), + Container(key: key2 = GlobalKey()), + Container(), ], )); final MultiChildRenderObjectElement element = key0.currentContext; @@ -518,14 +518,14 @@ void main() { testWidgets('Element diagnostics', (WidgetTester tester) async { GlobalKey key0; - await tester.pumpWidget(new Column( - key: key0 = new GlobalKey(), + await tester.pumpWidget(Column( + key: key0 = GlobalKey(), children: [ - new Container(), - new Container(key: new GlobalKey()), - new Container(child: new Container()), - new Container(key: new GlobalKey()), - new Container(), + Container(), + Container(key: GlobalKey()), + Container(child: Container()), + Container(key: GlobalKey()), + Container(), ], )); final MultiChildRenderObjectElement element = key0.currentContext; @@ -556,7 +556,7 @@ void main() { }); testWidgets('Element diagnostics with null child', (WidgetTester tester) async { - await tester.pumpWidget(new NullChildTest()); + await tester.pumpWidget(NullChildTest()); final NullChildElement test = tester.element(find.byType(NullChildTest)); test.includeChild = true; expect( @@ -573,7 +573,7 @@ void main() { class NullChildTest extends Widget { @override - Element createElement() => new NullChildElement(this); + Element createElement() => NullChildElement(this); } class NullChildElement extends Element { diff --git a/packages/flutter/test/widgets/gesture_detector_semantics_test.dart b/packages/flutter/test/widgets/gesture_detector_semantics_test.dart index 91e2abbdd0..91b1f68e57 100644 --- a/packages/flutter/test/widgets/gesture_detector_semantics_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_semantics_test.dart @@ -10,19 +10,19 @@ import 'semantics_tester.dart'; void main() { testWidgets('Vertical gesture detector has up/down actions', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int callCount = 0; - final GlobalKey detectorKey = new GlobalKey(); + final GlobalKey detectorKey = GlobalKey(); await tester.pumpWidget( - new Center( - child: new GestureDetector( + Center( + child: GestureDetector( key: detectorKey, onVerticalDragStart: (DragStartDetails _) { callCount += 1; }, - child: new Container(), + child: Container(), ), ) ); @@ -44,19 +44,19 @@ void main() { }); testWidgets('Horizontal gesture detector has up/down actions', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int callCount = 0; - final GlobalKey detectorKey = new GlobalKey(); + final GlobalKey detectorKey = GlobalKey(); await tester.pumpWidget( - new Center( - child: new GestureDetector( + Center( + child: GestureDetector( key: detectorKey, onHorizontalDragStart: (DragStartDetails _) { callCount += 1; }, - child: new Container(), + child: Container(), ), ) ); diff --git a/packages/flutter/test/widgets/gesture_detector_test.dart b/packages/flutter/test/widgets/gesture_detector_test.dart index 30074e9f54..a0b78209e8 100644 --- a/packages/flutter/test/widgets/gesture_detector_test.dart +++ b/packages/flutter/test/widgets/gesture_detector_test.dart @@ -13,7 +13,7 @@ void main() { double updatedDragDelta; bool didEndDrag = false; - final Widget widget = new GestureDetector( + final Widget widget = GestureDetector( onVerticalDragStart: (DragStartDetails details) { didStartDrag = true; }, @@ -23,7 +23,7 @@ void main() { onVerticalDragEnd: (DragEndDetails details) { didEndDrag = true; }, - child: new Container( + child: Container( color: const Color(0xFF00FF00), ), ); @@ -53,7 +53,7 @@ void main() { expect(didEndDrag, isTrue); didEndDrag = false; - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); }); testWidgets('Match two scroll gestures in succession', (WidgetTester tester) async { @@ -63,12 +63,12 @@ void main() { const Offset downLocation = Offset(10.0, 10.0); const Offset upLocation = Offset(10.0, 50.0); // must be far enough to be more than kTouchSlop - final Widget widget = new GestureDetector( + final Widget widget = GestureDetector( onVerticalDragUpdate: (DragUpdateDetails details) { dragDistance += details.primaryDelta; }, onVerticalDragEnd: (DragEndDetails details) { gestureCount += 1; }, onHorizontalDragUpdate: (DragUpdateDetails details) { fail('gesture should not match'); }, onHorizontalDragEnd: (DragEndDetails details) { fail('gesture should not match'); }, - child: new Container( + child: Container( color: const Color(0xFF00FF00), ), ); @@ -85,7 +85,7 @@ void main() { expect(gestureCount, 2); expect(dragDistance, 40.0 * 2.0); // delta between down and up, twice - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); }); testWidgets('Pan doesn\'t crash', (WidgetTester tester) async { @@ -94,7 +94,7 @@ void main() { bool didEndPan = false; await tester.pumpWidget( - new GestureDetector( + GestureDetector( onPanStart: (DragStartDetails details) { didStartPan = true; }, @@ -104,7 +104,7 @@ void main() { onPanEnd: (DragEndDetails details) { didEndPan = true; }, - child: new Container( + child: Container( color: const Color(0xFF00FF00), ), ), @@ -128,24 +128,24 @@ void main() { Future pumpWidgetTree(HitTestBehavior behavior) { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Listener( + Listener( onPointerDown: (_) { didReceivePointerDown = true; }, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: const Color(0xFF00FF00), ), ), - new Container( + Container( width: 100.0, height: 100.0, - child: new GestureDetector( + child: GestureDetector( onTap: () { didTap = true; }, @@ -191,8 +191,8 @@ void main() { testWidgets('Empty', (WidgetTester tester) async { bool didTap = false; await tester.pumpWidget( - new Center( - child: new GestureDetector( + Center( + child: GestureDetector( onTap: () { didTap = true; }, @@ -207,12 +207,12 @@ void main() { testWidgets('Only container', (WidgetTester tester) async { bool didTap = false; await tester.pumpWidget( - new Center( - child: new GestureDetector( + Center( + child: GestureDetector( onTap: () { didTap = true; }, - child: new Container(), + child: Container(), ), ), ); @@ -225,10 +225,10 @@ void main() { final GestureTapCallback inputCallback = () {}; await tester.pumpWidget( - new Center( - child: new GestureDetector( + Center( + child: GestureDetector( onTap: inputCallback, - child: new Container(), + child: Container(), ), ), ); @@ -237,10 +237,10 @@ void main() { final GestureTapCallback actualCallback1 = renderObj1.onTap; await tester.pumpWidget( - new Center( - child: new GestureDetector( + Center( + child: GestureDetector( onTap: inputCallback, - child: new Container(), + child: Container(), ), ), ); @@ -259,13 +259,13 @@ void main() { int longPress = 0; await tester.pumpWidget( - new Container( + Container( alignment: Alignment.topLeft, - child: new Container( + child: Container( alignment: Alignment.center, height: 100.0, color: const Color(0xFF00FF00), - child: new GestureDetector( + child: GestureDetector( onTapDown: (TapDownDetails details) { tapDown += 1; }, diff --git a/packages/flutter/test/widgets/gesture_disambiguation_test.dart b/packages/flutter/test/widgets/gesture_disambiguation_test.dart index 7b2d18bbf5..1e838b5460 100644 --- a/packages/flutter/test/widgets/gesture_disambiguation_test.dart +++ b/packages/flutter/test/widgets/gesture_disambiguation_test.dart @@ -11,16 +11,16 @@ void main() { int detector1TapCount = 0; int detector2TapCount = 0; - final Widget widget = new GestureDetector( - child: new Column( + final Widget widget = GestureDetector( + child: Column( mainAxisAlignment: MainAxisAlignment.start, children: [ - new GestureDetector( + GestureDetector( onTap: () { detector1TapCount += 1; }, behavior: HitTestBehavior.opaque, child: const SizedBox(width: 200.0, height: 200.0), ), - new GestureDetector( + GestureDetector( onTap: () { detector2TapCount += 1; }, behavior: HitTestBehavior.opaque, child: const SizedBox(width: 200.0, height: 200.0) diff --git a/packages/flutter/test/widgets/global_keys_duplicated_test.dart b/packages/flutter/test/widgets/global_keys_duplicated_test.dart index 9f9e25f3db..1350b35c00 100644 --- a/packages/flutter/test/widgets/global_keys_duplicated_test.dart +++ b/packages/flutter/test/widgets/global_keys_duplicated_test.dart @@ -12,9 +12,9 @@ void main() { testWidgets('GlobalKey children of one node', (WidgetTester tester) async { // This is actually a test of the regular duplicate key logic, which // happens before the duplicate GlobalKey logic. - await tester.pumpWidget(new Stack(children: [ - new Container(key: const GlobalObjectKey(0)), - new Container(key: const GlobalObjectKey(0)), + await tester.pumpWidget(Stack(children: [ + Container(key: const GlobalObjectKey(0)), + Container(key: const GlobalObjectKey(0)), ])); final dynamic error = tester.takeException(); expect(error, isFlutterError); @@ -24,11 +24,11 @@ void main() { }); testWidgets('GlobalKey children of two nodes', (WidgetTester tester) async { - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(child: new Container(key: const GlobalObjectKey(0))), - new Container(child: new Container(key: const GlobalObjectKey(0))), + Container(child: Container(key: const GlobalObjectKey(0))), + Container(child: Container(key: const GlobalObjectKey(0))), ], )); final dynamic error = tester.takeException(); @@ -41,11 +41,11 @@ void main() { }); testWidgets('GlobalKey children of two different nodes', (WidgetTester tester) async { - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(child: new Container(key: const GlobalObjectKey(0))), - new Container(key: const Key('x'), child: new Container(key: const GlobalObjectKey(0))), + Container(child: Container(key: const GlobalObjectKey(0))), + Container(key: const Key('x'), child: Container(key: const GlobalObjectKey(0))), ], )); final dynamic error = tester.takeException(); @@ -61,16 +61,16 @@ void main() { testWidgets('GlobalKey children of two nodes', (WidgetTester tester) async { StateSetter nestedSetState; bool flag = false; - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(child: new Container(key: const GlobalObjectKey(0))), - new Container(child: new StatefulBuilder( + Container(child: Container(key: const GlobalObjectKey(0))), + Container(child: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { nestedSetState = setState; if (flag) - return new Container(key: const GlobalObjectKey(0)); - return new Container(); + return Container(key: const GlobalObjectKey(0)); + return Container(); }, )), ], diff --git a/packages/flutter/test/widgets/global_keys_moving_test.dart b/packages/flutter/test/widgets/global_keys_moving_test.dart index d998d7ba15..45caaceb78 100644 --- a/packages/flutter/test/widgets/global_keys_moving_test.dart +++ b/packages/flutter/test/widgets/global_keys_moving_test.dart @@ -6,19 +6,19 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; class Item { - GlobalKey key1 = new GlobalKey(); - GlobalKey key2 = new GlobalKey(); + GlobalKey key1 = GlobalKey(); + GlobalKey key2 = GlobalKey(); @override String toString() => 'Item($key1, $key2)'; } -List items = [new Item(), new Item()]; +List items = [Item(), Item()]; class StatefulLeaf extends StatefulWidget { const StatefulLeaf({ GlobalKey key }) : super(key: key); @override - StatefulLeafState createState() => new StatefulLeafState(); + StatefulLeafState createState() => StatefulLeafState(); } class StatefulLeafState extends State { @@ -36,9 +36,9 @@ class KeyedWrapper extends StatelessWidget { @override Widget build(BuildContext context) { - return new Container( + return Container( key: key1, - child: new StatefulLeaf( + child: StatefulLeaf( key: key2, ) ); @@ -46,10 +46,10 @@ class KeyedWrapper extends StatelessWidget { } Widget builder() { - return new Column( + return Column( children: [ - new KeyedWrapper(items[1].key1, items[1].key2), - new KeyedWrapper(items[0].key1, items[0].key2), + KeyedWrapper(items[1].key1, items[1].key2), + KeyedWrapper(items[0].key1, items[0].key2), ], ); } diff --git a/packages/flutter/test/widgets/grid_view_layout_test.dart b/packages/flutter/test/widgets/grid_view_layout_test.dart index b0b1e05e0f..8a938dddd7 100644 --- a/packages/flutter/test/widgets/grid_view_layout_test.dart +++ b/packages/flutter/test/widgets/grid_view_layout_test.dart @@ -15,12 +15,12 @@ void main() { ]; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 200.0, - child: new GridView.extent( + child: GridView.extent( maxCrossAxisExtent: 100.0, shrinkWrap: true, children: children, @@ -44,12 +44,12 @@ void main() { expect(grid.debugNeedsLayout, false); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 200.0, - child: new GridView.extent( + child: GridView.extent( maxCrossAxisExtent: 60.0, shrinkWrap: true, children: children, diff --git a/packages/flutter/test/widgets/grid_view_test.dart b/packages/flutter/test/widgets/grid_view_test.dart index d476658a37..1adc5e787a 100644 --- a/packages/flutter/test/widgets/grid_view_test.dart +++ b/packages/flutter/test/widgets/grid_view_test.dart @@ -11,9 +11,9 @@ import 'states.dart'; void main() { testWidgets('Empty GridView', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( crossAxisCount: 4, children: const [], ), @@ -25,18 +25,18 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( crossAxisCount: 4, children: kStates.map((String state) { - return new GestureDetector( + return GestureDetector( onTap: () { log.add(state); }, - child: new Container( + child: Container( color: const Color(0xFF0000FF), - child: new Text(state), + child: Text(state), ), ); }).toList(), @@ -96,18 +96,18 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.extent( + child: GridView.extent( maxCrossAxisExtent: 200.0, children: kStates.map((String state) { - return new GestureDetector( + return GestureDetector( onTap: () { log.add(state); }, - child: new Container( + child: Container( color: const Color(0xFF0000FF), - child: new Text(state), + child: Text(state), ), ); }).toList(), @@ -142,18 +142,18 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.extent( + child: GridView.extent( scrollDirection: Axis.horizontal, maxCrossAxisExtent: 200.0, childAspectRatio: 0.75, - children: new List.generate(80, (int i) { - return new Builder( + children: List.generate(80, (int i) { + return Builder( builder: (BuildContext context) { log.add(i); - return new Container( - child: new Text('$i'), + return Container( + child: Text('$i'), ); } ); @@ -236,18 +236,18 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView( + child: GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, ), - children: new List.generate(40, (int i) { - return new Builder( + children: List.generate(40, (int i) { + return Builder( builder: (BuildContext context) { log.add(i); - return new Container( - child: new Text('$i'), + return Container( + child: Text('$i'), ); } ); @@ -274,18 +274,18 @@ void main() { log.clear(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView( + child: GridView( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), - children: new List.generate(40, (int i) { - return new Builder( + children: List.generate(40, (int i) { + return Builder( builder: (BuildContext context) { log.add(i); - return new Container( - child: new Text('$i'), + return Container( + child: Text('$i'), ); } ); @@ -311,18 +311,18 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView( + child: GridView( gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 200.0, ), - children: new List.generate(40, (int i) { - return new Builder( + children: List.generate(40, (int i) { + return Builder( builder: (BuildContext context) { log.add(i); - return new Container( - child: new Text('$i'), + return Container( + child: Text('$i'), ); } ); @@ -349,18 +349,18 @@ void main() { log.clear(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView( + child: GridView( gridDelegate: const SliverGridDelegateWithMaxCrossAxisExtent( maxCrossAxisExtent: 400.0, ), - children: new List.generate(40, (int i) { - return new Builder( + children: List.generate(40, (int i) { + return Builder( builder: (BuildContext context) { log.add(i); - return new Container( - child: new Text('$i'), + return Container( + child: Text('$i'), ); } ); @@ -385,19 +385,19 @@ void main() { testWidgets('One-line GridView paints', (WidgetTester tester) async { const Color green = Color(0xFF00FF00); - final Container container = new Container( + final Container container = Container( decoration: const BoxDecoration( color: green, ), ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( height: 200.0, - child: new GridView.count( + child: GridView.count( cacheExtent: 0.0, crossAxisCount: 2, children: [ container, container, container, container ], @@ -413,17 +413,17 @@ void main() { testWidgets('GridView in zero context', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 0.0, height: 0.0, - child: new GridView.count( + child: GridView.count( crossAxisCount: 4, - children: new List.generate(20, (int i) { - return new Container( - child: new Text('$i'), + children: List.generate(20, (int i) { + return Container( + child: Text('$i'), ); }), ), @@ -438,15 +438,15 @@ void main() { testWidgets('GridView in unbounded context', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SingleChildScrollView( - child: new GridView.count( + child: SingleChildScrollView( + child: GridView.count( crossAxisCount: 4, shrinkWrap: true, - children: new List.generate(20, (int i) { - return new Container( - child: new Text('$i'), + children: List.generate(20, (int i) { + return Container( + child: Text('$i'), ); }), ), @@ -460,17 +460,17 @@ void main() { testWidgets('GridView.builder control test', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.builder( + child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, ), shrinkWrap: true, itemCount: 20, itemBuilder: (BuildContext context, int index) { - return new Container( - child: new Text('$index'), + return Container( + child: Text('$index'), ); }, ), @@ -483,16 +483,16 @@ void main() { testWidgets('GridView.builder with undefined itemCount', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.builder( + child: GridView.builder( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 4, ), shrinkWrap: true, itemBuilder: (BuildContext context, int index) { - return new Container( - child: new Text('$index'), + return Container( + child: Text('$index'), ); }, ), @@ -506,15 +506,15 @@ void main() { }); testWidgets('GridView cross axis layout', (WidgetTester tester) async { - final Key target = new UniqueKey(); + final Key target = UniqueKey(); Widget build(TextDirection textDirection) { - return new Directionality( + return Directionality( textDirection: textDirection, - child: new GridView.count( + child: GridView.count( crossAxisCount: 4, children: [ - new Container(key: target), + Container(key: target), ], ), ); diff --git a/packages/flutter/test/widgets/heroes_test.dart b/packages/flutter/test/widgets/heroes_test.dart index 450c4ac865..850ae99f14 100644 --- a/packages/flutter/test/widgets/heroes_test.dart +++ b/packages/flutter/test/widgets/heroes_test.dart @@ -15,38 +15,38 @@ Key routeTwoKey = const Key('routeTwo'); Key routeThreeKey = const Key('routeThree'); final Map routes = { - '/': (BuildContext context) => new Material( - child: new ListView( + '/': (BuildContext context) => Material( + child: ListView( key: homeRouteKey, children: [ - new Container(height: 100.0, width: 100.0), - new Card(child: new Hero(tag: 'a', child: new Container(height: 100.0, width: 100.0, key: firstKey))), - new Container(height: 100.0, width: 100.0), - new FlatButton( + Container(height: 100.0, width: 100.0), + Card(child: Hero(tag: 'a', child: Container(height: 100.0, width: 100.0, key: firstKey))), + Container(height: 100.0, width: 100.0), + FlatButton( child: const Text('two'), onPressed: () { Navigator.pushNamed(context, '/two'); } ), - new FlatButton( + FlatButton( child: const Text('twoInset'), onPressed: () { Navigator.pushNamed(context, '/twoInset'); } ), ] ) ), - '/two': (BuildContext context) => new Material( - child: new ListView( + '/two': (BuildContext context) => Material( + child: ListView( key: routeTwoKey, children: [ - new FlatButton( + FlatButton( child: const Text('pop'), onPressed: () { Navigator.pop(context); } ), - new Container(height: 150.0, width: 150.0), - new Card(child: new Hero(tag: 'a', child: new Container(height: 150.0, width: 150.0, key: secondKey))), - new Container(height: 150.0, width: 150.0), - new FlatButton( + Container(height: 150.0, width: 150.0), + Card(child: Hero(tag: 'a', child: Container(height: 150.0, width: 150.0, key: secondKey))), + Container(height: 150.0, width: 150.0), + FlatButton( child: const Text('three'), - onPressed: () { Navigator.push(context, new ThreeRoute()); }, + onPressed: () { Navigator.push(context, ThreeRoute()); }, ), ] ) @@ -55,25 +55,25 @@ final Map routes = { // 50 pixels. When the hero's in-flight bounds between / and /twoInset are animated // using MaterialRectArcTween (the default) they'll follow a different path // then when the flight starts at /twoInset and returns to /. - '/twoInset': (BuildContext context) => new Material( - child: new ListView( + '/twoInset': (BuildContext context) => Material( + child: ListView( key: routeTwoKey, children: [ - new FlatButton( + FlatButton( child: const Text('pop'), onPressed: () { Navigator.pop(context); } ), - new Container(height: 150.0, width: 150.0), - new Card( - child: new Padding( + Container(height: 150.0, width: 150.0), + Card( + child: Padding( padding: const EdgeInsets.only(left: 50.0), - child: new Hero(tag: 'a', child: new Container(height: 150.0, width: 150.0, key: secondKey)) + child: Hero(tag: 'a', child: Container(height: 150.0, width: 150.0, key: secondKey)) ), ), - new Container(height: 150.0, width: 150.0), - new FlatButton( + Container(height: 150.0, width: 150.0), + FlatButton( child: const Text('three'), - onPressed: () { Navigator.push(context, new ThreeRoute()); }, + onPressed: () { Navigator.push(context, ThreeRoute()); }, ), ] ) @@ -83,13 +83,13 @@ final Map routes = { class ThreeRoute extends MaterialPageRoute { ThreeRoute() : super(builder: (BuildContext context) { - return new Material( + return Material( key: routeThreeKey, - child: new ListView( + child: ListView( children: [ - new Container(height: 200.0, width: 200.0), - new Card(child: new Hero(tag: 'a', child: new Container(height: 200.0, width: 200.0, key: thirdKey))), - new Container(height: 200.0, width: 200.0), + Container(height: 200.0, width: 200.0), + Card(child: Hero(tag: 'a', child: Container(height: 200.0, width: 200.0, key: thirdKey))), + Container(height: 200.0, width: 200.0), ] ) ); @@ -98,7 +98,7 @@ class ThreeRoute extends MaterialPageRoute { class MutatingRoute extends MaterialPageRoute { MutatingRoute() : super(builder: (BuildContext context) { - return new Hero(tag: 'a', child: const Text('MutatingRoute'), key: new UniqueKey()); + return Hero(tag: 'a', child: const Text('MutatingRoute'), key: UniqueKey()); }); void markNeedsBuild() { @@ -112,18 +112,18 @@ class MyStatefulWidget extends StatefulWidget { const MyStatefulWidget({ Key key, this.value = '123' }) : super(key: key); final String value; @override - MyStatefulWidgetState createState() => new MyStatefulWidgetState(); + MyStatefulWidgetState createState() => MyStatefulWidgetState(); } class MyStatefulWidgetState extends State { @override - Widget build(BuildContext context) => new Text(widget.value); + Widget build(BuildContext context) => Text(widget.value); } void main() { testWidgets('Heroes animate', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); // the initial setup. @@ -226,15 +226,15 @@ void main() { }); testWidgets('Destination hero is rebuilt midflight', (WidgetTester tester) async { - final MutatingRoute route = new MutatingRoute(); + final MutatingRoute route = MutatingRoute(); - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new ListView( + await tester.pumpWidget(MaterialApp( + home: Material( + child: ListView( children: [ const Hero(tag: 'a', child: Text('foo')), - new Builder(builder: (BuildContext context) { - return new FlatButton(child: const Text('two'), onPressed: () => Navigator.push(context, route)); + Builder(builder: (BuildContext context) { + return FlatButton(child: const Text('two'), onPressed: () => Navigator.push(context, route)); }) ] ) @@ -251,7 +251,7 @@ void main() { }); testWidgets('Heroes animation is fastOutSlowIn', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); await tester.tap(find.text('two')); await tester.pump(); // begin navigation @@ -293,15 +293,15 @@ void main() { testWidgets('Heroes are not interactive', (WidgetTester tester) async { final List log = []; - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Hero( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Hero( tag: 'foo', - child: new GestureDetector( + child: GestureDetector( onTap: () { log.add('foo'); }, - child: new Container( + child: Container( width: 100.0, height: 100.0, child: const Text('foo') @@ -311,15 +311,15 @@ void main() { ), routes: { '/next': (BuildContext context) { - return new Align( + return Align( alignment: Alignment.topLeft, - child: new Hero( + child: Hero( tag: 'foo', - child: new GestureDetector( + child: GestureDetector( onTap: () { log.add('bar'); }, - child: new Container( + child: Container( width: 100.0, height: 150.0, child: const Text('bar') @@ -361,11 +361,11 @@ void main() { }); testWidgets('Popping on first frame does not cause hero observer to crash', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, - builder: (BuildContext context) => new Hero(tag: 'test', child: new Container()), + builder: (BuildContext context) => Hero(tag: 'test', child: Container()), ); }, )); @@ -387,11 +387,11 @@ void main() { }); testWidgets('Overlapping starting and ending a hero transition works ok', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, - builder: (BuildContext context) => new Hero(tag: 'test', child: new Container()), + builder: (BuildContext context) => Hero(tag: 'test', child: Container()), ); }, )); @@ -421,18 +421,18 @@ void main() { }); testWidgets('One route, two heroes, same tag, throws', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new ListView( + await tester.pumpWidget(MaterialApp( + home: Material( + child: ListView( children: [ const Hero(tag: 'a', child: Text('a')), const Hero(tag: 'a', child: Text('a too')), - new Builder( + Builder( builder: (BuildContext context) { - return new FlatButton( + return FlatButton( child: const Text('push'), onPressed: () { - Navigator.push(context, new PageRouteBuilder( + Navigator.push(context, PageRouteBuilder( pageBuilder: (BuildContext context, Animation _, Animation __) { return const Text('fail'); }, @@ -452,7 +452,7 @@ void main() { }); testWidgets('Hero push transition interrupted by a pop', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes )); @@ -518,7 +518,7 @@ void main() { testWidgets('Hero pop transition interrupted by a push', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp(routes: routes) + MaterialApp(routes: routes) ); // Pushes MaterialPageRoute '/two'. @@ -593,22 +593,22 @@ void main() { StateSetter heroCardSetState; // Show a 200x200 Hero tagged 'H', with key routeHeroKey - final MaterialPageRoute route = new MaterialPageRoute( + final MaterialPageRoute route = MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new ListView( + return Material( + child: ListView( children: [ - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { heroCardSetState = setState; - return new Card( + return Card( child: routeIncludesHero - ? new Hero(tag: 'H', child: new Container(key: routeHeroKey, height: 200.0, width: 200.0)) - : new Container(height: 200.0, width: 200.0), + ? Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)) + : Container(height: 200.0, width: 200.0), ); }, ), - new FlatButton( + FlatButton( child: const Text('POP'), onPressed: () { Navigator.pop(context); } ), @@ -620,16 +620,16 @@ void main() { // Show a 100x100 Hero tagged 'H' with key homeHeroKey await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { // Navigator.push() needs context - return new ListView( + return ListView( children: [ - new Card( - child: new Hero(tag: 'H', child: new Container(key: homeHeroKey, height: 100.0, width: 100.0)), + Card( + child: Hero(tag: 'H', child: Container(key: homeHeroKey, height: 100.0, width: 100.0)), ), - new FlatButton( + FlatButton( child: const Text('PUSH'), onPressed: () { Navigator.push(context, route); } ), @@ -695,18 +695,18 @@ void main() { const Key routeContainerKey = Key('route hero container'); // Show a 200x200 Hero tagged 'H', with key routeHeroKey - final MaterialPageRoute route = new MaterialPageRoute( + final MaterialPageRoute route = MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new ListView( + return Material( + child: ListView( children: [ const SizedBox(height: 100.0), // This container will appear at Y=100 - new Container( + Container( key: routeContainerKey, - child: new Hero(tag: 'H', child: new Container(key: routeHeroKey, height: 200.0, width: 200.0)) + child: Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)) ), - new FlatButton( + FlatButton( child: const Text('POP'), onPressed: () { Navigator.pop(context); } ), @@ -719,18 +719,18 @@ void main() { // Show a 100x100 Hero tagged 'H' with key homeHeroKey await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { // Navigator.push() needs context - return new ListView( + return ListView( children: [ const SizedBox(height: 200.0), // This container will appear at Y=200 - new Container( - child: new Hero(tag: 'H', child: new Container(key: homeHeroKey, height: 100.0, width: 100.0)), + Container( + child: Hero(tag: 'H', child: Container(key: homeHeroKey, height: 100.0, width: 100.0)), ), - new FlatButton( + FlatButton( child: const Text('PUSH'), onPressed: () { Navigator.push(context, route); } ), @@ -777,17 +777,17 @@ void main() { const Key routeContainerKey = Key('route hero container'); // Show a 200x200 Hero tagged 'H', with key routeHeroKey - final MaterialPageRoute route = new MaterialPageRoute( + final MaterialPageRoute route = MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new ListView( + return Material( + child: ListView( cacheExtent: 0.0, children: [ const SizedBox(height: 100.0), // This container will appear at Y=100 - new Container( + Container( key: routeContainerKey, - child: new Hero(tag: 'H', child: new Container(key: routeHeroKey, height: 200.0, width: 200.0)) + child: Hero(tag: 'H', child: Container(key: routeHeroKey, height: 200.0, width: 200.0)) ), const SizedBox(height: 800.0), ], @@ -798,18 +798,18 @@ void main() { // Show a 100x100 Hero tagged 'H' with key homeHeroKey await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { // Navigator.push() needs context - return new ListView( + return ListView( children: [ const SizedBox(height: 200.0), // This container will appear at Y=200 - new Container( - child: new Hero(tag: 'H', child: new Container(key: homeHeroKey, height: 100.0, width: 100.0)), + Container( + child: Hero(tag: 'H', child: Container(key: homeHeroKey, height: 100.0, width: 100.0)), ), - new FlatButton( + FlatButton( child: const Text('PUSH'), onPressed: () { Navigator.push(context, route); } ), @@ -856,14 +856,14 @@ void main() { const Key heroBCKey = Key('BC hero'); // Show a 150x150 Hero tagged 'BC' - final MaterialPageRoute routeC = new MaterialPageRoute( + final MaterialPageRoute routeC = MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new ListView( + return Material( + child: ListView( children: [ // This container will appear at Y=0 - new Container( - child: new Hero(tag: 'BC', child: new Container(key: heroBCKey, height: 150.0)) + Container( + child: Hero(tag: 'BC', child: Container(key: heroBCKey, height: 150.0)) ), const SizedBox(height: 800.0), ], @@ -873,22 +873,22 @@ void main() { ); // Show a height=200 Hero tagged 'AB' and a height=50 Hero tagged 'BC' - final MaterialPageRoute routeB = new MaterialPageRoute( + final MaterialPageRoute routeB = MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new ListView( + return Material( + child: ListView( children: [ const SizedBox(height: 100.0), // This container will appear at Y=100 - new Container( - child: new Hero(tag: 'AB', child: new Container(key: heroABKey, height: 200.0)) + Container( + child: Hero(tag: 'AB', child: Container(key: heroABKey, height: 200.0)) ), - new FlatButton( + FlatButton( child: const Text('PUSH C'), onPressed: () { Navigator.push(context, routeC); } ), - new Container( - child: new Hero(tag: 'BC', child: new Container(height: 150.0)) + Container( + child: Hero(tag: 'BC', child: Container(height: 150.0)) ), const SizedBox(height: 800.0), ], @@ -899,18 +899,18 @@ void main() { // Show a 100x100 Hero tagged 'AB' with key heroABKey await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { // Navigator.push() needs context - return new ListView( + return ListView( children: [ const SizedBox(height: 200.0), // This container will appear at Y=200 - new Container( - child: new Hero(tag: 'AB', child: new Container(height: 100.0, width: 100.0)), + Container( + child: Hero(tag: 'AB', child: Container(height: 100.0, width: 100.0)), ), - new FlatButton( + FlatButton( child: const Text('PUSH B'), onPressed: () { Navigator.push(context, routeB); } ), @@ -957,10 +957,10 @@ void main() { }); testWidgets('Stateful hero child state survives flight', (WidgetTester tester) async { - final MaterialPageRoute route = new MaterialPageRoute( + final MaterialPageRoute route = MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new ListView( + return Material( + child: ListView( children: [ const Card( child: Hero( @@ -971,7 +971,7 @@ void main() { ), ), ), - new FlatButton( + FlatButton( child: const Text('POP'), onPressed: () { Navigator.pop(context); } ), @@ -982,11 +982,11 @@ void main() { ); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Builder( + MaterialApp( + home: Scaffold( + body: Builder( builder: (BuildContext context) { // Navigator.push() needs context - return new ListView( + return ListView( children: [ const Card( child: Hero( @@ -997,7 +997,7 @@ void main() { ), ), ), - new FlatButton( + FlatButton( child: const Text('PUSH'), onPressed: () { Navigator.push(context, route); } ), @@ -1041,54 +1041,54 @@ void main() { testWidgets('Hero createRectTween', (WidgetTester tester) async { RectTween createRectTween(Rect begin, Rect end) { - return new MaterialRectCenterArcTween(begin: begin, end: end); + return MaterialRectCenterArcTween(begin: begin, end: end); } final Map createRectTweenHeroRoutes = { - '/': (BuildContext context) => new Material( - child: new Column( + '/': (BuildContext context) => Material( + child: Column( crossAxisAlignment: CrossAxisAlignment.start, children: [ - new Hero( + Hero( tag: 'a', createRectTween: createRectTween, - child: new Container(height: 100.0, width: 100.0, key: firstKey), + child: Container(height: 100.0, width: 100.0, key: firstKey), ), - new FlatButton( + FlatButton( child: const Text('two'), onPressed: () { Navigator.pushNamed(context, '/two'); } ), ] ) ), - '/two': (BuildContext context) => new Material( - child: new Column( + '/two': (BuildContext context) => Material( + child: Column( crossAxisAlignment: CrossAxisAlignment.center, children: [ - new SizedBox( + SizedBox( height: 200.0, - child: new FlatButton( + child: FlatButton( child: const Text('pop'), onPressed: () { Navigator.pop(context); } ), ), - new Hero( + Hero( tag: 'a', createRectTween: createRectTween, - child: new Container(height: 200.0, width: 100.0, key: secondKey), + child: Container(height: 200.0, width: 100.0, key: secondKey), ), ], ), ), }; - await tester.pumpWidget(new MaterialApp(routes: createRectTweenHeroRoutes)); + await tester.pumpWidget(MaterialApp(routes: createRectTweenHeroRoutes)); expect(tester.getCenter(find.byKey(firstKey)), const Offset(50.0, 50.0)); const double epsilon = 0.001; const Duration duration = Duration(milliseconds: 300); const Curve curve = Curves.fastOutSlowIn; - final MaterialPointArcTween pushCenterTween = new MaterialPointArcTween( + final MaterialPointArcTween pushCenterTween = MaterialPointArcTween( begin: const Offset(50.0, 50.0), end: const Offset(400.0, 300.0), ); @@ -1126,7 +1126,7 @@ void main() { await tester.tap(find.text('pop')); await tester.pump(); // begin navigation - final MaterialPointArcTween popCenterTween = new MaterialPointArcTween( + final MaterialPointArcTween popCenterTween = MaterialPointArcTween( begin: const Offset(400.0, 300.0), end: const Offset(50.0, 50.0), ); @@ -1153,7 +1153,7 @@ void main() { }); testWidgets('Pop interrupts push, reverses flight', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); await tester.tap(find.text('twoInset')); await tester.pump(); // begin navigation from / to /twoInset. @@ -1246,18 +1246,18 @@ void main() { }); testWidgets('Can override flight shuttle', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new ListView( + await tester.pumpWidget(MaterialApp( + home: Material( + child: ListView( children: [ const Hero(tag: 'a', child: Text('foo')), - new Builder(builder: (BuildContext context) { - return new FlatButton( + Builder(builder: (BuildContext context) { + return FlatButton( child: const Text('two'), - onPressed: () => Navigator.push(context, new MaterialPageRoute( + onPressed: () => Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new Hero( + return Material( + child: Hero( tag: 'a', child: const Text('bar'), flightShuttleBuilder: ( @@ -1290,24 +1290,24 @@ void main() { }); testWidgets('Can override flight launch pads', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new ListView( + await tester.pumpWidget(MaterialApp( + home: Material( + child: ListView( children: [ - new Hero( + Hero( tag: 'a', child: const Text('Batman'), placeholderBuilder: (BuildContext context, Widget child) { return const Text('Venom'); }, ), - new Builder(builder: (BuildContext context) { - return new FlatButton( + Builder(builder: (BuildContext context) { + return FlatButton( child: const Text('two'), - onPressed: () => Navigator.push(context, new MaterialPageRoute( + onPressed: () => Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { - return new Material( - child: new Hero( + return Material( + child: Hero( tag: 'a', child: const Text('Wolverine'), placeholderBuilder: (BuildContext context, Widget child) { diff --git a/packages/flutter/test/widgets/hyperlink_test.dart b/packages/flutter/test/widgets/hyperlink_test.dart index c812597be0..65992b959d 100644 --- a/packages/flutter/test/widgets/hyperlink_test.dart +++ b/packages/flutter/test/widgets/hyperlink_test.dart @@ -9,13 +9,13 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Can tap a hyperlink', (WidgetTester tester) async { bool didTapLeft = false; - final TapGestureRecognizer tapLeft = new TapGestureRecognizer() + final TapGestureRecognizer tapLeft = TapGestureRecognizer() ..onTap = () { didTapLeft = true; }; bool didTapRight = false; - final TapGestureRecognizer tapRight = new TapGestureRecognizer() + final TapGestureRecognizer tapRight = TapGestureRecognizer() ..onTap = () { didTapRight = true; }; @@ -23,18 +23,18 @@ void main() { const Key textKey = Key('text'); await tester.pumpWidget( - new Center( - child: new RichText( + Center( + child: RichText( key: textKey, textDirection: TextDirection.ltr, - text: new TextSpan( + text: TextSpan( children: [ - new TextSpan( + TextSpan( text: 'xxxxxxxx', recognizer: tapLeft ), const TextSpan(text: 'yyyyyyyy'), - new TextSpan( + TextSpan( text: 'zzzzzzzzz', recognizer: tapRight ), @@ -63,7 +63,7 @@ void main() { didTapLeft = false; - await tester.tapAt(box.localToGlobal(new Offset(box.size.width, 0.0)) + const Offset(-2.0, 2.0)); + await tester.tapAt(box.localToGlobal(Offset(box.size.width, 0.0)) + const Offset(-2.0, 2.0)); expect(didTapLeft, isFalse); expect(didTapRight, isTrue); diff --git a/packages/flutter/test/widgets/icon_test.dart b/packages/flutter/test/widgets/icon_test.dart index d0e26fc68f..f9d11b9af4 100644 --- a/packages/flutter/test/widgets/icon_test.dart +++ b/packages/flutter/test/widgets/icon_test.dart @@ -127,7 +127,7 @@ void main() { }); testWidgets('Icon with semantic label', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const Directionality( @@ -147,7 +147,7 @@ void main() { }); testWidgets('Null icon with semantic label', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const Directionality( diff --git a/packages/flutter/test/widgets/image_headers_test.dart b/packages/flutter/test/widgets/image_headers_test.dart index d6593bc8a0..a4dc552616 100644 --- a/packages/flutter/test/widgets/image_headers_test.dart +++ b/packages/flutter/test/widgets/image_headers_test.dart @@ -12,14 +12,14 @@ import 'package:mockito/mockito.dart'; import '../painting/image_data.dart'; void main() { - final MockHttpClient client = new MockHttpClient(); - final MockHttpClientRequest request = new MockHttpClientRequest(); - final MockHttpClientResponse response = new MockHttpClientResponse(); - final MockHttpHeaders headers = new MockHttpHeaders(); + final MockHttpClient client = MockHttpClient(); + final MockHttpClientRequest request = MockHttpClientRequest(); + final MockHttpClientResponse response = MockHttpClientResponse(); + final MockHttpHeaders headers = MockHttpHeaders(); testWidgets('Headers', (WidgetTester tester) async { HttpOverrides.runZoned(() async { - await tester.pumpWidget(new Image.network( + await tester.pumpWidget(Image.network( 'https://www.example.com/images/frame.png', headers: const {'flutter': 'flutter'}, )); @@ -27,9 +27,9 @@ void main() { verify(headers.add('flutter', 'flutter')).called(1); }, createHttpClient: (SecurityContext _) { - when(client.getUrl(any)).thenAnswer((_) => new Future.value(request)); + when(client.getUrl(any)).thenAnswer((_) => Future.value(request)); when(request.headers).thenReturn(headers); - when(request.close()).thenAnswer((_) => new Future.value(response)); + when(request.close()).thenAnswer((_) => Future.value(response)); when(response.contentLength).thenReturn(kTransparentImage.length); when(response.statusCode).thenReturn(HttpStatus.ok); when(response.listen(any)).thenAnswer((Invocation invocation) { @@ -37,7 +37,7 @@ void main() { final void Function() onDone = invocation.namedArguments[#onDone]; final void Function(Object, [StackTrace]) onError = invocation.namedArguments[#onError]; final bool cancelOnError = invocation.namedArguments[#cancelOnError]; - return new Stream>.fromIterable(>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError); + return Stream>.fromIterable(>[kTransparentImage]).listen(onData, onDone: onDone, onError: onError, cancelOnError: cancelOnError); }); return client; }); diff --git a/packages/flutter/test/widgets/image_package_asset_test.dart b/packages/flutter/test/widgets/image_package_asset_test.dart index a31c62aa97..09f286a9f5 100644 --- a/packages/flutter/test/widgets/image_package_asset_test.dart +++ b/packages/flutter/test/widgets/image_package_asset_test.dart @@ -24,7 +24,7 @@ void main() { }); test('Image.asset from package', () { - final Image imageWidget = new Image.asset( + final Image imageWidget = Image.asset( 'assets/image.png', package: 'test_package', ); @@ -34,7 +34,7 @@ void main() { }); test('Image.asset from package', () { - final Image imageWidget = new Image.asset( + final Image imageWidget = Image.asset( 'assets/image.png', scale: 1.5, package: 'test_package', diff --git a/packages/flutter/test/widgets/image_resolution_test.dart b/packages/flutter/test/widgets/image_resolution_test.dart index 29165de69e..84f1950fd4 100644 --- a/packages/flutter/test/widgets/image_resolution_test.dart +++ b/packages/flutter/test/widgets/image_resolution_test.dart @@ -27,7 +27,7 @@ class TestImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } } @@ -61,31 +61,31 @@ class TestAssetBundle extends CachingAssetBundle { ByteData data; switch (key) { case 'assets/image.png': - data = new TestByteData(1.0); + data = TestByteData(1.0); break; case 'assets/1.0x/image.png': - data = new TestByteData(10.0); // see "...with a main asset and a 1.0x asset" + data = TestByteData(10.0); // see "...with a main asset and a 1.0x asset" break; case 'assets/1.5x/image.png': - data = new TestByteData(1.5); + data = TestByteData(1.5); break; case 'assets/2.0x/image.png': - data = new TestByteData(2.0); + data = TestByteData(2.0); break; case 'assets/3.0x/image.png': - data = new TestByteData(3.0); + data = TestByteData(3.0); break; case 'assets/4.0x/image.png': - data = new TestByteData(4.0); + data = TestByteData(4.0); break; } - return new SynchronousFuture(data); + return SynchronousFuture(data); } @override Future loadString(String key, { bool cache = true }) { if (key == 'AssetManifest.json') - return new SynchronousFuture(manifest); + return SynchronousFuture(manifest); return null; } @@ -107,12 +107,12 @@ class TestAssetImage extends AssetImage { ImageInfo imageInfo; key.bundle.load(key.name).then((ByteData data) { final TestByteData testData = data; - final ui.Image image = new TestImage(testData.scale); - imageInfo = new ImageInfo(image: image, scale: key.scale); + final ui.Image image = TestImage(testData.scale); + imageInfo = ImageInfo(image: image, scale: key.scale); }); assert(imageInfo != null); - return new FakeImageStreamCompleter( - new SynchronousFuture(imageInfo) + return FakeImageStreamCompleter( + SynchronousFuture(imageInfo) ); } } @@ -121,25 +121,25 @@ Widget buildImageAtRatio(String image, Key key, double ratio, bool inferSize, [A const double windowSize = 500.0; // 500 logical pixels const double imageSize = 200.0; // 200 logical pixels - return new MediaQuery( - data: new MediaQueryData( + return MediaQuery( + data: MediaQueryData( size: const Size(windowSize, windowSize), devicePixelRatio: ratio, padding: const EdgeInsets.all(0.0) ), - child: new DefaultAssetBundle( - bundle: bundle ?? new TestAssetBundle(), - child: new Center( + child: DefaultAssetBundle( + bundle: bundle ?? TestAssetBundle(), + child: Center( child: inferSize ? - new Image( + Image( key: key, excludeFromSemantics: true, - image: new TestAssetImage(image) + image: TestAssetImage(image) ) : - new Image( + Image( key: key, excludeFromSemantics: true, - image: new TestAssetImage(image), + image: TestAssetImage(image), height: imageSize, width: imageSize, fit: BoxFit.fill @@ -167,11 +167,11 @@ void main() { testWidgets('Image for device pixel ratio 1.0', (WidgetTester tester) async { const double ratio = 1.0; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 1.0); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 1.0); @@ -179,11 +179,11 @@ void main() { testWidgets('Image for device pixel ratio 0.5', (WidgetTester tester) async { const double ratio = 0.5; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 1.0); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 1.0); @@ -191,11 +191,11 @@ void main() { testWidgets('Image for device pixel ratio 1.5', (WidgetTester tester) async { const double ratio = 1.5; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 1.5); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 1.5); @@ -203,11 +203,11 @@ void main() { testWidgets('Image for device pixel ratio 1.75', (WidgetTester tester) async { const double ratio = 1.75; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 1.5); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 1.5); @@ -215,11 +215,11 @@ void main() { testWidgets('Image for device pixel ratio 2.3', (WidgetTester tester) async { const double ratio = 2.3; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 2.0); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 2.0); @@ -227,11 +227,11 @@ void main() { testWidgets('Image for device pixel ratio 3.7', (WidgetTester tester) async { const double ratio = 3.7; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 4.0); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 4.0); @@ -239,11 +239,11 @@ void main() { testWidgets('Image for device pixel ratio 5.1', (WidgetTester tester) async { const double ratio = 5.1; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 4.0); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 4.0); @@ -260,14 +260,14 @@ void main() { ] } '''; - final AssetBundle bundle = new TestAssetBundle(manifest: manifest); + final AssetBundle bundle = TestAssetBundle(manifest: manifest); const double ratio = 1.0; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, bundle)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 1.5); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true, bundle)); expect(getRenderImage(tester, key).size, const Size(48.0, 48.0)); expect(getTestImage(tester, key).scale, 1.5); @@ -289,14 +289,14 @@ void main() { ] } '''; - final AssetBundle bundle = new TestAssetBundle(manifest: manifest); + final AssetBundle bundle = TestAssetBundle(manifest: manifest); const double ratio = 1.0; - Key key = new GlobalKey(); + Key key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, false, bundle)); expect(getRenderImage(tester, key).size, const Size(200.0, 200.0)); expect(getTestImage(tester, key).scale, 10.0); - key = new GlobalKey(); + key = GlobalKey(); await pumpTreeToLayout(tester, buildImageAtRatio(image, key, ratio, true, bundle)); expect(getRenderImage(tester, key).size, const Size(480.0, 480.0)); expect(getTestImage(tester, key).scale, 10.0); diff --git a/packages/flutter/test/widgets/image_rtl_test.dart b/packages/flutter/test/widgets/image_rtl_test.dart index b738617488..f613f4081a 100644 --- a/packages/flutter/test/widgets/image_rtl_test.dart +++ b/packages/flutter/test/widgets/image_rtl_test.dart @@ -15,13 +15,13 @@ import '../rendering/mock_canvas.dart'; class TestImageProvider extends ImageProvider { @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override ImageStreamCompleter load(TestImageProvider key) { - return new OneFrameImageStreamCompleter( - new SynchronousFuture(new ImageInfo(image: new TestImage())) + return OneFrameImageStreamCompleter( + SynchronousFuture(ImageInfo(image: TestImage())) ); } } @@ -38,22 +38,22 @@ class TestImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } } void main() { testWidgets('DecorationImage RTL with alignment topEnd and match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, matchTextDirection: true, @@ -66,17 +66,17 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) ..translate(x: 50.0, y: 0.0) ..scale(x: -1.0, y: 1.0) ..translate(x: -50.0, y: 0.0) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale()..scale())); @@ -84,15 +84,15 @@ void main() { testWidgets('DecorationImage LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, matchTextDirection: true, @@ -105,14 +105,14 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale())); @@ -120,15 +120,15 @@ void main() { testWidgets('DecorationImage RTL with alignment topEnd', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, ), @@ -140,14 +140,14 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(16.0, 0.0, 32.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(32.0, 0.0, 48.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(48.0, 0.0, 64.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(64.0, 0.0, 80.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(80.0, 0.0, 96.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(96.0, 0.0, 112.0, 9.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(16.0, 0.0, 32.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(32.0, 0.0, 48.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(48.0, 0.0, 64.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(64.0, 0.0, 80.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(80.0, 0.0, 96.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(96.0, 0.0, 112.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale())); @@ -155,15 +155,15 @@ void main() { testWidgets('DecorationImage LTR with alignment topEnd', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, ), @@ -175,14 +175,14 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale())); @@ -190,15 +190,15 @@ void main() { testWidgets('DecorationImage RTL with alignment center-right and match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: true, ), @@ -213,7 +213,7 @@ void main() { ..translate(x: 50.0, y: 0.0) ..scale(x: -1.0, y: 1.0) ..translate(x: -50.0, y: 0.0) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(0.0, 20.5, 16.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(0.0, 20.5, 16.0, 29.5)) ..restore() ); expect(find.byType(Container), isNot(paints..scale()..scale())); @@ -222,15 +222,15 @@ void main() { testWidgets('DecorationImage RTL with alignment center-right and no match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: Alignment.centerRight, ), ), @@ -241,7 +241,7 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) ); expect(find.byType(Container), isNot(paints..scale())); expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); @@ -249,15 +249,15 @@ void main() { testWidgets('DecorationImage LTR with alignment center-right and match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: true ), @@ -269,7 +269,7 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) ); expect(find.byType(Container), isNot(paints..scale())); expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); @@ -277,15 +277,15 @@ void main() { testWidgets('DecorationImage LTR with alignment center-right and no match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - decoration: new BoxDecoration( - image: new DecorationImage( - image: new TestImageProvider(), + decoration: BoxDecoration( + image: DecorationImage( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: true ), @@ -297,7 +297,7 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) ); expect(find.byType(Container), isNot(paints..scale())); expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); @@ -305,14 +305,14 @@ void main() { testWidgets('Image RTL with alignment topEnd and match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, matchTextDirection: true, @@ -324,17 +324,17 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) ..translate(x: 50.0, y: 0.0) ..scale(x: -1.0, y: 1.0) ..translate(x: -50.0, y: 0.0) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale()..scale())); @@ -342,14 +342,14 @@ void main() { testWidgets('Image LTR with alignment topEnd (and pointless match)', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, matchTextDirection: true, @@ -361,14 +361,14 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale())); @@ -376,14 +376,14 @@ void main() { testWidgets('Image RTL with alignment topEnd', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, ), @@ -394,14 +394,14 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(16.0, 0.0, 32.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(32.0, 0.0, 48.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(48.0, 0.0, 64.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(64.0, 0.0, 80.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(80.0, 0.0, 96.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(96.0, 0.0, 112.0, 9.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(16.0, 0.0, 32.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(32.0, 0.0, 48.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(48.0, 0.0, 64.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(64.0, 0.0, 80.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(80.0, 0.0, 96.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(96.0, 0.0, 112.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale())); @@ -409,14 +409,14 @@ void main() { testWidgets('Image LTR with alignment topEnd', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: AlignmentDirectional.topEnd, repeat: ImageRepeat.repeatX, ), @@ -427,14 +427,14 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..clipRect(rect: new Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) + ..clipRect(rect: Rect.fromLTRB(0.0, 0.0, 100.0, 50.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(-12.0, 0.0, 4.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(4.0, 0.0, 20.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(20.0, 0.0, 36.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(36.0, 0.0, 52.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(52.0, 0.0, 68.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(68.0, 0.0, 84.0, 9.0)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 0.0, 100.0, 9.0)) ..restore() ); expect(find.byType(Container), isNot(paints..scale())); @@ -442,14 +442,14 @@ void main() { testWidgets('Image RTL with alignment center-right and match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: true, ), @@ -463,7 +463,7 @@ void main() { ..translate(x: 50.0, y: 0.0) ..scale(x: -1.0, y: 1.0) ..translate(x: -50.0, y: 0.0) - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(0.0, 20.5, 16.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(0.0, 20.5, 16.0, 29.5)) ..restore() ); expect(find.byType(Container), isNot(paints..scale()..scale())); @@ -472,14 +472,14 @@ void main() { testWidgets('Image RTL with alignment center-right and no match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: Alignment.centerRight, ), ), @@ -489,7 +489,7 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) ); expect(find.byType(Container), isNot(paints..scale())); expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); @@ -497,14 +497,14 @@ void main() { testWidgets('Image LTR with alignment center-right and match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: true ), @@ -515,7 +515,7 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) ); expect(find.byType(Container), isNot(paints..scale())); expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); @@ -523,14 +523,14 @@ void main() { testWidgets('Image LTR with alignment center-right and no match', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, height: 50.0, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: true ), @@ -541,7 +541,7 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); expect(find.byType(Container), paints - ..drawImageRect(source: new Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: new Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) + ..drawImageRect(source: Rect.fromLTRB(0.0, 0.0, 16.0, 9.0), destination: Rect.fromLTRB(84.0, 20.5, 100.0, 29.5)) ); expect(find.byType(Container), isNot(paints..scale())); expect(find.byType(Container), isNot(paints..drawImageRect()..drawImageRect())); @@ -549,10 +549,10 @@ void main() { testWidgets('Image - Switch needing direction', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: false, ), @@ -561,10 +561,10 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: AlignmentDirectional.centerEnd, matchTextDirection: true, ), @@ -573,10 +573,10 @@ void main() { EnginePhase.layout, // so that we don't try to paint the fake images ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), alignment: Alignment.centerRight, matchTextDirection: false, ), diff --git a/packages/flutter/test/widgets/image_test.dart b/packages/flutter/test/widgets/image_test.dart index bb5b00cf21..513b3304a5 100644 --- a/packages/flutter/test/widgets/image_test.dart +++ b/packages/flutter/test/widgets/image_test.dart @@ -16,12 +16,12 @@ import 'semantics_tester.dart'; void main() { testWidgets('Verify Image resets its RenderImage when changing providers', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final TestImageProvider imageProvider1 = new TestImageProvider(); + final GlobalKey key = GlobalKey(); + final TestImageProvider imageProvider1 = TestImageProvider(); await tester.pumpWidget( - new Container( + Container( key: key, - child: new Image( + child: Image( image: imageProvider1, excludeFromSemantics: true, ) @@ -39,11 +39,11 @@ void main() { renderImage = key.currentContext.findRenderObject(); expect(renderImage.image, isNotNull); - final TestImageProvider imageProvider2 = new TestImageProvider(); + final TestImageProvider imageProvider2 = TestImageProvider(); await tester.pumpWidget( - new Container( + Container( key: key, - child: new Image( + child: Image( image: imageProvider2, excludeFromSemantics: true, ) @@ -57,12 +57,12 @@ void main() { }); testWidgets('Verify Image doesn\'t reset its RenderImage when changing providers if it has gaplessPlayback set', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final TestImageProvider imageProvider1 = new TestImageProvider(); + final GlobalKey key = GlobalKey(); + final TestImageProvider imageProvider1 = TestImageProvider(); await tester.pumpWidget( - new Container( + Container( key: key, - child: new Image( + child: Image( gaplessPlayback: true, image: imageProvider1, excludeFromSemantics: true, @@ -81,11 +81,11 @@ void main() { renderImage = key.currentContext.findRenderObject(); expect(renderImage.image, isNotNull); - final TestImageProvider imageProvider2 = new TestImageProvider(); + final TestImageProvider imageProvider2 = TestImageProvider(); await tester.pumpWidget( - new Container( + Container( key: key, - child: new Image( + child: Image( gaplessPlayback: true, image: imageProvider2, excludeFromSemantics: true, @@ -100,10 +100,10 @@ void main() { }); testWidgets('Verify Image resets its RenderImage when changing providers if it has a key', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final TestImageProvider imageProvider1 = new TestImageProvider(); + final GlobalKey key = GlobalKey(); + final TestImageProvider imageProvider1 = TestImageProvider(); await tester.pumpWidget( - new Image( + Image( key: key, image: imageProvider1, excludeFromSemantics: true, @@ -121,9 +121,9 @@ void main() { renderImage = key.currentContext.findRenderObject(); expect(renderImage.image, isNotNull); - final TestImageProvider imageProvider2 = new TestImageProvider(); + final TestImageProvider imageProvider2 = TestImageProvider(); await tester.pumpWidget( - new Image( + Image( key: key, image: imageProvider2, excludeFromSemantics: true, @@ -137,10 +137,10 @@ void main() { }); testWidgets('Verify Image doesn\'t reset its RenderImage when changing providers if it has gaplessPlayback set', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final TestImageProvider imageProvider1 = new TestImageProvider(); + final GlobalKey key = GlobalKey(); + final TestImageProvider imageProvider1 = TestImageProvider(); await tester.pumpWidget( - new Image( + Image( key: key, gaplessPlayback: true, image: imageProvider1, @@ -159,9 +159,9 @@ void main() { renderImage = key.currentContext.findRenderObject(); expect(renderImage.image, isNotNull); - final TestImageProvider imageProvider2 = new TestImageProvider(); + final TestImageProvider imageProvider2 = TestImageProvider(); await tester.pumpWidget( - new Image( + Image( key: key, gaplessPlayback: true, excludeFromSemantics: true, @@ -176,27 +176,27 @@ void main() { }); testWidgets('Verify ImageProvider configuration inheritance', (WidgetTester tester) async { - final GlobalKey mediaQueryKey1 = new GlobalKey(debugLabel: 'mediaQueryKey1'); - final GlobalKey mediaQueryKey2 = new GlobalKey(debugLabel: 'mediaQueryKey2'); - final GlobalKey imageKey = new GlobalKey(debugLabel: 'image'); - final TestImageProvider imageProvider = new TestImageProvider(); + final GlobalKey mediaQueryKey1 = GlobalKey(debugLabel: 'mediaQueryKey1'); + final GlobalKey mediaQueryKey2 = GlobalKey(debugLabel: 'mediaQueryKey2'); + final GlobalKey imageKey = GlobalKey(debugLabel: 'image'); + final TestImageProvider imageProvider = TestImageProvider(); // Of the two nested MediaQuery objects, the innermost one, // mediaQuery2, should define the configuration of the imageProvider. await tester.pumpWidget( - new MediaQuery( + MediaQuery( key: mediaQueryKey1, data: const MediaQueryData( devicePixelRatio: 10.0, padding: EdgeInsets.zero, ), - child: new MediaQuery( + child: MediaQuery( key: mediaQueryKey2, data: const MediaQueryData( devicePixelRatio: 5.0, padding: EdgeInsets.zero, ), - child: new Image( + child: Image( excludeFromSemantics: true, key: imageKey, image: imageProvider @@ -211,19 +211,19 @@ void main() { // two MediaQuery objects have exchanged places. The imageProvider // should be resolved again, with the new innermost MediaQuery. await tester.pumpWidget( - new MediaQuery( + MediaQuery( key: mediaQueryKey2, data: const MediaQueryData( devicePixelRatio: 5.0, padding: EdgeInsets.zero, ), - child: new MediaQuery( + child: MediaQuery( key: mediaQueryKey1, data: const MediaQueryData( devicePixelRatio: 10.0, padding: EdgeInsets.zero, ), - child: new Image( + child: Image( excludeFromSemantics: true, key: imageKey, image: imageProvider @@ -236,36 +236,36 @@ void main() { }); testWidgets('Verify ImageProvider configuration inheritance again', (WidgetTester tester) async { - final GlobalKey mediaQueryKey1 = new GlobalKey(debugLabel: 'mediaQueryKey1'); - final GlobalKey mediaQueryKey2 = new GlobalKey(debugLabel: 'mediaQueryKey2'); - final GlobalKey imageKey = new GlobalKey(debugLabel: 'image'); - final TestImageProvider imageProvider = new TestImageProvider(); + final GlobalKey mediaQueryKey1 = GlobalKey(debugLabel: 'mediaQueryKey1'); + final GlobalKey mediaQueryKey2 = GlobalKey(debugLabel: 'mediaQueryKey2'); + final GlobalKey imageKey = GlobalKey(debugLabel: 'image'); + final TestImageProvider imageProvider = TestImageProvider(); // This is just a variation on the previous test. In this version the location // of the Image changes and the MediaQuery widgets do not. await tester.pumpWidget( - new Row( + Row( textDirection: TextDirection.ltr, children: [ - new MediaQuery( + MediaQuery( key: mediaQueryKey2, data: const MediaQueryData( devicePixelRatio: 5.0, padding: EdgeInsets.zero, ), - child: new Image( + child: Image( excludeFromSemantics: true, key: imageKey, image: imageProvider ) ), - new MediaQuery( + MediaQuery( key: mediaQueryKey1, data: const MediaQueryData( devicePixelRatio: 10.0, padding: EdgeInsets.zero, ), - child: new Container(width: 100.0) + child: Container(width: 100.0) ) ] ) @@ -274,24 +274,24 @@ void main() { expect(imageProvider._lastResolvedConfiguration.devicePixelRatio, 5.0); await tester.pumpWidget( - new Row( + Row( textDirection: TextDirection.ltr, children: [ - new MediaQuery( + MediaQuery( key: mediaQueryKey2, data: const MediaQueryData( devicePixelRatio: 5.0, padding: EdgeInsets.zero, ), - child: new Container(width: 100.0) + child: Container(width: 100.0) ), - new MediaQuery( + MediaQuery( key: mediaQueryKey1, data: const MediaQueryData( devicePixelRatio: 10.0, padding: EdgeInsets.zero, ), - child: new Image( + child: Image( excludeFromSemantics: true, key: imageKey, image: imageProvider @@ -305,14 +305,14 @@ void main() { }); testWidgets('Verify Image stops listening to ImageStream', (WidgetTester tester) async { - final TestImageProvider imageProvider = new TestImageProvider(); - await tester.pumpWidget(new Image(image: imageProvider, excludeFromSemantics: true)); + final TestImageProvider imageProvider = TestImageProvider(); + await tester.pumpWidget(Image(image: imageProvider, excludeFromSemantics: true)); final State image = tester.state/*State*/(find.byType(Image)); expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(stream: ImageStream#00000(OneFrameImageStreamCompleter#00000, unresolved, 2 listeners), pixels: null)')); imageProvider.complete(); await tester.pump(); expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(stream: ImageStream#00000(OneFrameImageStreamCompleter#00000, [100×100] @ 1.0x, 1 listener), pixels: [100×100] @ 1.0x)')); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(image.toString(), equalsIgnoringHashCodes('_ImageState#00000(lifecycle state: defunct, not mounted, stream: ImageStream#00000(OneFrameImageStreamCompleter#00000, [100×100] @ 1.0x, 0 listeners), pixels: [100×100] @ 1.0x)')); }); @@ -328,16 +328,16 @@ void main() { capturedImage = info; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); imageProvider._streamCompleter.addListener(listener, onError: errorListener); ImageConfiguration configuration; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { configuration = createLocalImageConfiguration(context); - return new Container(); + return Container(); }, ), ); @@ -374,15 +374,15 @@ void main() { reportedStackTrace = flutterError.stack; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); ImageConfiguration configuration; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { configuration = createLocalImageConfiguration(context); - return new Container(); + return Container(); }, ), ); @@ -419,18 +419,18 @@ void main() { capturedImage = info; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); imageProvider._streamCompleter.addListener(listener, onError: errorListener); // Add the exact same listener a second time without the errorListener. imageProvider._streamCompleter.addListener(listener); ImageConfiguration configuration; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { configuration = createLocalImageConfiguration(context); - return new Container(); + return Container(); }, ), ); @@ -463,18 +463,18 @@ void main() { capturedImage = info; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); imageProvider._streamCompleter.addListener(listener, onError: errorListener); // Add the exact same errorListener a second time. imageProvider._streamCompleter.addListener(null, onError: errorListener); ImageConfiguration configuration; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { configuration = createLocalImageConfiguration(context); - return new Container(); + return Container(); }, ), ); @@ -510,19 +510,19 @@ void main() { reportedStackTrace = flutterError.stack; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); imageProvider._streamCompleter.addListener(listener, onError: errorListener); // Now remove the listener the error listener is attached to. // Don't explicitly remove the error listener. imageProvider._streamCompleter.removeListener(listener); ImageConfiguration configuration; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { configuration = createLocalImageConfiguration(context); - return new Container(); + return Container(); }, ), ); @@ -551,9 +551,9 @@ void main() { capturedImage = info; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); imageProvider._streamCompleter.addListener(listener, onError: errorListener); // Duplicates the same set of listener and errorListener. imageProvider._streamCompleter.addListener(listener, onError: errorListener); @@ -562,10 +562,10 @@ void main() { imageProvider._streamCompleter.removeListener(listener); ImageConfiguration configuration; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { configuration = createLocalImageConfiguration(context); - return new Container(); + return Container(); }, ), ); @@ -582,14 +582,14 @@ void main() { }); testWidgets('Image.memory control test', (WidgetTester tester) async { - await tester.pumpWidget(new Image.memory(new Uint8List.fromList(kTransparentImage), excludeFromSemantics: true,)); + await tester.pumpWidget(Image.memory(Uint8List.fromList(kTransparentImage), excludeFromSemantics: true,)); }); testWidgets('Image color and colorBlend parameters', (WidgetTester tester) async { await tester.pumpWidget( - new Image( + Image( excludeFromSemantics: true, - image: new TestImageProvider(), + image: TestImageProvider(), color: const Color(0xFF00FF00), colorBlendMode: BlendMode.clear ) @@ -600,13 +600,13 @@ void main() { }); testWidgets('Precache', (WidgetTester tester) async { - final TestImageProvider provider = new TestImageProvider(); + final TestImageProvider provider = TestImageProvider(); Future precache; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { precache = precacheImage(provider, context); - return new Container(); + return Container(); } ) ); @@ -629,15 +629,15 @@ void main() { capturedStackTrace = stackTrace; }; - final Exception testException = new Exception('cannot resolve host'); + final Exception testException = Exception('cannot resolve host'); final StackTrace testStack = StackTrace.current; - final TestImageProvider imageProvider = new TestImageProvider(); + final TestImageProvider imageProvider = TestImageProvider(); Future precache; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { precache = precacheImage(imageProvider, context, onError: errorListener); - return new Container(); + return Container(); } ) ); @@ -652,20 +652,20 @@ void main() { }); testWidgets('TickerMode controls stream registration', (WidgetTester tester) async { - final TestImageStreamCompleter imageStreamCompleter = new TestImageStreamCompleter(); - final Image image = new Image( + final TestImageStreamCompleter imageStreamCompleter = TestImageStreamCompleter(); + final Image image = Image( excludeFromSemantics: true, - image: new TestImageProvider(streamCompleter: imageStreamCompleter), + image: TestImageProvider(streamCompleter: imageStreamCompleter), ); await tester.pumpWidget( - new TickerMode( + TickerMode( enabled: true, child: image, ), ); expect(imageStreamCompleter.listeners.length, 2); await tester.pumpWidget( - new TickerMode( + TickerMode( enabled: false, child: image, ), @@ -674,15 +674,15 @@ void main() { }); testWidgets('Verify Image shows correct RenderImage when changing to an already completed provider', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); - final TestImageProvider imageProvider1 = new TestImageProvider(); - final TestImageProvider imageProvider2 = new TestImageProvider(); + final TestImageProvider imageProvider1 = TestImageProvider(); + final TestImageProvider imageProvider2 = TestImageProvider(); await tester.pumpWidget( - new Container( + Container( key: key, - child: new Image( + child: Image( excludeFromSemantics: true, image: imageProvider1 ) @@ -704,9 +704,9 @@ void main() { final ui.Image oldImage = renderImage.image; await tester.pumpWidget( - new Container( + Container( key: key, - child: new Image( + child: Image( excludeFromSemantics: true, image: imageProvider2 ) @@ -721,13 +721,13 @@ void main() { }); testWidgets('Image State can be reconfigured to use another image', (WidgetTester tester) async { - final Image image1 = new Image(image: new TestImageProvider()..complete(), width: 10.0, excludeFromSemantics: true); - final Image image2 = new Image(image: new TestImageProvider()..complete(), width: 20.0, excludeFromSemantics: true); + final Image image1 = Image(image: TestImageProvider()..complete(), width: 10.0, excludeFromSemantics: true); + final Image image2 = Image(image: TestImageProvider()..complete(), width: 20.0, excludeFromSemantics: true); - final Column column = new Column(children: [image1, image2]); + final Column column = Column(children: [image1, image2]); await tester.pumpWidget(column, null, EnginePhase.layout); - final Column columnSwapped = new Column(children: [image2, image1]); + final Column columnSwapped = Column(children: [image2, image1]); await tester.pumpWidget(columnSwapped, null, EnginePhase.layout); final List renderObjects = tester.renderObjectList(find.byType(Image)).toList(); @@ -739,14 +739,14 @@ void main() { }); testWidgets('Image contributes semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Row( + child: Row( children: [ - new Image( - image: new TestImageProvider(), + Image( + image: TestImageProvider(), width: 100.0, height: 100.0, semanticLabel: 'test', @@ -756,12 +756,12 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'test', - rect: new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), + rect: Rect.fromLTWH(0.0, 0.0, 100.0, 100.0), textDirection: TextDirection.ltr, flags: [SemanticsFlag.isImage], ) @@ -771,12 +771,12 @@ void main() { }); testWidgets('Image can exclude semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Image( - image: new TestImageProvider(), + child: Image( + image: TestImageProvider(), width: 100.0, height: 100.0, excludeFromSemantics: true, @@ -784,7 +784,7 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [] ))); semantics.dispose(); @@ -792,18 +792,18 @@ void main() { } class TestImageProvider extends ImageProvider { - final Completer _completer = new Completer(); + final Completer _completer = Completer(); ImageStreamCompleter _streamCompleter; ImageConfiguration _lastResolvedConfiguration; TestImageProvider({ImageStreamCompleter streamCompleter}) { _streamCompleter = streamCompleter - ?? new OneFrameImageStreamCompleter(_completer.future); + ?? OneFrameImageStreamCompleter(_completer.future); } @override Future obtainKey(ImageConfiguration configuration) { - return new SynchronousFuture(this); + return SynchronousFuture(this); } @override @@ -816,7 +816,7 @@ class TestImageProvider extends ImageProvider { ImageStreamCompleter load(TestImageProvider key) => _streamCompleter; void complete() { - _completer.complete(new ImageInfo(image: new TestImage())); + _completer.complete(ImageInfo(image: TestImage())); } void fail(dynamic exception, StackTrace stackTrace) { @@ -853,7 +853,7 @@ class TestImage implements ui.Image { @override Future toByteData({ui.ImageByteFormat format}) async { - throw new UnsupportedError('Cannot encode test image'); + throw UnsupportedError('Cannot encode test image'); } @override diff --git a/packages/flutter/test/widgets/implicit_animations_test.dart b/packages/flutter/test/widgets/implicit_animations_test.dart index 7bc2da074e..73e6e82bc7 100644 --- a/packages/flutter/test/widgets/implicit_animations_test.dart +++ b/packages/flutter/test/widgets/implicit_animations_test.dart @@ -7,9 +7,9 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('BoxConstraintsTween control test', (WidgetTester tester) async { - final BoxConstraintsTween tween = new BoxConstraintsTween( - begin: new BoxConstraints.tight(const Size(20.0, 50.0)), - end: new BoxConstraints.tight(const Size(10.0, 30.0)) + final BoxConstraintsTween tween = BoxConstraintsTween( + begin: BoxConstraints.tight(const Size(20.0, 50.0)), + end: BoxConstraints.tight(const Size(10.0, 30.0)) ); final BoxConstraints result = tween.lerp(0.25); expect(result.minWidth, 17.5); @@ -19,7 +19,7 @@ void main() { }); testWidgets('DecorationTween control test', (WidgetTester tester) async { - final DecorationTween tween = new DecorationTween( + final DecorationTween tween = DecorationTween( begin: const BoxDecoration(color: Color(0xFF00FF00)), end: const BoxDecoration(color: Color(0xFFFFFF00)) ); @@ -28,7 +28,7 @@ void main() { }); testWidgets('EdgeInsetsTween control test', (WidgetTester tester) async { - final EdgeInsetsTween tween = new EdgeInsetsTween( + final EdgeInsetsTween tween = EdgeInsetsTween( begin: const EdgeInsets.symmetric(vertical: 50.0), end: const EdgeInsets.only(top: 10.0, bottom: 30.0) ); @@ -40,11 +40,11 @@ void main() { }); testWidgets('Matrix4Tween control test', (WidgetTester tester) async { - final Matrix4Tween tween = new Matrix4Tween( - begin: new Matrix4.translationValues(10.0, 20.0, 30.0), - end: new Matrix4.translationValues(14.0, 24.0, 34.0) + final Matrix4Tween tween = Matrix4Tween( + begin: Matrix4.translationValues(10.0, 20.0, 30.0), + end: Matrix4.translationValues(14.0, 24.0, 34.0) ); final Matrix4 result = tween.lerp(0.25); - expect(result, equals(new Matrix4.translationValues(11.0, 21.0, 31.0))); + expect(result, equals(Matrix4.translationValues(11.0, 21.0, 31.0))); }); } diff --git a/packages/flutter/test/widgets/implicit_semantics_test.dart b/packages/flutter/test/widgets/implicit_semantics_test.dart index 757f7ab3ac..ae4ff10f24 100644 --- a/packages/flutter/test/widgets/implicit_semantics_test.dart +++ b/packages/flutter/test/widgets/implicit_semantics_test.dart @@ -11,15 +11,15 @@ import 'semantics_tester.dart'; void main() { testWidgets('Implicit Semantics merge behavior', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, explicitChildNodes: false, - child: new Column( + child: Column( children: const [ Text('Michael Goderbauer'), Text('goderbauer@google.com'), @@ -34,9 +34,9 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'Michael Goderbauer\ngoderbauer@google.com', ), @@ -48,12 +48,12 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, explicitChildNodes: true, - child: new Column( + child: Column( children: const [ Text('Michael Goderbauer'), Text('goderbauer@google.com'), @@ -70,16 +70,16 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, children: [ - new TestSemantics( + TestSemantics( id: 2, label: 'Michael Goderbauer', ), - new TestSemantics( + TestSemantics( id: 3, label: 'goderbauer@google.com', ), @@ -93,14 +93,14 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, explicitChildNodes: true, - child: new Semantics( + child: Semantics( label: 'Signed in as', - child: new Column( + child: Column( children: const [ Text('Michael Goderbauer'), Text('goderbauer@google.com'), @@ -117,12 +117,12 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, children: [ - new TestSemantics( + TestSemantics( id: 4, label: 'Signed in as\nMichael Goderbauer\ngoderbauer@google.com', ), @@ -136,14 +136,14 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, explicitChildNodes: false, - child: new Semantics( + child: Semantics( label: 'Signed in as', - child: new Column( + child: Column( children: const [ Text('Michael Goderbauer'), Text('goderbauer@google.com'), @@ -159,9 +159,9 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'Signed in as\nMichael Goderbauer\ngoderbauer@google.com', ), @@ -176,36 +176,36 @@ void main() { }); testWidgets('Do not merge with conflicts', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, explicitChildNodes: false, - child: new Column( + child: Column( children: [ - new Semantics( + Semantics( label: 'node 1', selected: true, - child: new Container( + child: Container( width: 10.0, height: 10.0, ), ), - new Semantics( + Semantics( label: 'node 2', selected: true, - child: new Container( + child: Container( width: 10.0, height: 10.0, ), ), - new Semantics( + Semantics( label: 'node 3', selected: true, - child: new Container( + child: Container( width: 10.0, height: 10.0, ), @@ -224,22 +224,22 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 5, children: [ - new TestSemantics( + TestSemantics( id: 6, flags: SemanticsFlag.isSelected.index, label: 'node 1', ), - new TestSemantics( + TestSemantics( id: 7, flags: SemanticsFlag.isSelected.index, label: 'node 2', ), - new TestSemantics( + TestSemantics( id: 8, flags: SemanticsFlag.isSelected.index, label: 'node 3', diff --git a/packages/flutter/test/widgets/independent_widget_layout_test.dart b/packages/flutter/test/widgets/independent_widget_layout_test.dart index dac123706d..2f2d8af13b 100644 --- a/packages/flutter/test/widgets/independent_widget_layout_test.dart +++ b/packages/flutter/test/widgets/independent_widget_layout_test.dart @@ -23,13 +23,13 @@ class OffscreenWidgetTree { renderView.scheduleInitialFrame(); } - final RenderView renderView = new OffscreenRenderView(); - final BuildOwner buildOwner = new BuildOwner(); - final PipelineOwner pipelineOwner = new PipelineOwner(); + final RenderView renderView = OffscreenRenderView(); + final BuildOwner buildOwner = BuildOwner(); + final PipelineOwner pipelineOwner = PipelineOwner(); RenderObjectToWidgetElement root; void pumpWidget(Widget app) { - root = new RenderObjectToWidgetAdapter( + root = RenderObjectToWidgetAdapter( container: renderView, debugShortDescription: '[root]', child: app @@ -66,7 +66,7 @@ class TriggerableWidget extends StatefulWidget { final Trigger trigger; final Counter counter; @override - TriggerableState createState() => new TriggerableState(); + TriggerableState createState() => TriggerableState(); } class TriggerableState extends State { @@ -92,7 +92,7 @@ class TriggerableState extends State { @override Widget build(BuildContext context) { widget.counter.count++; - return new Text('Bang $_count!', textDirection: TextDirection.ltr); + return Text('Bang $_count!', textDirection: TextDirection.ltr); } } @@ -107,7 +107,7 @@ class TestFocusable extends StatefulWidget { final FocusNode focusNode; @override - TestFocusableState createState() => new TestFocusableState(); + TestFocusableState createState() => TestFocusableState(); } class TestFocusableState extends State { @@ -130,21 +130,21 @@ class TestFocusableState extends State { void main() { testWidgets('no crosstalk between widget build owners', (WidgetTester tester) async { - final Trigger trigger1 = new Trigger(); - final Counter counter1 = new Counter(); - final Trigger trigger2 = new Trigger(); - final Counter counter2 = new Counter(); - final OffscreenWidgetTree tree = new OffscreenWidgetTree(); + final Trigger trigger1 = Trigger(); + final Counter counter1 = Counter(); + final Trigger trigger2 = Trigger(); + final Counter counter2 = Counter(); + final OffscreenWidgetTree tree = OffscreenWidgetTree(); // Both counts should start at zero expect(counter1.count, equals(0)); expect(counter2.count, equals(0)); // Lay out the "onscreen" in the default test binding - await tester.pumpWidget(new TriggerableWidget(trigger: trigger1, counter: counter1)); + await tester.pumpWidget(TriggerableWidget(trigger: trigger1, counter: counter1)); // Only the "onscreen" widget should have built expect(counter1.count, equals(1)); expect(counter2.count, equals(0)); // Lay out the "offscreen" in a separate tree - tree.pumpWidget(new TriggerableWidget(trigger: trigger2, counter: counter2)); + tree.pumpWidget(TriggerableWidget(trigger: trigger2, counter: counter2)); // Now both widgets should have built expect(counter1.count, equals(1)); expect(counter2.count, equals(1)); @@ -180,16 +180,16 @@ void main() { }); testWidgets('no crosstalk between focus nodes', (WidgetTester tester) async { - final OffscreenWidgetTree tree = new OffscreenWidgetTree(); - final FocusNode onscreenFocus = new FocusNode(); - final FocusNode offscreenFocus = new FocusNode(); + final OffscreenWidgetTree tree = OffscreenWidgetTree(); + final FocusNode onscreenFocus = FocusNode(); + final FocusNode offscreenFocus = FocusNode(); await tester.pumpWidget( - new TestFocusable( + TestFocusable( focusNode: onscreenFocus, ), ); tree.pumpWidget( - new TestFocusable( + TestFocusable( focusNode: offscreenFocus, ), ); diff --git a/packages/flutter/test/widgets/inherited_model_test.dart b/packages/flutter/test/widgets/inherited_model_test.dart index aec404f9bf..d27aa4e47c 100644 --- a/packages/flutter/test/widgets/inherited_model_test.dart +++ b/packages/flutter/test/widgets/inherited_model_test.dart @@ -59,7 +59,7 @@ class ShowABCField extends StatefulWidget { final String fieldName; @override - _ShowABCFieldState createState() => new _ShowABCFieldState(); + _ShowABCFieldState createState() => _ShowABCFieldState(); } class _ShowABCFieldState extends State { @@ -69,7 +69,7 @@ class _ShowABCFieldState extends State { Widget build(BuildContext context) { final ABCModel abc = ABCModel.of(context, fieldName: widget.fieldName); final int value = widget.fieldName == 'a' ? abc.a : (widget.fieldName == 'b' ? abc.b : abc.c); - return new Text('${widget.fieldName}: $value [${_buildCount++}]'); + return Text('${widget.fieldName}: $value [${_buildCount++}]'); } } @@ -79,7 +79,7 @@ void main() { int _b = 1; int _c = 2; - final Widget abcPage = new StatefulBuilder( + final Widget abcPage = StatefulBuilder( builder: (BuildContext context, StateSetter setState) { const Widget showA = ShowABCField(fieldName: 'a'); const Widget showB = ShowABCField(fieldName: 'b'); @@ -87,29 +87,29 @@ void main() { // Unconditionally depends on the ABCModel: rebuilt when any // aspect of the model changes. - final Widget showABC = new Builder( + final Widget showABC = Builder( builder: (BuildContext context) { final ABCModel abc = ABCModel.of(context); - return new Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}'); + return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}'); } ); - return new Scaffold( - body: new StatefulBuilder( + return Scaffold( + body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new ABCModel( + return ABCModel( a: _a, b: _b, c: _c, - child: new Center( - child: new Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, children: [ showA, showB, showC, showABC, - new RaisedButton( + RaisedButton( child: const Text('Increment a'), onPressed: () { // Rebuilds the ABCModel which triggers a rebuild @@ -118,7 +118,7 @@ void main() { setState(() { _a += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('Increment b'), onPressed: () { // Rebuilds the ABCModel which triggers a rebuild @@ -127,7 +127,7 @@ void main() { setState(() { _b += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('Increment c'), onPressed: () { // Rebuilds the ABCModel which triggers a rebuild @@ -146,7 +146,7 @@ void main() { }, ); - await tester.pumpWidget(new MaterialApp(home: abcPage)); + await tester.pumpWidget(MaterialApp(home: abcPage)); expect(find.text('a: 0 [0]'), findsOneWidget); expect(find.text('b: 1 [0]'), findsOneWidget); @@ -200,7 +200,7 @@ void main() { // properties shadow (override) the outer model. Further complicating // matters: the inner model only supports the model's "a" aspect, // so showB and showC will depend on the outer model. - final Widget abcPage = new StatefulBuilder( + final Widget abcPage = StatefulBuilder( builder: (BuildContext context, StateSetter setState) { const Widget showA = ShowABCField(fieldName: 'a'); const Widget showB = ShowABCField(fieldName: 'b'); @@ -208,26 +208,26 @@ void main() { // Unconditionally depends on the closest ABCModel ancestor. // Which is the inner model, for which b,c are null. - final Widget showABC = new Builder( + final Widget showABC = Builder( builder: (BuildContext context) { final ABCModel abc = ABCModel.of(context); - return new Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context).textTheme.title); + return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context).textTheme.title); } ); - return new Scaffold( - body: new StatefulBuilder( + return Scaffold( + body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new ABCModel( // The "outer" model + return ABCModel( // The "outer" model a: _a, b: _b, c: _c, - child: new ABCModel( // The "inner" model + child: ABCModel( // The "inner" model a: 100 + _a, b: 100 + _b, - aspects: new Set.of(['a']), - child: new Center( - child: new Column( + aspects: Set.of(['a']), + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, children: [ showA, @@ -236,19 +236,19 @@ void main() { const SizedBox(height: 24.0), showABC, const SizedBox(height: 24.0), - new RaisedButton( + RaisedButton( child: const Text('Increment a'), onPressed: () { setState(() { _a += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('Increment b'), onPressed: () { setState(() { _b += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('Increment c'), onPressed: () { setState(() { _c += 1; }); @@ -265,7 +265,7 @@ void main() { }, ); - await tester.pumpWidget(new MaterialApp(home: abcPage)); + await tester.pumpWidget(MaterialApp(home: abcPage)); expect(find.text('a: 100 [0]'), findsOneWidget); expect(find.text('b: 1 [0]'), findsOneWidget); expect(find.text('c: 2 [0]'), findsOneWidget); @@ -312,12 +312,12 @@ void main() { int _a = 0; int _b = 1; int _c = 2; - Set _innerModelAspects = new Set.of(['a']); + Set _innerModelAspects = Set.of(['a']); // Same as in abcPage in the "Inner InheritedModel shadows the outer one" // test except: the "Add b aspect" changes adds 'b' to the set of // aspects supported by the inner model. - final Widget abcPage = new StatefulBuilder( + final Widget abcPage = StatefulBuilder( builder: (BuildContext context, StateSetter setState) { const Widget showA = ShowABCField(fieldName: 'a'); const Widget showB = ShowABCField(fieldName: 'b'); @@ -325,26 +325,26 @@ void main() { // Unconditionally depends on the closest ABCModel ancestor. // Which is the inner model, for which b,c are null. - final Widget showABC = new Builder( + final Widget showABC = Builder( builder: (BuildContext context) { final ABCModel abc = ABCModel.of(context); - return new Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context).textTheme.title); + return Text('a: ${abc.a} b: ${abc.b} c: ${abc.c}', style: Theme.of(context).textTheme.title); } ); - return new Scaffold( - body: new StatefulBuilder( + return Scaffold( + body: StatefulBuilder( builder: (BuildContext context, StateSetter setState) { - return new ABCModel( // The "outer" model + return ABCModel( // The "outer" model a: _a, b: _b, c: _c, - child: new ABCModel( // The "inner" model + child: ABCModel( // The "inner" model a: 100 + _a, b: 100 + _b, aspects: _innerModelAspects, - child: new Center( - child: new Column( + child: Center( + child: Column( mainAxisSize: MainAxisSize.min, children: [ showA, @@ -353,25 +353,25 @@ void main() { const SizedBox(height: 24.0), showABC, const SizedBox(height: 24.0), - new RaisedButton( + RaisedButton( child: const Text('Increment a'), onPressed: () { setState(() { _a += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('Increment b'), onPressed: () { setState(() { _b += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('Increment c'), onPressed: () { setState(() { _c += 1; }); }, ), - new RaisedButton( + RaisedButton( child: const Text('rebuild'), onPressed: () { setState(() { @@ -390,14 +390,14 @@ void main() { }, ); - _innerModelAspects = new Set.of(['a']); - await tester.pumpWidget(new MaterialApp(home: abcPage)); + _innerModelAspects = Set.of(['a']); + await tester.pumpWidget(MaterialApp(home: abcPage)); expect(find.text('a: 100 [0]'), findsOneWidget); // showA depends on the inner model expect(find.text('b: 1 [0]'), findsOneWidget); // showB depends on the outer model expect(find.text('c: 2 [0]'), findsOneWidget); expect(find.text('a: 100 b: 101 c: null'), findsOneWidget); // inner model's a, b, c - _innerModelAspects = new Set.of(['a', 'b']); + _innerModelAspects = Set.of(['a', 'b']); await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 100 [1]'), findsOneWidget); // rebuilt showA still depend on the inner model @@ -432,7 +432,7 @@ void main() { expect(find.text('c: 3 [2]'), findsOneWidget); // rebuilt showC still depends on the outer model expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); - _innerModelAspects = new Set.of(['a', 'b', 'c']); + _innerModelAspects = Set.of(['a', 'b', 'c']); await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 101 [3]'), findsOneWidget); // rebuilt showA still depend on the inner model @@ -441,7 +441,7 @@ void main() { expect(find.text('a: 101 b: 102 c: null'), findsOneWidget); // inner model's a, b, c // Now the inner model supports no aspects - _innerModelAspects = new Set.of([]); + _innerModelAspects = Set.of([]); await tester.tap(find.text('rebuild')); await tester.pumpAndSettle(); expect(find.text('a: 1 [4]'), findsOneWidget); // rebuilt showA now depends on the outer model diff --git a/packages/flutter/test/widgets/inherited_test.dart b/packages/flutter/test/widgets/inherited_test.dart index d7704485f9..cb718a0b94 100644 --- a/packages/flutter/test/widgets/inherited_test.dart +++ b/packages/flutter/test/widgets/inherited_test.dart @@ -34,7 +34,7 @@ class ExpectFail extends StatefulWidget { final VoidCallback onError; @override - ExpectFailState createState() => new ExpectFailState(); + ExpectFailState createState() => ExpectFailState(); } class ExpectFailState extends State { @@ -49,49 +49,49 @@ class ExpectFailState extends State { } @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } void main() { testWidgets('Inherited notifies dependents', (WidgetTester tester) async { final List log = []; - final Builder builder = new Builder( + final Builder builder = Builder( builder: (BuildContext context) { log.add(context.inheritFromWidgetOfExactType(TestInherited)); - return new Container(); + return Container(); } ); - final TestInherited first = new TestInherited(child: builder); + final TestInherited first = TestInherited(child: builder); await tester.pumpWidget(first); expect(log, equals([first])); - final TestInherited second = new TestInherited(child: builder, shouldNotify: false); + final TestInherited second = TestInherited(child: builder, shouldNotify: false); await tester.pumpWidget(second); expect(log, equals([first])); - final TestInherited third = new TestInherited(child: builder, shouldNotify: true); + final TestInherited third = TestInherited(child: builder, shouldNotify: true); await tester.pumpWidget(third); expect(log, equals([first, third])); }); testWidgets('Update inherited when reparenting state', (WidgetTester tester) async { - final GlobalKey globalKey = new GlobalKey(); + final GlobalKey globalKey = GlobalKey(); final List log = []; TestInherited build() { - return new TestInherited( - key: new UniqueKey(), - child: new Container( + return TestInherited( + key: UniqueKey(), + child: Container( key: globalKey, - child: new Builder( + child: Builder( builder: (BuildContext context) { log.add(context.inheritFromWidgetOfExactType(TestInherited)); - return new Container(); + return Container(); } ) ) @@ -113,19 +113,19 @@ void main() { final List log = []; await tester.pumpWidget( - new Container( - child: new ValueInherited( + Container( + child: ValueInherited( value: 1, - child: new Container( - child: new FlipWidget( - left: new Container( - child: new ValueInherited( + child: Container( + child: FlipWidget( + left: Container( + child: ValueInherited( value: 2, - child: new Container( - child: new ValueInherited( + child: Container( + child: ValueInherited( value: 3, - child: new Container( - child: new Builder( + child: Container( + child: Builder( builder: (BuildContext context) { final ValueInherited v = context.inheritFromWidgetOfExactType(ValueInherited); log.add('a: ${v.value}'); @@ -137,12 +137,12 @@ void main() { ) ) ), - right: new Container( - child: new ValueInherited( + right: Container( + child: ValueInherited( value: 2, - child: new Container( - child: new Container( - child: new Builder( + child: Container( + child: Container( + child: Builder( builder: (BuildContext context) { final ValueInherited v = context.inheritFromWidgetOfExactType(ValueInherited); log.add('b: ${v.value}'); @@ -184,23 +184,23 @@ void main() { final List log = []; - final Key key = new GlobalKey(); + final Key key = GlobalKey(); await tester.pumpWidget( - new Container( - child: new ValueInherited( + Container( + child: ValueInherited( value: 1, - child: new Container( - child: new FlipWidget( - left: new Container( - child: new ValueInherited( + child: Container( + child: FlipWidget( + left: Container( + child: ValueInherited( value: 2, - child: new Container( - child: new ValueInherited( + child: Container( + child: ValueInherited( value: 3, - child: new Container( + child: Container( key: key, - child: new Builder( + child: Builder( builder: (BuildContext context) { final ValueInherited v = context.inheritFromWidgetOfExactType(ValueInherited); log.add('a: ${v.value}'); @@ -212,13 +212,13 @@ void main() { ) ) ), - right: new Container( - child: new ValueInherited( + right: Container( + child: ValueInherited( value: 2, - child: new Container( - child: new Container( + child: Container( + child: Container( key: key, - child: new Builder( + child: Builder( builder: (BuildContext context) { final ValueInherited v = context.inheritFromWidgetOfExactType(ValueInherited); log.add('b: ${v.value}'); @@ -259,9 +259,9 @@ void main() { testWidgets('Update inherited when removing node and child has global key with constant child', (WidgetTester tester) async { final List log = []; - final Key key = new GlobalKey(); + final Key key = GlobalKey(); - final Widget child = new Builder( + final Widget child = Builder( builder: (BuildContext context) { final ValueInherited v = context.inheritFromWidgetOfExactType(ValueInherited); log.add(v.value); @@ -270,18 +270,18 @@ void main() { ); await tester.pumpWidget( - new Container( - child: new ValueInherited( + Container( + child: ValueInherited( value: 1, - child: new Container( - child: new FlipWidget( - left: new Container( - child: new ValueInherited( + child: Container( + child: FlipWidget( + left: Container( + child: ValueInherited( value: 2, - child: new Container( - child: new ValueInherited( + child: Container( + child: ValueInherited( value: 3, - child: new Container( + child: Container( key: key, child: child ) @@ -289,11 +289,11 @@ void main() { ) ) ), - right: new Container( - child: new ValueInherited( + right: Container( + child: ValueInherited( value: 2, - child: new Container( - child: new Container( + child: Container( + child: Container( key: key, child: child ) @@ -331,8 +331,8 @@ void main() { final List log = []; - final Widget child = new Builder( - key: new GlobalKey(), + final Widget child = Builder( + key: GlobalKey(), builder: (BuildContext context) { final ValueInherited v = context.inheritFromWidgetOfExactType(ValueInherited); log.add(v.value); @@ -341,10 +341,10 @@ void main() { ); await tester.pumpWidget( - new ValueInherited( + ValueInherited( value: 2, - child: new FlipWidget( - left: new ValueInherited( + child: FlipWidget( + left: ValueInherited( value: 3, child: child ), @@ -377,13 +377,13 @@ void main() { testWidgets('Inherited widget notifies descendants when descendant previously failed to find a match', (WidgetTester tester) async { int inheritedValue = -1; - final Widget inner = new Container( - key: new GlobalKey(), - child: new Builder( + final Widget inner = Container( + key: GlobalKey(), + child: Builder( builder: (BuildContext context) { final ValueInherited widget = context.inheritFromWidgetOfExactType(ValueInherited); inheritedValue = widget?.value; - return new Container(); + return Container(); } ) ); @@ -395,7 +395,7 @@ void main() { inheritedValue = -2; await tester.pumpWidget( - new ValueInherited( + ValueInherited( value: 3, child: inner ) @@ -406,12 +406,12 @@ void main() { testWidgets('Inherited widget doesn\'t notify descendants when descendant did not previously fail to find a match and had no dependencies', (WidgetTester tester) async { int buildCount = 0; - final Widget inner = new Container( - key: new GlobalKey(), - child: new Builder( + final Widget inner = Container( + key: GlobalKey(), + child: Builder( builder: (BuildContext context) { buildCount += 1; - return new Container(); + return Container(); } ) ); @@ -422,7 +422,7 @@ void main() { expect(buildCount, equals(1)); await tester.pumpWidget( - new ValueInherited( + ValueInherited( value: 3, child: inner ) @@ -433,15 +433,15 @@ void main() { testWidgets('Inherited widget does notify descendants when descendant did not previously fail to find a match but did have other dependencies', (WidgetTester tester) async { int buildCount = 0; - final Widget inner = new Container( - key: new GlobalKey(), - child: new TestInherited( + final Widget inner = Container( + key: GlobalKey(), + child: TestInherited( shouldNotify: false, - child: new Builder( + child: Builder( builder: (BuildContext context) { context.inheritFromWidgetOfExactType(TestInherited); buildCount += 1; - return new Container(); + return Container(); } ) ) @@ -453,7 +453,7 @@ void main() { expect(buildCount, equals(1)); await tester.pumpWidget( - new ValueInherited( + ValueInherited( value: 3, child: inner ) @@ -465,7 +465,7 @@ void main() { // This is a regression test for https://github.com/flutter/flutter/issues/5491 bool exceptionCaught = false; - final TestInherited parent = new TestInherited(child: new ExpectFail(() { + final TestInherited parent = TestInherited(child: ExpectFail(() { exceptionCaught = true; })); await tester.pumpWidget(parent); diff --git a/packages/flutter/test/widgets/init_state_test.dart b/packages/flutter/test/widgets/init_state_test.dart index 96c5d29063..62a8769d72 100644 --- a/packages/flutter/test/widgets/init_state_test.dart +++ b/packages/flutter/test/widgets/init_state_test.dart @@ -9,7 +9,7 @@ List ancestors = []; class TestWidget extends StatefulWidget { @override - TestWidgetState createState() => new TestWidgetState(); + TestWidgetState createState() => TestWidgetState(); } class TestWidgetState extends State { @@ -23,12 +23,12 @@ class TestWidgetState extends State { } @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } void main() { testWidgets('initState() is called when we are in the tree', (WidgetTester tester) async { - await tester.pumpWidget(new Container(child: new TestWidget())); + await tester.pumpWidget(Container(child: TestWidget())); expect(ancestors, equals(['Container', 'RenderObjectToWidgetAdapter'])); }); } diff --git a/packages/flutter/test/widgets/keep_alive_test.dart b/packages/flutter/test/widgets/keep_alive_test.dart index bce1f224b7..5155ac2ed8 100644 --- a/packages/flutter/test/widgets/keep_alive_test.dart +++ b/packages/flutter/test/widgets/keep_alive_test.dart @@ -11,7 +11,7 @@ class Leaf extends StatefulWidget { const Leaf({ Key key, this.child }) : super(key: key); final Widget child; @override - _LeafState createState() => new _LeafState(); + _LeafState createState() => _LeafState(); } class _LeafState extends State { @@ -23,7 +23,7 @@ class _LeafState extends State { @override Widget build(BuildContext context) { - return new KeepAlive( + return KeepAlive( keepAlive: _keepAlive, child: widget.child, ); @@ -31,10 +31,10 @@ class _LeafState extends State { } List generateList(Widget child) { - return new List.generate( + return List.generate( 100, - (int index) => new Leaf( - key: new GlobalObjectKey<_LeafState>(index), + (int index) => Leaf( + key: GlobalObjectKey<_LeafState>(index), child: child, ), growable: false, @@ -44,9 +44,9 @@ List generateList(Widget child) { void main() { testWidgets('KeepAlive with ListView with itemExtent', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( cacheExtent: 0.0, addAutomaticKeepAlives: false, addRepaintBoundaries: false, @@ -91,13 +91,13 @@ void main() { testWidgets('KeepAlive with ListView without itemExtent', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( cacheExtent: 0.0, addAutomaticKeepAlives: false, addRepaintBoundaries: false, - children: generateList(new Container(height: 12.3, child: const Placeholder())), // about 50 widgets visible + children: generateList(Container(height: 12.3, child: const Placeholder())), // about 50 widgets visible ), ), ); @@ -137,15 +137,15 @@ void main() { testWidgets('KeepAlive with GridView', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( cacheExtent: 0.0, addAutomaticKeepAlives: false, addRepaintBoundaries: false, crossAxisCount: 2, childAspectRatio: 400.0 / 24.6, // about 50 widgets visible - children: generateList(new Container(child: const Placeholder())), + children: generateList(Container(child: const Placeholder())), ), ), ); @@ -185,9 +185,9 @@ void main() { testWidgets('KeepAlive render tree description', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: false, addRepaintBoundaries: false, itemExtent: 400.0, // 2 visible children diff --git a/packages/flutter/test/widgets/key_test.dart b/packages/flutter/test/widgets/key_test.dart index d5d54b28d9..e34a624563 100644 --- a/packages/flutter/test/widgets/key_test.dart +++ b/packages/flutter/test/widgets/key_test.dart @@ -19,41 +19,41 @@ class NotEquals { void main() { testWidgets('Keys', (WidgetTester tester) async { - expect(new ValueKey(nonconst(3)) == new ValueKey(nonconst(3)), isTrue); - expect(new ValueKey(nonconst(3)) == new ValueKey(nonconst(3)), isFalse); - expect(new ValueKey(nonconst(3)) == new ValueKey(nonconst(2)), isFalse); + expect(ValueKey(nonconst(3)) == ValueKey(nonconst(3)), isTrue); + expect(ValueKey(nonconst(3)) == ValueKey(nonconst(3)), isFalse); + expect(ValueKey(nonconst(3)) == ValueKey(nonconst(2)), isFalse); expect(const ValueKey(double.nan) == const ValueKey(double.nan), isFalse); - expect(new Key(nonconst('')) == new ValueKey(nonconst('')), isTrue); - expect(new ValueKey(nonconst('')) == new ValueKey(nonconst('')), isTrue); - expect(new TestValueKey(nonconst('')) == new ValueKey(nonconst('')), isFalse); - expect(new TestValueKey(nonconst('')) == new TestValueKey(nonconst('')), isTrue); + expect(Key(nonconst('')) == ValueKey(nonconst('')), isTrue); + expect(ValueKey(nonconst('')) == ValueKey(nonconst('')), isTrue); + expect(TestValueKey(nonconst('')) == ValueKey(nonconst('')), isFalse); + expect(TestValueKey(nonconst('')) == TestValueKey(nonconst('')), isTrue); - expect(new ValueKey(nonconst('')) == new ValueKey(nonconst('')), isFalse); - expect(new TestValueKey(nonconst('')) == new TestValueKey(nonconst('')), isFalse); + expect(ValueKey(nonconst('')) == ValueKey(nonconst('')), isFalse); + expect(TestValueKey(nonconst('')) == TestValueKey(nonconst('')), isFalse); - expect(new UniqueKey() == new UniqueKey(), isFalse); - final LocalKey k = new UniqueKey(); - expect(new UniqueKey() == new UniqueKey(), isFalse); + expect(UniqueKey() == UniqueKey(), isFalse); + final LocalKey k = UniqueKey(); + expect(UniqueKey() == UniqueKey(), isFalse); expect(k == k, isTrue); - expect(new ValueKey(k) == new ValueKey(k), isTrue); - expect(new ValueKey(k) == new ValueKey(k), isFalse); - expect(new ObjectKey(k) == new ObjectKey(k), isTrue); + expect(ValueKey(k) == ValueKey(k), isTrue); + expect(ValueKey(k) == ValueKey(k), isFalse); + expect(ObjectKey(k) == ObjectKey(k), isTrue); final NotEquals constNotEquals = nonconst(const NotEquals()); - expect(new ValueKey(constNotEquals) == new ValueKey(constNotEquals), isFalse); - expect(new ObjectKey(constNotEquals) == new ObjectKey(constNotEquals), isTrue); + expect(ValueKey(constNotEquals) == ValueKey(constNotEquals), isFalse); + expect(ObjectKey(constNotEquals) == ObjectKey(constNotEquals), isTrue); final Object constObject = nonconst(const Object()); - expect(new ObjectKey(constObject) == new ObjectKey(constObject), isTrue); - expect(new ObjectKey(new Object()) == new ObjectKey(new Object()), isFalse); + expect(ObjectKey(constObject) == ObjectKey(constObject), isTrue); + expect(ObjectKey(nonconst(Object())) == ObjectKey(nonconst(Object())), isFalse); expect(const ValueKey(true), hasOneLineDescription); - expect(new UniqueKey(), hasOneLineDescription); + expect(UniqueKey(), hasOneLineDescription); expect(const ObjectKey(true), hasOneLineDescription); - expect(new GlobalKey(), hasOneLineDescription); - expect(new GlobalKey(debugLabel: 'hello'), hasOneLineDescription); + expect(GlobalKey(), hasOneLineDescription); + expect(GlobalKey(debugLabel: 'hello'), hasOneLineDescription); expect(const GlobalObjectKey(true), hasOneLineDescription); }); } diff --git a/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart b/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart index c15aaaf5ac..a36711a4a6 100644 --- a/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_global_keys_test.dart @@ -26,7 +26,7 @@ class StatefulWrapper extends StatefulWidget { final Widget child; @override - StatefulWrapperState createState() => new StatefulWrapperState(); + StatefulWrapperState createState() => StatefulWrapperState(); } class StatefulWrapperState extends State { @@ -41,18 +41,18 @@ class StatefulWrapperState extends State { void main() { testWidgets('Moving global key inside a LayoutBuilder', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { - return new Wrapper( - child: new StatefulWrapper(key: key, child: new Container(height: 100.0)), + LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return Wrapper( + child: StatefulWrapper(key: key, child: Container(height: 100.0)), ); }), ); await tester.pumpWidget( - new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { key.currentState.trigger(); - return new StatefulWrapper(key: key, child: new Container(height: 100.0)); + return StatefulWrapper(key: key, child: Container(height: 100.0)); }), ); }); diff --git a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart index 35e6560ccc..1d717e7665 100644 --- a/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_parent_data_test.dart @@ -14,7 +14,7 @@ class SizeChanger extends StatefulWidget { final Widget child; @override - SizeChangerState createState() => new SizeChangerState(); + SizeChangerState createState() => SizeChangerState(); } class SizeChangerState extends State { @@ -28,10 +28,10 @@ class SizeChangerState extends State { @override Widget build(BuildContext context) { - return new Row( + return Row( textDirection: TextDirection.ltr, children: [ - new SizedBox( + SizedBox( height: _flag ? 50.0 : 100.0, width: 100.0, child: widget.child @@ -58,11 +58,11 @@ class Wrapper extends StatelessWidget { void main() { testWidgets('Applying parent data inside a LayoutBuilder', (WidgetTester tester) async { int frame = 1; - await tester.pumpWidget(new SizeChanger( // when this is triggered, the child LayoutBuilder will build again - child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { - return new Column(children: [new Expanded( + await tester.pumpWidget(SizeChanger( // when this is triggered, the child LayoutBuilder will build again + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return Column(children: [Expanded( flex: frame, // this is different after the next pump, so that the parentData has to be applied again - child: new Container(height: 100.0), + child: Container(height: 100.0), )]); }) )); diff --git a/packages/flutter/test/widgets/layout_builder_and_state_test.dart b/packages/flutter/test/widgets/layout_builder_and_state_test.dart index 287c46c52a..88a07800a5 100644 --- a/packages/flutter/test/widgets/layout_builder_and_state_test.dart +++ b/packages/flutter/test/widgets/layout_builder_and_state_test.dart @@ -15,7 +15,7 @@ class StatefulWrapper extends StatefulWidget { final Widget child; @override - StatefulWrapperState createState() => new StatefulWrapperState(); + StatefulWrapperState createState() => StatefulWrapperState(); } class StatefulWrapperState extends State { @@ -50,14 +50,14 @@ class Wrapper extends StatelessWidget { void main() { testWidgets('Calling setState on a widget that moves into a LayoutBuilder in the same frame', (WidgetTester tester) async { StatefulWrapperState statefulWrapper; - final Widget inner = new Wrapper( - child: new StatefulWrapper( - key: new GlobalKey(), - child: new Container(), + final Widget inner = Wrapper( + child: StatefulWrapper( + key: GlobalKey(), + child: Container(), ), ); - await tester.pumpWidget(new FlipWidget( - left: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + await tester.pumpWidget(FlipWidget( + left: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { return inner; }), right: inner, diff --git a/packages/flutter/test/widgets/layout_builder_mutations_test.dart b/packages/flutter/test/widgets/layout_builder_mutations_test.dart index eaa487fc0b..19e6b0d4ce 100644 --- a/packages/flutter/test/widgets/layout_builder_mutations_test.dart +++ b/packages/flutter/test/widgets/layout_builder_mutations_test.dart @@ -22,21 +22,21 @@ class Wrapper extends StatelessWidget { void main() { testWidgets('Moving a global key from another LayoutBuilder at layout time', (WidgetTester tester) async { - final GlobalKey victimKey = new GlobalKey(); + final GlobalKey victimKey = GlobalKey(); - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Wrapper( - child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + Wrapper( + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { return const SizedBox(); }), ), - new Wrapper( - child: new Wrapper( - child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { - return new Wrapper( - child: new SizedBox(key: victimKey) + Wrapper( + child: Wrapper( + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return Wrapper( + child: SizedBox(key: victimKey) ); }) ) @@ -44,19 +44,19 @@ void main() { ], )); - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Wrapper( - child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { - return new Wrapper( - child: new SizedBox(key: victimKey) + Wrapper( + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + return Wrapper( + child: SizedBox(key: victimKey) ); }) ), - new Wrapper( - child: new Wrapper( - child: new LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { + Wrapper( + child: Wrapper( + child: LayoutBuilder(builder: (BuildContext context, BoxConstraints constraints) { return const SizedBox(); }) ) diff --git a/packages/flutter/test/widgets/layout_builder_test.dart b/packages/flutter/test/widgets/layout_builder_test.dart index dc23d5a932..1babfa49fe 100644 --- a/packages/flutter/test/widgets/layout_builder_test.dart +++ b/packages/flutter/test/widgets/layout_builder_test.dart @@ -9,18 +9,18 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('LayoutBuilder parent size', (WidgetTester tester) async { Size layoutBuilderSize; - final Key childKey = new UniqueKey(); - final Key parentKey = new UniqueKey(); + final Key childKey = UniqueKey(); + final Key parentKey = UniqueKey(); await tester.pumpWidget( - new Center( - child: new ConstrainedBox( + Center( + child: ConstrainedBox( constraints: const BoxConstraints(maxWidth: 100.0, maxHeight: 200.0), - child: new LayoutBuilder( + child: LayoutBuilder( key: parentKey, builder: (BuildContext context, BoxConstraints constraints) { layoutBuilderSize = constraints.biggest; - return new SizedBox( + return SizedBox( key: childKey, width: layoutBuilderSize.width / 2.0, height: layoutBuilderSize.height / 2.0 @@ -41,21 +41,21 @@ void main() { testWidgets('LayoutBuilder stateful child', (WidgetTester tester) async { Size layoutBuilderSize; StateSetter setState; - final Key childKey = new UniqueKey(); - final Key parentKey = new UniqueKey(); + final Key childKey = UniqueKey(); + final Key parentKey = UniqueKey(); double childWidth = 10.0; double childHeight = 20.0; await tester.pumpWidget( - new Center( - child: new LayoutBuilder( + Center( + child: LayoutBuilder( key: parentKey, builder: (BuildContext context, BoxConstraints constraints) { layoutBuilderSize = constraints.biggest; - return new StatefulBuilder( + return StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new SizedBox( + return SizedBox( key: childKey, width: childWidth, height: childHeight @@ -87,22 +87,22 @@ void main() { testWidgets('LayoutBuilder stateful parent', (WidgetTester tester) async { Size layoutBuilderSize; StateSetter setState; - final Key childKey = new UniqueKey(); + final Key childKey = UniqueKey(); double childWidth = 10.0; double childHeight = 20.0; await tester.pumpWidget( - new Center( - child: new StatefulBuilder( + Center( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new SizedBox( + return SizedBox( width: childWidth, height: childHeight, - child: new LayoutBuilder( + child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { layoutBuilderSize = constraints.biggest; - return new SizedBox( + return SizedBox( key: childKey, width: layoutBuilderSize.width, height: layoutBuilderSize.height @@ -131,21 +131,21 @@ void main() { testWidgets('LayoutBuilder and Inherited -- do not rebuild when not using inherited', (WidgetTester tester) async { int built = 0; - final Widget target = new LayoutBuilder( + final Widget target = LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { built += 1; - return new Container(); + return Container(); } ); expect(built, 0); - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(MediaQuery( data: const MediaQueryData(size: Size(400.0, 300.0)), child: target )); expect(built, 1); - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(MediaQuery( data: const MediaQueryData(size: Size(300.0, 400.0)), child: target )); @@ -154,22 +154,22 @@ void main() { testWidgets('LayoutBuilder and Inherited -- do rebuild when using inherited', (WidgetTester tester) async { int built = 0; - final Widget target = new LayoutBuilder( + final Widget target = LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { built += 1; MediaQuery.of(context); - return new Container(); + return Container(); } ); expect(built, 0); - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(MediaQuery( data: const MediaQueryData(size: Size(400.0, 300.0)), child: target )); expect(built, 1); - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(MediaQuery( data: const MediaQueryData(size: Size(300.0, 400.0)), child: target )); diff --git a/packages/flutter/test/widgets/linked_scroll_view_test.dart b/packages/flutter/test/widgets/linked_scroll_view_test.dart index 348a5e67be..1f36a3a366 100644 --- a/packages/flutter/test/widgets/linked_scroll_view_test.dart +++ b/packages/flutter/test/widgets/linked_scroll_view_test.dart @@ -59,7 +59,7 @@ class LinkedScrollController extends ScrollController { @override LinkedScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { - return new LinkedScrollPosition( + return LinkedScrollPosition( this, physics: physics, context: context, @@ -151,7 +151,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext { double beforeOverscroll = 0.0; if (owner.canLinkWithBefore && (value < minScrollExtent)) { final double delta = value - minScrollExtent; - _beforeActivities ??= new HashSet(); + _beforeActivities ??= HashSet(); _beforeActivities.addAll(owner.linkWithBefore(this)); for (LinkedScrollActivity activity in _beforeActivities) beforeOverscroll = math.min(activity.moveBy(delta), beforeOverscroll); @@ -161,7 +161,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext { double afterOverscroll = 0.0; if (owner.canLinkWithAfter && (value > maxScrollExtent)) { final double delta = value - maxScrollExtent; - _afterActivities ??= new HashSet(); + _afterActivities ??= HashSet(); _afterActivities.addAll(owner.linkWithAfter(this)); for (LinkedScrollActivity activity in _afterActivities) afterOverscroll = math.max(activity.moveBy(delta), afterOverscroll); @@ -184,7 +184,7 @@ class LinkedScrollPosition extends ScrollPositionWithSingleContext { LinkedScrollActivity link(LinkedScrollPosition driver) { if (this.activity is! LinkedScrollActivity) - beginActivity(new LinkedScrollActivity(this)); + beginActivity(LinkedScrollActivity(this)); final LinkedScrollActivity activity = this.activity; activity.link(driver); return activity; @@ -212,7 +212,7 @@ class LinkedScrollActivity extends ScrollActivity { @override LinkedScrollPosition get delegate => super.delegate; - final Set drivers = new HashSet(); + final Set drivers = HashSet(); void link(LinkedScrollPosition driver) { drivers.add(driver); @@ -257,7 +257,7 @@ class LinkedScrollActivity extends ScrollActivity { class Test extends StatefulWidget { @override - _TestState createState() => new _TestState(); + _TestState createState() => _TestState(); } class _TestState extends State { @@ -267,8 +267,8 @@ class _TestState extends State { @override void initState() { super.initState(); - _beforeController = new LinkedScrollController(); - _afterController = new LinkedScrollController(before: _beforeController); + _beforeController = LinkedScrollController(); + _afterController = LinkedScrollController(before: _beforeController); _beforeController.after = _afterController; } @@ -288,36 +288,36 @@ class _TestState extends State { @override Widget build(BuildContext context) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new Expanded( - child: new ListView( + Expanded( + child: ListView( controller: _beforeController, children: [ - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, color: const Color(0xFF90F090), child: const Center(child: Text('Hello A')), ), - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, color: const Color(0xFF90F090), child: const Center(child: Text('Hello B')), ), - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, color: const Color(0xFF90F090), child: const Center(child: Text('Hello C')), ), - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, @@ -328,32 +328,32 @@ class _TestState extends State { ), ), const Divider(), - new Expanded( - child: new ListView( + Expanded( + child: ListView( controller: _afterController, children: [ - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, color: const Color(0xFF9090F0), child: const Center(child: Text('Hello 1')), ), - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, color: const Color(0xFF9090F0), child: const Center(child: Text('Hello 2')), ), - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, color: const Color(0xFF9090F0), child: const Center(child: Text('Hello 3')), ), - new Container( + Container( margin: const EdgeInsets.all(8.0), padding: const EdgeInsets.all(8.0), height: 250.0, @@ -371,7 +371,7 @@ class _TestState extends State { void main() { testWidgets('LinkedScrollController - 1', (WidgetTester tester) async { - await tester.pumpWidget(new Test()); + await tester.pumpWidget(Test()); expect(find.text('Hello A'), findsOneWidget); expect(find.text('Hello 1'), findsOneWidget); expect(find.text('Hello D'), findsNothing); @@ -449,7 +449,7 @@ void main() { expect(find.text('Hello 4'), findsOneWidget); }); testWidgets('LinkedScrollController - 2', (WidgetTester tester) async { - await tester.pumpWidget(new Test()); + await tester.pumpWidget(Test()); expect(find.text('Hello A'), findsOneWidget); expect(find.text('Hello B'), findsOneWidget); expect(find.text('Hello C'), findsNothing); diff --git a/packages/flutter/test/widgets/list_body_test.dart b/packages/flutter/test/widgets/list_body_test.dart index 734d7f1007..9fb38b91ae 100644 --- a/packages/flutter/test/widgets/list_body_test.dart +++ b/packages/flutter/test/widgets/list_body_test.dart @@ -6,10 +6,10 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/widgets.dart'; final List children = [ - new Container(width: 200.0, height: 150.0), - new Container(width: 200.0, height: 150.0), - new Container(width: 200.0, height: 150.0), - new Container(width: 200.0, height: 150.0), + Container(width: 200.0, height: 150.0), + Container(width: 200.0, height: 150.0), + Container(width: 200.0, height: 150.0), + Container(width: 200.0, height: 150.0), ]; void expectRects(WidgetTester tester, List expected) { @@ -28,47 +28,47 @@ void expectRects(WidgetTester tester, List expected) { void main() { testWidgets('ListBody down', (WidgetTester tester) async { - await tester.pumpWidget(new Flex( + await tester.pumpWidget(Flex( direction: Axis.vertical, - children: [ new ListBody(children: children) ], + children: [ ListBody(children: children) ], )); expectRects( tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 150.0), - new Rect.fromLTWH(0.0, 150.0, 800.0, 150.0), - new Rect.fromLTWH(0.0, 300.0, 800.0, 150.0), - new Rect.fromLTWH(0.0, 450.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 150.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 300.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 450.0, 800.0, 150.0), ], ); }); testWidgets('ListBody up', (WidgetTester tester) async { - await tester.pumpWidget(new Flex( + await tester.pumpWidget(Flex( direction: Axis.vertical, - children: [ new ListBody(reverse: true, children: children) ], + children: [ ListBody(reverse: true, children: children) ], )); expectRects( tester, [ - new Rect.fromLTWH(0.0, 450.0, 800.0, 150.0), - new Rect.fromLTWH(0.0, 300.0, 800.0, 150.0), - new Rect.fromLTWH(0.0, 150.0, 800.0, 150.0), - new Rect.fromLTWH(0.0, 0.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 450.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 300.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 150.0, 800.0, 150.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 150.0), ], ); }); testWidgets('ListBody right', (WidgetTester tester) async { - await tester.pumpWidget(new Flex( + await tester.pumpWidget(Flex( textDirection: TextDirection.ltr, direction: Axis.horizontal, children: [ - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListBody(mainAxis: Axis.horizontal, children: children), + child: ListBody(mainAxis: Axis.horizontal, children: children), ), ], )); @@ -76,22 +76,22 @@ void main() { expectRects( tester, [ - new Rect.fromLTWH(0.0, 0.0, 200.0, 600.0), - new Rect.fromLTWH(200.0, 0.0, 200.0, 600.0), - new Rect.fromLTWH(400.0, 0.0, 200.0, 600.0), - new Rect.fromLTWH(600.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(0.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(200.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(400.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(600.0, 0.0, 200.0, 600.0), ], ); }); testWidgets('ListBody left', (WidgetTester tester) async { - await tester.pumpWidget(new Flex( + await tester.pumpWidget(Flex( textDirection: TextDirection.ltr, direction: Axis.horizontal, children: [ - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new ListBody(mainAxis: Axis.horizontal, children: children), + child: ListBody(mainAxis: Axis.horizontal, children: children), ), ], )); @@ -99,10 +99,10 @@ void main() { expectRects( tester, [ - new Rect.fromLTWH(600.0, 0.0, 200.0, 600.0), - new Rect.fromLTWH(400.0, 0.0, 200.0, 600.0), - new Rect.fromLTWH(200.0, 0.0, 200.0, 600.0), - new Rect.fromLTWH(0.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(600.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(400.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(200.0, 0.0, 200.0, 600.0), + Rect.fromLTWH(0.0, 0.0, 200.0, 600.0), ], ); }); diff --git a/packages/flutter/test/widgets/list_view_builder_test.dart b/packages/flutter/test/widgets/list_view_builder_test.dart index 38ec80399c..fc1907f37c 100644 --- a/packages/flutter/test/widgets/list_view_builder_test.dart +++ b/packages/flutter/test/widgets/list_view_builder_test.dart @@ -15,17 +15,17 @@ void main() { // so if our widget is 100 pixels tall, it should fit exactly 6 times. Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView.builder( + child: FlipWidget( + left: ListView.builder( itemExtent: 100.0, itemBuilder: (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), height: 100.0, - child: new Text('$index'), + child: Text('$index'), ); }, ), @@ -70,20 +70,20 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), width: 500.0, // this should be ignored height: 400.0, // should be overridden by itemExtent - child: new Text('$index', textDirection: TextDirection.ltr) + child: Text('$index', textDirection: TextDirection.ltr) ); }; Widget buildWidget() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView.builder( - controller: new ScrollController(initialScrollOffset: 300.0), + child: FlipWidget( + left: ListView.builder( + controller: ScrollController(initialScrollOffset: 300.0), itemExtent: 200.0, itemBuilder: itemBuilder, ), @@ -143,20 +143,20 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), width: 400.0, // this should be overridden by itemExtent height: 500.0, // this should be ignored - child: new Text('$index'), + child: Text('$index'), ); }; Widget buildWidget() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView.builder( - controller: new ScrollController(initialScrollOffset: 300.0), + child: FlipWidget( + left: ListView.builder( + controller: ScrollController(initialScrollOffset: 300.0), itemBuilder: itemBuilder, itemExtent: 200.0, scrollDirection: Axis.horizontal, @@ -217,12 +217,12 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return new Text('$index', key: new ValueKey(index), textDirection: TextDirection.ltr); + return Text('$index', key: ValueKey(index), textDirection: TextDirection.ltr); }; - final Widget testWidget = new Directionality( + final Widget testWidget = Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemBuilder: itemBuilder, itemExtent: 300.0, itemCount: 10, @@ -263,20 +263,20 @@ void main() { testWidgets('ListView.separated', (WidgetTester tester) async { Widget buildFrame({ int itemCount }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView.separated( + child: ListView.separated( itemCount: itemCount, itemBuilder: (BuildContext context, int index) { - return new SizedBox( + return SizedBox( height: 100.0, - child: new Text('i$index'), + child: Text('i$index'), ); }, separatorBuilder: (BuildContext context, int index) { - return new SizedBox( + return SizedBox( height: 10.0, - child: new Text('s$index'), + child: Text('s$index'), ); }, ), diff --git a/packages/flutter/test/widgets/list_view_correction_test.dart b/packages/flutter/test/widgets/list_view_correction_test.dart index cb5c77743d..d378c2f521 100644 --- a/packages/flutter/test/widgets/list_view_correction_test.dart +++ b/packages/flutter/test/widgets/list_view_correction_test.dart @@ -7,20 +7,20 @@ import 'package:flutter/material.dart'; void main() { testWidgets('ListView can handle shrinking top elements', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( cacheExtent: 0.0, controller: controller, children: [ - new Container(height: 400.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), - new Container(height: 400.0, child: const Text('4')), - new Container(height: 400.0, child: const Text('5')), - new Container(height: 400.0, child: const Text('6')), + Container(height: 400.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), + Container(height: 400.0, child: const Text('4')), + Container(height: 400.0, child: const Text('5')), + Container(height: 400.0, child: const Text('6')), ], ), ), @@ -32,18 +32,18 @@ void main() { expect(tester.getTopLeft(find.text('4')).dy, equals(200.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( cacheExtent: 0.0, controller: controller, children: [ - new Container(height: 200.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), - new Container(height: 400.0, child: const Text('4')), - new Container(height: 400.0, child: const Text('5')), - new Container(height: 400.0, child: const Text('6')), + Container(height: 200.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), + Container(height: 400.0, child: const Text('4')), + Container(height: 400.0, child: const Text('5')), + Container(height: 400.0, child: const Text('6')), ], ), ), @@ -66,19 +66,19 @@ void main() { }); testWidgets('ListView can handle shrinking top elements with cache extent', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: [ - new Container(height: 400.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), - new Container(height: 400.0, child: const Text('4')), - new Container(height: 400.0, child: const Text('5')), - new Container(height: 400.0, child: const Text('6')), + Container(height: 400.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), + Container(height: 400.0, child: const Text('4')), + Container(height: 400.0, child: const Text('5')), + Container(height: 400.0, child: const Text('6')), ], ), ), @@ -90,17 +90,17 @@ void main() { expect(tester.getTopLeft(find.text('4')).dy, equals(200.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: [ - new Container(height: 200.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), - new Container(height: 400.0, child: const Text('4')), - new Container(height: 400.0, child: const Text('5')), - new Container(height: 400.0, child: const Text('6')), + Container(height: 200.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), + Container(height: 400.0, child: const Text('4')), + Container(height: 400.0, child: const Text('5')), + Container(height: 400.0, child: const Text('6')), ], ), ), @@ -123,17 +123,17 @@ void main() { }); testWidgets('ListView can handle inserts at 0', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: [ - new Container(height: 400.0, child: const Text('0')), - new Container(height: 400.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), + Container(height: 400.0, child: const Text('0')), + Container(height: 400.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), ], ), ), @@ -146,17 +146,17 @@ void main() { final Finder findItemA = find.descendant(of: find.byType(Container), matching: find.text('A')); final Finder findItemB = find.descendant(of: find.byType(Container), matching: find.text('B')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: [ - new Container(height: 10.0, child: const Text('A')), - new Container(height: 10.0, child: const Text('B')), - new Container(height: 400.0, child: const Text('0')), - new Container(height: 400.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), + Container(height: 10.0, child: const Text('A')), + Container(height: 10.0, child: const Text('B')), + Container(height: 400.0, child: const Text('0')), + Container(height: 400.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), ], ), ), @@ -175,17 +175,17 @@ void main() { expect(find.text('B'), findsNothing); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: [ - new Container(height: 200.0, child: const Text('A')), - new Container(height: 200.0, child: const Text('B')), - new Container(height: 400.0, child: const Text('0')), - new Container(height: 400.0, child: const Text('1')), - new Container(height: 400.0, child: const Text('2')), - new Container(height: 400.0, child: const Text('3')), + Container(height: 200.0, child: const Text('A')), + Container(height: 200.0, child: const Text('B')), + Container(height: 400.0, child: const Text('0')), + Container(height: 400.0, child: const Text('1')), + Container(height: 400.0, child: const Text('2')), + Container(height: 400.0, child: const Text('3')), ], ), ), diff --git a/packages/flutter/test/widgets/list_view_fling_test.dart b/packages/flutter/test/widgets/list_view_fling_test.dart index b56b571e57..9852b12e09 100644 --- a/packages/flutter/test/widgets/list_view_fling_test.dart +++ b/packages/flutter/test/widgets/list_view_fling_test.dart @@ -11,11 +11,11 @@ const double kFlingOffset = kHeight * 20.0; void main() { testWidgets('Flings don\'t stutter', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemBuilder: (BuildContext context, int index) { - return new Container(height: kHeight); + return Container(height: kHeight); }, ), ), diff --git a/packages/flutter/test/widgets/list_view_horizontal_test.dart b/packages/flutter/test/widgets/list_view_horizontal_test.dart index 7664543e53..8ed0474ff4 100644 --- a/packages/flutter/test/widgets/list_view_horizontal_test.dart +++ b/packages/flutter/test/widgets/list_view_horizontal_test.dart @@ -9,19 +9,19 @@ import 'package:flutter_test/flutter_test.dart'; const List items = [0, 1, 2, 3, 4, 5]; Widget buildFrame({ bool reverse = false, @required TextDirection textDirection }) { - return new Directionality( + return Directionality( textDirection: textDirection, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 50.0, - child: new ListView( + child: ListView( itemExtent: 290.0, scrollDirection: Axis.horizontal, reverse: reverse, physics: const BouncingScrollPhysics(), children: items.map((int item) { - return new Container( - child: new Text('$item') + return Container( + child: Text('$item') ); }).toList(), ), @@ -119,7 +119,7 @@ void main() { expect(find.text('4'), findsOneWidget); expect(find.text('5'), findsOneWidget); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); await tester.pumpWidget(buildFrame(textDirection: TextDirection.ltr), const Duration(seconds: 1)); await tester.drag(find.text('2'), const Offset(-280.0, 0.0)); await tester.pump(const Duration(seconds: 1)); @@ -438,7 +438,7 @@ void main() { expect(find.text('4'), findsOneWidget); expect(find.text('5'), findsOneWidget); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); await tester.pumpWidget(buildFrame(reverse: true, textDirection: TextDirection.rtl), const Duration(seconds: 1)); await tester.drag(find.text('2'), const Offset(-280.0, 0.0)); await tester.pump(const Duration(seconds: 1)); diff --git a/packages/flutter/test/widgets/list_view_misc_test.dart b/packages/flutter/test/widgets/list_view_misc_test.dart index 3357bd925f..d2755946f7 100644 --- a/packages/flutter/test/widgets/list_view_misc_test.dart +++ b/packages/flutter/test/widgets/list_view_misc_test.dart @@ -11,12 +11,12 @@ const Key blockKey = Key('test'); void main() { testWidgets('Cannot scroll a non-overflowing block', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( key: blockKey, children: [ - new Container( + Container( height: 200.0, // less than 600, the height of the test area child: const Text('Hello'), ), @@ -39,12 +39,12 @@ void main() { testWidgets('Can scroll an overflowing block', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( key: blockKey, children: [ - new Container( + Container( height: 2000.0, // more than 600, the height of the test area child: const Text('Hello'), ), @@ -73,22 +73,22 @@ void main() { int second = 0; Widget buildBlock({ bool reverse = false }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView( - key: new UniqueKey(), + child: ListView( + key: UniqueKey(), reverse: reverse, children: [ - new GestureDetector( + GestureDetector( onTap: () { first += 1; }, - child: new Container( + child: Container( height: 350.0, // more than half the height of the test area color: const Color(0xFF00FF00), ) ), - new GestureDetector( + GestureDetector( onTap: () { second += 1; }, - child: new Container( + child: Container( height: 350.0, // more than half the height of the test area color: const Color(0xFF0000FF), ), @@ -113,12 +113,12 @@ void main() { }); testWidgets('ListView controller', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); Widget buildBlock() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: const [Text('A'), Text('B'), Text('C')], ), @@ -129,20 +129,20 @@ void main() { }); testWidgets('SliverBlockChildListDelegate.estimateMaxScrollOffset hits end', (WidgetTester tester) async { - final SliverChildListDelegate delegate = new SliverChildListDelegate([ - new Container(), - new Container(), - new Container(), - new Container(), - new Container(), + final SliverChildListDelegate delegate = SliverChildListDelegate([ + Container(), + Container(), + Container(), + Container(), + Container(), ]); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new SliverList( + SliverList( delegate: delegate, ), ], @@ -164,20 +164,20 @@ void main() { testWidgets('Resizing a ListView child restores scroll offset', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/9221 - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( vsync: const TestVSync(), duration: const Duration(milliseconds: 200), ); // The overall height of the frame is (as ever) 600 Widget buildFrame() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new Flexible( + Flexible( // The overall height of the ListView's contents is 500 - child: new ListView( + child: ListView( children: const [ SizedBox( height: 150.0, @@ -201,7 +201,7 @@ void main() { ), ), // If this widget's height is > 100 the ListView can scroll. - new SizeTransition( + SizeTransition( sizeFactor: controller.view, child: const SizedBox( height: 300.0, diff --git a/packages/flutter/test/widgets/list_view_relayout_test.dart b/packages/flutter/test/widgets/list_view_relayout_test.dart index 2c1be09cec..d56b385393 100644 --- a/packages/flutter/test/widgets/list_view_relayout_test.dart +++ b/packages/flutter/test/widgets/list_view_relayout_test.dart @@ -9,12 +9,12 @@ import 'package:flutter/rendering.dart'; void main() { testWidgets('Nested ListView with shrinkWrap', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( shrinkWrap: true, children: [ - new ListView( + ListView( shrinkWrap: true, children: const [ Text('1'), @@ -22,7 +22,7 @@ void main() { Text('3'), ], ), - new ListView( + ListView( shrinkWrap: true, children: const [ Text('4'), @@ -40,9 +40,9 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/5950 await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 100.0, child: Text('100')), ], @@ -51,9 +51,9 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 100.0, child: Text('100')), SizedBox(height: 200.0, child: Text('200')), @@ -67,9 +67,9 @@ void main() { testWidgets('Underflowing ListView contentExtent should track additional children', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 100.0, child: Text('100')), ], @@ -81,9 +81,9 @@ void main() { expect(list.geometry.scrollExtent, equals(100.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 100.0, child: Text('100')), SizedBox(height: 200.0, child: Text('200')), @@ -94,9 +94,9 @@ void main() { expect(list.geometry.scrollExtent, equals(300.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [] ), ), @@ -106,9 +106,9 @@ void main() { testWidgets('Overflowing ListView should relayout for missing children', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 300.0, child: Text('300')), SizedBox(height: 400.0, child: Text('400')), @@ -121,9 +121,9 @@ void main() { expect(find.text('400'), findsOneWidget); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 300.0, child: Text('300')), ], @@ -135,9 +135,9 @@ void main() { expect(find.text('400'), findsNothing); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [] ), ), @@ -149,9 +149,9 @@ void main() { testWidgets('Overflowing ListView should not relayout for additional children', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 300.0, child: Text('300')), SizedBox(height: 400.0, child: Text('400')), @@ -164,9 +164,9 @@ void main() { expect(find.text('400'), findsOneWidget); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 300.0, child: Text('300')), SizedBox(height: 400.0, child: Text('400')), @@ -188,9 +188,9 @@ void main() { // be enabled. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 100.0, child: Text('100')), ], @@ -202,9 +202,9 @@ void main() { expect(scrollable.position.maxScrollExtent, 0.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: const [ SizedBox(height: 100.0, child: Text('100')), SizedBox(height: 200.0, child: Text('200')), diff --git a/packages/flutter/test/widgets/list_view_test.dart b/packages/flutter/test/widgets/list_view_test.dart index 965483e15e..8bca4d0dae 100644 --- a/packages/flutter/test/widgets/list_view_test.dart +++ b/packages/flutter/test/widgets/list_view_test.dart @@ -24,7 +24,7 @@ class Alive extends StatefulWidget { final int index; @override - AliveState createState() => new AliveState(); + AliveState createState() => AliveState(); @override String toString({DiagnosticLevel minLevel}) => '$index $alive'; @@ -36,7 +36,7 @@ class AliveState extends State with AutomaticKeepAliveClientMixin { @override Widget build(BuildContext context) => - new Text('${widget.index}:$wantKeepAlive'); + Text('${widget.index}:$wantKeepAlive'); } typedef WhetherToKeepAlive = bool Function(int); @@ -45,24 +45,24 @@ class _StatefulListView extends StatefulWidget { final WhetherToKeepAlive aliveCallback; @override - _StatefulListViewState createState() => new _StatefulListViewState(); + _StatefulListViewState createState() => _StatefulListViewState(); } class _StatefulListViewState extends State<_StatefulListView> { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( // force a rebuild - the test(s) using this are verifying that the list is // still correct after rebuild onTap: () => setState, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new ListView( - children: new List.generate(200, (int i) { - return new Builder( + child: ListView( + children: List.generate(200, (int i) { + return Builder( builder: (BuildContext context) { - return new Container( - child: new Alive(widget.aliveCallback(i), i), + return Container( + child: Alive(widget.aliveCallback(i), i), ); }, ); @@ -76,10 +76,10 @@ class _StatefulListViewState extends State<_StatefulListView> { void main() { testWidgets('ListView default control', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new ListView(itemExtent: 100.0), + child: Center( + child: ListView(itemExtent: 100.0), ), ), ); @@ -87,13 +87,13 @@ void main() { testWidgets('ListView itemExtent control test', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 200.0, - children: new List.generate(20, (int i) { - return new Container( - child: new Text('$i'), + children: List.generate(20, (int i) { + return Container( + child: Text('$i'), ); }), ), @@ -135,16 +135,16 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 200.0, - children: new List.generate(20, (int i) { - return new Builder( + children: List.generate(20, (int i) { + return Builder( builder: (BuildContext context) { log.add(i); - return new Container( - child: new Text('$i'), + return Container( + child: Text('$i'), ); }, ); @@ -205,18 +205,18 @@ void main() { expect(find.text('3:true'), findsOneWidget); } - await tester.pumpWidget(new _StatefulListView((int i) => i > 2 && i % 3 == 0)); + await tester.pumpWidget(_StatefulListView((int i) => i > 2 && i % 3 == 0)); await checkAndScroll(); - await tester.pumpWidget(new _StatefulListView((int i) => i % 3 == 0)); + await tester.pumpWidget(_StatefulListView((int i) => i % 3 == 0)); await checkAndScroll('0:true'); }); testWidgets('ListView can build out of underflow', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 100.0, ), ), @@ -230,13 +230,13 @@ void main() { expect(find.text('5'), findsNothing); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 100.0, - children: new List.generate(2, (int i) { - return new Container( - child: new Text('$i'), + children: List.generate(2, (int i) { + return Container( + child: Text('$i'), ); }), ), @@ -251,13 +251,13 @@ void main() { expect(find.text('5'), findsNothing); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 100.0, - children: new List.generate(5, (int i) { - return new Container( - child: new Text('$i'), + children: List.generate(5, (int i) { + return Container( + child: Text('$i'), ); }), ), @@ -274,13 +274,13 @@ void main() { testWidgets('ListView can build out of overflow padding', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 0.0, height: 0.0, - child: new ListView( + child: ListView( padding: const EdgeInsets.all(8.0), children: const [ Text('padded', textDirection: TextDirection.ltr), @@ -295,15 +295,15 @@ void main() { testWidgets('ListView with itemExtent in unbounded context', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SingleChildScrollView( - child: new ListView( + child: SingleChildScrollView( + child: ListView( itemExtent: 100.0, shrinkWrap: true, - children: new List.generate(20, (int i) { - return new Container( - child: new Text('$i'), + children: List.generate(20, (int i) { + return Container( + child: Text('$i'), ); }), ), @@ -316,21 +316,21 @@ void main() { }); testWidgets('didFinishLayout has correct indices', (WidgetTester tester) async { - final TestSliverChildListDelegate delegate = new TestSliverChildListDelegate( - new List.generate( + final TestSliverChildListDelegate delegate = TestSliverChildListDelegate( + List.generate( 20, (int i) { - return new Container( - child: new Text('$i', textDirection: TextDirection.ltr), + return Container( + child: Text('$i', textDirection: TextDirection.ltr), ); }, ) ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView.custom( + child: ListView.custom( itemExtent: 110.0, childrenDelegate: delegate, ), @@ -341,9 +341,9 @@ void main() { delegate.log.clear(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView.custom( + child: ListView.custom( itemExtent: 210.0, childrenDelegate: delegate, ), @@ -367,18 +367,18 @@ void main() { EdgeInsets innerMediaQueryPadding; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData( padding: EdgeInsets.all(30.0), ), - child: new ListView( + child: ListView( children: [ const Text('top', textDirection: TextDirection.ltr), - new Builder(builder: (BuildContext context) { + Builder(builder: (BuildContext context) { innerMediaQueryPadding = MediaQuery.of(context).padding; - return new Container(); + return Container(); }), ], ), @@ -395,21 +395,21 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/17426. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 200.0, - child: new ListView( + child: ListView( cacheExtent: 500.0, children: [ - new Container( + Container( height: 90.0, ), - new Container( + Container( height: 110.0, ), - new Container( + Container( height: 80.0, ), ], @@ -424,15 +424,15 @@ void main() { testWidgets('ListView does not clips if no overflow', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 200.0, - child: new ListView( + child: ListView( cacheExtent: 500.0, children: [ - new Container( + Container( height: 100.0, ), ], @@ -449,22 +449,22 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/17426. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 200.0, - child: new ListView( + child: ListView( itemExtent: 100.0, cacheExtent: 500.0, children: [ - new Container( + Container( height: 100.0, ), - new Container( + Container( height: 100.0, ), - new Container( + Container( height: 100.0, ), ], @@ -479,16 +479,16 @@ void main() { testWidgets('ListView (fixed extent) does not clips if no overflow', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 200.0, - child: new ListView( + child: ListView( itemExtent: 100.0, cacheExtent: 500.0, children: [ - new Container( + Container( height: 100.0, ), ], diff --git a/packages/flutter/test/widgets/list_view_vertical_test.dart b/packages/flutter/test/widgets/list_view_vertical_test.dart index 88349be95c..ebc3fe298d 100644 --- a/packages/flutter/test/widgets/list_view_vertical_test.dart +++ b/packages/flutter/test/widgets/list_view_vertical_test.dart @@ -8,14 +8,14 @@ import 'package:flutter/widgets.dart'; const List items = [0, 1, 2, 3, 4, 5]; Widget buildFrame() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 290.0, scrollDirection: Axis.vertical, children: items.map((int item) { - return new Container( - child: new Text('$item') + return Container( + child: Text('$item') ); }).toList(), ), @@ -68,15 +68,15 @@ void main() { testWidgets('Drag vertically', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 290.0, padding: const EdgeInsets.only(top: 250.0), scrollDirection: Axis.vertical, children: items.map((int item) { - return new Container( - child: new Text('$item') + return Container( + child: Text('$item') ); }).toList(), ), diff --git a/packages/flutter/test/widgets/list_view_viewporting_test.dart b/packages/flutter/test/widgets/list_view_viewporting_test.dart index f0be9b60d7..9da426326b 100644 --- a/packages/flutter/test/widgets/list_view_viewporting_test.dart +++ b/packages/flutter/test/widgets/list_view_viewporting_test.dart @@ -18,16 +18,16 @@ void main() { // so if our widget is 100 pixels tall, it should fit exactly 6 times. Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView.builder( + child: FlipWidget( + left: ListView.builder( itemBuilder: (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), height: 100.0, - child: new Text('$index'), + child: Text('$index'), ); }, ), @@ -70,20 +70,20 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), width: 500.0, // this should be ignored height: 200.0, - child: new Text('$index', textDirection: TextDirection.ltr), + child: Text('$index', textDirection: TextDirection.ltr), ); }; Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView.builder( - controller: new ScrollController(initialScrollOffset: 300.0), + child: FlipWidget( + left: ListView.builder( + controller: ScrollController(initialScrollOffset: 300.0), itemBuilder: itemBuilder, ), right: const Text('Not Today'), @@ -134,21 +134,21 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), height: 500.0, // this should be ignored width: 200.0, - child: new Text('$index', textDirection: TextDirection.ltr), + child: Text('$index', textDirection: TextDirection.ltr), ); }; Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView.builder( + child: FlipWidget( + left: ListView.builder( scrollDirection: Axis.horizontal, - controller: new ScrollController(initialScrollOffset: 500.0), + controller: ScrollController(initialScrollOffset: 500.0), itemBuilder: itemBuilder, ), right: const Text('Not Today'), @@ -185,11 +185,11 @@ void main() { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { callbackTracker.add(index); - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), width: 500.0, // this should be ignored height: 220.0, - child: new Text('$index', textDirection: TextDirection.ltr) + child: Text('$index', textDirection: TextDirection.ltr) ); }; @@ -199,9 +199,9 @@ void main() { } Widget builder() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemBuilder: itemBuilder, ), ); @@ -232,29 +232,29 @@ void main() { testWidgets('ListView reinvoke builders', (WidgetTester tester) async { StateSetter setState; - ThemeData themeData = new ThemeData.light(); + ThemeData themeData = ThemeData.light(); final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), width: 500.0, // this should be ignored height: 220.0, color: Theme.of(context).primaryColor, - child: new Text('$index', textDirection: TextDirection.ltr), + child: Text('$index', textDirection: TextDirection.ltr), ); }; - final Widget viewport = new ListView.builder( + final Widget viewport = ListView.builder( itemBuilder: itemBuilder, ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new StatefulBuilder( + child: StatefulBuilder( builder: (BuildContext context, StateSetter setter) { setState = setter; - return new Theme(data: themeData, child: viewport); + return Theme(data: themeData, child: viewport); }, ), ), @@ -265,7 +265,7 @@ void main() { expect(decoration.color, equals(Colors.blue)); setState(() { - themeData = new ThemeData(primarySwatch: Colors.green); + themeData = ThemeData(primarySwatch: Colors.green); }); await tester.pump(); @@ -277,19 +277,19 @@ void main() { testWidgets('ListView padding', (WidgetTester tester) async { final IndexedWidgetBuilder itemBuilder = (BuildContext context, int index) { - return new Container( - key: new ValueKey(index), + return Container( + key: ValueKey(index), width: 500.0, // this should be ignored height: 220.0, color: Colors.green[500], - child: new Text('$index', textDirection: TextDirection.ltr), + child: Text('$index', textDirection: TextDirection.ltr), ); }; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( padding: const EdgeInsets.fromLTRB(7.0, 3.0, 5.0, 11.0), itemBuilder: itemBuilder, ), @@ -304,14 +304,14 @@ void main() { testWidgets('ListView underflow extents', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( addAutomaticKeepAlives: false, children: [ - new Container(height: 100.0), - new Container(height: 100.0), - new Container(height: 100.0), + Container(height: 100.0), + Container(height: 100.0), + Container(height: 100.0), ], ), ), @@ -435,21 +435,21 @@ void main() { testWidgets('ListView should not paint hidden children', (WidgetTester tester) async { const Text text = Text('test'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 200.0, - child: new ListView( + child: ListView( cacheExtent: 500.0, - controller: new ScrollController(initialScrollOffset: 300.0), + controller: ScrollController(initialScrollOffset: 300.0), children: [ - new Container(height: 140.0, child: text), - new Container(height: 160.0, child: text), - new Container(height: 90.0, child: text), - new Container(height: 110.0, child: text), - new Container(height: 80.0, child: text), - new Container(height: 70.0, child: text), + Container(height: 140.0, child: text), + Container(height: 160.0, child: text), + Container(height: 90.0, child: text), + Container(height: 110.0, child: text), + Container(height: 80.0, child: text), + Container(height: 70.0, child: text), ], ) ), @@ -463,21 +463,21 @@ void main() { testWidgets('ListView should paint with offset', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Container( + MaterialApp( + home: Scaffold( + body: Container( height: 500.0, - child: new CustomScrollView( - controller: new ScrollController(initialScrollOffset: 120.0), + child: CustomScrollView( + controller: ScrollController(initialScrollOffset: 120.0), slivers: [ const SliverAppBar( expandedHeight: 250.0, ), - new SliverList( - delegate: new ListView.builder( + SliverList( + delegate: ListView.builder( itemExtent: 100.0, itemCount: 100, - itemBuilder: (_, __) => new Container( + itemBuilder: (_, __) => Container( height: 40.0, child: const Text('hey'), )).childrenDelegate), @@ -494,17 +494,17 @@ void main() { testWidgets('ListView should paint with rtl', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Container( + child: Container( height: 200.0, - child: new ListView.builder( + child: ListView.builder( padding: const EdgeInsets.symmetric( horizontal: 0.0, vertical: 0.0), scrollDirection: Axis.horizontal, itemExtent: 200.0, itemCount: 10, - itemBuilder: (_, int i) => new Container( + itemBuilder: (_, int i) => Container( height: 200.0, width: 200.0, color: i % 2 == 0 ? Colors.black : Colors.red, diff --git a/packages/flutter/test/widgets/list_view_with_inherited_test.dart b/packages/flutter/test/widgets/list_view_with_inherited_test.dart index 71d5936b63..e699aa2e41 100644 --- a/packages/flutter/test/widgets/list_view_with_inherited_test.dart +++ b/packages/flutter/test/widgets/list_view_with_inherited_test.dart @@ -10,20 +10,20 @@ List items = [0, 1, 2, 3, 4, 5]; Widget buildCard(BuildContext context, int index) { if (index >= items.length) return null; - return new Container( - key: new ValueKey(items[index]), + return Container( + key: ValueKey(items[index]), height: 100.0, - child: new DefaultTextStyle( - style: new TextStyle(fontSize: 2.0 + items.length.toDouble()), - child: new Text('${items[index]}', textDirection: TextDirection.ltr) + child: DefaultTextStyle( + style: TextStyle(fontSize: 2.0 + items.length.toDouble()), + child: Text('${items[index]}', textDirection: TextDirection.ltr) ) ); } Widget buildFrame() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemBuilder: buildCard, ), ); diff --git a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart index 69174eb622..6177e51e8a 100644 --- a/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart +++ b/packages/flutter/test/widgets/list_wheel_scroll_view_test.dart @@ -16,7 +16,7 @@ void main() { group('construction check', () { testWidgets('ListWheelScrollView needs positive diameter ratio', (WidgetTester tester) async { try { - new ListWheelScrollView( + ListWheelScrollView( diameterRatio: nonconst(-2.0), itemExtent: 20.0, children: const [], @@ -30,9 +30,9 @@ void main() { testWidgets('ListWheelScrollView needs positive item extent', (WidgetTester tester) async { expect( () { - new ListWheelScrollView( + ListWheelScrollView( itemExtent: null, - children: [new Container()], + children: [Container()], ); }, throwsAssertionError, @@ -56,11 +56,11 @@ void main() { testWidgets('ListWheelScrollView needs positive magnification', (WidgetTester tester) async { expect( () { - new ListWheelScrollView( + ListWheelScrollView( useMagnifier: true, magnification: -1.0, itemExtent: 20.0, - children: [new Container()], + children: [Container()], ); }, throwsAssertionError, @@ -71,18 +71,18 @@ void main() { group('infinite scrolling', () { testWidgets('infinite looping list', (WidgetTester tester) async { final FixedExtentScrollController controller = - new FixedExtentScrollController(); + FixedExtentScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView.useDelegate( + child: ListWheelScrollView.useDelegate( controller: controller, itemExtent: 100.0, onSelectedItemChanged: (_) {}, - childDelegate: new ListWheelChildLoopingListDelegate( + childDelegate: ListWheelChildLoopingListDelegate( children: List.generate(10, (int index) { - return new Container( + return Container( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -117,18 +117,18 @@ void main() { testWidgets('infinite child builder', (WidgetTester tester) async { final FixedExtentScrollController controller = - new FixedExtentScrollController(); + FixedExtentScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView.useDelegate( + child: ListWheelScrollView.useDelegate( controller: controller, itemExtent: 100.0, onSelectedItemChanged: (_) {}, - childDelegate: new ListWheelChildBuilderDelegate( + childDelegate: ListWheelChildBuilderDelegate( builder: (BuildContext context, int index) { - return new Container( + return Container( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -160,24 +160,24 @@ void main() { final List paintedChildren = []; final FixedExtentScrollController controller = - new FixedExtentScrollController(initialItem: -10); + FixedExtentScrollController(initialItem: -10); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView.useDelegate( + child: ListWheelScrollView.useDelegate( controller: controller, itemExtent: 100.0, onSelectedItemChanged: (_) {}, - childDelegate: new ListWheelChildBuilderDelegate( + childDelegate: ListWheelChildBuilderDelegate( builder: (BuildContext context, int index) { if (index < -15 || index > -5) return null; - return new Container( + return Container( width: 400.0, height: 100.0, - child: new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + child: CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ), @@ -214,13 +214,13 @@ void main() { group('layout', () { testWidgets("ListWheelScrollView takes parent's size with small children", (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( // Inner children smaller than the outer window. itemExtent: 50.0, children: [ - new Container( + Container( height: 50.0, color: const Color(0xFFFFFFFF), ), @@ -235,13 +235,13 @@ void main() { testWidgets("ListWheelScrollView takes parent's size with large children", (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( // Inner children 5000.0px. itemExtent: 50.0, - children: new List.generate(100, (int index) { - return new Container( + children: List.generate(100, (int index) { + return Container( height: 50.0, color: const Color(0xFFFFFFFF), ); @@ -279,21 +279,21 @@ void main() { testWidgets('builder is never called twice for same index', (WidgetTester tester) async { final Set builtChildren = Set(); final FixedExtentScrollController controller = - new FixedExtentScrollController(); + FixedExtentScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView.useDelegate( + child: ListWheelScrollView.useDelegate( controller: controller, itemExtent: 100.0, onSelectedItemChanged: (_) {}, - childDelegate: new ListWheelChildBuilderDelegate( + childDelegate: ListWheelChildBuilderDelegate( builder: (BuildContext context, int index) { expect(builtChildren.contains(index), false); builtChildren.add(index); - return new Container( + return Container( width: 400.0, height: 100.0, child: Text(index.toString()), @@ -315,17 +315,17 @@ void main() { testWidgets('only visible children are maintained as children of the rendered viewport', (WidgetTester tester) async { final FixedExtentScrollController controller = - new FixedExtentScrollController(); + FixedExtentScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, onSelectedItemChanged: (_) {}, children: List.generate(16, (int index) { - return new Text(index.toString()); + return Text(index.toString()); }), ), ) @@ -353,18 +353,18 @@ void main() { group('pre-transform viewport', () { testWidgets('ListWheelScrollView starts and ends from the middle', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); final List paintedChildren = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: new List.generate(100, (int index) { - return new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + children: List.generate(100, (int index) { + return CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ); @@ -395,18 +395,18 @@ void main() { }); testWidgets('A child gets painted as soon as its first pixel is in the viewport', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(initialScrollOffset: 50.0); + final ScrollController controller = ScrollController(initialScrollOffset: 50.0); final List paintedChildren = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: new List.generate(10, (int index) { - return new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + children: List.generate(10, (int index) { + return CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ); @@ -429,18 +429,18 @@ void main() { }); testWidgets('A child is no longer painted after its last pixel leaves the viewport', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(initialScrollOffset: 250.0); + final ScrollController controller = ScrollController(initialScrollOffset: 250.0); final List paintedChildren = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: new List.generate(10, (int index) { - return new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + children: List.generate(10, (int index) { + return CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ); @@ -474,11 +474,11 @@ void main() { group('viewport transformation', () { testWidgets('Center child is magnified', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new RepaintBoundary( + child: RepaintBoundary( key: const Key('list_wheel_scroll_view'), - child: new ListWheelScrollView( + child: ListWheelScrollView( useMagnifier: true, magnification: 2.0, itemExtent: 50.0, @@ -499,12 +499,12 @@ void main() { testWidgets('Default middle transform', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( itemExtent: 100.0, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -527,13 +527,13 @@ void main() { }); testWidgets('Curve the wheel to the left', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(initialScrollOffset: 300.0); + final ScrollController controller = ScrollController(initialScrollOffset: 300.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new RepaintBoundary( + child: RepaintBoundary( key: const Key('list_wheel_scroll_view'), - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, offAxisFraction: 0.5, itemExtent: 50.0, @@ -553,16 +553,16 @@ void main() { }); testWidgets('Scrolling, diameterRatio, perspective all changes matrix', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(initialScrollOffset: 200.0); + final ScrollController controller = ScrollController(initialScrollOffset: 200.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -585,14 +585,14 @@ void main() { // Increase diameter. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, diameterRatio: 3.0, itemExtent: 100.0, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -614,14 +614,14 @@ void main() { // Decrease perspective. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, perspective: 0.0001, itemExtent: 100.0, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -644,13 +644,13 @@ void main() { // Scroll a bit. controller.jumpTo(300.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -672,18 +672,18 @@ void main() { }); testWidgets('offAxisFraction, magnification changes matrix', (WidgetTester tester) async { - final ScrollController controller = new ScrollController( + final ScrollController controller = ScrollController( initialScrollOffset: 200.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, offAxisFraction: 0.5, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -720,16 +720,16 @@ void main() { controller.jumpTo(0.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, offAxisFraction: 0.5, useMagnifier: true, magnification: 1.5, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -771,13 +771,13 @@ void main() { final ValueChanged onItemChange = (_) { itemChangeCalled = true; }; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( itemExtent: 100.0, onSelectedItemChanged: onItemChange, children: [ - new Container( + Container( width: 200.0, child: const Center( child: Text('blah'), @@ -795,12 +795,12 @@ void main() { final List selectedItems = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, - children: new List.generate(10, (int index) { + children: List.generate(10, (int index) { return const Placeholder(); }), ), @@ -832,13 +832,13 @@ void main() { final List selectedItems = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, // So item 0 is at 0 and item 9 is at 900 in the scrollable range. - children: new List.generate(10, (int index) { + children: List.generate(10, (int index) { return const Placeholder(); }), ), @@ -853,7 +853,7 @@ void main() { for (double verticalOffset = 0.0; verticalOffset > -2000.0; verticalOffset -= 10.0) { // Then gradually move down by a total vertical extent much higher than // the scrollable extent. - await scrollGesture.moveTo(new Offset(0.0, verticalOffset)); + await scrollGesture.moveTo(Offset(0.0, verticalOffset)); } // The list should only cover the list of valid items. Item 0 would not @@ -865,18 +865,18 @@ void main() { group('scroll controller', () { testWidgets('initialItem', (WidgetTester tester) async { - final FixedExtentScrollController controller = new FixedExtentScrollController(initialItem: 10); + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); final List paintedChildren = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: new List.generate(100, (int index) { - return new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + children: List.generate(100, (int index) { + return CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ); @@ -891,18 +891,18 @@ void main() { }); testWidgets('controller jump', (WidgetTester tester) async { - final FixedExtentScrollController controller = new FixedExtentScrollController(initialItem: 10); + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); final List paintedChildren = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: new List.generate(100, (int index) { - return new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + children: List.generate(100, (int index) { + return CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ); @@ -923,18 +923,18 @@ void main() { }); testWidgets('controller animateToItem', (WidgetTester tester) async { - final FixedExtentScrollController controller = new FixedExtentScrollController(initialItem: 10); + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); final List paintedChildren = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, - children: new List.generate(100, (int index) { - return new CustomPaint( - painter: new TestCallbackPainter(onPaint: () { + children: List.generate(100, (int index) { + return CustomPaint( + painter: TestCallbackPainter(onPaint: () { paintedChildren.add(index); }), ); @@ -961,16 +961,16 @@ void main() { testWidgets('onSelectedItemChanged and controller are in sync', (WidgetTester tester) async { final List selectedItems = []; - final FixedExtentScrollController controller = new FixedExtentScrollController(initialItem: 10); + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 10); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, itemExtent: 100.0, onSelectedItemChanged: (int index) { selectedItems.add(index); }, - children: new List.generate(100, (int index) { + children: List.generate(100, (int index) { return const Placeholder(); }), ), @@ -996,11 +996,11 @@ void main() { testWidgets('controller hot swappable', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( itemExtent: 100.0, - children: new List.generate(100, (int index) { + children: List.generate(100, (int index) { return const Placeholder(); }), ), @@ -1012,15 +1012,15 @@ void main() { await tester.pump(); final FixedExtentScrollController newController = - new FixedExtentScrollController(initialItem: 30); + FixedExtentScrollController(initialItem: 30); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: newController, itemExtent: 100.0, - children: new List.generate(100, (int index) { + children: List.generate(100, (int index) { return const Placeholder(); }), ), @@ -1037,11 +1037,11 @@ void main() { // Now remove the controller await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListWheelScrollView( + child: ListWheelScrollView( itemExtent: 100.0, - children: new List.generate(100, (int index) { + children: List.generate(100, (int index) { return const Placeholder(); }), ), @@ -1056,23 +1056,23 @@ void main() { group('physics', () { testWidgets('fling velocities too low snaps back to the same item', (WidgetTester tester) async { - final FixedExtentScrollController controller = new FixedExtentScrollController(initialItem: 40); + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 40); final List scrolledPositions = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (ScrollNotification notification) { if (notification is ScrollUpdateNotification) scrolledPositions.add(notification.metrics.pixels); return false; }, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, physics: const FixedExtentScrollPhysics(), itemExtent: 1000.0, - children: new List.generate(100, (int index) { + children: List.generate(100, (int index) { return const Placeholder(); }), ), @@ -1107,23 +1107,23 @@ void main() { testWidgets('high fling velocities lands exactly on items', (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final FixedExtentScrollController controller = new FixedExtentScrollController(initialItem: 40); + final FixedExtentScrollController controller = FixedExtentScrollController(initialItem: 40); final List scrolledPositions = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (ScrollNotification notification) { if (notification is ScrollUpdateNotification) scrolledPositions.add(notification.metrics.pixels); return false; }, - child: new ListWheelScrollView( + child: ListWheelScrollView( controller: controller, physics: const FixedExtentScrollPhysics(), itemExtent: 100.0, - children: new List.generate(100, (int index) { + children: List.generate(100, (int index) { return const Placeholder(); }), ), @@ -1161,25 +1161,25 @@ void main() { testWidgets('ListWheelScrollView getOffsetToReveal', (WidgetTester tester) async { List outerChildren; - final List innerChildren = new List(10); + final List innerChildren = List(10); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 500.0, width: 300.0, - child: new ListWheelScrollView( - controller: new ScrollController(initialScrollOffset: 300.0), + child: ListWheelScrollView( + controller: ScrollController(initialScrollOffset: 300.0), itemExtent: 100.0, - children: outerChildren = new List.generate(10, (int i) { - return new Container( - child: new Center( - child: innerChildren[i] = new Container( + children: outerChildren = List.generate(10, (int i) { + return Container( + child: Center( + child: innerChildren[i] = Container( height: 50.0, width: 50.0, - child: new Text('Item $i'), + child: Text('Item $i'), ), ), ); @@ -1196,62 +1196,62 @@ void main() { RenderObject target = tester.renderObject(find.byWidget(outerChildren[5])); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 200.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 200.0, 300.0, 100.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 200.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 200.0, 300.0, 100.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 240.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 240.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 240.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 240.0, 10.0, 10.0)); // descendant of viewport, not direct child target = tester.renderObject(find.byWidget(innerChildren[5])); revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(125.0, 225.0, 50.0, 50.0)); + expect(revealed.rect, Rect.fromLTWH(125.0, 225.0, 50.0, 50.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(125.0, 225.0, 50.0, 50.0)); + expect(revealed.rect, Rect.fromLTWH(125.0, 225.0, 50.0, 50.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(165.0, 265.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(165.0, 265.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(165.0, 265.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(165.0, 265.0, 10.0, 10.0)); }); testWidgets('ListWheelScrollView showOnScreen', (WidgetTester tester) async { List outerChildren; - final List innerChildren = new List(10); + final List innerChildren = List(10); ScrollController controller; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 500.0, width: 300.0, - child: new ListWheelScrollView( - controller: controller = new ScrollController(initialScrollOffset: 300.0), + child: ListWheelScrollView( + controller: controller = ScrollController(initialScrollOffset: 300.0), itemExtent: 100.0, children: - outerChildren = new List.generate(10, (int i) { - return new Container( - child: new Center( - child: innerChildren[i] = new Container( + outerChildren = List.generate(10, (int i) { + return Container( + child: Center( + child: innerChildren[i] = Container( height: 50.0, width: 50.0, - child: new Text('Item $i'), + child: Text('Item $i'), ), ), ); diff --git a/packages/flutter/test/widgets/listener_test.dart b/packages/flutter/test/widgets/listener_test.dart index 16c7c7dc96..49a2afffe6 100644 --- a/packages/flutter/test/widgets/listener_test.dart +++ b/packages/flutter/test/widgets/listener_test.dart @@ -10,17 +10,17 @@ void main() { final List log = []; await tester.pumpWidget( - new Listener( + Listener( onPointerDown: (_) { log.add('top'); }, - child: new Listener( + child: Listener( onPointerDown: (_) { log.add('middle'); }, - child: new DecoratedBox( + child: DecoratedBox( decoration: const BoxDecoration(), - child: new Listener( + child: Listener( onPointerDown: (_) { log.add('bottom'); }, diff --git a/packages/flutter/test/widgets/listview_end_append_test.dart b/packages/flutter/test/widgets/listview_end_append_test.dart index b2ecbfbf59..0f9f1f4bee 100644 --- a/packages/flutter/test/widgets/listview_end_append_test.dart +++ b/packages/flutter/test/widgets/listview_end_append_test.dart @@ -10,12 +10,12 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/9506 Widget buildFrame(int itemCount) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemExtent: 200.0, itemCount: itemCount, - itemBuilder: (BuildContext context, int index) => new Text('item $index'), + itemBuilder: (BuildContext context, int index) => Text('item $index'), ), ); } @@ -37,14 +37,14 @@ void main() { // Regression test for https://github.com/flutter/flutter/issues/9506 Widget buildFrame(int itemCount) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemCount: itemCount, itemBuilder: (BuildContext context, int index) { - return new SizedBox( + return SizedBox( height: 200.0, - child: new Text('item $index'), + child: Text('item $index'), ); }, ), diff --git a/packages/flutter/test/widgets/media_query_test.dart b/packages/flutter/test/widgets/media_query_test.dart index 1cd63a888a..ca9f98a78b 100644 --- a/packages/flutter/test/widgets/media_query_test.dart +++ b/packages/flutter/test/widgets/media_query_test.dart @@ -11,11 +11,11 @@ void main() { testWidgets('MediaQuery does not have a default', (WidgetTester tester) async { bool tested = false; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { tested = true; MediaQuery.of(context); // should throw - return new Container(); + return Container(); } ) ); @@ -26,12 +26,12 @@ void main() { testWidgets('MediaQuery defaults to null', (WidgetTester tester) async { bool tested = false; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { final MediaQueryData data = MediaQuery.of(context, nullOk: true); expect(data, isNull); tested = true; - return new Container(); + return Container(); } ) ); @@ -39,7 +39,7 @@ void main() { }); testWidgets('MediaQueryData is sane', (WidgetTester tester) async { - final MediaQueryData data = new MediaQueryData.fromWindow(ui.window); + final MediaQueryData data = MediaQueryData.fromWindow(ui.window); expect(data, hasOneLineDescription); expect(data.hashCode, equals(data.copyWith().hashCode)); expect(data.size, equals(ui.window.physicalSize / ui.window.devicePixelRatio)); @@ -50,7 +50,7 @@ void main() { }); testWidgets('MediaQueryData.copyWith defaults to source', (WidgetTester tester) async { - final MediaQueryData data = new MediaQueryData.fromWindow(ui.window); + final MediaQueryData data = MediaQueryData.fromWindow(ui.window); final MediaQueryData copied = data.copyWith(); expect(copied.size, data.size); expect(copied.devicePixelRatio, data.devicePixelRatio); @@ -65,7 +65,7 @@ void main() { }); testWidgets('MediaQuery.copyWith copies specified values', (WidgetTester tester) async { - final MediaQueryData data = new MediaQueryData.fromWindow(ui.window); + final MediaQueryData data = MediaQueryData.fromWindow(ui.window); final MediaQueryData copied = data.copyWith( size: const Size(3.14, 2.72), devicePixelRatio: 1.41, @@ -99,7 +99,7 @@ void main() { MediaQueryData unpadded; await tester.pumpWidget( - new MediaQuery( + MediaQuery( data: const MediaQueryData( size: size, devicePixelRatio: devicePixelRatio, @@ -112,18 +112,18 @@ void main() { disableAnimations: true, boldText: true, ), - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new MediaQuery.removePadding( + return MediaQuery.removePadding( context: context, removeLeft: true, removeTop: true, removeRight: true, removeBottom: true, - child: new Builder( + child: Builder( builder: (BuildContext context) { unpadded = MediaQuery.of(context); - return new Container(); + return Container(); } ), ); @@ -153,7 +153,7 @@ void main() { MediaQueryData unpadded; await tester.pumpWidget( - new MediaQuery( + MediaQuery( data: const MediaQueryData( size: size, devicePixelRatio: devicePixelRatio, @@ -166,18 +166,18 @@ void main() { disableAnimations: true, boldText: true, ), - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new MediaQuery.removeViewInsets( + return MediaQuery.removeViewInsets( context: context, removeLeft: true, removeTop: true, removeRight: true, removeBottom: true, - child: new Builder( + child: Builder( builder: (BuildContext context) { unpadded = MediaQuery.of(context); - return new Container(); + return Container(); } ), ); @@ -203,17 +203,17 @@ void main() { double insideTextScaleFactor; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { outsideTextScaleFactor = MediaQuery.textScaleFactorOf(context); - return new MediaQuery( + return MediaQuery( data: const MediaQueryData( textScaleFactor: 4.0, ), - child: new Builder( + child: Builder( builder: (BuildContext context) { insideTextScaleFactor = MediaQuery.textScaleFactorOf(context); - return new Container(); + return Container(); }, ), ); @@ -230,17 +230,17 @@ void main() { bool insideBoldTextOverride; await tester.pumpWidget( - new Builder( + Builder( builder: (BuildContext context) { outsideBoldTextOverride = MediaQuery.boldTextOverride(context); - return new MediaQuery( + return MediaQuery( data: const MediaQueryData( boldText: true, ), - child: new Builder( + child: Builder( builder: (BuildContext context) { insideBoldTextOverride = MediaQuery.boldTextOverride(context); - return new Container(); + return Container(); }, ), ); diff --git a/packages/flutter/test/widgets/modal_barrier_test.dart b/packages/flutter/test/widgets/modal_barrier_test.dart index b0b5f63a59..e51052fed7 100644 --- a/packages/flutter/test/widgets/modal_barrier_test.dart +++ b/packages/flutter/test/widgets/modal_barrier_test.dart @@ -16,7 +16,7 @@ void main() { setUp(() { tapped = false; - tapTarget = new GestureDetector( + tapTarget = GestureDetector( onTap: () { tapped = true; }, @@ -29,7 +29,7 @@ void main() { }); testWidgets('ModalBarrier prevents interactions with widgets behind it', (WidgetTester tester) async { - final Widget subject = new Stack( + final Widget subject = Stack( textDirection: TextDirection.ltr, children: [ tapTarget, @@ -45,7 +45,7 @@ void main() { }); testWidgets('ModalBarrier does not prevent interactions with widgets in front of it', (WidgetTester tester) async { - final Widget subject = new Stack( + final Widget subject = Stack( textDirection: TextDirection.ltr, children: [ const ModalBarrier(dismissible: false), @@ -62,11 +62,11 @@ void main() { testWidgets('ModalBarrier pops the Navigator when dismissed', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new FirstWidget(), - '/modal': (BuildContext context) => new SecondWidget(), + '/': (BuildContext context) => FirstWidget(), + '/modal': (BuildContext context) => SecondWidget(), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); // Initially the barrier is not visible expect(find.byKey(const ValueKey('barrier')), findsNothing); @@ -86,10 +86,10 @@ void main() { }); testWidgets('Undismissible ModalBarrier hidden in semantic tree', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(const ModalBarrier(dismissible: false)); - final TestSemantics expectedSemantics = new TestSemantics.root(); + final TestSemantics expectedSemantics = TestSemantics.root(); expect(semantics, hasSemantics(expectedSemantics)); semantics.dispose(); @@ -98,7 +98,7 @@ void main() { testWidgets('Dismissible ModalBarrier includes button in semantic tree on iOS', (WidgetTester tester) async { debugDefaultTargetPlatformOverride = TargetPlatform.iOS; - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(const Directionality( textDirection: TextDirection.ltr, child: ModalBarrier( @@ -107,9 +107,9 @@ void main() { ), )); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( rect: TestSemantics.fullScreen, actions: SemanticsAction.tap.index, label: 'Dismiss', @@ -124,10 +124,10 @@ void main() { }); testWidgets('Dismissible ModalBarrier is hidden on Android (back button is used to dismiss)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget(const ModalBarrier(dismissible: true)); - final TestSemantics expectedSemantics = new TestSemantics.root(); + final TestSemantics expectedSemantics = TestSemantics.root(); expect(semantics, hasSemantics(expectedSemantics)); semantics.dispose(); @@ -137,11 +137,11 @@ void main() { class FirstWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { Navigator.pushNamed(context, '/modal'); }, - child: new Container( + child: Container( child: const Text('X') ) ); diff --git a/packages/flutter/test/widgets/multichild_test.dart b/packages/flutter/test/widgets/multichild_test.dart index 70c98b8bc6..6845f93e6a 100644 --- a/packages/flutter/test/widgets/multichild_test.dart +++ b/packages/flutter/test/widgets/multichild_test.dart @@ -35,7 +35,7 @@ void main() { testWidgets('MultiChildRenderObjectElement control test', (WidgetTester tester) async { await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationA), @@ -48,7 +48,7 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationA), @@ -60,7 +60,7 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationA), @@ -73,7 +73,7 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(key: Key('b'), decoration: kBoxDecorationB), @@ -86,7 +86,7 @@ void main() { checkTree(tester, [kBoxDecorationB, kBoxDecorationC, kBoxDecorationA]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(key: Key('a'), decoration: kBoxDecorationA), @@ -99,7 +99,7 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationC, kBoxDecorationB]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationC), @@ -110,7 +110,7 @@ void main() { checkTree(tester, [kBoxDecorationC]); await tester.pumpWidget( - new Stack(textDirection: TextDirection.ltr) + Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -120,7 +120,7 @@ void main() { testWidgets('MultiChildRenderObjectElement with stateless widgets', (WidgetTester tester) async { await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationA), @@ -133,11 +133,11 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ const DecoratedBox(decoration: kBoxDecorationA), - new Container( + Container( child: const DecoratedBox(decoration: kBoxDecorationB) ), const DecoratedBox(decoration: kBoxDecorationC), @@ -148,12 +148,12 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ const DecoratedBox(decoration: kBoxDecorationA), - new Container( - child: new Container( + Container( + child: Container( child: const DecoratedBox(decoration: kBoxDecorationB), ), ), @@ -165,15 +165,15 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Container( - child: new Container( + Container( + child: Container( child: const DecoratedBox(decoration: kBoxDecorationB), ), ), - new Container( + Container( child: const DecoratedBox(decoration: kBoxDecorationA), ), const DecoratedBox(decoration: kBoxDecorationC), @@ -184,13 +184,13 @@ void main() { checkTree(tester, [kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Container( + Container( child: const DecoratedBox(decoration: kBoxDecorationB), ), - new Container( + Container( child: const DecoratedBox(decoration: kBoxDecorationA), ), const DecoratedBox(decoration: kBoxDecorationC), @@ -201,14 +201,14 @@ void main() { checkTree(tester, [kBoxDecorationB, kBoxDecorationA, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Container( + Container( key: const Key('b'), child: const DecoratedBox(decoration: kBoxDecorationB), ), - new Container( + Container( key: const Key('a'), child: const DecoratedBox(decoration: kBoxDecorationA), ), @@ -219,14 +219,14 @@ void main() { checkTree(tester, [kBoxDecorationB, kBoxDecorationA]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Container( + Container( key: const Key('a'), child: const DecoratedBox(decoration: kBoxDecorationA), ), - new Container( + Container( key: const Key('b'), child: const DecoratedBox(decoration: kBoxDecorationB), ), @@ -237,7 +237,7 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB]); await tester.pumpWidget( - new Stack(textDirection: TextDirection.ltr) + Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -245,7 +245,7 @@ void main() { testWidgets('MultiChildRenderObjectElement with stateful widgets', (WidgetTester tester) async { await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationA), @@ -257,7 +257,7 @@ void main() { checkTree(tester, [kBoxDecorationA, kBoxDecorationB]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ FlipWidget( @@ -277,7 +277,7 @@ void main() { checkTree(tester, [kBoxDecorationB, kBoxDecorationC]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ FlipWidget( @@ -296,7 +296,7 @@ void main() { checkTree(tester, [kBoxDecorationA]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ FlipWidget( @@ -309,7 +309,7 @@ void main() { ); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(key: Key('c'), decoration: kBoxDecorationC), @@ -330,7 +330,7 @@ void main() { checkTree(tester, [kBoxDecorationC, kBoxDecorationB]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ FlipWidget( diff --git a/packages/flutter/test/widgets/navigator_and_layers_test.dart b/packages/flutter/test/widgets/navigator_and_layers_test.dart index 263dc209c7..d524d3a11d 100644 --- a/packages/flutter/test/widgets/navigator_and_layers_test.dart +++ b/packages/flutter/test/widgets/navigator_and_layers_test.dart @@ -30,20 +30,20 @@ void main() { final List log = []; log.add('0'); await tester.pumpWidget( - new MaterialApp( + MaterialApp( routes: { - '/': (BuildContext context) => new RepaintBoundary( - child: new Container( - child: new RepaintBoundary( - child: new FlipWidget( - left: new CustomPaint( - painter: new TestCustomPainter( + '/': (BuildContext context) => RepaintBoundary( + child: Container( + child: RepaintBoundary( + child: FlipWidget( + left: CustomPaint( + painter: TestCustomPainter( log: log, name: 'left' ), ), - right: new CustomPaint( - painter: new TestCustomPainter( + right: CustomPaint( + painter: TestCustomPainter( log: log, name: 'right' ), @@ -52,7 +52,7 @@ void main() { ), ), ), - '/second': (BuildContext context) => new Container(), + '/second': (BuildContext context) => Container(), }, ), ); diff --git a/packages/flutter/test/widgets/navigator_replacement_test.dart b/packages/flutter/test/widgets/navigator_replacement_test.dart index b00714cf0d..ea7685951a 100644 --- a/packages/flutter/test/widgets/navigator_replacement_test.dart +++ b/packages/flutter/test/widgets/navigator_replacement_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Back during pushReplacement', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: const Material(child: Text('home')), routes: { '/a': (BuildContext context) => const Material(child: Text('a')), @@ -40,7 +40,7 @@ void main() { }); testWidgets('pushAndRemoveUntil', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: const Material(child: Text('home')), routes: { '/a': (BuildContext context) => const Material(child: Text('a')), diff --git a/packages/flutter/test/widgets/navigator_test.dart b/packages/flutter/test/widgets/navigator_test.dart index 627ab36720..14546dc693 100644 --- a/packages/flutter/test/widgets/navigator_test.dart +++ b/packages/flutter/test/widgets/navigator_test.dart @@ -12,11 +12,11 @@ import 'semantics_tester.dart'; class FirstWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () { Navigator.pushNamed(context, '/second'); }, - child: new Container( + child: Container( color: const Color(0xFFFFFF00), child: const Text('X'), ), @@ -26,15 +26,15 @@ class FirstWidget extends StatelessWidget { class SecondWidget extends StatefulWidget { @override - SecondWidgetState createState() => new SecondWidgetState(); + SecondWidgetState createState() => SecondWidgetState(); } class SecondWidgetState extends State { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( onTap: () => Navigator.pop(context), - child: new Container( + child: Container( color: const Color(0xFFFF00FF), child: const Text('Y'), ), @@ -52,7 +52,7 @@ class ThirdWidget extends StatelessWidget { @override Widget build(BuildContext context) { - return new GestureDetector( + return GestureDetector( key: targetKey, onTap: () { try { @@ -74,14 +74,14 @@ class OnTapPage extends StatelessWidget { @override Widget build(BuildContext context) { - return new Scaffold( - appBar: new AppBar(title: new Text('Page $id')), - body: new GestureDetector( + return Scaffold( + appBar: AppBar(title: Text('Page $id')), + body: GestureDetector( onTap: onTap, behavior: HitTestBehavior.opaque, - child: new Container( - child: new Center( - child: new Text(id, style: Theme.of(context).textTheme.display2), + child: Container( + child: Center( + child: Text(id, style: Theme.of(context).textTheme.display2), ), ), ), @@ -127,11 +127,11 @@ class TestObserver extends NavigatorObserver { void main() { testWidgets('Can navigator navigate to and from a stateful widget', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new FirstWidget(), // X - '/second': (BuildContext context) => new SecondWidget(), // Y + '/': (BuildContext context) => FirstWidget(), // X + '/second': (BuildContext context) => SecondWidget(), // Y }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(find.text('X'), findsOneWidget); expect(find.text('Y', skipOffstage: false), findsNothing); @@ -178,7 +178,7 @@ void main() { testWidgets('Navigator.of fails gracefully when not found in context', (WidgetTester tester) async { const Key targetKey = Key('foo'); dynamic exception; - final Widget widget = new ThirdWidget( + final Widget widget = ThirdWidget( targetKey: targetKey, onException: (dynamic e) { exception = e; @@ -191,32 +191,32 @@ void main() { }); testWidgets('Navigator.of rootNavigator finds root Navigator', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new Material( - child: new Column( + await tester.pumpWidget(MaterialApp( + home: Material( + child: Column( children: [ const SizedBox( height: 300.0, child: Text('Root page'), ), - new SizedBox( + SizedBox( height: 300.0, - child: new Navigator( + child: Navigator( onGenerateRoute: (RouteSettings settings) { if (settings.isInitialRoute) { - return new MaterialPageRoute( + return MaterialPageRoute( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( child: const Text('Next'), onPressed: () { Navigator.of(context).push( - new MaterialPageRoute( + MaterialPageRoute( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( child: const Text('Inner page'), onPressed: () { Navigator.of(context, rootNavigator: true).push( - new MaterialPageRoute( + MaterialPageRoute( builder: (BuildContext context) { return const Text('Dialog'); } @@ -262,25 +262,25 @@ void main() { final List log = []; final Map routes = { '/': (BuildContext context) { - return new Row( + return Row( children: [ - new GestureDetector( + GestureDetector( onTap: () { log.add('left'); Navigator.pushNamed(context, '/second'); }, child: const Text('left') ), - new GestureDetector( + GestureDetector( onTap: () { log.add('right'); }, child: const Text('right') ), ] ); }, - '/second': (BuildContext context) => new Container(), + '/second': (BuildContext context) => Container(), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(log, isEmpty); await tester.tap(find.text('left')); expect(log, equals(['left'])); @@ -327,12 +327,12 @@ void main() { testWidgets('popAndPushNamed', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.popAndPushNamed(context, '/B'); }), - '/B': (BuildContext context) => new OnTapPage(id: 'B', onTap: () { Navigator.pop(context); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.popAndPushNamed(context, '/B'); }), + '/B': (BuildContext context) => OnTapPage(id: 'B', onTap: () { Navigator.pop(context); }), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(find.text('/'), findsOneWidget); expect(find.text('A', skipOffstage: false), findsNothing); expect(find.text('B', skipOffstage: false), findsNothing); @@ -355,12 +355,12 @@ void main() { testWidgets('Push and pop should trigger the observers', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.pop(context); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context); }), }; bool isPushed = false; bool isPopped = false; - final TestObserver observer = new TestObserver() + final TestObserver observer = TestObserver() ..onPushed = (Route route, Route previousRoute) { // Pushes the initial route. expect(route is PageRoute && route.settings.name == '/', isTrue); @@ -371,7 +371,7 @@ void main() { isPopped = true; }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, navigatorObservers: [observer], )); @@ -415,13 +415,13 @@ void main() { testWidgets('Add and remove an observer should work', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.pop(context); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context); }), }; bool isPushed = false; bool isPopped = false; - final TestObserver observer1 = new TestObserver(); - final TestObserver observer2 = new TestObserver() + final TestObserver observer1 = TestObserver(); + final TestObserver observer2 = TestObserver() ..onPushed = (Route route, Route previousRoute) { isPushed = true; } @@ -429,14 +429,14 @@ void main() { isPopped = true; }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, navigatorObservers: [observer1], )); expect(isPushed, isFalse); expect(isPopped, isFalse); - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, navigatorObservers: [observer1, observer2], )); @@ -449,7 +449,7 @@ void main() { isPushed = false; isPopped = false; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, navigatorObservers: [observer1], )); @@ -462,12 +462,12 @@ void main() { testWidgets('replaceNamed', (WidgetTester tester) async { final Map routes = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushReplacementNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.pushReplacementNamed(context, '/B'); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushReplacementNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pushReplacementNamed(context, '/B'); }), '/B': (BuildContext context) => const OnTapPage(id: 'B'), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); await tester.tap(find.text('/')); // replaceNamed('/A') await tester.pump(); await tester.pump(const Duration(seconds: 1)); @@ -486,14 +486,14 @@ void main() { Future value; final Map routes = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { value = Navigator.pushReplacementNamed(context, '/B', result: 'B'); }), - '/B': (BuildContext context) => new OnTapPage(id: 'B', onTap: () { Navigator.pop(context, 'B'); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { value = Navigator.pushReplacementNamed(context, '/B', result: 'B'); }), + '/B': (BuildContext context) => OnTapPage(id: 'B', onTap: () { Navigator.pop(context, 'B'); }), }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( onGenerateRoute: (RouteSettings settings) { - return new PageRouteBuilder( + return PageRouteBuilder( settings: settings, pageBuilder: (BuildContext context, Animation _, Animation __) { return routes[settings.name](context); @@ -533,8 +533,8 @@ void main() { testWidgets('removeRoute', (WidgetTester tester) async { final Map pageBuilders = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.pushNamed(context, '/B'); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pushNamed(context, '/B'); }), '/B': (BuildContext context) => const OnTapPage(id: 'B'), }; final Map> routes = >{}; @@ -542,16 +542,16 @@ void main() { Route removedRoute; Route previousRoute; - final TestObserver observer = new TestObserver() + final TestObserver observer = TestObserver() ..onRemoved = (Route route, Route previous) { removedRoute = route; previousRoute = previous; }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( navigatorObservers: [observer], onGenerateRoute: (RouteSettings settings) { - routes[settings.name] = new PageRouteBuilder( + routes[settings.name] = PageRouteBuilder( settings: settings, pageBuilder: (BuildContext context, Animation _, Animation __) { return pageBuilders[settings.name](context); @@ -620,14 +620,14 @@ void main() { testWidgets('remove a route whose value is awaited', (WidgetTester tester) async { Future pageValue; final Map pageBuilders = { - '/': (BuildContext context) => new OnTapPage(id: '/', onTap: () { pageValue = Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: 'A', onTap: () { Navigator.pop(context, 'A'); }), + '/': (BuildContext context) => OnTapPage(id: '/', onTap: () { pageValue = Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: 'A', onTap: () { Navigator.pop(context, 'A'); }), }; final Map> routes = >{}; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( onGenerateRoute: (RouteSettings settings) { - routes[settings.name] = new PageRouteBuilder( + routes[settings.name] = PageRouteBuilder( settings: settings, pageBuilder: (BuildContext context, Animation _, Animation __) { return pageBuilders[settings.name](context); @@ -646,9 +646,9 @@ void main() { }); testWidgets('replacing route can be observed', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); final List log = []; - final TestObserver observer = new TestObserver() + final TestObserver observer = TestObserver() ..onPushed = (Route route, Route previousRoute) { log.add('pushed ${route.settings.name} (previous is ${previousRoute == null ? "" : previousRoute.settings.name})'); } @@ -662,27 +662,27 @@ void main() { log.add('replaced ${oldRoute.settings.name} with ${newRoute.settings.name}'); }; Route routeB; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( navigatorKey: key, navigatorObservers: [observer], - home: new FlatButton( + home: FlatButton( child: const Text('A'), onPressed: () { - key.currentState.push(routeB = new MaterialPageRoute( + key.currentState.push(routeB = MaterialPageRoute( settings: const RouteSettings(name: 'B'), builder: (BuildContext context) { - return new FlatButton( + return FlatButton( child: const Text('B'), onPressed: () { - key.currentState.push(new MaterialPageRoute( + key.currentState.push(MaterialPageRoute( settings: const RouteSettings(name: 'C'), builder: (BuildContext context) { - return new FlatButton( + return FlatButton( child: const Text('C'), onPressed: () { key.currentState.replace( oldRoute: routeB, - newRoute: new MaterialPageRoute( + newRoute: MaterialPageRoute( settings: const RouteSettings(name: 'D'), builder: (BuildContext context) { return const Text('D'); @@ -716,32 +716,32 @@ void main() { }); testWidgets('ModalRoute.of sets up a route to rebuild if its state changes', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); final List log = []; Route routeB; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( navigatorKey: key, - home: new FlatButton( + home: FlatButton( child: const Text('A'), onPressed: () { - key.currentState.push(routeB = new MaterialPageRoute( + key.currentState.push(routeB = MaterialPageRoute( settings: const RouteSettings(name: 'B'), builder: (BuildContext context) { log.add('building B'); - return new FlatButton( + return FlatButton( child: const Text('B'), onPressed: () { - key.currentState.push(new MaterialPageRoute( + key.currentState.push(MaterialPageRoute( settings: const RouteSettings(name: 'C'), builder: (BuildContext context) { log.add('building C'); log.add('found ${ModalRoute.of(context).settings.name}'); - return new FlatButton( + return FlatButton( child: const Text('C'), onPressed: () { key.currentState.replace( oldRoute: routeB, - newRoute: new MaterialPageRoute( + newRoute: MaterialPageRoute( settings: const RouteSettings(name: 'D'), builder: (BuildContext context) { log.add('building D'); @@ -776,14 +776,14 @@ void main() { }); testWidgets('route semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final Map routes = { - '/': (BuildContext context) => new OnTapPage(id: '1', onTap: () { Navigator.pushNamed(context, '/A'); }), - '/A': (BuildContext context) => new OnTapPage(id: '2', onTap: () { Navigator.pushNamed(context, '/B/C'); }), + '/': (BuildContext context) => OnTapPage(id: '1', onTap: () { Navigator.pushNamed(context, '/A'); }), + '/A': (BuildContext context) => OnTapPage(id: '2', onTap: () { Navigator.pushNamed(context, '/B/C'); }), '/B/C': (BuildContext context) => const OnTapPage(id: '3'), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(semantics, includesNodeWith( flags: [SemanticsFlag.scopesRoute], diff --git a/packages/flutter/test/widgets/nested_scroll_view_test.dart b/packages/flutter/test/widgets/nested_scroll_view_test.dart index 35b0700a06..4f3d713157 100644 --- a/packages/flutter/test/widgets/nested_scroll_view_test.dart +++ b/packages/flutter/test/widgets/nested_scroll_view_test.dart @@ -13,35 +13,35 @@ class _CustomPhysics extends ClampingScrollPhysics { @override _CustomPhysics applyTo(ScrollPhysics ancestor) { - return new _CustomPhysics(parent: buildParent(ancestor)); + return _CustomPhysics(parent: buildParent(ancestor)); } @override Simulation createBallisticSimulation(ScrollMetrics position, double dragVelocity) { - return new ScrollSpringSimulation(spring, 1000.0, 1000.0, 1000.0); + return ScrollSpringSimulation(spring, 1000.0, 1000.0, 1000.0); } } Widget buildTest({ ScrollController controller, String title ='TTTTTTTT' }) { - return new Localizations( + return Localizations( locale: const Locale('en', 'US'), delegates: const >[ DefaultMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scaffold( - body: new DefaultTabController( + child: Scaffold( + body: DefaultTabController( length: 4, - child: new NestedScrollView( + child: NestedScrollView( controller: controller, headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ - new SliverAppBar( - title: new Text(title), + SliverAppBar( + title: Text(title), pinned: true, expandedHeight: 200.0, forceElevated: innerBoxIsScrolled, @@ -56,42 +56,42 @@ Widget buildTest({ ScrollController controller, String title ='TTTTTTTT' }) { ), ]; }, - body: new TabBarView( + body: TabBarView( children: [ - new ListView( + ListView( children: [ - new Container( + Container( height: 300.0, child: const Text('aaa1'), ), - new Container( + Container( height: 200.0, child: const Text('aaa2'), ), - new Container( + Container( height: 100.0, child: const Text('aaa3'), ), - new Container( + Container( height: 50.0, child: const Text('aaa4'), ), ], ), - new ListView( + ListView( children: [ - new Container( + Container( height: 100.0, child: const Text('bbb1'), ), ], ), - new Container( + Container( child: const Center(child: Text('ccc1')), ), - new ListView( + ListView( children: [ - new Container( + Container( height: 10000.0, child: const Text('ddd1'), ), @@ -212,7 +212,7 @@ void main() { }); testWidgets('NestedScrollView with a ScrollController', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(initialScrollOffset: 50.0); + final ScrollController controller = ScrollController(initialScrollOffset: 50.0); double scrollOffset; controller.addListener(() { @@ -268,13 +268,13 @@ void main() { }); testWidgets('Three NestedScrollViews with one ScrollController', (WidgetTester tester) async { - final TrackingScrollController controller = new TrackingScrollController(); + final TrackingScrollController controller = TrackingScrollController(); expect(controller.mostRecentlyUpdatedPosition, isNull); expect(controller.initialScrollOffset, 0.0); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( children: [ buildTest(controller: controller, title: 'Page0'), buildTest(controller: controller, title: 'Page1'), @@ -316,11 +316,11 @@ void main() { }); testWidgets('NestedScrollViews with custom physics', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new NestedScrollView( + child: NestedScrollView( physics: const _CustomPhysics(), headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ @@ -330,7 +330,7 @@ void main() { ), ]; }, - body: new Container(), + body: Container(), ), ), )); @@ -348,17 +348,17 @@ void main() { const List _tabs = ['Hello', 'World']; int buildCount = 0; await tester.pumpWidget( - new MaterialApp(home: new Material(child: + MaterialApp(home: Material(child: // THE FOLLOWING SECTION IS FROM THE NestedScrollView DOCUMENTATION // (EXCEPT FOR THE CHANGES TO THE buildCount COUNTER) - new DefaultTabController( + DefaultTabController( length: _tabs.length, // This is the number of tabs. - child: new NestedScrollView( + child: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { buildCount += 1; // THIS LINE IS NOT IN THE ORIGINAL -- ADDED FOR TEST // These are the slivers that show up in the "outer" scroll view. return [ - new SliverOverlapAbsorber( + SliverOverlapAbsorber( // This widget takes the overlapping behavior of the SliverAppBar, // and redirects it to the SliverOverlapInjector below. If it is // missing, then it is possible for the nested "inner" scroll view @@ -367,7 +367,7 @@ void main() { // This is not necessary if the "headerSliverBuilder" only builds // widgets that do not overlap the next sliver. handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), - child: new SliverAppBar( + child: SliverAppBar( title: const Text('Books'), // This is the title in the app bar. pinned: true, expandedHeight: 150.0, @@ -380,26 +380,26 @@ void main() { // not actually aware of the precise position of the inner // scroll views. forceElevated: innerBoxIsScrolled, - bottom: new TabBar( + bottom: TabBar( // These are the widgets to put in each tab in the tab bar. - tabs: _tabs.map((String name) => new Tab(text: name)).toList(), + tabs: _tabs.map((String name) => Tab(text: name)).toList(), ), ), ), ]; }, - body: new TabBarView( + body: TabBarView( // These are the contents of the tab views, below the tabs. children: _tabs.map((String name) { - return new SafeArea( + return SafeArea( top: false, bottom: false, - child: new Builder( + child: Builder( // This Builder is needed to provide a BuildContext that is "inside" // the NestedScrollView, so that sliverOverlapAbsorberHandleFor() can // find the NestedScrollView. builder: (BuildContext context) { - return new CustomScrollView( + return CustomScrollView( // The "controller" and "primary" members should be left // unset, so that the NestedScrollView can control this // inner scroll view. @@ -408,29 +408,29 @@ void main() { // The PageStorageKey should be unique to this ScrollView; // it allows the list to remember its scroll position when // the tab view is not on the screen. - key: new PageStorageKey(name), + key: PageStorageKey(name), slivers: [ - new SliverOverlapInjector( + SliverOverlapInjector( // This is the flip side of the SliverOverlapAbsorber above. handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context), ), - new SliverPadding( + SliverPadding( padding: const EdgeInsets.all(8.0), // In this example, the inner scroll view has // fixed-height list items, hence the use of // SliverFixedExtentList. However, one could use any // sliver widget here, e.g. SliverList or SliverGrid. - sliver: new SliverFixedExtentList( + sliver: SliverFixedExtentList( // The items in this example are fixed to 48 pixels // high. This matches the Material Design spec for // ListTile widgets. itemExtent: 48.0, - delegate: new SliverChildBuilderDelegate( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { // This builder is called for each child. // In this example, we just number each list item. - return new ListTile( - title: new Text('Item $index'), + return ListTile( + title: Text('Item $index'), ); }, // The childCount of the SliverChildBuilderDelegate @@ -578,11 +578,11 @@ void main() { const Key key1 = ValueKey(1); const Key key2 = ValueKey(2); await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new DefaultTabController( + MaterialApp( + home: Material( + child: DefaultTabController( length: 1, - child: new NestedScrollView( + child: NestedScrollView( headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) { return [ const SliverPersistentHeader( @@ -590,8 +590,8 @@ void main() { ), ]; }, - body: new SingleChildScrollView( - child: new Container( + body: SingleChildScrollView( + child: Container( height: 1000.0, child: const Placeholder(key: key2), ), @@ -601,35 +601,35 @@ void main() { ), ), ); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); - expect(tester.getRect(find.byKey(key2)), new Rect.fromLTWH(0.0, 100.0, 800.0, 1000.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key2)), Rect.fromLTWH(0.0, 100.0, 800.0, 1000.0)); final TestGesture gesture = await tester.startGesture(const Offset(10.0, 10.0)); await gesture.moveBy(const Offset(0.0, -10.0)); // scroll up await tester.pump(); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, -10.0, 800.0, 100.0)); - expect(tester.getRect(find.byKey(key2)), new Rect.fromLTWH(0.0, 90.0, 800.0, 1000.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, -10.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key2)), Rect.fromLTWH(0.0, 90.0, 800.0, 1000.0)); await gesture.moveBy(const Offset(0.0, 10.0)); // scroll back to origin await tester.pump(); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); - expect(tester.getRect(find.byKey(key2)), new Rect.fromLTWH(0.0, 100.0, 800.0, 1000.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key2)), Rect.fromLTWH(0.0, 100.0, 800.0, 1000.0)); await gesture.moveBy(const Offset(0.0, 10.0)); // overscroll await gesture.moveBy(const Offset(0.0, 10.0)); // overscroll await gesture.moveBy(const Offset(0.0, 10.0)); // overscroll await tester.pump(); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); expect(tester.getRect(find.byKey(key2)).top, greaterThan(100.0)); expect(tester.getRect(find.byKey(key2)).top, lessThan(130.0)); await gesture.moveBy(const Offset(0.0, -1.0)); // scroll back a little await tester.pump(); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, -1.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, -1.0, 800.0, 100.0)); expect(tester.getRect(find.byKey(key2)).top, greaterThan(100.0)); expect(tester.getRect(find.byKey(key2)).top, lessThan(129.0)); await gesture.moveBy(const Offset(0.0, -10.0)); // scroll back a lot await tester.pump(); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, -11.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, -11.0, 800.0, 100.0)); await gesture.moveBy(const Offset(0.0, 20.0)); // overscroll again await tester.pump(); - expect(tester.getRect(find.byKey(key1)), new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); + expect(tester.getRect(find.byKey(key1)), Rect.fromLTWH(0.0, 0.0, 800.0, 100.0)); await gesture.up(); debugDefaultTargetPlatformOverride = null; }); @@ -644,7 +644,7 @@ class TestHeader extends SliverPersistentHeaderDelegate { double get maxExtent => 100.0; @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Placeholder(key: key); + return Placeholder(key: key); } @override bool shouldRebuild(TestHeader oldDelegate) => false; diff --git a/packages/flutter/test/widgets/notification_test.dart b/packages/flutter/test/widgets/notification_test.dart index b3e7ef01ac..49e0b5ff3b 100644 --- a/packages/flutter/test/widgets/notification_test.dart +++ b/packages/flutter/test/widgets/notification_test.dart @@ -9,71 +9,71 @@ class MyNotification extends Notification { } void main() { testWidgets('Notification basics - toString', (WidgetTester tester) async { - expect(new MyNotification(), hasOneLineDescription); + expect(MyNotification(), hasOneLineDescription); }); testWidgets('Notification basics - dispatch', (WidgetTester tester) async { final List log = []; - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new NotificationListener( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(NotificationListener( onNotification: (MyNotification value) { log.add('a'); log.add(value); return true; }, - child: new NotificationListener( + child: NotificationListener( onNotification: (MyNotification value) { log.add('b'); log.add(value); return false; }, - child: new Container(key: key), + child: Container(key: key), ), )); expect(log, isEmpty); - final Notification notification = new MyNotification(); + final Notification notification = MyNotification(); expect(() { notification.dispatch(key.currentContext); }, isNot(throwsException)); expect(log, ['b', notification, 'a', notification]); }); testWidgets('Notification basics - cancel', (WidgetTester tester) async { final List log = []; - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new NotificationListener( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(NotificationListener( onNotification: (MyNotification value) { log.add('a - error'); log.add(value); return true; }, - child: new NotificationListener( + child: NotificationListener( onNotification: (MyNotification value) { log.add('b'); log.add(value); return true; }, - child: new Container(key: key), + child: Container(key: key), ), )); expect(log, isEmpty); - final Notification notification = new MyNotification(); + final Notification notification = MyNotification(); expect(() { notification.dispatch(key.currentContext); }, isNot(throwsException)); expect(log, ['b', notification]); }); testWidgets('Notification basics - listener null return value', (WidgetTester tester) async { final List log = []; - final GlobalKey key = new GlobalKey(); - await tester.pumpWidget(new NotificationListener( + final GlobalKey key = GlobalKey(); + await tester.pumpWidget(NotificationListener( onNotification: (MyNotification value) { log.add(value.runtimeType); return false; }, - child: new NotificationListener( + child: NotificationListener( onNotification: (MyNotification value) => false, - child: new Container(key: key), + child: Container(key: key), ), )); - expect(() { new MyNotification().dispatch(key.currentContext); }, isNot(throwsException)); + expect(() { MyNotification().dispatch(key.currentContext); }, isNot(throwsException)); expect(log, [MyNotification]); }); } diff --git a/packages/flutter/test/widgets/obscured_animated_image_test.dart b/packages/flutter/test/widgets/obscured_animated_image_test.dart index b4e095ecd9..fac8fdcff2 100644 --- a/packages/flutter/test/widgets/obscured_animated_image_test.dart +++ b/packages/flutter/test/widgets/obscured_animated_image_test.dart @@ -14,16 +14,16 @@ import '../painting/fake_image_provider.dart'; import '../painting/image_data.dart'; Future main() async { - final FakeCodec fakeCodec = await FakeCodec.fromData(new Uint8List.fromList(kAnimatedGif)); - final FakeImageProvider fakeImageProvider = new FakeImageProvider(fakeCodec); + final FakeCodec fakeCodec = await FakeCodec.fromData(Uint8List.fromList(kAnimatedGif)); + final FakeImageProvider fakeImageProvider = FakeImageProvider(fakeCodec); testWidgets('Obscured image does not animate', (WidgetTester tester) async { - final GlobalKey imageKey = new GlobalKey(); + final GlobalKey imageKey = GlobalKey(); await tester.pumpWidget( - new MaterialApp( - home: new Image(image: fakeImageProvider, excludeFromSemantics: true, key: imageKey), + MaterialApp( + home: Image(image: fakeImageProvider, excludeFromSemantics: true, key: imageKey), routes: { - '/page': (BuildContext context) => new Container() + '/page': (BuildContext context) => Container() } ) ); diff --git a/packages/flutter/test/widgets/opacity_test.dart b/packages/flutter/test/widgets/opacity_test.dart index ace2f96926..b4fe15b28a 100644 --- a/packages/flutter/test/widgets/opacity_test.dart +++ b/packages/flutter/test/widgets/opacity_test.dart @@ -10,7 +10,7 @@ import 'semantics_tester.dart'; void main() { testWidgets('Opacity', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // Opacity 1.0: Semantics and painting await tester.pumpWidget( @@ -20,9 +20,9 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), label: 'a', @@ -41,7 +41,7 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root(), + TestSemantics.root(), )); expect(find.byType(Opacity), paintsNothing); @@ -54,9 +54,9 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), label: 'a', @@ -76,7 +76,7 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root(), + TestSemantics.root(), )); expect(find.byType(Opacity), paintsNothing); @@ -88,9 +88,9 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), label: 'a', @@ -110,9 +110,9 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), label: 'a', @@ -132,9 +132,9 @@ void main() { ), ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), label: 'a', diff --git a/packages/flutter/test/widgets/overflow_box_test.dart b/packages/flutter/test/widgets/overflow_box_test.dart index 074fec72cc..fbfb0fa2ae 100644 --- a/packages/flutter/test/widgets/overflow_box_test.dart +++ b/packages/flutter/test/widgets/overflow_box_test.dart @@ -8,18 +8,18 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('OverflowBox control test', (WidgetTester tester) async { - final GlobalKey inner = new GlobalKey(); - await tester.pumpWidget(new Align( + final GlobalKey inner = GlobalKey(); + await tester.pumpWidget(Align( alignment: const Alignment(1.0, 1.0), - child: new SizedBox( + child: SizedBox( width: 10.0, height: 20.0, - child: new OverflowBox( + child: OverflowBox( minWidth: 0.0, maxWidth: 100.0, minHeight: 0.0, maxHeight: 50.0, - child: new Container( + child: Container( key: inner ) ) @@ -31,7 +31,7 @@ void main() { }); testWidgets('OverflowBox implements debugFillProperties', (WidgetTester tester) async { - final DiagnosticPropertiesBuilder builder = new DiagnosticPropertiesBuilder(); + final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder(); const OverflowBox( minWidth: 1.0, maxWidth: 2.0, diff --git a/packages/flutter/test/widgets/overlay_test.dart b/packages/flutter/test/widgets/overlay_test.dart index 8ad1e5c94d..c393c59eec 100644 --- a/packages/flutter/test/widgets/overlay_test.dart +++ b/packages/flutter/test/widgets/overlay_test.dart @@ -8,21 +8,21 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('OverflowEntries context contains Overlay', (WidgetTester tester) async { - final GlobalKey overlayKey = new GlobalKey(); + final GlobalKey overlayKey = GlobalKey(); bool didBuild = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( key: overlayKey, initialEntries: [ - new OverlayEntry( + OverlayEntry( builder: (BuildContext context) { didBuild = true; final Overlay overlay = context.ancestorWidgetOfExactType(Overlay); expect(overlay, isNotNull); expect(overlay.key, equals(overlayKey)); - return new Container(); + return Container(); }, ), ], @@ -71,27 +71,27 @@ void main() { }); testWidgets('Offstage overlay', (WidgetTester tester) async { - final GlobalKey overlayKey = new GlobalKey(); + final GlobalKey overlayKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Overlay( + child: Overlay( key: overlayKey, initialEntries: [ - new OverlayEntry( + OverlayEntry( opaque: true, maintainState: true, - builder: (BuildContext context) => new Container(), + builder: (BuildContext context) => Container(), ), - new OverlayEntry( + OverlayEntry( opaque: true, maintainState: true, - builder: (BuildContext context) => new Container(), + builder: (BuildContext context) => Container(), ), - new OverlayEntry( + OverlayEntry( opaque: true, maintainState: true, - builder: (BuildContext context) => new Container(), + builder: (BuildContext context) => Container(), ), ], ), diff --git a/packages/flutter/test/widgets/overscroll_indicator_test.dart b/packages/flutter/test/widgets/overscroll_indicator_test.dart index da32eba5e8..ba60a9c260 100644 --- a/packages/flutter/test/widgets/overscroll_indicator_test.dart +++ b/packages/flutter/test/widgets/overscroll_indicator_test.dart @@ -24,9 +24,9 @@ Future slowDrag(WidgetTester tester, Offset start, Offset offset) async { void main() { testWidgets('Overscroll indicator color', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], @@ -60,17 +60,17 @@ void main() { testWidgets('Nested scrollable', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GlowingOverscrollIndicator( + child: GlowingOverscrollIndicator( axisDirection: AxisDirection.down, color: const Color(0x0DFFFFFF), notificationPredicate: (ScrollNotification notification) => notification.depth == 1, - child: new SingleChildScrollView( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - child: new Container( + child: Container( width: 600.0, - child: new CustomScrollView( + child: CustomScrollView( slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], @@ -91,9 +91,9 @@ void main() { testWidgets('Overscroll indicator changes side when you drag on the other side', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], @@ -129,9 +129,9 @@ void main() { testWidgets('Overscroll indicator changes side when you shift sides', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], @@ -165,9 +165,9 @@ void main() { group('Flipping direction of scrollable doesn\'t change overscroll behavior', () { testWidgets('down', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), @@ -185,9 +185,9 @@ void main() { testWidgets('up', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( reverse: true, physics: const AlwaysScrollableScrollPhysics(), slivers: const [ @@ -207,9 +207,9 @@ void main() { testWidgets('Overscroll in both directions', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( physics: const AlwaysScrollableScrollPhysics(), slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 20.0)), @@ -230,9 +230,9 @@ void main() { testWidgets('Overscroll horizontally', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( scrollDirection: Axis.horizontal, physics: const AlwaysScrollableScrollPhysics(), slivers: const [ @@ -254,13 +254,13 @@ void main() { }); testWidgets('Nested overscrolls do not throw exceptions', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( children: [ - new ListView( + ListView( children: [ - new Container( + Container( width: 2000.0, height: 2000.0, color: const Color(0xFF00FF00), @@ -279,11 +279,11 @@ void main() { RenderObject painter; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ScrollConfiguration( - behavior: new TestScrollBehavior1(), - child: new CustomScrollView( + child: ScrollConfiguration( + behavior: TestScrollBehavior1(), + child: CustomScrollView( scrollDirection: Axis.horizontal, physics: const AlwaysScrollableScrollPhysics(), reverse: true, @@ -301,11 +301,11 @@ void main() { await tester.pumpAndSettle(const Duration(seconds: 1)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ScrollConfiguration( - behavior: new TestScrollBehavior2(), - child: new CustomScrollView( + child: ScrollConfiguration( + behavior: TestScrollBehavior2(), + child: CustomScrollView( scrollDirection: Axis.horizontal, physics: const AlwaysScrollableScrollPhysics(), slivers: const [ @@ -325,7 +325,7 @@ void main() { class TestScrollBehavior1 extends ScrollBehavior { @override Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { - return new GlowingOverscrollIndicator( + return GlowingOverscrollIndicator( child: child, axisDirection: axisDirection, color: const Color(0xFF00FF00), @@ -336,7 +336,7 @@ class TestScrollBehavior1 extends ScrollBehavior { class TestScrollBehavior2 extends ScrollBehavior { @override Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { - return new GlowingOverscrollIndicator( + return GlowingOverscrollIndicator( child: child, axisDirection: axisDirection, color: const Color(0xFF0000FF), diff --git a/packages/flutter/test/widgets/page_forward_transitions_test.dart b/packages/flutter/test/widgets/page_forward_transitions_test.dart index 2138073748..89a8590c99 100644 --- a/packages/flutter/test/widgets/page_forward_transitions_test.dart +++ b/packages/flutter/test/widgets/page_forward_transitions_test.dart @@ -55,7 +55,7 @@ void main() { testWidgets('Check onstage/offstage handling around transitions', (WidgetTester tester) async { - final GlobalKey insideKey = new GlobalKey(); + final GlobalKey insideKey = GlobalKey(); String state({ bool skipOffstage = true }) { String result = ''; @@ -77,24 +77,24 @@ void main() { } await tester.pumpWidget( - new MaterialApp( + MaterialApp( onGenerateRoute: (RouteSettings settings) { switch (settings.name) { case '/': - return new TestRoute( + return TestRoute( settings: settings, - child: new Builder( + child: Builder( key: insideKey, builder: (BuildContext context) { final PageRoute route = ModalRoute.of(context); - return new Column( + return Column( children: [ - new TestTransition( + TestTransition( childFirstHalf: const Text('A'), childSecondHalf: const Text('B'), animation: route.animation ), - new TestTransition( + TestTransition( childFirstHalf: const Text('C'), childSecondHalf: const Text('D'), animation: route.secondaryAnimation @@ -104,9 +104,9 @@ void main() { } ) ); - case '/2': return new TestRoute(settings: settings, child: const Text('E')); - case '/3': return new TestRoute(settings: settings, child: const Text('F')); - case '/4': return new TestRoute(settings: settings, child: const Text('G')); + case '/2': return TestRoute(settings: settings, child: const Text('E')); + case '/3': return TestRoute(settings: settings, child: const Text('F')); + case '/4': return TestRoute(settings: settings, child: const Text('G')); } return null; } @@ -187,11 +187,11 @@ void main() { testWidgets('Check onstage/offstage handling of barriers around transitions', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( onGenerateRoute: (RouteSettings settings) { switch (settings.name) { - case '/': return new TestRoute(settings: settings, child: const Text('A')); - case '/1': return new TestRoute(settings: settings, barrierColor: const Color(0xFFFFFF00), child: const Text('B')); + case '/': return TestRoute(settings: settings, child: const Text('A')); + case '/1': return TestRoute(settings: settings, barrierColor: const Color(0xFFFFFF00), child: const Text('B')); } return null; } diff --git a/packages/flutter/test/widgets/page_storage_test.dart b/packages/flutter/test/widgets/page_storage_test.dart index 7055793413..b77f62967f 100644 --- a/packages/flutter/test/widgets/page_storage_test.dart +++ b/packages/flutter/test/widgets/page_storage_test.dart @@ -12,14 +12,14 @@ void main() { int storedValue = 0; await tester.pumpWidget( - new MaterialApp( - home: new StatefulBuilder( + MaterialApp( + home: StatefulBuilder( key: builderKey, builder: (BuildContext context, StateSetter setter) { PageStorage.of(context).writeState(context, storedValue); setState = setter; - return new Center( - child: new Text('storedValue: $storedValue') + return Center( + child: Text('storedValue: $storedValue') ); } ) @@ -42,14 +42,14 @@ void main() { int storedValue = 0; Widget buildWidthKey(Key key) { - return new MaterialApp( - home: new StatefulBuilder( + return MaterialApp( + home: StatefulBuilder( key: key, builder: (BuildContext context, StateSetter setter) { PageStorage.of(context).writeState(context, storedValue, identifier: 123); setState = setter; - return new Center( - child: new Text('storedValue: $storedValue') + return Center( + child: Text('storedValue: $storedValue') ); } ) diff --git a/packages/flutter/test/widgets/page_transitions_test.dart b/packages/flutter/test/widgets/page_transitions_test.dart index c08cc4dd1a..23abe7649e 100644 --- a/packages/flutter/test/widgets/page_transitions_test.dart +++ b/packages/flutter/test/widgets/page_transitions_test.dart @@ -9,7 +9,7 @@ class TestOverlayRoute extends OverlayRoute { TestOverlayRoute({ RouteSettings settings }) : super(settings: settings); @override Iterable createOverlayEntries() sync* { - yield new OverlayEntry(builder: _build); + yield OverlayEntry(builder: _build); } Widget _build(BuildContext context) => const Text('Overlay'); } @@ -18,11 +18,11 @@ class PersistentBottomSheetTest extends StatefulWidget { const PersistentBottomSheetTest({ Key key }) : super(key: key); @override - PersistentBottomSheetTestState createState() => new PersistentBottomSheetTestState(); + PersistentBottomSheetTestState createState() => PersistentBottomSheetTestState(); } class PersistentBottomSheetTestState extends State { - final GlobalKey _scaffoldKey = new GlobalKey(); + final GlobalKey _scaffoldKey = GlobalKey(); bool setStateCalled = false; @@ -39,7 +39,7 @@ class PersistentBottomSheetTestState extends State { @override Widget build(BuildContext context) { - return new Scaffold( + return Scaffold( key: _scaffoldKey, body: const Text('Sheet') ); @@ -48,14 +48,14 @@ class PersistentBottomSheetTestState extends State { void main() { testWidgets('Check onstage/offstage handling around transitions', (WidgetTester tester) async { - final GlobalKey containerKey1 = new GlobalKey(); - final GlobalKey containerKey2 = new GlobalKey(); + final GlobalKey containerKey1 = GlobalKey(); + final GlobalKey containerKey2 = GlobalKey(); final Map routes = { - '/': (_) => new Container(key: containerKey1, child: const Text('Home')), - '/settings': (_) => new Container(key: containerKey2, child: const Text('Settings')), + '/': (_) => Container(key: containerKey1, child: const Text('Home')), + '/settings': (_) => Container(key: containerKey2, child: const Text('Settings')), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); expect(find.text('Home'), isOnstage); expect(find.text('Settings'), findsNothing); @@ -83,7 +83,7 @@ void main() { expect(find.text('Settings'), isOnstage); expect(find.text('Overlay'), findsNothing); - Navigator.push(containerKey2.currentContext, new TestOverlayRoute()); + Navigator.push(containerKey2.currentContext, TestOverlayRoute()); await tester.pump(); @@ -130,13 +130,13 @@ void main() { }); testWidgets('Check back gesture disables Heroes', (WidgetTester tester) async { - final GlobalKey containerKey1 = new GlobalKey(); - final GlobalKey containerKey2 = new GlobalKey(); + final GlobalKey containerKey1 = GlobalKey(); + final GlobalKey containerKey2 = GlobalKey(); const String kHeroTag = 'hero'; final Map routes = { - '/': (_) => new Scaffold( + '/': (_) => Scaffold( key: containerKey1, - body: new Container( + body: Container( color: const Color(0xff00ffff), child: const Hero( tag: kHeroTag, @@ -144,9 +144,9 @@ void main() { ) ) ), - '/settings': (_) => new Scaffold( + '/settings': (_) => Scaffold( key: containerKey2, - body: new Container( + body: Container( padding: const EdgeInsets.all(100.0), color: const Color(0xffff00ff), child: const Hero( @@ -157,9 +157,9 @@ void main() { ), }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, - theme: new ThemeData(platform: TargetPlatform.iOS), + theme: ThemeData(platform: TargetPlatform.iOS), )); Navigator.pushNamed(containerKey1.currentContext, '/settings'); @@ -202,16 +202,16 @@ void main() { }); testWidgets('Check back gesture doesn\'t start during transitions', (WidgetTester tester) async { - final GlobalKey containerKey1 = new GlobalKey(); - final GlobalKey containerKey2 = new GlobalKey(); + final GlobalKey containerKey1 = GlobalKey(); + final GlobalKey containerKey2 = GlobalKey(); final Map routes = { - '/': (_) => new Scaffold(key: containerKey1, body: const Text('Home')), - '/settings': (_) => new Scaffold(key: containerKey2, body: const Text('Settings')), + '/': (_) => Scaffold(key: containerKey1, body: const Text('Home')), + '/settings': (_) => Scaffold(key: containerKey2, body: const Text('Settings')), }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, - theme: new ThemeData(platform: TargetPlatform.iOS), + theme: ThemeData(platform: TargetPlatform.iOS), )); Navigator.pushNamed(containerKey1.currentContext, '/settings'); @@ -249,16 +249,16 @@ void main() { // Tests bug https://github.com/flutter/flutter/issues/6451 testWidgets('Check back gesture with a persistent bottom sheet showing', (WidgetTester tester) async { - final GlobalKey containerKey1 = new GlobalKey(); - final GlobalKey containerKey2 = new GlobalKey(); + final GlobalKey containerKey1 = GlobalKey(); + final GlobalKey containerKey2 = GlobalKey(); final Map routes = { - '/': (_) => new Scaffold(key: containerKey1, body: const Text('Home')), - '/sheet': (_) => new PersistentBottomSheetTest(key: containerKey2), + '/': (_) => Scaffold(key: containerKey1, body: const Text('Home')), + '/sheet': (_) => PersistentBottomSheetTest(key: containerKey2), }; - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( routes: routes, - theme: new ThemeData(platform: TargetPlatform.iOS), + theme: ThemeData(platform: TargetPlatform.iOS), )); Navigator.pushNamed(containerKey1.currentContext, '/sheet'); @@ -310,9 +310,9 @@ void main() { '/next': (_) => const Center(child: Text('next')), }; - await tester.pumpWidget(new MaterialApp(routes: routes)); + await tester.pumpWidget(MaterialApp(routes: routes)); - final PageRoute route = new MaterialPageRoute( + final PageRoute route = MaterialPageRoute( settings: const RouteSettings(name: '/page'), builder: (BuildContext context) => const Center(child: Text('page')), ); diff --git a/packages/flutter/test/widgets/page_view_test.dart b/packages/flutter/test/widgets/page_view_test.dart index 9ee71c0ec5..c8ecdbec21 100644 --- a/packages/flutter/test/widgets/page_view_test.dart +++ b/packages/flutter/test/widgets/page_view_test.dart @@ -16,18 +16,18 @@ void main() { testWidgets('PageView control test', (WidgetTester tester) async { final List log = []; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( children: kStates.map((String state) { - return new GestureDetector( + return GestureDetector( onTap: () { log.add(state); }, - child: new Container( + child: Container( height: 200.0, color: const Color(0xFF0000FF), - child: new Text(state), + child: Text(state), ), ); }).toList(), @@ -80,20 +80,20 @@ void main() { testWidgets('PageView does not squish when overscrolled', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - theme: new ThemeData(platform: TargetPlatform.iOS), - home: new PageView( - children: new List.generate(10, (int i) { - return new Container( - key: new ValueKey(i), + await tester.pumpWidget(MaterialApp( + theme: ThemeData(platform: TargetPlatform.iOS), + home: PageView( + children: List.generate(10, (int i) { + return Container( + key: ValueKey(i), color: const Color(0xFF0000FF), ); }), ), )); - Size sizeOf(int i) => tester.getSize(find.byKey(new ValueKey(i))); - double leftOf(int i) => tester.getTopLeft(find.byKey(new ValueKey(i))).dx; + Size sizeOf(int i) => tester.getSize(find.byKey(ValueKey(i))); + double leftOf(int i) => tester.getTopLeft(find.byKey(ValueKey(i))).dx; expect(leftOf(0), equals(0.0)); expect(sizeOf(0), equals(const Size(800.0, 600.0))); @@ -114,17 +114,17 @@ void main() { }); testWidgets('PageController control test', (WidgetTester tester) async { - final PageController controller = new PageController(initialPage: 4); + final PageController controller = PageController(initialPage: 4); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new PageView( + child: PageView( controller: controller, - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), ), ), @@ -137,15 +137,15 @@ void main() { expect(find.text('Colorado'), findsOneWidget); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 300.0, height: 400.0, - child: new PageView( + child: PageView( controller: controller, - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), ), ), @@ -160,14 +160,14 @@ void main() { }); testWidgets('PageController page stability', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 600.0, height: 400.0, - child: new PageView( - children: kStates.map((String state) => new Text(state)).toList(), + child: PageView( + children: kStates.map((String state) => Text(state)).toList(), ), ) ), @@ -180,14 +180,14 @@ void main() { expect(find.text('Arizona'), findsOneWidget); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 250.0, height: 100.0, - child: new PageView( - children: kStates.map((String state) => new Text(state)).toList(), + child: PageView( + children: kStates.map((String state) => Text(state)).toList(), ), ), ), @@ -195,14 +195,14 @@ void main() { expect(find.text('Arizona'), findsOneWidget); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 450.0, height: 400.0, - child: new PageView( - children: kStates.map((String state) => new Text(state)).toList(), + child: PageView( + children: kStates.map((String state) => Text(state)).toList(), ), ), ), @@ -212,12 +212,12 @@ void main() { }); testWidgets('PageController nextPage and previousPage return Futures that resolve', (WidgetTester tester) async { - final PageController controller = new PageController(); - await tester.pumpWidget(new Directionality( + final PageController controller = PageController(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( controller: controller, - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), )); @@ -244,14 +244,14 @@ void main() { }); testWidgets('PageView in zero-size container', (WidgetTester tester) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 0.0, height: 0.0, - child: new PageView( - children: kStates.map((String state) => new Text(state)).toList(), + child: PageView( + children: kStates.map((String state) => Text(state)).toList(), ), ), ), @@ -259,14 +259,14 @@ void main() { expect(find.text('Alabama', skipOffstage: false), findsOneWidget); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( width: 200.0, height: 200.0, - child: new PageView( - children: kStates.map((String state) => new Text(state)).toList(), + child: PageView( + children: kStates.map((String state) => Text(state)).toList(), ), ), ), @@ -277,11 +277,11 @@ void main() { testWidgets('Page changes at halfway point', (WidgetTester tester) async { final List log = []; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( onPageChanged: log.add, - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), )); @@ -327,21 +327,21 @@ void main() { testWidgets('Bouncing scroll physics ballistics does not overshoot', (WidgetTester tester) async { final List log = []; - final PageController controller = new PageController(viewportFraction: 0.9); + final PageController controller = PageController(viewportFraction: 0.9); Widget build(PageController controller, {Size size}) { - final Widget pageView = new Directionality( + final Widget pageView = Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( controller: controller, onPageChanged: log.add, physics: const BouncingScrollPhysics(), - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), ); if (size != null) { - return new OverflowBox( + return OverflowBox( child: pageView, minWidth: size.width, minHeight: size.height, @@ -380,21 +380,21 @@ void main() { }); testWidgets('PageView viewportFraction', (WidgetTester tester) async { - PageController controller = new PageController(viewportFraction: 7/8); + PageController controller = PageController(viewportFraction: 7/8); Widget build(PageController controller) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new PageView.builder( + child: PageView.builder( controller: controller, itemCount: kStates.length, itemBuilder: (BuildContext context, int index) { - return new Container( + return Container( height: 200.0, color: index % 2 == 0 ? const Color(0xFF0000FF) : const Color(0xFF00FF00), - child: new Text(kStates[index]), + child: Text(kStates[index]), ); }, ), @@ -413,7 +413,7 @@ void main() { expect(tester.getTopLeft(find.text('Hawaii')), const Offset(50.0, 0.0)); expect(tester.getTopLeft(find.text('Idaho')), const Offset(750.0, 0.0)); - controller = new PageController(viewportFraction: 39/40); + controller = PageController(viewportFraction: 39/40); await tester.pumpWidget(build(controller)); @@ -426,13 +426,13 @@ void main() { final List log = []; Widget build({ bool pageSnapping }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( pageSnapping: pageSnapping, onPageChanged: log.add, children: - kStates.map((String state) => new Text(state)).toList(), + kStates.map((String state) => Text(state)).toList(), ), ); } @@ -486,21 +486,21 @@ void main() { }); testWidgets('PageView small viewportFraction', (WidgetTester tester) async { - final PageController controller = new PageController(viewportFraction: 1/8); + final PageController controller = PageController(viewportFraction: 1/8); Widget build(PageController controller) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new PageView.builder( + child: PageView.builder( controller: controller, itemCount: kStates.length, itemBuilder: (BuildContext context, int index) { - return new Container( + return Container( height: 200.0, color: index % 2 == 0 ? const Color(0xFF0000FF) : const Color(0xFF00FF00), - child: new Text(kStates[index]), + child: Text(kStates[index]), ); }, ), @@ -531,21 +531,21 @@ void main() { testWidgets('PageView large viewportFraction', (WidgetTester tester) async { final PageController controller = - new PageController(viewportFraction: 5/4); + PageController(viewportFraction: 5/4); Widget build(PageController controller) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new PageView.builder( + child: PageView.builder( controller: controller, itemCount: kStates.length, itemBuilder: (BuildContext context, int index) { - return new Container( + return Container( height: 200.0, color: index % 2 == 0 ? const Color(0xFF0000FF) : const Color(0xFF00FF00), - child: new Text(kStates[index]), + child: Text(kStates[index]), ); }, ), @@ -565,16 +565,16 @@ void main() { testWidgets('PageView does not report page changed on overscroll', (WidgetTester tester) async { - final PageController controller = new PageController( + final PageController controller = PageController( initialPage: kStates.length - 1, ); int changeIndex = 0; Widget build() { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( children: - kStates.map((String state) => new Text(state)).toList(), + kStates.map((String state) => Text(state)).toList(), controller: controller, onPageChanged: (int page) { changeIndex = page; @@ -593,7 +593,7 @@ void main() { testWidgets('PageView can restore page', (WidgetTester tester) async { - final PageController controller = new PageController(); + final PageController controller = PageController(); try { controller.page; fail('Accessing page before attaching should fail.'); @@ -603,12 +603,12 @@ void main() { 'PageController.page cannot be accessed before a PageView is built with it.', ); } - final PageStorageBucket bucket = new PageStorageBucket(); - await tester.pumpWidget(new Directionality( + final PageStorageBucket bucket = PageStorageBucket(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageStorage( + child: PageStorage( bucket: bucket, - child: new PageView( + child: PageView( key: const PageStorageKey('PageView'), controller: controller, children: const [ @@ -624,9 +624,9 @@ void main() { expect(await tester.pumpAndSettle(const Duration(minutes: 1)), 1); expect(controller.page, 2); await tester.pumpWidget( - new PageStorage( + PageStorage( bucket: bucket, - child: new Container(), + child: Container(), ), ); try { @@ -638,11 +638,11 @@ void main() { 'PageController.page cannot be accessed before a PageView is built with it.', ); } - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageStorage( + child: PageStorage( bucket: bucket, - child: new PageView( + child: PageView( key: const PageStorageKey('PageView'), controller: controller, children: const [ @@ -655,12 +655,12 @@ void main() { )); expect(controller.page, 2); - final PageController controller2 = new PageController(keepPage: false); - await tester.pumpWidget(new Directionality( + final PageController controller2 = PageController(keepPage: false); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageStorage( + child: PageStorage( bucket: bucket, - child: new PageView( + child: PageView( key: const PageStorageKey('Check it again against your list and see consistency!'), controller: controller2, children: const [ @@ -675,16 +675,16 @@ void main() { }); testWidgets('PageView exposes semantics of children', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final PageController controller = new PageController(); - await tester.pumpWidget(new Directionality( + final PageController controller = PageController(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PageView( + child: PageView( controller: controller, - children: new List.generate(3, (int i) { - return new Semantics( - child: new Text('Page #$i'), + children: List.generate(3, (int i) { + return Semantics( + child: Text('Page #$i'), container: true, ); }) @@ -714,7 +714,7 @@ void main() { }); testWidgets('PageMetrics', (WidgetTester tester) async { - final PageMetrics page = new PageMetrics( + final PageMetrics page = PageMetrics( minScrollExtent: 100.0, maxScrollExtent: 200.0, pixels: 150.0, diff --git a/packages/flutter/test/widgets/pageable_list_test.dart b/packages/flutter/test/widgets/pageable_list_test.dart index 8a343db2b9..670a23303a 100644 --- a/packages/flutter/test/widgets/pageable_list_test.dart +++ b/packages/flutter/test/widgets/pageable_list_test.dart @@ -9,15 +9,15 @@ import 'package:meta/meta.dart'; Size pageSize = const Size(600.0, 300.0); const List defaultPages = [0, 1, 2, 3, 4, 5]; -final List globalKeys = defaultPages.map((_) => new GlobalKey()).toList(); +final List globalKeys = defaultPages.map((_) => GlobalKey()).toList(); int currentPage; Widget buildPage(int page) { - return new Container( + return Container( key: globalKeys[page], width: pageSize.width, height: pageSize.height, - child: new Text(page.toString()) + child: Text(page.toString()) ); } @@ -26,7 +26,7 @@ Widget buildFrame({ List pages = defaultPages, @required TextDirection textDirection, }) { - final PageView child = new PageView( + final PageView child = PageView( scrollDirection: Axis.horizontal, reverse: reverse, onPageChanged: (int page) { currentPage = page; }, @@ -35,10 +35,10 @@ Widget buildFrame({ // The test framework forces the frame to be 800x600, so we need to create // an outer container where we can change the size. - return new Directionality( + return Directionality( textDirection: textDirection, - child: new Center( - child: new Container( + child: Center( + child: Container( width: pageSize.width, height: pageSize.height, child: child, ), ), @@ -54,20 +54,20 @@ Future page(WidgetTester tester, Offset offset) { } Future pageLeft(WidgetTester tester) { - return page(tester, new Offset(-pageSize.width, 0.0)); + return page(tester, Offset(-pageSize.width, 0.0)); } Future pageRight(WidgetTester tester) { - return page(tester, new Offset(pageSize.width, 0.0)); + return page(tester, Offset(pageSize.width, 0.0)); } void main() { testWidgets('PageView default control', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new PageView(), + child: Center( + child: PageView(), ), ), ); diff --git a/packages/flutter/test/widgets/parent_data_test.dart b/packages/flutter/test/widgets/parent_data_test.dart index 25702630ee..bd2847bceb 100644 --- a/packages/flutter/test/widgets/parent_data_test.dart +++ b/packages/flutter/test/widgets/parent_data_test.dart @@ -45,13 +45,13 @@ void checkTree(WidgetTester tester, List expectedParentData) { } } -final TestParentData kNonPositioned = new TestParentData(); +final TestParentData kNonPositioned = TestParentData(); void main() { testWidgets('ParentDataWidget control test', (WidgetTester tester) async { await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ DecoratedBox(decoration: kBoxDecorationA), @@ -67,12 +67,12 @@ void main() { checkTree(tester, [ kNonPositioned, - new TestParentData(top: 10.0, left: 10.0), + TestParentData(top: 10.0, left: 10.0), kNonPositioned, ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -91,8 +91,8 @@ void main() { ); checkTree(tester, [ - new TestParentData(bottom: 5.0, right: 7.0), - new TestParentData(top: 10.0, left: 10.0), + TestParentData(bottom: 5.0, right: 7.0), + TestParentData(top: 10.0, left: 10.0), kNonPositioned, ]); @@ -101,7 +101,7 @@ void main() { const DecoratedBox kDecoratedBoxC = DecoratedBox(decoration: kBoxDecorationC); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -120,13 +120,13 @@ void main() { ); checkTree(tester, [ - new TestParentData(bottom: 5.0, right: 7.0), - new TestParentData(top: 10.0, left: 10.0), + TestParentData(bottom: 5.0, right: 7.0), + TestParentData(top: 10.0, left: 10.0), kNonPositioned, ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -145,20 +145,20 @@ void main() { ); checkTree(tester, [ - new TestParentData(bottom: 6.0, right: 8.0), - new TestParentData(left: 10.0, right: 10.0), + TestParentData(bottom: 6.0, right: 8.0), + TestParentData(left: 10.0, right: 10.0), kNonPositioned, ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ kDecoratedBoxA, - new Positioned( + Positioned( left: 11.0, right: 12.0, - child: new Container(child: kDecoratedBoxB), + child: Container(child: kDecoratedBoxB), ), kDecoratedBoxC, ], @@ -167,20 +167,20 @@ void main() { checkTree(tester, [ kNonPositioned, - new TestParentData(left: 11.0, right: 12.0), + TestParentData(left: 11.0, right: 12.0), kNonPositioned, ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ kDecoratedBoxA, - new Positioned( + Positioned( right: 10.0, - child: new Container(child: kDecoratedBoxB), + child: Container(child: kDecoratedBoxB), ), - new Container( + Container( child: const Positioned( top: 8.0, child: kDecoratedBoxC, @@ -192,12 +192,12 @@ void main() { checkTree(tester, [ kNonPositioned, - new TestParentData(right: 10.0), - new TestParentData(top: 8.0), + TestParentData(right: 10.0), + TestParentData(top: 8.0), ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -209,18 +209,18 @@ void main() { ); checkTree(tester, [ - new TestParentData(right: 10.0), + TestParentData(right: 10.0), ]); flipStatefulWidget(tester); await tester.pump(); checkTree(tester, [ - new TestParentData(right: 10.0), + TestParentData(right: 10.0), ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -232,18 +232,18 @@ void main() { ); checkTree(tester, [ - new TestParentData(top: 7.0), + TestParentData(top: 7.0), ]); flipStatefulWidget(tester); await tester.pump(); checkTree(tester, [ - new TestParentData(top: 7.0), + TestParentData(top: 7.0), ]); await tester.pumpWidget( - new Stack(textDirection: TextDirection.ltr) + Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); @@ -251,7 +251,7 @@ void main() { testWidgets('ParentDataWidget conflicting data', (WidgetTester tester) async { await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -268,13 +268,13 @@ void main() { ); expect(tester.takeException(), isFlutterError); - await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr)); + await tester.pumpWidget(Stack(textDirection: TextDirection.ltr)); checkTree(tester, []); await tester.pumpWidget( - new Container( - child: new Row( + Container( + child: Row( children: const [ Positioned( top: 6.0, @@ -288,42 +288,42 @@ void main() { expect(tester.takeException(), isFlutterError); await tester.pumpWidget( - new Stack(textDirection: TextDirection.ltr) + Stack(textDirection: TextDirection.ltr) ); checkTree(tester, []); }); testWidgets('ParentDataWidget interacts with global keys', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Positioned( + Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox(key: key, decoration: kBoxDecorationA), + child: DecoratedBox(key: key, decoration: kBoxDecorationA), ), ], ), ); checkTree(tester, [ - new TestParentData(top: 10.0, left: 10.0), + TestParentData(top: 10.0, left: 10.0), ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Positioned( + Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox( + child: DecoratedBox( decoration: kBoxDecorationB, - child: new DecoratedBox(key: key, decoration: kBoxDecorationA), + child: DecoratedBox(key: key, decoration: kBoxDecorationA), ), ), ], @@ -331,35 +331,35 @@ void main() { ); checkTree(tester, [ - new TestParentData(top: 10.0, left: 10.0), + TestParentData(top: 10.0, left: 10.0), ]); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Positioned( + Positioned( top: 10.0, left: 10.0, - child: new DecoratedBox(key: key, decoration: kBoxDecorationA), + child: DecoratedBox(key: key, decoration: kBoxDecorationA), ), ], ), ); checkTree(tester, [ - new TestParentData(top: 10.0, left: 10.0), + TestParentData(top: 10.0, left: 10.0), ]); }); testWidgets('Parent data invalid ancestor', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( children: [ - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Expanded( - child: new Container() + Expanded( + child: Container() ), ], ), diff --git a/packages/flutter/test/widgets/performance_overlay_test.dart b/packages/flutter/test/widgets/performance_overlay_test.dart index 0cbc69c44c..35bb5e678d 100644 --- a/packages/flutter/test/widgets/performance_overlay_test.dart +++ b/packages/flutter/test/widgets/performance_overlay_test.dart @@ -8,6 +8,6 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Performance overlay smoke test', (WidgetTester tester) async { await tester.pumpWidget(const PerformanceOverlay()); - await tester.pumpWidget(new PerformanceOverlay.allEnabled()); + await tester.pumpWidget(PerformanceOverlay.allEnabled()); }); } diff --git a/packages/flutter/test/widgets/physical_model_test.dart b/packages/flutter/test/widgets/physical_model_test.dart index 89cfc80253..b48ba07fb1 100644 --- a/packages/flutter/test/widgets/physical_model_test.dart +++ b/packages/flutter/test/widgets/physical_model_test.dart @@ -6,14 +6,14 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('PhysicalModel - creates a physical model layer when it needs compositing', (WidgetTester tester) async { debugDisableShadows = false; - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new PhysicalModel( + child: PhysicalModel( shape: BoxShape.rectangle, color: Colors.grey, shadowColor: Colors.red, elevation: 1.0, - child: new Material(child: new TextField(controller: new TextEditingController())), + child: Material(child: TextField(controller: TextEditingController())), ), ), ); diff --git a/packages/flutter/test/widgets/placeholder_test.dart b/packages/flutter/test/widgets/placeholder_test.dart index 74ab191160..288d0875ef 100644 --- a/packages/flutter/test/widgets/placeholder_test.dart +++ b/packages/flutter/test/widgets/placeholder_test.dart @@ -13,11 +13,11 @@ void main() { expect(tester.renderObject(find.byType(Placeholder)).size, const Size(800.0, 600.0)); await tester.pumpWidget(const Center(child: Placeholder())); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(800.0, 600.0)); - await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: const [Positioned(top: 0.0, bottom: 0.0, child: Placeholder())])); + await tester.pumpWidget(Stack(textDirection: TextDirection.ltr, children: const [Positioned(top: 0.0, bottom: 0.0, child: Placeholder())])); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(400.0, 600.0)); - await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: const [Positioned(left: 0.0, right: 0.0, child: Placeholder())])); + await tester.pumpWidget(Stack(textDirection: TextDirection.ltr, children: const [Positioned(left: 0.0, right: 0.0, child: Placeholder())])); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(800.0, 400.0)); - await tester.pumpWidget(new Stack(textDirection: TextDirection.ltr, children: const [Positioned(top: 0.0, child: Placeholder(fallbackWidth: 200.0, fallbackHeight: 300.0))])); + await tester.pumpWidget(Stack(textDirection: TextDirection.ltr, children: const [Positioned(top: 0.0, child: Placeholder(fallbackWidth: 200.0, fallbackHeight: 300.0))])); expect(tester.renderObject(find.byType(Placeholder)).size, const Size(200.0, 300.0)); }); diff --git a/packages/flutter/test/widgets/platform_view_test.dart b/packages/flutter/test/widgets/platform_view_test.dart index 2bc4bdec4a..78d050c296 100644 --- a/packages/flutter/test/widgets/platform_view_test.dart +++ b/packages/flutter/test/widgets/platform_view_test.dart @@ -17,7 +17,7 @@ void main() { testWidgets('Create Android view', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( @@ -33,14 +33,14 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); }); testWidgets('Create Android view with params', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( @@ -60,7 +60,7 @@ void main() { final FakePlatformView fakeView = viewsController.views.first; final Uint8List rawCreationParams = fakeView.creationParams; - final ByteData byteData = new ByteData.view( + final ByteData byteData = ByteData.view( rawCreationParams.buffer, rawCreationParams.offsetInBytes, rawCreationParams.lengthInBytes @@ -71,13 +71,13 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, fakeView.creationParams) + FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr, fakeView.creationParams) ]), ); }); testWidgets('Zero sized Android view is not created', (WidgetTester tester) async { - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( @@ -98,7 +98,7 @@ void main() { testWidgets('Resize Android view', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( Center( @@ -110,7 +110,7 @@ void main() { ), ); - viewsController.resizeCompleter = new Completer(); + viewsController.resizeCompleter = Completer(); await tester.pumpWidget( Center( @@ -125,11 +125,11 @@ void main() { final Layer textureParentLayer = tester.layers[tester.layers.length - 2]; expect(textureParentLayer, isInstanceOf()); final ClipRectLayer clipRect = textureParentLayer; - expect(clipRect.clipRect, new Rect.fromLTWH(0.0, 0.0, 100.0, 50.0)); + expect(clipRect.clipRect, Rect.fromLTWH(0.0, 0.0, 100.0, 50.0)); expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); @@ -139,14 +139,14 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'webview', const Size(100.0, 50.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 1, 'webview', const Size(100.0, 50.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); }); testWidgets('Change Android view type', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); viewsController.registerViewType('maps'); await tester.pumpWidget( @@ -172,13 +172,13 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 2, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 2, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); }); testWidgets('Dispose Android view', (WidgetTester tester) async { - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( Center( @@ -207,26 +207,26 @@ void main() { testWidgets('Android view survives widget tree change', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( width: 200.0, height: 100.0, - child: new AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key), + child: AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key), ), ), ); await tester.pumpWidget( - new Center( - child: new Container( - child: new SizedBox( + Center( + child: Container( + child: SizedBox( width: 200.0, height: 100.0, - child: new AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key), + child: AndroidView(viewType: 'webview', layoutDirection: TextDirection.ltr, key: key), ), ), ), @@ -235,14 +235,14 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 1, 'webview', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); }); testWidgets('Android view gets touch events', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( Align( @@ -269,16 +269,16 @@ void main() { testWidgets('Android view transparent hit test behavior', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); int numPointerDownsOnParent = 0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Listener( + Listener( behavior: HitTestBehavior.opaque, onPointerDown: (PointerDownEvent e) { numPointerDownsOnParent++; }, ), @@ -312,16 +312,16 @@ void main() { testWidgets('Android view translucent hit test behavior', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); int numPointerDownsOnParent = 0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Listener( + Listener( behavior: HitTestBehavior.opaque, onPointerDown: (PointerDownEvent e) { numPointerDownsOnParent++; }, ), @@ -357,16 +357,16 @@ void main() { testWidgets('Android view opaque hit test behavior', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); int numPointerDownsOnParent = 0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Listener( + Listener( behavior: HitTestBehavior.opaque, onPointerDown: (PointerDownEvent e) { numPointerDownsOnParent++; }, ), @@ -402,12 +402,12 @@ void main() { testWidgets('Android view touch events are in virtual display\'s coordinate system', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Container( + child: Container( margin: const EdgeInsets.all(10.0), child: SizedBox( width: 200.0, @@ -432,7 +432,7 @@ void main() { testWidgets('Android view directionality', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('maps'); await tester.pumpWidget( Center( @@ -447,7 +447,7 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl) + FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl) ]), ); @@ -464,14 +464,14 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); }); testWidgets('Android view ambient directionality', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('maps'); await tester.pumpWidget( Directionality( @@ -489,7 +489,7 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl) + FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionRtl) ]), ); @@ -509,20 +509,20 @@ void main() { expect( viewsController.views, unorderedEquals([ - new FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) + FakePlatformView(currentViewId + 1, 'maps', const Size(200.0, 100.0), AndroidViewController.kAndroidLayoutDirectionLtr) ]), ); }); testWidgets('Android view can lose gesture arenas', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); bool verticalDragAcceptedByParent = false; await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Container( + child: Container( margin: const EdgeInsets.all(10.0), child: GestureDetector( onVerticalDragStart: (DragStartDetails d) { verticalDragAcceptedByParent = true; }, @@ -549,11 +549,11 @@ void main() { testWidgets('Android view gesture recognizers', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); bool verticalDragAcceptedByParent = false; await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, child: GestureDetector( onVerticalDragStart: (DragStartDetails d) { verticalDragAcceptedByParent = true; }, @@ -562,7 +562,7 @@ void main() { height: 100.0, child: AndroidView( viewType: 'webview', - gestureRecognizers: [new VerticalDragGestureRecognizer()], + gestureRecognizers: [VerticalDragGestureRecognizer()], layoutDirection: TextDirection.ltr, ), ), @@ -587,13 +587,13 @@ void main() { testWidgets('Android view can claim gesture after all pointers are up', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); bool verticalDragAcceptedByParent = false; // The long press recognizer rejects the gesture after the AndroidView gets the pointer up event. // This test makes sure that the Android view can win the gesture after it got the pointer up event. await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, child: GestureDetector( onVerticalDragStart: (DragStartDetails d) { verticalDragAcceptedByParent = true; }, @@ -625,10 +625,10 @@ void main() { testWidgets('Android view rebuilt during gesture', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, child: SizedBox( width: 200.0, @@ -645,7 +645,7 @@ void main() { await gesture.moveBy(const Offset(0.0, 100.0)); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, child: SizedBox( width: 200.0, @@ -672,10 +672,10 @@ void main() { testWidgets('Android view with eager gesture recognizer', (WidgetTester tester) async { final int currentViewId = platformViewsRegistry.getNextPlatformViewId(); - final FakePlatformViewsController viewsController = new FakePlatformViewsController(TargetPlatform.android); + final FakePlatformViewsController viewsController = FakePlatformViewsController(TargetPlatform.android); viewsController.registerViewType('webview'); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, child: GestureDetector( onVerticalDragStart: (DragStartDetails d) {}, @@ -684,7 +684,7 @@ void main() { height: 100.0, child: AndroidView( viewType: 'webview', - gestureRecognizers: [ new EagerGestureRecognizer() ], + gestureRecognizers: [ EagerGestureRecognizer() ], layoutDirection: TextDirection.ltr, ), ), diff --git a/packages/flutter/test/widgets/positioned_test.dart b/packages/flutter/test/widgets/positioned_test.dart index 454259ac8e..a73dfa9bb9 100644 --- a/packages/flutter/test/widgets/positioned_test.dart +++ b/packages/flutter/test/widgets/positioned_test.dart @@ -10,8 +10,8 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Positioned constructors', (WidgetTester tester) async { - final Widget child = new Container(); - final Positioned a = new Positioned( + final Widget child = Container(); + final Positioned a = Positioned( left: 101.0, right: 201.0, top: 301.0, @@ -24,8 +24,8 @@ void main() { expect(a.bottom, 401.0); expect(a.width, null); expect(a.height, null); - final Positioned b = new Positioned.fromRect( - rect: new Rect.fromLTRB( + final Positioned b = Positioned.fromRect( + rect: Rect.fromLTRB( 102.0, 302.0, 202.0, @@ -39,7 +39,7 @@ void main() { expect(b.bottom, null); expect(b.width, 100.0); expect(b.height, 200.0); - final Positioned c = new Positioned.fromRelativeRect( + final Positioned c = Positioned.fromRelativeRect( rect: const RelativeRect.fromLTRB( 103.0, 303.0, @@ -57,23 +57,23 @@ void main() { }); testWidgets('Can animate position data', (WidgetTester tester) async { - final RelativeRectTween rect = new RelativeRectTween( - begin: new RelativeRect.fromRect( - new Rect.fromLTRB(10.0, 20.0, 20.0, 30.0), - new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0), + final RelativeRectTween rect = RelativeRectTween( + begin: RelativeRect.fromRect( + Rect.fromLTRB(10.0, 20.0, 20.0, 30.0), + Rect.fromLTRB(0.0, 10.0, 100.0, 110.0), ), - end: new RelativeRect.fromRect( - new Rect.fromLTRB(80.0, 90.0, 90.0, 100.0), - new Rect.fromLTRB(0.0, 10.0, 100.0, 110.0), + end: RelativeRect.fromRect( + Rect.fromLTRB(80.0, 90.0, 90.0, 100.0), + Rect.fromLTRB(0.0, 10.0, 100.0, 110.0), ) ); - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(seconds: 10), vsync: tester, ); final List sizes = []; final List positions = []; - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); void recordMetrics() { final RenderBox box = key.currentContext.findRenderObject(); @@ -83,17 +83,17 @@ void main() { } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 100.0, width: 100.0, - child: new Stack( + child: Stack( children: [ - new PositionedTransition( + PositionedTransition( rect: rect.animate(controller), - child: new Container( + child: Container( key: key, ), ), @@ -104,7 +104,7 @@ void main() { ), ); // t=0 recordMetrics(); - final Completer completer = new Completer(); + final Completer completer = Completer(); controller.forward().whenComplete(completer.complete); expect(completer.isCompleted, isFalse); await tester.pump(); // t=0 again diff --git a/packages/flutter/test/widgets/raw_keyboard_listener_test.dart b/packages/flutter/test/widgets/raw_keyboard_listener_test.dart index db9cd55373..7a6d6cd1d4 100644 --- a/packages/flutter/test/widgets/raw_keyboard_listener_test.dart +++ b/packages/flutter/test/widgets/raw_keyboard_listener_test.dart @@ -18,21 +18,21 @@ void sendFakeKeyEvent(Map data) { void main() { testWidgets('Can dispose without keyboard', (WidgetTester tester) async { - final FocusNode focusNode = new FocusNode(); - await tester.pumpWidget(new RawKeyboardListener(focusNode: focusNode, onKey: null, child: new Container())); - await tester.pumpWidget(new RawKeyboardListener(focusNode: focusNode, onKey: null, child: new Container())); - await tester.pumpWidget(new Container()); + final FocusNode focusNode = FocusNode(); + await tester.pumpWidget(RawKeyboardListener(focusNode: focusNode, onKey: null, child: Container())); + await tester.pumpWidget(RawKeyboardListener(focusNode: focusNode, onKey: null, child: Container())); + await tester.pumpWidget(Container()); }); testWidgets('Fuchsia key event', (WidgetTester tester) async { final List events = []; - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); - await tester.pumpWidget(new RawKeyboardListener( + await tester.pumpWidget(RawKeyboardListener( focusNode: focusNode, onKey: events.add, - child: new Container(), + child: Container(), )); tester.binding.focusManager.rootScope.requestFocus(focusNode); @@ -55,7 +55,7 @@ void main() { expect(typedData.codePoint, 0x64); expect(typedData.modifiers, 0x08); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); focusNode.dispose(); }); @@ -63,12 +63,12 @@ void main() { (WidgetTester tester) async { final List events = []; - final FocusNode focusNode = new FocusNode(); + final FocusNode focusNode = FocusNode(); - await tester.pumpWidget(new RawKeyboardListener( + await tester.pumpWidget(RawKeyboardListener( focusNode: focusNode, onKey: events.add, - child: new Container(), + child: Container(), )); tester.binding.focusManager.rootScope.requestFocus(focusNode); @@ -86,7 +86,7 @@ void main() { expect(events.length, 1); events.clear(); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); sendFakeKeyEvent({ 'type': 'keydown', @@ -100,7 +100,7 @@ void main() { expect(events.length, 0); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); focusNode.dispose(); }); } diff --git a/packages/flutter/test/widgets/reassemble_test.dart b/packages/flutter/test/widgets/reassemble_test.dart index 21d683cbfa..c107812217 100644 --- a/packages/flutter/test/widgets/reassemble_test.dart +++ b/packages/flutter/test/widgets/reassemble_test.dart @@ -7,7 +7,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('reassemble does not crash', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: const Text('Hello World') )); await tester.pump(); diff --git a/packages/flutter/test/widgets/remember_scroll_position_test.dart b/packages/flutter/test/widgets/remember_scroll_position_test.dart index d6792ddf4c..8796a1d086 100644 --- a/packages/flutter/test/widgets/remember_scroll_position_test.dart +++ b/packages/flutter/test/widgets/remember_scroll_position_test.dart @@ -8,7 +8,7 @@ import 'package:meta/meta.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/material.dart'; -ScrollController _controller = new ScrollController( +ScrollController _controller = ScrollController( initialScrollOffset: 110.0, ); @@ -17,35 +17,35 @@ class ThePositiveNumbers extends StatelessWidget { final int from; @override Widget build(BuildContext context) { - return new ListView.builder( + return ListView.builder( key: const PageStorageKey('ThePositiveNumbers'), itemExtent: 100.0, controller: _controller, itemBuilder: (BuildContext context, int index) { - return new Text('${index + from}', key: new ValueKey(index)); + return Text('${index + from}', key: ValueKey(index)); } ); } } Future performTest(WidgetTester tester, bool maintainState) async { - final GlobalKey navigatorKey = new GlobalKey(); + final GlobalKey navigatorKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( key: navigatorKey, onGenerateRoute: (RouteSettings settings) { if (settings.name == '/') { - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, - builder: (_) => new Container(child: const ThePositiveNumbers(from: 0)), + builder: (_) => Container(child: const ThePositiveNumbers(from: 0)), maintainState: maintainState, ); } else if (settings.name == '/second') { - return new MaterialPageRoute( + return MaterialPageRoute( settings: settings, - builder: (_) => new Container(child: const ThePositiveNumbers(from: 10000)), + builder: (_) => Container(child: const ThePositiveNumbers(from: 10000)), maintainState: maintainState, ); } diff --git a/packages/flutter/test/widgets/render_object_widget_test.dart b/packages/flutter/test/widgets/render_object_widget_test.dart index 38d75ace98..1270df4402 100644 --- a/packages/flutter/test/widgets/render_object_widget_test.dart +++ b/packages/flutter/test/widgets/render_object_widget_test.dart @@ -6,9 +6,9 @@ import 'package:flutter_test/flutter_test.dart'; import 'package:flutter/rendering.dart'; import 'package:flutter/widgets.dart'; -final BoxDecoration kBoxDecorationA = new BoxDecoration(border: nonconst(null)); -final BoxDecoration kBoxDecorationB = new BoxDecoration(border: nonconst(null)); -final BoxDecoration kBoxDecorationC = new BoxDecoration(border: nonconst(null)); +final BoxDecoration kBoxDecorationA = BoxDecoration(border: nonconst(null)); +final BoxDecoration kBoxDecorationB = BoxDecoration(border: nonconst(null)); +final BoxDecoration kBoxDecorationC = BoxDecoration(border: nonconst(null)); class TestWidget extends StatelessWidget { const TestWidget({ this.child }); @@ -35,7 +35,7 @@ class TestOrientedBox extends SingleChildRenderObjectWidget { } @override - RenderDecoratedBox createRenderObject(BuildContext context) => new RenderDecoratedBox(decoration: _getDecoration(context)); + RenderDecoratedBox createRenderObject(BuildContext context) => RenderDecoratedBox(decoration: _getDecoration(context)); @override void updateRenderObject(BuildContext context, RenderDecoratedBox renderObject) { @@ -45,7 +45,7 @@ class TestOrientedBox extends SingleChildRenderObjectWidget { void main() { testWidgets('RenderObjectWidget smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationA)); + await tester.pumpWidget(DecoratedBox(decoration: kBoxDecorationA)); SingleChildRenderObjectElement element = tester.element(find.byElementType(SingleChildRenderObjectElement)); expect(element, isNotNull); @@ -54,7 +54,7 @@ void main() { expect(renderObject.decoration, equals(kBoxDecorationA)); expect(renderObject.position, equals(DecorationPosition.background)); - await tester.pumpWidget(new DecoratedBox(decoration: kBoxDecorationB)); + await tester.pumpWidget(DecoratedBox(decoration: kBoxDecorationB)); element = tester.element(find.byElementType(SingleChildRenderObjectElement)); expect(element, isNotNull); expect(element.renderObject is RenderDecoratedBox, isTrue); @@ -92,19 +92,19 @@ void main() { expect(renderObject.child, isNull); } - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA, - child: new DecoratedBox( + child: DecoratedBox( decoration: kBoxDecorationB ) )); checkFullTree(); - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA, - child: new TestWidget( - child: new DecoratedBox( + child: TestWidget( + child: DecoratedBox( decoration: kBoxDecorationB ) ) @@ -112,26 +112,26 @@ void main() { checkFullTree(); - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA, - child: new DecoratedBox( + child: DecoratedBox( decoration: kBoxDecorationB ) )); checkFullTree(); - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA )); childBareTree(); - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA, - child: new TestWidget( - child: new TestWidget( - child: new DecoratedBox( + child: TestWidget( + child: TestWidget( + child: DecoratedBox( decoration: kBoxDecorationB ) ) @@ -140,7 +140,7 @@ void main() { checkFullTree(); - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA )); @@ -149,11 +149,11 @@ void main() { testWidgets('Detached render tree is intact', (WidgetTester tester) async { - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA, - child: new DecoratedBox( + child: DecoratedBox( decoration: kBoxDecorationB, - child: new DecoratedBox( + child: DecoratedBox( decoration: kBoxDecorationC ) ) @@ -171,7 +171,7 @@ void main() { expect(grandChild.decoration, equals(kBoxDecorationC)); expect(grandChild.child, isNull); - await tester.pumpWidget(new DecoratedBox( + await tester.pumpWidget(DecoratedBox( decoration: kBoxDecorationA )); @@ -190,10 +190,10 @@ void main() { }); testWidgets('Can watch inherited widgets', (WidgetTester tester) async { - final Key boxKey = new UniqueKey(); - final TestOrientedBox box = new TestOrientedBox(key: boxKey); + final Key boxKey = UniqueKey(); + final TestOrientedBox box = TestOrientedBox(key: boxKey); - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(MediaQuery( data: const MediaQueryData(size: Size(400.0, 300.0)), child: box )); @@ -202,7 +202,7 @@ void main() { BoxDecoration decoration = renderBox.decoration; expect(decoration.color, equals(const Color(0xFF00FF00))); - await tester.pumpWidget(new MediaQuery( + await tester.pumpWidget(MediaQuery( data: const MediaQueryData(size: Size(300.0, 400.0)), child: box )); diff --git a/packages/flutter/test/widgets/reparent_state_harder_test.dart b/packages/flutter/test/widgets/reparent_state_harder_test.dart index a05de39e48..5967b5fd05 100644 --- a/packages/flutter/test/widgets/reparent_state_harder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_harder_test.dart @@ -14,7 +14,7 @@ class OrderSwitcher extends StatefulWidget { final Widget b; @override - OrderSwitcherState createState() => new OrderSwitcherState(); + OrderSwitcherState createState() => OrderSwitcherState(); } class OrderSwitcherState extends State { @@ -31,13 +31,13 @@ class OrderSwitcherState extends State { Widget build(BuildContext context) { final List children = []; if (_aFirst) { - children.add(new KeyedSubtree(child: widget.a)); + children.add(KeyedSubtree(child: widget.a)); children.add(widget.b); } else { - children.add(new KeyedSubtree(child: widget.b)); + children.add(KeyedSubtree(child: widget.b)); children.add(widget.a); } - return new Stack( + return Stack( textDirection: TextDirection.ltr, children: children, ); @@ -48,7 +48,7 @@ class DummyStatefulWidget extends StatefulWidget { const DummyStatefulWidget(Key key) : super(key: key); @override - DummyStatefulWidgetState createState() => new DummyStatefulWidgetState(); + DummyStatefulWidgetState createState() => DummyStatefulWidgetState(); } class DummyStatefulWidgetState extends State { @@ -61,7 +61,7 @@ class RekeyableDummyStatefulWidgetWrapper extends StatefulWidget { final Widget child; final GlobalKey initialKey; @override - RekeyableDummyStatefulWidgetWrapperState createState() => new RekeyableDummyStatefulWidgetWrapperState(); + RekeyableDummyStatefulWidgetWrapperState createState() => RekeyableDummyStatefulWidgetWrapperState(); } class RekeyableDummyStatefulWidgetWrapperState extends State { @@ -81,7 +81,7 @@ class RekeyableDummyStatefulWidgetWrapperState extends State keyRoot = new GlobalKey(debugLabel: 'Root'); - final GlobalKey keyA = new GlobalKey(debugLabel: 'A'); - final GlobalKey keyB = new GlobalKey(debugLabel: 'B'); - final GlobalKey keyC = new GlobalKey(debugLabel: 'C'); - final GlobalKey keyD = new GlobalKey(debugLabel: 'D'); - await tester.pumpWidget(new OrderSwitcher( + final GlobalKey keyRoot = GlobalKey(debugLabel: 'Root'); + final GlobalKey keyA = GlobalKey(debugLabel: 'A'); + final GlobalKey keyB = GlobalKey(debugLabel: 'B'); + final GlobalKey keyC = GlobalKey(debugLabel: 'C'); + final GlobalKey keyD = GlobalKey(debugLabel: 'D'); + await tester.pumpWidget(OrderSwitcher( key: keyRoot, - a: new KeyedSubtree( + a: KeyedSubtree( key: keyA, - child: new RekeyableDummyStatefulWidgetWrapper( + child: RekeyableDummyStatefulWidgetWrapper( initialKey: keyC ), ), - b: new KeyedSubtree( + b: KeyedSubtree( key: keyB, - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new Builder( + return Builder( builder: (BuildContext context) { - return new Builder( + return Builder( builder: (BuildContext context) { - return new LayoutBuilder( + return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new RekeyableDummyStatefulWidgetWrapper( + return RekeyableDummyStatefulWidgetWrapper( initialKey: keyD ); } diff --git a/packages/flutter/test/widgets/reparent_state_test.dart b/packages/flutter/test/widgets/reparent_state_test.dart index 6685596f5e..eec6c1fa16 100644 --- a/packages/flutter/test/widgets/reparent_state_test.dart +++ b/packages/flutter/test/widgets/reparent_state_test.dart @@ -11,7 +11,7 @@ class StateMarker extends StatefulWidget { final Widget child; @override - StateMarkerState createState() => new StateMarkerState(); + StateMarkerState createState() => StateMarkerState(); } class StateMarkerState extends State { @@ -21,7 +21,7 @@ class StateMarkerState extends State { Widget build(BuildContext context) { if (widget.child != null) return widget.child; - return new Container(); + return Container(); } } @@ -31,7 +31,7 @@ class DeactivateLogger extends StatefulWidget { final List log; @override - DeactivateLoggerState createState() => new DeactivateLoggerState(); + DeactivateLoggerState createState() => DeactivateLoggerState(); } class DeactivateLoggerState extends State { @@ -44,25 +44,25 @@ class DeactivateLoggerState extends State { @override Widget build(BuildContext context) { widget.log.add('build'); - return new Container(); + return Container(); } } void main() { testWidgets('can reparent state', (WidgetTester tester) async { - final GlobalKey left = new GlobalKey(); - final GlobalKey right = new GlobalKey(); + final GlobalKey left = GlobalKey(); + final GlobalKey right = GlobalKey(); const StateMarker grandchild = StateMarker(); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Container( - child: new StateMarker(key: left) + Container( + child: StateMarker(key: left) ), - new Container( - child: new StateMarker( + Container( + child: StateMarker( key: right, child: grandchild ) @@ -82,17 +82,17 @@ void main() { const StateMarker newGrandchild = StateMarker(); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new Container( - child: new StateMarker( + Container( + child: StateMarker( key: right, child: newGrandchild ) ), - new Container( - child: new StateMarker(key: left) + Container( + child: StateMarker(key: left) ), ] ) @@ -109,11 +109,11 @@ void main() { expect(newGrandchildState.marker, equals('grandchild')); await tester.pumpWidget( - new Center( - child: new Container( - child: new StateMarker( + Center( + child: Container( + child: StateMarker( key: left, - child: new Container() + child: Container() ) ) ) @@ -125,16 +125,16 @@ void main() { }); testWidgets('can reparent state with multichild widgets', (WidgetTester tester) async { - final GlobalKey left = new GlobalKey(); - final GlobalKey right = new GlobalKey(); + final GlobalKey left = GlobalKey(); + final GlobalKey right = GlobalKey(); const StateMarker grandchild = StateMarker(); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new StateMarker(key: left), - new StateMarker( + StateMarker(key: left), + StateMarker( key: right, child: grandchild ) @@ -153,14 +153,14 @@ void main() { const StateMarker newGrandchild = StateMarker(); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ - new StateMarker( + StateMarker( key: right, child: newGrandchild ), - new StateMarker(key: left) + StateMarker(key: left) ] ) ); @@ -176,11 +176,11 @@ void main() { expect(newGrandchildState.marker, equals('grandchild')); await tester.pumpWidget( - new Center( - child: new Container( - child: new StateMarker( + Center( + child: Container( + child: StateMarker( key: left, - child: new Container() + child: Container() ) ) ) @@ -192,23 +192,23 @@ void main() { }); testWidgets('can with scrollable list', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); - await tester.pumpWidget(new StateMarker(key: key)); + await tester.pumpWidget(StateMarker(key: key)); final StateMarkerState keyState = key.currentState; keyState.marker = 'marked'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 100.0, children: [ - new Container( + Container( key: const Key('container'), height: 100.0, - child: new StateMarker(key: key), + child: StateMarker(key: key), ), ], ), @@ -218,42 +218,42 @@ void main() { expect(key.currentState, equals(keyState)); expect(keyState.marker, equals('marked')); - await tester.pumpWidget(new StateMarker(key: key)); + await tester.pumpWidget(StateMarker(key: key)); expect(key.currentState, equals(keyState)); expect(keyState.marker, equals('marked')); }); testWidgets('Reparent during update children', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new StateMarker(key: key), - new Container(width: 100.0, height: 100.0), + StateMarker(key: key), + Container(width: 100.0, height: 100.0), ] )); final StateMarkerState keyState = key.currentState; keyState.marker = 'marked'; - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(width: 100.0, height: 100.0), - new StateMarker(key: key), + Container(width: 100.0, height: 100.0), + StateMarker(key: key), ] )); expect(key.currentState, equals(keyState)); expect(keyState.marker, equals('marked')); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new StateMarker(key: key), - new Container(width: 100.0, height: 100.0), + StateMarker(key: key), + Container(width: 100.0, height: 100.0), ] )); @@ -262,60 +262,60 @@ void main() { }); testWidgets('Reparent to child during update children', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(width: 100.0, height: 100.0), - new StateMarker(key: key), - new Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 100.0), + StateMarker(key: key), + Container(width: 100.0, height: 100.0), ] )); final StateMarkerState keyState = key.currentState; keyState.marker = 'marked'; - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(width: 100.0, height: 100.0, child: new StateMarker(key: key)), - new Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 100.0, child: StateMarker(key: key)), + Container(width: 100.0, height: 100.0), ] )); expect(key.currentState, equals(keyState)); expect(keyState.marker, equals('marked')); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(width: 100.0, height: 100.0), - new StateMarker(key: key), - new Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 100.0), + StateMarker(key: key), + Container(width: 100.0, height: 100.0), ] )); expect(key.currentState, equals(keyState)); expect(keyState.marker, equals('marked')); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(width: 100.0, height: 100.0), - new Container(width: 100.0, height: 100.0, child: new StateMarker(key: key)), + Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 100.0, child: StateMarker(key: key)), ] )); expect(key.currentState, equals(keyState)); expect(keyState.marker, equals('marked')); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Container(width: 100.0, height: 100.0), - new StateMarker(key: key), - new Container(width: 100.0, height: 100.0), + Container(width: 100.0, height: 100.0), + StateMarker(key: key), + Container(width: 100.0, height: 100.0), ] )); @@ -324,18 +324,18 @@ void main() { }); testWidgets('Deactivate implies build', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); final List log = []; - final DeactivateLogger logger = new DeactivateLogger(key: key, log: log); + final DeactivateLogger logger = DeactivateLogger(key: key, log: log); await tester.pumpWidget( - new Container(key: new UniqueKey(), child: logger) + Container(key: UniqueKey(), child: logger) ); expect(log, equals(['build'])); await tester.pumpWidget( - new Container(key: new UniqueKey(), child: logger) + Container(key: UniqueKey(), child: logger) ); expect(log, equals(['build', 'deactivate', 'build'])); @@ -346,21 +346,21 @@ void main() { }); testWidgets('Reparenting with multiple moves', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); - final GlobalKey key2 = new GlobalKey(); - final GlobalKey key3 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); + final GlobalKey key2 = GlobalKey(); + final GlobalKey key3 = GlobalKey(); await tester.pumpWidget( - new Row( + Row( textDirection: TextDirection.ltr, children: [ - new StateMarker( + StateMarker( key: key1, - child: new StateMarker( + child: StateMarker( key: key2, - child: new StateMarker( + child: StateMarker( key: key3, - child: new StateMarker(child: new Container(width: 100.0)) + child: StateMarker(child: Container(width: 100.0)) ) ) ) @@ -369,18 +369,18 @@ void main() { ); await tester.pumpWidget( - new Row( + Row( textDirection: TextDirection.ltr, children: [ - new StateMarker( + StateMarker( key: key2, - child: new StateMarker(child: new Container(width: 100.0)) + child: StateMarker(child: Container(width: 100.0)) ), - new StateMarker( + StateMarker( key: key1, - child: new StateMarker( + child: StateMarker( key: key3, - child: new StateMarker(child: new Container(width: 100.0)) + child: StateMarker(child: Container(width: 100.0)) ) ), ] diff --git a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart index 9005815a6e..8fef52227f 100644 --- a/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart +++ b/packages/flutter/test/widgets/reparent_state_with_layout_builder_test.dart @@ -11,11 +11,11 @@ import 'package:flutter_test/flutter_test.dart'; class Bar extends StatefulWidget { @override - BarState createState() => new BarState(); + BarState createState() => BarState(); } class BarState extends State { - final GlobalKey _fooKey = new GlobalKey(); + final GlobalKey _fooKey = GlobalKey(); bool _mode = false; @@ -28,17 +28,17 @@ class BarState extends State { @override Widget build(BuildContext context) { if (_mode) { - return new SizedBox( - child: new LayoutBuilder( + return SizedBox( + child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new StatefulCreationCounter(key: _fooKey); + return StatefulCreationCounter(key: _fooKey); }, ), ); } else { - return new LayoutBuilder( + return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new StatefulCreationCounter(key: _fooKey); + return StatefulCreationCounter(key: _fooKey); }, ); } @@ -49,7 +49,7 @@ class StatefulCreationCounter extends StatefulWidget { const StatefulCreationCounter({ Key key }) : super(key: key); @override - StatefulCreationCounterState createState() => new StatefulCreationCounterState(); + StatefulCreationCounterState createState() => StatefulCreationCounterState(); } class StatefulCreationCounterState extends State { @@ -62,14 +62,14 @@ class StatefulCreationCounterState extends State { } @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } void main() { testWidgets('reparent state with layout builder', (WidgetTester tester) async { expect(StatefulCreationCounterState.creationCount, 0); - await tester.pumpWidget(new Bar()); + await tester.pumpWidget(Bar()); expect(StatefulCreationCounterState.creationCount, 1); final BarState s = tester.state(find.byType(Bar)); s.trigger(); @@ -86,40 +86,40 @@ void main() { StateSetter layoutBuilderSetState; StateSetter childSetState; - final GlobalKey key = new GlobalKey(); - final Widget keyedWidget = new StatefulBuilder( + final GlobalKey key = GlobalKey(); + final Widget keyedWidget = StatefulBuilder( key: key, builder: (BuildContext context, StateSetter setState) { keyedSetState = setState; MediaQuery.of(context); - return new Container(); + return Container(); }, ); Widget layoutBuilderChild = keyedWidget; - Widget deepChild = new Container(); + Widget deepChild = Container(); - await tester.pumpWidget(new MediaQuery( - data: new MediaQueryData.fromWindow(ui.window), - child: new Column( + await tester.pumpWidget(MediaQuery( + data: MediaQueryData.fromWindow(ui.window), + child: Column( children: [ - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { layoutBuilderSetState = setState; - return new LayoutBuilder( + return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { layoutBuilderBuildCount += 1; return layoutBuilderChild; // initially keyedWidget above, but then a new Container }, ); }), - new Container( - child: new Container( - child: new Container( - child: new Container( - child: new Container( - child: new Container( - child: new StatefulBuilder(builder: + Container( + child: Container( + child: Container( + child: Container( + child: Container( + child: Container( + child: StatefulBuilder(builder: (BuildContext context, StateSetter setState) { childSetState = setState; return deepChild; // initially a Container, but then the keyedWidget above @@ -146,7 +146,7 @@ void main() { layoutBuilderSetState(() { // The layout builder will build in a separate build scope. This delays // the removal of the keyed child until this build scope. - layoutBuilderChild = new Container(); + layoutBuilderChild = Container(); }); // The essential part of this test is that this call to pump doesn't throw. diff --git a/packages/flutter/test/widgets/rotated_box_test.dart b/packages/flutter/test/widgets/rotated_box_test.dart index 3e003caa58..9884298365 100644 --- a/packages/flutter/test/widgets/rotated_box_test.dart +++ b/packages/flutter/test/widgets/rotated_box_test.dart @@ -8,28 +8,28 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Rotated box control test', (WidgetTester tester) async { final List log = []; - final Key rotatedBoxKey = new UniqueKey(); + final Key rotatedBoxKey = UniqueKey(); await tester.pumpWidget( - new Center( - child: new RotatedBox( + Center( + child: RotatedBox( key: rotatedBoxKey, quarterTurns: 1, - child: new Row( + child: Row( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, children: [ - new GestureDetector( + GestureDetector( onTap: () { log.add('left'); }, - child: new Container( + child: Container( width: 100.0, height: 40.0, color: Colors.blue[500], ), ), - new GestureDetector( + GestureDetector( onTap: () { log.add('right'); }, - child: new Container( + child: Container( width: 75.0, height: 65.0, color: Colors.blue[500], diff --git a/packages/flutter/test/widgets/routes_test.dart b/packages/flutter/test/widgets/routes_test.dart index 97718d1e63..c28c10d7aa 100644 --- a/packages/flutter/test/widgets/routes_test.dart +++ b/packages/flutter/test/widgets/routes_test.dart @@ -10,7 +10,7 @@ import 'package:flutter/widgets.dart'; final List results = []; -Set routes = new HashSet(); +Set routes = HashSet(); class TestRoute extends LocalHistoryRoute { TestRoute(this.name); @@ -28,8 +28,8 @@ class TestRoute extends LocalHistoryRoute { @override void install(OverlayEntry insertionPoint) { log('install'); - final OverlayEntry entry = new OverlayEntry( - builder: (BuildContext context) => new Container(), + final OverlayEntry entry = OverlayEntry( + builder: (BuildContext context) => Container(), opaque: true ); _entries.add(entry); @@ -115,13 +115,13 @@ void main() { }); testWidgets('Route management - push, replace, pop', (WidgetTester tester) async { - final GlobalKey navigatorKey = new GlobalKey(); + final GlobalKey navigatorKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( key: navigatorKey, - onGenerateRoute: (_) => new TestRoute('initial'), + onGenerateRoute: (_) => TestRoute('initial'), ), ), ); @@ -140,7 +140,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(second = new TestRoute('second')); }, + () { host.push(second = TestRoute('second')); }, [ 'second: install', 'second: didPush', @@ -151,7 +151,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(new TestRoute('third')); }, + () { host.push(TestRoute('third')); }, [ 'third: install', 'third: didPush', @@ -162,7 +162,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.replace(oldRoute: second, newRoute: new TestRoute('two')); }, + () { host.replace(oldRoute: second, newRoute: TestRoute('two')); }, [ 'two: install', 'two: didReplace second', @@ -191,20 +191,20 @@ void main() { 'initial: didPopNext two', ] ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(results, equals(['initial: dispose'])); expect(routes.isEmpty, isTrue); results.clear(); }); testWidgets('Route management - push, remove, pop', (WidgetTester tester) async { - final GlobalKey navigatorKey = new GlobalKey(); + final GlobalKey navigatorKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( key: navigatorKey, - onGenerateRoute: (_) => new TestRoute('first') + onGenerateRoute: (_) => TestRoute('first') ), ), ); @@ -223,7 +223,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(second = new TestRoute('second')); }, + () { host.push(second = TestRoute('second')); }, [ 'second: install', 'second: didPush', @@ -234,7 +234,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(new TestRoute('third')); }, + () { host.push(TestRoute('third')); }, [ 'third: install', 'third: didPush', @@ -263,7 +263,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(new TestRoute('three')); }, + () { host.push(TestRoute('three')); }, [ 'three: install', 'three: didPush', @@ -275,7 +275,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(four = new TestRoute('four')); }, + () { host.push(four = TestRoute('four')); }, [ 'four: install', 'four: didPush', @@ -302,20 +302,20 @@ void main() { 'second: didPopNext four', ] ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(results, equals(['second: dispose'])); expect(routes.isEmpty, isTrue); results.clear(); }); testWidgets('Route management - push, replace, popUntil', (WidgetTester tester) async { - final GlobalKey navigatorKey = new GlobalKey(); + final GlobalKey navigatorKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( key: navigatorKey, - onGenerateRoute: (_) => new TestRoute('A') + onGenerateRoute: (_) => TestRoute('A') ), ), ); @@ -333,7 +333,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(new TestRoute('B')); }, + () { host.push(TestRoute('B')); }, [ 'B: install', 'B: didPush', @@ -345,7 +345,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.push(routeC = new TestRoute('C')); }, + () { host.push(routeC = TestRoute('C')); }, [ 'C: install', 'C: didPush', @@ -358,7 +358,7 @@ void main() { await runNavigatorTest( tester, host, - () { host.replaceRouteBelow(anchorRoute: routeC, newRoute: routeB = new TestRoute('b')); }, + () { host.replaceRouteBelow(anchorRoute: routeC, newRoute: routeB = TestRoute('b')); }, [ 'b: install', 'b: didReplace B', @@ -377,25 +377,25 @@ void main() { 'b: didPopNext C', ] ); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect(results, equals(['A: dispose', 'b: dispose'])); expect(routes.isEmpty, isTrue); results.clear(); }); testWidgets('Route localHistory - popUntil', (WidgetTester tester) async { - final TestRoute routeA = new TestRoute('A'); - routeA.addLocalHistoryEntry(new LocalHistoryEntry( + final TestRoute routeA = TestRoute('A'); + routeA.addLocalHistoryEntry(LocalHistoryEntry( onRemove: () { routeA.log('onRemove 0'); } )); - routeA.addLocalHistoryEntry(new LocalHistoryEntry( + routeA.addLocalHistoryEntry(LocalHistoryEntry( onRemove: () { routeA.log('onRemove 1'); } )); - final GlobalKey navigatorKey = new GlobalKey(); + final GlobalKey navigatorKey = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( key: navigatorKey, onGenerateRoute: (_) => routeA ), @@ -428,14 +428,14 @@ void main() { group('PageRouteObserver', () { test('calls correct listeners', () { - final RouteObserver> observer = new RouteObserver>(); - final RouteAware pageRouteAware1 = new MockRouteAware(); - final MockPageRoute route1 = new MockPageRoute(); + final RouteObserver> observer = RouteObserver>(); + final RouteAware pageRouteAware1 = MockRouteAware(); + final MockPageRoute route1 = MockPageRoute(); observer.subscribe(pageRouteAware1, route1); verify(pageRouteAware1.didPush()).called(1); - final RouteAware pageRouteAware2 = new MockRouteAware(); - final MockPageRoute route2 = new MockPageRoute(); + final RouteAware pageRouteAware2 = MockRouteAware(); + final MockPageRoute route2 = MockPageRoute(); observer.didPush(route2, route1); verify(pageRouteAware1.didPushNext()).called(1); @@ -448,10 +448,10 @@ void main() { }); test('does not call listeners for non-PageRoute', () { - final RouteObserver> observer = new RouteObserver>(); - final RouteAware pageRouteAware = new MockRouteAware(); - final MockPageRoute pageRoute = new MockPageRoute(); - final MockRoute route = new MockRoute(); + final RouteObserver> observer = RouteObserver>(); + final RouteAware pageRouteAware = MockRouteAware(); + final MockPageRoute pageRoute = MockPageRoute(); + final MockRoute route = MockRoute(); observer.subscribe(pageRouteAware, pageRoute); verify(pageRouteAware.didPush()); @@ -461,19 +461,19 @@ void main() { }); test('does not call listeners when already subscribed', () { - final RouteObserver> observer = new RouteObserver>(); - final RouteAware pageRouteAware = new MockRouteAware(); - final MockPageRoute pageRoute = new MockPageRoute(); + final RouteObserver> observer = RouteObserver>(); + final RouteAware pageRouteAware = MockRouteAware(); + final MockPageRoute pageRoute = MockPageRoute(); observer.subscribe(pageRouteAware, pageRoute); observer.subscribe(pageRouteAware, pageRoute); verify(pageRouteAware.didPush()).called(1); }); test('does not call listeners when unsubscribed', () { - final RouteObserver> observer = new RouteObserver>(); - final RouteAware pageRouteAware = new MockRouteAware(); - final MockPageRoute pageRoute = new MockPageRoute(); - final MockPageRoute nextPageRoute = new MockPageRoute(); + final RouteObserver> observer = RouteObserver>(); + final RouteAware pageRouteAware = MockRouteAware(); + final MockPageRoute pageRoute = MockPageRoute(); + final MockPageRoute nextPageRoute = MockPageRoute(); observer.subscribe(pageRouteAware, pageRoute); observer.subscribe(pageRouteAware, nextPageRoute); verify(pageRouteAware.didPush()).called(2); diff --git a/packages/flutter/test/widgets/row_test.dart b/packages/flutter/test/widgets/row_test.dart index e5d0fb10d9..0ccc7d72ba 100644 --- a/packages/flutter/test/widgets/row_test.dart +++ b/packages/flutter/test/widgets/row_test.dart @@ -23,7 +23,7 @@ class OrderPainter extends CustomPainter { bool shouldRepaint(OrderPainter old) => false; } -Widget log(int index) => new CustomPaint(painter: new OrderPainter(index)); +Widget log(int index) => CustomPaint(painter: OrderPainter(index)); void main() { // NO DIRECTION @@ -42,13 +42,13 @@ void main() { }; // Default is MainAxisAlignment.start so this should fail, asking for a direction. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -73,13 +73,13 @@ void main() { }; // Default is MainAxisAlignment.start so this should fail too. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -103,13 +103,13 @@ void main() { }; // More than one child, so it's not clear what direction to lay out in: should fail. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), ], ), )); @@ -134,14 +134,14 @@ void main() { }; // No direction so this should fail, asking for a direction. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.end, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -166,14 +166,14 @@ void main() { }; // More than one child, so it's not clear what direction to lay out in: should fail. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -199,15 +199,15 @@ void main() { }; // More than one child, so it's not clear what direction to lay out in: should fail. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceAround, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), - new Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), ], ), )); @@ -232,14 +232,14 @@ void main() { }; // More than one child, so it's not clear what direction to lay out in: should fail. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ - new Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), ], ), )); @@ -263,13 +263,13 @@ void main() { }; // Default is MainAxisAlignment.start so this should fail, asking for a direction. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisSize: MainAxisSize.min, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), ], ), )); @@ -284,15 +284,15 @@ void main() { OrderPainter.log.clear(); const Key childKey = Key('childKey'); - await tester.pumpWidget(new Center( - child: new Container( + await tester.pumpWidget(Center( + child: Container( width: 0.0, height: 0.0, - child: new Row( + child: Row( mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Container( + Container( key: childKey, width: 100.0, height: 100.0, @@ -320,14 +320,14 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisAlignment.start so children so the children's // left edges should be at 0, 100, 700, child2's width should be 600 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -370,14 +370,14 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisAlignment.start so children so the children's // left edges should be at 0, 100, 200 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -418,14 +418,14 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's left edges should be at 300, 400 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.center, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), ], ), )); @@ -461,15 +461,15 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's left edges should be at 500, 600, 700. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, textDirection: TextDirection.ltr, mainAxisAlignment: MainAxisAlignment.end, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -511,15 +511,15 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's left edges should be at 0, 350, 700 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -562,16 +562,16 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's left edges should be at 50, 250, 450, 650 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceAround, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), - new Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), ], ), )); @@ -619,15 +619,15 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 200x100 children's left edges should be at 50, 300, 550 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), ], ), )); @@ -668,14 +668,14 @@ void main() { // Row with MainAxisSize.min without flexible children shrink wraps. // Row's width should be 250, children should be at 0, 100. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisSize: MainAxisSize.min, textDirection: TextDirection.ltr, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), ], ), )); @@ -706,16 +706,16 @@ void main() { OrderPainter.log.clear(); const Key childKey = Key('childKey'); - await tester.pumpWidget(new Center( - child: new Container( + await tester.pumpWidget(Center( + child: Container( width: 0.0, height: 0.0, - child: new Row( + child: Row( textDirection: TextDirection.ltr, mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Container( + Container( key: childKey, width: 100.0, height: 100.0, @@ -743,14 +743,14 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisAlignment.start so children so the children's // right edges should be at 0, 100, 700 from the right, child2's width should be 600 - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Expanded(child: new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Expanded(child: Container(key: child1Key, width: 100.0, height: 100.0, child: log(2))), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -793,14 +793,14 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // Default is MainAxisAlignment.start so children so the children's // right edges should be at 0, 100, 200 from the right - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -841,14 +841,14 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 300, 400 from the right - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.center, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), ], ), )); @@ -884,15 +884,15 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 500, 600, 700 from the right. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, textDirection: TextDirection.rtl, mainAxisAlignment: MainAxisAlignment.end, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -934,15 +934,15 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 0, 350, 700 from the right - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceBetween, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), ], ), )); @@ -985,16 +985,16 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 100x100 children's right edges should be at 50, 250, 450, 650 from the right - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceAround, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), - new Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 100.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 100.0, height: 100.0, child: log(3)), + Container(key: child3Key, width: 100.0, height: 100.0, child: log(4)), ], ), )); @@ -1042,15 +1042,15 @@ void main() { // Default is MainAxisSize.max so the Row should be as wide as the test: 800. // The 200x100 children's right edges should be at 50, 300, 550 from the right - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisAlignment: MainAxisAlignment.spaceEvenly, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), - new Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), + Container(key: child0Key, width: 200.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 200.0, height: 100.0, child: log(2)), + Container(key: child2Key, width: 200.0, height: 100.0, child: log(3)), ], ), )); @@ -1091,14 +1091,14 @@ void main() { // Row with MainAxisSize.min without flexible children shrink wraps. // Row's width should be 250, children should be at 0, 100 from right. - await tester.pumpWidget(new Center( - child: new Row( + await tester.pumpWidget(Center( + child: Row( key: rowKey, mainAxisSize: MainAxisSize.min, textDirection: TextDirection.rtl, children: [ - new Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), - new Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), + Container(key: child0Key, width: 100.0, height: 100.0, child: log(1)), + Container(key: child1Key, width: 150.0, height: 100.0, child: log(2)), ], ), )); @@ -1129,16 +1129,16 @@ void main() { OrderPainter.log.clear(); const Key childKey = Key('childKey'); - await tester.pumpWidget(new Center( - child: new Container( + await tester.pumpWidget(Center( + child: Container( width: 0.0, height: 0.0, - child: new Row( + child: Row( textDirection: TextDirection.rtl, mainAxisSize: MainAxisSize.min, mainAxisAlignment: MainAxisAlignment.center, children: [ - new Container( + Container( key: childKey, width: 100.0, height: 100.0, diff --git a/packages/flutter/test/widgets/rtl_test.dart b/packages/flutter/test/widgets/rtl_test.dart index 09dbb01ac3..b96776143a 100644 --- a/packages/flutter/test/widgets/rtl_test.dart +++ b/packages/flutter/test/widgets/rtl_test.dart @@ -44,18 +44,18 @@ void main() { }); testWidgets('Container padding/margin RTL', (WidgetTester tester) async { - final Widget child = new Container( + final Widget child = Container( padding: const EdgeInsetsDirectional.only(start: 6.0), margin: const EdgeInsetsDirectional.only(end: 20.0, start: 4.0), child: const Placeholder(), ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: child, )); expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(10.0, 0.0)); expect(tester.getTopRight(find.byType(Placeholder)), const Offset(780.0, 0.0)); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, child: child, )); @@ -64,18 +64,18 @@ void main() { }); testWidgets('Container padding/margin mixed RTL/absolute', (WidgetTester tester) async { - final Widget child = new Container( + final Widget child = Container( padding: const EdgeInsets.only(left: 6.0), margin: const EdgeInsetsDirectional.only(end: 20.0, start: 4.0), child: const Placeholder(), ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, child: child, )); expect(tester.getTopLeft(find.byType(Placeholder)), const Offset(10.0, 0.0)); expect(tester.getTopRight(find.byType(Placeholder)), const Offset(780.0, 0.0)); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.rtl, child: child, )); diff --git a/packages/flutter/test/widgets/run_app_test.dart b/packages/flutter/test/widgets/run_app_test.dart index 5a527224ca..777fb08cb3 100644 --- a/packages/flutter/test/widgets/run_app_test.dart +++ b/packages/flutter/test/widgets/run_app_test.dart @@ -8,10 +8,10 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('runApp inside onPressed does not throw', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Material( - child: new RaisedButton( + child: Material( + child: RaisedButton( onPressed: () { runApp(const Center(child: Text('Done', textDirection: TextDirection.ltr,))); }, diff --git a/packages/flutter/test/widgets/safe_area_test.dart b/packages/flutter/test/widgets/safe_area_test.dart index 02ea5b3df5..98fca7d8c9 100644 --- a/packages/flutter/test/widgets/safe_area_test.dart +++ b/packages/flutter/test/widgets/safe_area_test.dart @@ -89,12 +89,12 @@ void main() { group('SliverSafeArea', () { Widget buildWidget(EdgeInsets mediaPadding, Widget sliver) { - return new MediaQuery( - data: new MediaQueryData(padding: mediaPadding), - child: new Directionality( + return MediaQuery( + data: MediaQueryData(padding: mediaPadding), + child: Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(0.0), + child: Viewport( + offset: ViewportOffset.fixed(0.0), axisDirection: AxisDirection.down, slivers: [ const SliverToBoxAdapter(child: SizedBox(width: 800.0, height: 100.0, child: Text('before'))), @@ -111,7 +111,7 @@ void main() { (RenderBox target) { final Offset topLeft = target.localToGlobal(Offset.zero); final Offset bottomRight = target.localToGlobal(target.size.bottomRight(Offset.zero)); - return new Rect.fromPoints(topLeft, bottomRight); + return Rect.fromPoints(topLeft, bottomRight); } ).toList(); expect(testAnswers, equals(expectedRects)); @@ -128,9 +128,9 @@ void main() { ), ); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), - new Rect.fromLTWH(0.0, 120.0, 780.0, 100.0), - new Rect.fromLTWH(0.0, 240.0, 800.0, 100.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), + Rect.fromLTWH(0.0, 120.0, 780.0, 100.0), + Rect.fromLTWH(0.0, 240.0, 800.0, 100.0), ]); }); @@ -146,9 +146,9 @@ void main() { ), ); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), - new Rect.fromLTWH(20.0, 110.0, 760.0, 100.0), - new Rect.fromLTWH(0.0, 240.0, 800.0, 100.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), + Rect.fromLTWH(20.0, 110.0, 760.0, 100.0), + Rect.fromLTWH(0.0, 240.0, 800.0, 100.0), ]); }); @@ -166,9 +166,9 @@ void main() { ), ); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), - new Rect.fromLTWH(20.0, 120.0, 760.0, 100.0), - new Rect.fromLTWH(0.0, 240.0, 800.0, 100.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), + Rect.fromLTWH(20.0, 120.0, 760.0, 100.0), + Rect.fromLTWH(0.0, 240.0, 800.0, 100.0), ]); }); @@ -188,9 +188,9 @@ void main() { ), ); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), - new Rect.fromLTWH(20.0, 120.0, 760.0, 100.0), - new Rect.fromLTWH(0.0, 220.0, 800.0, 100.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), + Rect.fromLTWH(20.0, 120.0, 760.0, 100.0), + Rect.fromLTWH(0.0, 220.0, 800.0, 100.0), ]); await tester.pumpWidget( @@ -205,9 +205,9 @@ void main() { ), ); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), - new Rect.fromLTWH(100.0, 130.0, 700.0, 100.0), - new Rect.fromLTWH(0.0, 230.0, 800.0, 100.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 100.0), + Rect.fromLTWH(100.0, 130.0, 700.0, 100.0), + Rect.fromLTWH(0.0, 230.0, 800.0, 100.0), ]); }); }); diff --git a/packages/flutter/test/widgets/scroll_behavior_test.dart b/packages/flutter/test/widgets/scroll_behavior_test.dart index 19410d97b2..d23bc54aba 100644 --- a/packages/flutter/test/widgets/scroll_behavior_test.dart +++ b/packages/flutter/test/widgets/scroll_behavior_test.dart @@ -23,23 +23,23 @@ class TestScrollBehavior extends ScrollBehavior { void main() { testWidgets('Inherited ScrollConfiguration changed', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(debugLabel: 'scrollable'); + final GlobalKey key = GlobalKey(debugLabel: 'scrollable'); TestScrollBehavior behavior; ScrollPositionWithSingleContext position; - final Widget scrollView = new SingleChildScrollView( + final Widget scrollView = SingleChildScrollView( key: key, - child: new Builder( + child: Builder( builder: (BuildContext context) { behavior = ScrollConfiguration.of(context); position = Scrollable.of(context).position; - return new Container(height: 1000.0); + return Container(height: 1000.0); }, ), ); await tester.pumpWidget( - new ScrollConfiguration( + ScrollConfiguration( behavior: const TestScrollBehavior(true), child: scrollView, ), @@ -54,7 +54,7 @@ void main() { // Same Scrollable, different ScrollConfiguration await tester.pumpWidget( - new ScrollConfiguration( + ScrollConfiguration( behavior: const TestScrollBehavior(false), child: scrollView, ), diff --git a/packages/flutter/test/widgets/scroll_controller_test.dart b/packages/flutter/test/widgets/scroll_controller_test.dart index 7a5bb5a1a9..c408add4c6 100644 --- a/packages/flutter/test/widgets/scroll_controller_test.dart +++ b/packages/flutter/test/widgets/scroll_controller_test.dart @@ -9,17 +9,17 @@ import 'states.dart'; void main() { testWidgets('ScrollController control test', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container( + return Container( height: 200.0, - child: new Text(state), + child: Text(state), ); }).toList(), ), @@ -50,15 +50,15 @@ void main() { expect(realOffset(), equals(controller.offset)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( key: const Key('second'), controller: controller, children: kStates.map((String state) { - return new Container( + return Container( height: 200.0, - child: new Text(state), + child: Text(state), ); }).toList(), ), @@ -73,18 +73,18 @@ void main() { expect(controller.offset, equals(653.0)); expect(realOffset(), equals(controller.offset)); - final ScrollController controller2 = new ScrollController(); + final ScrollController controller2 = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( key: const Key('second'), controller: controller2, children: kStates.map((String state) { - return new Container( + return Container( height: 200.0, - child: new Text(state), + child: Text(state), ); }).toList(), ), @@ -99,16 +99,16 @@ void main() { expect(() => controller.animateTo(132.0, duration: const Duration(milliseconds: 300), curve: Curves.ease), throwsAssertionError); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( key: const Key('second'), controller: controller2, physics: const BouncingScrollPhysics(), children: kStates.map((String state) { - return new Container( + return Container( height: 200.0, - child: new Text(state), + child: Text(state), ); }).toList(), ), @@ -130,17 +130,17 @@ void main() { }); testWidgets('ScrollController control test', (WidgetTester tester) async { - final ScrollController controller = new ScrollController( + final ScrollController controller = ScrollController( initialScrollOffset: 209.0, ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( crossAxisCount: 4, controller: controller, - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), ), ); @@ -160,12 +160,12 @@ void main() { expect(realOffset(), equals(controller.offset)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( crossAxisCount: 2, controller: controller, - children: kStates.map((String state) => new Text(state)).toList(), + children: kStates.map((String state) => Text(state)).toList(), ), ), ); @@ -175,14 +175,14 @@ void main() { }); testWidgets('DrivenScrollActivity ending after dispose', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, - children: [ new Container(height: 200000.0) ], + children: [ Container(height: 200000.0) ], ), ), ); @@ -192,37 +192,37 @@ void main() { await tester.pump(); // Start the animation. // We will now change the tree on the same frame as the animation ends. - await tester.pumpWidget(new Container(), const Duration(seconds: 2)); + await tester.pumpWidget(Container(), const Duration(seconds: 2)); }); testWidgets('Read operations on ScrollControllers with no positions fail', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); expect(() => controller.offset, throwsAssertionError); expect(() => controller.position, throwsAssertionError); }); testWidgets('Read operations on ScrollControllers with more than one position fail', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: [ - new Container( + Container( constraints: const BoxConstraints(maxHeight: 500.0), - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container(height: 200.0, child: new Text(state)); + return Container(height: 200.0, child: Text(state)); }).toList(), ), ), - new Container( + Container( constraints: const BoxConstraints(maxHeight: 500.0), - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container(height: 200.0, child: new Text(state)); + return Container(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -236,33 +236,33 @@ void main() { }); testWidgets('Write operations on ScrollControllers with no positions fail', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); expect(() => controller.animateTo(1.0, duration: const Duration(seconds: 1), curve: Curves.linear), throwsAssertionError); expect(() => controller.jumpTo(1.0), throwsAssertionError); }); testWidgets('Write operations on ScrollControllers with more than one position do not throw', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: [ - new Container( + Container( constraints: const BoxConstraints(maxHeight: 500.0), - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container(height: 200.0, child: new Text(state)); + return Container(height: 200.0, child: Text(state)); }).toList(), ), ), - new Container( + Container( constraints: const BoxConstraints(maxHeight: 500.0), - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container(height: 200.0, child: new Text(state)); + return Container(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -277,7 +277,7 @@ void main() { }); testWidgets('Scroll controllers notify when the position changes', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); final List log = []; @@ -286,12 +286,12 @@ void main() { }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container(height: 200.0, child: new Text(state)); + return Container(height: 200.0, child: Text(state)); }).toList(), ), ), @@ -311,20 +311,20 @@ void main() { }); testWidgets('keepScrollOffset', (WidgetTester tester) async { - final PageStorageBucket bucket = new PageStorageBucket(); + final PageStorageBucket bucket = PageStorageBucket(); Widget buildFrame(ScrollController controller) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new PageStorage( + child: PageStorage( bucket: bucket, - child: new KeyedSubtree( + child: KeyedSubtree( key: const PageStorageKey('ListView'), - child: new ListView( - key: new UniqueKey(), // it's a different ListView every time + child: ListView( + key: UniqueKey(), // it's a different ListView every time controller: controller, - children: new List.generate(50, (int index) { - return new Container(height: 100.0, child: new Text('Item $index')); + children: List.generate(50, (int index) { + return Container(height: 100.0, child: Text('Item $index')); }).toList(), ), ), @@ -337,7 +337,7 @@ void main() { // The initialScrollOffset is used in this case, because there's no saved // scroll offset. - ScrollController controller = new ScrollController(initialScrollOffset: 200.0); + ScrollController controller = ScrollController(initialScrollOffset: 200.0); await tester.pumpWidget(buildFrame(controller)); expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 2')), Offset.zero); @@ -347,7 +347,7 @@ void main() { // The initialScrollOffset isn't used in this case, because the scrolloffset // can be restored. - controller = new ScrollController(initialScrollOffset: 25.0); + controller = ScrollController(initialScrollOffset: 25.0); await tester.pumpWidget(buildFrame(controller)); expect(controller.offset, 2000.0); expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 20')), Offset.zero); @@ -356,7 +356,7 @@ void main() { // when the ListView is recreated with a new ScrollController and // the initialScrollOffset is used. - controller = new ScrollController(keepScrollOffset: false, initialScrollOffset: 100.0); + controller = ScrollController(keepScrollOffset: false, initialScrollOffset: 100.0); await tester.pumpWidget(buildFrame(controller)); expect(controller.offset, 100.0); expect(tester.getTopLeft(find.widgetWithText(Container, 'Item 1')), Offset.zero); diff --git a/packages/flutter/test/widgets/scroll_events_test.dart b/packages/flutter/test/widgets/scroll_events_test.dart index 5b47666799..83ba680827 100644 --- a/packages/flutter/test/widgets/scroll_events_test.dart +++ b/packages/flutter/test/widgets/scroll_events_test.dart @@ -9,7 +9,7 @@ import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; Widget _buildScroller({ List log }) { - return new NotificationListener( + return NotificationListener( onNotification: (ScrollNotification notification) { if (notification is ScrollStartNotification) { log.add('scroll-start'); @@ -20,15 +20,15 @@ Widget _buildScroller({ List log }) { } return false; }, - child: new SingleChildScrollView( - child: new Container(width: 1000.0, height: 1000.0), + child: SingleChildScrollView( + child: Container(width: 1000.0, height: 1000.0), ), ); } void main() { Completer animateTo(WidgetTester tester, double newScrollOffset, { @required Duration duration }) { - final Completer completer = new Completer(); + final Completer completer = Completer(); final ScrollableState scrollable = tester.state(find.byType(Scrollable)); scrollable.position.animateTo(newScrollOffset, duration: duration, curve: Curves.linear).whenComplete(completer.complete); return completer; diff --git a/packages/flutter/test/widgets/scroll_interaction_test.dart b/packages/flutter/test/widgets/scroll_interaction_test.dart index 014f198554..0779eef7a6 100644 --- a/packages/flutter/test/widgets/scroll_interaction_test.dart +++ b/packages/flutter/test/widgets/scroll_interaction_test.dart @@ -8,11 +8,11 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Scroll flings twice in a row does not crash', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: [ - new Container(height: 100000.0) + Container(height: 100000.0) ], ), ), diff --git a/packages/flutter/test/widgets/scroll_notification_test.dart b/packages/flutter/test/widgets/scroll_notification_test.dart index 070f4dded1..5d7aedfe18 100644 --- a/packages/flutter/test/widgets/scroll_notification_test.dart +++ b/packages/flutter/test/widgets/scroll_notification_test.dart @@ -10,13 +10,13 @@ void main() { testWidgets('Scroll notification basics', (WidgetTester tester) async { ScrollNotification notification; - await tester.pumpWidget(new NotificationListener( + await tester.pumpWidget(NotificationListener( onNotification: (ScrollNotification value) { if (value is ScrollStartNotification || value is ScrollUpdateNotification || value is ScrollEndNotification) notification = value; return false; }, - child: new SingleChildScrollView( + child: SingleChildScrollView( child: const SizedBox(height: 1200.0) ) )); @@ -53,24 +53,24 @@ void main() { final List depth0Values = []; final List depth1Values = []; - await tester.pumpWidget(new NotificationListener( + await tester.pumpWidget(NotificationListener( onNotification: (ScrollNotification value) { depth1Types.add(value.runtimeType); depth1Values.add(value.depth); return false; }, - child: new SingleChildScrollView( - child: new SizedBox( + child: SingleChildScrollView( + child: SizedBox( height: 1200.0, - child: new NotificationListener( + child: NotificationListener( onNotification: (ScrollNotification value) { depth0Types.add(value.runtimeType); depth0Values.add(value.depth); return false; }, - child: new Container( + child: Container( padding: const EdgeInsets.all(50.0), - child: new SingleChildScrollView(child: const SizedBox(height: 1200.0)) + child: SingleChildScrollView(child: const SizedBox(height: 1200.0)) ) ) ) diff --git a/packages/flutter/test/widgets/scroll_physics_test.dart b/packages/flutter/test/widgets/scroll_physics_test.dart index 30255738b8..665b1376f2 100644 --- a/packages/flutter/test/widgets/scroll_physics_test.dart +++ b/packages/flutter/test/widgets/scroll_physics_test.dart @@ -11,7 +11,7 @@ class TestScrollPhysics extends ScrollPhysics { @override TestScrollPhysics applyTo(ScrollPhysics ancestor) { - return new TestScrollPhysics(name: name, parent: parent?.applyTo(ancestor) ?? ancestor); + return TestScrollPhysics(name: name, parent: parent?.applyTo(ancestor) ?? ancestor); } TestScrollPhysics get namedParent => parent; @@ -84,7 +84,7 @@ void main() { }); test('overscroll is progressively harder', () { - final ScrollMetrics lessOverscrolledPosition = new FixedScrollMetrics( + final ScrollMetrics lessOverscrolledPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 1000.0, pixels: -20.0, @@ -92,7 +92,7 @@ void main() { axisDirection: AxisDirection.down, ); - final ScrollMetrics moreOverscrolledPosition = new FixedScrollMetrics( + final ScrollMetrics moreOverscrolledPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 1000.0, pixels: -40.0, @@ -117,7 +117,7 @@ void main() { }); test('easing an overscroll still has resistance', () { - final ScrollMetrics overscrolledPosition = new FixedScrollMetrics( + final ScrollMetrics overscrolledPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 1000.0, pixels: -20.0, @@ -133,7 +133,7 @@ void main() { }); test('no resistance when not overscrolled', () { - final ScrollMetrics scrollPosition = new FixedScrollMetrics( + final ScrollMetrics scrollPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 1000.0, pixels: 300.0, @@ -146,7 +146,7 @@ void main() { }); test('easing an overscroll meets less resistance than tensioning', () { - final ScrollMetrics overscrolledPosition = new FixedScrollMetrics( + final ScrollMetrics overscrolledPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 1000.0, pixels: -20.0, @@ -163,7 +163,7 @@ void main() { }); test('overscroll a small list and a big list works the same way', () { - final ScrollMetrics smallListOverscrolledPosition = new FixedScrollMetrics( + final ScrollMetrics smallListOverscrolledPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 10.0, pixels: -20.0, @@ -171,7 +171,7 @@ void main() { axisDirection: AxisDirection.down, ); - final ScrollMetrics bigListOverscrolledPosition = new FixedScrollMetrics( + final ScrollMetrics bigListOverscrolledPosition = FixedScrollMetrics( minScrollExtent: 0.0, maxScrollExtent: 1000.0, pixels: -20.0, diff --git a/packages/flutter/test/widgets/scroll_simulation_test.dart b/packages/flutter/test/widgets/scroll_simulation_test.dart index 23ed2c8d5c..a47545d99c 100644 --- a/packages/flutter/test/widgets/scroll_simulation_test.dart +++ b/packages/flutter/test/widgets/scroll_simulation_test.dart @@ -8,7 +8,7 @@ import 'package:flutter/widgets.dart'; void main() { test('ClampingScrollSimulation has a stable initial conditions', () { void checkInitialConditions(double position, double velocity) { - final ClampingScrollSimulation simulation = new ClampingScrollSimulation(position: position, velocity: velocity); + final ClampingScrollSimulation simulation = ClampingScrollSimulation(position: position, velocity: velocity); expect(simulation.x(0.0), closeTo(position, 0.00001)); expect(simulation.dx(0.0), closeTo(velocity, 0.00001)); } diff --git a/packages/flutter/test/widgets/scroll_view_test.dart b/packages/flutter/test/widgets/scroll_view_test.dart index fcc6498eea..5df19046f2 100644 --- a/packages/flutter/test/widgets/scroll_view_test.dart +++ b/packages/flutter/test/widgets/scroll_view_test.dart @@ -12,18 +12,18 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: kStates.map((String state) { - return new GestureDetector( + return GestureDetector( onTap: () { log.add(state); }, - child: new Container( + child: Container( height: 200.0, color: const Color(0xFF0000FF), - child: new Text(state), + child: Text(state), ), ); }).toList(), @@ -50,14 +50,14 @@ void main() { testWidgets('ListView restart ballistic activity out of range', (WidgetTester tester) async { Widget buildListView(int n) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: kStates.take(n).map((String state) { - return new Container( + return Container( height: 200.0, color: const Color(0xFF0000FF), - child: new Text(state), + child: Text(state), ); }).toList(), ), @@ -81,21 +81,21 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new SliverList( - delegate: new SliverChildListDelegate( + SliverList( + delegate: SliverChildListDelegate( kStates.map((String state) { - return new GestureDetector( + return GestureDetector( onTap: () { log.add(state); }, - child: new Container( + child: Container( height: 200.0, color: const Color(0xFF0000FF), - child: new Text(state), + child: Text(state), ), ); }).toList(), @@ -125,22 +125,22 @@ void main() { testWidgets('Can jumpTo during drag', (WidgetTester tester) async { final List log = []; - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (ScrollNotification notification) { log.add(notification.runtimeType); return false; }, - child: new ListView( + child: ListView( controller: controller, children: kStates.map((String state) { - return new Container( + return Container( height: 200.0, - child: new Text(state), + child: Text(state), ); }).toList(), ), @@ -182,17 +182,17 @@ void main() { }); testWidgets('Vertical CustomScrollViews are primary by default', (WidgetTester tester) async { - final CustomScrollView view = new CustomScrollView(scrollDirection: Axis.vertical); + final CustomScrollView view = CustomScrollView(scrollDirection: Axis.vertical); expect(view.primary, isTrue); }); testWidgets('Vertical ListViews are primary by default', (WidgetTester tester) async { - final ListView view = new ListView(scrollDirection: Axis.vertical); + final ListView view = ListView(scrollDirection: Axis.vertical); expect(view.primary, isTrue); }); testWidgets('Vertical GridViews are primary by default', (WidgetTester tester) async { - final GridView view = new GridView.count( + final GridView view = GridView.count( scrollDirection: Axis.vertical, crossAxisCount: 1, ); @@ -200,17 +200,17 @@ void main() { }); testWidgets('Horizontal CustomScrollViews are non-primary by default', (WidgetTester tester) async { - final CustomScrollView view = new CustomScrollView(scrollDirection: Axis.horizontal); + final CustomScrollView view = CustomScrollView(scrollDirection: Axis.horizontal); expect(view.primary, isFalse); }); testWidgets('Horizontal ListViews are non-primary by default', (WidgetTester tester) async { - final ListView view = new ListView(scrollDirection: Axis.horizontal); + final ListView view = ListView(scrollDirection: Axis.horizontal); expect(view.primary, isFalse); }); testWidgets('Horizontal GridViews are non-primary by default', (WidgetTester tester) async { - final GridView view = new GridView.count( + final GridView view = GridView.count( scrollDirection: Axis.horizontal, crossAxisCount: 1, ); @@ -218,24 +218,24 @@ void main() { }); testWidgets('CustomScrollViews with controllers are non-primary by default', (WidgetTester tester) async { - final CustomScrollView view = new CustomScrollView( - controller: new ScrollController(), + final CustomScrollView view = CustomScrollView( + controller: ScrollController(), scrollDirection: Axis.vertical, ); expect(view.primary, isFalse); }); testWidgets('ListViews with controllers are non-primary by default', (WidgetTester tester) async { - final ListView view = new ListView( - controller: new ScrollController(), + final ListView view = ListView( + controller: ScrollController(), scrollDirection: Axis.vertical, ); expect(view.primary, isFalse); }); testWidgets('GridViews with controllers are non-primary by default', (WidgetTester tester) async { - final GridView view = new GridView.count( - controller: new ScrollController(), + final GridView view = GridView.count( + controller: ScrollController(), scrollDirection: Axis.vertical, crossAxisCount: 1, ); @@ -243,13 +243,13 @@ void main() { }); testWidgets('CustomScrollView sets PrimaryScrollController when primary', (WidgetTester tester) async { - final ScrollController primaryScrollController = new ScrollController(); + final ScrollController primaryScrollController = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new PrimaryScrollController( + child: PrimaryScrollController( controller: primaryScrollController, - child: new CustomScrollView(primary: true), + child: CustomScrollView(primary: true), ), ), ); @@ -258,13 +258,13 @@ void main() { }); testWidgets('ListView sets PrimaryScrollController when primary', (WidgetTester tester) async { - final ScrollController primaryScrollController = new ScrollController(); + final ScrollController primaryScrollController = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new PrimaryScrollController( + child: PrimaryScrollController( controller: primaryScrollController, - child: new ListView(primary: true), + child: ListView(primary: true), ), ), ); @@ -273,13 +273,13 @@ void main() { }); testWidgets('GridView sets PrimaryScrollController when primary', (WidgetTester tester) async { - final ScrollController primaryScrollController = new ScrollController(); + final ScrollController primaryScrollController = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new PrimaryScrollController( + child: PrimaryScrollController( controller: primaryScrollController, - child: new GridView.count(primary: true, crossAxisCount: 1), + child: GridView.count(primary: true, crossAxisCount: 1), ), ), ); @@ -289,18 +289,18 @@ void main() { testWidgets('Nested scrollables have a null PrimaryScrollController', (WidgetTester tester) async { const Key innerKey = Key('inner'); - final ScrollController primaryScrollController = new ScrollController(); + final ScrollController primaryScrollController = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new PrimaryScrollController( + child: PrimaryScrollController( controller: primaryScrollController, - child: new ListView( + child: ListView( primary: true, children: [ - new Container( + Container( constraints: const BoxConstraints(maxHeight: 200.0), - child: new ListView(key: innerKey, primary: true), + child: ListView(key: innerKey, primary: true), ), ], ), @@ -318,33 +318,33 @@ void main() { }); testWidgets('Primary ListViews are always scrollable', (WidgetTester tester) async { - final ListView view = new ListView(primary: true); + final ListView view = ListView(primary: true); expect(view.physics, isInstanceOf()); }); testWidgets('Non-primary ListViews are not always scrollable', (WidgetTester tester) async { - final ListView view = new ListView(primary: false); + final ListView view = ListView(primary: false); expect(view.physics, isNot(isInstanceOf())); }); testWidgets('Defaulting-to-primary ListViews are always scrollable', (WidgetTester tester) async { - final ListView view = new ListView(scrollDirection: Axis.vertical); + final ListView view = ListView(scrollDirection: Axis.vertical); expect(view.physics, isInstanceOf()); }); testWidgets('Defaulting-to-not-primary ListViews are not always scrollable', (WidgetTester tester) async { - final ListView view = new ListView(scrollDirection: Axis.horizontal); + final ListView view = ListView(scrollDirection: Axis.horizontal); expect(view.physics, isNot(isInstanceOf())); }); testWidgets('primary:true leads to scrolling', (WidgetTester tester) async { bool scrolled = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (OverscrollNotification message) { scrolled = true; return false; }, - child: new ListView( + child: ListView( primary: true, children: const [], ), @@ -358,11 +358,11 @@ void main() { testWidgets('primary:false leads to no scrolling', (WidgetTester tester) async { bool scrolled = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (OverscrollNotification message) { scrolled = true; return false; }, - child: new ListView( + child: ListView( primary: false, children: const [], ), @@ -376,11 +376,11 @@ void main() { testWidgets('physics:AlwaysScrollableScrollPhysics actually overrides primary:false default behavior', (WidgetTester tester) async { bool scrolled = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (OverscrollNotification message) { scrolled = true; return false; }, - child: new ListView( + child: ListView( primary: false, physics: const AlwaysScrollableScrollPhysics(), children: const [], @@ -395,11 +395,11 @@ void main() { testWidgets('physics:ScrollPhysics actually overrides primary:true default behavior', (WidgetTester tester) async { bool scrolled = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new NotificationListener( + child: NotificationListener( onNotification: (OverscrollNotification message) { scrolled = true; return false; }, - child: new ListView( + child: ListView( primary: true, physics: const ScrollPhysics(), children: const [], diff --git a/packages/flutter/test/widgets/scrollable_animations_test.dart b/packages/flutter/test/widgets/scrollable_animations_test.dart index bbe3d391bb..1909f38964 100644 --- a/packages/flutter/test/widgets/scrollable_animations_test.dart +++ b/packages/flutter/test/widgets/scrollable_animations_test.dart @@ -10,12 +10,12 @@ void main() { testWidgets('Does not animate if already at target position', (WidgetTester tester) async { final List textWidgets = []; for (int i = 0; i < 80; i++) - textWidgets.add(new Text('$i', textDirection: TextDirection.ltr)); - final ScrollController controller = new ScrollController(); + textWidgets.add(Text('$i', textDirection: TextDirection.ltr)); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: textWidgets, controller: controller, ), @@ -33,12 +33,12 @@ void main() { testWidgets('Does not animate if already at target position within tolerance', (WidgetTester tester) async { final List textWidgets = []; for (int i = 0; i < 80; i++) - textWidgets.add(new Text('$i', textDirection: TextDirection.ltr)); - final ScrollController controller = new ScrollController(); + textWidgets.add(Text('$i', textDirection: TextDirection.ltr)); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: textWidgets, controller: controller, ), @@ -59,12 +59,12 @@ void main() { testWidgets('Animates if going to a position outside of tolerance', (WidgetTester tester) async { final List textWidgets = []; for (int i = 0; i < 80; i++) - textWidgets.add(new Text('$i', textDirection: TextDirection.ltr)); - final ScrollController controller = new ScrollController(); + textWidgets.add(Text('$i', textDirection: TextDirection.ltr)); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( children: textWidgets, controller: controller, ), diff --git a/packages/flutter/test/widgets/scrollable_dispose_test.dart b/packages/flutter/test/widgets/scrollable_dispose_test.dart index c414841c2d..a55d47496d 100644 --- a/packages/flutter/test/widgets/scrollable_dispose_test.dart +++ b/packages/flutter/test/widgets/scrollable_dispose_test.dart @@ -11,13 +11,13 @@ void main() { testWidgets('simultaneously dispose a widget and end the scroll animation', (WidgetTester tester) async { final List textWidgets = []; for (int i = 0; i < 250; i++) - textWidgets.add(new Text('$i')); + textWidgets.add(Text('$i')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new FlipWidget( - left: new ListView(children: textWidgets), - right: new Container() + child: FlipWidget( + left: ListView(children: textWidgets), + right: Container() ), ), ); diff --git a/packages/flutter/test/widgets/scrollable_fling_test.dart b/packages/flutter/test/widgets/scrollable_fling_test.dart index 6a19acf1ae..e35bab8949 100644 --- a/packages/flutter/test/widgets/scrollable_fling_test.dart +++ b/packages/flutter/test/widgets/scrollable_fling_test.dart @@ -11,16 +11,16 @@ const TextStyle testFont = TextStyle( ); Future pumpTest(WidgetTester tester, TargetPlatform platform) async { - await tester.pumpWidget(new Container()); - await tester.pumpWidget(new MaterialApp( - theme: new ThemeData( + await tester.pumpWidget(Container()); + await tester.pumpWidget(MaterialApp( + theme: ThemeData( platform: platform, ), - home: new Container( + home: Container( color: const Color(0xFF111111), - child: new ListView.builder( + child: ListView.builder( itemBuilder: (BuildContext context, int index) { - return new Text('$index', style: testFont); + return Text('$index', style: testFont); }, ), ), @@ -61,11 +61,11 @@ void main() { final List textWidgets = []; for (int i = 0; i < 250; i += 1) - textWidgets.add(new GestureDetector(onTap: () { log.add('tap $i'); }, child: new Text('$i', style: testFont))); + textWidgets.add(GestureDetector(onTap: () { log.add('tap $i'); }, child: Text('$i', style: testFont))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: textWidgets) + child: ListView(children: textWidgets) ), ); @@ -89,11 +89,11 @@ void main() { final List textWidgets = []; for (int i = 0; i < 250; i += 1) - textWidgets.add(new GestureDetector(onTap: () { log.add('tap $i'); }, child: new Text('$i', style: testFont))); + textWidgets.add(GestureDetector(onTap: () { log.add('tap $i'); }, child: Text('$i', style: testFont))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: textWidgets) + child: ListView(children: textWidgets) ), ); diff --git a/packages/flutter/test/widgets/scrollable_grid_test.dart b/packages/flutter/test/widgets/scrollable_grid_test.dart index 931c683294..5054ea4d61 100644 --- a/packages/flutter/test/widgets/scrollable_grid_test.dart +++ b/packages/flutter/test/widgets/scrollable_grid_test.dart @@ -9,10 +9,10 @@ import 'package:flutter/rendering.dart'; void main() { testWidgets('GridView default control', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new GridView.count( + child: Center( + child: GridView.count( crossAxisCount: 1, ), ), @@ -24,17 +24,17 @@ void main() { testWidgets('GridView displays correct children with nonzero padding', (WidgetTester tester) async { const EdgeInsets padding = EdgeInsets.fromLTRB(0.0, 100.0, 0.0, 0.0); - final Widget testWidget = new Directionality( + final Widget testWidget = Directionality( textDirection: TextDirection.ltr, - child: new Align( - child: new SizedBox( + child: Align( + child: SizedBox( height: 800.0, width: 300.0, // forces the grid children to be 300..300 - child: new GridView.count( + child: GridView.count( crossAxisCount: 1, padding: padding, - children: new List.generate(10, (int index) { - return new Text('$index', key: new ValueKey(index)); + children: List.generate(10, (int index) { + return Text('$index', key: ValueKey(index)); }).toList(), ), ), @@ -80,14 +80,14 @@ void main() { testWidgets('GridView.count() fixed itemExtent, scroll to end, append, scroll', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/issues/9506 Widget buildFrame(int itemCount) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new GridView.count( + child: GridView.count( crossAxisCount: itemCount, - children: new List.generate(itemCount, (int index) { - return new SizedBox( + children: List.generate(itemCount, (int index) { + return SizedBox( height: 200.0, - child: new Text('item $index'), + child: Text('item $index'), ); }), ), diff --git a/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart b/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart index c1095fe771..862873e9a2 100644 --- a/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart +++ b/packages/flutter/test/widgets/scrollable_list_hit_testing_test.dart @@ -12,19 +12,19 @@ void main() { testWidgets('Tap item after scroll - horizontal', (WidgetTester tester) async { final List tapped = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 50.0, - child: new ListView( + child: ListView( itemExtent: 290.0, scrollDirection: Axis.horizontal, children: items.map((int item) { - return new Container( - child: new GestureDetector( + return Container( + child: GestureDetector( onTap: () { tapped.add(item); }, - child: new Text('$item'), + child: Text('$item'), ), ); }).toList(), @@ -54,19 +54,19 @@ void main() { testWidgets('Tap item after scroll - vertical', (WidgetTester tester) async { final List tapped = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 50.0, - child: new ListView( + child: ListView( itemExtent: 290.0, scrollDirection: Axis.vertical, children: items.map((int item) { - return new Container( - child: new GestureDetector( + return Container( + child: GestureDetector( onTap: () { tapped.add(item); }, - child: new Text('$item'), + child: Text('$item'), ), ); }).toList(), @@ -99,16 +99,16 @@ void main() { final List tapped = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 290.0, padding: const EdgeInsets.fromLTRB(5.0, 20.0, 15.0, 10.0), children: items.map((int item) { - return new Container( - child: new GestureDetector( + return Container( + child: GestureDetector( onTap: () { tapped.add(item); }, - child: new Text('$item'), + child: Text('$item'), ), ); }).toList(), @@ -133,17 +133,17 @@ void main() { final List tapped = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 290.0, reverse: true, padding: const EdgeInsets.fromLTRB(5.0, 20.0, 15.0, 10.0), children: items.map((int item) { - return new Container( - child: new GestureDetector( + return Container( + child: GestureDetector( onTap: () { tapped.add(item); }, - child: new Text('$item'), + child: Text('$item'), ), ); }).toList(), @@ -169,15 +169,15 @@ void main() { final List tapped = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( itemExtent: 200.0, children: items.map((int item) { - return new Container( - child: new GestureDetector( + return Container( + child: GestureDetector( onTap: () { tapped.add(item); }, - child: new Text('$item'), + child: Text('$item'), ), ); }).toList(), diff --git a/packages/flutter/test/widgets/scrollable_of_test.dart b/packages/flutter/test/widgets/scrollable_of_test.dart index f127e2a293..a91ac4b19d 100644 --- a/packages/flutter/test/widgets/scrollable_of_test.dart +++ b/packages/flutter/test/widgets/scrollable_of_test.dart @@ -12,7 +12,7 @@ class ScrollPositionListener extends StatefulWidget { final ValueChanged log; @override - _ScrollPositionListenerState createState() => new _ScrollPositionListenerState(); + _ScrollPositionListenerState createState() => _ScrollPositionListenerState(); } class _ScrollPositionListenerState extends State { @@ -45,16 +45,16 @@ class _ScrollPositionListenerState extends State { void main() { testWidgets('Scrollable.of() dependent rebuilds when Scrollable position changes', (WidgetTester tester) async { String logValue; - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); // Changing the SingleChildScrollView's physics causes the // ScrollController's ScrollPosition to be rebuilt. Widget buildFrame(ScrollPhysics physics) { - return new SingleChildScrollView( + return SingleChildScrollView( controller: controller, physics: physics, - child: new ScrollPositionListener( + child: ScrollPositionListener( log: (String s) { logValue = s; }, child: const SizedBox(height: 400.0), ), diff --git a/packages/flutter/test/widgets/scrollable_semantics_test.dart b/packages/flutter/test/widgets/scrollable_semantics_test.dart index 42840aa5c6..0cc8a9c522 100644 --- a/packages/flutter/test/widgets/scrollable_semantics_test.dart +++ b/packages/flutter/test/widgets/scrollable_semantics_test.dart @@ -19,15 +19,15 @@ void main() { }); testWidgets('scrollable exposes the correct semantic actions', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); final List textWidgets = []; for (int i = 0; i < 80; i++) - textWidgets.add(new Text('$i')); + textWidgets.add(Text('$i')); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: textWidgets), + child: ListView(children: textWidgets), ), ); @@ -49,25 +49,25 @@ void main() { }); testWidgets('showOnScreen works in scrollable', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation const double kItemHeight = 40.0; final List containers = []; for (int i = 0; i < 80; i++) - containers.add(new MergeSemantics(child: new Container( + containers.add(MergeSemantics(child: Container( height: kItemHeight, - child: new Text('container $i', textDirection: TextDirection.ltr), + child: Text('container $i', textDirection: TextDirection.ltr), ))); - final ScrollController scrollController = new ScrollController( + final ScrollController scrollController = ScrollController( initialScrollOffset: kItemHeight / 2, ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( + child: ListView( controller: scrollController, children: containers, ), @@ -87,30 +87,30 @@ void main() { }); testWidgets('showOnScreen works with pinned app bar and sliver list', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation const double kItemHeight = 100.0; const double kExpandedAppBarHeight = 56.0; final List containers = []; for (int i = 0; i < 80; i++) - containers.add(new MergeSemantics(child: new Container( + containers.add(MergeSemantics(child: Container( height: kItemHeight, - child: new Text('container $i'), + child: Text('container $i'), ))); - final ScrollController scrollController = new ScrollController( + final ScrollController scrollController = ScrollController( initialScrollOffset: kItemHeight / 2, ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scrollable( + child: Scrollable( controller: scrollController, viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( offset: offset, slivers: [ const SliverAppBar( @@ -120,8 +120,8 @@ void main() { title: Text('App Bar'), ), ), - new SliverList( - delegate: new SliverChildListDelegate(containers), + SliverList( + delegate: SliverChildListDelegate(containers), ) ], ); @@ -141,38 +141,38 @@ void main() { }); testWidgets('showOnScreen works with pinned app bar and individual slivers', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation const double kItemHeight = 100.0; const double kExpandedAppBarHeight = 256.0; final List children = []; - final List slivers = new List.generate(30, (int i) { - final Widget child = new MergeSemantics( - child: new Container( - child: new Text('Item $i'), + final List slivers = List.generate(30, (int i) { + final Widget child = MergeSemantics( + child: Container( + child: Text('Item $i'), height: 72.0, ), ); children.add(child); - return new SliverToBoxAdapter( + return SliverToBoxAdapter( child: child, ); }); - final ScrollController scrollController = new ScrollController( + final ScrollController scrollController = ScrollController( initialScrollOffset: 2.5 * kItemHeight, ); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scrollable( + child: Scrollable( controller: scrollController, viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( offset: offset, slivers: [ const SliverAppBar( @@ -201,14 +201,14 @@ void main() { }); testWidgets('correct scrollProgress', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); final List textWidgets = []; for (int i = 0; i < 80; i++) - textWidgets.add(new Text('$i')); - await tester.pumpWidget(new Directionality( + textWidgets.add(Text('$i')); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: textWidgets), + child: ListView(children: textWidgets), )); expect(semantics, includesNodeWith( @@ -247,14 +247,14 @@ void main() { }); testWidgets('correct scrollProgress for unbound', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ListView.builder( + child: ListView.builder( itemExtent: 20.0, itemBuilder: (BuildContext context, int index) { - return new Text('entry $index'); + return Text('entry $index'); }, ), )); @@ -296,18 +296,18 @@ void main() { }); testWidgets('Semantics tree is populated mid-scroll', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); final List children = []; for (int i = 0; i < 80; i++) - children.add(new Container( - child: new Text('Item $i'), + children.add(Container( + child: Text('Item $i'), height: 40.0, )); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: children), + child: ListView(children: children), ), ); @@ -324,12 +324,12 @@ void main() { testWidgets('Can toggle semantics on, off, on without crash', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView( - children: new List.generate(40, (int i) { - return new Container( - child: new Text('item $i'), + child: ListView( + children: List.generate(40, (int i) { + return Container( + child: Text('item $i'), height: 400.0, ); }), @@ -337,25 +337,25 @@ void main() { ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.hasImplicitScrolling, ], actions: [SemanticsAction.scrollUp], children: [ - new TestSemantics( + TestSemantics( label: r'item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], @@ -372,7 +372,7 @@ void main() { expect(tester.binding.pipelineOwner.semanticsOwner, isNull); // Semantics on - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); await tester.pumpAndSettle(); expect(tester.binding.pipelineOwner.semanticsOwner, isNotNull); expect(semantics, hasSemantics(expectedSemantics, ignoreId: true, ignoreRect: true, ignoreTransform: true)); @@ -383,7 +383,7 @@ void main() { expect(tester.binding.pipelineOwner.semanticsOwner, isNull); // Semantics on - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); await tester.pumpAndSettle(); expect(tester.binding.pipelineOwner.semanticsOwner, isNotNull); expect(semantics, hasSemantics(expectedSemantics, ignoreId: true, ignoreRect: true, ignoreTransform: true)); @@ -400,25 +400,25 @@ void main() { Widget widgetUnderTest; setUp(() { - children = new List.generate(10, (int i) { - return new MergeSemantics( - child: new Container( + children = List.generate(10, (int i) { + return MergeSemantics( + child: Container( height: kItemHeight, - child: new Text('container $i'), + child: Text('container $i'), ), ); }); - scrollController = new ScrollController( + scrollController = ScrollController( initialScrollOffset: kItemHeight / 2, ); - widgetUnderTest = new Directionality( + widgetUnderTest = Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 2 * kItemHeight, - child: new ListView( + child: ListView( controller: scrollController, children: children, ), @@ -429,7 +429,7 @@ void main() { }); testWidgets('brings item above leading edge to leading edge', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation await tester.pumpWidget(widgetUnderTest); @@ -445,7 +445,7 @@ void main() { }); testWidgets('brings item below trailing edge to trailing edge', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation await tester.pumpWidget(widgetUnderTest); @@ -461,7 +461,7 @@ void main() { }); testWidgets('does not change position of items already fully on-screen', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation await tester.pumpWidget(widgetUnderTest); @@ -485,22 +485,22 @@ void main() { Widget widgetUnderTest; setUp(() { - final Key center = new GlobalKey(); + final Key center = GlobalKey(); - children = new List.generate(10, (int i) { - return new SliverToBoxAdapter( + children = List.generate(10, (int i) { + return SliverToBoxAdapter( key: i == 5 ? center : null, - child: new MergeSemantics( - key: new ValueKey(i), - child: new Container( + child: MergeSemantics( + key: ValueKey(i), + child: Container( height: kItemHeight, - child: new Text('container $i'), + child: Text('container $i'), ), ), ); }); - scrollController = new ScrollController( + scrollController = ScrollController( initialScrollOffset: -2.5 * kItemHeight, ); @@ -511,15 +511,15 @@ void main() { // 'container 4' is at offset -100 // 'container 5' is at offset 0 - widgetUnderTest = new Directionality( + widgetUnderTest = Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: 2 * kItemHeight, - child: new Scrollable( + child: Scrollable( controller: scrollController, viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( cacheExtent: 0.0, offset: offset, center: center, @@ -534,7 +534,7 @@ void main() { }); testWidgets('brings item above leading edge to leading edge', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation await tester.pumpWidget(widgetUnderTest); @@ -550,7 +550,7 @@ void main() { }); testWidgets('brings item below trailing edge to trailing edge', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation await tester.pumpWidget(widgetUnderTest); @@ -566,7 +566,7 @@ void main() { }); testWidgets('does not change position of items already fully on-screen', (WidgetTester tester) async { - semantics = new SemanticsTester(tester); // enables semantics tree generation + semantics = SemanticsTester(tester); // enables semantics tree generation await tester.pumpWidget(widgetUnderTest); diff --git a/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart b/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart index 4211575eee..c83be5c887 100644 --- a/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart +++ b/packages/flutter/test/widgets/scrollable_semantics_traversal_order_test.dart @@ -13,38 +13,38 @@ import 'semantics_tester.dart'; void main() { testWidgets('Traversal Order of SliverList', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(30, (int i) { - return new Container( + final List listChildren = List.generate(30, (int i) { + return Container( height: 200.0, - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Semantics( + Semantics( container: true, - child: new Text('Item ${i}a'), + child: Text('Item ${i}a'), ), - new Semantics( + Semantics( container: true, - child: new Text('item ${i}b'), + child: Text('item ${i}b'), ), ], ), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( - controller: new ScrollController(initialScrollOffset: 3000.0), + child: CustomScrollView( + controller: ScrollController(initialScrollOffset: 3000.0), slivers: [ - new SliverList( - delegate: new SliverChildListDelegate(listChildren), + SliverList( + delegate: SliverChildListDelegate(listChildren), ), ], ), @@ -54,79 +54,79 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 13a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 13b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 14a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 14b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 15a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 15b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 16a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 16b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 17a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 17b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 18a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 18b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 19a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 19b', textDirection: TextDirection.ltr, @@ -149,39 +149,39 @@ void main() { }); testWidgets('Traversal Order of SliverFixedExtentList', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(30, (int i) { - return new Container( + final List listChildren = List.generate(30, (int i) { + return Container( height: 200.0, - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Semantics( + Semantics( container: true, - child: new Text('Item ${i}a'), + child: Text('Item ${i}a'), ), - new Semantics( + Semantics( container: true, - child: new Text('item ${i}b'), + child: Text('item ${i}b'), ), ], ), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( - controller: new ScrollController(initialScrollOffset: 3000.0), + child: CustomScrollView( + controller: ScrollController(initialScrollOffset: 3000.0), slivers: [ - new SliverFixedExtentList( + SliverFixedExtentList( itemExtent: 200.0, - delegate: new SliverChildListDelegate(listChildren), + delegate: SliverChildListDelegate(listChildren), ), ], ), @@ -191,79 +191,79 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 13a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 13b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 14a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 14b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 15a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 15b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 16a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 16b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 17a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 17b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 18a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 18b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 19a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 19b', textDirection: TextDirection.ltr, @@ -286,25 +286,25 @@ void main() { }); testWidgets('Traversal Order of SliverGrid', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(30, (int i) { - return new Container( + final List listChildren = List.generate(30, (int i) { + return Container( height: 200.0, - child: new Text('Item $i'), + child: Text('Item $i'), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( - controller: new ScrollController(initialScrollOffset: 1600.0), + child: CustomScrollView( + controller: ScrollController(initialScrollOffset: 1600.0), slivers: [ - new SliverGrid.count( + SliverGrid.count( crossAxisCount: 2, crossAxisSpacing: 400.0, children: listChildren, @@ -317,77 +317,77 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [SemanticsAction.scrollUp, SemanticsAction.scrollDown], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 12', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 13', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 14', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 15', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 16', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 17', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 18', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 19', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 20', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 21', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 22', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 23', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 24', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 25', textDirection: TextDirection.ltr, @@ -410,22 +410,22 @@ void main() { }); testWidgets('Traversal Order of List of individual slivers', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(30, (int i) { - return new SliverToBoxAdapter( - child: new Container( + final List listChildren = List.generate(30, (int i) { + return SliverToBoxAdapter( + child: Container( height: 200.0, - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Semantics( + Semantics( container: true, - child: new Text('Item ${i}a'), + child: Text('Item ${i}a'), ), - new Semantics( + Semantics( container: true, - child: new Text('item ${i}b'), + child: Text('item ${i}b'), ), ], ), @@ -433,14 +433,14 @@ void main() { ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( - controller: new ScrollController(initialScrollOffset: 3000.0), + child: CustomScrollView( + controller: ScrollController(initialScrollOffset: 3000.0), slivers: listChildren, ), ), @@ -449,79 +449,79 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 13a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 13b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 14a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 14b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 15a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 15b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 16a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 16b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 17a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 17b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 18a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 18b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 19a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 19b', textDirection: TextDirection.ltr, @@ -544,36 +544,36 @@ void main() { }); testWidgets('Traversal Order of in a SingleChildScrollView', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(30, (int i) { - return new Container( + final List listChildren = List.generate(30, (int i) { + return Container( height: 200.0, - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Semantics( + Semantics( container: true, - child: new Text('Item ${i}a'), + child: Text('Item ${i}a'), ), - new Semantics( + Semantics( container: true, - child: new Text('item ${i}b'), + child: Text('item ${i}b'), ), ], ), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new SingleChildScrollView( - controller: new ScrollController(initialScrollOffset: 3000.0), - child: new Column( + child: SingleChildScrollView( + controller: ScrollController(initialScrollOffset: 3000.0), + child: Column( children: listChildren, ), ), @@ -583,77 +583,77 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 13a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 13b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 14a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 14b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 15a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 15b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 16a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 16b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 17a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'item 17b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 18a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 18b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 19a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'item 19b', textDirection: TextDirection.ltr, @@ -674,35 +674,35 @@ void main() { }); testWidgets('Traversal Order with center child', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scrollable( + child: Scrollable( viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( offset: offset, center: const ValueKey(0), - slivers: new List.generate(30, (int i) { + slivers: List.generate(30, (int i) { final int item = i - 15; - return new SliverToBoxAdapter( - key: new ValueKey(item), - child: new Container( + return SliverToBoxAdapter( + key: ValueKey(item), + child: Container( height: 200.0, - child: new Row( + child: Row( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Semantics( + Semantics( container: true, - child: new Text('${item}a'), + child: Text('${item}a'), ), - new Semantics( + Semantics( container: true, - child: new Text('${item}b'), + child: Text('${item}b'), ), ], ), @@ -717,79 +717,79 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '-2a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '-2b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '-1a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '-1b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: '0a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: '0b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: '1a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: '1b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: '2a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: '2b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '3a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '3b', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '4a', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: '4b', textDirection: TextDirection.ltr, diff --git a/packages/flutter/test/widgets/scrollable_test.dart b/packages/flutter/test/widgets/scrollable_test.dart index 9eaadff213..7370a2910c 100644 --- a/packages/flutter/test/widgets/scrollable_test.dart +++ b/packages/flutter/test/widgets/scrollable_test.dart @@ -7,11 +7,11 @@ import 'package:flutter/material.dart'; import 'package:flutter/rendering.dart'; Future pumpTest(WidgetTester tester, TargetPlatform platform) async { - await tester.pumpWidget(new MaterialApp( - theme: new ThemeData( + await tester.pumpWidget(MaterialApp( + theme: ThemeData( platform: platform, ), - home: new CustomScrollView( + home: CustomScrollView( slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 2000.0)), ], diff --git a/packages/flutter/test/widgets/semantics_10_test.dart b/packages/flutter/test/widgets/semantics_10_test.dart index 0612fd7bb0..31457e2a19 100644 --- a/packages/flutter/test/widgets/semantics_10_test.dart +++ b/packages/flutter/test/widgets/semantics_10_test.dart @@ -11,7 +11,7 @@ import 'semantics_tester.dart'; void main() { testWidgets('can cease to be semantics boundary after markNeedsSemanticsUpdate() has already been called once', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( buildTestWidgets( @@ -35,22 +35,22 @@ void main() { } Widget buildTestWidgets({bool excludeSemantics, String label, bool isSemanticsBoundary}) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( label: 'container', container: true, - child: new ExcludeSemantics( + child: ExcludeSemantics( excluding: excludeSemantics, - child: new TestWidget( + child: TestWidget( label: label, isSemanticBoundary: isSemanticsBoundary, - child: new Column( + child: Column( children: [ - new Semantics( + Semantics( label: 'child1', ), - new Semantics( + Semantics( label: 'child2', ), ], @@ -74,7 +74,7 @@ class TestWidget extends SingleChildRenderObjectWidget { @override RenderTest createRenderObject(BuildContext context) { - return new RenderTest() + return RenderTest() ..label = label ..isSemanticBoundary = isSemanticBoundary; } diff --git a/packages/flutter/test/widgets/semantics_11_test.dart b/packages/flutter/test/widgets/semantics_11_test.dart index 240a15ef8d..9075db702e 100644 --- a/packages/flutter/test/widgets/semantics_11_test.dart +++ b/packages/flutter/test/widgets/semantics_11_test.dart @@ -11,15 +11,15 @@ import 'semantics_tester.dart'; void main() { testWidgets('markNeedsSemanticsUpdate() called on non-boundary with non-boundary parent', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Semantics( + Semantics( container: true, onTap: dummyTapHandler, - child: new Semantics( + child: Semantics( onTap: dummyTapHandler, - child: new Semantics( + child: Semantics( onTap: dummyTapHandler, textDirection: TextDirection.ltr, label: 'foo', @@ -28,17 +28,17 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, actions: SemanticsAction.tap.index, children: [ - new TestSemantics( + TestSemantics( id: 2, actions: SemanticsAction.tap.index, children: [ - new TestSemantics( + TestSemantics( id: 3, actions: SemanticsAction.tap.index, label: 'foo', @@ -54,12 +54,12 @@ void main() { // This should not throw an assert. await tester.pumpWidget( - new Semantics( + Semantics( container: true, onTap: dummyTapHandler, - child: new Semantics( + child: Semantics( onTap: dummyTapHandler, - child: new Semantics( + child: Semantics( onTap: dummyTapHandler, textDirection: TextDirection.ltr, label: 'bar', // <-- only change @@ -68,17 +68,17 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, actions: SemanticsAction.tap.index, children: [ - new TestSemantics( + TestSemantics( id: 2, actions: SemanticsAction.tap.index, children: [ - new TestSemantics( + TestSemantics( id: 3, actions: SemanticsAction.tap.index, label: 'bar', diff --git a/packages/flutter/test/widgets/semantics_1_test.dart b/packages/flutter/test/widgets/semantics_1_test.dart index 6b752db19a..a887b7daab 100644 --- a/packages/flutter/test/widgets/semantics_1_test.dart +++ b/packages/flutter/test/widgets/semantics_1_test.dart @@ -11,26 +11,26 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 1', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // smoketest await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( label: 'test1', textDirection: TextDirection.ltr, - child: new Container(), + child: Container(), selected: true, ), ), ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'test1', rect: TestSemantics.fullScreen, @@ -41,24 +41,24 @@ void main() { // control for forking await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: true, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, @@ -70,9 +70,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'child1', rect: TestSemantics.fullScreen, @@ -83,24 +83,24 @@ void main() { // forking semantics await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: false, - child: new Semantics( + child: Semantics( label: 'child2', textDirection: TextDirection.ltr, selected: true, @@ -112,22 +112,22 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 2, label: 'child1', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), - new TestSemantics( + TestSemantics( id: 3, label: 'child2', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), ], @@ -137,24 +137,24 @@ void main() { // toggle a branch off await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: true, - child: new Semantics( + child: Semantics( label: 'child2', textDirection: TextDirection.ltr, selected: true, @@ -166,9 +166,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'child1', rect: TestSemantics.fullScreen, @@ -179,24 +179,24 @@ void main() { // toggle a branch back on await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: false, - child: new Semantics( + child: Semantics( label: 'child2', textDirection: TextDirection.ltr, selected: true, @@ -208,22 +208,22 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 4, label: 'child1', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), - new TestSemantics( + TestSemantics( id: 3, label: 'child2', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), ], diff --git a/packages/flutter/test/widgets/semantics_2_test.dart b/packages/flutter/test/widgets/semantics_2_test.dart index e5a7f13970..17c1ef4cb9 100644 --- a/packages/flutter/test/widgets/semantics_2_test.dart +++ b/packages/flutter/test/widgets/semantics_2_test.dart @@ -11,7 +11,7 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 2', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // this test is the same as the test in Semantics 1, but // starting with the second branch being ignored and then @@ -19,24 +19,24 @@ void main() { // forking semantics await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: false, - child: new Semantics( + child: Semantics( label: 'child2', textDirection: TextDirection.ltr, selected: true, @@ -48,22 +48,22 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 2, label: 'child1', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), - new TestSemantics( + TestSemantics( id: 3, label: 'child2', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), ], @@ -73,24 +73,24 @@ void main() { // toggle a branch off await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: true, - child: new Semantics( + child: Semantics( label: 'child2', textDirection: TextDirection.ltr, selected: true, @@ -102,9 +102,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'child1', rect: TestSemantics.fullScreen, @@ -115,24 +115,24 @@ void main() { // toggle a branch back on await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Column( + child: Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: [ - new Container( + Container( height: 10.0, - child: new Semantics( + child: Semantics( label: 'child1', textDirection: TextDirection.ltr, selected: true, ), ), - new Container( + Container( height: 10.0, - child: new IgnorePointer( + child: IgnorePointer( ignoring: false, - child: new Semantics( + child: Semantics( label: 'child2', textDirection: TextDirection.ltr, selected: true, @@ -144,22 +144,22 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 4, label: 'child1', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), - new TestSemantics( + TestSemantics( id: 3, label: 'child2', - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 10.0), flags: SemanticsFlag.isSelected.index, ), ], diff --git a/packages/flutter/test/widgets/semantics_3_test.dart b/packages/flutter/test/widgets/semantics_3_test.dart index e37cd35c33..3f68fd3952 100644 --- a/packages/flutter/test/widgets/semantics_3_test.dart +++ b/packages/flutter/test/widgets/semantics_3_test.dart @@ -10,18 +10,18 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 3', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // implicit annotators await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( label: 'test', textDirection: TextDirection.ltr, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( checked: true ), ), @@ -31,9 +31,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: 'test', @@ -45,10 +45,10 @@ void main() { // remove one await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( checked: true, ), ), @@ -56,9 +56,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, rect: TestSemantics.fullScreen, @@ -69,10 +69,10 @@ void main() { // change what it says await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( label: 'test', textDirection: TextDirection.ltr, ), @@ -81,9 +81,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'test', textDirection: TextDirection.ltr, @@ -95,12 +95,12 @@ void main() { // add a node await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( checked: true, - child: new Semantics( + child: Semantics( label: 'test', textDirection: TextDirection.ltr, ), @@ -110,9 +110,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: 'test', @@ -129,12 +129,12 @@ void main() { // make no changes await tester.pumpWidget( - new Semantics( + Semantics( container: true, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( checked: true, - child: new Semantics( + child: Semantics( label: 'test', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/widgets/semantics_4_test.dart b/packages/flutter/test/widgets/semantics_4_test.dart index 89440ccae6..1cb51d1bc8 100644 --- a/packages/flutter/test/widgets/semantics_4_test.dart +++ b/packages/flutter/test/widgets/semantics_4_test.dart @@ -11,7 +11,7 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 4', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // O // / \ O=root @@ -19,25 +19,25 @@ void main() { // / \ C=node with checked // C C* *=node removed next pass // - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( container: true, label: 'L1', ), - new Semantics( + Semantics( label: 'L2', container: true, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( checked: true, ), - new Semantics( + Semantics( checked: false, ), ], @@ -48,24 +48,24 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'L1', rect: TestSemantics.fullScreen, ), - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, label: 'L2', rect: TestSemantics.fullScreen, children: [ - new TestSemantics( + TestSemantics( id: 3, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, rect: TestSemantics.fullScreen, ), - new TestSemantics( + TestSemantics( id: 4, flags: SemanticsFlag.hasCheckedState.index, rect: TestSemantics.fullScreen, @@ -81,25 +81,25 @@ void main() { // L* LC C=node with checked // *=node removed next pass // - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( label: 'L1', container: true, ), - new Semantics( + Semantics( label: 'L2', container: true, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( checked: true, ), - new Semantics(), + Semantics(), ], ), ), @@ -108,14 +108,14 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'L1', rect: TestSemantics.fullScreen, ), - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, label: 'L2', flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, @@ -129,22 +129,22 @@ void main() { // OLC L=node with label // C=node with checked // - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics(), - new Semantics( + Semantics(), + Semantics( label: 'L2', container: true, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( checked: true, ), - new Semantics(), + Semantics(), ], ), ), @@ -153,9 +153,9 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, label: 'L2', flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, diff --git a/packages/flutter/test/widgets/semantics_5_test.dart b/packages/flutter/test/widgets/semantics_5_test.dart index 25fb24700b..682eea1ca9 100644 --- a/packages/flutter/test/widgets/semantics_5_test.dart +++ b/packages/flutter/test/widgets/semantics_5_test.dart @@ -10,21 +10,21 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 5', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, fit: StackFit.expand, children: [ - new Semantics( + Semantics( // this tests that empty nodes disappear ), - new Semantics( + Semantics( // this tests whether you can have a container with no other semantics container: true, ), - new Semantics( + Semantics( label: 'label', // (force a fork) textDirection: TextDirection.ltr, ), @@ -33,13 +33,13 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, rect: TestSemantics.fullScreen, ), - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, label: 'label', rect: TestSemantics.fullScreen, diff --git a/packages/flutter/test/widgets/semantics_6_test.dart b/packages/flutter/test/widgets/semantics_6_test.dart index f078fe9f3a..e49231caf1 100644 --- a/packages/flutter/test/widgets/semantics_6_test.dart +++ b/packages/flutter/test/widgets/semantics_6_test.dart @@ -12,11 +12,11 @@ import 'semantics_tester.dart'; void main() { testWidgets('can change semantics in a branch blocked by BlockSemantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'hello', textDirection: TextDirection.ltr, @@ -51,22 +51,22 @@ void main() { Widget buildWidget({ @required String blockedText, bool blocking = true }) { assert(blockedText != null); - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( container: true, - child: new ListView( + child: ListView( children: [ - new Text(blockedText), + Text(blockedText), ], ), ), - new BlockSemantics( + BlockSemantics( blocking: blocking, - child: new Semantics( + child: Semantics( label: 'hello', container: true, ), diff --git a/packages/flutter/test/widgets/semantics_7_test.dart b/packages/flutter/test/widgets/semantics_7_test.dart index c9bdbaa50f..615ae22820 100644 --- a/packages/flutter/test/widgets/semantics_7_test.dart +++ b/packages/flutter/test/widgets/semantics_7_test.dart @@ -10,35 +10,35 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 7 - Merging', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); String label; label = '1'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new MergeSemantics( - child: new Semantics( + MergeSemantics( + child: Semantics( checked: true, container: true, - child: new Semantics( + child: Semantics( container: true, label: label, ), ), ), - new MergeSemantics( - child: new Stack( + MergeSemantics( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( checked: true, ), - new Semantics( + Semantics( label: label, ), ], @@ -50,16 +50,16 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: label, rect: TestSemantics.fullScreen, ), // IDs 2 and 3 are used up by the nodes that get merged in - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 4, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: label, @@ -72,29 +72,29 @@ void main() { label = '2'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( fit: StackFit.expand, children: [ - new MergeSemantics( - child: new Semantics( + MergeSemantics( + child: Semantics( checked: true, container: true, - child: new Semantics( + child: Semantics( container: true, label: label, ), ), ), - new MergeSemantics( - child: new Stack( + MergeSemantics( + child: Stack( fit: StackFit.expand, children: [ - new Semantics( + Semantics( checked: true, ), - new Semantics( + Semantics( label: label, ), ], @@ -106,16 +106,16 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: label, rect: TestSemantics.fullScreen, ), // IDs 2 and 3 are used up by the nodes that get merged in - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 4, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: label, diff --git a/packages/flutter/test/widgets/semantics_8_test.dart b/packages/flutter/test/widgets/semantics_8_test.dart index 5dcdf6f181..07231cd3fe 100644 --- a/packages/flutter/test/widgets/semantics_8_test.dart +++ b/packages/flutter/test/widgets/semantics_8_test.dart @@ -10,21 +10,21 @@ import 'semantics_tester.dart'; void main() { testWidgets('Semantics 8 - Merging with reset', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new MergeSemantics( - child: new Semantics( + MergeSemantics( + child: Semantics( container: true, - child: new Semantics( + child: Semantics( container: true, - child: new Stack( + child: Stack( textDirection: TextDirection.ltr, children: [ - new Semantics( + Semantics( checked: true, ), - new Semantics( + Semantics( label: 'label', textDirection: TextDirection.ltr, ) @@ -36,9 +36,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: 'label', @@ -51,19 +51,19 @@ void main() { // switch the order of the inner Semantics node to trigger a reset await tester.pumpWidget( - new MergeSemantics( - child: new Semantics( + MergeSemantics( + child: Semantics( container: true, - child: new Semantics( + child: Semantics( container: true, - child: new Stack( + child: Stack( textDirection: TextDirection.ltr, children: [ - new Semantics( + Semantics( label: 'label', textDirection: TextDirection.ltr, ), - new Semantics( + Semantics( checked: true ) ] @@ -74,9 +74,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: SemanticsFlag.hasCheckedState.index | SemanticsFlag.isChecked.index, label: 'label', diff --git a/packages/flutter/test/widgets/semantics_9_test.dart b/packages/flutter/test/widgets/semantics_9_test.dart index faff0f337e..bff31ce385 100644 --- a/packages/flutter/test/widgets/semantics_9_test.dart +++ b/packages/flutter/test/widgets/semantics_9_test.dart @@ -12,34 +12,34 @@ import 'semantics_tester.dart'; void main() { group('BlockSemantics', () { testWidgets('hides semantic nodes of siblings', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Semantics( + Semantics( label: 'layer#1', textDirection: TextDirection.ltr, - child: new Container(), + child: Container(), ), const BlockSemantics(), - new Semantics( + Semantics( label: 'layer#2', textDirection: TextDirection.ltr, - child: new Container(), + child: Container(), ), ], )); expect(semantics, isNot(includesNodeWith(label: 'layer#1'))); - await tester.pumpWidget(new Stack( + await tester.pumpWidget(Stack( textDirection: TextDirection.ltr, children: [ - new Semantics( + Semantics( label: 'layer#1', textDirection: TextDirection.ltr, - child: new Container(), + child: Container(), ), ], )); @@ -50,44 +50,44 @@ void main() { }); testWidgets('does not hides semantic nodes of siblings outside the current semantic boundary', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality(textDirection: TextDirection.ltr, child: new Stack( + await tester.pumpWidget(Directionality(textDirection: TextDirection.ltr, child: Stack( children: [ - new Semantics( + Semantics( label: '#1', - child: new Container(), + child: Container(), ), - new Semantics( + Semantics( label: '#2', container: true, explicitChildNodes: true, - child: new Stack( + child: Stack( children: [ - new Semantics( + Semantics( label: 'NOT#2.1', - child: new Container(), + child: Container(), ), - new Semantics( + Semantics( label: '#2.2', - child: new BlockSemantics( - child: new Semantics( + child: BlockSemantics( + child: Semantics( container: true, label: '#2.2.1', - child: new Container(), + child: Container(), ), ), ), - new Semantics( + Semantics( label: '#2.3', - child: new Container(), + child: Container(), ), ], ), ), - new Semantics( + Semantics( label: '#3', - child: new Container(), + child: Container(), ), ], ))); @@ -104,25 +104,25 @@ void main() { }); testWidgets('node is semantic boundary and blocking previously painted nodes', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final GlobalKey stackKey = new GlobalKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final GlobalKey stackKey = GlobalKey(); - await tester.pumpWidget(new Directionality(textDirection: TextDirection.ltr, child: new Stack( + await tester.pumpWidget(Directionality(textDirection: TextDirection.ltr, child: Stack( key: stackKey, children: [ - new Semantics( + Semantics( label: 'NOT#1', - child: new Container(), + child: Container(), ), - new BoundaryBlockSemantics( - child: new Semantics( + BoundaryBlockSemantics( + child: Semantics( label: '#2.1', - child: new Container(), + child: Container(), ) ), - new Semantics( + Semantics( label: '#3', - child: new Container(), + child: Container(), ), ], ))); @@ -140,7 +140,7 @@ class BoundaryBlockSemantics extends SingleChildRenderObjectWidget { const BoundaryBlockSemantics({ Key key, Widget child }) : super(key: key, child: child); @override - RenderBoundaryBlockSemantics createRenderObject(BuildContext context) => new RenderBoundaryBlockSemantics(); + RenderBoundaryBlockSemantics createRenderObject(BuildContext context) => RenderBoundaryBlockSemantics(); } class RenderBoundaryBlockSemantics extends RenderProxyBox { diff --git a/packages/flutter/test/widgets/semantics_clipping_test.dart b/packages/flutter/test/widgets/semantics_clipping_test.dart index 567c080e8d..330d8cd661 100644 --- a/packages/flutter/test/widgets/semantics_clipping_test.dart +++ b/packages/flutter/test/widgets/semantics_clipping_test.dart @@ -11,25 +11,25 @@ import 'semantics_tester.dart'; void main() { testWidgets('SemanticNode.rect is clipped', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, - child: new Flex( + child: Flex( direction: Axis.horizontal, children: [ - new Container( + Container( width: 75.0, child: const Text('1'), ), - new Container( + Container( width: 75.0, child: const Text('2'), ), - new Container( + Container( width: 75.0, child: const Text('3'), ), @@ -42,15 +42,15 @@ void main() { expect(tester.takeException(), contains('overflowed')); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( label: '1', - rect: new Rect.fromLTRB(0.0, 0.0, 75.0, 14.0), + rect: Rect.fromLTRB(0.0, 0.0, 75.0, 14.0), ), - new TestSemantics( + TestSemantics( label: '2', - rect: new Rect.fromLTRB(0.0, 0.0, 25.0, 14.0), // clipped form original 75.0 to 25.0 + rect: Rect.fromLTRB(0.0, 0.0, 25.0, 14.0), // clipped form original 75.0 to 25.0 ), // node with Text 3 not present. ], @@ -63,29 +63,29 @@ void main() { }); testWidgets('SemanticsNode is not removed if out of bounds and merged into something within bounds', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, - child: new Flex( + child: Flex( direction: Axis.horizontal, children: [ - new Container( + Container( width: 75.0, child: const Text('1'), ), - new MergeSemantics( - child: new Flex( + MergeSemantics( + child: Flex( direction: Axis.horizontal, children: [ - new Container( + Container( width: 75.0, child: const Text('2'), ), - new Container( + Container( width: 75.0, child: const Text('3'), ), @@ -101,15 +101,15 @@ void main() { expect(tester.takeException(), contains('overflowed')); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( label: '1', - rect: new Rect.fromLTRB(0.0, 0.0, 75.0, 14.0), + rect: Rect.fromLTRB(0.0, 0.0, 75.0, 14.0), ), - new TestSemantics( + TestSemantics( label: '2\n3', - rect: new Rect.fromLTRB(0.0, 0.0, 25.0, 14.0), // clipped form original 75.0 to 25.0 + rect: Rect.fromLTRB(0.0, 0.0, 25.0, 14.0), // clipped form original 75.0 to 25.0 ), ], ), diff --git a/packages/flutter/test/widgets/semantics_debugger_test.dart b/packages/flutter/test/widgets/semantics_debugger_test.dart index 75a73bde54..cf0e5359e2 100644 --- a/packages/flutter/test/widgets/semantics_debugger_test.dart +++ b/packages/flutter/test/widgets/semantics_debugger_test.dart @@ -14,15 +14,15 @@ void main() { // This is a smoketest to verify that adding a debugger doesn't crash. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Semantics(), - new Semantics( + Semantics(), + Semantics( container: true, ), - new Semantics( + Semantics( label: 'label', textDirection: TextDirection.ltr, ), @@ -32,16 +32,16 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Stack( + child: SemanticsDebugger( + child: Stack( children: [ - new Semantics(), - new Semantics( + Semantics(), + Semantics( container: true, ), - new Semantics( + Semantics( label: 'label', textDirection: TextDirection.ltr, ), @@ -56,22 +56,22 @@ void main() { testWidgets('SemanticsDebugger reparents subtree', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); + final GlobalKey key = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Stack( + child: SemanticsDebugger( + child: Stack( children: [ - new Semantics(label: 'label1', textDirection: TextDirection.ltr), - new Positioned( + Semantics(label: 'label1', textDirection: TextDirection.ltr), + Positioned( key: key, left: 0.0, top: 0.0, width: 100.0, height: 100.0, - child: new Semantics(label: 'label2', textDirection: TextDirection.ltr), + child: Semantics(label: 'label2', textDirection: TextDirection.ltr), ), ], ), @@ -80,25 +80,25 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Stack( + child: SemanticsDebugger( + child: Stack( children: [ - new Semantics(label: 'label1', textDirection: TextDirection.ltr), - new Semantics( + Semantics(label: 'label1', textDirection: TextDirection.ltr), + Semantics( container: true, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( key: key, left: 0.0, top: 0.0, width: 100.0, height: 100.0, - child: new Semantics(label: 'label2', textDirection: TextDirection.ltr), + child: Semantics(label: 'label2', textDirection: TextDirection.ltr), ), - new Semantics(label: 'label3', textDirection: TextDirection.ltr), + Semantics(label: 'label3', textDirection: TextDirection.ltr), ], ), ), @@ -109,25 +109,25 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Stack( + child: SemanticsDebugger( + child: Stack( children: [ - new Semantics(label: 'label1', textDirection: TextDirection.ltr), - new Semantics( + Semantics(label: 'label1', textDirection: TextDirection.ltr), + Semantics( container: true, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( key: key, left: 0.0, top: 0.0, width: 100.0, height: 100.0, - child: new Semantics(label: 'label2', textDirection: TextDirection.ltr)), - new Semantics(label: 'label3', textDirection: TextDirection.ltr), - new Semantics(label: 'label4', textDirection: TextDirection.ltr), + child: Semantics(label: 'label2', textDirection: TextDirection.ltr)), + Semantics(label: 'label3', textDirection: TextDirection.ltr), + Semantics(label: 'label4', textDirection: TextDirection.ltr), ], ), ), @@ -145,19 +145,19 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Material( - child: new ListView( + child: SemanticsDebugger( + child: Material( + child: ListView( children: [ - new RaisedButton( + RaisedButton( onPressed: () { log.add('top'); }, child: const Text('TOP'), ), - new RaisedButton( + RaisedButton( onPressed: () { log.add('bottom'); }, @@ -184,20 +184,20 @@ void main() { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Material( - child: new ListView( + child: SemanticsDebugger( + child: Material( + child: ListView( children: [ - new RaisedButton( + RaisedButton( onPressed: () { log.add('top'); }, child: const Text('TOP', textDirection: TextDirection.ltr), ), - new ExcludeSemantics( - child: new RaisedButton( + ExcludeSemantics( + child: RaisedButton( onPressed: () { log.add('bottom'); }, @@ -221,15 +221,15 @@ void main() { }); testWidgets('SemanticsDebugger scroll test', (WidgetTester tester) async { - final Key childKey = new UniqueKey(); + final Key childKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new ListView( + child: SemanticsDebugger( + child: ListView( children: [ - new Container( + Container( key: childKey, height: 5000.0, color: Colors.green[500], @@ -267,10 +267,10 @@ void main() { bool didLongPress = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new GestureDetector( + child: SemanticsDebugger( + child: GestureDetector( onLongPress: () { expect(didLongPress, isFalse); didLongPress = true; @@ -289,16 +289,16 @@ void main() { double value = 0.75; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Directionality( + child: SemanticsDebugger( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( - data: new MediaQueryData.fromWindow(window), - child: new Material( - child: new Center( - child: new Slider( + child: MediaQuery( + data: MediaQueryData.fromWindow(window), + child: Material( + child: Center( + child: Slider( value: value, onChanged: (double newValue) { value = newValue; @@ -322,27 +322,27 @@ void main() { }); testWidgets('SemanticsDebugger checkbox', (WidgetTester tester) async { - final Key keyTop = new UniqueKey(); - final Key keyBottom = new UniqueKey(); + final Key keyTop = UniqueKey(); + final Key keyBottom = UniqueKey(); bool valueTop = false; const bool valueBottom = true; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SemanticsDebugger( - child: new Material( - child: new ListView( + child: SemanticsDebugger( + child: Material( + child: ListView( children: [ - new Checkbox( + Checkbox( key: keyTop, value: valueTop, onChanged: (bool newValue) { valueTop = newValue; }, ), - new Checkbox( + Checkbox( key: keyBottom, value: valueBottom, onChanged: null, diff --git a/packages/flutter/test/widgets/semantics_event_test.dart b/packages/flutter/test/widgets/semantics_event_test.dart index 1ec11db03b..eb342dc703 100644 --- a/packages/flutter/test/widgets/semantics_event_test.dart +++ b/packages/flutter/test/widgets/semantics_event_test.dart @@ -8,25 +8,25 @@ import 'package:flutter_test/flutter_test.dart'; void main() { test('SemanticsEvent.toString', () { expect( - new TestSemanticsEvent().toString(), + TestSemanticsEvent().toString(), 'TestSemanticsEvent()', ); expect( - new TestSemanticsEvent(number: 10).toString(), + TestSemanticsEvent(number: 10).toString(), 'TestSemanticsEvent(number: 10)', ); expect( - new TestSemanticsEvent(text: 'hello').toString(), + TestSemanticsEvent(text: 'hello').toString(), 'TestSemanticsEvent(text: hello)', ); expect( - new TestSemanticsEvent(text: 'hello', number: 10).toString(), + TestSemanticsEvent(text: 'hello', number: 10).toString(), 'TestSemanticsEvent(number: 10, text: hello)', ); }); test('SemanticsEvent.toMap', () { expect( - new TestSemanticsEvent(text: 'hi', number: 11).toMap(), + TestSemanticsEvent(text: 'hi', number: 11).toMap(), { 'type': 'TestEvent', 'data': { @@ -36,7 +36,7 @@ void main() { } ); expect( - new TestSemanticsEvent(text: 'hi', number: 11).toMap(nodeId: 123), + TestSemanticsEvent(text: 'hi', number: 11).toMap(nodeId: 123), { 'type': 'TestEvent', 'nodeId': 123, diff --git a/packages/flutter/test/widgets/semantics_merge_test.dart b/packages/flutter/test/widgets/semantics_merge_test.dart index 31df7617eb..aa04c6dacc 100644 --- a/packages/flutter/test/widgets/semantics_merge_test.dart +++ b/packages/flutter/test/widgets/semantics_merge_test.dart @@ -15,19 +15,19 @@ void main() { }); testWidgets('MergeSemantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // not merged await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Row( + child: Row( children: [ - new Semantics( + Semantics( container: true, child: const Text('test1'), ), - new Semantics( + Semantics( container: true, child: const Text('test2'), ), @@ -37,13 +37,13 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'test1', ), - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, label: 'test2', ), @@ -55,16 +55,16 @@ void main() { // merged await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MergeSemantics( - child: new Row( + child: MergeSemantics( + child: Row( children: [ - new Semantics( + Semantics( container: true, child: const Text('test1'), ), - new Semantics( + Semantics( container: true, child: const Text('test2'), ), @@ -75,9 +75,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 3, label: 'test1\ntest2', ), @@ -89,15 +89,15 @@ void main() { // not merged await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Row( + child: Row( children: [ - new Semantics( + Semantics( container: true, child: const Text('test1'), ), - new Semantics( + Semantics( container: true, child: const Text('test2'), ), @@ -107,10 +107,10 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild(id: 6, label: 'test1'), - new TestSemantics.rootChild(id: 7, label: 'test2'), + TestSemantics.rootChild(id: 6, label: 'test1'), + TestSemantics.rootChild(id: 7, label: 'test2'), ], ), ignoreRect: true, @@ -121,21 +121,21 @@ void main() { }); testWidgets('MergeSemantics works if other nodes are implicitly merged into its node', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MergeSemantics( - child: new Semantics( + child: MergeSemantics( + child: Semantics( selected: true, // this is implicitly merged into the MergeSemantics node - child: new Row( + child: Row( children: [ - new Semantics( + Semantics( container: true, child: const Text('test1'), ), - new Semantics( + Semantics( container: true, child: const Text('test2'), ), @@ -147,9 +147,9 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, flags: [ SemanticsFlag.isSelected, diff --git a/packages/flutter/test/widgets/semantics_test.dart b/packages/flutter/test/widgets/semantics_test.dart index 0064558209..82ea8d606d 100644 --- a/packages/flutter/test/widgets/semantics_test.dart +++ b/packages/flutter/test/widgets/semantics_test.dart @@ -19,11 +19,11 @@ void main() { }); testWidgets('Semantics shutdown and restart', (WidgetTester tester) async { - SemanticsTester semantics = new SemanticsTester(tester); + SemanticsTester semantics = SemanticsTester(tester); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'test1', textDirection: TextDirection.ltr, ) @@ -31,11 +31,11 @@ void main() { ); await tester.pumpWidget( - new Container( - child: new Semantics( + Container( + child: Semantics( label: 'test1', textDirection: TextDirection.ltr, - child: new Container() + child: Container() ) ) ); @@ -51,7 +51,7 @@ void main() { semantics = null; expect(tester.binding.hasScheduledFrame, isFalse); - semantics = new SemanticsTester(tester); + semantics = SemanticsTester(tester); expect(tester.binding.hasScheduledFrame, isTrue); await tester.pump(); @@ -65,31 +65,31 @@ void main() { }); testWidgets('Detach and reattach assert', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final GlobalKey key = new GlobalKey(); + final SemanticsTester semantics = SemanticsTester(tester); + final GlobalKey key = GlobalKey(); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( label: 'test1', - child: new Semantics( + child: Semantics( key: key, container: true, label: 'test2a', - child: new Container() + child: Container() ) ) ) )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'test1', children: [ - new TestSemantics( + TestSemantics( label: 'test2a', ) ] @@ -101,19 +101,19 @@ void main() { ignoreTransform: true, )); - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Container( - child: new Semantics( + child: Container( + child: Semantics( label: 'test1', - child: new Semantics( + child: Semantics( container: true, label: 'middle', - child: new Semantics( + child: Semantics( key: key, container: true, label: 'test2b', - child: new Container() + child: Container() ) ) ) @@ -121,15 +121,15 @@ void main() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'test1', children: [ - new TestSemantics( + TestSemantics( label: 'middle', children: [ - new TestSemantics( + TestSemantics( label: 'test2b', ), ], @@ -147,14 +147,14 @@ void main() { }); testWidgets('Semantics and Directionality - RTL', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Semantics( + child: Semantics( label: 'test1', - child: new Container(), + child: Container(), ), ), ); @@ -164,14 +164,14 @@ void main() { }); testWidgets('Semantics and Directionality - LTR', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( label: 'test1', - child: new Container(), + child: Container(), ), ), ); @@ -181,11 +181,11 @@ void main() { }); testWidgets('Semantics and Directionality - cannot override RTL with LTR', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'test1', textDirection: TextDirection.ltr, ) @@ -193,12 +193,12 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Semantics( + child: Semantics( label: 'test1', textDirection: TextDirection.ltr, - child: new Container(), + child: Container(), ), ), ); @@ -208,11 +208,11 @@ void main() { }); testWidgets('Semantics and Directionality - cannot override LTR with RTL', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'test1', textDirection: TextDirection.rtl, ) @@ -220,12 +220,12 @@ void main() { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( label: 'test1', textDirection: TextDirection.rtl, - child: new Container(), + child: Container(), ), ), ); @@ -235,23 +235,23 @@ void main() { }); testWidgets('Semantics label and hint', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( label: 'label', hint: 'hint', value: 'value', - child: new Container(), + child: Container(), ), ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'label', hint: 'hint', value: 'value', @@ -265,19 +265,19 @@ void main() { }); testWidgets('Semantics hints can merge', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, - child: new Column( + child: Column( children: [ - new Semantics( + Semantics( hint: 'hint one', ), - new Semantics( + Semantics( hint: 'hint two', ) @@ -287,9 +287,9 @@ void main() { ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( hint: 'hint one\nhint two', textDirection: TextDirection.ltr, ) @@ -301,25 +301,25 @@ void main() { }); testWidgets('Semantics values do not merge', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, - child: new Column( + child: Column( children: [ - new Semantics( + Semantics( value: 'value one', - child: new Container( + child: Container( height: 10.0, width: 10.0, ) ), - new Semantics( + Semantics( value: 'value two', - child: new Container( + child: Container( height: 10.0, width: 10.0, ) @@ -330,15 +330,15 @@ void main() { ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( value: 'value one', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( value: 'value two', textDirection: TextDirection.ltr, ), @@ -352,19 +352,19 @@ void main() { }); testWidgets('Semantics value and hint can merge', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, - child: new Column( + child: Column( children: [ - new Semantics( + Semantics( hint: 'hint', ), - new Semantics( + Semantics( value: 'value', ), ], @@ -373,9 +373,9 @@ void main() { ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( hint: 'hint', value: 'value', textDirection: TextDirection.ltr, @@ -388,12 +388,12 @@ void main() { }); testWidgets('Semantics widget supports all actions', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final List performedActions = []; await tester.pumpWidget( - new Semantics( + Semantics( container: true, onDismiss: () => performedActions.add(SemanticsAction.dismiss), onTap: () => performedActions.add(SemanticsAction.tap), @@ -422,9 +422,9 @@ void main() { ..remove(SemanticsAction.showOnScreen); // showOnScreen is not user-exposed const int expectedId = 1; - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: expectedId, rect: TestSemantics.fullScreen, actions: allActions.fold(0, (int previous, SemanticsAction action) => previous | action.index), @@ -460,10 +460,10 @@ void main() { }); testWidgets('Semantics widget supports all flags', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // Note: checked state and toggled state are mutually exclusive. await tester.pumpWidget( - new Semantics( + Semantics( key: const Key('a'), container: true, explicitChildNodes: true, @@ -490,9 +490,9 @@ void main() { ..remove(SemanticsFlag.isToggled) ..remove(SemanticsFlag.hasImplicitScrolling); - TestSemantics expectedSemantics = new TestSemantics.root( + TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( rect: TestSemantics.fullScreen, flags: flags, ), @@ -500,14 +500,14 @@ void main() { ); expect(semantics, hasSemantics(expectedSemantics, ignoreId: true)); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( key: const Key('b'), container: true, scopesRoute: false, )); - expectedSemantics = new TestSemantics.root( + expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( rect: TestSemantics.fullScreen, flags: [], ), @@ -516,15 +516,15 @@ void main() { expect(semantics, hasSemantics(expectedSemantics, ignoreId: true)); await tester.pumpWidget( - new Semantics( + Semantics( key: const Key('c'), toggled: true, ), ); - expectedSemantics = new TestSemantics.root( + expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( rect: TestSemantics.fullScreen, flags: [ SemanticsFlag.hasToggledState, @@ -539,7 +539,7 @@ void main() { }); testWidgets('Actions can be replaced without triggering semantics update', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics( listener: () { @@ -550,16 +550,16 @@ void main() { final List performedActions = []; await tester.pumpWidget( - new Semantics( + Semantics( container: true, onTap: () => performedActions.add('first'), ), ); const int expectedId = 1; - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: expectedId, rect: TestSemantics.fullScreen, actions: SemanticsAction.tap.index, @@ -579,7 +579,7 @@ void main() { // Updating existing handler should not trigger semantics update await tester.pumpWidget( - new Semantics( + Semantics( container: true, onTap: () => performedActions.add('second'), ), @@ -595,16 +595,16 @@ void main() { // Adding a handler works await tester.pumpWidget( - new Semantics( + Semantics( container: true, onTap: () => performedActions.add('second'), onLongPress: () => performedActions.add('longPress'), ), ); - final TestSemantics expectedSemanticsWithLongPress = new TestSemantics.root( + final TestSemantics expectedSemanticsWithLongPress = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: expectedId, rect: TestSemantics.fullScreen, actions: SemanticsAction.tap.index | SemanticsAction.longPress.index, @@ -622,7 +622,7 @@ void main() { // Removing a handler works await tester.pumpWidget( - new Semantics( + Semantics( container: true, onTap: () => performedActions.add('second'), ), @@ -637,7 +637,7 @@ void main() { testWidgets('onTapHint and onLongPressHint create custom actions', (WidgetTester tester) async { final SemanticsHandle semantics = tester.ensureSemantics(); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( container: true, onTap: () {}, onTapHint: 'test', @@ -648,7 +648,7 @@ void main() { onTapHint: 'test' )); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( container: true, onLongPress: () {}, onLongPressHint: 'foo', @@ -663,7 +663,7 @@ void main() { testWidgets('CustomSemanticsActions can be added to a Semantics widget', (WidgetTester tester) async { final SemanticsHandle semantics = tester.ensureSemantics(); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( container: true, customSemanticsActions: { const CustomSemanticsAction(label: 'foo'): () {}, @@ -681,12 +681,12 @@ void main() { }); testWidgets('Increased/decreased values are annotated', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( container: true, value: '10s', increasedValue: '11s', @@ -697,9 +697,9 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( actions: SemanticsAction.increase.index | SemanticsAction.decrease.index, textDirection: TextDirection.ltr, value: '10s', @@ -713,7 +713,7 @@ void main() { }); testWidgets('Semantics widgets built in a widget tree are sorted properly', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics( listener: () { @@ -721,23 +721,23 @@ void main() { } ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( sortKey: const CustomSortKey(0.0), explicitChildNodes: true, - child: new Column( + child: Column( children: [ - new Semantics(sortKey: const CustomSortKey(3.0), child: const Text('Label 1')), - new Semantics(sortKey: const CustomSortKey(2.0), child: const Text('Label 2')), - new Semantics( + Semantics(sortKey: const CustomSortKey(3.0), child: const Text('Label 1')), + Semantics(sortKey: const CustomSortKey(2.0), child: const Text('Label 2')), + Semantics( sortKey: const CustomSortKey(1.0), explicitChildNodes: true, - child: new Row( + child: Row( children: [ - new Semantics(sortKey: const OrdinalSortKey(3.0), child: const Text('Label 3')), - new Semantics(sortKey: const OrdinalSortKey(2.0), child: const Text('Label 4')), - new Semantics(sortKey: const OrdinalSortKey(1.0), child: const Text('Label 5')), + Semantics(sortKey: const OrdinalSortKey(3.0), child: const Text('Label 3')), + Semantics(sortKey: const OrdinalSortKey(2.0), child: const Text('Label 4')), + Semantics(sortKey: const OrdinalSortKey(1.0), child: const Text('Label 5')), ], ), ), @@ -748,37 +748,37 @@ void main() { ); expect(semanticsUpdateCount, 1); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, children: [ - new TestSemantics( + TestSemantics( id: 4, children: [ - new TestSemantics( + TestSemantics( id: 7, label: r'Label 5', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, label: r'Label 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, label: r'Label 3', textDirection: TextDirection.ltr, ), ], ), - new TestSemantics( + TestSemantics( id: 3, label: r'Label 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 2, label: r'Label 1', textDirection: TextDirection.ltr, @@ -794,7 +794,7 @@ void main() { }); testWidgets('Semantics widgets built with explicit sort orders are sorted properly', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics( listener: () { @@ -802,19 +802,19 @@ void main() { } ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Row( + child: Row( children: [ - new Semantics( + Semantics( sortKey: const CustomSortKey(3.0), child: const Text('Label 1'), ), - new Semantics( + Semantics( sortKey: const CustomSortKey(1.0), child: const Text('Label 2'), ), - new Semantics( + Semantics( sortKey: const CustomSortKey(2.0), child: const Text('Label 3'), ), @@ -824,19 +824,19 @@ void main() { ); expect(semanticsUpdateCount, 1); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 2, label: r'Label 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 3, label: r'Label 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 1, label: r'Label 1', textDirection: TextDirection.ltr, @@ -849,7 +849,7 @@ void main() { }); testWidgets('Semantics widgets without sort orders are sorted properly', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics( listener: () { @@ -857,13 +857,13 @@ void main() { } ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ const Text('Label 1'), const Text('Label 2'), - new Row( + Row( children: const [ Text('Label 3'), Text('Label 4'), @@ -876,25 +876,25 @@ void main() { ); expect(semanticsUpdateCount, 1); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: r'Label 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 5', textDirection: TextDirection.ltr, ), @@ -907,7 +907,7 @@ void main() { }); testWidgets('Semantics widgets that are transformed are sorted properly', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics( listener: () { @@ -915,15 +915,15 @@ void main() { } ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ const Text('Label 1'), const Text('Label 2'), - new Transform.rotate( + Transform.rotate( angle: pi / 2.0, - child: new Row( + child: Row( children: const [ Text('Label 3'), Text('Label 4'), @@ -937,25 +937,25 @@ void main() { ); expect(semanticsUpdateCount, 1); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: r'Label 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Label 5', textDirection: TextDirection.ltr, ), @@ -970,13 +970,13 @@ void main() { testWidgets( 'Semantics widgets without sort orders are sorted properly when no Directionality is present', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); int semanticsUpdateCount = 0; final SemanticsHandle handle = tester.binding.pipelineOwner.ensureSemantics(listener: () { semanticsUpdateCount += 1; }); await tester.pumpWidget( - new Stack( + Stack( alignment: Alignment.center, children: [ // Set this up so that the placeholder takes up the whole screen, @@ -987,46 +987,46 @@ void main() { // is no directionality, so we don't have a geometric opinion about // horizontal order. We do still want to sort vertically, however, // which is why the order isn't [0, 1, 2, 3, 4]. - new Semantics( + Semantics( button: true, child: const Placeholder(), ), - new Positioned( + Positioned( top: 200.0, left: 100.0, - child: new Semantics( // Box 0 + child: Semantics( // Box 0 button: true, child: const SizedBox(width: 30.0, height: 30.0), ), ), - new Positioned( + Positioned( top: 100.0, left: 200.0, - child: new Semantics( // Box 1 + child: Semantics( // Box 1 button: true, child: const SizedBox(width: 30.0, height: 30.0), ), ), - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Semantics( // Box 2 + child: Semantics( // Box 2 button: true, child: const SizedBox(width: 30.0, height: 30.0), ), ), - new Positioned( + Positioned( top: 100.0, left: 0.0, - child: new Semantics( // Box 3 + child: Semantics( // Box 3 button: true, child: const SizedBox(width: 30.0, height: 30.0), ), ), - new Positioned( + Positioned( top: 10.0, left: 100.0, - child: new Semantics( // Box 4 + child: Semantics( // Box 4 button: true, child: const SizedBox(width: 30.0, height: 30.0), ), @@ -1038,24 +1038,24 @@ void main() { expect( semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isButton], ), ], @@ -1070,21 +1070,21 @@ void main() { }); testWidgets('Semantics excludeSemantics ignores children', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - await tester.pumpWidget(new Semantics( + final SemanticsTester semantics = SemanticsTester(tester); + await tester.pumpWidget(Semantics( label: 'label', excludeSemantics: true, textDirection: TextDirection.ltr, - child: new Semantics( + child: Semantics( label: 'other label', textDirection: TextDirection.ltr, ), )); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( label: 'label', textDirection: TextDirection.ltr, ), diff --git a/packages/flutter/test/widgets/semantics_tester.dart b/packages/flutter/test/widgets/semantics_tester.dart index 1fa0fb8c09..455275a199 100644 --- a/packages/flutter/test/widgets/semantics_tester.dart +++ b/packages/flutter/test/widgets/semantics_tester.dart @@ -57,7 +57,7 @@ class TestSemantics { assert(decreasedValue != null), assert(hint != null), assert(children != null), - tags = tags?.toSet() ?? new Set(); + tags = tags?.toSet() ?? Set(); /// Creates an object with some test semantics data, with the [id] and [rect] /// set to the appropriate values for the root node. @@ -84,7 +84,7 @@ class TestSemantics { assert(hint != null), rect = TestSemantics.rootRect, assert(children != null), - tags = tags?.toSet() ?? new Set(); + tags = tags?.toSet() ?? Set(); /// Creates an object with some test semantics data, with the [id] and [rect] /// set to the appropriate values for direct children of the root node. @@ -119,7 +119,7 @@ class TestSemantics { assert(hint != null), transform = _applyRootChildScale(transform), assert(children != null), - tags = tags?.toSet() ?? new Set(); + tags = tags?.toSet() ?? Set(); /// The unique identifier for this node. /// @@ -187,11 +187,11 @@ class TestSemantics { /// /// See also [new TestSemantics.root], which uses this value to describe the /// root node. - static final Rect rootRect = new Rect.fromLTWH(0.0, 0.0, 2400.0, 1800.0); + static final Rect rootRect = Rect.fromLTWH(0.0, 0.0, 2400.0, 1800.0); /// The test screen's size in logical pixels, useful for the [rect] of /// full-screen widgets other than the root node. - static final Rect fullScreen = new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0); + static final Rect fullScreen = Rect.fromLTWH(0.0, 0.0, 800.0, 600.0); /// The transform from this node's coordinate system to its parent's coordinate system. /// @@ -203,7 +203,7 @@ class TestSemantics { final TextSelection textSelection; static Matrix4 _applyRootChildScale(Matrix4 transform) { - final Matrix4 result = new Matrix4.diagonal3Values(3.0, 3.0, 1.0); + final Matrix4 result = Matrix4.diagonal3Values(3.0, 3.0, 1.0); if (transform != null) result.multiply(transform); return result; @@ -300,8 +300,8 @@ class TestSemantics { @override String toString([int indentAmount = 0]) { final String indent = ' ' * indentAmount; - final StringBuffer buf = new StringBuffer(); - buf.writeln('${indent}new $runtimeType('); + final StringBuffer buf = StringBuffer(); + buf.writeln('$indent$runtimeType('); if (id != null) buf.writeln('$indent id: $id,'); if (flags is int && flags != 0 || flags is List && flags.isNotEmpty) @@ -523,10 +523,10 @@ class SemanticsTester { if (node == null) return 'null'; final String indent = ' ' * indentAmount; - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); final SemanticsData nodeData = node.getSemanticsData(); final bool isRoot = node.id == 0; - buf.writeln('new TestSemantics${isRoot ? '.root': ''}('); + buf.writeln('TestSemantics${isRoot ? '.root': ''}('); if (!isRoot) buf.writeln(' id: ${node.id},'); if (nodeData.tags != null) @@ -642,7 +642,7 @@ Matcher hasSemantics(TestSemantics semantics, { bool ignoreId = false, DebugSemanticsDumpOrder childOrder = DebugSemanticsDumpOrder.traversalOrder, }) { - return new _HasSemantics( + return _HasSemantics( semantics, ignoreRect: ignoreRect, ignoreTransform: ignoreTransform, @@ -738,7 +738,7 @@ Matcher includesNodeWith({ double scrollExtentMax, double scrollExtentMin, }) { - return new _IncludesNodeWith( + return _IncludesNodeWith( label: label, value: value, hint: hint, diff --git a/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart b/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart index db07298da4..4b92021407 100644 --- a/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart +++ b/packages/flutter/test/widgets/semantics_tester_generateTestSemanticsExpressionForCurrentSemanticsTree_test.dart @@ -23,11 +23,11 @@ void _tests() { }); Future pumpTestWidget(WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new ListView( + await tester.pumpWidget(MaterialApp( + home: ListView( children: [ const Text('Plain text'), - new Semantics( + Semantics( selected: true, checked: true, onTap: () {}, @@ -51,7 +51,7 @@ void _tests() { // // This test is flexible w.r.t. leading and trailing whitespace. testWidgets('generates code', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await pumpTestWidget(tester); final String code = semantics .generateTestSemanticsExpressionForCurrentSemanticsTree(DebugSemanticsDumpOrder.inverseHitTest) @@ -90,7 +90,7 @@ void _tests() { }); testWidgets('generated code is correct', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await pumpTestWidget(tester); expect( semantics, @@ -101,30 +101,30 @@ void _tests() { // generateTestSemanticsExpressionForCurrentSemanticsTree. Otherwise, // the test 'generates code', defined above, will fail. // vvvvvvvvvvvv - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( id: 3, children: [ - new TestSemantics( + TestSemantics( id: 6, flags: [SemanticsFlag.hasImplicitScrolling], children: [ - new TestSemantics( + TestSemantics( id: 4, tags: [const SemanticsTag('RenderViewport.twoPane')], label: 'Plain text', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, tags: [const SemanticsTag('RenderViewport.twoPane')], flags: [SemanticsFlag.hasCheckedState, SemanticsFlag.isChecked, SemanticsFlag.isSelected], diff --git a/packages/flutter/test/widgets/semantics_traversal_test.dart b/packages/flutter/test/widgets/semantics_traversal_test.dart index e6f7c58215..f50a550c79 100644 --- a/packages/flutter/test/widgets/semantics_traversal_test.dart +++ b/packages/flutter/test/widgets/semantics_traversal_test.dart @@ -24,7 +24,7 @@ void main() { void testTraversal(String description, TraversalTestFunction testFunction) { testWidgets(description, (WidgetTester tester) async { - final TraversalTester traversalTester = new TraversalTester(tester); + final TraversalTester traversalTester = TraversalTester(tester); await testFunction(traversalTester); traversalTester.dispose(); }); @@ -256,7 +256,7 @@ void main() { final Map children = { 'A': const Offset(10.0, 10.0) & tenByTen, - 'B': new Offset(10.0 + dx, 10.0 + dy) & tenByTen, + 'B': Offset(10.0 + dx, 10.0 + dy) & tenByTen, }; try { @@ -282,7 +282,7 @@ void main() { } class TraversalTester { - TraversalTester(this.tester) : semantics = new SemanticsTester(tester); + TraversalTester(this.tester) : semantics = SemanticsTester(tester); final WidgetTester tester; final SemanticsTester semantics; @@ -294,21 +294,21 @@ class TraversalTester { }) async { assert(children is LinkedHashMap); await tester.pumpWidget( - new Container( - child: new Directionality( + Container( + child: Directionality( textDirection: textDirection, - child: new Semantics( + child: Semantics( textDirection: textDirection, - child: new CustomMultiChildLayout( - delegate: new TestLayoutDelegate(children), + child: CustomMultiChildLayout( + delegate: TestLayoutDelegate(children), children: children.keys.map((String label) { - return new LayoutId( + return LayoutId( id: label, - child: new Semantics( + child: Semantics( container: true, explicitChildNodes: true, label: label, - child: new SizedBox( + child: SizedBox( width: children[label].width, height: children[label].height, ), @@ -322,12 +322,12 @@ class TraversalTester { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( textDirection: textDirection, children: expectedTraversal.split(' ').map((String label) { - return new TestSemantics( + return TestSemantics( label: label, ); }).toList(), @@ -355,7 +355,7 @@ class TestLayoutDelegate extends MultiChildLayoutDelegate { @override void performLayout(Size size) { children.forEach((String label, Rect rect) { - layoutChild(label, new BoxConstraints.loose(size)); + layoutChild(label, BoxConstraints.loose(size)); positionChild(label, rect.topLeft); }); } diff --git a/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart b/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart index a742696456..f8885d6310 100644 --- a/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart +++ b/packages/flutter/test/widgets/semantics_zero_surface_size_test.dart @@ -11,20 +11,20 @@ import 'semantics_tester.dart'; void main() { testWidgets('has only root node if surface size is 0x0', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( selected: true, )); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( id: 0, - rect: new Rect.fromLTRB(0.0, 0.0, 2400.0, 1800.0), + rect: Rect.fromLTRB(0.0, 0.0, 2400.0, 1800.0), children: [ - new TestSemantics( + TestSemantics( id: 1, - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), flags: [SemanticsFlag.isSelected], ), ], @@ -35,9 +35,9 @@ void main() { await tester.pumpAndSettle(); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( id: 0, - rect: new Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 0.0, 0.0), ), ignoreTransform: true, )); diff --git a/packages/flutter/test/widgets/set_state_1_test.dart b/packages/flutter/test/widgets/set_state_1_test.dart index d9ccee44c0..cc949aaea3 100644 --- a/packages/flutter/test/widgets/set_state_1_test.dart +++ b/packages/flutter/test/widgets/set_state_1_test.dart @@ -7,13 +7,13 @@ import 'package:flutter/widgets.dart'; class Inside extends StatefulWidget { @override - InsideState createState() => new InsideState(); + InsideState createState() => InsideState(); } class InsideState extends State { @override Widget build(BuildContext context) { - return new Listener( + return Listener( onPointerDown: _handlePointerDown, child: const Text('INSIDE', textDirection: TextDirection.ltr), ); @@ -30,13 +30,13 @@ class Middle extends StatefulWidget { final Inside child; @override - MiddleState createState() => new MiddleState(); + MiddleState createState() => MiddleState(); } class MiddleState extends State { @override Widget build(BuildContext context) { - return new Listener( + return Listener( onPointerDown: _handlePointerDown, child: widget.child, ); @@ -49,19 +49,19 @@ class MiddleState extends State { class Outside extends StatefulWidget { @override - OutsideState createState() => new OutsideState(); + OutsideState createState() => OutsideState(); } class OutsideState extends State { @override Widget build(BuildContext context) { - return new Middle(child: new Inside()); + return Middle(child: Inside()); } } void main() { testWidgets('setState() smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new Outside()); + await tester.pumpWidget(Outside()); final Offset location = tester.getCenter(find.text('INSIDE')); final TestGesture gesture = await tester.startGesture(location); await tester.pump(); diff --git a/packages/flutter/test/widgets/set_state_2_test.dart b/packages/flutter/test/widgets/set_state_2_test.dart index f2570bb76b..674169c434 100644 --- a/packages/flutter/test/widgets/set_state_2_test.dart +++ b/packages/flutter/test/widgets/set_state_2_test.dart @@ -8,26 +8,26 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('setState() overbuild test', (WidgetTester tester) async { final List log = []; - final Builder inner = new Builder( + final Builder inner = Builder( builder: (BuildContext context) { log.add('inner'); return const Text('inner', textDirection: TextDirection.ltr); } ); int value = 0; - await tester.pumpWidget(new Builder( + await tester.pumpWidget(Builder( builder: (BuildContext context) { log.add('outer'); - return new StatefulBuilder( + return StatefulBuilder( builder: (BuildContext context, StateSetter setState) { log.add('stateful'); - return new GestureDetector( + return GestureDetector( onTap: () { setState(() { value += 1; }); }, - child: new Builder( + child: Builder( builder: (BuildContext context) { log.add('middle $value'); return inner; diff --git a/packages/flutter/test/widgets/set_state_3_test.dart b/packages/flutter/test/widgets/set_state_3_test.dart index 53a242557e..1806c79729 100644 --- a/packages/flutter/test/widgets/set_state_3_test.dart +++ b/packages/flutter/test/widgets/set_state_3_test.dart @@ -13,7 +13,7 @@ class Changer extends StatefulWidget { final Widget child; @override - ChangerState createState() => new ChangerState(); + ChangerState createState() => ChangerState(); } class ChangerState extends State { @@ -28,7 +28,7 @@ class ChangerState extends State { void test() { setState(() { _state = true; }); } @override - Widget build(BuildContext context) => _state ? new Wrapper(widget.child) : widget.child; + Widget build(BuildContext context) => _state ? Wrapper(widget.child) : widget.child; } class Wrapper extends StatelessWidget { @@ -42,7 +42,7 @@ class Wrapper extends StatelessWidget { class Leaf extends StatefulWidget { @override - LeafState createState() => new LeafState(); + LeafState createState() => LeafState(); } class LeafState extends State { @@ -52,8 +52,8 @@ class LeafState extends State { void main() { testWidgets('three-way setState() smoke test', (WidgetTester tester) async { - await tester.pumpWidget(new Changer(new Wrapper(new Leaf()))); - await tester.pumpWidget(new Changer(new Wrapper(new Leaf()))); + await tester.pumpWidget(Changer(Wrapper(Leaf()))); + await tester.pumpWidget(Changer(Wrapper(Leaf()))); changer.test(); await tester.pump(); }); diff --git a/packages/flutter/test/widgets/set_state_4_test.dart b/packages/flutter/test/widgets/set_state_4_test.dart index 0da0619755..29cdaba169 100644 --- a/packages/flutter/test/widgets/set_state_4_test.dart +++ b/packages/flutter/test/widgets/set_state_4_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; class Changer extends StatefulWidget { @override - ChangerState createState() => new ChangerState(); + ChangerState createState() => ChangerState(); } class ChangerState extends State { @@ -21,7 +21,7 @@ class ChangerState extends State { void main() { testWidgets('setState() catches being used with an async callback', (WidgetTester tester) async { - await tester.pumpWidget(new Changer()); + await tester.pumpWidget(Changer()); final ChangerState s = tester.state(find.byType(Changer)); expect(s.test0, isNot(throwsFlutterError)); expect(s.test1, isNot(throwsFlutterError)); diff --git a/packages/flutter/test/widgets/set_state_5_test.dart b/packages/flutter/test/widgets/set_state_5_test.dart index d9b3583896..fe4f60a454 100644 --- a/packages/flutter/test/widgets/set_state_5_test.dart +++ b/packages/flutter/test/widgets/set_state_5_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; class BadWidget extends StatefulWidget { @override - State createState() => new BadWidgetState(); + State createState() => BadWidgetState(); } @@ -22,13 +22,13 @@ class BadWidgetState extends State { @override Widget build(BuildContext context) { - return new Text(_count.toString()); + return Text(_count.toString()); } } void main() { testWidgets('setState() catches being used inside a constructor', (WidgetTester tester) async { - await tester.pumpWidget(new BadWidget()); + await tester.pumpWidget(BadWidget()); expect(tester.takeException(), isInstanceOf()); }); } diff --git a/packages/flutter/test/widgets/shader_mask_test.dart b/packages/flutter/test/widgets/shader_mask_test.dart index dd5fa1bd2c..6d0de8adb3 100644 --- a/packages/flutter/test/widgets/shader_mask_test.dart +++ b/packages/flutter/test/widgets/shader_mask_test.dart @@ -19,8 +19,8 @@ Shader createShader(Rect bounds) { void main() { testWidgets('Can be constructed', (WidgetTester tester) async { - final Widget child = new Container(width: 100.0, height: 100.0); - await tester.pumpWidget(new ShaderMask(child: child, shaderCallback: createShader)); + final Widget child = Container(width: 100.0, height: 100.0); + await tester.pumpWidget(ShaderMask(child: child, shaderCallback: createShader)); }); testWidgets('Bounds rect includes offset', (WidgetTester tester) async { @@ -30,20 +30,20 @@ void main() { return createShader(bounds); } - final Widget widget = new Align( + final Widget widget = Align( alignment: Alignment.center, - child: new SizedBox( + child: SizedBox( width: 400.0, height: 400.0, - child: new ShaderMask( + child: ShaderMask( shaderCallback: recordShaderBounds, - child: new Container(width: 100.0, height: 100.0) + child: Container(width: 100.0, height: 100.0) ), ), ); await tester.pumpWidget(widget); // The shader bounds rectangle should reflect the position of the centered SizedBox. - expect(shaderBounds, equals(new Rect.fromLTWH(200.0, 100.0, 400.0, 400.0))); + expect(shaderBounds, equals(Rect.fromLTWH(200.0, 100.0, 400.0, 400.0))); }); } diff --git a/packages/flutter/test/widgets/shadow_test.dart b/packages/flutter/test/widgets/shadow_test.dart index 29dfa802f0..e5594545b0 100644 --- a/packages/flutter/test/widgets/shadow_test.dart +++ b/packages/flutter/test/widgets/shadow_test.dart @@ -10,11 +10,11 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Shadows on BoxDecoration', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( margin: const EdgeInsets.all(50.0), - decoration: new BoxDecoration( + decoration: BoxDecoration( boxShadow: kElevationToShadow[9], ), height: 100.0, @@ -43,12 +43,12 @@ void main() { testWidgets('Shadows on ShapeDecoration', (WidgetTester tester) async { debugDisableShadows = false; Widget build(int elevation) { - return new Center( - child: new RepaintBoundary( - child: new Container( + return Center( + child: RepaintBoundary( + child: Container( margin: const EdgeInsets.all(150.0), - decoration: new ShapeDecoration( - shape: new BeveledRectangleBorder(borderRadius: new BorderRadius.circular(20.0)), + decoration: ShapeDecoration( + shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(20.0)), shadows: kElevationToShadow[elevation], ), height: 100.0, @@ -69,12 +69,12 @@ void main() { testWidgets('Shadows with PhysicalLayer', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( margin: const EdgeInsets.all(150.0), color: Colors.yellow[200], - child: new PhysicalModel( + child: PhysicalModel( elevation: 9.0, color: Colors.blue[900], child: const SizedBox( @@ -106,14 +106,14 @@ void main() { testWidgets('Shadows with PhysicalShape', (WidgetTester tester) async { debugDisableShadows = false; Widget build(double elevation) { - return new Center( - child: new RepaintBoundary( - child: new Container( + return Center( + child: RepaintBoundary( + child: Container( padding: const EdgeInsets.all(150.0), color: Colors.yellow[200], - child: new PhysicalShape( + child: PhysicalShape( color: Colors.green[900], - clipper: new ShapeBorderClipper(shape: new BeveledRectangleBorder(borderRadius: new BorderRadius.circular(20.0))), + clipper: ShapeBorderClipper(shape: BeveledRectangleBorder(borderRadius: BorderRadius.circular(20.0))), elevation: elevation, child: const SizedBox( height: 100.0, diff --git a/packages/flutter/test/widgets/shape_decoration_test.dart b/packages/flutter/test/widgets/shape_decoration_test.dart index 9fa7d0ec2b..64c27bdf76 100644 --- a/packages/flutter/test/widgets/shape_decoration_test.dart +++ b/packages/flutter/test/widgets/shape_decoration_test.dart @@ -13,16 +13,16 @@ import '../painting/mocks_for_image_cache.dart'; import '../rendering/mock_canvas.dart'; Future main() async { - final ui.Image rawImage = await decodeImageFromList(new Uint8List.fromList(kTransparentImage)); - final ImageProvider image = new TestImageProvider(0, 0, image: rawImage); + final ui.Image rawImage = await decodeImageFromList(Uint8List.fromList(kTransparentImage)); + final ImageProvider image = TestImageProvider(0, 0, image: rawImage); testWidgets('ShapeDecoration.image', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new DecoratedBox( - decoration: new ShapeDecoration( - shape: new Border.all(width: 1.0, color: Colors.white) + - new Border.all(width: 1.0, color: Colors.black), - image: new DecorationImage( + MaterialApp( + home: DecoratedBox( + decoration: ShapeDecoration( + shape: Border.all(width: 1.0, color: Colors.white) + + Border.all(width: 1.0, color: Colors.black), + image: DecorationImage( image: image, ), ), @@ -40,11 +40,11 @@ Future main() async { testWidgets('ShapeDecoration.color', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new DecoratedBox( - decoration: new ShapeDecoration( - shape: new Border.all(width: 1.0, color: Colors.white) + - new Border.all(width: 1.0, color: Colors.black), + MaterialApp( + home: DecoratedBox( + decoration: ShapeDecoration( + shape: Border.all(width: 1.0, color: Colors.white) + + Border.all(width: 1.0, color: Colors.black), color: Colors.blue, ), ), @@ -53,7 +53,7 @@ Future main() async { expect( find.byType(DecoratedBox), paints - ..path(color: new Color(Colors.blue.value)) + ..path(color: Color(Colors.blue.value)) ..rect(color: Colors.black) ..rect(color: Colors.white) ); @@ -62,10 +62,10 @@ Future main() async { testWidgets('TestBorder and Directionality - 1', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( - new MaterialApp( - home: new DecoratedBox( - decoration: new ShapeDecoration( - shape: new TestBorder(log.add), + MaterialApp( + home: DecoratedBox( + decoration: ShapeDecoration( + shape: TestBorder(log.add), color: Colors.green, ), ), @@ -83,12 +83,12 @@ Future main() async { testWidgets('TestBorder and Directionality - 2', (WidgetTester tester) async { final List log = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new DecoratedBox( - decoration: new ShapeDecoration( - shape: new TestBorder(log.add), - image: new DecorationImage( + child: DecoratedBox( + decoration: ShapeDecoration( + shape: TestBorder(log.add), + image: DecorationImage( image: image, ), ), @@ -116,18 +116,18 @@ class TestBorder extends ShapeBorder { EdgeInsetsGeometry get dimensions => const EdgeInsetsDirectional.only(start: 1.0); @override - ShapeBorder scale(double t) => new TestBorder(onLog); + ShapeBorder scale(double t) => TestBorder(onLog); @override Path getInnerPath(Rect rect, { TextDirection textDirection }) { onLog('getInnerPath $rect $textDirection'); - return new Path(); + return Path(); } @override Path getOuterPath(Rect rect, { TextDirection textDirection }) { onLog('getOuterPath $rect $textDirection'); - return new Path(); + return Path(); } @override diff --git a/packages/flutter/test/widgets/simple_semantics_test.dart b/packages/flutter/test/widgets/simple_semantics_test.dart index e536542b62..9d5db74bfd 100644 --- a/packages/flutter/test/widgets/simple_semantics_test.dart +++ b/packages/flutter/test/widgets/simple_semantics_test.dart @@ -13,7 +13,7 @@ import 'semantics_tester.dart'; void main() { testWidgets('Simple tree is simple', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const Center( @@ -21,14 +21,14 @@ void main() { ), ); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 1, label: 'Hello!', textDirection: TextDirection.ltr, - rect: new Rect.fromLTRB(0.0, 0.0, 84.0, 14.0), - transform: new Matrix4.translationValues(358.0, 293.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 84.0, 14.0), + transform: Matrix4.translationValues(358.0, 293.0, 0.0), ) ], ))); @@ -37,14 +37,14 @@ void main() { }); testWidgets('Simple tree is simple - material', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); // Not using Text widget because of https://github.com/flutter/flutter/issues/12357. - await tester.pumpWidget(new MaterialApp( - home: new Center( - child: new Semantics( + await tester.pumpWidget(MaterialApp( + home: Center( + child: Semantics( label: 'Hello!', - child: new Container( + child: Container( width: 10.0, height: 10.0, ), @@ -52,23 +52,23 @@ void main() { ), )); - expect(semantics, hasSemantics(new TestSemantics.root( + expect(semantics, hasSemantics(TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( id: 2, - rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), + rect: Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), children: [ - new TestSemantics( + TestSemantics( id: 3, - rect: new Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), + rect: Rect.fromLTWH(0.0, 0.0, 800.0, 600.0), flags: [SemanticsFlag.scopesRoute], children: [ - new TestSemantics( + TestSemantics( id: 4, label: 'Hello!', textDirection: TextDirection.ltr, - rect: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), - transform: new Matrix4.translationValues(395.0, 295.0, 0.0), + rect: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0), + transform: Matrix4.translationValues(395.0, 295.0, 0.0), ) ], ), diff --git a/packages/flutter/test/widgets/single_child_scroll_view_test.dart b/packages/flutter/test/widgets/single_child_scroll_view_test.dart index 6d19b501c8..d974141bf9 100644 --- a/packages/flutter/test/widgets/single_child_scroll_view_test.dart +++ b/packages/flutter/test/widgets/single_child_scroll_view_test.dart @@ -27,7 +27,7 @@ class TestScrollPosition extends ScrollPositionWithSingleContext { class TestScrollController extends ScrollController { @override ScrollPosition createScrollPosition(ScrollPhysics physics, ScrollContext context, ScrollPosition oldPosition) { - return new TestScrollPosition( + return TestScrollPosition( physics: physics, state: context, initialPixels: initialScrollOffset, @@ -38,8 +38,8 @@ class TestScrollController extends ScrollController { void main() { testWidgets('SingleChildScrollView control test', (WidgetTester tester) async { - await tester.pumpWidget(new SingleChildScrollView( - child: new Container( + await tester.pumpWidget(SingleChildScrollView( + child: Container( height: 2000.0, color: const Color(0xFF00FF00), ), @@ -54,18 +54,18 @@ void main() { }); testWidgets('Changing controllers changes scroll position', (WidgetTester tester) async { - final TestScrollController controller = new TestScrollController(); + final TestScrollController controller = TestScrollController(); - await tester.pumpWidget(new SingleChildScrollView( - child: new Container( + await tester.pumpWidget(SingleChildScrollView( + child: Container( height: 2000.0, color: const Color(0xFF00FF00), ), )); - await tester.pumpWidget(new SingleChildScrollView( + await tester.pumpWidget(SingleChildScrollView( controller: controller, - child: new Container( + child: Container( height: 2000.0, color: const Color(0xFF00FF00), ), @@ -76,12 +76,12 @@ void main() { }); testWidgets('Sets PrimaryScrollController when primary', (WidgetTester tester) async { - final ScrollController primaryScrollController = new ScrollController(); - await tester.pumpWidget(new PrimaryScrollController( + final ScrollController primaryScrollController = ScrollController(); + await tester.pumpWidget(PrimaryScrollController( controller: primaryScrollController, - child: new SingleChildScrollView( + child: SingleChildScrollView( primary: true, - child: new Container( + child: Container( height: 2000.0, color: const Color(0xFF00FF00), ), @@ -94,15 +94,15 @@ void main() { testWidgets('Changing scroll controller inside dirty layout builder does not assert', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); - await tester.pumpWidget(new Center( - child: new SizedBox( + await tester.pumpWidget(Center( + child: SizedBox( width: 750.0, - child: new LayoutBuilder( + child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new SingleChildScrollView( - child: new Container( + return SingleChildScrollView( + child: Container( height: 2000.0, color: const Color(0xFF00FF00), ), @@ -112,14 +112,14 @@ void main() { ), )); - await tester.pumpWidget(new Center( - child: new SizedBox( + await tester.pumpWidget(Center( + child: SizedBox( width: 700.0, - child: new LayoutBuilder( + child: LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new SingleChildScrollView( + return SingleChildScrollView( controller: controller, - child: new Container( + child: Container( height: 2000.0, color: const Color(0xFF00FF00), ), @@ -131,18 +131,18 @@ void main() { }); testWidgets('Vertical SingleChildScrollViews are primary by default', (WidgetTester tester) async { - final SingleChildScrollView view = new SingleChildScrollView(scrollDirection: Axis.vertical); + final SingleChildScrollView view = SingleChildScrollView(scrollDirection: Axis.vertical); expect(view.primary, isTrue); }); testWidgets('Horizontal SingleChildScrollViews are non-primary by default', (WidgetTester tester) async { - final SingleChildScrollView view = new SingleChildScrollView(scrollDirection: Axis.horizontal); + final SingleChildScrollView view = SingleChildScrollView(scrollDirection: Axis.horizontal); expect(view.primary, isFalse); }); testWidgets('SingleChildScrollViews with controllers are non-primary by default', (WidgetTester tester) async { - final SingleChildScrollView view = new SingleChildScrollView( - controller: new ScrollController(), + final SingleChildScrollView view = SingleChildScrollView( + controller: ScrollController(), scrollDirection: Axis.vertical, ); expect(view.primary, isFalse); @@ -150,17 +150,17 @@ void main() { testWidgets('Nested scrollables have a null PrimaryScrollController', (WidgetTester tester) async { const Key innerKey = Key('inner'); - final ScrollController primaryScrollController = new ScrollController(); + final ScrollController primaryScrollController = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new PrimaryScrollController( + child: PrimaryScrollController( controller: primaryScrollController, - child: new SingleChildScrollView( + child: SingleChildScrollView( primary: true, - child: new Container( + child: Container( constraints: const BoxConstraints(maxHeight: 200.0), - child: new ListView(key: innerKey, primary: true), + child: ListView(key: innerKey, primary: true), ), ), ), @@ -177,19 +177,19 @@ void main() { }); testWidgets('SingleChildScrollView semantics', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); - final ScrollController controller = new ScrollController(); + final SemanticsTester semantics = SemanticsTester(tester); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new SingleChildScrollView( + child: SingleChildScrollView( controller: controller, - child: new Column( - children: new List.generate(30, (int i) { - return new Container( + child: Column( + children: List.generate(30, (int i) { + return Container( height: 200.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -198,33 +198,33 @@ void main() { ); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, ], children: [ - new TestSemantics( + TestSemantics( label: r'Tile 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], label: r'Tile 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden,], label: r'Tile 4', @@ -241,48 +241,48 @@ void main() { await tester.pumpAndSettle(); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], label: r'Tile 13', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], label: r'Tile 14', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 15', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 16', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 17', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], label: r'Tile 18', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], @@ -300,36 +300,36 @@ void main() { await tester.pumpAndSettle(); expect(semantics, hasSemantics( - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], label: r'Tile 25', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.isHidden, ], label: r'Tile 26', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 27', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 28', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: r'Tile 29', textDirection: TextDirection.ltr, ), @@ -346,20 +346,20 @@ void main() { testWidgets('SingleChildScrollView getOffsetToReveal - down', (WidgetTester tester) async { List children; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 300.0, - child: new SingleChildScrollView( - controller: new ScrollController(initialScrollOffset: 300.0), - child: new Column( - children: children = new List.generate(20, (int i) { - return new Container( + child: SingleChildScrollView( + controller: ScrollController(initialScrollOffset: 300.0), + child: Column( + children: children = List.generate(20, (int i) { + return Container( height: 100.0, width: 300.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -374,40 +374,40 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5])); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 540.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 350.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); }); testWidgets('SingleChildScrollView getOffsetToReveal - up', (WidgetTester tester) async { - final List children = new List.generate(20, (int i) { - return new Container( + final List children = List.generate(20, (int i) { + return Container( height: 100.0, width: 300.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 300.0, - child: new SingleChildScrollView( - controller: new ScrollController(initialScrollOffset: 300.0), + child: SingleChildScrollView( + controller: ScrollController(initialScrollOffset: 300.0), reverse: true, - child: new Column( + child: Column( children: children.reversed.toList(), ), ), @@ -421,40 +421,40 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5])); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 100.0, 300.0, 100.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 300.0, 100.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 550.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 190.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 360.0); - expect(revealed.rect, new Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(40.0, 0.0, 10.0, 10.0)); }); testWidgets('SingleChildScrollView getOffsetToReveal - right', (WidgetTester tester) async { List children; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 300.0, width: 200.0, - child: new SingleChildScrollView( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, - controller: new ScrollController(initialScrollOffset: 300.0), - child: new Row( - children: children = new List.generate(20, (int i) { - return new Container( + controller: ScrollController(initialScrollOffset: 300.0), + child: Row( + children: children = List.generate(20, (int i) { + return Container( height: 300.0, width: 100.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }), ), @@ -469,42 +469,42 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5])); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 540.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 350.0); - expect(revealed.rect, new Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); }); testWidgets('SingleChildScrollView getOffsetToReveal - left', (WidgetTester tester) async { - final List children = new List.generate(20, (int i) { - return new Container( + final List children = List.generate(20, (int i) { + return Container( height: 300.0, width: 100.0, - child: new Text('Tile $i'), + child: Text('Tile $i'), ); }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 300.0, width: 200.0, - child: new SingleChildScrollView( + child: SingleChildScrollView( scrollDirection: Axis.horizontal, reverse: true, - controller: new ScrollController(initialScrollOffset: 300.0), - child: new Row( + controller: ScrollController(initialScrollOffset: 300.0), + child: Row( children: children.reversed.toList(), ), ), @@ -518,23 +518,23 @@ void main() { final RenderObject target = tester.renderObject(find.byWidget(children[5])); RevealedOffset revealed = viewport.getOffsetToReveal(target, 0.0); expect(revealed.offset, 500.0); - expect(revealed.rect, new Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(100.0, 0.0, 100.0, 300.0)); revealed = viewport.getOffsetToReveal(target, 1.0); expect(revealed.offset, 400.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 0.0, 100.0, 300.0)); - revealed = viewport.getOffsetToReveal(target, 0.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 0.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 550.0); - expect(revealed.rect, new Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(190.0, 40.0, 10.0, 10.0)); - revealed = viewport.getOffsetToReveal(target, 1.0, rect: new Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); + revealed = viewport.getOffsetToReveal(target, 1.0, rect: Rect.fromLTWH(40.0, 40.0, 10.0, 10.0)); expect(revealed.offset, 360.0); - expect(revealed.rect, new Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); + expect(revealed.rect, Rect.fromLTWH(0.0, 40.0, 10.0, 10.0)); }); testWidgets('Nested SingleChildScrollView showOnScreen', (WidgetTester tester) async { - final List> children = new List>(10); + final List> children = List>(10); ScrollController controllerX; ScrollController controllerY; @@ -557,22 +557,22 @@ void main() { /// viewport. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 200.0, - child: new SingleChildScrollView( - controller: controllerY = new ScrollController(initialScrollOffset: 400.0), - child: new SingleChildScrollView( - controller: controllerX = new ScrollController(initialScrollOffset: 400.0), + child: SingleChildScrollView( + controller: controllerY = ScrollController(initialScrollOffset: 400.0), + child: SingleChildScrollView( + controller: controllerX = ScrollController(initialScrollOffset: 400.0), scrollDirection: Axis.horizontal, - child: new Column( - children: new List.generate(10, (int y) { - return new Row( - children: children[y] = new List.generate(10, (int x) { - return new Container( + child: Column( + children: List.generate(10, (int y) { + return Row( + children: children[y] = List.generate(10, (int x) { + return Container( height: 100.0, width: 100.0, ); @@ -699,36 +699,36 @@ void main() { Future buildNestedScroller({WidgetTester tester, ScrollController inner, ScrollController outer}) { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( + child: Center( child: Container( height: 200.0, width: 300.0, - child: new SingleChildScrollView( + child: SingleChildScrollView( controller: outer, - child: new Column( + child: Column( children: [ - new Container( + Container( height: 200.0, ), - new Container( + Container( height: 200.0, width: 300.0, - child: new SingleChildScrollView( + child: SingleChildScrollView( controller: inner, - child: new Column( - children: children = new List.generate(10, (int i) { - return new Container( + child: Column( + children: children = List.generate(10, (int i) { + return Container( height: 100.0, width: 300.0, - child: new Text('$i'), + child: Text('$i'), ); }), ), ), ), - new Container( + Container( height: 200.0, ) ], @@ -741,8 +741,8 @@ void main() { } testWidgets('in view in inner, but not in outer', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(); - final ScrollController outer = new ScrollController(); + final ScrollController inner = ScrollController(); + final ScrollController outer = ScrollController(); await buildNestedScroller( tester: tester, inner: inner, @@ -758,8 +758,8 @@ void main() { }); testWidgets('not in view of neither inner nor outer', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(); - final ScrollController outer = new ScrollController(); + final ScrollController inner = ScrollController(); + final ScrollController outer = ScrollController(); await buildNestedScroller( tester: tester, inner: inner, @@ -775,8 +775,8 @@ void main() { }); testWidgets('in view in inner and outer', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(initialScrollOffset: 200.0); - final ScrollController outer = new ScrollController(initialScrollOffset: 200.0); + final ScrollController inner = ScrollController(initialScrollOffset: 200.0); + final ScrollController outer = ScrollController(initialScrollOffset: 200.0); await buildNestedScroller( tester: tester, inner: inner, @@ -792,8 +792,8 @@ void main() { }); testWidgets('inner shown in outer, but item not visible', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(initialScrollOffset: 200.0); - final ScrollController outer = new ScrollController(initialScrollOffset: 200.0); + final ScrollController inner = ScrollController(initialScrollOffset: 200.0); + final ScrollController outer = ScrollController(initialScrollOffset: 200.0); await buildNestedScroller( tester: tester, inner: inner, @@ -809,8 +809,8 @@ void main() { }); testWidgets('inner half shown in outer, item only visible in inner', (WidgetTester tester) async { - final ScrollController inner = new ScrollController(); - final ScrollController outer = new ScrollController(initialScrollOffset: 100.0); + final ScrollController inner = ScrollController(); + final ScrollController outer = ScrollController(initialScrollOffset: 100.0); await buildNestedScroller( tester: tester, inner: inner, diff --git a/packages/flutter/test/widgets/size_changed_layout_notification_test.dart b/packages/flutter/test/widgets/size_changed_layout_notification_test.dart index 6a93660cf8..a92ebf41c0 100644 --- a/packages/flutter/test/widgets/size_changed_layout_notification_test.dart +++ b/packages/flutter/test/widgets/size_changed_layout_notification_test.dart @@ -8,8 +8,8 @@ import 'package:flutter_test/flutter_test.dart'; class NotifyMaterial extends StatelessWidget { @override Widget build(BuildContext context) { - new LayoutChangedNotification().dispatch(context); - return new Container(); + LayoutChangedNotification().dispatch(context); + return Container(); } } @@ -18,10 +18,10 @@ void main() { bool notified = false; await tester.pumpWidget( - new Center( - child: new NotificationListener( + Center( + child: NotificationListener( onNotification: (LayoutChangedNotification notification) { - throw new Exception('Should not reach this point.'); + throw Exception('Should not reach this point.'); }, child: const SizeChangedLayoutNotifier( child: SizedBox( @@ -34,8 +34,8 @@ void main() { ); await tester.pumpWidget( - new Center( - child: new NotificationListener( + Center( + child: NotificationListener( onNotification: (LayoutChangedNotification notification) { expect(notification, isInstanceOf()); notified = true; diff --git a/packages/flutter/test/widgets/sized_box_test.dart b/packages/flutter/test/widgets/sized_box_test.dart index ae80796c78..4d5ca9e725 100644 --- a/packages/flutter/test/widgets/sized_box_test.dart +++ b/packages/flutter/test/widgets/sized_box_test.dart @@ -19,11 +19,11 @@ void main() { expect(c.width, 10.0); expect(c.height, 20.0); - final SizedBox d = new SizedBox.fromSize(); + final SizedBox d = SizedBox.fromSize(); expect(d.width, isNull); expect(d.height, isNull); - final SizedBox e = new SizedBox.fromSize(size: const Size(1.0, 2.0)); + final SizedBox e = SizedBox.fromSize(size: const Size(1.0, 2.0)); expect(e.width, 1.0); expect(e.height, 2.0); @@ -37,11 +37,11 @@ void main() { }); testWidgets('SizedBox - no child', (WidgetTester tester) async { - final GlobalKey patient = new GlobalKey(); + final GlobalKey patient = GlobalKey(); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, ) ) @@ -49,8 +49,8 @@ void main() { expect(patient.currentContext.size, equals(const Size(0.0, 0.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, height: 0.0, ) @@ -59,8 +59,8 @@ void main() { expect(patient.currentContext.size, equals(const Size(0.0, 0.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, width: 0.0, height: 0.0, @@ -70,8 +70,8 @@ void main() { expect(patient.currentContext.size, equals(const Size(0.0, 0.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, width: 100.0, height: 100.0, @@ -81,8 +81,8 @@ void main() { expect(patient.currentContext.size, equals(const Size(100.0, 100.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, width: 1000.0, height: 1000.0, @@ -92,8 +92,8 @@ void main() { expect(patient.currentContext.size, equals(const Size(800.0, 600.0))); await tester.pumpWidget( - new Center( - child: new SizedBox.expand( + Center( + child: SizedBox.expand( key: patient, ) ) @@ -101,8 +101,8 @@ void main() { expect(patient.currentContext.size, equals(const Size(800.0, 600.0))); await tester.pumpWidget( - new Center( - child: new SizedBox.shrink( + Center( + child: SizedBox.shrink( key: patient, ) ) @@ -111,80 +111,80 @@ void main() { }); testWidgets('SizedBox - container child', (WidgetTester tester) async { - final GlobalKey patient = new GlobalKey(); + final GlobalKey patient = GlobalKey(); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, - child: new Container(), + child: Container(), ) ) ); expect(patient.currentContext.size, equals(const Size(800.0, 600.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, height: 0.0, - child: new Container(), + child: Container(), ) ) ); expect(patient.currentContext.size, equals(const Size(800.0, 0.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, width: 0.0, height: 0.0, - child: new Container(), + child: Container(), ) ) ); expect(patient.currentContext.size, equals(const Size(0.0, 0.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, width: 100.0, height: 100.0, - child: new Container(), + child: Container(), ) ) ); expect(patient.currentContext.size, equals(const Size(100.0, 100.0))); await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( key: patient, width: 1000.0, height: 1000.0, - child: new Container(), + child: Container(), ) ) ); expect(patient.currentContext.size, equals(const Size(800.0, 600.0))); await tester.pumpWidget( - new Center( - child: new SizedBox.expand( + Center( + child: SizedBox.expand( key: patient, - child: new Container(), + child: Container(), ) ) ); expect(patient.currentContext.size, equals(const Size(800.0, 600.0))); await tester.pumpWidget( - new Center( - child: new SizedBox.shrink( + Center( + child: SizedBox.shrink( key: patient, - child: new Container(), + child: Container(), ) ) ); diff --git a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart index 6836f4d648..ff2090b486 100644 --- a/packages/flutter/test/widgets/sliver_fill_remaining_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_remaining_test.dart @@ -7,14 +7,14 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('SliverFillRemaining - no siblings', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( controller: controller, slivers: [ - new SliverFillRemaining(child: new Container()), + SliverFillRemaining(child: Container()), ], ), ), @@ -35,15 +35,15 @@ void main() { }); testWidgets('SliverFillRemaining - one sibling', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( controller: controller, slivers: [ const SliverToBoxAdapter(child: SizedBox(height: 100.0)), - new SliverFillRemaining(child: new Container()), + SliverFillRemaining(child: Container()), ], ), ), diff --git a/packages/flutter/test/widgets/sliver_fill_viewport_test.dart b/packages/flutter/test/widgets/sliver_fill_viewport_test.dart index d6177f6436..159550623e 100644 --- a/packages/flutter/test/widgets/sliver_fill_viewport_test.dart +++ b/packages/flutter/test/widgets/sliver_fill_viewport_test.dart @@ -7,17 +7,17 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('SliverFillRemaining control test', (WidgetTester tester) async { - final List children = new List.generate(20, (int i) { - return new Container(child: new Text('$i', textDirection: TextDirection.ltr)); + final List children = List.generate(20, (int i) { + return Container(child: Text('$i', textDirection: TextDirection.ltr)); }); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new SliverFillViewport( - delegate: new SliverChildListDelegate(children, addAutomaticKeepAlives: false), + SliverFillViewport( + delegate: SliverChildListDelegate(children, addAutomaticKeepAlives: false), ), ], ), diff --git a/packages/flutter/test/widgets/sliver_list_test.dart b/packages/flutter/test/widgets/sliver_list_test.dart index 2ab12ac8eb..9ab78b700e 100644 --- a/packages/flutter/test/widgets/sliver_list_test.dart +++ b/packages/flutter/test/widgets/sliver_list_test.dart @@ -7,12 +7,12 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('SliverList reverse children (with keys)', (WidgetTester tester) async { - final List items = new List.generate(20, (int i) => i); + final List items = List.generate(20, (int i) => i); const double itemHeight = 300.0; const double viewportHeight = 500.0; const double scrollPosition = 18 * itemHeight; - final ScrollController controller = new ScrollController(initialScrollOffset: scrollPosition); + final ScrollController controller = ScrollController(initialScrollOffset: scrollPosition); await tester.pumpWidget(_buildSliverList( items: items, @@ -54,12 +54,12 @@ void main() { }); testWidgets('SliverList replace children (with keys)', (WidgetTester tester) async { - final List items = new List.generate(20, (int i) => i); + final List items = List.generate(20, (int i) => i); const double itemHeight = 300.0; const double viewportHeight = 500.0; const double scrollPosition = 18 * itemHeight; - final ScrollController controller = new ScrollController(initialScrollOffset: scrollPosition); + final ScrollController controller = ScrollController(initialScrollOffset: scrollPosition); await tester.pumpWidget(_buildSliverList( items: items, @@ -106,12 +106,12 @@ void main() { }); testWidgets('SliverList replace with shorter children list (with keys)', (WidgetTester tester) async { - final List items = new List.generate(20, (int i) => i); + final List items = List.generate(20, (int i) => i); const double itemHeight = 300.0; const double viewportHeight = 500.0; final double scrollPosition = items.length * itemHeight - viewportHeight; - final ScrollController controller = new ScrollController(initialScrollOffset: scrollPosition); + final ScrollController controller = ScrollController(initialScrollOffset: scrollPosition); await tester.pumpWidget(_buildSliverList( items: items, @@ -152,21 +152,21 @@ Widget _buildSliverList({ double itemHeight = 500.0, double viewportHeight = 300.0, }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Container( + child: Center( + child: Container( height: viewportHeight, - child: new CustomScrollView( + child: CustomScrollView( controller: controller, slivers: [ - new SliverList( - delegate: new SliverChildBuilderDelegate( + SliverList( + delegate: SliverChildBuilderDelegate( (BuildContext context, int i) { - return new Container( - key: new ValueKey(items[i]), + return Container( + key: ValueKey(items[i]), height: itemHeight, - child: new Text('Tile ${items[i]}'), + child: Text('Tile ${items[i]}'), ); }, childCount: items.length, diff --git a/packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart b/packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart index 8be2d77a9b..970903a554 100644 --- a/packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart +++ b/packages/flutter/test/widgets/sliver_prototype_item_extent_test.dart @@ -12,25 +12,25 @@ class TestItem extends StatelessWidget { final double height; @override Widget build(BuildContext context) { - return new Container( + return Container( width: width, height: height, alignment: Alignment.center, - child: new Text('Item $item', textDirection: TextDirection.ltr), + child: Text('Item $item', textDirection: TextDirection.ltr), ); } } Widget buildFrame({ int count, double width, double height, Axis scrollDirection }) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( scrollDirection: scrollDirection ?? Axis.vertical, slivers: [ - new SliverPrototypeExtentList( - prototypeItem: new TestItem(item: -1, width: width, height: height), - delegate: new SliverChildBuilderDelegate( - (BuildContext context, int index) => new TestItem(item: index), + SliverPrototypeExtentList( + prototypeItem: TestItem(item: -1, width: width, height: height), + delegate: SliverChildBuilderDelegate( + (BuildContext context, int index) => TestItem(item: index), childCount: count, ), ), @@ -109,18 +109,18 @@ void main() { }); testWidgets('SliverPrototypeExtentList first item is also the prototype', (WidgetTester tester) async { - final List items = new List.generate(10, (int index) { - return new TestItem(key: new ValueKey(index), item: index, height: index == 0 ? 60.0 : null); + final List items = List.generate(10, (int index) { + return TestItem(key: ValueKey(index), item: index, height: index == 0 ? 60.0 : null); }).toList(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new SliverPrototypeExtentList( + SliverPrototypeExtentList( prototypeItem: items[0], - delegate: new SliverChildBuilderDelegate( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) => items[index], childCount: 10, ), diff --git a/packages/flutter/test/widgets/sliver_semantics_test.dart b/packages/flutter/test/widgets/sliver_semantics_test.dart index b3f89c5464..9203be058d 100644 --- a/packages/flutter/test/widgets/sliver_semantics_test.dart +++ b/packages/flutter/test/widgets/sliver_semantics_test.dart @@ -23,25 +23,25 @@ void main() { void _tests() { testWidgets('excludeFromScrollable works correctly', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const double appBarExpandedHeight = 200.0; - final ScrollController scrollController = new ScrollController(); - final List listChildren = new List.generate(30, (int i) { - return new Container( + final ScrollController scrollController = ScrollController(); + final List listChildren = List.generate(30, (int i) { + return Container( height: appBarExpandedHeight, - child: new Text('Item $i'), + child: Text('Item $i'), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( + child: CustomScrollView( controller: scrollController, slivers: [ const SliverAppBar( @@ -49,8 +49,8 @@ void _tests() { expandedHeight: appBarExpandedHeight, title: Text('Semantics Test with Slivers'), ), - new SliverList( - delegate: new SliverChildListDelegate(listChildren), + SliverList( + delegate: SliverChildListDelegate(listChildren), ), ], ), @@ -61,23 +61,23 @@ void _tests() { // AppBar is child of node with semantic scroll actions. expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, children: [ - new TestSemantics( + TestSemantics( id: 9, actions: [SemanticsAction.scrollUp], children: [ - new TestSemantics( + TestSemantics( id: 7, children: [ - new TestSemantics( + TestSemantics( id: 8, flags: [ SemanticsFlag.namesRoute, @@ -88,23 +88,23 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( id: 3, label: 'Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 4, label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, flags: [SemanticsFlag.isHidden], label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, flags: [SemanticsFlag.isHidden], label: 'Item 3', @@ -128,20 +128,20 @@ void _tests() { // App bar is NOT a child of node with semantic scroll actions. expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, children: [ - new TestSemantics( + TestSemantics( id: 7, tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( id: 8, flags: [ SemanticsFlag.namesRoute, @@ -152,35 +152,35 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( id: 9, actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( id: 3, label: 'Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 4, label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, flags: [SemanticsFlag.isHidden], label: 'Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 10, flags: [SemanticsFlag.isHidden], label: 'Item 4', @@ -204,26 +204,26 @@ void _tests() { // AppBar is child of node with semantic scroll actions. expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( id: 1, textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( id: 2, children: [ - new TestSemantics( + TestSemantics( id: 9, actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( id: 7, children: [ - new TestSemantics( + TestSemantics( id: 8, flags: [ SemanticsFlag.namesRoute, @@ -234,22 +234,22 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( id: 3, label: 'Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 4, label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 5, label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( id: 6, flags: [SemanticsFlag.isHidden], label: 'Item 3', @@ -271,30 +271,30 @@ void _tests() { }); testWidgets('Offscreen sliver are hidden in semantics tree', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const double containerHeight = 200.0; - final ScrollController scrollController = new ScrollController( + final ScrollController scrollController = ScrollController( initialScrollOffset: containerHeight * 1.5, ); - final List slivers = new List.generate(30, (int i) { - return new SliverToBoxAdapter( - child: new Container( + final List slivers = List.generate(30, (int i) { + return SliverToBoxAdapter( + child: Container( height: containerHeight, - child: new Text('Item $i', textDirection: TextDirection.ltr), + child: Text('Item $i', textDirection: TextDirection.ltr), ), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new SizedBox( + child: Center( + child: SizedBox( height: containerHeight, - child: new CustomScrollView( + child: CustomScrollView( controller: scrollController, slivers: slivers, ), @@ -305,33 +305,33 @@ void _tests() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 3', textDirection: TextDirection.ltr, @@ -353,22 +353,22 @@ void _tests() { }); testWidgets('SemanticsNodes of Slivers are in paint order', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List slivers = new List.generate(5, (int i) { - return new SliverToBoxAdapter( - child: new Container( + final List slivers = List.generate(5, (int i) { + return SliverToBoxAdapter( + child: Container( height: 20.0, - child: new Text('Item $i'), + child: Text('Item $i'), ), ); }); await tester.pumpWidget( - new Semantics( + Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: slivers, ), ), @@ -376,35 +376,35 @@ void _tests() { ); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.hasImplicitScrolling, ], children: [ - new TestSemantics( + TestSemantics( label: 'Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 0', textDirection: TextDirection.ltr, ), @@ -426,30 +426,30 @@ void _tests() { }); testWidgets('SemanticsNodes of a sliver fully covered by another overlapping sliver are excluded', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(10, (int i) { - return new Container( + final List listChildren = List.generate(10, (int i) { + return Container( height: 200.0, - child: new Text('Item $i', textDirection: TextDirection.ltr), + child: Text('Item $i', textDirection: TextDirection.ltr), ); }); - final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); - await tester.pumpWidget(new Semantics( + final ScrollController controller = ScrollController(initialScrollOffset: 280.0); + await tester.pumpWidget(Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( + child: CustomScrollView( slivers: [ const SliverAppBar( pinned: true, expandedHeight: 100.0, title: Text('AppBar'), ), - new SliverList( - delegate: new SliverChildListDelegate(listChildren), + SliverList( + delegate: SliverChildListDelegate(listChildren), ), ], controller: controller, @@ -459,17 +459,17 @@ void _tests() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -479,35 +479,35 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 5', textDirection: TextDirection.ltr, @@ -529,24 +529,24 @@ void _tests() { }); testWidgets('Slivers fully covered by another overlapping sliver are hidden', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); - final List slivers = new List.generate(10, (int i) { - return new SliverToBoxAdapter( - child: new Container( + final ScrollController controller = ScrollController(initialScrollOffset: 280.0); + final List slivers = List.generate(10, (int i) { + return SliverToBoxAdapter( + child: Container( height: 200.0, - child: new Text('Item $i', textDirection: TextDirection.ltr), + child: Text('Item $i', textDirection: TextDirection.ltr), ), ); }); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( + child: CustomScrollView( controller: controller, slivers: [ const SliverAppBar( @@ -561,17 +561,17 @@ void _tests() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -581,35 +581,35 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 5', textDirection: TextDirection.ltr, @@ -631,22 +631,22 @@ void _tests() { }); testWidgets('SemanticsNodes of a sliver fully covered by another overlapping sliver are excluded (reverse)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final List listChildren = new List.generate(10, (int i) { - return new Container( + final List listChildren = List.generate(10, (int i) { + return Container( height: 200.0, - child: new Text('Item $i', textDirection: TextDirection.ltr), + child: Text('Item $i', textDirection: TextDirection.ltr), ); }); - final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); - await tester.pumpWidget(new Semantics( + final ScrollController controller = ScrollController(initialScrollOffset: 280.0); + await tester.pumpWidget(Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( + child: CustomScrollView( reverse: true, // This is the important setting for this test. slivers: [ const SliverAppBar( @@ -654,8 +654,8 @@ void _tests() { expandedHeight: 100.0, title: Text('AppBar'), ), - new SliverList( - delegate: new SliverChildListDelegate(listChildren), + SliverList( + delegate: SliverChildListDelegate(listChildren), ), ], controller: controller, @@ -665,52 +665,52 @@ void _tests() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 5', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 0', textDirection: TextDirection.ltr, ), ], ), - new TestSemantics( + TestSemantics( tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -735,24 +735,24 @@ void _tests() { }); testWidgets('Slivers fully covered by another overlapping sliver are hidden (reverse)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); - final List slivers = new List.generate(10, (int i) { - return new SliverToBoxAdapter( - child: new Container( + final ScrollController controller = ScrollController(initialScrollOffset: 280.0); + final List slivers = List.generate(10, (int i) { + return SliverToBoxAdapter( + child: Container( height: 200.0, - child: new Text('Item $i', textDirection: TextDirection.ltr), + child: Text('Item $i', textDirection: TextDirection.ltr), ), ); }); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( + child: CustomScrollView( reverse: true, // This is the important setting for this test. controller: controller, slivers: [ @@ -768,50 +768,50 @@ void _tests() { )); expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [SemanticsAction.scrollUp, SemanticsAction.scrollDown], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 5', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Item 0', textDirection: TextDirection.ltr, ), ], ), - new TestSemantics( + TestSemantics( tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -836,37 +836,37 @@ void _tests() { }); testWidgets('Slivers fully covered by another overlapping sliver are hidden (with center sliver)', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); - final ScrollController controller = new ScrollController(initialScrollOffset: 280.0); - final GlobalKey forwardAppBarKey = new GlobalKey(debugLabel: 'forward app bar'); - final List forwardChildren = new List.generate(10, (int i) { - return new Container( + final ScrollController controller = ScrollController(initialScrollOffset: 280.0); + final GlobalKey forwardAppBarKey = GlobalKey(debugLabel: 'forward app bar'); + final List forwardChildren = List.generate(10, (int i) { + return Container( height: 200.0, - child: new Text('Forward Item $i', textDirection: TextDirection.ltr), + child: Text('Forward Item $i', textDirection: TextDirection.ltr), ); }); - final List backwardChildren = new List.generate(10, (int i) { - return new Container( + final List backwardChildren = List.generate(10, (int i) { + return Container( height: 200.0, - child: new Text('Backward Item $i', textDirection: TextDirection.ltr), + child: Text('Backward Item $i', textDirection: TextDirection.ltr), ); }); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( textDirection: TextDirection.ltr, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new Scrollable( + child: Scrollable( controller: controller, viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( offset: offset, center: forwardAppBarKey, slivers: [ - new SliverList( - delegate: new SliverChildListDelegate(backwardChildren), + SliverList( + delegate: SliverChildListDelegate(backwardChildren), ), const SliverAppBar( pinned: true, @@ -875,7 +875,7 @@ void _tests() { title: Text('Backward app bar', textDirection: TextDirection.ltr), ), ), - new SliverAppBar( + SliverAppBar( pinned: true, key: forwardAppBarKey, expandedHeight: 100.0, @@ -883,8 +883,8 @@ void _tests() { title: Text('Forward app bar', textDirection: TextDirection.ltr), ), ), - new SliverList( - delegate: new SliverChildListDelegate(forwardChildren), + SliverList( + delegate: SliverChildListDelegate(forwardChildren), ), ], ); @@ -896,17 +896,17 @@ void _tests() { // 'Forward Item 0' is covered by app bar. expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, @@ -916,35 +916,35 @@ void _tests() { ), ], ), - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Forward Item 0', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Forward Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Forward Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Forward Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Forward Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Forward Item 5', textDirection: TextDirection.ltr, @@ -967,52 +967,52 @@ void _tests() { // 'Backward Item 0' is covered by app bar. expect(semantics, hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics( + TestSemantics( textDirection: TextDirection.ltr, children: [ - new TestSemantics( + TestSemantics( children: [ - new TestSemantics( + TestSemantics( actions: [ SemanticsAction.scrollUp, SemanticsAction.scrollDown, ], children: [ - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Backward Item 5', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Backward Item 4', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Backward Item 3', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Backward Item 2', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'Backward Item 1', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( flags: [SemanticsFlag.isHidden], label: 'Backward Item 0', textDirection: TextDirection.ltr, ), ], ), - new TestSemantics( + TestSemantics( tags: [RenderViewport.excludeFromScrolling], children: [ - new TestSemantics( + TestSemantics( flags: [ SemanticsFlag.namesRoute, SemanticsFlag.isHeader, diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart index 63dd86b87d..f91f6bd13f 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_pinned_test.dart @@ -7,13 +7,13 @@ import 'package:flutter/material.dart'; void main() { testWidgets('Sliver appbars - floating and pinned - second app bar stacks below', (WidgetTester tester) async { - final ScrollController controller = new ScrollController(); + final ScrollController controller = ScrollController(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new MediaQuery( + child: MediaQuery( data: const MediaQueryData(), - child: new CustomScrollView( + child: CustomScrollView( controller: controller, slivers: const [ SliverAppBar(floating: true, pinned: true, expandedHeight: 200.0, title: Text('A')), @@ -57,6 +57,6 @@ void main() { // we have scrolled 600.0 pixels // initial position of E was 200 + 56 + cSize.height + cSize.height + 500 // we've scrolled that up by 600.0, meaning it's at that minus 600 now: - expect(tester.getTopLeft(find.text('E')), new Offset(0.0, 200.0 + 56.0 + cSize.height * 2.0 + 500.0 - 600.0)); + expect(tester.getTopLeft(find.text('E')), Offset(0.0, 200.0 + 56.0 + cSize.height * 2.0 + 500.0 - 600.0)); }); } diff --git a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart index 96896b53de..932871c77e 100644 --- a/packages/flutter/test/widgets/slivers_appbar_floating_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_floating_test.dart @@ -18,7 +18,7 @@ void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) { void verifyActualBoxPosition(WidgetTester tester, Finder finder, int index, Rect ideal) { final RenderBox box = tester.renderObjectList(finder).elementAt(index); - final Rect rect = new Rect.fromPoints(box.localToGlobal(Offset.zero), box.localToGlobal(box.size.bottomRight(Offset.zero))); + final Rect rect = Rect.fromPoints(box.localToGlobal(Offset.zero), box.localToGlobal(box.size.bottomRight(Offset.zero))); expect(rect, equals(ideal)); } @@ -26,19 +26,19 @@ void main() { testWidgets('Sliver appbars - floating - scroll offset doesn\'t change', (WidgetTester tester) async { const double bigHeight = 1000.0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ const BigSliver(height: bigHeight), - new SliverPersistentHeader(delegate: new TestDelegate(), floating: true), + SliverPersistentHeader(delegate: TestDelegate(), floating: true), const BigSliver(height: bigHeight), ], ), ), ); final ScrollPosition position = tester.state(find.byType(Scrollable)).position; - final double max = bigHeight * 2.0 + new TestDelegate().maxExtent - 600.0; // 600 is the height of the test viewport + final double max = bigHeight * 2.0 + TestDelegate().maxExtent - 600.0; // 600 is the height of the test viewport assert(max < 10000.0); expect(max, 1600.0); expect(position.pixels, 0.0); @@ -52,17 +52,17 @@ void main() { }); testWidgets('Sliver appbars - floating - normal behavior works', (WidgetTester tester) async { - final TestDelegate delegate = new TestDelegate(); + final TestDelegate delegate = TestDelegate(); const double bigHeight = 1000.0; GlobalKey key1, key2, key3; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: delegate, floating: true), - new BigSliver(key: key3 = new GlobalKey(), height: bigHeight), + BigSliver(key: key1 = GlobalKey(), height: bigHeight), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: delegate, floating: true), + BigSliver(key: key3 = GlobalKey(), height: bigHeight), ], ), ), @@ -76,45 +76,45 @@ void main() { position.animateTo(bigHeight - 600.0 + delegate.maxExtent, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), true); - verifyPaintPosition(key2, new Offset(0.0, 600.0 - delegate.maxExtent), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent, 800.0, delegate.maxExtent)); + verifyPaintPosition(key2, Offset(0.0, 600.0 - delegate.maxExtent), true); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent, 800.0, delegate.maxExtent)); verifyPaintPosition(key3, const Offset(0.0, 600.0), false); assert(delegate.maxExtent * 2.0 < 600.0); // make sure this fits on the test screen... position.animateTo(bigHeight - 600.0 + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), true); - verifyPaintPosition(key2, new Offset(0.0, 600.0 - delegate.maxExtent * 2.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent * 2.0, 800.0, delegate.maxExtent)); - verifyPaintPosition(key3, new Offset(0.0, 600.0 - delegate.maxExtent), true); + verifyPaintPosition(key2, Offset(0.0, 600.0 - delegate.maxExtent * 2.0), true); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, 600.0 - delegate.maxExtent * 2.0, 800.0, delegate.maxExtent)); + verifyPaintPosition(key3, Offset(0.0, 600.0 - delegate.maxExtent), true); position.animateTo(bigHeight, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent)); - verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent), true); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent)); + verifyPaintPosition(key3, Offset(0.0, delegate.maxExtent), true); position.animateTo(bigHeight + delegate.maxExtent * 0.1, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.9)); - verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.9), true); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.9)); + verifyPaintPosition(key3, Offset(0.0, delegate.maxExtent * 0.9), true); position.animateTo(bigHeight + delegate.maxExtent * 0.5, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.5)); - verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.5), true); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, 0.0, 800.0, delegate.maxExtent * 0.5)); + verifyPaintPosition(key3, Offset(0.0, delegate.maxExtent * 0.5), true); position.animateTo(bigHeight + delegate.maxExtent * 0.9, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5)); - verifyPaintPosition(key3, new Offset(0.0, delegate.maxExtent * 0.1), true); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5)); + verifyPaintPosition(key3, Offset(0.0, delegate.maxExtent * 0.1), true); position.animateTo(bigHeight + delegate.maxExtent * 2.0, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); @@ -124,17 +124,17 @@ void main() { }); testWidgets('Sliver appbars - floating - no floating behavior when animating', (WidgetTester tester) async { - final TestDelegate delegate = new TestDelegate(); + final TestDelegate delegate = TestDelegate(); const double bigHeight = 1000.0; GlobalKey key1, key2, key3; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: delegate, floating: true), - new BigSliver(key: key3 = new GlobalKey(), height: bigHeight), + BigSliver(key: key1 = GlobalKey(), height: bigHeight), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: delegate, floating: true), + BigSliver(key: key3 = GlobalKey(), height: bigHeight), ], ), ), @@ -159,17 +159,17 @@ void main() { }); testWidgets('Sliver appbars - floating - floating behavior when dragging down', (WidgetTester tester) async { - final TestDelegate delegate = new TestDelegate(); + final TestDelegate delegate = TestDelegate(); const double bigHeight = 1000.0; GlobalKey key1, key2, key3; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: delegate, floating: true), - new BigSliver(key: key3 = new GlobalKey(), height: bigHeight), + BigSliver(key: key1 = GlobalKey(), height: bigHeight), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: delegate, floating: true), + BigSliver(key: key3 = GlobalKey(), height: bigHeight), ], ), ), @@ -191,18 +191,18 @@ void main() { await tester.pumpAndSettle(const Duration(milliseconds: 1000)); verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 0, new Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5)); + verifyActualBoxPosition(tester, find.byType(Container), 0, Rect.fromLTWH(0.0, -delegate.maxExtent * 0.4, 800.0, delegate.maxExtent * 0.5)); verifyPaintPosition(key3, const Offset(0.0, 0.0), true); }); testWidgets('Sliver appbars - floating - overscroll gap is below header', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( physics: const BouncingScrollPhysics(), slivers: [ - new SliverPersistentHeader(delegate: new TestDelegate(), floating: true), + SliverPersistentHeader(delegate: TestDelegate(), floating: true), const SliverList( delegate: SliverChildListDelegate([ SizedBox( @@ -237,7 +237,7 @@ class TestDelegate extends SliverPersistentHeaderDelegate { @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Container(constraints: new BoxConstraints(minHeight: minExtent, maxHeight: maxExtent)); + return Container(constraints: BoxConstraints(minHeight: minExtent, maxHeight: maxExtent)); } @override @@ -261,7 +261,7 @@ class RenderBigSliver extends RenderSliver { @override void performLayout() { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: height, paintExtent: paintExtent, maxPaintExtent: height, @@ -276,7 +276,7 @@ class BigSliver extends LeafRenderObjectWidget { @override RenderBigSliver createRenderObject(BuildContext context) { - return new RenderBigSliver(height); + return RenderBigSliver(height); } @override diff --git a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart index 24a733a142..013e8e7327 100644 --- a/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_pinned_test.dart @@ -18,7 +18,7 @@ void verifyPaintPosition(GlobalKey key, Offset ideal, bool visible) { void verifyActualBoxPosition(WidgetTester tester, Finder finder, int index, Rect ideal) { final RenderBox box = tester.renderObjectList(finder).elementAt(index); - final Rect rect = new Rect.fromPoints(box.localToGlobal(Offset.zero), box.localToGlobal(box.size.bottomRight(Offset.zero))); + final Rect rect = Rect.fromPoints(box.localToGlobal(Offset.zero), box.localToGlobal(box.size.bottomRight(Offset.zero))); expect(rect, equals(ideal)); } @@ -27,21 +27,21 @@ void main() { const double bigHeight = 550.0; GlobalKey key1, key2, key3, key4, key5; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), - new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), - new BigSliver(key: key4 = new GlobalKey(), height: bigHeight), - new BigSliver(key: key5 = new GlobalKey(), height: bigHeight), + BigSliver(key: key1 = GlobalKey(), height: bigHeight), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: TestDelegate(), pinned: true), + SliverPersistentHeader(key: key3 = GlobalKey(), delegate: TestDelegate(), pinned: true), + BigSliver(key: key4 = GlobalKey(), height: bigHeight), + BigSliver(key: key5 = GlobalKey(), height: bigHeight), ], ), ), ); final ScrollPosition position = tester.state(find.byType(Scrollable)).position; - final double max = bigHeight * 3.0 + new TestDelegate().maxExtent * 2.0 - 600.0; // 600 is the height of the test viewport + final double max = bigHeight * 3.0 + TestDelegate().maxExtent * 2.0 - 600.0; // 600 is the height of the test viewport assert(max < 10000.0); expect(max, 1450.0); expect(position.pixels, 0.0); @@ -60,14 +60,14 @@ void main() { }); testWidgets('Sliver appbars - toStringDeep of maxExtent that throws', (WidgetTester tester) async { - final TestDelegateThatCanThrow delegateThatCanThrow = new TestDelegateThatCanThrow(); + final TestDelegateThatCanThrow delegateThatCanThrow = TestDelegateThatCanThrow(); GlobalKey key; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new SliverPersistentHeader(key: key = new GlobalKey(), delegate: delegateThatCanThrow, pinned: true), + SliverPersistentHeader(key: key = GlobalKey(), delegate: delegateThatCanThrow, pinned: true), ], ), ), @@ -125,15 +125,15 @@ void main() { const double bigHeight = 550.0; GlobalKey key1, key2, key3, key4, key5; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), - new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), - new BigSliver(key: key4 = new GlobalKey(), height: bigHeight), - new BigSliver(key: key5 = new GlobalKey(), height: bigHeight), + BigSliver(key: key1 = GlobalKey(), height: bigHeight), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: TestDelegate(), pinned: true), + SliverPersistentHeader(key: key3 = GlobalKey(), delegate: TestDelegate(), pinned: true), + BigSliver(key: key4 = GlobalKey(), height: bigHeight), + BigSliver(key: key5 = GlobalKey(), height: bigHeight), ], ), ), @@ -164,7 +164,7 @@ void main() { verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 1, new Rect.fromLTWH(0.0, 100.0, 800.0, 200.0)); + verifyActualBoxPosition(tester, find.byType(Container), 1, Rect.fromLTWH(0.0, 100.0, 800.0, 200.0)); verifyPaintPosition(key4, const Offset(0.0, 300.0), true); verifyPaintPosition(key5, const Offset(0.0, 850.0), false); position.animateTo(700.0, curve: Curves.linear, duration: const Duration(minutes: 1)); @@ -172,7 +172,7 @@ void main() { verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 1, new Rect.fromLTWH(0.0, 100.0, 800.0, 200.0)); + verifyActualBoxPosition(tester, find.byType(Container), 1, Rect.fromLTWH(0.0, 100.0, 800.0, 200.0)); verifyPaintPosition(key4, const Offset(0.0, 250.0), true); verifyPaintPosition(key5, const Offset(0.0, 800.0), false); position.animateTo(750.0, curve: Curves.linear, duration: const Duration(minutes: 1)); @@ -180,7 +180,7 @@ void main() { verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 1, new Rect.fromLTWH(0.0, 100.0, 800.0, 200.0)); + verifyActualBoxPosition(tester, find.byType(Container), 1, Rect.fromLTWH(0.0, 100.0, 800.0, 200.0)); verifyPaintPosition(key4, const Offset(0.0, 200.0), true); verifyPaintPosition(key5, const Offset(0.0, 750.0), false); position.animateTo(800.0, curve: Curves.linear, duration: const Duration(minutes: 1)); @@ -209,7 +209,7 @@ void main() { verifyPaintPosition(key1, const Offset(0.0, 0.0), false); verifyPaintPosition(key2, const Offset(0.0, 0.0), true); verifyPaintPosition(key3, const Offset(0.0, 100.0), true); - verifyActualBoxPosition(tester, find.byType(Container), 1, new Rect.fromLTWH(0.0, 100.0, 800.0, 100.0)); + verifyActualBoxPosition(tester, find.byType(Container), 1, Rect.fromLTWH(0.0, 100.0, 800.0, 100.0)); verifyPaintPosition(key4, const Offset(0.0, 0.0), true); verifyPaintPosition(key5, const Offset(0.0, 550.0), true); }); @@ -218,21 +218,21 @@ void main() { const double bigHeight = 650.0; GlobalKey key1, key2, key3, key4, key5; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey(), height: bigHeight), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), - new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate(), pinned: true), - new BigSliver(key: key4 = new GlobalKey(), height: bigHeight), - new BigSliver(key: key5 = new GlobalKey(), height: bigHeight), + BigSliver(key: key1 = GlobalKey(), height: bigHeight), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: TestDelegate(), pinned: true), + SliverPersistentHeader(key: key3 = GlobalKey(), delegate: TestDelegate(), pinned: true), + BigSliver(key: key4 = GlobalKey(), height: bigHeight), + BigSliver(key: key5 = GlobalKey(), height: bigHeight), ], ), ), ); final ScrollPosition position = tester.state(find.byType(Scrollable)).position; - final double max = bigHeight * 3.0 + new TestDelegate().maxExtent * 2.0 - 600.0; // 600 is the height of the test viewport + final double max = bigHeight * 3.0 + TestDelegate().maxExtent * 2.0 - 600.0; // 600 is the height of the test viewport assert(max < 10000.0); expect(max, 1750.0); expect(position.pixels, 0.0); @@ -252,12 +252,12 @@ void main() { testWidgets('Sliver appbars - overscroll gap is below header', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( physics: const BouncingScrollPhysics(), slivers: [ - new SliverPersistentHeader(delegate: new TestDelegate(), pinned: true), + SliverPersistentHeader(delegate: TestDelegate(), pinned: true), const SliverList( delegate: SliverChildListDelegate([ SizedBox( @@ -304,7 +304,7 @@ class TestDelegate extends SliverPersistentHeaderDelegate { @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Container(constraints: new BoxConstraints(minHeight: minExtent, maxHeight: maxExtent)); + return Container(constraints: BoxConstraints(minHeight: minExtent, maxHeight: maxExtent)); } @override @@ -316,17 +316,17 @@ class TestDelegateThatCanThrow extends SliverPersistentHeaderDelegate { @override double get maxExtent { - return shouldThrow ? throw new FlutterError('Unavailable maxExtent') : 200.0; + return shouldThrow ? throw FlutterError('Unavailable maxExtent') : 200.0; } @override double get minExtent { - return shouldThrow ? throw new FlutterError('Unavailable minExtent') : 100.0; + return shouldThrow ? throw FlutterError('Unavailable minExtent') : 100.0; } @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Container(constraints: new BoxConstraints(minHeight: minExtent, maxHeight: maxExtent)); + return Container(constraints: BoxConstraints(minHeight: minExtent, maxHeight: maxExtent)); } @override @@ -350,7 +350,7 @@ class RenderBigSliver extends RenderSliver { @override void performLayout() { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: height, paintExtent: paintExtent, maxPaintExtent: height, @@ -365,7 +365,7 @@ class BigSliver extends LeafRenderObjectWidget { @override RenderBigSliver createRenderObject(BuildContext context) { - return new RenderBigSliver(height); + return RenderBigSliver(height); } @override diff --git a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart index a72b0cb83f..e88a48cf08 100644 --- a/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart +++ b/packages/flutter/test/widgets/slivers_appbar_scrolling_test.dart @@ -18,21 +18,21 @@ void main() { testWidgets('Sliver appbars - scrolling', (WidgetTester tester) async { GlobalKey key1, key2, key3, key4, key5; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey()), - new SliverPersistentHeader(key: key2 = new GlobalKey(), delegate: new TestDelegate()), - new SliverPersistentHeader(key: key3 = new GlobalKey(), delegate: new TestDelegate()), - new BigSliver(key: key4 = new GlobalKey()), - new BigSliver(key: key5 = new GlobalKey()), + BigSliver(key: key1 = GlobalKey()), + SliverPersistentHeader(key: key2 = GlobalKey(), delegate: TestDelegate()), + SliverPersistentHeader(key: key3 = GlobalKey(), delegate: TestDelegate()), + BigSliver(key: key4 = GlobalKey()), + BigSliver(key: key5 = GlobalKey()), ], ), ), ); final ScrollPosition position = tester.state(find.byType(Scrollable)).position; - final double max = RenderBigSliver.height * 3.0 + new TestDelegate().maxExtent * 2.0 - 600.0; // 600 is the height of the test viewport + final double max = RenderBigSliver.height * 3.0 + TestDelegate().maxExtent * 2.0 - 600.0; // 600 is the height of the test viewport assert(max < 10000.0); expect(max, 1450.0); expect(position.pixels, 0.0); @@ -51,15 +51,15 @@ void main() { }); testWidgets('Sliver appbars - scrolling off screen', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final TestDelegate delegate = new TestDelegate(); + final GlobalKey key = GlobalKey(); + final TestDelegate delegate = TestDelegate(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ const BigSliver(), - new SliverPersistentHeader(key: key, delegate: delegate), + SliverPersistentHeader(key: key, delegate: delegate), const BigSliver(), const BigSliver(), ], @@ -70,18 +70,18 @@ void main() { position.animateTo(RenderBigSliver.height + delegate.maxExtent - 5.0, curve: Curves.linear, duration: const Duration(minutes: 1)); await tester.pumpAndSettle(const Duration(milliseconds: 1000)); final RenderBox box = tester.renderObject(find.byType(Container)); - final Rect rect = new Rect.fromPoints(box.localToGlobal(Offset.zero), box.localToGlobal(box.size.bottomRight(Offset.zero))); - expect(rect, equals(new Rect.fromLTWH(0.0, -195.0, 800.0, 200.0))); + final Rect rect = Rect.fromPoints(box.localToGlobal(Offset.zero), box.localToGlobal(box.size.bottomRight(Offset.zero))); + expect(rect, equals(Rect.fromLTWH(0.0, -195.0, 800.0, 200.0))); }); testWidgets('Sliver appbars - scrolling - overscroll gap is below header', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( physics: const BouncingScrollPhysics(), slivers: [ - new SliverPersistentHeader(delegate: new TestDelegate()), + SliverPersistentHeader(delegate: TestDelegate()), const SliverList( delegate: SliverChildListDelegate([ SizedBox( @@ -116,7 +116,7 @@ class TestDelegate extends SliverPersistentHeaderDelegate { @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Container(height: maxExtent); + return Container(height: maxExtent); } @override @@ -130,7 +130,7 @@ class RenderBigSliver extends RenderSliver { @override void performLayout() { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: height, paintExtent: paintExtent, maxPaintExtent: height, @@ -142,6 +142,6 @@ class BigSliver extends LeafRenderObjectWidget { const BigSliver({ Key key }) : super(key: key); @override RenderBigSliver createRenderObject(BuildContext context) { - return new RenderBigSliver(); + return RenderBigSliver(); } } diff --git a/packages/flutter/test/widgets/slivers_block_global_key_test.dart b/packages/flutter/test/widgets/slivers_block_global_key_test.dart index afcbb99449..92a28604c8 100644 --- a/packages/flutter/test/widgets/slivers_block_global_key_test.dart +++ b/packages/flutter/test/widgets/slivers_block_global_key_test.dart @@ -12,14 +12,14 @@ class GenerationText extends StatefulWidget { const GenerationText(this.value); final int value; @override - _GenerationTextState createState() => new _GenerationTextState(); + _GenerationTextState createState() => _GenerationTextState(); } class _GenerationTextState extends State { _GenerationTextState() : generation = globalGeneration; final int generation; @override - Widget build(BuildContext context) => new Text('${widget.value}:$generation ', textDirection: TextDirection.ltr); + Widget build(BuildContext context) => Text('${widget.value}:$generation ', textDirection: TextDirection.ltr); } // Creates a SliverList with `keys.length` children and each child having a key from `keys` and a text of `key:generation`. @@ -27,15 +27,15 @@ class _GenerationTextState extends State { Future test(WidgetTester tester, double offset, List keys) { globalGeneration += 1; return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( cacheExtent: 0.0, - offset: new ViewportOffset.fixed(offset), + offset: ViewportOffset.fixed(offset), slivers: [ - new SliverList( - delegate: new SliverChildListDelegate(keys.map((int key) { - return new SizedBox(key: new GlobalObjectKey(key), height: 100.0, child: new GenerationText(key)); + SliverList( + delegate: SliverChildListDelegate(keys.map((int key) { + return SizedBox(key: GlobalObjectKey(key), height: 100.0, child: GenerationText(key)); }).toList()), ), ], diff --git a/packages/flutter/test/widgets/slivers_block_test.dart b/packages/flutter/test/widgets/slivers_block_test.dart index d319be6a8b..d433be9acb 100644 --- a/packages/flutter/test/widgets/slivers_block_test.dart +++ b/packages/flutter/test/widgets/slivers_block_test.dart @@ -10,10 +10,10 @@ import '../rendering/mock_canvas.dart'; Future test(WidgetTester tester, double offset) { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(offset), + child: Viewport( + offset: ViewportOffset.fixed(offset), slivers: const [ SliverList( delegate: SliverChildListDelegate([ @@ -77,19 +77,19 @@ void main() { }); testWidgets('Viewport with GlobalKey reparenting', (WidgetTester tester) async { - final Key key1 = new GlobalKey(); - final ViewportOffset offset = new ViewportOffset.zero(); + final Key key1 = GlobalKey(); + final ViewportOffset offset = ViewportOffset.zero(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( offset: offset, slivers: [ - new SliverList( - delegate: new SliverChildListDelegate([ + SliverList( + delegate: SliverChildListDelegate([ const SizedBox(height: 251.0, child: Text('a')), const SizedBox(height: 252.0, child: Text('b')), - new SizedBox(key: key1, height: 253.0, child: const Text('c')), + SizedBox(key: key1, height: 253.0, child: const Text('c')), ]), ), ], @@ -102,14 +102,14 @@ void main() { const Offset(0.0, 503.0), ], 'abc'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( offset: offset, slivers: [ - new SliverList( - delegate: new SliverChildListDelegate([ - new SizedBox(key: key1, height: 253.0, child: const Text('c')), + SliverList( + delegate: SliverChildListDelegate([ + SizedBox(key: key1, height: 253.0, child: const Text('c')), const SizedBox(height: 251.0, child: Text('a')), const SizedBox(height: 252.0, child: Text('b')), ]), @@ -124,15 +124,15 @@ void main() { const Offset(0.0, 504.0), ], 'cab'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( offset: offset, slivers: [ - new SliverList( - delegate: new SliverChildListDelegate([ + SliverList( + delegate: SliverChildListDelegate([ const SizedBox(height: 251.0, child: Text('a')), - new SizedBox(key: key1, height: 253.0, child: const Text('c')), + SizedBox(key: key1, height: 253.0, child: const Text('c')), const SizedBox(height: 252.0, child: Text('b')), ]), ), @@ -146,9 +146,9 @@ void main() { const Offset(0.0, 504.0), ], 'acb'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( offset: offset, slivers: const [ SliverList( @@ -166,15 +166,15 @@ void main() { const Offset(0.0, 251.0), ], 'ab'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( offset: offset, slivers: [ - new SliverList( - delegate: new SliverChildListDelegate([ + SliverList( + delegate: SliverChildListDelegate([ const SizedBox(height: 251.0, child: Text('a')), - new SizedBox(key: key1, height: 253.0, child: const Text('c')), + SizedBox(key: key1, height: 253.0, child: const Text('c')), const SizedBox(height: 252.0, child: Text('b')), ]), ), @@ -191,10 +191,10 @@ void main() { testWidgets('Viewport overflow clipping of SliverToBoxAdapter', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.zero(), + child: Viewport( + offset: ViewportOffset.zero(), slivers: const [ SliverToBoxAdapter( child: SizedBox(height: 400.0, child: Text('a')), @@ -207,10 +207,10 @@ void main() { expect(find.byType(Viewport), isNot(paints..clipRect())); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(100.0), + child: Viewport( + offset: ViewportOffset.fixed(100.0), slivers: const [ SliverToBoxAdapter( child: SizedBox(height: 400.0, child: Text('a')), @@ -223,10 +223,10 @@ void main() { expect(find.byType(Viewport), paints..clipRect()); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(100.0), + child: Viewport( + offset: ViewportOffset.fixed(100.0), slivers: const [ SliverToBoxAdapter( child: SizedBox(height: 4000.0, child: Text('a')), @@ -239,10 +239,10 @@ void main() { expect(find.byType(Viewport), paints..clipRect()); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.zero(), + child: Viewport( + offset: ViewportOffset.zero(), slivers: const [ SliverToBoxAdapter( child: SizedBox(height: 4000.0, child: Text('a')), @@ -257,10 +257,10 @@ void main() { testWidgets('Viewport overflow clipping of SliverBlock', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.zero(), + child: Viewport( + offset: ViewportOffset.zero(), slivers: const [ SliverList( delegate: SliverChildListDelegate([ @@ -275,10 +275,10 @@ void main() { expect(find.byType(Viewport), isNot(paints..clipRect())); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(100.0), + child: Viewport( + offset: ViewportOffset.fixed(100.0), slivers: const [ SliverList( delegate: SliverChildListDelegate([ @@ -293,10 +293,10 @@ void main() { expect(find.byType(Viewport), paints..clipRect()); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(100.0), + child: Viewport( + offset: ViewportOffset.fixed(100.0), slivers: const [ SliverList( delegate: SliverChildListDelegate([ @@ -311,10 +311,10 @@ void main() { expect(find.byType(Viewport), paints..clipRect()); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.zero(), + child: Viewport( + offset: ViewportOffset.zero(), slivers: const [ SliverList( delegate: SliverChildListDelegate([ diff --git a/packages/flutter/test/widgets/slivers_evil_test.dart b/packages/flutter/test/widgets/slivers_evil_test.dart index 3443e0edc0..f03e416f4c 100644 --- a/packages/flutter/test/widgets/slivers_evil_test.dart +++ b/packages/flutter/test/widgets/slivers_evil_test.dart @@ -20,10 +20,10 @@ class TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate @override Widget build(BuildContext context, double shrinkOffset, bool overlapsContent) { - return new Column( + return Column( children: [ - new Container(height: minExtent), - new Expanded(child: new Container()), + Container(height: minExtent), + Expanded(child: Container()), ], ); } @@ -35,7 +35,7 @@ class TestSliverPersistentHeaderDelegate extends SliverPersistentHeaderDelegate class TestBehavior extends ScrollBehavior { @override Widget buildViewportChrome(BuildContext context, Widget child, AxisDirection axisDirection) { - return new GlowingOverscrollIndicator( + return GlowingOverscrollIndicator( child: child, axisDirection: axisDirection, color: const Color(0xFFFFFFFF), @@ -48,7 +48,7 @@ class TestScrollPhysics extends ClampingScrollPhysics { @override TestScrollPhysics applyTo(ScrollPhysics ancestor) { - return new TestScrollPhysics(parent: parent?.applyTo(ancestor) ?? ancestor); + return TestScrollPhysics(parent: parent?.applyTo(ancestor) ?? ancestor); } @override @@ -72,88 +72,88 @@ class TestViewportScrollPosition extends ScrollPositionWithSingleContext { void main() { testWidgets('Evil test of sliver features - 1', (WidgetTester tester) async { - final GlobalKey centerKey = new GlobalKey(); - await tester.pumpWidget(new Directionality( + final GlobalKey centerKey = GlobalKey(); + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new ScrollConfiguration( - behavior: new TestBehavior(), - child: new Scrollbar( - child: new Scrollable( + child: ScrollConfiguration( + behavior: TestBehavior(), + child: Scrollbar( + child: Scrollable( axisDirection: AxisDirection.down, physics: const TestScrollPhysics(), viewportBuilder: (BuildContext context, ViewportOffset offset) { - return new Viewport( + return Viewport( axisDirection: AxisDirection.down, anchor: 0.25, offset: offset, center: centerKey, slivers: [ - new SliverToBoxAdapter(child: new Container(height: 5.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), pinned: true), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPadding( + SliverToBoxAdapter(child: Container(height: 5.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(150.0), pinned: true), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPadding( padding: const EdgeInsets.all(50.0), - sliver: new SliverToBoxAdapter(child: new Container(height: 520.0)), + sliver: SliverToBoxAdapter(child: Container(height: 520.0)), ), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), floating: true), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(key: centerKey, child: new Container(height: 520.0)), // ------------------------ CENTER ------------------------ - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), pinned: true), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPadding( + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(150.0), floating: true), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(key: centerKey, child: Container(height: 520.0)), // ------------------------ CENTER ------------------------ + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(150.0), pinned: true), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPadding( padding: const EdgeInsets.all(50.0), - sliver: new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true), + sliver: SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0), pinned: true), ), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true), - new SliverToBoxAdapter(child: new Container(height: 5.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true), - new SliverToBoxAdapter(child: new Container(height: 5.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true), - new SliverToBoxAdapter(child: new Container(height: 5.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0), pinned: true), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), floating: true), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(150.0), floating: true), - new SliverToBoxAdapter(child: new Container(height: 5.0)), - new SliverList( - delegate: new SliverChildListDelegate([ - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), - new Container(height: 50.0), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0), pinned: true), + SliverToBoxAdapter(child: Container(height: 5.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0), pinned: true), + SliverToBoxAdapter(child: Container(height: 5.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0), pinned: true), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0), pinned: true), + SliverToBoxAdapter(child: Container(height: 5.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0), pinned: true), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(150.0), floating: true), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(150.0), floating: true), + SliverToBoxAdapter(child: Container(height: 5.0)), + SliverList( + delegate: SliverChildListDelegate([ + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), + Container(height: 50.0), ]), ), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)), - new SliverPersistentHeader(delegate: new TestSliverPersistentHeaderDelegate(250.0)), - new SliverPadding( + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0)), + SliverPersistentHeader(delegate: TestSliverPersistentHeaderDelegate(250.0)), + SliverPadding( padding: const EdgeInsets.symmetric(horizontal: 50.0), - sliver: new SliverToBoxAdapter(child: new Container(height: 520.0)), + sliver: SliverToBoxAdapter(child: Container(height: 520.0)), ), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(child: new Container(height: 520.0)), - new SliverToBoxAdapter(child: new Container(height: 5.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(child: Container(height: 520.0)), + SliverToBoxAdapter(child: Container(height: 5.0)), ], ); }, @@ -196,17 +196,17 @@ void main() { }); testWidgets('Removing offscreen items above and rescrolling does not crash', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( - home: new CustomScrollView( + await tester.pumpWidget(MaterialApp( + home: CustomScrollView( cacheExtent: 0.0, slivers: [ - new SliverFixedExtentList( + SliverFixedExtentList( itemExtent: 100.0, - delegate: new SliverChildBuilderDelegate( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { - return new Container( + return Container( color: Colors.blue, - child: new Text(index.toString()), + child: Text(index.toString()), ); }, childCount: 30, @@ -224,18 +224,18 @@ void main() { expect(tester.getBottomLeft(find.widgetWithText(DecoratedBox, '10')).dy, 600.0); // Stop returning the first 3 items. - await tester.pumpWidget(new MaterialApp( - home: new CustomScrollView( + await tester.pumpWidget(MaterialApp( + home: CustomScrollView( cacheExtent: 0.0, slivers: [ - new SliverFixedExtentList( + SliverFixedExtentList( itemExtent: 100.0, - delegate: new SliverChildBuilderDelegate( + delegate: SliverChildBuilderDelegate( (BuildContext context, int index) { if (index > 3) { - return new Container( + return Container( color: Colors.blue, - child: new Text(index.toString()), + child: Text(index.toString()), ); } return null; diff --git a/packages/flutter/test/widgets/slivers_padding_test.dart b/packages/flutter/test/widgets/slivers_padding_test.dart index 2c079b2ba4..231611148f 100644 --- a/packages/flutter/test/widgets/slivers_padding_test.dart +++ b/packages/flutter/test/widgets/slivers_padding_test.dart @@ -8,14 +8,14 @@ import 'package:flutter/widgets.dart'; Future test(WidgetTester tester, double offset, EdgeInsetsGeometry padding, AxisDirection axisDirection, TextDirection textDirection) { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: textDirection, - child: new Viewport( - offset: new ViewportOffset.fixed(offset), + child: Viewport( + offset: ViewportOffset.fixed(offset), axisDirection: axisDirection, slivers: [ const SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('before'))), - new SliverPadding( + SliverPadding( padding: padding, sliver: const SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('padded'))), ), @@ -31,7 +31,7 @@ void verify(WidgetTester tester, List answerKey) { (RenderBox target) { final Offset topLeft = target.localToGlobal(Offset.zero); final Offset bottomRight = target.localToGlobal(target.size.bottomRight(Offset.zero)); - return new Rect.fromPoints(topLeft, bottomRight); + return Rect.fromPoints(topLeft, bottomRight); } ).toList(); expect(testAnswers, equals(answerKey)); @@ -43,37 +43,37 @@ void main() { await test(tester, 0.0, padding, AxisDirection.down, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, 420.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 855.0, 800.0, 400.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 400.0), + Rect.fromLTWH(25.0, 420.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 855.0, 800.0, 400.0), ]); await test(tester, 200.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -200.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, 220.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 655.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -200.0, 800.0, 400.0), + Rect.fromLTWH(25.0, 220.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 655.0, 800.0, 400.0), ]); await test(tester, 390.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -390.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, 30.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 465.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -390.0, 800.0, 400.0), + Rect.fromLTWH(25.0, 30.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 465.0, 800.0, 400.0), ]); await test(tester, 490.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -490.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, -70.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 365.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -490.0, 800.0, 400.0), + Rect.fromLTWH(25.0, -70.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 365.0, 800.0, 400.0), ]); await test(tester, 10000.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, -9580.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0), + Rect.fromLTWH(25.0, -9580.0, 760.0, 400.0), + Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0), ]); }); @@ -82,37 +82,37 @@ void main() { await test(tester, 0.0, padding, AxisDirection.down, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, 420.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 855.0, 800.0, 400.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 400.0), + Rect.fromLTWH(25.0, 420.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 855.0, 800.0, 400.0), ]); await test(tester, 200.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -200.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, 220.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 655.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -200.0, 800.0, 400.0), + Rect.fromLTWH(25.0, 220.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 655.0, 800.0, 400.0), ]); await test(tester, 390.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -390.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, 30.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 465.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -390.0, 800.0, 400.0), + Rect.fromLTWH(25.0, 30.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 465.0, 800.0, 400.0), ]); await test(tester, 490.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -490.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, -70.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 365.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -490.0, 800.0, 400.0), + Rect.fromLTWH(25.0, -70.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 365.0, 800.0, 400.0), ]); await test(tester, 10000.0, padding, AxisDirection.down, TextDirection.ltr); verify(tester, [ - new Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0), - new Rect.fromLTWH(25.0, -9580.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0), + Rect.fromLTWH(25.0, -9580.0, 760.0, 400.0), + Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0), ]); }); @@ -121,37 +121,37 @@ void main() { await test(tester, 0.0, padding, AxisDirection.down, TextDirection.rtl); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(0.0, 0.0, 800.0, 400.0), - new Rect.fromLTWH(15.0, 420.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 855.0, 800.0, 400.0), + Rect.fromLTWH(0.0, 0.0, 800.0, 400.0), + Rect.fromLTWH(15.0, 420.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 855.0, 800.0, 400.0), ]); await test(tester, 200.0, padding, AxisDirection.down, TextDirection.rtl); verify(tester, [ - new Rect.fromLTWH(0.0, -200.0, 800.0, 400.0), - new Rect.fromLTWH(15.0, 220.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 655.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -200.0, 800.0, 400.0), + Rect.fromLTWH(15.0, 220.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 655.0, 800.0, 400.0), ]); await test(tester, 390.0, padding, AxisDirection.down, TextDirection.rtl); verify(tester, [ - new Rect.fromLTWH(0.0, -390.0, 800.0, 400.0), - new Rect.fromLTWH(15.0, 30.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 465.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -390.0, 800.0, 400.0), + Rect.fromLTWH(15.0, 30.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 465.0, 800.0, 400.0), ]); await test(tester, 490.0, padding, AxisDirection.down, TextDirection.rtl); verify(tester, [ - new Rect.fromLTWH(0.0, -490.0, 800.0, 400.0), - new Rect.fromLTWH(15.0, -70.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, 365.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -490.0, 800.0, 400.0), + Rect.fromLTWH(15.0, -70.0, 760.0, 400.0), + Rect.fromLTWH(0.0, 365.0, 800.0, 400.0), ]); await test(tester, 10000.0, padding, AxisDirection.down, TextDirection.rtl); verify(tester, [ - new Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0), - new Rect.fromLTWH(15.0, -9580.0, 760.0, 400.0), - new Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -10000.0, 800.0, 400.0), + Rect.fromLTWH(15.0, -9580.0, 760.0, 400.0), + Rect.fromLTWH(0.0, -9145.0, 800.0, 400.0), ]); }); @@ -160,9 +160,9 @@ void main() { await test(tester, 350.0, padding, AxisDirection.down, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(0.0, -350.0, 800.0, 400.0), - new Rect.fromLTWH(30.0, 80.0, 740.0, 400.0), - new Rect.fromLTWH(0.0, 510.0, 800.0, 400.0), + Rect.fromLTWH(0.0, -350.0, 800.0, 400.0), + Rect.fromLTWH(30.0, 80.0, 740.0, 400.0), + Rect.fromLTWH(0.0, 510.0, 800.0, 400.0), ]); HitTestResult result; result = tester.hitTestOnBinding(const Offset(10.0, 10.0)); @@ -182,9 +182,9 @@ void main() { await test(tester, 350.0, padding, AxisDirection.up, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(0.0, 600.0+350.0-400.0, 800.0, 400.0), - new Rect.fromLTWH(30.0, 600.0-80.0-400.0, 740.0, 400.0), - new Rect.fromLTWH(0.0, 600.0-510.0-400.0, 800.0, 400.0), + Rect.fromLTWH(0.0, 600.0+350.0-400.0, 800.0, 400.0), + Rect.fromLTWH(30.0, 600.0-80.0-400.0, 740.0, 400.0), + Rect.fromLTWH(0.0, 600.0-510.0-400.0, 800.0, 400.0), ]); HitTestResult result; result = tester.hitTestOnBinding(const Offset(10.0, 600.0-10.0)); @@ -204,9 +204,9 @@ void main() { await test(tester, 350.0, padding, AxisDirection.left, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(800.0+350.0-400.0, 0.0, 400.0, 600.0), - new Rect.fromLTWH(800.0-80.0-400.0, 30.0, 400.0, 540.0), - new Rect.fromLTWH(800.0-510.0-400.0, 0.0, 400.0, 600.0), + Rect.fromLTWH(800.0+350.0-400.0, 0.0, 400.0, 600.0), + Rect.fromLTWH(800.0-80.0-400.0, 30.0, 400.0, 540.0), + Rect.fromLTWH(800.0-510.0-400.0, 0.0, 400.0, 600.0), ]); HitTestResult result; result = tester.hitTestOnBinding(const Offset(800.0-10.0, 10.0)); @@ -226,9 +226,9 @@ void main() { await test(tester, 350.0, padding, AxisDirection.right, TextDirection.ltr); expect(tester.renderObject(find.byType(Viewport)).size, equals(const Size(800.0, 600.0))); verify(tester, [ - new Rect.fromLTWH(-350.0, 0.0, 400.0, 600.0), - new Rect.fromLTWH(80.0, 30.0, 400.0, 540.0), - new Rect.fromLTWH(510.0, 0.0, 400.0, 600.0), + Rect.fromLTWH(-350.0, 0.0, 400.0, 600.0), + Rect.fromLTWH(80.0, 30.0, 400.0, 540.0), + Rect.fromLTWH(510.0, 0.0, 400.0, 600.0), ]); HitTestResult result; result = tester.hitTestOnBinding(const Offset(10.0, 10.0)); @@ -245,10 +245,10 @@ void main() { testWidgets('Viewport+SliverPadding no child', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( - offset: new ViewportOffset.fixed(0.0), + child: Viewport( + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.all(100.0)), SliverToBoxAdapter(child: SizedBox(width: 400.0, height: 400.0, child: Text('x'))), @@ -261,11 +261,11 @@ void main() { testWidgets('Viewport+SliverPadding changing padding', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.left, - offset: new ViewportOffset.fixed(0.0), + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(90.0, 1.0, 110.0, 2.0)), SliverToBoxAdapter(child: SizedBox(width: 201.0, child: Text('x'))), @@ -275,11 +275,11 @@ void main() { ); expect(tester.renderObject(find.text('x')).localToGlobal(Offset.zero), const Offset(399.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.left, - offset: new ViewportOffset.fixed(0.0), + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(110.0, 1.0, 80.0, 2.0)), SliverToBoxAdapter(child: SizedBox(width: 201.0, child: Text('x'))), @@ -292,11 +292,11 @@ void main() { testWidgets('Viewport+SliverPadding changing direction', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.up, - offset: new ViewportOffset.fixed(0.0), + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)), ], @@ -305,11 +305,11 @@ void main() { ); expect(tester.renderObject(find.byType(SliverPadding)).afterPadding, 2.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.down, - offset: new ViewportOffset.fixed(0.0), + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)), ], @@ -318,11 +318,11 @@ void main() { ); expect(tester.renderObject(find.byType(SliverPadding)).afterPadding, 8.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.right, - offset: new ViewportOffset.fixed(0.0), + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)), ], @@ -331,11 +331,11 @@ void main() { ); expect(tester.renderObject(find.byType(SliverPadding)).afterPadding, 4.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.left, - offset: new ViewportOffset.fixed(0.0), + offset: ViewportOffset.fixed(0.0), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)), ], @@ -344,11 +344,11 @@ void main() { ); expect(tester.renderObject(find.byType(SliverPadding)).afterPadding, 1.0); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( axisDirection: AxisDirection.left, - offset: new ViewportOffset.fixed(99999.9), + offset: ViewportOffset.fixed(99999.9), slivers: const [ SliverPadding(padding: EdgeInsets.fromLTRB(1.0, 2.0, 4.0, 8.0)), ], @@ -360,15 +360,15 @@ void main() { testWidgets('SliverPadding propagates geometry offset corrections', (WidgetTester tester) async { Widget listBuilder(IndexedWidgetBuilder sliverChildBuilder) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( cacheExtent: 0.0, slivers: [ - new SliverPadding( + SliverPadding( padding: EdgeInsets.zero, - sliver: new SliverList( - delegate: new SliverChildBuilderDelegate( + sliver: SliverList( + delegate: SliverChildBuilderDelegate( sliverChildBuilder, childCount: 10, ), @@ -382,10 +382,10 @@ void main() { await tester.pumpWidget( listBuilder( (BuildContext context, int index) { - return new Container( + return Container( height: 200.0, - child: new Center( - child: new Text(index.toString()), + child: Center( + child: Text(index.toString()), ), ); }, @@ -397,17 +397,17 @@ void main() { expect( tester.getRect(find.widgetWithText(Container, '2')), - new Rect.fromLTRB(0.0, 100.0, 800.0, 300.0), + Rect.fromLTRB(0.0, 100.0, 800.0, 300.0), ); // Now item 0 is 400.0px and going back will underflow. await tester.pumpWidget( listBuilder( (BuildContext context, int index) { - return new Container( + return Container( height: index == 0 ? 400.0 : 200.0, - child: new Center( - child: new Text(index.toString()), + child: Center( + child: Text(index.toString()), ), ); }, @@ -420,7 +420,7 @@ void main() { expect( tester.getRect(find.widgetWithText(Container, '0')), - new Rect.fromLTRB(0.0, -200.0, 800.0, 200.0), + Rect.fromLTRB(0.0, -200.0, 800.0, 200.0), ); }); } diff --git a/packages/flutter/test/widgets/slivers_protocol_test.dart b/packages/flutter/test/widgets/slivers_protocol_test.dart index 5ceb9b5bee..0755575bc9 100644 --- a/packages/flutter/test/widgets/slivers_protocol_test.dart +++ b/packages/flutter/test/widgets/slivers_protocol_test.dart @@ -20,15 +20,15 @@ void main() { testWidgets('Sliver protocol', (WidgetTester tester) async { GlobalKey key1, key2, key3, key4, key5; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new BigSliver(key: key1 = new GlobalKey()), - new OverlappingSliver(key: key2 = new GlobalKey()), - new OverlappingSliver(key: key3 = new GlobalKey()), - new BigSliver(key: key4 = new GlobalKey()), - new BigSliver(key: key5 = new GlobalKey()), + BigSliver(key: key1 = GlobalKey()), + OverlappingSliver(key: key2 = GlobalKey()), + OverlappingSliver(key: key3 = GlobalKey()), + BigSliver(key: key4 = GlobalKey()), + BigSliver(key: key5 = GlobalKey()), ], ), ), @@ -59,7 +59,7 @@ class RenderBigSliver extends RenderSliver { @override void performLayout() { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: height, paintExtent: paintExtent, maxPaintExtent: height, @@ -71,7 +71,7 @@ class BigSliver extends LeafRenderObjectWidget { const BigSliver({ Key key }) : super(key: key); @override RenderBigSliver createRenderObject(BuildContext context) { - return new RenderBigSliver(); + return RenderBigSliver(); } } @@ -95,7 +95,7 @@ class RenderOverlappingSliver extends RenderSliver { @override void performLayout() { - geometry = new SliverGeometry( + geometry = SliverGeometry( scrollExtent: totalHeight, paintExtent: paintExtent, layoutExtent: layoutExtent, @@ -108,6 +108,6 @@ class OverlappingSliver extends LeafRenderObjectWidget { const OverlappingSliver({ Key key }) : super(key: key); @override RenderOverlappingSliver createRenderObject(BuildContext context) { - return new RenderOverlappingSliver(); + return RenderOverlappingSliver(); } } diff --git a/packages/flutter/test/widgets/slivers_test.dart b/packages/flutter/test/widgets/slivers_test.dart index 8f8deee204..9b39ac791f 100644 --- a/packages/flutter/test/widgets/slivers_test.dart +++ b/packages/flutter/test/widgets/slivers_test.dart @@ -8,11 +8,11 @@ import 'package:flutter/rendering.dart'; Future test(WidgetTester tester, double offset, { double anchor = 0.0 }) { return tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Viewport( + child: Viewport( anchor: anchor / 600.0, - offset: new ViewportOffset.fixed(offset), + offset: ViewportOffset.fixed(offset), slivers: const [ SliverToBoxAdapter(child: SizedBox(height: 400.0)), SliverToBoxAdapter(child: SizedBox(height: 400.0)), @@ -117,51 +117,51 @@ void main() { testWidgets('Multiple grids and lists', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( width: 44.4, height: 60.0, - child: new Directionality( + child: Directionality( textDirection: TextDirection.ltr, - child: new CustomScrollView( + child: CustomScrollView( slivers: [ - new SliverList( - delegate: new SliverChildListDelegate( + SliverList( + delegate: SliverChildListDelegate( [ - new Container(height: 22.2, child: const Text('TOP')), - new Container(height: 22.2), - new Container(height: 22.2), + Container(height: 22.2, child: const Text('TOP')), + Container(height: 22.2), + Container(height: 22.2), ], ), ), - new SliverFixedExtentList( + SliverFixedExtentList( itemExtent: 22.2, - delegate: new SliverChildListDelegate( + delegate: SliverChildListDelegate( [ - new Container(), - new Container(child: const Text('A')), - new Container(), + Container(), + Container(child: const Text('A')), + Container(), ], ), ), - new SliverGrid( + SliverGrid( gridDelegate: const SliverGridDelegateWithFixedCrossAxisCount( crossAxisCount: 2, ), - delegate: new SliverChildListDelegate( + delegate: SliverChildListDelegate( [ - new Container(), - new Container(child: const Text('B')), - new Container(), + Container(), + Container(child: const Text('B')), + Container(), ], ), ), - new SliverList( - delegate: new SliverChildListDelegate( + SliverList( + delegate: SliverChildListDelegate( [ - new Container(height: 22.2), - new Container(height: 22.2), - new Container(height: 22.2, child: const Text('BOTTOM')), + Container(height: 22.2), + Container(height: 22.2), + Container(height: 22.2, child: const Text('BOTTOM')), ], ), ), diff --git a/packages/flutter/test/widgets/spacer_test.dart b/packages/flutter/test/widgets/spacer_test.dart index 3d321ec9f0..63d13d99dc 100644 --- a/packages/flutter/test/widgets/spacer_test.dart +++ b/packages/flutter/test/widgets/spacer_test.dart @@ -7,7 +7,7 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Spacer takes up space.', (WidgetTester tester) async { - await tester.pumpWidget(new Column( + await tester.pumpWidget(Column( children: const [ SizedBox(width: 10.0, height: 10.0), Spacer(), @@ -24,7 +24,7 @@ void main() { const Spacer spacer2 = Spacer(flex: 1); const Spacer spacer3 = Spacer(flex: 2); const Spacer spacer4 = Spacer(flex: 4); - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.rtl, children: const [ SizedBox(width: 10.0, height: 10.0), @@ -54,9 +54,9 @@ void main() { }); testWidgets('Spacer takes up space.', (WidgetTester tester) async { - await tester.pumpWidget(new UnconstrainedBox( + await tester.pumpWidget(UnconstrainedBox( constrainedAxis: Axis.vertical, - child: new Column( + child: Column( children: const [ SizedBox(width: 20.0, height: 10.0), Spacer(), @@ -68,6 +68,6 @@ void main() { final Rect flexRect = tester.getRect(find.byType(Column)); expect(spacerRect.size, const Size(0.0, 580.0)); expect(spacerRect.topLeft, const Offset(400.0, 10.0)); - expect(flexRect, new Rect.fromLTWH(390.0, 0.0, 20.0, 600.0)); + expect(flexRect, Rect.fromLTWH(390.0, 0.0, 20.0, 600.0)); }); } diff --git a/packages/flutter/test/widgets/stack_test.dart b/packages/flutter/test/widgets/stack_test.dart index 0b98ad4d9c..aefc1283b2 100644 --- a/packages/flutter/test/widgets/stack_test.dart +++ b/packages/flutter/test/widgets/stack_test.dart @@ -20,18 +20,18 @@ class TestPaintingContext implements PaintingContext { void main() { testWidgets('Can construct an empty Stack', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack(), + child: Stack(), ), ); }); testWidgets('Can construct an empty Centered Stack', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center(child: new Stack()), + child: Center(child: Stack()), ), ); }); @@ -40,12 +40,12 @@ void main() { const Key key = Key('container'); await tester.pumpWidget( - new Stack( + Stack( alignment: Alignment.topLeft, children: [ - new Positioned( + Positioned( left: 10.0, - child: new Container( + child: Container( key: key, width: 10.0, height: 10.0, @@ -68,12 +68,12 @@ void main() { expect(parentData.height, isNull); await tester.pumpWidget( - new Stack( + Stack( alignment: Alignment.topLeft, children: [ - new Positioned( + Positioned( right: 10.0, - child: new Container( + child: Container( key: key, width: 10.0, height: 10.0, @@ -95,12 +95,12 @@ void main() { testWidgets('Can remove parent data', (WidgetTester tester) async { const Key key = Key('container'); - final Container container = new Container(key: key, width: 10.0, height: 10.0); + final Container container = Container(key: key, width: 10.0, height: 10.0); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, - children: [ new Positioned(left: 10.0, child: container) ], + children: [ Positioned(left: 10.0, child: container) ], ), ); Element containerElement = tester.element(find.byKey(key)); @@ -115,7 +115,7 @@ void main() { expect(parentData.height, isNull); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: [ container ], ), @@ -136,14 +136,14 @@ void main() { const Key child1Key = Key('child1'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Stack( + child: Center( + child: Stack( alignment: Alignment.center, children: [ - new Container(key: child0Key, width: 20.0, height: 20.0), - new Container(key: child1Key, width: 10.0, height: 10.0), + Container(key: child0Key, width: 20.0, height: 20.0), + Container(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -159,14 +159,14 @@ void main() { expect(child1RenderObjectParentData.offset, equals(const Offset(5.0, 5.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Stack( + child: Center( + child: Stack( alignment: AlignmentDirectional.bottomEnd, children: [ - new Container(key: child0Key, width: 20.0, height: 20.0), - new Container(key: child1Key, width: 10.0, height: 10.0), + Container(key: child0Key, width: 20.0, height: 20.0), + Container(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -182,14 +182,14 @@ void main() { const Key child1Key = Key('child1'); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Stack( + child: Center( + child: Stack( alignment: Alignment.center, children: [ - new Container(key: child0Key, width: 20.0, height: 20.0), - new Container(key: child1Key, width: 10.0, height: 10.0), + Container(key: child0Key, width: 20.0, height: 20.0), + Container(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -205,14 +205,14 @@ void main() { expect(child1RenderObjectParentData.offset, equals(const Offset(5.0, 5.0))); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Stack( + child: Center( + child: Stack( alignment: AlignmentDirectional.bottomEnd, children: [ - new Container(key: child0Key, width: 20.0, height: 20.0), - new Container(key: child1Key, width: 10.0, height: 10.0), + Container(key: child0Key, width: 20.0, height: 20.0), + Container(key: child1Key, width: 10.0, height: 10.0), ], ), ), @@ -225,18 +225,18 @@ void main() { testWidgets('Can construct an empty IndexedStack', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new IndexedStack(), + child: IndexedStack(), ), ); }); testWidgets('Can construct an empty Centered IndexedStack', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center(child: new IndexedStack()), + child: Center(child: IndexedStack()), ), ); }); @@ -247,16 +247,16 @@ void main() { Widget buildFrame(int index) { itemsPainted = []; - final List items = new List.generate(itemCount, (int i) { - return new CustomPaint( - child: new Text('$i', textDirection: TextDirection.ltr), - painter: new TestCallbackPainter( + final List items = List.generate(itemCount, (int i) { + return CustomPaint( + child: Text('$i', textDirection: TextDirection.ltr), + painter: TestCallbackPainter( onPaint: () { itemsPainted.add(i); } ), ); }); - return new Center( - child: new IndexedStack( + return Center( + child: IndexedStack( alignment: Alignment.topLeft, children: items, index: index, @@ -284,11 +284,11 @@ void main() { Widget buildFrame(int index) { itemsTapped = []; - final List items = new List.generate(itemCount, (int i) { - return new GestureDetector(child: new Text('$i', textDirection: TextDirection.ltr), onTap: () { itemsTapped.add(i); }); + final List items = List.generate(itemCount, (int i) { + return GestureDetector(child: Text('$i', textDirection: TextDirection.ltr), onTap: () { itemsTapped.add(i); }); }); - return new Center( - child: new IndexedStack( + return Center( + child: IndexedStack( alignment: Alignment.topLeft, children: items, key: key, @@ -316,7 +316,7 @@ void main() { ); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -348,7 +348,7 @@ void main() { expect(renderBox.size.height, equals(12.0)); await tester.pumpWidget( - new Stack( + Stack( textDirection: TextDirection.ltr, children: const [ Positioned( @@ -380,13 +380,13 @@ void main() { bool tapped; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new IndexedStack( + child: Center( + child: IndexedStack( index: null, children: [ - new GestureDetector( + GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { tapped = true; }, child: const SizedBox( @@ -408,19 +408,19 @@ void main() { testWidgets('Stack clip test', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Stack( + child: Center( + child: Stack( children: [ - new Container( + Container( width: 100.0, height: 100.0, ), - new Positioned( + Positioned( top: 0.0, left: 0.0, - child: new Container( + child: Container( width: 200.0, height: 200.0, ), @@ -432,25 +432,25 @@ void main() { ); RenderBox box = tester.renderObject(find.byType(Stack)); - TestPaintingContext context = new TestPaintingContext(); + TestPaintingContext context = TestPaintingContext(); box.paint(context, Offset.zero); expect(context.invocations.first.memberName, equals(#pushClipRect)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Stack( + child: Center( + child: Stack( overflow: Overflow.visible, children: [ - new Container( + Container( width: 100.0, height: 100.0, ), - new Positioned( + Positioned( top: 0.0, left: 0.0, - child: new Container( + child: Container( width: 200.0, height: 200.0, ), @@ -462,7 +462,7 @@ void main() { ); box = tester.renderObject(find.byType(Stack)); - context = new TestPaintingContext(); + context = TestPaintingContext(); box.paint(context, Offset.zero); expect(context.invocations.first.memberName, equals(#paintChild)); }); @@ -470,19 +470,19 @@ void main() { testWidgets('Stack sizing: default', (WidgetTester tester) async { final List logs = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new ConstrainedBox( + child: Center( + child: ConstrainedBox( constraints: const BoxConstraints( minWidth: 2.0, maxWidth: 3.0, minHeight: 5.0, maxHeight: 7.0, ), - child: new Stack( + child: Stack( children: [ - new LayoutBuilder( + LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { logs.add(constraints.toString()); return const Placeholder(); @@ -500,20 +500,20 @@ void main() { testWidgets('Stack sizing: explicit', (WidgetTester tester) async { final List logs = []; Widget buildStack(StackFit sizing) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new ConstrainedBox( + child: Center( + child: ConstrainedBox( constraints: const BoxConstraints( minWidth: 2.0, maxWidth: 3.0, minHeight: 5.0, maxHeight: 7.0, ), - child: new Stack( + child: Stack( fit: sizing, children: [ - new LayoutBuilder( + LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { logs.add(constraints.toString()); return const Placeholder(); @@ -540,16 +540,16 @@ void main() { }); testWidgets('Positioned.directional control test', (WidgetTester tester) async { - final Key key = new UniqueKey(); + final Key key = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned.directional( + Positioned.directional( textDirection: TextDirection.rtl, start: 50.0, - child: new Container(key: key, width: 75.0, height: 175.0), + child: Container(key: key, width: 75.0, height: 175.0), ), ], ), @@ -559,14 +559,14 @@ void main() { expect(tester.getTopLeft(find.byKey(key)), const Offset(675.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned.directional( + Positioned.directional( textDirection: TextDirection.ltr, start: 50.0, - child: new Container(key: key, width: 75.0, height: 175.0), + child: Container(key: key, width: 75.0, height: 175.0), ), ], ), @@ -577,15 +577,15 @@ void main() { }); testWidgets('PositionedDirectional control test', (WidgetTester tester) async { - final Key key = new UniqueKey(); + final Key key = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( children: [ - new PositionedDirectional( + PositionedDirectional( start: 50.0, - child: new Container(key: key, width: 75.0, height: 175.0), + child: Container(key: key, width: 75.0, height: 175.0), ), ], ), @@ -595,13 +595,13 @@ void main() { expect(tester.getTopLeft(find.byKey(key)), const Offset(675.0, 0.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new PositionedDirectional( + PositionedDirectional( start: 50.0, - child: new Container(key: key, width: 75.0, height: 175.0), + child: Container(key: key, width: 75.0, height: 175.0), ), ], ), @@ -613,18 +613,18 @@ void main() { testWidgets('Can change the text direction of a Stack', (WidgetTester tester) async { await tester.pumpWidget( - new Stack( + Stack( alignment: Alignment.center, ), ); await tester.pumpWidget( - new Stack( + Stack( alignment: AlignmentDirectional.topStart, textDirection: TextDirection.rtl, ), ); await tester.pumpWidget( - new Stack( + Stack( alignment: Alignment.center, ), ); @@ -632,9 +632,9 @@ void main() { testWidgets('Alignment with partially-positioned children', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Stack( + child: Stack( alignment: Alignment.center, children: const [ SizedBox(width: 100.0, height: 100.0), @@ -650,20 +650,20 @@ void main() { ), ), ); - expect(tester.getRect(find.byType(SizedBox).at(0)), new Rect.fromLTWH(350.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(1)), new Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(2)), new Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(3)), new Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(4)), new Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(5)), new Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(6)), new Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(7)), new Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(8)), new Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(0)), Rect.fromLTWH(350.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(1)), Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(2)), Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(3)), Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(4)), Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(5)), Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(6)), Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(7)), Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(8)), Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( alignment: Alignment.center, children: const [ SizedBox(width: 100.0, height: 100.0), @@ -679,20 +679,20 @@ void main() { ), ), ); - expect(tester.getRect(find.byType(SizedBox).at(0)), new Rect.fromLTWH(350.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(1)), new Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(2)), new Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(3)), new Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(4)), new Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(5)), new Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(6)), new Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(7)), new Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(8)), new Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(0)), Rect.fromLTWH(350.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(1)), Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(2)), Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(3)), Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(4)), Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(5)), Rect.fromLTWH(0.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(6)), Rect.fromLTWH(700.0, 250.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(7)), Rect.fromLTWH(350.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(8)), Rect.fromLTWH(350.0, 500.0, 100.0, 100.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( alignment: Alignment.bottomRight, children: const [ SizedBox(width: 100.0, height: 100.0), @@ -708,20 +708,20 @@ void main() { ), ), ); - expect(tester.getRect(find.byType(SizedBox).at(0)), new Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(1)), new Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(2)), new Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(3)), new Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(4)), new Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(5)), new Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(6)), new Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(7)), new Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(8)), new Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(0)), Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(1)), Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(2)), Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(3)), Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(4)), Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(5)), Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(6)), Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(7)), Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(8)), Rect.fromLTWH(700.0, 500.0, 100.0, 100.0)); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( alignment: Alignment.topLeft, children: const [ SizedBox(width: 100.0, height: 100.0), @@ -737,14 +737,14 @@ void main() { ), ), ); - expect(tester.getRect(find.byType(SizedBox).at(0)), new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(1)), new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(2)), new Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(3)), new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(4)), new Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(5)), new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(6)), new Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(7)), new Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); - expect(tester.getRect(find.byType(SizedBox).at(8)), new Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(0)), Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(1)), Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(2)), Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(3)), Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(4)), Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(5)), Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(6)), Rect.fromLTWH(700.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(7)), Rect.fromLTWH(0.0, 0.0, 100.0, 100.0)); + expect(tester.getRect(find.byType(SizedBox).at(8)), Rect.fromLTWH(0.0, 500.0, 100.0, 100.0)); }); } diff --git a/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart b/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart index d6649c09ea..3b7b060df7 100644 --- a/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart +++ b/packages/flutter/test/widgets/state_setting_in_scrollables_test.dart @@ -7,22 +7,22 @@ import 'package:flutter_test/flutter_test.dart'; class Foo extends StatefulWidget { @override - FooState createState() => new FooState(); + FooState createState() => FooState(); } class FooState extends State { - ScrollController scrollController = new ScrollController(); + ScrollController scrollController = ScrollController(); @override Widget build(BuildContext context) { - return new LayoutBuilder( + return LayoutBuilder( builder: (BuildContext context, BoxConstraints constraints) { - return new ScrollConfiguration( - behavior: new FooScrollBehavior(), - child: new ListView( + return ScrollConfiguration( + behavior: FooScrollBehavior(), + child: ListView( controller: scrollController, children: [ - new GestureDetector( + GestureDetector( onTap: () { setState(() { /* this is needed to trigger the original bug this is regression-testing */ }); scrollController.animateTo(200.0, duration: const Duration(milliseconds: 500), curve: Curves.linear); @@ -80,9 +80,9 @@ class FooScrollBehavior extends ScrollBehavior { void main() { testWidgets('Can animate scroll after setState', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Foo(), + child: Foo(), ), ); expect(tester.state(find.byType(Scrollable)).position.pixels, 0.0); diff --git a/packages/flutter/test/widgets/stateful_component_test.dart b/packages/flutter/test/widgets/stateful_component_test.dart index 5c12b88e9b..6363f0523e 100644 --- a/packages/flutter/test/widgets/stateful_component_test.dart +++ b/packages/flutter/test/widgets/stateful_component_test.dart @@ -57,9 +57,9 @@ void main() { testWidgets('Don\'t rebuild subwidgets', (WidgetTester tester) async { await tester.pumpWidget( - new FlipWidget( + FlipWidget( key: const Key('rebuild test'), - left: new TestBuildCounter(), + left: TestBuildCounter(), right: const DecoratedBox(decoration: kBoxDecorationB) ) ); diff --git a/packages/flutter/test/widgets/stateful_components_test.dart b/packages/flutter/test/widgets/stateful_components_test.dart index d5342b60d9..b8b0d29d0a 100644 --- a/packages/flutter/test/widgets/stateful_components_test.dart +++ b/packages/flutter/test/widgets/stateful_components_test.dart @@ -9,7 +9,7 @@ class InnerWidget extends StatefulWidget { const InnerWidget({ Key key }) : super(key: key); @override - InnerWidgetState createState() => new InnerWidgetState(); + InnerWidgetState createState() => InnerWidgetState(); } class InnerWidgetState extends State { @@ -23,7 +23,7 @@ class InnerWidgetState extends State { @override Widget build(BuildContext context) { - return new Container(); + return Container(); } } @@ -33,7 +33,7 @@ class OuterContainer extends StatefulWidget { final InnerWidget child; @override - OuterContainerState createState() => new OuterContainerState(); + OuterContainerState createState() => OuterContainerState(); } class OuterContainerState extends State { @@ -62,7 +62,7 @@ void main() { expect(innerElement.renderObject.attached, isTrue); inner2 = const InnerWidget(key: innerKey); - outer2 = new OuterContainer(key: outerKey, child: inner2); + outer2 = OuterContainer(key: outerKey, child: inner2); await tester.pumpWidget(outer2); diff --git a/packages/flutter/test/widgets/status_transitions_test.dart b/packages/flutter/test/widgets/status_transitions_test.dart index b918aec19e..eba05ad258 100644 --- a/packages/flutter/test/widgets/status_transitions_test.dart +++ b/packages/flutter/test/widgets/status_transitions_test.dart @@ -21,17 +21,17 @@ class TestStatusTransitionWidget extends StatusTransitionWidget { void main() { testWidgets('Status transition control test', (WidgetTester tester) async { bool didBuild = false; - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(seconds: 1), vsync: const TestVSync(), ); - await tester.pumpWidget(new TestStatusTransitionWidget( + await tester.pumpWidget(TestStatusTransitionWidget( animation: controller, builder: (BuildContext context) { expect(didBuild, isFalse); didBuild = true; - return new Container(); + return Container(); }, )); @@ -58,17 +58,17 @@ void main() { await tester.pump(const Duration(milliseconds: 100)); expect(didBuild, isFalse); - final AnimationController anotherController = new AnimationController( + final AnimationController anotherController = AnimationController( duration: const Duration(seconds: 1), vsync: const TestVSync(), ); - await tester.pumpWidget(new TestStatusTransitionWidget( + await tester.pumpWidget(TestStatusTransitionWidget( animation: anotherController, builder: (BuildContext context) { expect(didBuild, isFalse); didBuild = true; - return new Container(); + return Container(); }, )); diff --git a/packages/flutter/test/widgets/syncing_test.dart b/packages/flutter/test/widgets/syncing_test.dart index 5572b60805..e6b6296cf4 100644 --- a/packages/flutter/test/widgets/syncing_test.dart +++ b/packages/flutter/test/widgets/syncing_test.dart @@ -13,7 +13,7 @@ class TestWidget extends StatefulWidget { final int syncedState; @override - TestWidgetState createState() => new TestWidgetState(); + TestWidgetState createState() => TestWidgetState(); } class TestWidgetState extends State { @@ -45,11 +45,11 @@ void main() { testWidgets('no change', (WidgetTester tester) async { await tester.pumpWidget( - new Container( - child: new Container( - child: new TestWidget( + Container( + child: Container( + child: TestWidget( persistentState: 1, - child: new Container() + child: Container() ) ) ) @@ -61,11 +61,11 @@ void main() { expect(state.updates, equals(0)); await tester.pumpWidget( - new Container( - child: new Container( - child: new TestWidget( + Container( + child: Container( + child: TestWidget( persistentState: 2, - child: new Container() + child: Container() ) ) ) @@ -74,16 +74,16 @@ void main() { expect(state.persistentState, equals(1)); expect(state.updates, equals(1)); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); }); testWidgets('remove one', (WidgetTester tester) async { await tester.pumpWidget( - new Container( - child: new Container( - child: new TestWidget( + Container( + child: Container( + child: TestWidget( persistentState: 10, - child: new Container() + child: Container() ) ) ) @@ -95,10 +95,10 @@ void main() { expect(state.updates, equals(0)); await tester.pumpWidget( - new Container( - child: new TestWidget( + Container( + child: TestWidget( persistentState: 11, - child: new Container() + child: Container() ) ) ); @@ -108,25 +108,25 @@ void main() { expect(state.persistentState, equals(11)); expect(state.updates, equals(0)); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); }); testWidgets('swap instances around', (WidgetTester tester) async { const Widget a = TestWidget(persistentState: 0x61, syncedState: 0x41, child: Text('apple', textDirection: TextDirection.ltr)); const Widget b = TestWidget(persistentState: 0x62, syncedState: 0x42, child: Text('banana', textDirection: TextDirection.ltr)); - await tester.pumpWidget(new Column()); + await tester.pumpWidget(Column()); - final GlobalKey keyA = new GlobalKey(); - final GlobalKey keyB = new GlobalKey(); + final GlobalKey keyA = GlobalKey(); + final GlobalKey keyB = GlobalKey(); await tester.pumpWidget( - new Column( + Column( children: [ - new Container( + Container( key: keyA, child: a ), - new Container( + Container( key: keyB, child: b ) @@ -147,13 +147,13 @@ void main() { expect(second.syncedState, equals(0x42)); await tester.pumpWidget( - new Column( + Column( children: [ - new Container( + Container( key: keyA, child: a ), - new Container( + Container( key: keyB, child: b ) @@ -176,13 +176,13 @@ void main() { // since they are both "old" nodes, they shouldn't sync with each other even though they look alike await tester.pumpWidget( - new Column( + Column( children: [ - new Container( + Container( key: keyA, child: b ), - new Container( + Container( key: keyB, child: a ) diff --git a/packages/flutter/test/widgets/table_test.dart b/packages/flutter/test/widgets/table_test.dart index 1c49b17e13..3a55541529 100644 --- a/packages/flutter/test/widgets/table_test.dart +++ b/packages/flutter/test/widgets/table_test.dart @@ -10,29 +10,29 @@ class TestStatefulWidget extends StatefulWidget { const TestStatefulWidget({ Key key }) : super(key: key); @override - TestStatefulWidgetState createState() => new TestStatefulWidgetState(); + TestStatefulWidgetState createState() => TestStatefulWidgetState(); } class TestStatefulWidgetState extends State { @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } void main() { testWidgets('Table widget - empty', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table(), + child: Table(), ), ); }); testWidgets('Table widget - control test', (WidgetTester tester) async { Future run(TextDirection textDirection) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: textDirection, - child: new Table( + child: Table( children: const [ TableRow( children: [ @@ -63,16 +63,16 @@ void main() { } await run(TextDirection.ltr); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); await run(TextDirection.rtl); }); testWidgets('Table widget - column offset (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Center( - child: new Table( + child: Center( + child: Table( columnWidths: const { 0: FixedColumnWidth(100.0), 1: FixedColumnWidth(110.0), @@ -139,10 +139,10 @@ void main() { testWidgets('Table widget - column offset (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.rtl, - child: new Center( - child: new Table( + child: Center( + child: Table( columnWidths: const { 0: FixedColumnWidth(100.0), 1: FixedColumnWidth(110.0), @@ -210,10 +210,10 @@ void main() { testWidgets('Table border - smoke test', (WidgetTester tester) async { Future run(TextDirection textDirection) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: textDirection, - child: new Table( - border: new TableBorder.all(), + child: Table( + border: TableBorder.all(), children: const [ TableRow( children: [ @@ -237,15 +237,15 @@ void main() { } await run(TextDirection.ltr); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); await run(TextDirection.rtl); }); testWidgets('Table widget - changing table dimensions', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( children: [ @@ -271,9 +271,9 @@ void main() { expect(boxA1, isNotNull); expect(boxG1, isNotNull); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( children: [ @@ -299,9 +299,9 @@ void main() { testWidgets('Table widget - repump test', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( children: [ @@ -323,9 +323,9 @@ void main() { ), ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( children: [ @@ -357,9 +357,9 @@ void main() { testWidgets('Table widget - intrinsic sizing test', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( defaultColumnWidth: const IntrinsicColumnWidth(), children: const [ TableRow( @@ -393,9 +393,9 @@ void main() { testWidgets('Table widget - intrinsic sizing test, resizing', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( defaultColumnWidth: const IntrinsicColumnWidth(), children: const [ TableRow( @@ -418,9 +418,9 @@ void main() { ), ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( defaultColumnWidth: const IntrinsicColumnWidth(), children: const [ TableRow( @@ -454,9 +454,9 @@ void main() { testWidgets('Table widget - intrinsic sizing test, changing column widths', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( children: [ @@ -478,9 +478,9 @@ void main() { ), ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( defaultColumnWidth: const IntrinsicColumnWidth(), children: const [ TableRow( @@ -515,14 +515,14 @@ void main() { testWidgets('Table widget - moving test', (WidgetTester tester) async { final List contexts = []; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: [ - new TableRow( + TableRow( key: const ValueKey(1), children: [ - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { contexts.add(context); return const Text('A'); @@ -540,19 +540,19 @@ void main() { ), ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: [ const TableRow( children: [ Text('b'), ], ), - new TableRow( + TableRow( key: const ValueKey(1), children: [ - new StatefulBuilder( + StatefulBuilder( builder: (BuildContext context, StateSetter setState) { contexts.add(context); return const Text('A'); @@ -570,9 +570,9 @@ void main() { testWidgets('Table widget - keyed rows', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( key: ValueKey(1), @@ -604,9 +604,9 @@ void main() { expect(state22.mounted, isTrue); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Table( + child: Table( children: const [ TableRow( key: ValueKey(2), @@ -627,23 +627,23 @@ void main() { }); testWidgets('Table widget - global key reparenting', (WidgetTester tester) async { - final GlobalKey key = new GlobalKey(); - final Key tableKey = new UniqueKey(); + final GlobalKey key = GlobalKey(); + final Key tableKey = UniqueKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new Expanded( + Expanded( key: tableKey, - child: new Table( + child: Table( children: [ - new TableRow( + TableRow( children: [ - new Container(key: const ValueKey(1)), - new TestStatefulWidget(key: key), - new Container(key: const ValueKey(2)), + Container(key: const ValueKey(1)), + TestStatefulWidget(key: key), + Container(key: const ValueKey(2)), ], ), ], @@ -658,19 +658,19 @@ void main() { expect(table.row(0).length, 3); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new Expanded(child: new TestStatefulWidget(key: key)), - new Expanded( + Expanded(child: TestStatefulWidget(key: key)), + Expanded( key: tableKey, - child: new Table( + child: Table( children: [ - new TableRow( + TableRow( children: [ - new Container(key: const ValueKey(1)), - new Container(key: const ValueKey(2)), + Container(key: const ValueKey(1)), + Container(key: const ValueKey(2)), ], ), ], @@ -685,19 +685,19 @@ void main() { expect(table.row(0).length, 2); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new Expanded( + Expanded( key: tableKey, - child: new Table( + child: Table( children: [ - new TableRow( + TableRow( children: [ - new Container(key: const ValueKey(1)), - new TestStatefulWidget(key: key), - new Container(key: const ValueKey(2)), + Container(key: const ValueKey(1)), + TestStatefulWidget(key: key), + Container(key: const ValueKey(2)), ], ), ], @@ -712,24 +712,24 @@ void main() { expect(table.row(0).length, 3); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Column( + child: Column( children: [ - new Expanded( + Expanded( key: tableKey, - child: new Table( + child: Table( children: [ - new TableRow( + TableRow( children: [ - new Container(key: const ValueKey(1)), - new Container(key: const ValueKey(2)), + Container(key: const ValueKey(1)), + Container(key: const ValueKey(2)), ], ), ], ), ), - new Expanded(child: new TestStatefulWidget(key: key)), + Expanded(child: TestStatefulWidget(key: key)), ], ), ), @@ -741,10 +741,10 @@ void main() { testWidgets('Table widget diagnostics', (WidgetTester tester) async { GlobalKey key0; - final Widget table = new Directionality( + final Widget table = Directionality( textDirection: TextDirection.ltr, - child: new Table( - key: key0 = new GlobalKey(), + child: Table( + key: key0 = GlobalKey(), defaultColumnWidth: const IntrinsicColumnWidth(), children: const [ TableRow( diff --git a/packages/flutter/test/widgets/test_widgets.dart b/packages/flutter/test/widgets/test_widgets.dart index 77e1b09554..aac5c26930 100644 --- a/packages/flutter/test/widgets/test_widgets.dart +++ b/packages/flutter/test/widgets/test_widgets.dart @@ -36,7 +36,7 @@ class FlipWidget extends StatefulWidget { final Widget right; @override - FlipWidgetState createState() => new FlipWidgetState(); + FlipWidgetState createState() => FlipWidgetState(); } class FlipWidgetState extends State { diff --git a/packages/flutter/test/widgets/text_formatter_test.dart b/packages/flutter/test/widgets/text_formatter_test.dart index 5c51a7bdaf..1fbf3b937c 100644 --- a/packages/flutter/test/widgets/text_formatter_test.dart +++ b/packages/flutter/test/widgets/text_formatter_test.dart @@ -47,7 +47,7 @@ void main() { test('test blacklisting formatter', () { final TextEditingValue actualValue = - new BlacklistingTextInputFormatter(new RegExp(r'[a-z]')) + BlacklistingTextInputFormatter(RegExp(r'[a-z]')) .formatEditUpdate(testOldValue, testNewValue); // Expecting @@ -80,7 +80,7 @@ void main() { test('test whitelisting formatter', () { final TextEditingValue actualValue = - new WhitelistingTextInputFormatter(new RegExp(r'[a-c]')) + WhitelistingTextInputFormatter(RegExp(r'[a-c]')) .formatEditUpdate(testOldValue, testNewValue); // Expecting @@ -112,7 +112,7 @@ void main() { test('test length limiting formatter', () { final TextEditingValue actualValue = - new LengthLimitingTextInputFormatter(6) + LengthLimitingTextInputFormatter(6) .formatEditUpdate(testOldValue, testNewValue); // Expecting @@ -136,7 +136,7 @@ void main() { ); final TextEditingValue actualValue = - new LengthLimitingTextInputFormatter(1) + LengthLimitingTextInputFormatter(1) .formatEditUpdate(testOldValue, testNewValue); // Expecting the empty string. @@ -159,7 +159,7 @@ void main() { ); final TextEditingValue actualValue = - new LengthLimitingTextInputFormatter(2) + LengthLimitingTextInputFormatter(2) .formatEditUpdate(testOldValue, testNewValue); // Expecting two runes. @@ -200,7 +200,7 @@ void main() { extentOffset: 1, ), ); - TextEditingValue actualValue = new LengthLimitingTextInputFormatter(1).formatEditUpdate(testOldValue, testNewValue); + TextEditingValue actualValue = LengthLimitingTextInputFormatter(1).formatEditUpdate(testOldValue, testNewValue); expect(actualValue, const TextEditingValue( text: '\u{1F984}', selection: TextSelection( @@ -218,7 +218,7 @@ void main() { extentOffset: 1, ), ); - actualValue = new LengthLimitingTextInputFormatter(1).formatEditUpdate(testOldValue, testNewValue); + actualValue = LengthLimitingTextInputFormatter(1).formatEditUpdate(testOldValue, testNewValue); expect(actualValue, const TextEditingValue( text: '\u{0058}', selection: TextSelection( @@ -231,7 +231,7 @@ void main() { test('test length limiting formatter when selection is off the end', () { final TextEditingValue actualValue = - new LengthLimitingTextInputFormatter(2) + LengthLimitingTextInputFormatter(2) .formatEditUpdate(testOldValue, testNewValue); // Expecting diff --git a/packages/flutter/test/widgets/text_golden_test.dart b/packages/flutter/test/widgets/text_golden_test.dart index c1b07cb331..6d99f304f9 100644 --- a/packages/flutter/test/widgets/text_golden_test.dart +++ b/packages/flutter/test/widgets/text_golden_test.dart @@ -11,9 +11,9 @@ import 'package:flutter/widgets.dart'; void main() { testWidgets('Centered text', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( width: 200.0, height: 100.0, decoration: const BoxDecoration( @@ -35,9 +35,9 @@ void main() { ); await tester.pumpWidget( - new Center( - child: new RepaintBoundary( - child: new Container( + Center( + child: RepaintBoundary( + child: Container( width: 200.0, height: 100.0, decoration: const BoxDecoration( @@ -66,16 +66,16 @@ void main() { const Color blue = Color(0xFF0000FF); final Shader linearGradient = const LinearGradient( colors: [red, blue], - ).createShader(new Rect.fromLTWH(0.0, 0.0, 50.0, 20.0)); + ).createShader(Rect.fromLTWH(0.0, 0.0, 50.0, 20.0)); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new RepaintBoundary( - child: new Text('Hello', + child: RepaintBoundary( + child: Text('Hello', textDirection: TextDirection.ltr, - style: new TextStyle( - foreground: new Paint() + style: TextStyle( + foreground: Paint() ..color = black ..shader = linearGradient ), @@ -90,13 +90,13 @@ void main() { ); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new RepaintBoundary( - child: new Text('Hello', + child: RepaintBoundary( + child: Text('Hello', textDirection: TextDirection.ltr, - style: new TextStyle( - foreground: new Paint() + style: TextStyle( + foreground: Paint() ..color = black ..style = PaintingStyle.stroke ..strokeWidth = 2.0 @@ -112,13 +112,13 @@ void main() { ); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new RepaintBoundary( - child: new Text('Hello', + child: RepaintBoundary( + child: Text('Hello', textDirection: TextDirection.ltr, - style: new TextStyle( - foreground: new Paint() + style: TextStyle( + foreground: Paint() ..color = black ..style = PaintingStyle.stroke ..strokeWidth = 2.0 @@ -137,17 +137,17 @@ void main() { testWidgets('Text Fade', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( + MaterialApp( + home: Scaffold( backgroundColor: Colors.transparent, - body: new RepaintBoundary( + body: RepaintBoundary( child: Center( - child: new Container( + child: Container( width: 200.0, height: 200.0, color: Colors.green, - child: new Center( - child: new Container( + child: Center( + child: Container( width: 100.0, color: Colors.blue, child: const Text( diff --git a/packages/flutter/test/widgets/text_test.dart b/packages/flutter/test/widgets/text_test.dart index 50c6233fdc..550a70f9a1 100644 --- a/packages/flutter/test/widgets/text_test.dart +++ b/packages/flutter/test/widgets/text_test.dart @@ -115,13 +115,13 @@ void main() { }); testWidgets('semanticsLabel can override text label', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); await tester.pumpWidget( const Text('\$\$', semanticsLabel: 'Double dollars', textDirection: TextDirection.ltr) ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'Double dollars', textDirection: TextDirection.ltr, ), @@ -140,14 +140,14 @@ void main() { }); testWidgets('recognizers split semantic node', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const TextStyle textStyle = TextStyle(fontFamily: 'Ahem'); await tester.pumpWidget( - new Text.rich( - new TextSpan( + Text.rich( + TextSpan( children: [ const TextSpan(text: 'hello '), - new TextSpan(text: 'world', recognizer: new TapGestureRecognizer()..onTap = () {}), + TextSpan(text: 'world', recognizer: TapGestureRecognizer()..onTap = () {}), const TextSpan(text: ' this is a '), const TextSpan(text: 'cat-astrophe'), ], @@ -156,22 +156,22 @@ void main() { textDirection: TextDirection.ltr, ), ); - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( children: [ - new TestSemantics( + TestSemantics( label: 'hello ', textDirection: TextDirection.ltr, ), - new TestSemantics( + TestSemantics( label: 'world', textDirection: TextDirection.ltr, actions: [ SemanticsAction.tap, ], ), - new TestSemantics( + TestSemantics( label: ' this is a cat-astrophe', textDirection: TextDirection.ltr, ) @@ -184,17 +184,17 @@ void main() { }); testWidgets('recognizers split semantic node - bidi', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); const TextStyle textStyle = TextStyle(fontFamily: 'Ahem'); await tester.pumpWidget( - new RichText( - text: new TextSpan( + RichText( + text: TextSpan( style: textStyle, children: [ const TextSpan(text: 'hello world${Unicode.RLE}${Unicode.RLO} '), - new TextSpan(text: 'BOY', recognizer: new LongPressGestureRecognizer()..onLongPress = () {}), + TextSpan(text: 'BOY', recognizer: LongPressGestureRecognizer()..onLongPress = () {}), const TextSpan(text: ' HOW DO${Unicode.PDF} you ${Unicode.RLO} DO '), - new TextSpan(text: 'SIR', recognizer: new TapGestureRecognizer()..onTap = () {}), + TextSpan(text: 'SIR', recognizer: TapGestureRecognizer()..onTap = () {}), const TextSpan(text: '${Unicode.PDF}${Unicode.PDF} good bye'), ], ), @@ -203,39 +203,39 @@ void main() { ); // The expected visual order of the text is: // hello world RIS OD you OD WOH YOB good bye - final TestSemantics expectedSemantics = new TestSemantics.root( + final TestSemantics expectedSemantics = TestSemantics.root( children: [ - new TestSemantics.rootChild( - rect: new Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), + TestSemantics.rootChild( + rect: Rect.fromLTRB(0.0, 0.0, 800.0, 600.0), children: [ - new TestSemantics( - rect: new Rect.fromLTRB(-4.0, -4.0, 480.0, 18.0), + TestSemantics( + rect: Rect.fromLTRB(-4.0, -4.0, 480.0, 18.0), label: 'hello world ', textDirection: TextDirection.ltr, // text direction is declared as LTR. ), - new TestSemantics( - rect: new Rect.fromLTRB(150.0, -4.0, 200.0, 18.0), + TestSemantics( + rect: Rect.fromLTRB(150.0, -4.0, 200.0, 18.0), label: 'RIS', textDirection: TextDirection.rtl, // in the last string we switched to RTL using RLE. actions: [ SemanticsAction.tap, ], ), - new TestSemantics( - rect: new Rect.fromLTRB(192.0, -4.0, 424.0, 18.0), + TestSemantics( + rect: Rect.fromLTRB(192.0, -4.0, 424.0, 18.0), label: ' OD you OD WOH ', // Still RTL. textDirection: TextDirection.rtl, ), - new TestSemantics( - rect: new Rect.fromLTRB(416.0, -4.0, 466.0, 18.0), + TestSemantics( + rect: Rect.fromLTRB(416.0, -4.0, 466.0, 18.0), label: 'YOB', textDirection: TextDirection.rtl, // Still RTL. actions: [ SemanticsAction.longPress, ], ), - new TestSemantics( - rect: new Rect.fromLTRB(472.0, -4.0, 606.0, 18.0), + TestSemantics( + rect: Rect.fromLTRB(472.0, -4.0, 606.0, 18.0), label: ' good bye', textDirection: TextDirection.rtl, // Begin as RTL but pop to LTR. ), diff --git a/packages/flutter/test/widgets/ticker_provider_test.dart b/packages/flutter/test/widgets/ticker_provider_test.dart index 116a41c261..4cec82d891 100644 --- a/packages/flutter/test/widgets/ticker_provider_test.dart +++ b/packages/flutter/test/widgets/ticker_provider_test.dart @@ -33,7 +33,7 @@ void main() { }); testWidgets('Navigation with TickerMode', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( home: const LinearProgressIndicator(), routes: { '/test': (BuildContext context) => const Text('hello'), @@ -55,21 +55,21 @@ void main() { }); testWidgets('SingleTickerProviderStateMixin can handle not being used', (WidgetTester tester) async { - final Widget widget = new BoringTickerTest(); + final Widget widget = BoringTickerTest(); expect(widget.toString, isNot(throwsException)); await tester.pumpWidget(widget); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); // the test is that this doesn't crash, like it used to... }); } class BoringTickerTest extends StatefulWidget { @override - _BoringTickerTestState createState() => new _BoringTickerTestState(); + _BoringTickerTestState createState() => _BoringTickerTestState(); } class _BoringTickerTestState extends State with SingleTickerProviderStateMixin { @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } diff --git a/packages/flutter/test/widgets/title_test.dart b/packages/flutter/test/widgets/title_test.dart index 09696e2b20..99b688bc9f 100644 --- a/packages/flutter/test/widgets/title_test.dart +++ b/packages/flutter/test/widgets/title_test.dart @@ -8,17 +8,17 @@ import 'package:flutter/services.dart'; void main() { testWidgets('toString control test', (WidgetTester tester) async { - final Widget widget = new Title( + final Widget widget = Title( color: const Color(0xFF00FF00), title: 'Awesome app', - child: new Container(), + child: Container(), ); expect(widget.toString, isNot(throwsException)); }); testWidgets('should handle having no title', (WidgetTester tester) async { - final Title widget = new Title( - child: new Container(), + final Title widget = Title( + child: Container(), color: const Color(0xFF00FF00), ); expect(widget.toString, isNot(throwsException)); @@ -27,21 +27,21 @@ void main() { }); testWidgets('should not allow null title or color', (WidgetTester tester) async { - expect(() => new Title( + expect(() => Title( title: null, color: const Color(0xFF00FF00), - child: new Container(), + child: Container(), ), throwsAssertionError); - expect(() => new Title( + expect(() => Title( color: null, - child: new Container(), + child: Container(), ), throwsAssertionError); }); testWidgets('should not allow non-opaque color', (WidgetTester tester) async { - expect(() => new Title( + expect(() => Title( color: const Color(0), - child: new Container(), + child: Container(), ), throwsAssertionError); }); @@ -53,8 +53,8 @@ void main() { log.add(methodCall); }); - await tester.pumpWidget(new Title( - child: new Container(), + await tester.pumpWidget(Title( + child: Container(), color: const Color(0xFF00FF00), )); diff --git a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart index 7303dba620..438a0bd19d 100644 --- a/packages/flutter/test/widgets/tracking_scroll_controller_test.dart +++ b/packages/flutter/test/widgets/tracking_scroll_controller_test.dart @@ -8,21 +8,21 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('TrackingScrollController saves offset', (WidgetTester tester) async { - final TrackingScrollController controller = new TrackingScrollController(); + final TrackingScrollController controller = TrackingScrollController(); const double listItemHeight = 100.0; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new PageView.builder( + child: PageView.builder( itemBuilder: (BuildContext context, int index) { - return new ListView( + return ListView( controller: controller, - children: new List.generate( + children: List.generate( 10, - (int i) => new Container( + (int i) => Container( height: listItemHeight, - child: new Text('Page$index-Item$i'), + child: Text('Page$index-Item$i'), ), ).toList(), ); diff --git a/packages/flutter/test/widgets/transform_test.dart b/packages/flutter/test/widgets/transform_test.dart index c009edd481..81afd854d8 100644 --- a/packages/flutter/test/widgets/transform_test.dart +++ b/packages/flutter/test/widgets/transform_test.dart @@ -13,33 +13,33 @@ void main() { testWidgets('Transform origin', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: const Color(0xFF0000FF), ), ), - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + child: Transform( + transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0), origin: const Offset(100.0, 50.0), - child: new GestureDetector( + child: GestureDetector( onTap: () { didReceiveTap = true; }, - child: new Container( + child: Container( color: const Color(0xFF00FFFF), ), ), @@ -61,33 +61,33 @@ void main() { testWidgets('Transform alignment', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: const Color(0xFF0000FF), ), ), - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + child: Transform( + transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0), alignment: const Alignment(1.0, 0.0), - child: new GestureDetector( + child: GestureDetector( onTap: () { didReceiveTap = true; }, - child: new Container( + child: Container( color: const Color(0xFF00FFFF), ), ), @@ -110,33 +110,33 @@ void main() { bool didReceiveTap = false; Widget buildFrame(TextDirection textDirection, AlignmentGeometry alignment) { - return new Directionality( + return Directionality( textDirection: textDirection, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: const Color(0xFF0000FF), ), ), - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + child: Transform( + transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0), alignment: alignment, - child: new GestureDetector( + child: GestureDetector( onTap: () { didReceiveTap = true; }, - child: new Container( + child: Container( color: const Color(0xFF00FFFF), ), ), @@ -180,34 +180,34 @@ void main() { testWidgets('Transform offset + alignment', (WidgetTester tester) async { bool didReceiveTap = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: [ - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, color: const Color(0xFF0000FF), ), ), - new Positioned( + Positioned( top: 100.0, left: 100.0, - child: new Container( + child: Container( width: 100.0, height: 100.0, - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), + child: Transform( + transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0), origin: const Offset(100.0, 0.0), alignment: const Alignment(-1.0, 0.0), - child: new GestureDetector( + child: GestureDetector( onTap: () { didReceiveTap = true; }, - child: new Container( + child: Container( color: const Color(0xFF00FFFF), ), ), @@ -228,16 +228,16 @@ void main() { testWidgets('Composited transform offset', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new SizedBox( + Center( + child: SizedBox( width: 400.0, height: 300.0, - child: new ClipRect( - child: new Transform( - transform: new Matrix4.diagonal3Values(0.5, 0.5, 1.0), - child: new Opacity( + child: ClipRect( + child: Transform( + transform: Matrix4.diagonal3Values(0.5, 0.5, 1.0), + child: Opacity( opacity: 0.9, - child: new Container( + child: Container( color: const Color(0xFF00FF00), ), ), @@ -253,14 +253,14 @@ void main() { // The first transform is from the render view. final TransformLayer layer = layers[1]; final Matrix4 transform = layer.transform; - expect(transform.getTranslation(), equals(new Vector3(100.0, 75.0, 0.0))); + expect(transform.getTranslation(), equals(Vector3(100.0, 75.0, 0.0))); }); testWidgets('Transform.rotate', (WidgetTester tester) async { await tester.pumpWidget( - new Transform.rotate( + Transform.rotate( angle: math.pi / 2.0, - child: new Opacity(opacity: 0.5, child: new Container()), + child: Opacity(opacity: 0.5, child: Container()), ), ); @@ -280,15 +280,15 @@ void main() { testWidgets('applyPaintTransform of Transform in Padding', (WidgetTester tester) async { await tester.pumpWidget( - new Padding( + Padding( padding: const EdgeInsets.only( left: 30.0, top: 20.0, right: 50.0, bottom: 70.0, ), - child: new Transform( - transform: new Matrix4.diagonal3Values(2.0, 2.0, 2.0), + child: Transform( + transform: Matrix4.diagonal3Values(2.0, 2.0, 2.0), child: const Placeholder(), ), ), @@ -298,9 +298,9 @@ void main() { testWidgets('Transform.translate', (WidgetTester tester) async { await tester.pumpWidget( - new Transform.translate( + Transform.translate( offset: const Offset(100.0, 50.0), - child: new Opacity(opacity: 0.5, child: new Container()), + child: Opacity(opacity: 0.5, child: Container()), ), ); @@ -313,9 +313,9 @@ void main() { testWidgets('Transform.scale', (WidgetTester tester) async { await tester.pumpWidget( - new Transform.scale( + Transform.scale( scale: 2.0, - child: new Opacity(opacity: 0.5, child: new Container()), + child: Opacity(opacity: 0.5, child: Container()), ), ); @@ -335,18 +335,18 @@ void main() { }); testWidgets('Translated child into translated box - hit test', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); bool _pointerDown = false; await tester.pumpWidget( - new Transform.translate( + Transform.translate( offset: const Offset(100.0, 50.0), - child: new Transform.translate( + child: Transform.translate( offset: const Offset(1000.0, 1000.0), - child: new Listener( + child: Listener( onPointerDown: (PointerDownEvent event) { _pointerDown = true; }, - child: new Container( + child: Container( key: key1, color: const Color(0xFF000000), ) diff --git a/packages/flutter/test/widgets/transitions_test.dart b/packages/flutter/test/widgets/transitions_test.dart index ee2520ef2c..cbc019bb32 100644 --- a/packages/flutter/test/widgets/transitions_test.dart +++ b/packages/flutter/test/widgets/transitions_test.dart @@ -16,10 +16,10 @@ void main() { }); group('DecoratedBoxTransition test', () { - final DecorationTween decorationTween = new DecorationTween( - begin: new BoxDecoration( + final DecorationTween decorationTween = DecorationTween( + begin: BoxDecoration( color: const Color(0xFFFFFFFF), - border: new Border.all( + border: Border.all( color: const Color(0xFF000000), style: BorderStyle.solid, width: 4.0, @@ -32,14 +32,14 @@ void main() { spreadRadius: 4.0, )], ), - end: new BoxDecoration( + end: BoxDecoration( color: const Color(0xFF000000), - border: new Border.all( + border: Border.all( color: const Color(0xFF202020), style: BorderStyle.solid, width: 1.0, ), - borderRadius: new BorderRadius.circular(10.0), + borderRadius: BorderRadius.circular(10.0), shape: BoxShape.rectangle, // No shadow. ), @@ -48,14 +48,14 @@ void main() { AnimationController controller; setUp(() { - controller = new AnimationController(vsync: const TestVSync()); + controller = AnimationController(vsync: const TestVSync()); }); testWidgets( 'decoration test', (WidgetTester tester) async { final DecoratedBoxTransition transitionUnderTest = - new DecoratedBoxTransition( + DecoratedBoxTransition( decoration: decorationTween.animate(controller), child: const Text('Doesn\'t matter', textDirection: TextDirection.ltr), ); @@ -82,7 +82,7 @@ void main() { expect(border.left.width, 2.5); expect(border.left.style, BorderStyle.solid); expect(border.left.color, const Color(0xFF101010)); - expect(actualDecoration.borderRadius, new BorderRadius.circular(5.0)); + expect(actualDecoration.borderRadius, BorderRadius.circular(5.0)); expect(actualDecoration.shape, BoxShape.rectangle); expect(actualDecoration.boxShadow[0].blurRadius, 5.0); expect(actualDecoration.boxShadow[0].spreadRadius, 2.0); @@ -102,13 +102,13 @@ void main() { testWidgets('animations work with curves test', (WidgetTester tester) async { final Animation curvedDecorationAnimation = - decorationTween.animate(new CurvedAnimation( + decorationTween.animate(CurvedAnimation( parent: controller, curve: Curves.easeOut, )); final DecoratedBoxTransition transitionUnderTest = - new DecoratedBoxTransition( + DecoratedBoxTransition( decoration: curvedDecorationAnimation, position: DecorationPosition.foreground, child: const Text('Doesn\'t matter', textDirection: TextDirection.ltr), @@ -148,12 +148,12 @@ void main() { }); testWidgets('AlignTransition animates', (WidgetTester tester) async { - final AnimationController controller = new AnimationController(vsync: const TestVSync()); - final Animation alignmentTween = new AlignmentTween( + final AnimationController controller = AnimationController(vsync: const TestVSync()); + final Animation alignmentTween = AlignmentTween( begin: const Alignment(-1.0, 0.0), end: const Alignment(1.0, 1.0), ).animate(controller); - final Widget widget = new AlignTransition( + final Widget widget = AlignTransition( alignment: alignmentTween, child: const Text('Ready', textDirection: TextDirection.ltr), ); @@ -172,12 +172,12 @@ void main() { }); testWidgets('AlignTransition keeps width and height factors', (WidgetTester tester) async { - final AnimationController controller = new AnimationController(vsync: const TestVSync()); - final Animation alignmentTween = new AlignmentTween( + final AnimationController controller = AnimationController(vsync: const TestVSync()); + final Animation alignmentTween = AlignmentTween( begin: const Alignment(-1.0, 0.0), end: const Alignment(1.0, 1.0), ).animate(controller); - final Widget widget = new AlignTransition( + final Widget widget = AlignTransition( alignment: alignmentTween, child: const Text('Ready', textDirection: TextDirection.ltr), widthFactor: 0.3, @@ -193,12 +193,12 @@ void main() { }); testWidgets('SizeTransition clamps negative size factors - vertical axis', (WidgetTester tester) async { - final AnimationController controller = new AnimationController(vsync: const TestVSync()); - final Animation animation = new Tween(begin: -1.0, end: 1.0).animate(controller); + final AnimationController controller = AnimationController(vsync: const TestVSync()); + final Animation animation = Tween(begin: -1.0, end: 1.0).animate(controller); - final Widget widget = new Directionality( + final Widget widget = Directionality( textDirection: TextDirection.ltr, - child: new SizeTransition( + child: SizeTransition( axis: Axis.vertical, sizeFactor: animation, child: const Text('Ready'), @@ -224,12 +224,12 @@ void main() { }); testWidgets('SizeTransition clamps negative size factors - horizontal axis', (WidgetTester tester) async { - final AnimationController controller = new AnimationController(vsync: const TestVSync()); - final Animation animation = new Tween(begin: -1.0, end: 1.0).animate(controller); + final AnimationController controller = AnimationController(vsync: const TestVSync()); + final Animation animation = Tween(begin: -1.0, end: 1.0).animate(controller); - final Widget widget = new Directionality( + final Widget widget = Directionality( textDirection: TextDirection.ltr, - child: new SizeTransition( + child: SizeTransition( axis: Axis.horizontal, sizeFactor: animation, child: const Text('Ready'), diff --git a/packages/flutter/test/widgets/unique_widget_test.dart b/packages/flutter/test/widgets/unique_widget_test.dart index 7f455cb58b..f66d5bf4dd 100644 --- a/packages/flutter/test/widgets/unique_widget_test.dart +++ b/packages/flutter/test/widgets/unique_widget_test.dart @@ -9,17 +9,17 @@ class TestUniqueWidget extends UniqueWidget { const TestUniqueWidget({ GlobalKey key }) : super(key: key); @override - TestUniqueWidgetState createState() => new TestUniqueWidgetState(); + TestUniqueWidgetState createState() => TestUniqueWidgetState(); } class TestUniqueWidgetState extends State { @override - Widget build(BuildContext context) => new Container(); + Widget build(BuildContext context) => Container(); } void main() { testWidgets('Unique widget control test', (WidgetTester tester) async { - final TestUniqueWidget widget = new TestUniqueWidget(key: new GlobalKey()); + final TestUniqueWidget widget = TestUniqueWidget(key: GlobalKey()); await tester.pumpWidget(widget); @@ -27,7 +27,7 @@ void main() { expect(state, isNotNull); - await tester.pumpWidget(new Container(child: widget)); + await tester.pumpWidget(Container(child: widget)); expect(widget.currentState, equals(state)); }); diff --git a/packages/flutter/test/widgets/value_listenable_builder_test.dart b/packages/flutter/test/widgets/value_listenable_builder_test.dart index 293d974e32..d6348707fd 100644 --- a/packages/flutter/test/widgets/value_listenable_builder_test.dart +++ b/packages/flutter/test/widgets/value_listenable_builder_test.dart @@ -13,21 +13,21 @@ void main() { Widget builderForValueListenable( ValueListenable valueListenable, ) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, - child: new ValueListenableBuilder( + child: ValueListenableBuilder( valueListenable: valueListenable, builder: (BuildContext context, String value, Widget child) { if (value == null) return const Placeholder(); - return new Text(value); + return Text(value); }, ), ); } setUp(() { - valueListenable = new SpyStringValueNotifier(null); + valueListenable = SpyStringValueNotifier(null); textBuilderUnderTest = builderForValueListenable(valueListenable); }); @@ -38,7 +38,7 @@ void main() { }); testWidgets('Widget builds with initial value', (WidgetTester tester) async { - valueListenable = new SpyStringValueNotifier('Bachman'); + valueListenable = SpyStringValueNotifier('Bachman'); await tester.pumpWidget(builderForValueListenable(valueListenable)); @@ -66,7 +66,7 @@ void main() { expect(find.text('Gilfoyle'), findsOneWidget); final ValueListenable differentListenable = - new SpyStringValueNotifier('Hendricks'); + SpyStringValueNotifier('Hendricks'); await tester.pumpWidget(builderForValueListenable(differentListenable)); @@ -82,7 +82,7 @@ void main() { expect(find.text('Gilfoyle'), findsOneWidget); final ValueListenable differentListenable = - new SpyStringValueNotifier('Hendricks'); + SpyStringValueNotifier('Hendricks'); await tester.pumpWidget(builderForValueListenable(differentListenable)); diff --git a/packages/flutter/test/widgets/visibility_test.dart b/packages/flutter/test/widgets/visibility_test.dart index be6a544967..18afe636b1 100644 --- a/packages/flutter/test/widgets/visibility_test.dart +++ b/packages/flutter/test/widgets/visibility_test.dart @@ -13,7 +13,7 @@ class TestState extends StatefulWidget { final Widget child; final List log; @override - State createState() => new _TestStateState(); + State createState() => _TestStateState(); } class _TestStateState extends State { @@ -30,26 +30,26 @@ class _TestStateState extends State { void main() { testWidgets('Visibility', (WidgetTester tester) async { - final SemanticsTester semantics = new SemanticsTester(tester); + final SemanticsTester semantics = SemanticsTester(tester); final List log = []; - final Widget testChild = new GestureDetector( + final Widget testChild = GestureDetector( onTap: () { log.add('tap'); }, - child: new Builder( + child: Builder( builder: (BuildContext context) { final bool animating = TickerMode.of(context); - return new TestState( + return TestState( log: log, - child: new Text('a $animating', textDirection: TextDirection.rtl), + child: Text('a $animating', textDirection: TextDirection.rtl), ); }, ), ); final Matcher expectedSemanticsWhenPresent = hasSemantics( - new TestSemantics.root( + TestSemantics.root( children: [ - new TestSemantics.rootChild( + TestSemantics.rootChild( label: 'a true', textDirection: TextDirection.rtl, actions: [SemanticsAction.tap], @@ -61,13 +61,13 @@ void main() { ignoreTransform: true, ); - final Matcher expectedSemanticsWhenAbsent = hasSemantics(new TestSemantics.root()); + final Matcher expectedSemanticsWhenAbsent = hasSemantics(TestSemantics.root()); // We now run a sequence of pumpWidget calls one after the other. In // addition to verifying that the right behaviour is seen in each case, this // also verifies that the widget can dynamically change from state to state. - await tester.pumpWidget(new Visibility(child: testChild)); + await tester.pumpWidget(Visibility(child: testChild)); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Visibility), paints..paragraph()); @@ -78,7 +78,7 @@ void main() { expect(log, ['created new state', 'tap']); log.clear(); - await tester.pumpWidget(new Visibility(child: testChild, visible: false)); + await tester.pumpWidget(Visibility(child: testChild, visible: false)); expect(find.byType(Text, skipOffstage: false), findsNothing); expect(find.byType(Visibility), paintsNothing); expect(tester.getSize(find.byType(Visibility)), const Size(800.0, 600.0)); @@ -88,7 +88,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false))); expect(find.byType(Text, skipOffstage: false), findsNothing); expect(find.byType(Placeholder), findsNothing); expect(find.byType(Visibility), paintsNothing); @@ -99,7 +99,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, replacement: const Placeholder(), visible: false))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, replacement: const Placeholder(), visible: false))); expect(find.byType(Text, skipOffstage: false), findsNothing); expect(find.byType(Placeholder), findsOneWidget); expect(find.byType(Visibility), paints..path()); @@ -110,7 +110,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, replacement: const Placeholder(), visible: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, replacement: const Placeholder(), visible: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -122,7 +122,7 @@ void main() { expect(log, ['created new state', 'tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: true, maintainState: true, maintainAnimation: true, maintainSize: true, maintainInteractivity: true, maintainSemantics: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: true, maintainState: true, maintainAnimation: true, maintainSize: true, maintainInteractivity: true, maintainSemantics: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -134,7 +134,7 @@ void main() { expect(log, ['created new state', 'tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true, maintainInteractivity: true, maintainSemantics: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true, maintainInteractivity: true, maintainSemantics: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -146,7 +146,7 @@ void main() { expect(log, ['tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true, maintainInteractivity: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true, maintainInteractivity: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -158,7 +158,7 @@ void main() { expect(log, ['tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true, maintainSemantics: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true, maintainSemantics: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -170,7 +170,7 @@ void main() { expect(log, ['created new state']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true, maintainSize: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -182,7 +182,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true, maintainAnimation: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.byType(Text, skipOffstage: true), findsNothing); expect(find.text('a true', skipOffstage: false), findsOneWidget); @@ -195,7 +195,7 @@ void main() { expect(log, ['created new state']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.byType(Text, skipOffstage: true), findsNothing); expect(find.text('a false', skipOffstage: false), findsOneWidget); @@ -210,7 +210,7 @@ void main() { // Now we toggle the visibility off and on a few times to make sure that works. - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: true, maintainState: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: true, maintainState: true))); expect(find.byType(Text), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -222,7 +222,7 @@ void main() { expect(log, ['tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.byType(Text, skipOffstage: true), findsNothing); expect(find.text('a false', skipOffstage: false), findsOneWidget); @@ -235,7 +235,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: true, maintainState: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: true, maintainState: true))); expect(find.byType(Text), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -247,7 +247,7 @@ void main() { expect(log, ['tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false, maintainState: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false, maintainState: true))); expect(find.byType(Text, skipOffstage: false), findsOneWidget); expect(find.byType(Text, skipOffstage: true), findsNothing); expect(find.text('a false', skipOffstage: false), findsOneWidget); @@ -262,7 +262,7 @@ void main() { // Same but without maintainState. - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false))); expect(find.byType(Text, skipOffstage: false), findsNothing); expect(find.byType(Placeholder), findsNothing); expect(find.byType(Visibility), paintsNothing); @@ -273,7 +273,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: true))); expect(find.byType(Text), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); @@ -285,7 +285,7 @@ void main() { expect(log, ['created new state', 'tap']); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: false))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: false))); expect(find.byType(Text, skipOffstage: false), findsNothing); expect(find.byType(Placeholder), findsNothing); expect(find.byType(Visibility), paintsNothing); @@ -296,7 +296,7 @@ void main() { expect(log, []); log.clear(); - await tester.pumpWidget(new Center(child: new Visibility(child: testChild, visible: true))); + await tester.pumpWidget(Center(child: Visibility(child: testChild, visible: true))); expect(find.byType(Text), findsOneWidget); expect(find.text('a true', skipOffstage: false), findsOneWidget); expect(find.byType(Placeholder), findsNothing); diff --git a/packages/flutter/test/widgets/widget_inspector_test.dart b/packages/flutter/test/widgets/widget_inspector_test.dart index ecc81fce33..d43adb0f43 100644 --- a/packages/flutter/test/widgets/widget_inspector_test.dart +++ b/packages/flutter/test/widgets/widget_inspector_test.dart @@ -21,18 +21,18 @@ class RenderRepaintBoundaryWithDebugPaint extends RenderRepaintBoundary { assert(() { // Draw some debug paint UI interleaving creating layers and drawing // directly to the context's canvas. - final Paint paint = new Paint() + final Paint paint = Paint() ..style = PaintingStyle.stroke ..strokeWidth = 1.0 ..color = Colors.red; { - final PictureLayer pictureLayer = new PictureLayer(Offset.zero & size); - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final Canvas pictureCanvas = new Canvas(recorder); + final PictureLayer pictureLayer = PictureLayer(Offset.zero & size); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final Canvas pictureCanvas = Canvas(recorder); pictureCanvas.drawCircle(Offset.zero, 20.0, paint); pictureLayer.picture = recorder.endRecording(); context.addLayer( - new OffsetLayer() + OffsetLayer() ..offset = offset ..append(pictureLayer), ); @@ -43,13 +43,13 @@ class RenderRepaintBoundaryWithDebugPaint extends RenderRepaintBoundary { paint, ); { - final PictureLayer pictureLayer = new PictureLayer(Offset.zero & size); - final ui.PictureRecorder recorder = new ui.PictureRecorder(); - final Canvas pictureCanvas = new Canvas(recorder); + final PictureLayer pictureLayer = PictureLayer(Offset.zero & size); + final ui.PictureRecorder recorder = ui.PictureRecorder(); + final Canvas pictureCanvas = Canvas(recorder); pictureCanvas.drawCircle(const Offset(20.0, 20.0), 20.0, paint); pictureLayer.picture = recorder.endRecording(); context.addLayer( - new OffsetLayer() + OffsetLayer() ..offset = offset ..append(pictureLayer), ); @@ -74,7 +74,7 @@ class RepaintBoundaryWithDebugPaint extends RepaintBoundary { @override RenderRepaintBoundary createRenderObject(BuildContext context) { - return new RenderRepaintBoundaryWithDebugPaint(); + return RenderRepaintBoundaryWithDebugPaint(); } } @@ -129,15 +129,15 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // These tests need access to protected members of WidgetInspectorService. static void runTests() { - final TestWidgetInspectorService service = new TestWidgetInspectorService(); + final TestWidgetInspectorService service = TestWidgetInspectorService(); WidgetInspectorService.instance = service; testWidgets('WidgetInspector smoke test', (WidgetTester tester) async { // This is a smoke test to verify that adding the inspector doesn't crash. await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -148,11 +148,11 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { ); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new WidgetInspector( + child: WidgetInspector( selectButtonBuilder: null, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -168,34 +168,34 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('WidgetInspector interaction test', (WidgetTester tester) async { final List log = []; - final GlobalKey selectButtonKey = new GlobalKey(); - final GlobalKey inspectorKey = new GlobalKey(); - final GlobalKey topButtonKey = new GlobalKey(); + final GlobalKey selectButtonKey = GlobalKey(); + final GlobalKey inspectorKey = GlobalKey(); + final GlobalKey topButtonKey = GlobalKey(); Widget selectButtonBuilder(BuildContext context, VoidCallback onPressed) { - return new Material(child: new RaisedButton(onPressed: onPressed, key: selectButtonKey)); + return Material(child: RaisedButton(onPressed: onPressed, key: selectButtonKey)); } // State type is private, hence using dynamic. dynamic getInspectorState() => inspectorKey.currentState; String paragraphText(RenderParagraph paragraph) => paragraph.text.text; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new WidgetInspector( + child: WidgetInspector( key: inspectorKey, selectButtonBuilder: selectButtonBuilder, - child: new Material( - child: new ListView( + child: Material( + child: ListView( children: [ - new RaisedButton( + RaisedButton( key: topButtonKey, onPressed: () { log.add('top'); }, child: const Text('TOP'), ), - new RaisedButton( + RaisedButton( onPressed: () { log.add('bottom'); }, @@ -241,13 +241,13 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('WidgetInspector non-invertible transform regression test', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new WidgetInspector( + child: WidgetInspector( selectButtonBuilder: null, - child: new Transform( - transform: new Matrix4.identity()..scale(0.0), - child: new Stack( + child: Transform( + transform: Matrix4.identity()..scale(0.0), + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -265,25 +265,25 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { }); testWidgets('WidgetInspector scroll test', (WidgetTester tester) async { - final Key childKey = new UniqueKey(); - final GlobalKey selectButtonKey = new GlobalKey(); - final GlobalKey inspectorKey = new GlobalKey(); + final Key childKey = UniqueKey(); + final GlobalKey selectButtonKey = GlobalKey(); + final GlobalKey inspectorKey = GlobalKey(); Widget selectButtonBuilder(BuildContext context, VoidCallback onPressed) { - return new Material(child: new RaisedButton(onPressed: onPressed, key: selectButtonKey)); + return Material(child: RaisedButton(onPressed: onPressed, key: selectButtonKey)); } // State type is private, hence using dynamic. dynamic getInspectorState() => inspectorKey.currentState; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new WidgetInspector( + child: WidgetInspector( key: inspectorKey, selectButtonBuilder: selectButtonBuilder, - child: new ListView( + child: ListView( children: [ - new Container( + Container( key: childKey, height: 5000.0, ), @@ -326,11 +326,11 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { bool didLongPress = false; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new WidgetInspector( + child: WidgetInspector( selectButtonBuilder: null, - child: new GestureDetector( + child: GestureDetector( onLongPress: () { expect(didLongPress, isFalse); didLongPress = true; @@ -347,42 +347,42 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { }); testWidgets('WidgetInspector offstage', (WidgetTester tester) async { - final GlobalKey inspectorKey = new GlobalKey(); - final GlobalKey clickTarget = new GlobalKey(); + final GlobalKey inspectorKey = GlobalKey(); + final GlobalKey clickTarget = GlobalKey(); Widget createSubtree({ double width, Key key }) { - return new Stack( + return Stack( children: [ - new Positioned( + Positioned( key: key, left: 0.0, top: 0.0, width: width, height: 100.0, - child: new Text(width.toString(), textDirection: TextDirection.ltr), + child: Text(width.toString(), textDirection: TextDirection.ltr), ), ], ); } await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new WidgetInspector( + child: WidgetInspector( key: inspectorKey, selectButtonBuilder: null, - child: new Overlay( + child: Overlay( initialEntries: [ - new OverlayEntry( + OverlayEntry( opaque: false, maintainState: true, builder: (BuildContext _) => createSubtree(width: 94.0), ), - new OverlayEntry( + OverlayEntry( opaque: true, maintainState: true, builder: (BuildContext _) => createSubtree(width: 95.0), ), - new OverlayEntry( + OverlayEntry( opaque: false, maintainState: true, builder: (BuildContext _) => createSubtree(width: 96.0, key: clickTarget), @@ -413,7 +413,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { test('WidgetInspectorService dispose group', () { service.disposeAllGroups(); - final Object a = new Object(); + final Object a = Object(); const String group1 = 'group-1'; const String group2 = 'group-2'; const String group3 = 'group-3'; @@ -429,8 +429,8 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { test('WidgetInspectorService dispose id', () { service.disposeAllGroups(); - final Object a = new Object(); - final Object b = new Object(); + final Object a = Object(); + final Object b = Object(); const String group1 = 'group-1'; const String group2 = 'group-2'; final String aId = service.toId(a, group1); @@ -492,9 +492,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('WidgetInspectorService maybeSetSelection', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -541,9 +541,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -612,9 +612,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -639,9 +639,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('WidgetInspectorService creationLocation', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a'), Text('b', textDirection: TextDirection.ltr), @@ -699,9 +699,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('WidgetInspectorService setPubRootDirectories', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a'), Text('b', textDirection: TextDirection.ltr), @@ -777,7 +777,7 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { }, skip: !WidgetInspectorService.instance.isWidgetCreationTracked()); // Test requires --track-widget-creation flag. test('ext.flutter.inspector.disposeGroup', () async { - final Object a = new Object(); + final Object a = Object(); const String group1 = 'group-1'; const String group2 = 'group-2'; const String group3 = 'group-3'; @@ -792,8 +792,8 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { }); test('ext.flutter.inspector.disposeId', () async { - final Object a = new Object(); - final Object b = new Object(); + final Object a = Object(); + final Object b = Object(); const String group1 = 'group-1'; const String group2 = 'group-2'; final String aId = service.toId(a, group1); @@ -809,9 +809,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('ext.flutter.inspector.setSelection', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -858,9 +858,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -927,9 +927,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -955,9 +955,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -991,9 +991,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -1029,9 +1029,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -1112,9 +1112,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { const String group = 'test-group'; await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a', textDirection: TextDirection.ltr), Text('b', textDirection: TextDirection.ltr), @@ -1165,9 +1165,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('ext.flutter.inspector creationLocation', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a'), Text('b', textDirection: TextDirection.ltr), @@ -1225,9 +1225,9 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('ext.flutter.inspector.setPubRootDirectories', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( children: const [ Text('a'), Text('b', textDirection: TextDirection.ltr), @@ -1318,46 +1318,46 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { testWidgets('ext.flutter.inspector.screenshot', (WidgetTester tester) async { - final GlobalKey outerContainerKey = new GlobalKey(); - final GlobalKey paddingKey = new GlobalKey(); - final GlobalKey redContainerKey = new GlobalKey(); - final GlobalKey whiteContainerKey = new GlobalKey(); - final GlobalKey sizedBoxKey = new GlobalKey(); + final GlobalKey outerContainerKey = GlobalKey(); + final GlobalKey paddingKey = GlobalKey(); + final GlobalKey redContainerKey = GlobalKey(); + final GlobalKey whiteContainerKey = GlobalKey(); + final GlobalKey sizedBoxKey = GlobalKey(); // Complex widget tree intended to exercise features such as children // with rotational transforms and clipping without introducing platform // specific behavior as text rendering would. await tester.pumpWidget( - new Center( - child: new RepaintBoundaryWithDebugPaint( - child: new Container( + Center( + child: RepaintBoundaryWithDebugPaint( + child: Container( key: outerContainerKey, color: Colors.white, - child: new Padding( + child: Padding( key: paddingKey, padding: const EdgeInsets.all(100.0), - child: new SizedBox( + child: SizedBox( key: sizedBoxKey, height: 100.0, width: 100.0, - child: new Transform.rotate( + child: Transform.rotate( angle: 1.0, // radians - child: new ClipRRect( + child: ClipRRect( borderRadius: const BorderRadius.only( topLeft: Radius.elliptical(10.0, 20.0), topRight: Radius.elliptical(5.0, 30.0), bottomLeft: Radius.elliptical(2.5, 12.0), bottomRight: Radius.elliptical(15.0, 6.0), ), - child: new Container( + child: Container( key: redContainerKey, color: Colors.red, - child: new Container( + child: Container( key: whiteContainerKey, color: Colors.white, - child: new RepaintBoundary( - child: new Center( - child: new Container( + child: RepaintBoundary( + child: Center( + child: Container( color: Colors.black, height: 10.0, width: 10.0, @@ -1609,44 +1609,44 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { // These tests verify that screenshots can still be taken and look correct // when the leader and follower layer are both in the screenshots and when // only the leader or follower layer is in the screenshot. - final LayerLink link = new LayerLink(); - final GlobalKey key = new GlobalKey(); - final GlobalKey mainStackKey = new GlobalKey(); - final GlobalKey transformTargetParent = new GlobalKey(); - final GlobalKey stackWithTransformFollower = new GlobalKey(); + final LayerLink link = LayerLink(); + final GlobalKey key = GlobalKey(); + final GlobalKey mainStackKey = GlobalKey(); + final GlobalKey transformTargetParent = GlobalKey(); + final GlobalKey stackWithTransformFollower = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new RepaintBoundary( - child: new Stack( + child: RepaintBoundary( + child: Stack( key: mainStackKey, children: [ - new Stack( + Stack( key: transformTargetParent, children: [ - new Positioned( + Positioned( left: 123.0, top: 456.0, - child: new CompositedTransformTarget( + child: CompositedTransformTarget( link: link, - child: new Container(height: 20.0, width: 20.0, color: const Color.fromARGB(128, 255, 0, 0)), + child: Container(height: 20.0, width: 20.0, color: const Color.fromARGB(128, 255, 0, 0)), ), ), ], ), - new Positioned( + Positioned( left: 787.0, top: 343.0, - child: new Stack( + child: Stack( key: stackWithTransformFollower, children: [ // Container so we can see how the follower layer was // transformed relative to its initial location. - new Container(height: 15.0, width: 15.0, color: const Color.fromARGB(128, 0, 0, 255)), - new CompositedTransformFollower( + Container(height: 15.0, width: 15.0, color: const Color.fromARGB(128, 0, 0, 255)), + CompositedTransformFollower( link: link, - child: new Container(key: key, height: 10.0, width: 10.0, color: const Color.fromARGB(128, 0, 255, 0)), + child: Container(key: key, height: 10.0, width: 10.0, color: const Color.fromARGB(128, 0, 255, 0)), ), ], ), @@ -1689,51 +1689,51 @@ class TestWidgetInspectorService extends Object with WidgetInspectorService { }); testWidgets('Screenshot composited transforms - with rotations', (WidgetTester tester) async { - final LayerLink link = new LayerLink(); - final GlobalKey key1 = new GlobalKey(); - final GlobalKey key2 = new GlobalKey(); - final GlobalKey rotate1 = new GlobalKey(); - final GlobalKey rotate2 = new GlobalKey(); - final GlobalKey mainStackKey = new GlobalKey(); - final GlobalKey stackWithTransformTarget = new GlobalKey(); - final GlobalKey stackWithTransformFollower = new GlobalKey(); + final LayerLink link = LayerLink(); + final GlobalKey key1 = GlobalKey(); + final GlobalKey key2 = GlobalKey(); + final GlobalKey rotate1 = GlobalKey(); + final GlobalKey rotate2 = GlobalKey(); + final GlobalKey mainStackKey = GlobalKey(); + final GlobalKey stackWithTransformTarget = GlobalKey(); + final GlobalKey stackWithTransformFollower = GlobalKey(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Stack( + child: Stack( key: mainStackKey, children: [ - new Stack( + Stack( key: stackWithTransformTarget, children: [ - new Positioned( + Positioned( top: 123.0, left: 456.0, - child: new Transform.rotate( + child: Transform.rotate( key: rotate1, angle: 1.0, // radians - child: new CompositedTransformTarget( + child: CompositedTransformTarget( link: link, - child: new Container(key: key1, height: 20.0, width: 20.0, color: const Color.fromARGB(128, 255, 0, 0)), + child: Container(key: key1, height: 20.0, width: 20.0, color: const Color.fromARGB(128, 255, 0, 0)), ), ), ), ], ), - new Positioned( + Positioned( top: 487.0, left: 243.0, - child: new Stack( + child: Stack( key: stackWithTransformFollower, children: [ - new Container(height: 15.0, width: 15.0, color: const Color.fromARGB(128, 0, 0, 255)), - new Transform.rotate( + Container(height: 15.0, width: 15.0, color: const Color.fromARGB(128, 0, 0, 255)), + Transform.rotate( key: rotate2, angle: -0.3, // radians - child: new CompositedTransformFollower( + child: CompositedTransformFollower( link: link, - child: new Container(key: key2, height: 10.0, width: 10.0, color: const Color.fromARGB(128, 0, 255, 0)), + child: Container(key: key2, height: 10.0, width: 10.0, color: const Color.fromARGB(128, 0, 255, 0)), ), ), ], diff --git a/packages/flutter/test/widgets/wrap_test.dart b/packages/flutter/test/widgets/wrap_test.dart index ff47574bda..5e6acde602 100644 --- a/packages/flutter/test/widgets/wrap_test.dart +++ b/packages/flutter/test/widgets/wrap_test.dart @@ -18,7 +18,7 @@ void verify(WidgetTester tester, List answerKey) { void main() { testWidgets('Basic Wrap test (LTR)', (WidgetTester tester) async { await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, textDirection: TextDirection.ltr, children: const [ @@ -37,7 +37,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.center, textDirection: TextDirection.ltr, children: const [ @@ -56,7 +56,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.end, textDirection: TextDirection.ltr, children: const [ @@ -75,7 +75,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, textDirection: TextDirection.ltr, @@ -95,7 +95,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.center, textDirection: TextDirection.ltr, @@ -115,7 +115,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.end, textDirection: TextDirection.ltr, @@ -138,7 +138,7 @@ void main() { testWidgets('Basic Wrap test (RTL)', (WidgetTester tester) async { await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, textDirection: TextDirection.rtl, children: const [ @@ -157,7 +157,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.center, textDirection: TextDirection.rtl, children: const [ @@ -176,7 +176,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.end, textDirection: TextDirection.rtl, children: const [ @@ -195,7 +195,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, textDirection: TextDirection.ltr, @@ -216,7 +216,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.center, textDirection: TextDirection.ltr, @@ -237,7 +237,7 @@ void main() { ]); await tester.pumpWidget( - new Wrap( + Wrap( alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.end, textDirection: TextDirection.ltr, @@ -260,12 +260,12 @@ void main() { }); testWidgets('Empty wrap', (WidgetTester tester) async { - await tester.pumpWidget(new Center(child: new Wrap(alignment: WrapAlignment.center))); + await tester.pumpWidget(Center(child: Wrap(alignment: WrapAlignment.center))); expect(tester.renderObject(find.byType(Wrap)).size, equals(Size.zero)); }); testWidgets('Wrap alignment (LTR)', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.center, spacing: 5.0, textDirection: TextDirection.ltr, @@ -282,7 +282,7 @@ void main() { const Offset(405.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.spaceBetween, spacing: 5.0, textDirection: TextDirection.ltr, @@ -299,7 +299,7 @@ void main() { const Offset(500.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.spaceAround, spacing: 5.0, textDirection: TextDirection.ltr, @@ -316,7 +316,7 @@ void main() { const Offset(460.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.spaceEvenly, spacing: 5.0, textDirection: TextDirection.ltr, @@ -335,7 +335,7 @@ void main() { }); testWidgets('Wrap alignment (RTL)', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.center, spacing: 5.0, textDirection: TextDirection.rtl, @@ -352,7 +352,7 @@ void main() { const Offset(95.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.spaceBetween, spacing: 5.0, textDirection: TextDirection.rtl, @@ -369,7 +369,7 @@ void main() { const Offset(0.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.spaceAround, spacing: 5.0, textDirection: TextDirection.rtl, @@ -386,7 +386,7 @@ void main() { const Offset(30.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( alignment: WrapAlignment.spaceEvenly, spacing: 5.0, textDirection: TextDirection.rtl, @@ -405,7 +405,7 @@ void main() { }); testWidgets('Wrap runAlignment (DOWN)', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.center, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -426,7 +426,7 @@ void main() { const Offset(0.0, 310.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.spaceBetween, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -447,7 +447,7 @@ void main() { const Offset(0.0, 540.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.spaceAround, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -468,7 +468,7 @@ void main() { const Offset(0.0, 455.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.spaceEvenly, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -492,7 +492,7 @@ void main() { }); testWidgets('Wrap runAlignment (UP)', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.center, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -514,7 +514,7 @@ void main() { const Offset(0.0, 230.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.spaceBetween, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -536,7 +536,7 @@ void main() { const Offset(0.0, 0.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.spaceAround, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -558,7 +558,7 @@ void main() { const Offset(0.0, 75.0), ]); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( runAlignment: WrapAlignment.spaceEvenly, runSpacing: 5.0, textDirection: TextDirection.ltr, @@ -584,9 +584,9 @@ void main() { testWidgets('Shrink-wrapping Wrap test', (WidgetTester tester) async { await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Wrap( + child: Wrap( alignment: WrapAlignment.end, crossAxisAlignment: WrapCrossAlignment.end, textDirection: TextDirection.ltr, @@ -608,9 +608,9 @@ void main() { ]); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Wrap( + child: Wrap( alignment: WrapAlignment.end, crossAxisAlignment: WrapCrossAlignment.end, textDirection: TextDirection.ltr, @@ -634,9 +634,9 @@ void main() { testWidgets('Wrap spacing test', (WidgetTester tester) async { await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Wrap( + child: Wrap( runSpacing: 10.0, alignment: WrapAlignment.start, crossAxisAlignment: WrapCrossAlignment.start, @@ -661,9 +661,9 @@ void main() { testWidgets('Vertical Wrap test with spacing', (WidgetTester tester) async { await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Wrap( + child: Wrap( direction: Axis.vertical, spacing: 10.0, runSpacing: 15.0, @@ -692,9 +692,9 @@ void main() { ]); await tester.pumpWidget( - new Align( + Align( alignment: Alignment.topLeft, - child: new Wrap( + child: Wrap( direction: Axis.horizontal, spacing: 12.0, runSpacing: 8.0, @@ -722,7 +722,7 @@ void main() { }); testWidgets('Visual overflow generates a clip', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( textDirection: TextDirection.ltr, children: const [ SizedBox(width: 500.0, height: 500.0), @@ -731,7 +731,7 @@ void main() { expect(tester.renderObject(find.byType(Wrap)), isNot(paints..clipRect())); - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( textDirection: TextDirection.ltr, children: const [ SizedBox(width: 500.0, height: 500.0), @@ -745,7 +745,7 @@ void main() { testWidgets('Hit test children in wrap', (WidgetTester tester) async { final List log = []; - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( spacing: 10.0, runSpacing: 15.0, textDirection: TextDirection.ltr, @@ -754,10 +754,10 @@ void main() { const SizedBox(width: 200.0, height: 300.0), const SizedBox(width: 200.0, height: 300.0), const SizedBox(width: 200.0, height: 300.0), - new SizedBox( + SizedBox( width: 200.0, height: 300.0, - child: new GestureDetector( + child: GestureDetector( behavior: HitTestBehavior.opaque, onTap: () { log.add('hit'); }, ), @@ -779,14 +779,14 @@ void main() { }); testWidgets('RenderWrap toStringShallow control test', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap(alignment: WrapAlignment.center)); + await tester.pumpWidget(Wrap(alignment: WrapAlignment.center)); final RenderBox wrap = tester.renderObject(find.byType(Wrap)); expect(wrap.toStringShallow(), hasOneLineDescription); }); testWidgets('RenderWrap toString control test', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( direction: Axis.vertical, runSpacing: 7.0, textDirection: TextDirection.ltr, @@ -805,16 +805,16 @@ void main() { testWidgets('Wrap baseline control test', (WidgetTester tester) async { await tester.pumpWidget( - new Center( - child: new Baseline( + Center( + child: Baseline( baseline: 180.0, baselineType: TextBaseline.alphabetic, - child: new DefaultTextStyle( + child: DefaultTextStyle( style: const TextStyle( fontFamily: 'Ahem', fontSize: 100.0, ), - child: new Wrap( + child: Wrap( textDirection: TextDirection.ltr, children: const [ Text('X', textDirection: TextDirection.ltr), @@ -830,7 +830,7 @@ void main() { }); testWidgets('Spacing with slight overflow', (WidgetTester tester) async { - await tester.pumpWidget(new Wrap( + await tester.pumpWidget(Wrap( direction: Axis.horizontal, textDirection: TextDirection.ltr, spacing: 10.0, @@ -854,9 +854,9 @@ void main() { testWidgets('Object exactly matches container width', (WidgetTester tester) async { await tester.pumpWidget( - new Column( + Column( children: [ - new Wrap( + Wrap( direction: Axis.horizontal, textDirection: TextDirection.ltr, spacing: 10.0, @@ -873,9 +873,9 @@ void main() { verify(tester, [const Offset(0.0, 0.0)]); await tester.pumpWidget( - new Column( + Column( children: [ - new Wrap( + Wrap( direction: Axis.horizontal, textDirection: TextDirection.ltr, spacing: 10.0, diff --git a/packages/flutter_driver/lib/src/common/enum_util.dart b/packages/flutter_driver/lib/src/common/enum_util.dart index fcf25783ec..2023476b62 100644 --- a/packages/flutter_driver/lib/src/common/enum_util.dart +++ b/packages/flutter_driver/lib/src/common/enum_util.dart @@ -18,11 +18,11 @@ class EnumIndex { /// Creates an index of [enumValues]. EnumIndex(List enumValues) - : _nameToValue = new Map.fromIterable( + : _nameToValue = Map.fromIterable( enumValues, key: _getSimpleName ), - _valueToName = new Map.fromIterable( + _valueToName = Map.fromIterable( enumValues, value: _getSimpleName ); diff --git a/packages/flutter_driver/lib/src/common/error.dart b/packages/flutter_driver/lib/src/common/error.dart index 86d8eb2db3..2655c5be36 100644 --- a/packages/flutter_driver/lib/src/common/error.dart +++ b/packages/flutter_driver/lib/src/common/error.dart @@ -34,12 +34,12 @@ $originalStackTrace bool _noLogSubscribers = true; final StreamController _logger = - new StreamController.broadcast(sync: true, onListen: () { + StreamController.broadcast(sync: true, onListen: () { _noLogSubscribers = false; }); void _log(LogLevel level, String loggerName, Object message) { - final LogRecord record = new LogRecord._(level, loggerName, '$message'); + final LogRecord record = LogRecord._(level, loggerName, '$message'); // If nobody expressed interest in rerouting log messages somewhere specific, // print them to stderr. if (_noLogSubscribers) diff --git a/packages/flutter_driver/lib/src/common/find.dart b/packages/flutter_driver/lib/src/common/find.dart index 69f9f7754f..d6dd9a1a1a 100644 --- a/packages/flutter_driver/lib/src/common/find.dart +++ b/packages/flutter_driver/lib/src/common/find.dart @@ -10,7 +10,7 @@ import 'message.dart'; const List _supportedKeyValueTypes = [String, int]; DriverError _createInvalidKeyValueTypeError(String invalidType) { - return new DriverError('Unsupported key value type $invalidType. Flutter Driver only supports ${_supportedKeyValueTypes.join(", ")}'); + return DriverError('Unsupported key value type $invalidType. Flutter Driver only supports ${_supportedKeyValueTypes.join(", ")}'); } /// A Flutter Driver command aimed at an object to be located by [finder]. @@ -22,7 +22,7 @@ abstract class CommandWithTarget extends Command { /// Constructs this command given a [finder]. CommandWithTarget(this.finder, {Duration timeout}) : super(timeout: timeout) { if (finder == null) - throw new DriverError('$runtimeType target cannot be null'); + throw DriverError('$runtimeType target cannot be null'); } /// Deserializes this command from the value generated by [serialize]. @@ -66,7 +66,7 @@ class WaitFor extends CommandWithTarget { class WaitForResult extends Result { /// Deserializes the result from JSON. static WaitForResult fromJson(Map json) { - return new WaitForResult(); + return WaitForResult(); } @override @@ -93,7 +93,7 @@ class WaitForAbsent extends CommandWithTarget { class WaitForAbsentResult extends Result { /// Deserializes the result from JSON. static WaitForAbsentResult fromJson(Map json) { - return new WaitForAbsentResult(); + return WaitForAbsentResult(); } @override @@ -137,7 +137,7 @@ abstract class SerializableFinder { case 'ByTooltipMessage': return ByTooltipMessage.deserialize(json); case 'ByText': return ByText.deserialize(json); } - throw new DriverError('Unsupported search specification type $finderType'); + throw DriverError('Unsupported search specification type $finderType'); } } @@ -159,7 +159,7 @@ class ByTooltipMessage extends SerializableFinder { /// Deserializes the finder from JSON generated by [serialize]. static ByTooltipMessage deserialize(Map json) { - return new ByTooltipMessage(json['text']); + return ByTooltipMessage(json['text']); } } @@ -182,7 +182,7 @@ class ByText extends SerializableFinder { /// Deserializes the finder from JSON generated by [serialize]. static ByText deserialize(Map json) { - return new ByText(json['text']); + return ByText(json['text']); } } @@ -222,9 +222,9 @@ class ByValueKey extends SerializableFinder { final String keyValueType = json['keyValueType']; switch (keyValueType) { case 'int': - return new ByValueKey(int.parse(keyValueString)); + return ByValueKey(int.parse(keyValueString)); case 'String': - return new ByValueKey(keyValueString); + return ByValueKey(keyValueString); default: throw _createInvalidKeyValueTypeError(keyValueType); } @@ -249,7 +249,7 @@ class ByType extends SerializableFinder { /// Deserializes the finder from JSON generated by [serialize]. static ByType deserialize(Map json) { - return new ByType(json['type']); + return ByType(json['type']); } } @@ -289,7 +289,7 @@ class GetSemanticsIdResult extends Result { /// Deserializes this result from JSON. static GetSemanticsIdResult fromJson(Map json) { - return new GetSemanticsIdResult(json['id']); + return GetSemanticsIdResult(json['id']); } @override diff --git a/packages/flutter_driver/lib/src/common/frame_sync.dart b/packages/flutter_driver/lib/src/common/frame_sync.dart index 29e02c8c8e..51cf884ee2 100644 --- a/packages/flutter_driver/lib/src/common/frame_sync.dart +++ b/packages/flutter_driver/lib/src/common/frame_sync.dart @@ -30,7 +30,7 @@ class SetFrameSync extends Command { class SetFrameSyncResult extends Result { /// Deserializes this result from JSON. static SetFrameSyncResult fromJson(Map json) { - return new SetFrameSyncResult(); + return SetFrameSyncResult(); } @override diff --git a/packages/flutter_driver/lib/src/common/gesture.dart b/packages/flutter_driver/lib/src/common/gesture.dart index 9c954f0978..d1c535afbb 100644 --- a/packages/flutter_driver/lib/src/common/gesture.dart +++ b/packages/flutter_driver/lib/src/common/gesture.dart @@ -21,7 +21,7 @@ class Tap extends CommandWithTarget { class TapResult extends Result { /// Deserializes this result from JSON. static TapResult fromJson(Map json) { - return new TapResult(); + return TapResult(); } @override @@ -46,7 +46,7 @@ class Scroll extends CommandWithTarget { Scroll.deserialize(Map json) : this.dx = double.parse(json['dx']), this.dy = double.parse(json['dy']), - this.duration = new Duration(microseconds: int.parse(json['duration'])), + this.duration = Duration(microseconds: int.parse(json['duration'])), this.frequency = int.parse(json['frequency']), super.deserialize(json); @@ -78,7 +78,7 @@ class Scroll extends CommandWithTarget { class ScrollResult extends Result { /// Deserializes this result from JSON. static ScrollResult fromJson(Map json) { - return new ScrollResult(); + return ScrollResult(); } @override diff --git a/packages/flutter_driver/lib/src/common/health.dart b/packages/flutter_driver/lib/src/common/health.dart index df343e5d20..9441fa68ce 100644 --- a/packages/flutter_driver/lib/src/common/health.dart +++ b/packages/flutter_driver/lib/src/common/health.dart @@ -27,7 +27,7 @@ enum HealthStatus { } final EnumIndex _healthStatusIndex = - new EnumIndex(HealthStatus.values); + EnumIndex(HealthStatus.values); /// A description of the application state, as provided in response to a /// [FlutterDriver.checkHealth] test. @@ -43,7 +43,7 @@ class Health extends Result { /// Deserializes the result from JSON. static Health fromJson(Map json) { - return new Health(_healthStatusIndex.lookupBySimpleName(json['status'])); + return Health(_healthStatusIndex.lookupBySimpleName(json['status'])); } @override diff --git a/packages/flutter_driver/lib/src/common/message.dart b/packages/flutter_driver/lib/src/common/message.dart index 2b37ae4f3c..e834ebf6cd 100644 --- a/packages/flutter_driver/lib/src/common/message.dart +++ b/packages/flutter_driver/lib/src/common/message.dart @@ -14,7 +14,7 @@ abstract class Command { /// Deserializes this command from the value generated by [serialize]. Command.deserialize(Map json) - : timeout = new Duration(milliseconds: int.parse(json['timeout'])); + : timeout = Duration(milliseconds: int.parse(json['timeout'])); /// The maximum amount of time to wait for the command to complete. /// diff --git a/packages/flutter_driver/lib/src/common/render_tree.dart b/packages/flutter_driver/lib/src/common/render_tree.dart index 84cbd2f882..718253c891 100644 --- a/packages/flutter_driver/lib/src/common/render_tree.dart +++ b/packages/flutter_driver/lib/src/common/render_tree.dart @@ -27,7 +27,7 @@ class RenderTree extends Result { /// Deserializes the result from JSON. static RenderTree fromJson(Map json) { - return new RenderTree(json['tree']); + return RenderTree(json['tree']); } @override diff --git a/packages/flutter_driver/lib/src/common/request_data.dart b/packages/flutter_driver/lib/src/common/request_data.dart index 06fbf37c61..82026b7b4d 100644 --- a/packages/flutter_driver/lib/src/common/request_data.dart +++ b/packages/flutter_driver/lib/src/common/request_data.dart @@ -37,7 +37,7 @@ class RequestDataResult extends Result { /// Deserializes the result from JSON. static RequestDataResult fromJson(Map json) { - return new RequestDataResult(json['message']); + return RequestDataResult(json['message']); } @override diff --git a/packages/flutter_driver/lib/src/common/semantics.dart b/packages/flutter_driver/lib/src/common/semantics.dart index 517ce77863..f015f67270 100644 --- a/packages/flutter_driver/lib/src/common/semantics.dart +++ b/packages/flutter_driver/lib/src/common/semantics.dart @@ -37,7 +37,7 @@ class SetSemanticsResult extends Result { /// Deserializes this result from JSON. static SetSemanticsResult fromJson(Map json) { - return new SetSemanticsResult(json['changedState']); + return SetSemanticsResult(json['changedState']); } @override diff --git a/packages/flutter_driver/lib/src/common/text.dart b/packages/flutter_driver/lib/src/common/text.dart index 352dd77998..c0d70b829b 100644 --- a/packages/flutter_driver/lib/src/common/text.dart +++ b/packages/flutter_driver/lib/src/common/text.dart @@ -27,7 +27,7 @@ class GetTextResult extends Result { /// Deserializes the result from JSON. static GetTextResult fromJson(Map json) { - return new GetTextResult(json['text']); + return GetTextResult(json['text']); } @override @@ -65,7 +65,7 @@ class EnterTextResult extends Result { /// Deserializes the result from JSON. static EnterTextResult fromJson(Map json) { - return new EnterTextResult(); + return EnterTextResult(); } @override @@ -101,7 +101,7 @@ class SetTextEntryEmulationResult extends Result { /// Deserializes the result from JSON. static SetTextEntryEmulationResult fromJson(Map json) { - return new SetTextEntryEmulationResult(); + return SetTextEntryEmulationResult(); } @override diff --git a/packages/flutter_driver/lib/src/driver/common.dart b/packages/flutter_driver/lib/src/driver/common.dart index 1b6a4a7a46..19bbb471fd 100644 --- a/packages/flutter_driver/lib/src/driver/common.dart +++ b/packages/flutter_driver/lib/src/driver/common.dart @@ -16,7 +16,7 @@ FileSystem fs = const LocalFileSystem(); /// Overrides the file system so it can be tested without hitting the hard /// drive. void useMemoryFileSystemForTesting() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); } /// Restores the file system to the default local file system implementation. diff --git a/packages/flutter_driver/lib/src/driver/driver.dart b/packages/flutter_driver/lib/src/driver/driver.dart index 3626016acb..61d9364bb9 100644 --- a/packages/flutter_driver/lib/src/driver/driver.dart +++ b/packages/flutter_driver/lib/src/driver/driver.dart @@ -96,7 +96,7 @@ String _timelineStreamsToString(List streams) { return '[$contents]'; } -final Logger _log = new Logger('FlutterDriver'); +final Logger _log = Logger('FlutterDriver'); /// A convenient accessor to frequently used finders. /// @@ -165,7 +165,7 @@ class FlutterDriver { dartVmServiceUrl ??= Platform.environment['VM_SERVICE_URL']; if (dartVmServiceUrl == null) { - throw new DriverError( + throw DriverError( 'Could not determine URL to connect to application.\n' 'Either the VM_SERVICE_URL environment variable should be set, or an explicit\n' 'URL should be provided to the FlutterDriver.connect() method.'); @@ -186,7 +186,7 @@ class FlutterDriver { VMIsolate isolate = await isolateRef .loadRunnable() .timeout(isolateReadyTimeout, onTimeout: () { - throw new TimeoutException( + throw TimeoutException( 'Timeout while waiting for the isolate to become runnable'); }); @@ -203,11 +203,11 @@ class FlutterDriver { isolate.pauseEvent is! VMPauseExceptionEvent && isolate.pauseEvent is! VMPauseInterruptedEvent && isolate.pauseEvent is! VMResumeEvent) { - await new Future.delayed(_kShortTimeout ~/ 10); + await Future.delayed(_kShortTimeout ~/ 10); isolate = await isolateRef.loadRunnable(); } - final FlutterDriver driver = new FlutterDriver.connectedTo( + final FlutterDriver driver = FlutterDriver.connectedTo( client, connection.peer, isolate, printCommunication: printCommunication, logCommunicationToFile: logCommunicationToFile, @@ -273,7 +273,7 @@ class FlutterDriver { // register it. If that happens time out. await whenServiceExtensionReady.timeout(_kLongTimeout * 2); } on TimeoutException catch (_) { - throw new DriverError( + throw DriverError( 'Timed out waiting for Flutter Driver extension to become available. ' 'Ensure your test app (often: lib/main.dart) imports ' '"package:flutter_driver/driver_extension.dart" and ' @@ -320,7 +320,7 @@ class FlutterDriver { final Health health = await checkHealth(); if (health.status != HealthStatus.ok) { await client.close(); - throw new DriverError('Flutter application health check failed.'); + throw DriverError('Flutter application health check failed.'); } _log.info('Connected to Flutter application.'); @@ -350,20 +350,20 @@ class FlutterDriver { .timeout(command.timeout + _kRpcGraceTime); _logCommunication('<<< $response'); } on TimeoutException catch (error, stackTrace) { - throw new DriverError( + throw DriverError( 'Failed to fulfill ${command.runtimeType}: Flutter application not responding', error, stackTrace, ); } catch (error, stackTrace) { - throw new DriverError( + throw DriverError( 'Failed to fulfill ${command.runtimeType} due to remote error', error, stackTrace, ); } if (response['isError']) - throw new DriverError('Error in Flutter application: ${response['response']}'); + throw DriverError('Error in Flutter application: ${response['response']}'); return response['response']; } @@ -373,35 +373,35 @@ class FlutterDriver { if (_logCommunicationToFile) { final f.File file = fs.file(p.join(testOutputsDirectory, 'flutter_driver_commands_$_driverId.log')); file.createSync(recursive: true); // no-op if file exists - file.writeAsStringSync('${new DateTime.now()} $message\n', mode: f.FileMode.append, flush: true); + file.writeAsStringSync('${DateTime.now()} $message\n', mode: f.FileMode.append, flush: true); } } /// Checks the status of the Flutter Driver extension. Future checkHealth({Duration timeout}) async { - return Health.fromJson(await _sendCommand(new GetHealth(timeout: timeout))); + return Health.fromJson(await _sendCommand(GetHealth(timeout: timeout))); } /// Returns a dump of the render tree. Future getRenderTree({Duration timeout}) async { - return RenderTree.fromJson(await _sendCommand(new GetRenderTree(timeout: timeout))); + return RenderTree.fromJson(await _sendCommand(GetRenderTree(timeout: timeout))); } /// Taps at the center of the widget located by [finder]. Future tap(SerializableFinder finder, {Duration timeout}) async { - await _sendCommand(new Tap(finder, timeout: timeout)); + await _sendCommand(Tap(finder, timeout: timeout)); return null; } /// Waits until [finder] locates the target. Future waitFor(SerializableFinder finder, {Duration timeout}) async { - await _sendCommand(new WaitFor(finder, timeout: timeout)); + await _sendCommand(WaitFor(finder, timeout: timeout)); return null; } /// Waits until [finder] can no longer locate the target. Future waitForAbsent(SerializableFinder finder, {Duration timeout}) async { - await _sendCommand(new WaitForAbsent(finder, timeout: timeout)); + await _sendCommand(WaitForAbsent(finder, timeout: timeout)); return null; } @@ -410,7 +410,7 @@ class FlutterDriver { /// Use this method when you need to wait for the moment when the application /// becomes "stable", for example, prior to taking a [screenshot]. Future waitUntilNoTransientCallbacks({Duration timeout}) async { - await _sendCommand(new WaitUntilNoTransientCallbacks(timeout: timeout)); + await _sendCommand(WaitUntilNoTransientCallbacks(timeout: timeout)); return null; } @@ -428,7 +428,7 @@ class FlutterDriver { /// The move events are generated at a given [frequency] in Hz (or events per /// second). It defaults to 60Hz. Future scroll(SerializableFinder finder, double dx, double dy, Duration duration, { int frequency = 60, Duration timeout }) async { - return await _sendCommand(new Scroll(finder, dx, dy, duration, frequency, timeout: timeout)).then((Map _) => null); + return await _sendCommand(Scroll(finder, dx, dy, duration, frequency, timeout: timeout)).then((Map _) => null); } /// Scrolls the Scrollable ancestor of the widget located by [finder] @@ -439,7 +439,7 @@ class FlutterDriver { /// then this method may fail because [finder] doesn't actually exist. /// The [scrollUntilVisible] method can be used in this case. Future scrollIntoView(SerializableFinder finder, { double alignment = 0.0, Duration timeout }) async { - return await _sendCommand(new ScrollIntoView(finder, alignment: alignment, timeout: timeout)).then((Map _) => null); + return await _sendCommand(ScrollIntoView(finder, alignment: alignment, timeout: timeout)).then((Map _) => null); } /// Repeatedly [scroll] the widget located by [scrollable] by [dxScroll] and @@ -484,10 +484,10 @@ class FlutterDriver { // repeatedly until we either find the item or time out. bool isVisible = false; waitFor(item, timeout: timeout).then((Null value) { isVisible = true; }); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); while (!isVisible) { await scroll(scrollable, dxScroll, dyScroll, const Duration(milliseconds: 100)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); } return scrollIntoView(item, alignment: alignment); @@ -495,7 +495,7 @@ class FlutterDriver { /// Returns the text in the `Text` widget located by [finder]. Future getText(SerializableFinder finder, { Duration timeout }) async { - return GetTextResult.fromJson(await _sendCommand(new GetText(finder, timeout: timeout))).text; + return GetTextResult.fromJson(await _sendCommand(GetText(finder, timeout: timeout))).text; } /// Enters `text` into the currently focused text input, such as the @@ -531,7 +531,7 @@ class FlutterDriver { /// }); /// ``` Future enterText(String text, { Duration timeout }) async { - await _sendCommand(new EnterText(text, timeout: timeout)); + await _sendCommand(EnterText(text, timeout: timeout)); } /// Configures text entry emulation. @@ -549,7 +549,7 @@ class FlutterDriver { /// channel will be mocked out. Future setTextEntryEmulation({ @required bool enabled, Duration timeout }) async { assert(enabled != null); - await _sendCommand(new SetTextEntryEmulation(enabled, timeout: timeout)); + await _sendCommand(SetTextEntryEmulation(enabled, timeout: timeout)); } /// Sends a string and returns a string. @@ -559,7 +559,7 @@ class FlutterDriver { /// callback in [enableFlutterDriverExtension] that can successfully handle /// these requests. Future requestData(String message, { Duration timeout }) async { - return RequestDataResult.fromJson(await _sendCommand(new RequestData(message, timeout: timeout))).message; + return RequestDataResult.fromJson(await _sendCommand(RequestData(message, timeout: timeout))).message; } /// Turns semantics on or off in the Flutter app under test. @@ -567,7 +567,7 @@ class FlutterDriver { /// Returns true when the call actually changed the state from on to off or /// vice versa. Future setSemantics(bool enabled, { Duration timeout = _kShortTimeout }) async { - final SetSemanticsResult result = SetSemanticsResult.fromJson(await _sendCommand(new SetSemantics(enabled, timeout: timeout))); + final SetSemanticsResult result = SetSemanticsResult.fromJson(await _sendCommand(SetSemantics(enabled, timeout: timeout))); return result.changedState; } @@ -580,7 +580,7 @@ class FlutterDriver { /// Semantics must be enabled to use this method, either using a platform /// specific shell command or [setSemantics]. Future getSemanticsId(SerializableFinder finder, { Duration timeout = _kShortTimeout}) async { - final Map jsonResponse = await _sendCommand(new GetSemanticsId(finder, timeout: timeout)); + final Map jsonResponse = await _sendCommand(GetSemanticsId(finder, timeout: timeout)); final GetSemanticsIdResult result = GetSemanticsIdResult.fromJson(jsonResponse); return result.id; } @@ -622,7 +622,7 @@ class FlutterDriver { // The two-second gap should be long enough for the GPU thread to // finish rasterizing the frame, but not longer than necessary to keep // driver tests as fast a possible. - await new Future.delayed(const Duration(seconds: 2)); + await Future.delayed(const Duration(seconds: 2)); final Map result = await _peer.sendRequest('_flutter.screenshot').timeout(timeout); return base64.decode(result['screenshot']); @@ -664,7 +664,7 @@ class FlutterDriver { }).timeout(timeout); return null; } catch (error, stackTrace) { - throw new DriverError( + throw DriverError( 'Failed to start tracing due to remote error', error, stackTrace, @@ -678,9 +678,9 @@ class FlutterDriver { await _peer .sendRequest(_setVMTimelineFlagsMethodName, {'recordedStreams': '[]'}) .timeout(timeout); - return new Timeline.fromJson(await _peer.sendRequest(_getVMTimelineMethodName)); + return Timeline.fromJson(await _peer.sendRequest(_getVMTimelineMethodName)); } catch (error, stackTrace) { - throw new DriverError( + throw DriverError( 'Failed to stop tracing due to remote error', error, stackTrace, @@ -722,7 +722,7 @@ class FlutterDriver { .sendRequest(_clearVMTimelineMethodName, {}) .timeout(timeout); } catch (error, stackTrace) { - throw new DriverError( + throw DriverError( 'Failed to clear event timeline due to remote error', error, stackTrace, @@ -747,12 +747,12 @@ class FlutterDriver { /// ensure that no action is performed while the app is undergoing a /// transition to avoid flakiness. Future runUnsynchronized(Future action(), { Duration timeout }) async { - await _sendCommand(new SetFrameSync(false, timeout: timeout)); + await _sendCommand(SetFrameSync(false, timeout: timeout)); T result; try { result = await action(); } finally { - await _sendCommand(new SetFrameSync(true, timeout: timeout)); + await _sendCommand(SetFrameSync(true, timeout: timeout)); } return result; } @@ -802,7 +802,7 @@ void restoreVmServiceConnectFunction() { /// /// Times out after 30 seconds. Future _waitAndConnect(String url) async { - final Stopwatch timer = new Stopwatch()..start(); + final Stopwatch timer = Stopwatch()..start(); Future attemptConnection() async { Uri uri = Uri.parse(url); @@ -814,9 +814,9 @@ Future _waitAndConnect(String url) async { try { ws1 = await WebSocket.connect(uri.toString()).timeout(_kShortTimeout); ws2 = await WebSocket.connect(uri.toString()).timeout(_kShortTimeout); - return new VMServiceClientConnection( - new VMServiceClient(new IOWebSocketChannel(ws1).cast()), - new rpc.Peer(new IOWebSocketChannel(ws2).cast())..listen() + return VMServiceClientConnection( + VMServiceClient(IOWebSocketChannel(ws1).cast()), + rpc.Peer(IOWebSocketChannel(ws2).cast())..listen() ); } catch (e) { await ws1?.close(); @@ -824,7 +824,7 @@ Future _waitAndConnect(String url) async { if (timer.elapsed < _kLongTimeout * 2) { _log.info('Waiting for application to start'); - await new Future.delayed(_kPauseBetweenReconnectAttempts); + await Future.delayed(_kPauseBetweenReconnectAttempts); return attemptConnection(); } else { _log.critical( @@ -844,14 +844,14 @@ class CommonFinders { const CommonFinders._(); /// Finds [Text] and [EditableText] widgets containing string equal to [text]. - SerializableFinder text(String text) => new ByText(text); + SerializableFinder text(String text) => ByText(text); /// Finds widgets by [key]. Only [String] and [int] values can be used. - SerializableFinder byValueKey(dynamic key) => new ByValueKey(key); + SerializableFinder byValueKey(dynamic key) => ByValueKey(key); /// Finds widgets with a tooltip with the given [message]. - SerializableFinder byTooltip(String message) => new ByTooltipMessage(message); + SerializableFinder byTooltip(String message) => ByTooltipMessage(message); /// Finds widgets whose class name matches the given string. - SerializableFinder byType(String type) => new ByType(type); + SerializableFinder byType(String type) => ByType(type); } diff --git a/packages/flutter_driver/lib/src/driver/timeline.dart b/packages/flutter_driver/lib/src/driver/timeline.dart index 11a17df90b..34be834abc 100644 --- a/packages/flutter_driver/lib/src/driver/timeline.dart +++ b/packages/flutter_driver/lib/src/driver/timeline.dart @@ -11,7 +11,7 @@ class Timeline { /// /// See https://docs.google.com/document/d/1CvAClvFfyA5R-PhYUmn5OOQtYMH4h6I0nSsKchNAySU/preview factory Timeline.fromJson(Map json) { - return new Timeline._(json, _parseEvents(json)); + return Timeline._(json, _parseEvents(json)); } Timeline._(this.json, this.events); @@ -27,7 +27,7 @@ class Timeline { class TimelineEvent { /// Creates a timeline event given JSON-encoded event data. factory TimelineEvent(Map json) { - return new TimelineEvent._( + return TimelineEvent._( json, json['name'], json['cat'], @@ -35,10 +35,10 @@ class TimelineEvent { json['pid'], json['tid'], json['dur'] != null - ? new Duration(microseconds: json['dur']) + ? Duration(microseconds: json['dur']) : null, json['tdur'] != null - ? new Duration(microseconds: json['tdur']) + ? Duration(microseconds: json['tdur']) : null, json['ts'], json['tts'], @@ -129,6 +129,6 @@ List _parseEvents(Map json) { // TODO(vegorov): use instance method version of castFrom when it is available. return Iterable.castFrom>(jsonEvents) - .map((Map eventJson) => new TimelineEvent(eventJson)) + .map((Map eventJson) => TimelineEvent(eventJson)) .toList(); } diff --git a/packages/flutter_driver/lib/src/driver/timeline_summary.dart b/packages/flutter_driver/lib/src/driver/timeline_summary.dart index bd8e0da35f..9843e7879b 100644 --- a/packages/flutter_driver/lib/src/driver/timeline_summary.dart +++ b/packages/flutter_driver/lib/src/driver/timeline_summary.dart @@ -150,7 +150,7 @@ class TimelineSummary { final TimelineEvent beginEvent = events.current; if (events.moveNext()) { final TimelineEvent endEvent = events.current; - result.add(new TimedEvent( + result.add(TimedEvent( beginEvent.timestampMicros, endEvent.timestampMicros, )); @@ -162,14 +162,14 @@ class TimelineSummary { double _averageInMillis(Iterable durations) { if (durations.isEmpty) - throw new ArgumentError('durations is empty!'); + throw ArgumentError('durations is empty!'); final double total = durations.fold(0.0, (double t, Duration duration) => t + duration.inMicroseconds.toDouble() / 1000.0); return total / durations.length; } double _percentileInMillis(Iterable durations, double percentile) { if (durations.isEmpty) - throw new ArgumentError('durations is empty!'); + throw ArgumentError('durations is empty!'); assert(percentile >= 0.0 && percentile <= 100.0); final List doubles = durations.map((Duration duration) => duration.inMicroseconds.toDouble() / 1000.0).toList(); doubles.sort(); @@ -179,7 +179,7 @@ class TimelineSummary { double _maxInMillis(Iterable durations) { if (durations.isEmpty) - throw new ArgumentError('durations is empty!'); + throw ArgumentError('durations is empty!'); return durations .map((Duration duration) => duration.inMicroseconds.toDouble() / 1000.0) .reduce(math.max); @@ -198,7 +198,7 @@ class TimelineSummary { class TimedEvent { /// Creates a timed event given begin and end timestamps in microseconds. TimedEvent(int beginTimeMicros, int endTimeMicros) - : this.duration = new Duration(microseconds: endTimeMicros - beginTimeMicros); + : this.duration = Duration(microseconds: endTimeMicros - beginTimeMicros); /// The duration of the event. final Duration duration; diff --git a/packages/flutter_driver/lib/src/extension/extension.dart b/packages/flutter_driver/lib/src/extension/extension.dart index 9bf524431a..2808d5c4ac 100644 --- a/packages/flutter_driver/lib/src/extension/extension.dart +++ b/packages/flutter_driver/lib/src/extension/extension.dart @@ -45,7 +45,7 @@ class _DriverBinding extends BindingBase with ServicesBinding, SchedulerBinding, @override void initServiceExtensions() { super.initServiceExtensions(); - final FlutterDriverExtension extension = new FlutterDriverExtension(_handler, _silenceErrors); + final FlutterDriverExtension extension = FlutterDriverExtension(_handler, _silenceErrors); registerServiceExtension( name: _extensionMethodName, callback: extension.call, @@ -70,7 +70,7 @@ class _DriverBinding extends BindingBase with ServicesBinding, SchedulerBinding, /// with an `isError` boolean. void enableFlutterDriverExtension({ DataHandler handler, bool silenceErrors = false }) { assert(WidgetsBinding.instance == null); - new _DriverBinding(handler, silenceErrors); + _DriverBinding(handler, silenceErrors); assert(WidgetsBinding.instance is _DriverBinding); } @@ -91,7 +91,7 @@ typedef Finder FinderConstructor(SerializableFinder finder); /// calling [enableFlutterDriverExtension]. @visibleForTesting class FlutterDriverExtension { - final TestTextInput _testTextInput = new TestTextInput(); + final TestTextInput _testTextInput = TestTextInput(); /// Creates an object to manage a Flutter Driver connection. FlutterDriverExtension(this._requestDataHandler, this._silenceErrors) { @@ -116,21 +116,21 @@ class FlutterDriverExtension { }); _commandDeserializers.addAll({ - 'get_health': (Map params) => new GetHealth.deserialize(params), - 'get_render_tree': (Map params) => new GetRenderTree.deserialize(params), - 'enter_text': (Map params) => new EnterText.deserialize(params), - 'get_text': (Map params) => new GetText.deserialize(params), - 'request_data': (Map params) => new RequestData.deserialize(params), - 'scroll': (Map params) => new Scroll.deserialize(params), - 'scrollIntoView': (Map params) => new ScrollIntoView.deserialize(params), - 'set_frame_sync': (Map params) => new SetFrameSync.deserialize(params), - 'set_semantics': (Map params) => new SetSemantics.deserialize(params), - 'set_text_entry_emulation': (Map params) => new SetTextEntryEmulation.deserialize(params), - 'tap': (Map params) => new Tap.deserialize(params), - 'waitFor': (Map params) => new WaitFor.deserialize(params), - 'waitForAbsent': (Map params) => new WaitForAbsent.deserialize(params), - 'waitUntilNoTransientCallbacks': (Map params) => new WaitUntilNoTransientCallbacks.deserialize(params), - 'get_semantics_id': (Map params) => new GetSemanticsId.deserialize(params), + 'get_health': (Map params) => GetHealth.deserialize(params), + 'get_render_tree': (Map params) => GetRenderTree.deserialize(params), + 'enter_text': (Map params) => EnterText.deserialize(params), + 'get_text': (Map params) => GetText.deserialize(params), + 'request_data': (Map params) => RequestData.deserialize(params), + 'scroll': (Map params) => Scroll.deserialize(params), + 'scrollIntoView': (Map params) => ScrollIntoView.deserialize(params), + 'set_frame_sync': (Map params) => SetFrameSync.deserialize(params), + 'set_semantics': (Map params) => SetSemantics.deserialize(params), + 'set_text_entry_emulation': (Map params) => SetTextEntryEmulation.deserialize(params), + 'tap': (Map params) => Tap.deserialize(params), + 'waitFor': (Map params) => WaitFor.deserialize(params), + 'waitForAbsent': (Map params) => WaitForAbsent.deserialize(params), + 'waitUntilNoTransientCallbacks': (Map params) => WaitUntilNoTransientCallbacks.deserialize(params), + 'get_semantics_id': (Map params) => GetSemanticsId.deserialize(params), }); _finders.addAll({ @@ -144,9 +144,9 @@ class FlutterDriverExtension { final DataHandler _requestDataHandler; final bool _silenceErrors; - static final Logger _log = new Logger('FlutterDriverExtension'); + static final Logger _log = Logger('FlutterDriverExtension'); - final WidgetController _prober = new LiveWidgetController(WidgetsBinding.instance); + final WidgetController _prober = LiveWidgetController(WidgetsBinding.instance); final Map _commandHandlers = {}; final Map _commandDeserializers = {}; final Map _finders = {}; @@ -196,15 +196,15 @@ class FlutterDriverExtension { }; } - Future _getHealth(Command command) async => new Health(HealthStatus.ok); + Future _getHealth(Command command) async => Health(HealthStatus.ok); Future _getRenderTree(Command command) async { - return new RenderTree(RendererBinding.instance?.renderView?.toStringDeep()); + return RenderTree(RendererBinding.instance?.renderView?.toStringDeep()); } // Waits until at the end of a frame the provided [condition] is [true]. Future _waitUntilFrame(bool condition(), [Completer completer]) { - completer ??= new Completer(); + completer ??= Completer(); if (!condition()) { SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) { _waitUntilFrame(condition, completer); @@ -219,7 +219,7 @@ class FlutterDriverExtension { Future _waitForElement(Finder finder) async { // TODO(mravn): This method depends on async execution. A refactoring // for sync-async semantics is tracked in https://github.com/flutter/flutter/issues/16801. - await new Future.value(null); + await Future.value(null); if (_frameSync) await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0); @@ -260,9 +260,9 @@ class FlutterDriverExtension { Finder _createByValueKeyFinder(ByValueKey arguments) { switch (arguments.keyValueType) { case 'int': - return find.byKey(new ValueKey(arguments.keyValue)); + return find.byKey(ValueKey(arguments.keyValue)); case 'String': - return find.byKey(new ValueKey(arguments.keyValue)); + return find.byKey(ValueKey(arguments.keyValue)); default: throw 'Unsupported ByValueKey type: ${arguments.keyValueType}'; } @@ -289,19 +289,19 @@ class FlutterDriverExtension { _createFinder(tapCommand.finder).hitTestable() ); await _prober.tap(computedFinder); - return new TapResult(); + return TapResult(); } Future _waitFor(Command command) async { final WaitFor waitForCommand = command; await _waitForElement(_createFinder(waitForCommand.finder)); - return new WaitForResult(); + return WaitForResult(); } Future _waitForAbsent(Command command) async { final WaitForAbsent waitForAbsentCommand = command; await _waitForAbsentElement(_createFinder(waitForAbsentCommand.finder)); - return new WaitForAbsentResult(); + return WaitForAbsentResult(); } Future _waitUntilNoTransientCallbacks(Command command) async { @@ -320,39 +320,39 @@ class FlutterDriverExtension { renderObject = renderObject.parent; } if (node == null) - throw new StateError('No semantics data found'); - return new GetSemanticsIdResult(node.id); + throw StateError('No semantics data found'); + return GetSemanticsIdResult(node.id); } Future _scroll(Command command) async { final Scroll scrollCommand = command; final Finder target = await _waitForElement(_createFinder(scrollCommand.finder)); final int totalMoves = scrollCommand.duration.inMicroseconds * scrollCommand.frequency ~/ Duration.microsecondsPerSecond; - final Offset delta = new Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble(); + final Offset delta = Offset(scrollCommand.dx, scrollCommand.dy) / totalMoves.toDouble(); final Duration pause = scrollCommand.duration ~/ totalMoves; final Offset startLocation = _prober.getCenter(target); Offset currentLocation = startLocation; - final TestPointer pointer = new TestPointer(1); - final HitTestResult hitTest = new HitTestResult(); + final TestPointer pointer = TestPointer(1); + final HitTestResult hitTest = HitTestResult(); _prober.binding.hitTest(hitTest, startLocation); _prober.binding.dispatchEvent(pointer.down(startLocation), hitTest); - await new Future.value(); // so that down and move don't happen in the same microtask + await Future.value(); // so that down and move don't happen in the same microtask for (int moves = 0; moves < totalMoves; moves += 1) { currentLocation = currentLocation + delta; _prober.binding.dispatchEvent(pointer.move(currentLocation), hitTest); - await new Future.delayed(pause); + await Future.delayed(pause); } _prober.binding.dispatchEvent(pointer.up(), hitTest); - return new ScrollResult(); + return ScrollResult(); } Future _scrollIntoView(Command command) async { final ScrollIntoView scrollIntoViewCommand = command; final Finder target = await _waitForElement(_createFinder(scrollIntoViewCommand.finder)); await Scrollable.ensureVisible(target.evaluate().single, duration: const Duration(milliseconds: 100), alignment: scrollIntoViewCommand.alignment ?? 0.0); - return new ScrollResult(); + return ScrollResult(); } Future _getText(Command command) async { @@ -360,7 +360,7 @@ class FlutterDriverExtension { final Finder target = await _waitForElement(_createFinder(getTextCommand.finder)); // TODO(yjbanov): support more ways to read text final Text text = target.evaluate().single.widget; - return new GetTextResult(text.data); + return GetTextResult(text.data); } Future _setTextEntryEmulation(Command command) async { @@ -370,7 +370,7 @@ class FlutterDriverExtension { } else { _testTextInput.unregister(); } - return new SetTextEntryEmulationResult(); + return SetTextEntryEmulationResult(); } Future _enterText(Command command) async { @@ -380,18 +380,18 @@ class FlutterDriverExtension { } final EnterText enterTextCommand = command; _testTextInput.enterText(enterTextCommand.text); - return new EnterTextResult(); + return EnterTextResult(); } Future _requestData(Command command) async { final RequestData requestDataCommand = command; - return new RequestDataResult(_requestDataHandler == null ? 'No requestData Extension registered' : await _requestDataHandler(requestDataCommand.message)); + return RequestDataResult(_requestDataHandler == null ? 'No requestData Extension registered' : await _requestDataHandler(requestDataCommand.message)); } Future _setFrameSync(Command command) async { final SetFrameSync setFrameSyncCommand = command; _frameSync = setFrameSyncCommand.enabled; - return new SetFrameSyncResult(); + return SetFrameSyncResult(); } SemanticsHandle _semantics; @@ -404,7 +404,7 @@ class FlutterDriverExtension { _semantics = RendererBinding.instance.pipelineOwner.ensureSemantics(); if (!semanticsWasEnabled) { // wait for the first frame where semantics is enabled. - final Completer completer = new Completer(); + final Completer completer = Completer(); SchedulerBinding.instance.addPostFrameCallback((Duration d) { completer.complete(); }); @@ -414,6 +414,6 @@ class FlutterDriverExtension { _semantics.dispose(); _semantics = null; } - return new SetSemanticsResult(semanticsWasEnabled != _semanticsIsEnabled); + return SetSemanticsResult(semanticsWasEnabled != _semanticsIsEnabled); } } diff --git a/packages/flutter_driver/test/common.dart b/packages/flutter_driver/test/common.dart index dbc658f949..efc4cbdc70 100644 --- a/packages/flutter_driver/test/common.dart +++ b/packages/flutter_driver/test/common.dart @@ -13,7 +13,7 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; // TODO(ianh): Clean this up once https://github.com/dart-lang/matcher/issues/98 is fixed /// A matcher that compares the type of the actual value to the type argument T. -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that diff --git a/packages/flutter_driver/test/flutter_driver_test.dart b/packages/flutter_driver/test/flutter_driver_test.dart index ab2b5ecbe4..d8d8adbd99 100644 --- a/packages/flutter_driver/test/flutter_driver_test.dart +++ b/packages/flutter_driver/test/flutter_driver_test.dart @@ -34,18 +34,18 @@ void main() { setUp(() { log = []; logSub = flutterDriverLog.listen(log.add); - mockClient = new MockVMServiceClient(); - mockVM = new MockVM(); - mockIsolate = new MockIsolate(); - mockPeer = new MockPeer(); - when(mockClient.getVM()).thenAnswer((_) => new Future.value(mockVM)); + mockClient = MockVMServiceClient(); + mockVM = MockVM(); + mockIsolate = MockIsolate(); + mockPeer = MockPeer(); + when(mockClient.getVM()).thenAnswer((_) => Future.value(mockVM)); when(mockVM.isolates).thenReturn([mockIsolate]); - when(mockIsolate.loadRunnable()).thenAnswer((_) => new Future.value(mockIsolate)); + when(mockIsolate.loadRunnable()).thenAnswer((_) => Future.value(mockIsolate)); when(mockIsolate.invokeExtension(any, any)).thenAnswer( (Invocation invocation) => makeMockResponse({'status': 'ok'})); vmServiceConnectFunction = (String url) { - return new Future.value( - new VMServiceClientConnection(mockClient, mockPeer) + return Future.value( + VMServiceClientConnection(mockClient, mockPeer) ); }; }); @@ -61,14 +61,14 @@ void main() { connectionLog.add('streamListen'); return null; }); - when(mockIsolate.pauseEvent).thenReturn(new MockVMPauseStartEvent()); + when(mockIsolate.pauseEvent).thenReturn(MockVMPauseStartEvent()); when(mockIsolate.resume()).thenAnswer((Invocation invocation) { connectionLog.add('resume'); - return new Future.value(); + return Future.value(); }); when(mockIsolate.onExtensionAdded).thenAnswer((Invocation invocation) { connectionLog.add('onExtensionAdded'); - return new Stream.fromIterable(['ext.flutter.driver']); + return Stream.fromIterable(['ext.flutter.driver']); }); final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: ''); @@ -78,8 +78,8 @@ void main() { }); test('connects to isolate paused mid-flight', () async { - when(mockIsolate.pauseEvent).thenReturn(new MockVMPauseBreakpointEvent()); - when(mockIsolate.resume()).thenAnswer((Invocation invocation) => new Future.value()); + when(mockIsolate.pauseEvent).thenReturn(MockVMPauseBreakpointEvent()); + when(mockIsolate.resume()).thenAnswer((Invocation invocation) => Future.value()); final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: ''); expect(driver, isNotNull); @@ -91,11 +91,11 @@ void main() { // we do. There's no need to fail as we should be able to drive the app // just fine. test('connects despite losing the race to resume isolate', () async { - when(mockIsolate.pauseEvent).thenReturn(new MockVMPauseBreakpointEvent()); + when(mockIsolate.pauseEvent).thenReturn(MockVMPauseBreakpointEvent()); when(mockIsolate.resume()).thenAnswer((Invocation invocation) { // This needs to be wrapped in a closure to not be considered uncaught // by package:test - return new Future.error(new rpc.RpcException(101, '')); + return Future.error(rpc.RpcException(101, '')); }); final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: ''); @@ -104,7 +104,7 @@ void main() { }); test('connects to unpaused isolate', () async { - when(mockIsolate.pauseEvent).thenReturn(new MockVMResumeEvent()); + when(mockIsolate.pauseEvent).thenReturn(MockVMResumeEvent()); final FlutterDriver driver = await FlutterDriver.connect(dartVmServiceUrl: ''); expect(driver, isNotNull); expectLogContains('Isolate is not paused. Assuming application is ready.'); @@ -118,10 +118,10 @@ void main() { FlutterDriver driver; setUp(() { - mockClient = new MockVMServiceClient(); - mockPeer = new MockPeer(); - mockIsolate = new MockIsolate(); - driver = new FlutterDriver.connectedTo(mockClient, mockPeer, mockIsolate); + mockClient = MockVMServiceClient(); + mockPeer = MockPeer(); + mockIsolate = MockIsolate(); + driver = FlutterDriver.connectedTo(mockClient, mockPeer, mockIsolate); }); test('checks the health of the driver extension', () async { @@ -132,7 +132,7 @@ void main() { }); test('closes connection', () async { - when(mockClient.close()).thenAnswer((Invocation invocation) => new Future.value()); + when(mockClient.close()).thenAnswer((Invocation invocation) => Future.value()); await driver.close(); }); @@ -359,7 +359,7 @@ void main() { test('local timeout', () async { when(mockIsolate.invokeExtension(any, any)).thenAnswer((Invocation i) { // completer never competed to trigger timeout - return new Completer>().future; + return Completer>().future; }); try { await driver.waitFor(find.byTooltip('foo'), timeout: const Duration(milliseconds: 100)); @@ -390,7 +390,7 @@ void main() { Future> makeMockResponse( Map response, {bool isError = false}) { - return new Future>.value({ + return Future>.value({ 'isError': isError, 'response': response }); diff --git a/packages/flutter_driver/test/src/extension_test.dart b/packages/flutter_driver/test/src/extension_test.dart index 6fe42339cd..10871b16e6 100644 --- a/packages/flutter_driver/test/src/extension_test.dart +++ b/packages/flutter_driver/test/src/extension_test.dart @@ -19,11 +19,11 @@ void main() { setUp(() { result = null; - extension = new FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false); + extension = FlutterDriverExtension((String message) async { log.add(message); return (messageId += 1).toString(); }, false); }); testWidgets('returns immediately when transient callback queue is empty', (WidgetTester tester) async { - extension.call(new WaitUntilNoTransientCallbacks().serialize()) + extension.call(WaitUntilNoTransientCallbacks().serialize()) .then(expectAsync1((Map r) { result = r; })); @@ -43,7 +43,7 @@ void main() { // Intentionally blank. We only care about existence of a callback. }); - extension.call(new WaitUntilNoTransientCallbacks().serialize()) + extension.call(WaitUntilNoTransientCallbacks().serialize()) .then(expectAsync1((Map r) { result = r; })); @@ -65,7 +65,7 @@ void main() { testWidgets('handler', (WidgetTester tester) async { expect(log, isEmpty); - final dynamic result = RequestDataResult.fromJson((await extension.call(new RequestData('hello').serialize()))['response']); + final dynamic result = RequestDataResult.fromJson((await extension.call(RequestData('hello').serialize()))['response']); expect(log, ['hello']); expect(result.message, '1'); }); @@ -74,7 +74,7 @@ void main() { group('getSemanticsId', () { FlutterDriverExtension extension; setUp(() { - extension = new FlutterDriverExtension((String arg) async => '', true); + extension = FlutterDriverExtension((String arg) async => '', true); }); testWidgets('works when semantics are enabled', (WidgetTester tester) async { @@ -82,7 +82,7 @@ void main() { await tester.pumpWidget( const Text('hello', textDirection: TextDirection.ltr)); - final Map arguments = new GetSemanticsId(new ByText('hello')).serialize(); + final Map arguments = GetSemanticsId(ByText('hello')).serialize(); final GetSemanticsIdResult result = GetSemanticsIdResult.fromJson((await extension.call(arguments))['response']); expect(result.id, 1); @@ -93,7 +93,7 @@ void main() { await tester.pumpWidget( const Text('hello', textDirection: TextDirection.ltr)); - final Map arguments = new GetSemanticsId(new ByText('hello')).serialize(); + final Map arguments = GetSemanticsId(ByText('hello')).serialize(); final Map response = await extension.call(arguments); expect(response['isError'], true); @@ -103,16 +103,16 @@ void main() { testWidgets('throws state error multiple matches are found', (WidgetTester tester) async { final SemanticsHandle semantics = RendererBinding.instance.pipelineOwner.ensureSemantics(); await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new ListView(children: const [ + child: ListView(children: const [ SizedBox(width: 100.0, height: 100.0, child: Text('hello')), SizedBox(width: 100.0, height: 100.0, child: Text('hello')), ]), ), ); - final Map arguments = new GetSemanticsId(new ByText('hello')).serialize(); + final Map arguments = GetSemanticsId(ByText('hello')).serialize(); final Map response = await extension.call(arguments); expect(response['isError'], true); diff --git a/packages/flutter_driver/test/src/timeline_summary_test.dart b/packages/flutter_driver/test/src/timeline_summary_test.dart index 96b38b184a..d235e84071 100644 --- a/packages/flutter_driver/test/src/timeline_summary_test.dart +++ b/packages/flutter_driver/test/src/timeline_summary_test.dart @@ -15,7 +15,7 @@ void main() { group('TimelineSummary', () { TimelineSummary summarize(List> testEvents) { - return new TimelineSummary.summarize(new Timeline.fromJson({ + return TimelineSummary.summarize(Timeline.fromJson({ 'traceEvents': testEvents, })); } diff --git a/packages/flutter_driver/test/src/timeline_test.dart b/packages/flutter_driver/test/src/timeline_test.dart index 0d57f88630..5f031cfc91 100644 --- a/packages/flutter_driver/test/src/timeline_test.dart +++ b/packages/flutter_driver/test/src/timeline_test.dart @@ -9,7 +9,7 @@ import '../common.dart'; void main() { group('Timeline', () { test('parses JSON', () { - final Timeline timeline = new Timeline.fromJson({ + final Timeline timeline = Timeline.fromJson({ 'traceEvents': >[ { 'name': 'test event', diff --git a/packages/flutter_goldens/lib/flutter_goldens.dart b/packages/flutter_goldens/lib/flutter_goldens.dart index f102d4491f..a9828907eb 100644 --- a/packages/flutter_goldens/lib/flutter_goldens.dart +++ b/packages/flutter_goldens/lib/flutter_goldens.dart @@ -65,21 +65,21 @@ class FlutterGoldenFileComparator implements GoldenFileComparator { defaultComparator ??= goldenFileComparator; // Prepare the goldens repo. - goldens ??= new GoldensClient(); + goldens ??= GoldensClient(); await goldens.prepare(); // Calculate the appropriate basedir for the current test context. final FileSystem fs = goldens.fs; final Directory testDirectory = fs.directory(defaultComparator.basedir); final String testDirectoryRelativePath = fs.path.relative(testDirectory.path, from: goldens.flutterRoot.path); - return new FlutterGoldenFileComparator(goldens.repositoryRoot.childDirectory(testDirectoryRelativePath).uri); + return FlutterGoldenFileComparator(goldens.repositoryRoot.childDirectory(testDirectoryRelativePath).uri); } @override Future compare(Uint8List imageBytes, Uri golden) async { final File goldenFile = _getGoldenFile(golden); if (!goldenFile.existsSync()) { - throw new TestFailure('Could not be compared against non-existent file: "$golden"'); + throw TestFailure('Could not be compared against non-existent file: "$golden"'); } final List goldenBytes = await goldenFile.readAsBytes(); // TODO(tvolkert): Improve the intelligence of this comparison. diff --git a/packages/flutter_goldens/test/flutter_goldens_test.dart b/packages/flutter_goldens/test/flutter_goldens_test.dart index 0c26bf4446..19645edc8f 100644 --- a/packages/flutter_goldens/test/flutter_goldens_test.dart +++ b/packages/flutter_goldens/test/flutter_goldens_test.dart @@ -24,9 +24,9 @@ void main() { MockProcessManager process; setUp(() { - fs = new MemoryFileSystem(); - platform = new FakePlatform(environment: {'FLUTTER_ROOT': _kFlutterRoot}); - process = new MockProcessManager(); + fs = MemoryFileSystem(); + platform = FakePlatform(environment: {'FLUTTER_ROOT': _kFlutterRoot}); + process = MockProcessManager(); fs.directory(_kFlutterRoot).createSync(recursive: true); fs.directory(_kRepositoryRoot).createSync(recursive: true); fs.file(_kVersionFile).createSync(recursive: true); @@ -37,7 +37,7 @@ void main() { GoldensClient goldens; setUp(() { - goldens = new GoldensClient( + goldens = GoldensClient( fs: fs, platform: platform, process: process, @@ -47,7 +47,7 @@ void main() { group('prepare', () { test('performs minimal work if versions match', () async { when(process.run(any, workingDirectory: anyNamed('workingDirectory'))) - .thenAnswer((_) => new Future.value(io.ProcessResult(123, 0, _kGoldensVersion, ''))); + .thenAnswer((_) => Future.value(io.ProcessResult(123, 0, _kGoldensVersion, ''))); await goldens.prepare(); // Verify that we only spawned `git rev-parse HEAD` @@ -65,17 +65,17 @@ void main() { FlutterGoldenFileComparator comparator; setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); final Directory flutterRoot = fs.directory('/path/to/flutter')..createSync(recursive: true); final Directory goldensRoot = flutterRoot.childDirectory('bin/cache/goldens')..createSync(recursive: true); final Directory testDirectory = goldensRoot.childDirectory('test/foo/bar')..createSync(recursive: true); - comparator = new FlutterGoldenFileComparator(testDirectory.uri, fs: fs); + comparator = FlutterGoldenFileComparator(testDirectory.uri, fs: fs); }); group('fromDefaultComparator', () { test('calculates the basedir correctly', () async { - final MockGoldensClient goldens = new MockGoldensClient(); - final MockLocalFileComparator defaultComparator = new MockLocalFileComparator(); + final MockGoldensClient goldens = MockGoldensClient(); + final MockLocalFileComparator defaultComparator = MockLocalFileComparator(); final Directory flutterRoot = fs.directory('/foo')..createSync(recursive: true); final Directory goldensRoot = flutterRoot.childDirectory('bar')..createSync(recursive: true); when(goldens.fs).thenReturn(fs); @@ -91,7 +91,7 @@ void main() { group('compare', () { test('throws if golden file is not found', () async { try { - await comparator.compare(new Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); + await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); fail('TestFailure expected but not thrown'); } on TestFailure catch (error) { expect(error.message, contains('Could not be compared against non-existent file')); @@ -102,7 +102,7 @@ void main() { final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') ..createSync(recursive: true); goldenFile.writeAsBytesSync([4, 5, 6], flush: true); - final bool result = await comparator.compare(new Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); + final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); expect(result, isFalse); }); @@ -110,7 +110,7 @@ void main() { final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') ..createSync(recursive: true); goldenFile.writeAsBytesSync([1, 2, 3], flush: true); - final bool result = await comparator.compare(new Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); + final bool result = await comparator.compare(Uint8List.fromList([1, 2, 3]), Uri.parse('test.png')); expect(result, isTrue); }); }); @@ -119,7 +119,7 @@ void main() { test('creates golden file if it does not already exist', () async { final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png'); expect(goldenFile.existsSync(), isFalse); - await comparator.update(Uri.parse('test.png'), new Uint8List.fromList([1, 2, 3])); + await comparator.update(Uri.parse('test.png'), Uint8List.fromList([1, 2, 3])); expect(goldenFile.existsSync(), isTrue); expect(goldenFile.readAsBytesSync(), [1, 2, 3]); }); @@ -128,7 +128,7 @@ void main() { final File goldenFile = fs.file('/path/to/flutter/bin/cache/goldens/test/foo/bar/test.png') ..createSync(recursive: true); goldenFile.writeAsBytesSync([4, 5, 6], flush: true); - await comparator.update(Uri.parse('test.png'), new Uint8List.fromList([1, 2, 3])); + await comparator.update(Uri.parse('test.png'), Uint8List.fromList([1, 2, 3])); expect(goldenFile.readAsBytesSync(), [1, 2, 3]); }); }); diff --git a/packages/flutter_goldens_client/lib/client.dart b/packages/flutter_goldens_client/lib/client.dart index 5824243b9d..961b383097 100644 --- a/packages/flutter_goldens_client/lib/client.dart +++ b/packages/flutter_goldens_client/lib/client.dart @@ -139,7 +139,7 @@ class GoldensClient { workingDirectory: workingDirectory?.path, ); if (result.exitCode != 0) { - throw new NonZeroExitCode(result.exitCode, result.stderr); + throw NonZeroExitCode(result.exitCode, result.stderr); } } } diff --git a/packages/flutter_localizations/lib/src/l10n/localizations.dart b/packages/flutter_localizations/lib/src/l10n/localizations.dart index 2d9e76fd08..f996a64dcb 100644 --- a/packages/flutter_localizations/lib/src/l10n/localizations.dart +++ b/packages/flutter_localizations/lib/src/l10n/localizations.dart @@ -10766,7 +10766,7 @@ class MaterialLocalizationZhTw extends MaterialLocalizationZh { /// See also: /// /// * [getTranslation], whose documentation describes these values. -final Set kSupportedLanguages = new HashSet.from(const [ +final Set kSupportedLanguages = HashSet.from(const [ 'ar', // Arabic 'bg', // Bulgarian 'bs', // Bosnian @@ -10884,181 +10884,181 @@ GlobalMaterialLocalizations getTranslation( ) { switch (locale.languageCode) { case 'ar': - return new MaterialLocalizationAr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationAr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'bg': - return new MaterialLocalizationBg(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationBg(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'bs': - return new MaterialLocalizationBs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationBs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ca': - return new MaterialLocalizationCa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationCa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'cs': - return new MaterialLocalizationCs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationCs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'da': - return new MaterialLocalizationDa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationDa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'de': { switch (locale.countryCode) { case 'CH': - return new MaterialLocalizationDeCh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationDeCh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationDe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationDe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } case 'el': - return new MaterialLocalizationEl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'en': { switch (locale.countryCode) { case 'AU': - return new MaterialLocalizationEnAu(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnAu(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'CA': - return new MaterialLocalizationEnCa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnCa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'GB': - return new MaterialLocalizationEnGb(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnGb(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'IE': - return new MaterialLocalizationEnIe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnIe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'IN': - return new MaterialLocalizationEnIn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnIn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'SG': - return new MaterialLocalizationEnSg(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnSg(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ZA': - return new MaterialLocalizationEnZa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEnZa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationEn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } case 'es': { switch (locale.countryCode) { case '419': - return new MaterialLocalizationEs419(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEs419(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'AR': - return new MaterialLocalizationEsAr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsAr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'BO': - return new MaterialLocalizationEsBo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsBo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'CL': - return new MaterialLocalizationEsCl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsCl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'CO': - return new MaterialLocalizationEsCo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsCo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'CR': - return new MaterialLocalizationEsCr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsCr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'DO': - return new MaterialLocalizationEsDo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsDo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'EC': - return new MaterialLocalizationEsEc(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsEc(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'GT': - return new MaterialLocalizationEsGt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsGt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'HN': - return new MaterialLocalizationEsHn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsHn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'MX': - return new MaterialLocalizationEsMx(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsMx(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'NI': - return new MaterialLocalizationEsNi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsNi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'PA': - return new MaterialLocalizationEsPa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsPa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'PE': - return new MaterialLocalizationEsPe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsPe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'PR': - return new MaterialLocalizationEsPr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsPr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'PY': - return new MaterialLocalizationEsPy(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsPy(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'SV': - return new MaterialLocalizationEsSv(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsSv(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'US': - return new MaterialLocalizationEsUs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsUs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'UY': - return new MaterialLocalizationEsUy(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsUy(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'VE': - return new MaterialLocalizationEsVe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEsVe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationEs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } case 'et': - return new MaterialLocalizationEt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationEt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'fa': - return new MaterialLocalizationFa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationFa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'fi': - return new MaterialLocalizationFi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationFi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'fil': - return new MaterialLocalizationFil(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationFil(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'fr': { switch (locale.countryCode) { case 'CA': - return new MaterialLocalizationFrCa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationFrCa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationFr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationFr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } case 'gsw': - return new MaterialLocalizationGsw(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationGsw(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'he': - return new MaterialLocalizationHe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationHe(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'hi': - return new MaterialLocalizationHi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationHi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'hr': - return new MaterialLocalizationHr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationHr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'hu': - return new MaterialLocalizationHu(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationHu(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'id': - return new MaterialLocalizationId(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationId(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'it': - return new MaterialLocalizationIt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationIt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ja': - return new MaterialLocalizationJa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationJa(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ko': - return new MaterialLocalizationKo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationKo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'lt': - return new MaterialLocalizationLt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationLt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'lv': - return new MaterialLocalizationLv(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationLv(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ms': - return new MaterialLocalizationMs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationMs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'nb': - return new MaterialLocalizationNb(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationNb(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'nl': - return new MaterialLocalizationNl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationNl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'pl': - return new MaterialLocalizationPl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationPl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ps': - return new MaterialLocalizationPs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationPs(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'pt': { switch (locale.countryCode) { case 'PT': - return new MaterialLocalizationPtPt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationPtPt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationPt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationPt(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } case 'ro': - return new MaterialLocalizationRo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationRo(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ru': - return new MaterialLocalizationRu(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationRu(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'sk': - return new MaterialLocalizationSk(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationSk(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'sl': - return new MaterialLocalizationSl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationSl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'sr': { switch (locale.countryCode) { case 'Latn': - return new MaterialLocalizationSrLatn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationSrLatn(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationSr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationSr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } case 'sv': - return new MaterialLocalizationSv(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationSv(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'th': - return new MaterialLocalizationTh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationTh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'tl': - return new MaterialLocalizationTl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationTl(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'tr': - return new MaterialLocalizationTr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationTr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'uk': - return new MaterialLocalizationUk(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationUk(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'ur': - return new MaterialLocalizationUr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationUr(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'vi': - return new MaterialLocalizationVi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationVi(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'zh': { switch (locale.countryCode) { case 'HK': - return new MaterialLocalizationZhHk(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationZhHk(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); case 'TW': - return new MaterialLocalizationZhTw(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationZhTw(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } - return new MaterialLocalizationZh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); + return MaterialLocalizationZh(fullYearFormat: fullYearFormat, mediumDateFormat: mediumDateFormat, longDateFormat: longDateFormat, yearMonthFormat: yearMonthFormat, decimalFormat: decimalFormat, twoDigitZeroPaddedFormat: twoDigitZeroPaddedFormat); } } assert(false, 'getTranslation() called for unsupported locale "$locale"'); diff --git a/packages/flutter_localizations/lib/src/material_localizations.dart b/packages/flutter_localizations/lib/src/material_localizations.dart index 7b40da85cf..c7209cf340 100644 --- a/packages/flutter_localizations/lib/src/material_localizations.dart +++ b/packages/flutter_localizations/lib/src/material_localizations.dart @@ -525,7 +525,7 @@ class _MaterialLocalizationsDelegate extends LocalizationsDelegate(getTranslation( + return SynchronousFuture(getTranslation( locale, fullYearFormat, mediumDateFormat, diff --git a/packages/flutter_localizations/lib/src/widgets_localizations.dart b/packages/flutter_localizations/lib/src/widgets_localizations.dart index 5bf4db4ee6..45d7522c07 100644 --- a/packages/flutter_localizations/lib/src/widgets_localizations.dart +++ b/packages/flutter_localizations/lib/src/widgets_localizations.dart @@ -53,7 +53,7 @@ class GlobalWidgetsLocalizations implements WidgetsLocalizations { /// This method is typically used to create a [LocalizationsDelegate]. /// The [WidgetsApp] does so by default. static Future load(Locale locale) { - return new SynchronousFuture(new GlobalWidgetsLocalizations(locale)); + return SynchronousFuture(GlobalWidgetsLocalizations(locale)); } /// A [LocalizationsDelegate] that uses [GlobalWidgetsLocalizations.load] diff --git a/packages/flutter_localizations/test/basics_test.dart b/packages/flutter_localizations/test/basics_test.dart index 77aa0e9cc8..1e198711c6 100644 --- a/packages/flutter_localizations/test/basics_test.dart +++ b/packages/flutter_localizations/test/basics_test.dart @@ -8,11 +8,11 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('Nested Localizations', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( // Creates the outer Localizations widget. - home: new ListView( + await tester.pumpWidget(MaterialApp( // Creates the outer Localizations widget. + home: ListView( children: [ const LocalizationTracker(key: ValueKey('outer')), - new Localizations( + Localizations( locale: const Locale('zh', 'CN'), delegates: GlobalMaterialLocalizations.delegates, child: const LocalizationTracker(key: ValueKey('inner')), @@ -30,28 +30,28 @@ void main() { testWidgets('Localizations is compatible with ChangeNotifier.dispose() called during didChangeDependencies', (WidgetTester tester) async { // PageView calls ScrollPosition.dispose() during didChangeDependencies. await tester.pumpWidget( - new MaterialApp( + MaterialApp( supportedLocales: const [ Locale('en', 'US'), Locale('es', 'ES'), ], localizationsDelegates: >[ - new _DummyLocalizationsDelegate(), + _DummyLocalizationsDelegate(), GlobalMaterialLocalizations.delegate, ], - home: new PageView(), + home: PageView(), ) ); await tester.binding.setLocale('es', 'US'); await tester.pump(); - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); }); testWidgets('Locale without coutryCode', (WidgetTester tester) async { // Regression test for https://github.com/flutter/flutter/pull/16782 await tester.pumpWidget( - new MaterialApp( + MaterialApp( localizationsDelegates: const >[ GlobalMaterialLocalizations.delegate, ], @@ -59,7 +59,7 @@ void main() { Locale('es', 'ES'), Locale('zh'), ], - home: new Container(), + home: Container(), ) ); @@ -75,7 +75,7 @@ void main() { /// used to trigger didChangeDependencies upon locale change. class _DummyLocalizationsDelegate extends LocalizationsDelegate { @override - Future load(Locale locale) async => new DummyLocalizations(); + Future load(Locale locale) async => DummyLocalizations(); @override bool isSupported(Locale locale) => true; @@ -90,7 +90,7 @@ class LocalizationTracker extends StatefulWidget { const LocalizationTracker({Key key}) : super(key: key); @override - State createState() => new LocalizationTrackerState(); + State createState() => LocalizationTrackerState(); } class LocalizationTrackerState extends State { @@ -99,6 +99,6 @@ class LocalizationTrackerState extends State { @override Widget build(BuildContext context) { captionFontSize = Theme.of(context).textTheme.caption.fontSize; - return new Container(); + return Container(); } } diff --git a/packages/flutter_localizations/test/date_picker_test.dart b/packages/flutter_localizations/test/date_picker_test.dart index 4d93bc21a3..7abd4507b1 100644 --- a/packages/flutter_localizations/test/date_picker_test.dart +++ b/packages/flutter_localizations/test/date_picker_test.dart @@ -14,39 +14,39 @@ void main() { DateTime initialDate; setUp(() { - firstDate = new DateTime(2001, DateTime.january, 1); - lastDate = new DateTime(2031, DateTime.december, 31); - initialDate = new DateTime(2016, DateTime.january, 15); + firstDate = DateTime(2001, DateTime.january, 1); + lastDate = DateTime(2031, DateTime.december, 31); + initialDate = DateTime(2016, DateTime.january, 15); }); group(DayPicker, () { - final intl.NumberFormat arabicNumbers = new intl.NumberFormat('0', 'ar'); + final intl.NumberFormat arabicNumbers = intl.NumberFormat('0', 'ar'); final Map> testLocales = >{ // Tests the default. const Locale('en', 'US'): { 'textDirection': TextDirection.ltr, 'expectedDaysOfWeek': ['S', 'M', 'T', 'W', 'T', 'F', 'S'], - 'expectedDaysOfMonth': new List.generate(30, (int i) => '${i + 1}'), + 'expectedDaysOfMonth': List.generate(30, (int i) => '${i + 1}'), 'expectedMonthYearHeader': 'September 2017', }, // Tests a different first day of week. const Locale('ru', 'RU'): { 'textDirection': TextDirection.ltr, 'expectedDaysOfWeek': ['пн', 'вт', 'ср', 'чт', 'пт', 'сб', 'вс'], - 'expectedDaysOfMonth': new List.generate(30, (int i) => '${i + 1}'), + 'expectedDaysOfMonth': List.generate(30, (int i) => '${i + 1}'), 'expectedMonthYearHeader': 'сентябрь 2017 г.', }, const Locale('ro', 'RO'): { 'textDirection': TextDirection.ltr, 'expectedDaysOfWeek': ['D', 'L', 'M', 'M', 'J', 'V', 'S'], - 'expectedDaysOfMonth': new List.generate(30, (int i) => '${i + 1}'), + 'expectedDaysOfMonth': List.generate(30, (int i) => '${i + 1}'), 'expectedMonthYearHeader': 'septembrie 2017', }, // Tests RTL. const Locale('ar', 'AR'): { 'textDirection': TextDirection.rtl, 'expectedDaysOfWeek': ['ح', 'ن', 'ث', 'ر', 'خ', 'ج', 'س'], - 'expectedDaysOfMonth': new List.generate(30, (int i) => '${arabicNumbers.format(i + 1)}'), + 'expectedDaysOfMonth': List.generate(30, (int i) => '${arabicNumbers.format(i + 1)}'), 'expectedMonthYearHeader': 'سبتمبر ٢٠١٧', }, }; @@ -57,9 +57,9 @@ void main() { final List expectedDaysOfMonth = testLocales[locale]['expectedDaysOfMonth']; final String expectedMonthYearHeader = testLocales[locale]['expectedMonthYearHeader']; final TextDirection textDirection = testLocales[locale]['textDirection']; - final DateTime baseDate = new DateTime(2017, 9, 27); + final DateTime baseDate = DateTime(2017, 9, 27); - await _pumpBoilerplate(tester, new DayPicker( + await _pumpBoilerplate(tester, DayPicker( selectedDate: baseDate, currentDate: baseDate, onChanged: (DateTime newValue) {}, @@ -96,17 +96,17 @@ void main() { }); testWidgets('locale parameter overrides ambient locale', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( locale: const Locale('en', 'US'), supportedLocales: const [ Locale('en', 'US'), Locale('fr', 'CA'), ], localizationsDelegates: GlobalMaterialLocalizations.delegates, - home: new Material( - child: new Builder( + home: Material( + child: Builder( builder: (BuildContext context) { - return new FlatButton( + return FlatButton( onPressed: () async { await showDatePicker( context: context, @@ -141,15 +141,15 @@ void main() { }); testWidgets('textDirection parameter overrides ambient textDirection', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( locale: const Locale('en', 'US'), supportedLocales: const [ Locale('en', 'US'), ], - home: new Material( - child: new Builder( + home: Material( + child: Builder( builder: (BuildContext context) { - return new FlatButton( + return FlatButton( onPressed: () async { await showDatePicker( context: context, @@ -179,17 +179,17 @@ void main() { }); testWidgets('textDirection parameter takes precedence over locale parameter', (WidgetTester tester) async { - await tester.pumpWidget(new MaterialApp( + await tester.pumpWidget(MaterialApp( locale: const Locale('en', 'US'), supportedLocales: const [ Locale('en', 'US'), Locale('fr', 'CA'), ], localizationsDelegates: GlobalMaterialLocalizations.delegates, - home: new Material( - child: new Builder( + home: Material( + child: Builder( builder: (BuildContext context) { - return new FlatButton( + return FlatButton( onPressed: () async { await showDatePicker( context: context, @@ -231,9 +231,9 @@ Future _pumpBoilerplate( Locale locale = const Locale('en', 'US'), TextDirection textDirection = TextDirection.ltr }) async { - await tester.pumpWidget(new Directionality( + await tester.pumpWidget(Directionality( textDirection: TextDirection.ltr, - child: new Localizations( + child: Localizations( locale: locale, delegates: GlobalMaterialLocalizations.delegates, child: child, diff --git a/packages/flutter_localizations/test/date_time_test.dart b/packages/flutter_localizations/test/date_time_test.dart index ca86e5d91c..18b3f08e05 100644 --- a/packages/flutter_localizations/test/date_time_test.dart +++ b/packages/flutter_localizations/test/date_time_test.dart @@ -28,16 +28,16 @@ void main() { group('formatHour', () { Future formatHour(WidgetTester tester, Locale locale, TimeOfDay timeOfDay) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new MaterialApp( + final Completer completer = Completer(); + await tester.pumpWidget(MaterialApp( supportedLocales: [locale], locale: locale, localizationsDelegates: const >[ GlobalMaterialLocalizations.delegate, ], - home: new Builder(builder: (BuildContext context) { + home: Builder(builder: (BuildContext context) { completer.complete(MaterialLocalizations.of(context).formatHour(timeOfDay)); - return new Container(); + return Container(); }), )); return completer.future; @@ -74,16 +74,16 @@ void main() { group('formatTimeOfDay', () { Future formatTimeOfDay(WidgetTester tester, Locale locale, TimeOfDay timeOfDay) async { - final Completer completer = new Completer(); - await tester.pumpWidget(new MaterialApp( + final Completer completer = Completer(); + await tester.pumpWidget(MaterialApp( supportedLocales: [locale], locale: locale, localizationsDelegates: const >[ GlobalMaterialLocalizations.delegate, ], - home: new Builder(builder: (BuildContext context) { + home: Builder(builder: (BuildContext context) { completer.complete(MaterialLocalizations.of(context).formatTimeOfDay(timeOfDay)); - return new Container(); + return Container(); }), )); return completer.future; @@ -118,14 +118,14 @@ void main() { group('date formatters', () { Future> formatDate(WidgetTester tester, Locale locale, DateTime dateTime) async { - final Completer> completer = new Completer>(); - await tester.pumpWidget(new MaterialApp( + final Completer> completer = Completer>(); + await tester.pumpWidget(MaterialApp( supportedLocales: [locale], locale: locale, localizationsDelegates: const >[ GlobalMaterialLocalizations.delegate, ], - home: new Builder(builder: (BuildContext context) { + home: Builder(builder: (BuildContext context) { final MaterialLocalizations localizations = MaterialLocalizations.of(context); completer.complete({ DateType.year: localizations.formatYear(dateTime), @@ -133,14 +133,14 @@ void main() { DateType.full: localizations.formatFullDate(dateTime), DateType.monthYear: localizations.formatMonthYear(dateTime), }); - return new Container(); + return Container(); }), )); return completer.future; } testWidgets('formats dates in English', (WidgetTester tester) async { - final Map formatted = await formatDate(tester, const Locale('en', ''), new DateTime(2018, 8, 1)); + final Map formatted = await formatDate(tester, const Locale('en', ''), DateTime(2018, 8, 1)); expect(formatted[DateType.year], '2018'); expect(formatted[DateType.medium], 'Wed, Aug 1'); expect(formatted[DateType.full], 'Wednesday, August 1, 2018'); @@ -148,7 +148,7 @@ void main() { }); testWidgets('formats dates in German', (WidgetTester tester) async { - final Map formatted = await formatDate(tester, const Locale('de', ''), new DateTime(2018, 8, 1)); + final Map formatted = await formatDate(tester, const Locale('de', ''), DateTime(2018, 8, 1)); expect(formatted[DateType.year], '2018'); expect(formatted[DateType.medium], 'Mi., 1. Aug.'); expect(formatted[DateType.full], 'Mittwoch, 1. August 2018'); diff --git a/packages/flutter_localizations/test/override_test.dart b/packages/flutter_localizations/test/override_test.dart index 9114979b50..d8bf3cb958 100644 --- a/packages/flutter_localizations/test/override_test.dart +++ b/packages/flutter_localizations/test/override_test.dart @@ -14,12 +14,12 @@ class FooMaterialLocalizations extends MaterialLocalizationEn { this.backButtonTooltip, ) : super( localeName: localeName.toString(), - fullYearFormat: new intl.DateFormat.y(), - mediumDateFormat: new intl.DateFormat('E, MMM\u00a0d'), - longDateFormat: new intl.DateFormat.yMMMMEEEEd(), - yearMonthFormat: new intl.DateFormat.yMMMM(), - decimalFormat: new intl.NumberFormat.decimalPattern(), - twoDigitZeroPaddedFormat: new intl.NumberFormat('00'), + fullYearFormat: intl.DateFormat.y(), + mediumDateFormat: intl.DateFormat('E, MMM\u00a0d'), + longDateFormat: intl.DateFormat.yMMMMEEEEd(), + yearMonthFormat: intl.DateFormat.yMMMM(), + decimalFormat: intl.NumberFormat.decimalPattern(), + twoDigitZeroPaddedFormat: intl.NumberFormat('00'), ); @override @@ -42,7 +42,7 @@ class FooMaterialLocalizationsDelegate extends LocalizationsDelegate load(Locale locale) { - return new SynchronousFuture(new FooMaterialLocalizations(locale, backButtonTooltip)); + return SynchronousFuture(FooMaterialLocalizations(locale, backButtonTooltip)); } @override @@ -59,14 +59,14 @@ Widget buildFrame({ Locale('es', 'ES'), ], }) { - return new MaterialApp( + return MaterialApp( color: const Color(0xFFFFFFFF), locale: locale, supportedLocales: supportedLocales, localizationsDelegates: delegates, localeResolutionCallback: localeResolutionCallback, onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute( + return MaterialPageRoute( builder: (BuildContext context) { return buildContent(context); } @@ -77,12 +77,12 @@ Widget buildFrame({ void main() { testWidgets('Locale fallbacks', (WidgetTester tester) async { - final Key textKey = new UniqueKey(); + final Key textKey = UniqueKey(); await tester.pumpWidget( buildFrame( buildContent: (BuildContext context) { - return new Text( + return Text( MaterialLocalizations.of(context).backButtonTooltip, key: textKey, ); @@ -108,15 +108,15 @@ void main() { return buildFrame( locale: locale, buildContent: (BuildContext context) { - return new Localizations.override( + return Localizations.override( context: context, - child: new Builder( + child: Builder( builder: (BuildContext context) { // No MaterialLocalizations are defined for the first Localizations // ancestor, so we should get the values from the default one, i.e. // the one created by WidgetsApp via the LocalizationsDelegate // provided by MaterialApp. - return new Text(MaterialLocalizations.of(context).backButtonTooltip); + return Text(MaterialLocalizations.of(context).backButtonTooltip); }, ), ); @@ -139,16 +139,16 @@ void main() { return buildFrame( locale: locale, buildContent: (BuildContext context) { - return new Localizations.override( + return Localizations.override( context: context, locale: const Locale('en', 'US'), - child: new Builder( + child: Builder( builder: (BuildContext context) { // No MaterialLocalizations are defined for the Localizations.override // ancestor, so we should get all values from the default one, i.e. // the one created by WidgetsApp via the LocalizationsDelegate // provided by MaterialApp. - return new Text(MaterialLocalizations.of(context).backButtonTooltip); + return Text(MaterialLocalizations.of(context).backButtonTooltip); }, ), ); @@ -167,7 +167,7 @@ void main() { }); testWidgets('MaterialApp adds MaterialLocalizations for additional languages', (WidgetTester tester) async { - final Key textKey = new UniqueKey(); + final Key textKey = UniqueKey(); await tester.pumpWidget( buildFrame( @@ -181,7 +181,7 @@ void main() { Locale('de', ''), ], buildContent: (BuildContext context) { - return new Text( + return Text( MaterialLocalizations.of(context).backButtonTooltip, key: textKey, ); @@ -201,7 +201,7 @@ void main() { }); testWidgets('MaterialApp overrides MaterialLocalizations for all locales', (WidgetTester tester) async { - final Key textKey = new UniqueKey(); + final Key textKey = UniqueKey(); await tester.pumpWidget( buildFrame( @@ -212,7 +212,7 @@ void main() { ], buildContent: (BuildContext context) { // Should always be 'foo', no matter what the locale is - return new Text( + return Text( MaterialLocalizations.of(context).backButtonTooltip, key: textKey, ); @@ -232,7 +232,7 @@ void main() { }); testWidgets('MaterialApp overrides MaterialLocalizations for default locale', (WidgetTester tester) async { - final Key textKey = new UniqueKey(); + final Key textKey = UniqueKey(); await tester.pumpWidget( buildFrame( @@ -241,7 +241,7 @@ void main() { ], // supportedLocales not specified, so all locales resolve to 'en' buildContent: (BuildContext context) { - return new Text( + return Text( MaterialLocalizations.of(context).backButtonTooltip, key: textKey, ); @@ -264,7 +264,7 @@ void main() { }); testWidgets('deprecated Android/Java locales are modernized', (WidgetTester tester) async { - final Key textKey = new UniqueKey(); + final Key textKey = UniqueKey(); await tester.pumpWidget( buildFrame( @@ -275,7 +275,7 @@ void main() { const Locale('id', 'JV'), ], buildContent: (BuildContext context) { - return new Text( + return Text( '${Localizations.localeOf(context)}', key: textKey, ); diff --git a/packages/flutter_localizations/test/time_picker_test.dart b/packages/flutter_localizations/test/time_picker_test.dart index 76f57b258f..3d978fb892 100644 --- a/packages/flutter_localizations/test/time_picker_test.dart +++ b/packages/flutter_localizations/test/time_picker_test.dart @@ -15,14 +15,14 @@ class _TimePickerLauncher extends StatelessWidget { @override Widget build(BuildContext context) { - return new MaterialApp( + return MaterialApp( locale: locale, localizationsDelegates: GlobalMaterialLocalizations.delegates, - home: new Material( - child: new Center( - child: new Builder( + home: Material( + child: Center( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( child: const Text('X'), onPressed: () async { onChanged(await showTimePicker( @@ -41,7 +41,7 @@ class _TimePickerLauncher extends StatelessWidget { Future startPicker(WidgetTester tester, ValueChanged onChanged, { Locale locale = const Locale('en', 'US') }) async { - await tester.pumpWidget(new _TimePickerLauncher(onChanged: onChanged, locale: locale,)); + await tester.pumpWidget(_TimePickerLauncher(onChanged: onChanged, locale: locale,)); await tester.tap(find.text('X')); await tester.pumpAndSettle(const Duration(seconds: 1)); return tester.getCenter(find.byKey(const Key('time-picker-dial'))); @@ -84,7 +84,7 @@ void main() { } }); expect(actual, locales[locale]); - await tester.tapAt(new Offset(center.dx, center.dy - 50.0)); + await tester.tapAt(Offset(center.dx, center.dy - 50.0)); await finishPicker(tester); } }); @@ -99,7 +99,7 @@ void main() { final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }); final Size size = tester.getSize(find.byKey(const Key('time-picker-dial'))); final double dy = (size.height / 2.0 / 10) * i; - await tester.tapAt(new Offset(center.dx, center.dy - dy)); + await tester.tapAt(Offset(center.dx, center.dy - dy)); await finishPicker(tester); expect(result, equals(const TimeOfDay(hour: 0, minute: 0))); } @@ -119,9 +119,9 @@ void main() { final Offset center = await startPicker(tester, (TimeOfDay time) { result = time; }, locale: locale); final Size size = tester.getSize(find.byKey(const Key('time-picker-dial'))); final double dy = (size.height / 2.0 / 10) * i; - await tester.tapAt(new Offset(center.dx, center.dy - dy)); + await tester.tapAt(Offset(center.dx, center.dy - dy)); await finishPicker(tester); - expect(result, equals(new TimeOfDay(hour: i < 7 ? 12 : 0, minute: 0))); + expect(result, equals(TimeOfDay(hour: i < 7 ? 12 : 0, minute: 0))); } } }); @@ -132,21 +132,21 @@ void main() { Future mediaQueryBoilerplate(WidgetTester tester, bool alwaysUse24HourFormat) async { await tester.pumpWidget( - new Localizations( + Localizations( locale: const Locale('en', 'US'), delegates: const >[ GlobalMaterialLocalizations.delegate, DefaultWidgetsLocalizations.delegate, ], - child: new MediaQuery( - data: new MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), - child: new Material( - child: new Directionality( + child: MediaQuery( + data: MediaQueryData(alwaysUse24HourFormat: alwaysUse24HourFormat), + child: Material( + child: Directionality( textDirection: TextDirection.ltr, - child: new Navigator( + child: Navigator( onGenerateRoute: (RouteSettings settings) { - return new MaterialPageRoute(builder: (BuildContext context) { - return new FlatButton( + return MaterialPageRoute(builder: (BuildContext context) { + return FlatButton( onPressed: () { showTimePicker(context: context, initialTime: const TimeOfDay(hour: 7, minute: 0)); }, diff --git a/packages/flutter_localizations/test/translations_test.dart b/packages/flutter_localizations/test/translations_test.dart index 5268d89083..0aa2f03eba 100644 --- a/packages/flutter_localizations/test/translations_test.dart +++ b/packages/flutter_localizations/test/translations_test.dart @@ -9,7 +9,7 @@ import 'package:flutter_test/flutter_test.dart'; void main() { for (String language in kSupportedLanguages) { testWidgets('translations exist for $language', (WidgetTester tester) async { - final Locale locale = new Locale(language, ''); + final Locale locale = Locale(language, ''); expect(GlobalMaterialLocalizations.delegate.isSupported(locale), isTrue); @@ -120,19 +120,19 @@ void main() { testWidgets('spot check formatMediumDate(), formatFullDate() translations', (WidgetTester tester) async { MaterialLocalizations localizations = await GlobalMaterialLocalizations.delegate.load(const Locale('en', '')); - expect(localizations.formatMediumDate(new DateTime(2015, 7, 23)), 'Thu, Jul 23'); - expect(localizations.formatFullDate(new DateTime(2015, 7, 23)), 'Thursday, July 23, 2015'); + expect(localizations.formatMediumDate(DateTime(2015, 7, 23)), 'Thu, Jul 23'); + expect(localizations.formatFullDate(DateTime(2015, 7, 23)), 'Thursday, July 23, 2015'); localizations = await GlobalMaterialLocalizations.delegate.load(const Locale('en', 'GB')); - expect(localizations.formatMediumDate(new DateTime(2015, 7, 23)), 'Thu 23 Jul'); - expect(localizations.formatFullDate(new DateTime(2015, 7, 23)), 'Thursday, 23 July 2015'); + expect(localizations.formatMediumDate(DateTime(2015, 7, 23)), 'Thu 23 Jul'); + expect(localizations.formatFullDate(DateTime(2015, 7, 23)), 'Thursday, 23 July 2015'); localizations = await GlobalMaterialLocalizations.delegate.load(const Locale('es', '')); - expect(localizations.formatMediumDate(new DateTime(2015, 7, 23)), 'jue., 23 jul.'); - expect(localizations.formatFullDate(new DateTime(2015, 7, 23)), 'jueves, 23 de julio de 2015'); + expect(localizations.formatMediumDate(DateTime(2015, 7, 23)), 'jue., 23 jul.'); + expect(localizations.formatFullDate(DateTime(2015, 7, 23)), 'jueves, 23 de julio de 2015'); localizations = await GlobalMaterialLocalizations.delegate.load(const Locale('de', '')); - expect(localizations.formatMediumDate(new DateTime(2015, 7, 23)), 'Do., 23. Juli'); - expect(localizations.formatFullDate(new DateTime(2015, 7, 23)), 'Donnerstag, 23. Juli 2015'); + expect(localizations.formatMediumDate(DateTime(2015, 7, 23)), 'Do., 23. Juli'); + expect(localizations.formatFullDate(DateTime(2015, 7, 23)), 'Donnerstag, 23. Juli 2015'); }); } diff --git a/packages/flutter_localizations/test/widgets_test.dart b/packages/flutter_localizations/test/widgets_test.dart index f81c680e08..a5df0931ea 100644 --- a/packages/flutter_localizations/test/widgets_test.dart +++ b/packages/flutter_localizations/test/widgets_test.dart @@ -14,12 +14,12 @@ class TestLocalizations { final String prefix; static Future loadSync(Locale locale, String prefix) { - return new SynchronousFuture(new TestLocalizations(locale, prefix)); + return SynchronousFuture(TestLocalizations(locale, prefix)); } static Future loadAsync(Locale locale, String prefix) { - return new Future.delayed(const Duration(milliseconds: 100)) - .then((_) => new TestLocalizations(locale, prefix)); + return Future.delayed(const Duration(milliseconds: 100)) + .then((_) => TestLocalizations(locale, prefix)); } static TestLocalizations of(BuildContext context) { @@ -79,12 +79,12 @@ class MoreLocalizations { final Locale locale; static Future loadSync(Locale locale) { - return new SynchronousFuture(new MoreLocalizations(locale)); + return SynchronousFuture(MoreLocalizations(locale)); } static Future loadAsync(Locale locale) { - return new Future.delayed(const Duration(milliseconds: 100)) - .then((_) => new MoreLocalizations(locale)); + return Future.delayed(const Duration(milliseconds: 100)) + .then((_) => MoreLocalizations(locale)); } static MoreLocalizations of(BuildContext context) { @@ -129,7 +129,7 @@ class OnlyRTLDefaultWidgetsLocalizationsDelegate extends LocalizationsDelegate load(Locale locale) { - return new SynchronousFuture(new OnlyRTLDefaultWidgetsLocalizations()); + return SynchronousFuture(OnlyRTLDefaultWidgetsLocalizations()); } @override @@ -146,14 +146,14 @@ Widget buildFrame({ Locale('en', 'GB'), ], }) { - return new WidgetsApp( + return WidgetsApp( color: const Color(0xFFFFFFFF), locale: locale, localizationsDelegates: delegates, localeResolutionCallback: localeResolutionCallback, supportedLocales: supportedLocales, onGenerateRoute: (RouteSettings settings) { - return new PageRouteBuilder( + return PageRouteBuilder( pageBuilder: (BuildContext context, Animation _, Animation __) { return buildContent(context); } @@ -166,13 +166,13 @@ class SyncLoadTest extends StatefulWidget { const SyncLoadTest(); @override - SyncLoadTestState createState() => new SyncLoadTestState(); + SyncLoadTestState createState() => SyncLoadTestState(); } class SyncLoadTestState extends State { @override Widget build(BuildContext context) { - return new Text( + return Text( TestLocalizations.of(context).message, textDirection: TextDirection.rtl, ); @@ -226,12 +226,12 @@ void main() { testWidgets('Synchronously loaded localizations in a WidgetsApp', (WidgetTester tester) async { final List> delegates = >[ - new SyncTestLocalizationsDelegate(), + SyncTestLocalizationsDelegate(), DefaultWidgetsLocalizations.delegate, ]; Future pumpTest(Locale locale) async { - await tester.pumpWidget(new Localizations( + await tester.pumpWidget(Localizations( locale: locale, delegates: delegates, child: const SyncLoadTest(), @@ -254,10 +254,10 @@ void main() { await tester.pumpWidget( buildFrame( delegates: >[ - new AsyncTestLocalizationsDelegate(), + AsyncTestLocalizationsDelegate(), ], buildContent: (BuildContext context) { - return new Text(TestLocalizations.of(context).message); + return Text(TestLocalizations.of(context).message); } ) ); @@ -287,15 +287,15 @@ void main() { await tester.pumpWidget( buildFrame( delegates: >[ - new SyncTestLocalizationsDelegate(), - new SyncMoreLocalizationsDelegate(), + SyncTestLocalizationsDelegate(), + SyncMoreLocalizationsDelegate(), ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Text('B: ${MoreLocalizations.of(context).message}'), + Text('A: ${TestLocalizations.of(context).message}'), + Text('B: ${MoreLocalizations.of(context).message}'), ], ); } @@ -311,15 +311,15 @@ void main() { await tester.pumpWidget( buildFrame( delegates: >[ - new SyncTestLocalizationsDelegate(), - new AsyncMoreLocalizationsDelegate(), // No resources until this completes + SyncTestLocalizationsDelegate(), + AsyncMoreLocalizationsDelegate(), // No resources until this completes ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Text('B: ${MoreLocalizations.of(context).message}'), + Text('A: ${TestLocalizations.of(context).message}'), + Text('B: ${MoreLocalizations.of(context).message}'), ], ); } @@ -341,23 +341,23 @@ void main() { await tester.pumpWidget( buildFrame( delegates: >[ - new SyncTestLocalizationsDelegate(), + SyncTestLocalizationsDelegate(), ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Localizations( + Text('A: ${TestLocalizations.of(context).message}'), + Localizations( locale: const Locale('en', 'GB'), delegates: >[ - new SyncTestLocalizationsDelegate(), + SyncTestLocalizationsDelegate(), DefaultWidgetsLocalizations.delegate, ], // Create a new context within the en_GB Localization - child: new Builder( + child: Builder( builder: (BuildContext context) { - return new Text('B: ${TestLocalizations.of(context).message}'); + return Text('B: ${TestLocalizations.of(context).message}'); }, ), ), @@ -375,19 +375,19 @@ void main() { // stays the same BUT one of its delegate.shouldReload() methods returns true, // then the dependent widgets should rebuild. testWidgets('Localizations sync delegate shouldReload returns true', (WidgetTester tester) async { - final SyncTestLocalizationsDelegate originalDelegate = new SyncTestLocalizationsDelegate(); + final SyncTestLocalizationsDelegate originalDelegate = SyncTestLocalizationsDelegate(); await tester.pumpWidget( buildFrame( delegates: >[ originalDelegate, - new SyncMoreLocalizationsDelegate(), + SyncMoreLocalizationsDelegate(), ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Text('B: ${MoreLocalizations.of(context).message}'), + Text('A: ${TestLocalizations.of(context).message}'), + Text('B: ${MoreLocalizations.of(context).message}'), ], ); } @@ -400,19 +400,19 @@ void main() { expect(originalDelegate.shouldReloadValues, []); - final SyncTestLocalizationsDelegate modifiedDelegate = new SyncTestLocalizationsDelegate('---'); + final SyncTestLocalizationsDelegate modifiedDelegate = SyncTestLocalizationsDelegate('---'); await tester.pumpWidget( buildFrame( delegates: >[ modifiedDelegate, - new SyncMoreLocalizationsDelegate(), + SyncMoreLocalizationsDelegate(), ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Text('B: ${MoreLocalizations.of(context).message}'), + Text('A: ${TestLocalizations.of(context).message}'), + Text('B: ${MoreLocalizations.of(context).message}'), ], ); } @@ -430,15 +430,15 @@ void main() { await tester.pumpWidget( buildFrame( delegates: >[ - new AsyncTestLocalizationsDelegate(), - new AsyncMoreLocalizationsDelegate(), + AsyncTestLocalizationsDelegate(), + AsyncMoreLocalizationsDelegate(), ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Text('B: ${MoreLocalizations.of(context).message}'), + Text('A: ${TestLocalizations.of(context).message}'), + Text('B: ${MoreLocalizations.of(context).message}'), ], ); } @@ -449,19 +449,19 @@ void main() { expect(find.text('A: en_US'), findsOneWidget); expect(find.text('B: en_US'), findsOneWidget); - final AsyncTestLocalizationsDelegate modifiedDelegate = new AsyncTestLocalizationsDelegate('---'); + final AsyncTestLocalizationsDelegate modifiedDelegate = AsyncTestLocalizationsDelegate('---'); await tester.pumpWidget( buildFrame( delegates: >[ modifiedDelegate, - new AsyncMoreLocalizationsDelegate(), + AsyncMoreLocalizationsDelegate(), ], locale: const Locale('en', 'US'), buildContent: (BuildContext context) { - return new Column( + return Column( children: [ - new Text('A: ${TestLocalizations.of(context).message}'), - new Text('B: ${MoreLocalizations.of(context).message}'), + Text('A: ${TestLocalizations.of(context).message}'), + Text('B: ${MoreLocalizations.of(context).message}'), ], ); } @@ -509,7 +509,7 @@ void main() { return const Locale('foo', 'BAR'); }, buildContent: (BuildContext context) { - return new Text(Localizations.localeOf(context).toString()); + return Text(Localizations.localeOf(context).toString()); } ) ); @@ -532,7 +532,7 @@ void main() { Locale('en', 'CA'), ], buildContent: (BuildContext context) { - return new Text(Localizations.localeOf(context).toString()); + return Text(Localizations.localeOf(context).toString()); } ) ); @@ -567,13 +567,13 @@ void main() { GlobalWidgetsLocalizations.delegate, ], buildContent: (BuildContext context) { - return new Localizations.override( + return Localizations.override( context: context, - child: new Builder( + child: Builder( builder: (BuildContext context) { final Locale locale = Localizations.localeOf(context); final TextDirection direction = WidgetsLocalizations.of(context).textDirection; - return new Text('$locale $direction'); + return Text('$locale $direction'); }, ), ); @@ -604,17 +604,17 @@ void main() { // Accept whatever locale we're given localeResolutionCallback: (Locale locale, Iterable supportedLocales) => locale, buildContent: (BuildContext context) { - return new Localizations.override( + return Localizations.override( context: context, delegates: const [ // Override: no matter what the locale, textDirection is always RTL. OnlyRTLDefaultWidgetsLocalizationsDelegate(), ], - child: new Builder( + child: Builder( builder: (BuildContext context) { final Locale locale = Localizations.localeOf(context); final TextDirection direction = WidgetsLocalizations.of(context).textDirection; - return new Text('$locale $direction'); + return Text('$locale $direction'); }, ), ); @@ -650,7 +650,7 @@ void main() { buildContent: (BuildContext context) { final Locale locale = Localizations.localeOf(context); final TextDirection direction = WidgetsLocalizations.of(context).textDirection; - return new Text('$locale $direction'); + return Text('$locale $direction'); } ) ); diff --git a/packages/flutter_test/lib/src/accessibility.dart b/packages/flutter_test/lib/src/accessibility.dart index ed44b122fc..ade0de66b3 100644 --- a/packages/flutter_test/lib/src/accessibility.dart +++ b/packages/flutter_test/lib/src/accessibility.dart @@ -39,14 +39,14 @@ class Evaluation { Evaluation operator +(Evaluation other) { if (other == null) return this; - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); if (reason != null) { buffer.write(reason); buffer.write(' '); } if (other.reason != null) buffer.write(other.reason); - return new Evaluation._(passed && other.passed, buffer.isEmpty ? null : buffer.toString()); + return Evaluation._(passed && other.passed, buffer.isEmpty ? null : buffer.toString()); } } @@ -112,7 +112,7 @@ class MinimumTapTargetGuideline extends AccessibilityGuideline { // shrink by device pixel ratio. final Size candidateSize = paintBounds.size / ui.window.devicePixelRatio; if (candidateSize.width < size.width || candidateSize.height < size.height) - result += new Evaluation.fail( + result += Evaluation.fail( '$node: expected tap target size of at least $size, but found $candidateSize\n' 'See also: $link'); return result; @@ -203,7 +203,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { assert(false); } } else if (elements.length > 1) { - return new Evaluation.fail('Multiple nodes with the same label: ${data.label}\n'); + return Evaluation.fail('Multiple nodes with the same label: ${data.label}\n'); } else { // If we can't find the text node then assume the label does not // correspond to actual text. @@ -225,7 +225,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { // Node was too far off screen. if (subset.isEmpty) return result; - final _ContrastReport report = new _ContrastReport(subset); + final _ContrastReport report = _ContrastReport(subset); final double contrastRatio = report.contrastRatio(); const double delta = -0.01; double targetContrastRatio; @@ -236,7 +236,7 @@ class MinimumTextContrastGuideline extends AccessibilityGuideline { } if (contrastRatio - targetContrastRatio >= delta) return result + const Evaluation.pass(); - return result + new Evaluation.fail( + return result + Evaluation.fail( '$node:\nExpected contrast ratio of at least ' '$targetContrastRatio but found ${contrastRatio.toStringAsFixed(2)} for a font size of $fontSize. ' 'The computed foreground color was: ${report.lightColor}, ' @@ -306,14 +306,14 @@ class _ContrastReport { for (int color in colors) colorHistogram[color] = (colorHistogram[color] ?? 0) + 1; if (colorHistogram.length == 1) { - final Color hslColor = new Color(colorHistogram.keys.first); - return new _ContrastReport._(hslColor, hslColor); + final Color hslColor = Color(colorHistogram.keys.first); + return _ContrastReport._(hslColor, hslColor); } // to determine the lighter and darker color, partition the colors // by lightness and then choose the mode from each group. double averageLightness = 0.0; for (int color in colorHistogram.keys) { - final HSLColor hslColor = new HSLColor.fromColor(new Color(color)); + final HSLColor hslColor = HSLColor.fromColor(Color(color)); averageLightness += hslColor.lightness * colorHistogram[color]; } averageLightness /= colors.length; @@ -324,7 +324,7 @@ class _ContrastReport { int darkCount = 0; // Find the most frequently occurring light and dark color. for (MapEntry entry in colorHistogram.entries) { - final HSLColor color = new HSLColor.fromColor(new Color(entry.key)); + final HSLColor color = HSLColor.fromColor(Color(entry.key)); final int count = entry.value; if (color.lightness <= averageLightness && count > darkCount) { darkColor = entry.key; @@ -335,7 +335,7 @@ class _ContrastReport { } } assert (lightColor != 0 && darkColor != 0); - return new _ContrastReport._(new Color(lightColor), new Color(darkColor)); + return _ContrastReport._(Color(lightColor), Color(darkColor)); } const _ContrastReport._(this.lightColor, this.darkColor); diff --git a/packages/flutter_test/lib/src/all_elements.dart b/packages/flutter_test/lib/src/all_elements.dart index af02db62af..019648f41b 100644 --- a/packages/flutter_test/lib/src/all_elements.dart +++ b/packages/flutter_test/lib/src/all_elements.dart @@ -19,7 +19,7 @@ import 'package:flutter/widgets.dart'; Iterable collectAllElementsFrom(Element rootElement, { @required bool skipOffstage, }) { - return new CachingIterable(new _DepthFirstChildIterator(rootElement, skipOffstage)); + return CachingIterable(_DepthFirstChildIterator(rootElement, skipOffstage)); } class _DepthFirstChildIterator implements Iterator { diff --git a/packages/flutter_test/lib/src/binding.dart b/packages/flutter_test/lib/src/binding.dart index cc6cbc25b8..2d47644df9 100644 --- a/packages/flutter_test/lib/src/binding.dart +++ b/packages/flutter_test/lib/src/binding.dart @@ -140,9 +140,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase static WidgetsBinding ensureInitialized() { if (WidgetsBinding.instance == null) { if (Platform.environment.containsKey('FLUTTER_TEST')) { - new AutomatedTestWidgetsFlutterBinding(); + AutomatedTestWidgetsFlutterBinding(); } else { - new LiveTestWidgetsFlutterBinding(); + LiveTestWidgetsFlutterBinding(); } } assert(WidgetsBinding.instance is TestWidgetsFlutterBinding); @@ -152,8 +152,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase @override void initInstances() { timeDilation = 1.0; // just in case the developer has artificially changed it for development - HttpOverrides.global = new _MockHttpOverrides(); - _testTextInput = new TestTextInput(onCleared: _resetFocusedEditable)..register(); + HttpOverrides.global = _MockHttpOverrides(); + _testTextInput = TestTextInput(onCleared: _resetFocusedEditable)..register(); super.initInstances(); } @@ -230,7 +230,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase Future setLocale(String languageCode, String countryCode) { return TestAsyncUtils.guard(() async { assert(inTest); - final Locale locale = new Locale(languageCode, countryCode); + final Locale locale = Locale(languageCode, countryCode); dispatchLocaleChanged(locale); return null; }); @@ -257,7 +257,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase ViewConfiguration createViewConfiguration() { final double devicePixelRatio = ui.window.devicePixelRatio; final Size size = _surfaceSize ?? ui.window.physicalSize / devicePixelRatio; - return new ViewConfiguration( + return ViewConfiguration( size: size, devicePixelRatio: devicePixelRatio, ); @@ -274,7 +274,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase /// after this method was invoked, even if they are zero-time timers. Future idle() { return TestAsyncUtils.guard(() { - final Completer completer = new Completer(); + final Completer completer = Completer(); Timer.run(() { completer.complete(null); }); @@ -443,7 +443,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase _exceptionCount += 1; } FlutterError.dumpErrorToConsole(details, forceReport: true); - _pendingExceptionDetails = new FlutterErrorDetails( + _pendingExceptionDetails = FlutterErrorDetails( exception: 'Multiple exceptions ($_exceptionCount) were detected during the running of the current test, and at least one was unexpected.', library: 'Flutter test framework' ); @@ -452,7 +452,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase _pendingExceptionDetails = details; } }; - final Completer testCompleter = new Completer(); + final Completer testCompleter = Completer(); final VoidCallback testCompletionHandler = _createTestCompletionHandler(description, testCompleter); void handleUncaughtError(dynamic exception, StackTrace stack) { if (testCompleter.isCompleted) { @@ -463,7 +463,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase // we report them to the console. They don't cause test failures, but hopefully someone // will see them in the logs at some point. debugPrint = debugPrintOverride; // just in case the test overrides it -- otherwise we won't see the error! - FlutterError.dumpErrorToConsole(new FlutterErrorDetails( + FlutterError.dumpErrorToConsole(FlutterErrorDetails( exception: exception, stack: _unmangle(stack), context: 'running a test (but after the test had completed)', @@ -505,9 +505,9 @@ abstract class TestWidgetsFlutterBinding extends BindingBase } catch (exception) { treeDump = ''; } - final StringBuffer expectLine = new StringBuffer(); + final StringBuffer expectLine = StringBuffer(); final int stackLinesToOmit = reportExpectCall(stack, expectLine); - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: _unmangle(stack), context: 'running a test', @@ -530,7 +530,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase assert(_pendingExceptionDetails != null, 'A test overrode FlutterError.onError but either failed to return it to its original state, or had unexpected additional errors that it could not handle. Typically, this is caused by using expect() before restoring FlutterError.onError.'); _parentZone.run(testCompletionHandler); } - final ZoneSpecification errorHandlingZoneSpecification = new ZoneSpecification( + final ZoneSpecification errorHandlingZoneSpecification = ZoneSpecification( handleUncaughtError: (Zone self, ZoneDelegate parent, Zone zone, dynamic exception, StackTrace stack) { handleUncaughtError(exception, stack); } @@ -546,7 +546,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase Future _runTestBody(Future testBody(), VoidCallback invariantTester) async { assert(inTest); - runApp(new Container(key: new UniqueKey(), child: _preTestMessage)); // Reset the tree to a known state. + runApp(Container(key: UniqueKey(), child: _preTestMessage)); // Reset the tree to a known state. await pump(); final bool autoUpdateGoldensBeforeTest = autoUpdateGoldenFiles; @@ -560,7 +560,7 @@ abstract class TestWidgetsFlutterBinding extends BindingBase // We only try to clean up and verify invariants if we didn't already // fail. If we got an exception already, then we instead leave everything // alone so that we don't cause more spurious errors. - runApp(new Container(key: new UniqueKey(), child: _postTestMessage)); // Unmount any remaining widgets. + runApp(Container(key: UniqueKey(), child: _postTestMessage)); // Unmount any remaining widgets. await pump(); invariantTester(); _verifyAutoUpdateGoldensUnset(autoUpdateGoldensBeforeTest); @@ -603,8 +603,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase void _verifyAutoUpdateGoldensUnset(bool valueBeforeTest) { assert(() { if (autoUpdateGoldenFiles != valueBeforeTest) { - FlutterError.reportError(new FlutterErrorDetails( - exception: new FlutterError( + FlutterError.reportError(FlutterErrorDetails( + exception: FlutterError( 'The value of autoUpdateGoldenFiles was changed by the test.', ), stack: StackTrace.current, @@ -623,8 +623,8 @@ abstract class TestWidgetsFlutterBinding extends BindingBase // So we reset the error reporter to its initial value and then report // this error. reportTestException = valueBeforeTest; - FlutterError.reportError(new FlutterErrorDetails( - exception: new FlutterError( + FlutterError.reportError(FlutterErrorDetails( + exception: FlutterError( 'The value of reportTestException was changed by the test.', ), stack: StackTrace.current, @@ -698,14 +698,14 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { if (hasScheduledFrame) { addTime(const Duration(milliseconds: 500)); _currentFakeAsync.flushMicrotasks(); - handleBeginFrame(new Duration( + handleBeginFrame(Duration( milliseconds: _clock.now().millisecondsSinceEpoch, )); _currentFakeAsync.flushMicrotasks(); handleDrawFrame(); } _currentFakeAsync.flushMicrotasks(); - return new Future.value(); + return Future.value(); }); } @@ -717,7 +717,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { assert(() { if (_pendingAsyncTasks == null) return true; - throw new test_package.TestFailure( + throw test_package.TestFailure( 'Reentrant call to runAsync() denied.\n' 'runAsync() was called, then before its future completed, it ' 'was called again. You must wait for the first returned future ' @@ -726,7 +726,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { }()); final Zone realAsyncZone = Zone.current.fork( - specification: new ZoneSpecification( + specification: ZoneSpecification( scheduleMicrotask: (Zone self, ZoneDelegate parent, Zone zone, void f()) { Zone.root.scheduleMicrotask(f); }, @@ -742,9 +742,9 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { addTime(additionalTime); return realAsyncZone.run(() { - _pendingAsyncTasks = new Completer(); + _pendingAsyncTasks = Completer(); return callback().catchError((dynamic exception, StackTrace stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: exception, stack: stack, library: 'Flutter test framework', @@ -822,7 +822,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { assert(_timeoutTimer == timer); if (_timeoutStopwatch.elapsed > _timeout) { _timeoutCompleter.completeError( - new TimeoutException( + TimeoutException( 'The test exceeded the timeout. It may have hung.\n' 'Consider using "addTime" to increase the timeout before expensive operations.', _timeout, @@ -870,13 +870,13 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { assert(_clock == null); _timeout = timeout; - _timeoutStopwatch = new Stopwatch()..start(); - _timeoutTimer = new Timer.periodic(const Duration(seconds: 1), _checkTimeout); - _timeoutCompleter = new Completer(); + _timeoutStopwatch = Stopwatch()..start(); + _timeoutTimer = Timer.periodic(const Duration(seconds: 1), _checkTimeout); + _timeoutCompleter = Completer(); - final FakeAsync fakeAsync = new FakeAsync(); + final FakeAsync fakeAsync = FakeAsync(); _currentFakeAsync = fakeAsync; // reset in postTest - _clock = fakeAsync.getClock(new DateTime.utc(2015, 1, 1)); + _clock = fakeAsync.getClock(DateTime.utc(2015, 1, 1)); Future testBodyResult; fakeAsync.run((FakeAsync localFakeAsync) { assert(fakeAsync == _currentFakeAsync); @@ -885,7 +885,7 @@ class AutomatedTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { assert(inTest); }); - return new Future.microtask(() async { + return Future.microtask(() async { // testBodyResult is a Future that was created in the Zone of the // fakeAsync. This means that if we await it here, it will register a // microtask to handle the future _in the fake async zone_. We avoid this @@ -1143,7 +1143,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { @override void initRenderView() { assert(renderView == null); - renderView = new _LiveTestRenderView( + renderView = _LiveTestRenderView( configuration: createViewConfiguration(), onNeedPaint: _handleViewNeedsPaint, ); @@ -1175,7 +1175,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { case TestBindingEventSource.test: if (!renderView._pointers.containsKey(event.pointer)) { assert(event.down); - renderView._pointers[event.pointer] = new _LiveTestPointerRecord(event.pointer, event.position); + renderView._pointers[event.pointer] = _LiveTestPointerRecord(event.pointer, event.position); } else { renderView._pointers[event.pointer].position = event.position; if (!event.down) @@ -1199,7 +1199,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { assert(_pendingFrame == null); return TestAsyncUtils.guard(() { if (duration != null) { - new Timer(duration, () { + Timer(duration, () { _expectingFrame = true; scheduleFrame(); }); @@ -1207,7 +1207,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { _expectingFrame = true; scheduleFrame(); } - _pendingFrame = new Completer(); + _pendingFrame = Completer(); return _pendingFrame.future; }); } @@ -1219,7 +1219,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { assert(() { if (!_runningAsyncTasks) return true; - throw new test_package.TestFailure( + throw test_package.TestFailure( 'Reentrant call to runAsync() denied.\n' 'runAsync() was called, then before its future completed, it ' 'was called again. You must wait for the first returned future ' @@ -1231,7 +1231,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { try { return await callback(); } catch (error, stack) { - FlutterError.reportError(new FlutterErrorDetails( + FlutterError.reportError(FlutterErrorDetails( exception: error, stack: stack, library: 'Flutter test framework', @@ -1277,7 +1277,7 @@ class LiveTestWidgetsFlutterBinding extends TestWidgetsFlutterBinding { @override ViewConfiguration createViewConfiguration() { - return new TestViewConfiguration(size: _surfaceSize ?? _kDefaultTestViewportSize); + return TestViewConfiguration(size: _surfaceSize ?? _kDefaultTestViewportSize); } @override @@ -1322,10 +1322,10 @@ class TestViewConfiguration extends ViewConfiguration { shiftX = 0.0; shiftY = (actualHeight - desiredHeight * scale) / 2.0; } - final Matrix4 matrix = new Matrix4.compose( - new Vector3(shiftX, shiftY, 0.0), // translation - new Quaternion.identity(), // rotation - new Vector3(scale, scale, 1.0) // scale + final Matrix4 matrix = Matrix4.compose( + Vector3(shiftX, shiftY, 0.0), // translation + Quaternion.identity(), // rotation + Vector3(scale, scale, 1.0) // scale ); return matrix; } @@ -1356,7 +1356,7 @@ class _LiveTestPointerRecord { _LiveTestPointerRecord( this.pointer, this.position - ) : color = new HSVColor.fromAHSV(0.8, (35.0 * pointer) % 360.0, 1.0, 1.0).toColor(), + ) : color = HSVColor.fromAHSV(0.8, (35.0 * pointer) % 360.0, 1.0, 1.0).toColor(), decay = 1; final int pointer; final Color color; @@ -1391,8 +1391,8 @@ class _LiveTestRenderView extends RenderView { return; } // TODO(ianh): Figure out if the test name is actually RTL. - _label ??= new TextPainter(textAlign: TextAlign.left, textDirection: TextDirection.ltr); - _label.text = new TextSpan(text: value, style: _labelStyle); + _label ??= TextPainter(textAlign: TextAlign.left, textDirection: TextDirection.ltr); + _label.text = TextSpan(text: value, style: _labelStyle); _label.layout(); if (onNeedPaint != null) onNeedPaint(); @@ -1413,14 +1413,14 @@ class _LiveTestRenderView extends RenderView { super.paint(context, offset); if (_pointers.isNotEmpty) { final double radius = configuration.size.shortestSide * 0.05; - final Path path = new Path() - ..addOval(new Rect.fromCircle(center: Offset.zero, radius: radius)) + final Path path = Path() + ..addOval(Rect.fromCircle(center: Offset.zero, radius: radius)) ..moveTo(0.0, -radius * 2.0) ..lineTo(0.0, radius * 2.0) ..moveTo(-radius * 2.0, 0.0) ..lineTo(radius * 2.0, 0.0); final Canvas canvas = context.canvas; - final Paint paint = new Paint() + final Paint paint = Paint() ..strokeWidth = radius / 10.0 ..style = PaintingStyle.stroke; bool dirty = false; @@ -1459,7 +1459,7 @@ StackTrace _unmangle(StackTrace stack) { class _MockHttpOverrides extends HttpOverrides { @override HttpClient createHttpClient(SecurityContext _) { - return new _MockHttpClient(); + return _MockHttpClient(); } } @@ -1500,12 +1500,12 @@ class _MockHttpClient implements HttpClient { @override Future delete(String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future deleteUrl(Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override @@ -1513,62 +1513,62 @@ class _MockHttpClient implements HttpClient { @override Future get(String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future getUrl(Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future head(String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future headUrl(Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future open(String method, String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future openUrl(String method, Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future patch(String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future patchUrl(Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future post(String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future postUrl(Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future put(String host, int port, String path) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } @override Future putUrl(Uri url) { - return new Future.value(new _MockHttpRequest()); + return Future.value(_MockHttpRequest()); } } @@ -1578,7 +1578,7 @@ class _MockHttpRequest extends HttpClientRequest { Encoding encoding; @override - final HttpHeaders headers = new _MockHttpHeaders(); + final HttpHeaders headers = _MockHttpHeaders(); @override void add(List data) {} @@ -1588,12 +1588,12 @@ class _MockHttpRequest extends HttpClientRequest { @override Future addStream(Stream> stream) { - return new Future.value(null); + return Future.value(null); } @override Future close() { - return new Future.value(new _MockHttpResponse()); + return Future.value(_MockHttpResponse()); } @override @@ -1607,7 +1607,7 @@ class _MockHttpRequest extends HttpClientRequest { @override Future flush() { - return new Future.value(null); + return Future.value(null); } @override @@ -1632,7 +1632,7 @@ class _MockHttpRequest extends HttpClientRequest { /// A mocked [HttpClientResponse] which is empty and has a [statusCode] of 400. class _MockHttpResponse extends Stream> implements HttpClientResponse { @override - final HttpHeaders headers = new _MockHttpHeaders(); + final HttpHeaders headers = _MockHttpHeaders(); @override X509Certificate get certificate => null; @@ -1648,7 +1648,7 @@ class _MockHttpResponse extends Stream> implements HttpClientResponse @override Future detachSocket() { - return new Future.error(new UnsupportedError('Mocked response')); + return Future.error(UnsupportedError('Mocked response')); } @override @@ -1667,7 +1667,7 @@ class _MockHttpResponse extends Stream> implements HttpClientResponse @override Future redirect([String method, Uri url, bool followLoops]) { - return new Future.error(new UnsupportedError('Mocked response')); + return Future.error(UnsupportedError('Mocked response')); } @override diff --git a/packages/flutter_test/lib/src/controller.dart b/packages/flutter_test/lib/src/controller.dart index 13d222cf9e..d2c18d2694 100644 --- a/packages/flutter_test/lib/src/controller.dart +++ b/packages/flutter_test/lib/src/controller.dart @@ -180,7 +180,7 @@ abstract class WidgetController { TestAsyncUtils.guardSync(); if (element is StatefulElement) return element.state; - throw new StateError('Widget of type ${element.widget.runtimeType}, with ${finder.description}, is not a StatefulWidget.'); + throw StateError('Widget of type ${element.widget.runtimeType}, with ${finder.description}, is not a StatefulWidget.'); } @@ -372,28 +372,28 @@ abstract class WidgetController { assert(offset.distance > 0.0); assert(speed > 0.0); // speed is pixels/second return TestAsyncUtils.guard(() async { - final TestPointer testPointer = new TestPointer(pointer ?? _getNextPointer()); + final TestPointer testPointer = TestPointer(pointer ?? _getNextPointer()); final HitTestResult result = hitTestOnBinding(startLocation); const int kMoveCount = 50; // Needs to be >= kHistorySize, see _LeastSquaresVelocityTrackerStrategy final double timeStampDelta = 1000.0 * offset.distance / (kMoveCount * speed); double timeStamp = 0.0; double lastTimeStamp = timeStamp; - await sendEventToBinding(testPointer.down(startLocation, timeStamp: new Duration(milliseconds: timeStamp.round())), result); + await sendEventToBinding(testPointer.down(startLocation, timeStamp: Duration(milliseconds: timeStamp.round())), result); if (initialOffset.distance > 0.0) { - await sendEventToBinding(testPointer.move(startLocation + initialOffset, timeStamp: new Duration(milliseconds: timeStamp.round())), result); + await sendEventToBinding(testPointer.move(startLocation + initialOffset, timeStamp: Duration(milliseconds: timeStamp.round())), result); timeStamp += initialOffsetDelay.inMilliseconds; await pump(initialOffsetDelay); } for (int i = 0; i <= kMoveCount; i += 1) { final Offset location = startLocation + initialOffset + Offset.lerp(Offset.zero, offset, i / kMoveCount); - await sendEventToBinding(testPointer.move(location, timeStamp: new Duration(milliseconds: timeStamp.round())), result); + await sendEventToBinding(testPointer.move(location, timeStamp: Duration(milliseconds: timeStamp.round())), result); timeStamp += timeStampDelta; if (timeStamp - lastTimeStamp > frameInterval.inMilliseconds) { - await pump(new Duration(milliseconds: (timeStamp - lastTimeStamp).truncate())); + await pump(Duration(milliseconds: (timeStamp - lastTimeStamp).truncate())); lastTimeStamp = timeStamp; } } - await sendEventToBinding(testPointer.up(timeStamp: new Duration(milliseconds: timeStamp.round())), result); + await sendEventToBinding(testPointer.up(timeStamp: Duration(milliseconds: timeStamp.round())), result); return null; }); } @@ -462,7 +462,7 @@ abstract class WidgetController { /// Forwards the given location to the binding's hitTest logic. HitTestResult hitTestOnBinding(Offset location) { - final HitTestResult result = new HitTestResult(); + final HitTestResult result = HitTestResult(); binding.hitTest(result, location); return result; } @@ -540,7 +540,7 @@ class LiveWidgetController extends WidgetController { @override Future pump(Duration duration) async { if (duration != null) - await new Future.delayed(duration); + await Future.delayed(duration); binding.scheduleFrame(); await binding.endOfFrame; } diff --git a/packages/flutter_test/lib/src/finders.dart b/packages/flutter_test/lib/src/finders.dart index 2133d0791f..2f0c4bf7f6 100644 --- a/packages/flutter_test/lib/src/finders.dart +++ b/packages/flutter_test/lib/src/finders.dart @@ -34,7 +34,7 @@ class CommonFinders { /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder text(String text, { bool skipOffstage = true }) => new _TextFinder(text, skipOffstage: skipOffstage); + Finder text(String text, { bool skipOffstage = true }) => _TextFinder(text, skipOffstage: skipOffstage); /// Looks for widgets that contain a [Text] descendant with `text` /// in it. @@ -70,7 +70,7 @@ class CommonFinders { /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder byKey(Key key, { bool skipOffstage = true }) => new _KeyFinder(key, skipOffstage: skipOffstage); + Finder byKey(Key key, { bool skipOffstage = true }) => _KeyFinder(key, skipOffstage: skipOffstage); /// Finds widgets by searching for widgets with a particular type. /// @@ -88,7 +88,7 @@ class CommonFinders { /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder byType(Type type, { bool skipOffstage = true }) => new _WidgetTypeFinder(type, skipOffstage: skipOffstage); + Finder byType(Type type, { bool skipOffstage = true }) => _WidgetTypeFinder(type, skipOffstage: skipOffstage); /// Finds [Icon] widgets containing icon data equal to the `icon` /// argument. @@ -101,7 +101,7 @@ class CommonFinders { /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder byIcon(IconData icon, { bool skipOffstage = true }) => new _WidgetIconFinder(icon, skipOffstage: skipOffstage); + Finder byIcon(IconData icon, { bool skipOffstage = true }) => _WidgetIconFinder(icon, skipOffstage: skipOffstage); /// Looks for widgets that contain an [Icon] descendant displaying [IconData] /// `icon` in it. @@ -143,7 +143,7 @@ class CommonFinders { /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder byElementType(Type type, { bool skipOffstage = true }) => new _ElementTypeFinder(type, skipOffstage: skipOffstage); + Finder byElementType(Type type, { bool skipOffstage = true }) => _ElementTypeFinder(type, skipOffstage: skipOffstage); /// Finds widgets whose current widget is the instance given by the /// argument. @@ -162,7 +162,7 @@ class CommonFinders { /// /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. - Finder byWidget(Widget widget, { bool skipOffstage = true }) => new _WidgetFinder(widget, skipOffstage: skipOffstage); + Finder byWidget(Widget widget, { bool skipOffstage = true }) => _WidgetFinder(widget, skipOffstage: skipOffstage); /// Finds widgets using a widget [predicate]. /// @@ -183,7 +183,7 @@ class CommonFinders { /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. Finder byWidgetPredicate(WidgetPredicate predicate, { String description, bool skipOffstage = true }) { - return new _WidgetPredicateFinder(predicate, description: description, skipOffstage: skipOffstage); + return _WidgetPredicateFinder(predicate, description: description, skipOffstage: skipOffstage); } /// Finds Tooltip widgets with the given message. @@ -225,7 +225,7 @@ class CommonFinders { /// If the `skipOffstage` argument is true (the default), then this skips /// nodes that are [Offstage] or that are from inactive [Route]s. Finder byElementPredicate(ElementPredicate predicate, { String description, bool skipOffstage = true }) { - return new _ElementPredicateFinder(predicate, description: description, skipOffstage: skipOffstage); + return _ElementPredicateFinder(predicate, description: description, skipOffstage: skipOffstage); } /// Finds widgets that are descendants of the [of] parameter and that match @@ -245,7 +245,7 @@ class CommonFinders { /// If the [skipOffstage] argument is true (the default), then nodes that are /// [Offstage] or that are from inactive [Route]s are skipped. Finder descendant({ Finder of, Finder matching, bool matchRoot = false, bool skipOffstage = true }) { - return new _DescendantFinder(of, matching, matchRoot: matchRoot, skipOffstage: skipOffstage); + return _DescendantFinder(of, matching, matchRoot: matchRoot, skipOffstage: skipOffstage); } /// Finds widgets that are ancestors of the [of] parameter and that match @@ -270,7 +270,7 @@ class CommonFinders { /// If the [matchRoot] argument is true then the widget(s) specified by [of] /// will be matched along with the ancestors. Finder ancestor({ Finder of, Finder matching, bool matchRoot = false}) { - return new _AncestorFinder(of, matching, matchRoot: matchRoot); + return _AncestorFinder(of, matching, matchRoot: matchRoot); } } @@ -343,22 +343,22 @@ abstract class Finder { /// Returns a variant of this finder that only matches the first element /// matched by this finder. - Finder get first => new _FirstFinder(this); + Finder get first => _FirstFinder(this); /// Returns a variant of this finder that only matches the last element /// matched by this finder. - Finder get last => new _LastFinder(this); + Finder get last => _LastFinder(this); /// Returns a variant of this finder that only matches the element at the /// given index matched by this finder. - Finder at(int index) => new _IndexFinder(this, index); + Finder at(int index) => _IndexFinder(this, index); /// Returns a variant of this finder that only matches elements reachable by /// a hit test. /// /// The [at] parameter specifies the location relative to the size of the /// target element where the hit test is performed. - Finder hitTestable({ Alignment at = Alignment.center }) => new _HitTestableFinder(this, at); + Finder hitTestable({ Alignment at = Alignment.center }) => _HitTestableFinder(this, at); @override String toString() { @@ -450,7 +450,7 @@ class _HitTestableFinder extends ChainedFinder { final RenderBox box = candidate.renderObject; assert(box != null); final Offset absoluteOffset = box.localToGlobal(alignment.alongSize(box.size)); - final HitTestResult hitResult = new HitTestResult(); + final HitTestResult hitResult = HitTestResult(); WidgetsBinding.instance.hitTest(hitResult, absoluteOffset); for (final HitTestEntry entry in hitResult.path) { if (entry.target == candidate.renderObject) { diff --git a/packages/flutter_test/lib/src/goldens.dart b/packages/flutter_test/lib/src/goldens.dart index ff7330f928..eeab00b7f5 100644 --- a/packages/flutter_test/lib/src/goldens.dart +++ b/packages/flutter_test/lib/src/goldens.dart @@ -119,13 +119,13 @@ class TrivialComparator implements GoldenFileComparator { @override Future compare(Uint8List imageBytes, Uri golden) { debugPrint('Golden file comparison requested for "$golden"; skipping...'); - return new Future.value(true); + return Future.value(true); } @override Future update(Uri golden, Uint8List imageBytes) { // [autoUpdateGoldenFiles] should never be set in a live widget binding. - throw new StateError('goldenFileComparator has not been initialized'); + throw StateError('goldenFileComparator has not been initialized'); } } @@ -153,7 +153,7 @@ class LocalFileComparator implements GoldenFileComparator { _path = _getPath(pathStyle); static path.Context _getPath(path.Style style) { - return new path.Context(style: style ?? path.Style.platform); + return path.Context(style: style ?? path.Style.platform); } static Uri _getBasedir(Uri testFile, path.Style pathStyle) { @@ -178,7 +178,7 @@ class LocalFileComparator implements GoldenFileComparator { Future compare(Uint8List imageBytes, Uri golden) async { final File goldenFile = _getFile(golden); if (!goldenFile.existsSync()) { - throw new test_package.TestFailure('Could not be compared against non-existent file: "$golden"'); + throw test_package.TestFailure('Could not be compared against non-existent file: "$golden"'); } final List goldenBytes = await goldenFile.readAsBytes(); return _areListsEqual(imageBytes, goldenBytes); @@ -192,7 +192,7 @@ class LocalFileComparator implements GoldenFileComparator { } File _getFile(Uri golden) { - return new File(_path.join(_path.fromUri(basedir), _path.fromUri(golden.path))); + return File(_path.join(_path.fromUri(basedir), _path.fromUri(golden.path))); } static bool _areListsEqual(List list1, List list2) { diff --git a/packages/flutter_test/lib/src/matchers.dart b/packages/flutter_test/lib/src/matchers.dart index 762a6437ec..18d68acc5b 100644 --- a/packages/flutter_test/lib/src/matchers.dart +++ b/packages/flutter_test/lib/src/matchers.dart @@ -81,7 +81,7 @@ const Matcher findsOneWidget = _FindsWidgetMatcher(1, 1); /// * [findsNothing], when you want the finder to not find anything. /// * [findsWidgets], when you want the finder to find one or more widgets. /// * [findsOneWidget], when you want the finder to find exactly one widget. -Matcher findsNWidgets(int n) => new _FindsWidgetMatcher(n, n); +Matcher findsNWidgets(int n) => _FindsWidgetMatcher(n, n); /// Asserts that the [Finder] locates the a single widget that has at /// least one [Offstage] widget ancestor. @@ -194,7 +194,7 @@ final Matcher isAssertionError = isInstanceOf(); /// A matcher that compares the type of the actual value to the type argument T. // TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 /// Asserts that two [double]s are equal, within some tolerated error. /// @@ -211,7 +211,7 @@ Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefe /// * [inInclusiveRange], which matches if the argument is in a specified /// range. Matcher moreOrLessEquals(double value, { double epsilon = 1e-10 }) { - return new _MoreOrLessEquals(value, epsilon); + return _MoreOrLessEquals(value, epsilon); } /// Asserts that two [String]s are equal after normalizing likely hash codes. @@ -228,7 +228,7 @@ Matcher moreOrLessEquals(double value, { double epsilon = 1e-10 }) { /// * [TreeDiagnosticsMixin.toStringDeep], a method that returns a [String] /// typically containing multiple hash codes. Matcher equalsIgnoringHashCodes(String value) { - return new _EqualsIgnoringHashCodes(value); + return _EqualsIgnoringHashCodes(value); } /// A matcher for [MethodCall]s, asserting that it has the specified @@ -236,7 +236,7 @@ Matcher equalsIgnoringHashCodes(String value) { /// /// Arguments checking implements deep equality for [List] and [Map] types. Matcher isMethodCall(String name, {@required dynamic arguments}) { - return new _IsMethodCall(name, arguments); + return _IsMethodCall(name, arguments); } /// Asserts that 2 paths cover the same area by sampling multiple points. @@ -249,7 +249,7 @@ Matcher isMethodCall(String name, {@required dynamic arguments}) { /// the area you expect to paint in for [areaToCompare] to catch errors where /// the path draws outside the expected area. Matcher coversSameAreaAs(Path expectedPath, {@required Rect areaToCompare, int sampleSize = 20}) - => new _CoversSameAreaAs(expectedPath, areaToCompare: areaToCompare, sampleSize: sampleSize); + => _CoversSameAreaAs(expectedPath, areaToCompare: areaToCompare, sampleSize: sampleSize); /// Asserts that a [Finder], [Future], or [ui.Image] matches the /// golden image file identified by [key]. @@ -279,11 +279,11 @@ Matcher coversSameAreaAs(Path expectedPath, {@required Rect areaToCompare, int s /// may swap out the backend for this matcher. Matcher matchesGoldenFile(dynamic key) { if (key is Uri) { - return new _MatchesGoldenFile(key); + return _MatchesGoldenFile(key); } else if (key is String) { - return new _MatchesGoldenFile.forStringPath(key); + return _MatchesGoldenFile.forStringPath(key); } - throw new ArgumentError('Unexpected type for golden file: ${key.runtimeType}'); + throw ArgumentError('Unexpected type for golden file: ${key.runtimeType}'); } /// Asserts that a [SemanticsData] contains the specified information. @@ -448,12 +448,12 @@ Matcher matchesSemanticsData({ actions.add(SemanticsAction.moveCursorBackwardByWord); SemanticsHintOverrides hintOverrides; if (onTapHint != null || onLongPressHint != null) - hintOverrides = new SemanticsHintOverrides( + hintOverrides = SemanticsHintOverrides( onTapHint: onTapHint, onLongPressHint: onLongPressHint, ); - return new _MatchesSemanticsData( + return _MatchesSemanticsData( label: label, hint: hint, value: value, @@ -489,7 +489,7 @@ Matcher matchesSemanticsData({ /// * [iOSTapTargetGuideline], for iOS minimum tapable area guidelines. /// * [textContrastGuideline], for WCAG minimum text contrast guidelines. AsyncMatcher meetsGuideline(AccessibilityGuideline guideline) { - return new _MatchesAccessibilityGuideline(guideline); + return _MatchesAccessibilityGuideline(guideline); } /// The inverse matcher of [meetsGuideline]. @@ -497,7 +497,7 @@ AsyncMatcher meetsGuideline(AccessibilityGuideline guideline) { /// This is needed because the [isNot] matcher does not compose with an /// [AsyncMatcher]. AsyncMatcher doesNotMeetGuideline(AccessibilityGuideline guideline) { - return new _DoesNotMatchAccessibilityGuideline(guideline); + return _DoesNotMatchAccessibilityGuideline(guideline); } class _FindsWidgetMatcher extends Matcher { @@ -678,10 +678,10 @@ class _EqualsIgnoringHashCodes extends Matcher { final String _value; - static final Object _mismatchedValueKey = new Object(); + static final Object _mismatchedValueKey = Object(); static String _normalize(String s) { - return s.replaceAll(new RegExp(r'#[0-9a-f]{5}'), '#00000'); + return s.replaceAll(RegExp(r'#[0-9a-f]{5}'), '#00000'); } @override @@ -751,7 +751,7 @@ bool _isAllTreeConnectorCharacters(String line) { class _HasGoodToStringDeep extends Matcher { const _HasGoodToStringDeep(); - static final Object _toStringDeepErrorDescriptionKey = new Object(); + static final Object _toStringDeepErrorDescriptionKey = Object(); @override bool matches(dynamic object, Map matchState) { @@ -810,7 +810,7 @@ class _HasGoodToStringDeep extends Matcher { prefixIssues.add('Line ${i+1} does not contain the expected prefix.'); } - final StringBuffer errorDescription = new StringBuffer(); + final StringBuffer errorDescription = StringBuffer(); if (issues.isNotEmpty) { errorDescription.writeln('Bad toStringDeep():'); errorDescription.writeln(description); @@ -960,14 +960,14 @@ Matcher within({ distanceFunction ??= _kStandardDistanceFunctions[from.runtimeType]; if (distanceFunction == null) { - throw new ArgumentError( + throw ArgumentError( 'The specified distanceFunction was null, and a standard distance ' 'function was not found for type ${from.runtimeType} of the provided ' '`from` argument.' ); } - return new _IsWithinDistance(distanceFunction, from, distance); + return _IsWithinDistance(distanceFunction, from, distance); } class _IsWithinDistance extends Matcher { @@ -986,7 +986,7 @@ class _IsWithinDistance extends Matcher { final T test = object; final num distance = distanceFunction(test, value); if (distance < 0) { - throw new ArgumentError( + throw ArgumentError( 'Invalid distance function was used to compare a ${value.runtimeType} ' 'to a ${object.runtimeType}. The function must return a non-negative ' 'double value, but it returned $distance.' @@ -1098,14 +1098,14 @@ const Matcher hasNoImmediateClip = _MatchAnythingExceptClip(); /// is a [RenderClipRRect] with no clipper set, and border radius equals to /// [borderRadius], or an equivalent [RenderClipPath]. Matcher clipsWithBoundingRRect({@required BorderRadius borderRadius}) { - return new _ClipsWithBoundingRRect(borderRadius: borderRadius); + return _ClipsWithBoundingRRect(borderRadius: borderRadius); } /// Asserts that a [Finder] locates a single object whose root RenderObject /// is a [RenderClipPath] with a [ShapeBorderClipper] that clips to /// [shape]. Matcher clipsWithShapeBorder({@required ShapeBorder shape}) { - return new _ClipsWithShapeBorder(shape: shape); + return _ClipsWithShapeBorder(shape: shape); } /// Asserts that a [Finder] locates a single object whose root RenderObject @@ -1130,7 +1130,7 @@ Matcher rendersOnPhysicalModel({ BorderRadius borderRadius, double elevation, }) { - return new _RendersOnPhysicalModel( + return _RendersOnPhysicalModel( shape: shape, borderRadius: borderRadius, elevation: elevation, @@ -1146,7 +1146,7 @@ Matcher rendersOnPhysicalShape({ ShapeBorder shape, double elevation, }) { - return new _RendersOnPhysicalShape( + return _RendersOnPhysicalShape( shape: shape, elevation: elevation, ); @@ -1438,7 +1438,7 @@ class _CoversSameAreaAs extends Matcher { }) : maxHorizontalNoise = areaToCompare.width / sampleSize, maxVerticalNoise = areaToCompare.height / sampleSize { // Use a fixed random seed to make sure tests are deterministic. - random = new math.Random(1); + random = math.Random(1); } final Path expectedPath; @@ -1452,7 +1452,7 @@ class _CoversSameAreaAs extends Matcher { bool matches(covariant Path actualPath, Map matchState) { for (int i = 0; i < sampleSize; i += 1) { for (int j = 0; j < sampleSize; j += 1) { - final Offset offset = new Offset( + final Offset offset = Offset( i * (areaToCompare.width / sampleSize), j * (areaToCompare.height / sampleSize) ); @@ -1460,7 +1460,7 @@ class _CoversSameAreaAs extends Matcher { if (!_samplePoint(matchState, actualPath, offset)) return false; - final Offset noise = new Offset( + final Offset noise = Offset( maxHorizontalNoise * random.nextDouble(), maxVerticalNoise * random.nextDouble(), ); @@ -1526,7 +1526,7 @@ class _MatchesGoldenFile extends AsyncMatcher { if (item is Future) { imageFuture = item; } else if (item is ui.Image) { - imageFuture = new Future.value(item); + imageFuture = Future.value(item); } else { final Finder finder = item; final Iterable elements = finder.evaluate(); @@ -1661,11 +1661,11 @@ class _MatchesSemanticsData extends Matcher { final List providedCustomActions = data.customSemanticsActionIds.map((int id) { return CustomSemanticsAction.getAction(id); }).toList(); - final List expectedCustomActions = new List.from(customActions ?? const []); + final List expectedCustomActions = List.from(customActions ?? const []); if (hintOverrides?.onTapHint != null) - expectedCustomActions.add(new CustomSemanticsAction.overridingAction(hint: hintOverrides.onTapHint, action: SemanticsAction.tap)); + expectedCustomActions.add(CustomSemanticsAction.overridingAction(hint: hintOverrides.onTapHint, action: SemanticsAction.tap)); if (hintOverrides?.onLongPressHint != null) - expectedCustomActions.add(new CustomSemanticsAction.overridingAction(hint: hintOverrides.onLongPressHint, action: SemanticsAction.longPress)); + expectedCustomActions.add(CustomSemanticsAction.overridingAction(hint: hintOverrides.onLongPressHint, action: SemanticsAction.longPress)); if (expectedCustomActions.length != providedCustomActions.length) return failWithDescription(matchState, 'custom actions where: $providedCustomActions'); int sortActions(CustomSemanticsAction left, CustomSemanticsAction right) { diff --git a/packages/flutter_test/lib/src/stack_manipulation.dart b/packages/flutter_test/lib/src/stack_manipulation.dart index a61381a7f7..540e628f01 100644 --- a/packages/flutter_test/lib/src/stack_manipulation.dart +++ b/packages/flutter_test/lib/src/stack_manipulation.dart @@ -12,11 +12,11 @@ /// the test_widgets [expect] function, this will fill the given StringBuffer /// with the precise file and line number that called that function. int reportExpectCall(StackTrace stack, StringBuffer information) { - final RegExp line0 = new RegExp(r'^#0 +fail \(.+\)$'); - final RegExp line1 = new RegExp(r'^#1 +_expect \(.+\)$'); - final RegExp line2 = new RegExp(r'^#2 +expect \(.+\)$'); - final RegExp line3 = new RegExp(r'^#3 +expect \(.+\)$'); - final RegExp line4 = new RegExp(r'^#4 +[^(]+ \((.+?):([0-9]+)(?::[0-9]+)?\)$'); + final RegExp line0 = RegExp(r'^#0 +fail \(.+\)$'); + final RegExp line1 = RegExp(r'^#1 +_expect \(.+\)$'); + final RegExp line2 = RegExp(r'^#2 +expect \(.+\)$'); + final RegExp line3 = RegExp(r'^#3 +expect \(.+\)$'); + final RegExp line4 = RegExp(r'^#4 +[^(]+ \((.+?):([0-9]+)(?::[0-9]+)?\)$'); final List stackLines = stack.toString().split('\n'); if (line0.firstMatch(stackLines[0]) != null && line1.firstMatch(stackLines[1]) != null && diff --git a/packages/flutter_test/lib/src/test_async_utils.dart b/packages/flutter_test/lib/src/test_async_utils.dart index e70b5401e7..6307770edd 100644 --- a/packages/flutter_test/lib/src/test_async_utils.dart +++ b/packages/flutter_test/lib/src/test_async_utils.dart @@ -64,7 +64,7 @@ class TestAsyncUtils { _scopeStack: true // so we can recognize this as our own zone } ); - final _AsyncScope scope = new _AsyncScope(StackTrace.current, zone); + final _AsyncScope scope = _AsyncScope(StackTrace.current, zone); _scopeStack.add(scope); final Future result = scope.zone.run>(body); T resultValue; // This is set when the body of work completes with a result value. @@ -73,7 +73,7 @@ class TestAsyncUtils { assert(_scopeStack.contains(scope)); bool leaked = false; _AsyncScope closedScope; - final StringBuffer message = new StringBuffer(); + final StringBuffer message = StringBuffer(); while (_scopeStack.isNotEmpty) { closedScope = _scopeStack.removeLast(); if (closedScope == scope) @@ -100,11 +100,11 @@ class TestAsyncUtils { message.writeln('The stack trace associated with this exception was:'); FlutterError.defaultStackFilter(stack.toString().trimRight().split('\n')).forEach(message.writeln); } - throw new FlutterError(message.toString().trimRight()); + throw FlutterError(message.toString().trimRight()); } if (error != null) - return new Future.error(error, stack); - return new Future.value(resultValue); + return Future.error(error, stack); + return Future.value(resultValue); } return result.then( (T value) { @@ -182,7 +182,7 @@ class TestAsyncUtils { assert(candidateScope.zone != null); } while (candidateScope.zone != zone); assert(scope != null); - final StringBuffer message = new StringBuffer(); + final StringBuffer message = StringBuffer(); message.writeln('Guarded function conflict. You must use "await" with all Future-returning test APIs.'); final _StackEntry originalGuarder = _findResponsibleMethod(scope.creationStack, 'guard', message); final _StackEntry collidingGuarder = _findResponsibleMethod(StackTrace.current, 'guardSync', message); @@ -258,7 +258,7 @@ class TestAsyncUtils { ); message.writeln(FlutterError.defaultStackFilter(scope.creationStack.toString().trimRight().split('\n')).join('\n')); } - throw new FlutterError(message.toString().trimRight()); + throw FlutterError(message.toString().trimRight()); } /// Verifies that there are no guarded methods currently pending (see [guard]). @@ -266,7 +266,7 @@ class TestAsyncUtils { /// This is used at the end of tests to ensure that nothing leaks out of the test. static void verifyAllScopesClosed() { if (_scopeStack.isNotEmpty) { - final StringBuffer message = new StringBuffer(); + final StringBuffer message = StringBuffer(); message.writeln('Asynchronous call to guarded function leaked. You must use "await" with all Future-returning test APIs.'); for (_AsyncScope scope in _scopeStack) { final _StackEntry guarder = _findResponsibleMethod(scope.creationStack, 'guard', message); @@ -280,7 +280,7 @@ class TestAsyncUtils { ); } } - throw new FlutterError(message.toString().trimRight()); + throw FlutterError(message.toString().trimRight()); } } @@ -293,7 +293,7 @@ class TestAsyncUtils { final List stack = rawStack.toString().split('\n').where(_stripAsynchronousSuspensions).toList(); assert(stack.last == ''); stack.removeLast(); - final RegExp getClassPattern = new RegExp(r'^#[0-9]+ +([^. ]+)'); + final RegExp getClassPattern = RegExp(r'^#[0-9]+ +([^. ]+)'); Match lineMatch; int index = -1; do { // skip past frames that are from this class @@ -305,7 +305,7 @@ class TestAsyncUtils { } while (lineMatch.group(1) == _className); // try to parse the stack to find the interesting frame if (index < stack.length) { - final RegExp guardPattern = new RegExp(r'^#[0-9]+ +(?:([^. ]+)\.)?([^. ]+)'); + final RegExp guardPattern = RegExp(r'^#[0-9]+ +(?:([^. ]+)\.)?([^. ]+)'); final Match guardMatch = guardPattern.matchAsPrefix(stack[index]); // find the class that called us if (guardMatch != null) { assert(guardMatch.groupCount == 2); @@ -323,13 +323,13 @@ class TestAsyncUtils { break; } if (index < stack.length) { - final RegExp callerPattern = new RegExp(r'^#[0-9]+ .* \((.+?):([0-9]+)(?::[0-9]+)?\)$'); + final RegExp callerPattern = RegExp(r'^#[0-9]+ .* \((.+?):([0-9]+)(?::[0-9]+)?\)$'); final Match callerMatch = callerPattern.matchAsPrefix(stack[index]); // extract the caller's info if (callerMatch != null) { assert(callerMatch.groupCount == 2); final String callerFile = callerMatch.group(1); final String callerLine = callerMatch.group(2); - return new _StackEntry(guardClass, guardMethod, callerFile, callerLine); + return _StackEntry(guardClass, guardMethod, callerFile, callerLine); } else { // One reason you might get here is if the guarding method was called directly from // a 'dart:' API, like from the Future/microtask mechanism, because dart: URLs in the diff --git a/packages/flutter_test/lib/src/test_exception_reporter.dart b/packages/flutter_test/lib/src/test_exception_reporter.dart index df8386b846..ac50aa4f45 100644 --- a/packages/flutter_test/lib/src/test_exception_reporter.dart +++ b/packages/flutter_test/lib/src/test_exception_reporter.dart @@ -39,4 +39,4 @@ void _defaultTestExceptionReporter(FlutterErrorDetails errorDetails, String test test_package.registerException('Test failed. See exception logs above.$additional', _emptyStackTrace); } -final StackTrace _emptyStackTrace = new stack_trace.Chain(const []); +final StackTrace _emptyStackTrace = stack_trace.Chain(const []); diff --git a/packages/flutter_test/lib/src/test_pointer.dart b/packages/flutter_test/lib/src/test_pointer.dart index 4328046c76..f0ef3b0561 100644 --- a/packages/flutter_test/lib/src/test_pointer.dart +++ b/packages/flutter_test/lib/src/test_pointer.dart @@ -52,7 +52,7 @@ class TestPointer { assert(!isDown); _isDown = true; _location = newLocation; - return new PointerDownEvent( + return PointerDownEvent( timeStamp: timeStamp, pointer: pointer, position: location @@ -68,7 +68,7 @@ class TestPointer { assert(isDown); final Offset delta = newLocation - location; _location = newLocation; - return new PointerMoveEvent( + return PointerMoveEvent( timeStamp: timeStamp, pointer: pointer, position: newLocation, @@ -86,7 +86,7 @@ class TestPointer { PointerUpEvent up({ Duration timeStamp = Duration.zero }) { assert(isDown); _isDown = false; - return new PointerUpEvent( + return PointerUpEvent( timeStamp: timeStamp, pointer: pointer, position: location @@ -103,7 +103,7 @@ class TestPointer { PointerCancelEvent cancel({ Duration timeStamp = Duration.zero }) { assert(isDown); _isDown = false; - return new PointerCancelEvent( + return PointerCancelEvent( timeStamp: timeStamp, pointer: pointer, position: location @@ -145,16 +145,16 @@ class TestGesture { return TestAsyncUtils.guard(() async { // dispatch down event final HitTestResult hitTestResult = hitTester(downLocation); - final TestPointer testPointer = new TestPointer(pointer); + final TestPointer testPointer = TestPointer(pointer); await dispatcher(testPointer.down(downLocation), hitTestResult); // create a TestGesture - result = new TestGesture._(dispatcher, hitTestResult, testPointer); + result = TestGesture._(dispatcher, hitTestResult, testPointer); return null; }).then((Null value) { return result; }, onError: (dynamic error, StackTrace stack) { - return new Future.error(error, stack); + return Future.error(error, stack); }); } diff --git a/packages/flutter_test/lib/src/test_text_input.dart b/packages/flutter_test/lib/src/test_text_input.dart index b1075c6a16..851ea9ad44 100644 --- a/packages/flutter_test/lib/src/test_text_input.dart +++ b/packages/flutter_test/lib/src/test_text_input.dart @@ -104,11 +104,11 @@ class TestTextInput { // Not using the `expect` function because in the case of a FlutterDriver // test this code does not run in a package:test test zone. if (_client == 0) - throw new TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.'); + throw TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.'); BinaryMessages.handlePlatformMessage( SystemChannels.textInput.name, SystemChannels.textInput.codec.encodeMethodCall( - new MethodCall( + MethodCall( 'TextInputClient.updateEditingState', [_client, value.toJSON()], ), @@ -119,7 +119,7 @@ class TestTextInput { /// Simulates the user typing the given text. void enterText(String text) { - updateEditingValue(new TextEditingValue( + updateEditingValue(TextEditingValue( text: text, )); } @@ -132,15 +132,15 @@ class TestTextInput { // Not using the `expect` function because in the case of a FlutterDriver // test this code does not run in a package:test test zone. if (_client == 0) { - throw new TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.'); + throw TestFailure('Tried to use TestTextInput with no keyboard attached. You must use WidgetTester.showKeyboard() first.'); } - final Completer completer = new Completer(); + final Completer completer = Completer(); BinaryMessages.handlePlatformMessage( SystemChannels.textInput.name, SystemChannels.textInput.codec.encodeMethodCall( - new MethodCall( + MethodCall( 'TextInputClient.performAction', [_client, action.toString()], ), diff --git a/packages/flutter_test/lib/src/test_vsync.dart b/packages/flutter_test/lib/src/test_vsync.dart index 80d88fe96a..e5c89550fa 100644 --- a/packages/flutter_test/lib/src/test_vsync.dart +++ b/packages/flutter_test/lib/src/test_vsync.dart @@ -13,5 +13,5 @@ class TestVSync implements TickerProvider { const TestVSync(); @override - Ticker createTicker(TickerCallback onTick) => new Ticker(onTick); + Ticker createTicker(TickerCallback onTick) => Ticker(onTick); } diff --git a/packages/flutter_test/lib/src/widget_tester.dart b/packages/flutter_test/lib/src/widget_tester.dart index ba31d9a82a..df32b7819a 100644 --- a/packages/flutter_test/lib/src/widget_tester.dart +++ b/packages/flutter_test/lib/src/widget_tester.dart @@ -61,7 +61,7 @@ void testWidgets(String description, WidgetTesterCallback callback, { test_package.Timeout timeout }) { final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); - final WidgetTester tester = new WidgetTester._(binding); + final WidgetTester tester = WidgetTester._(binding); timeout ??= binding.defaultTestTimeout; test_package.test( description, @@ -131,12 +131,12 @@ Future benchmarkWidgets(WidgetTesterCallback callback) { }()); final TestWidgetsFlutterBinding binding = TestWidgetsFlutterBinding.ensureInitialized(); assert(binding is! AutomatedTestWidgetsFlutterBinding); - final WidgetTester tester = new WidgetTester._(binding); + final WidgetTester tester = WidgetTester._(binding); tester._recordNumberOfSemanticsHandles(); return binding.runTest( () => callback(tester), tester._endOfTestVerifications, - ) ?? new Future.value(); + ) ?? Future.value(); } /// Assert that `actual` matches `matcher`. @@ -296,7 +296,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker final DateTime endTime = binding.clock.fromNowBy(timeout); do { if (binding.clock.now().isAfter(endTime)) - throw new FlutterError('pumpAndSettle timed out'); + throw FlutterError('pumpAndSettle timed out'); await binding.pump(duration, phase); count += 1; } while (binding.hasScheduledFrame); @@ -492,8 +492,8 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker @override Ticker createTicker(TickerCallback onTick) { - _tickers ??= new Set<_TestTicker>(); - final _TestTicker result = new _TestTicker(onTick, _removeTicker); + _tickers ??= Set<_TestTicker>(); + final _TestTicker result = _TestTicker(onTick, _removeTicker); _tickers.add(result); return result; } @@ -515,7 +515,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker if (_tickers != null) { for (Ticker ticker in _tickers) { if (ticker.isActive) { - throw new FlutterError( + throw FlutterError( 'A Ticker was active $when.\n' 'All Tickers must be disposed. Tickers used by AnimationControllers ' 'should be disposed by calling dispose() on the AnimationController itself. ' @@ -535,7 +535,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker void _verifySemanticsHandlesWereDisposed() { assert(_lastRecordedSemanticsHandles != null); if (binding.pipelineOwner.debugOutstandingSemanticsHandles > _lastRecordedSemanticsHandles) { - throw new FlutterError( + throw FlutterError( 'A SemanticsHandle was active at the end of the test.\n' 'All SemanticsHandle instances must be disposed by calling dispose() on ' 'the SemanticsHandle. If your test uses SemanticsTester, it is ' @@ -628,13 +628,13 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker /// if no semantics are found or are not enabled. SemanticsData getSemanticsData(Finder finder) { if (binding.pipelineOwner.semanticsOwner == null) - throw new StateError('Semantics are not enabled.'); + throw StateError('Semantics are not enabled.'); final Iterable candidates = finder.evaluate(); if (candidates.isEmpty) { - throw new StateError('Finder returned no matching elements.'); + throw StateError('Finder returned no matching elements.'); } if (candidates.length > 1) { - throw new StateError('Finder returned more than one element.'); + throw StateError('Finder returned more than one element.'); } final Element element = candidates.single; RenderObject renderObject = element.findRenderObject(); @@ -644,7 +644,7 @@ class WidgetTester extends WidgetController implements HitTestDispatcher, Ticker result = renderObject?.debugSemantics; } if (result == null) - throw new StateError('No Semantics data found.'); + throw StateError('No Semantics data found.'); return result.getSemanticsData(); } diff --git a/packages/flutter_test/test/accessibility_test.dart b/packages/flutter_test/test/accessibility_test.dart index 4026c9c52f..7c32847c6d 100644 --- a/packages/flutter_test/test/accessibility_test.dart +++ b/packages/flutter_test/test/accessibility_test.dart @@ -22,7 +22,7 @@ void main() { testWidgets('white text on black background - Text Widget - direct style', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new Container( + Container( width: 200.0, height: 200.0, color: Colors.black, @@ -39,9 +39,9 @@ void main() { testWidgets('black text on white background - Text Widget - inherited style', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new DefaultTextStyle( + DefaultTextStyle( style: const TextStyle(fontSize: 14.0, color: Colors.black), - child: new Container( + child: Container( color: Colors.white, child: const Text('this is a test'), ), @@ -54,9 +54,9 @@ void main() { testWidgets('white text on black background - Text Widget - inherited style', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new DefaultTextStyle( + DefaultTextStyle( style: const TextStyle(fontSize: 14.0, color: Colors.white), - child: new Container( + child: Container( width: 200.0, height: 200.0, color: Colors.black, @@ -70,15 +70,15 @@ void main() { testWidgets('Material text field - amber on amber', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Container( + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Container( width: 200.0, height: 200.0, color: Colors.amberAccent, - child: new TextField( + child: TextField( style: const TextStyle(color: Colors.amber), - controller: new TextEditingController(text: 'this is a test'), + controller: TextEditingController(text: 'this is a test'), ), ), ), @@ -89,11 +89,11 @@ void main() { testWidgets('Material text field - default style', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - await tester.pumpWidget(new MaterialApp( - home: new Scaffold( - body: new Center( - child: new TextField( - controller: new TextEditingController(text: 'this is a test'), + await tester.pumpWidget(MaterialApp( + home: Scaffold( + body: Center( + child: TextField( + controller: TextEditingController(text: 'this is a test'), ), ), ), @@ -106,7 +106,7 @@ void main() { testWidgets('yellow text on yellow background fails with correct message', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new Container( + Container( width: 200.0, height: 200.0, color: Colors.yellow, @@ -131,10 +131,10 @@ void main() { testWidgets('label without corresponding text is skipped', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new Semantics( + Semantics( label: 'This is not text', container: true, - child: new Container( + child: Container( width: 200.0, height: 200.0, child: const Placeholder(), @@ -150,11 +150,11 @@ void main() { testWidgets('offscreen text is skipped', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new Stack( + Stack( children: [ - new Positioned( + Positioned( left: -300.0, - child: new Container( + child: Container( width: 200.0, height: 200.0, color: Colors.yellow, @@ -178,10 +178,10 @@ void main() { testWidgets('Tappable box at 48 by 48', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new SizedBox( + SizedBox( width: 48.0, height: 48.0, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, ), ), @@ -193,10 +193,10 @@ void main() { testWidgets('Tappable box at 47 by 48', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new SizedBox( + SizedBox( width: 47.0, height: 48.0, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, ), ), @@ -208,10 +208,10 @@ void main() { testWidgets('Tappable box at 48 by 47', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new SizedBox( + SizedBox( width: 48.0, height: 47.0, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, ), ), @@ -223,12 +223,12 @@ void main() { testWidgets('Tappable box at 48 by 48 shrunk by transform', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new Transform.scale( + Transform.scale( scale: 0.5, // should have new height of 24 by 24. - child: new SizedBox( + child: SizedBox( width: 48.0, height: 48.0, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, ), ), @@ -241,10 +241,10 @@ void main() { testWidgets('Too small tap target fails with the correct message', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new SizedBox( + SizedBox( width: 48.0, height: 47.0, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, ), ), @@ -260,18 +260,18 @@ void main() { testWidgets('Box that overlaps edge of window is skipped', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); - final Widget smallBox = new SizedBox( + final Widget smallBox = SizedBox( width: 48.0, height: 47.0, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, ), ); await tester.pumpWidget( - new MaterialApp( - home: new Stack( + MaterialApp( + home: Stack( children: [ - new Positioned( + Positioned( left: 0.0, top: -1.0, child: smallBox, @@ -285,10 +285,10 @@ void main() { expect(overlappingTopResult.passed, true); await tester.pumpWidget( - new MaterialApp( - home: new Stack( + MaterialApp( + home: Stack( children: [ - new Positioned( + Positioned( left: -1.0, top: 0.0, child: smallBox, @@ -302,10 +302,10 @@ void main() { expect(overlappingLeftResult.passed, true); await tester.pumpWidget( - new MaterialApp( - home: new Stack( + MaterialApp( + home: Stack( children: [ - new Positioned( + Positioned( bottom: -1.0, child: smallBox, ), @@ -318,10 +318,10 @@ void main() { expect(overlappingBottomResult.passed, true); await tester.pumpWidget( - new MaterialApp( - home: new Stack( + MaterialApp( + home: Stack( children: [ - new Positioned( + Positioned( right: -1.0, child: smallBox, ), @@ -338,15 +338,15 @@ void main() { testWidgets('Does not fail on mergedIntoParent child', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); await tester.pumpWidget(_boilerplate( - new MergeSemantics( - child: new Semantics( + MergeSemantics( + child: Semantics( container: true, - child: new SizedBox( + child: SizedBox( width: 50.0, height: 50.0, - child: new Semantics( + child: Semantics( container: true, - child: new GestureDetector( + child: GestureDetector( onTap: () {}, child: const SizedBox(width: 4.0, height: 4.0), ) @@ -364,7 +364,7 @@ void main() { } Widget _boilerplate(Widget child) { - return new MaterialApp( - home: new Scaffold(body: new Center(child: child)), + return MaterialApp( + home: Scaffold(body: Center(child: child)), ); } diff --git a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart index b52217f87a..46a17cd97e 100644 --- a/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart +++ b/packages/flutter_test/test/custom_exception_reporter/flutter_test_config.dart @@ -21,6 +21,6 @@ Future main(FutureOr testMain()) async { void runTest() { testWidgets('custom exception reporter', (WidgetTester tester) { - throw new StateError('foo'); + throw StateError('foo'); }); } diff --git a/packages/flutter_test/test/finders_test.dart b/packages/flutter_test/test/finders_test.dart index a42925b55f..bb0d43480f 100644 --- a/packages/flutter_test/test/finders_test.dart +++ b/packages/flutter_test/test/finders_test.dart @@ -32,16 +32,16 @@ void main() { group('hitTestable', () { testWidgets('excludes non-hit-testable widgets', (WidgetTester tester) async { await tester.pumpWidget( - _boilerplate(new IndexedStack( + _boilerplate(IndexedStack( sizing: StackFit.expand, children: [ - new GestureDetector( + GestureDetector( key: const ValueKey(0), behavior: HitTestBehavior.opaque, onTap: () { }, child: const SizedBox.expand(), ), - new GestureDetector( + GestureDetector( key: const ValueKey(1), behavior: HitTestBehavior.opaque, onTap: () { }, @@ -58,15 +58,15 @@ void main() { }); testWidgets('ChainedFinders chain properly', (WidgetTester tester) async { - final GlobalKey key1 = new GlobalKey(); + final GlobalKey key1 = GlobalKey(); await tester.pumpWidget( - _boilerplate(new Column( + _boilerplate(Column( children: [ - new Container( + Container( key: key1, child: const Text('1'), ), - new Container( + Container( child: const Text('2'), ) ], @@ -87,7 +87,7 @@ void main() { } Widget _boilerplate(Widget child) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, child: child, ); diff --git a/packages/flutter_test/test/goldens_test.dart b/packages/flutter_test/test/goldens_test.dart index a5b50e3b13..147ed2daea 100644 --- a/packages/flutter_test/test/goldens_test.dart +++ b/packages/flutter_test/test/goldens_test.dart @@ -19,7 +19,7 @@ void main() { final FileSystemStyle style = io.Platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix; - fs = new MemoryFileSystem(style: style); + fs = MemoryFileSystem(style: style); }); /// Converts posix-style paths to the style associated with [fs]. @@ -48,7 +48,7 @@ void main() { fseIdenticalSync: (String p1, String p2) => fs.identicalSync(p1, p2), fseGetType: (String path, bool followLinks) => fs.type(path, followLinks: followLinks), fseGetTypeSync: (String path, bool followLinks) => fs.typeSync(path, followLinks: followLinks), - fsWatch: (String a, int b, bool c) => throw new UnsupportedError('unsupported'), + fsWatch: (String a, int b, bool c) => throw UnsupportedError('unsupported'), fsWatchIsSupported: () => fs.isWatchSupported, ); }); @@ -67,17 +67,17 @@ void main() { LocalFileComparator comparator; setUp(() { - comparator = new LocalFileComparator(fs.file(fix('/golden_test.dart')).uri, pathStyle: fs.path.style); + comparator = LocalFileComparator(fs.file(fix('/golden_test.dart')).uri, pathStyle: fs.path.style); }); test('calculates basedir correctly', () { expect(comparator.basedir, fs.file(fix('/')).uri); - comparator = new LocalFileComparator(fs.file(fix('/foo/bar/golden_test.dart')).uri, pathStyle: fs.path.style); + comparator = LocalFileComparator(fs.file(fix('/foo/bar/golden_test.dart')).uri, pathStyle: fs.path.style); expect(comparator.basedir, fs.directory(fix('/foo/bar/')).uri); }); test('can be instantiated with uri that represents file in same folder', () { - comparator = new LocalFileComparator(Uri.parse('foo_test.dart'), pathStyle: fs.path.style); + comparator = LocalFileComparator(Uri.parse('foo_test.dart'), pathStyle: fs.path.style); expect(comparator.basedir, Uri.parse('./')); }); @@ -85,7 +85,7 @@ void main() { Future doComparison([String golden = 'golden.png']) { final Uri uri = fs.file(fix(golden)).uri; return comparator.compare( - new Uint8List.fromList(_kExpectedBytes), + Uint8List.fromList(_kExpectedBytes), uri, ); } @@ -111,7 +111,7 @@ void main() { ..createSync(recursive: true) ..writeAsBytesSync(_kExpectedBytes); fs.currentDirectory = fix('/foo/bar'); - comparator = new LocalFileComparator(Uri.parse('local_test.dart'), pathStyle: fs.path.style); + comparator = LocalFileComparator(Uri.parse('local_test.dart'), pathStyle: fs.path.style); final bool success = await doComparison('golden.png'); expect(success, isTrue); }); @@ -121,7 +121,7 @@ void main() { ..createSync(recursive: true) ..writeAsBytesSync(_kExpectedBytes); fs.currentDirectory = fix('/foo/bar'); - comparator = new LocalFileComparator(Uri.parse('local_test.dart'), pathStyle: fs.path.style); + comparator = LocalFileComparator(Uri.parse('local_test.dart'), pathStyle: fs.path.style); final bool success = await doComparison('baz/golden.png'); expect(success, isTrue); }); @@ -170,14 +170,14 @@ void main() { test('updates existing file', () async { fs.file(fix('/golden.png')).writeAsBytesSync(_kExpectedBytes); const List newBytes = [11, 12, 13]; - await comparator.update(fs.file('golden.png').uri, new Uint8List.fromList(newBytes)); + await comparator.update(fs.file('golden.png').uri, Uint8List.fromList(newBytes)); expect(fs.file(fix('/golden.png')).readAsBytesSync(), newBytes); }); test('creates non-existent file', () async { expect(fs.file(fix('/foo.png')).existsSync(), isFalse); const List newBytes = [11, 12, 13]; - await comparator.update(fs.file('foo.png').uri, new Uint8List.fromList(newBytes)); + await comparator.update(fs.file('foo.png').uri, Uint8List.fromList(newBytes)); expect(fs.file(fix('/foo.png')).existsSync(), isTrue); expect(fs.file(fix('/foo.png')).readAsBytesSync(), newBytes); }); diff --git a/packages/flutter_test/test/matchers_test.dart b/packages/flutter_test/test/matchers_test.dart index 1ad12adcb1..166ef1cc84 100644 --- a/packages/flutter_test/test/matchers_test.dart +++ b/packages/flutter_test/test/matchers_test.dart @@ -32,7 +32,7 @@ class _MockToStringDeep { List _lines; String toStringDeep({ String prefixLineOne = '', String prefixOtherLines = '' }) { - final StringBuffer sb = new StringBuffer(); + final StringBuffer sb = StringBuffer(); if (_lines.isNotEmpty) sb.write('$prefixLineOne${_lines.first}'); @@ -52,59 +52,59 @@ void main() { expect('Hello\nHello', isNot(hasOneLineDescription)); expect(' Hello', isNot(hasOneLineDescription)); expect('Hello ', isNot(hasOneLineDescription)); - expect(new Object(), isNot(hasOneLineDescription)); + expect(Object(), isNot(hasOneLineDescription)); }); test('hasAGoodToStringDeep', () { - expect(new _MockToStringDeep('Hello\n World\n'), hasAGoodToStringDeep); + expect(_MockToStringDeep('Hello\n World\n'), hasAGoodToStringDeep); // Not terminated with a line break. - expect(new _MockToStringDeep('Hello\n World'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('Hello\n World'), isNot(hasAGoodToStringDeep)); // Trailing whitespace on last line. - expect(new _MockToStringDeep('Hello\n World \n'), + expect(_MockToStringDeep('Hello\n World \n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('Hello\n World\t\n'), + expect(_MockToStringDeep('Hello\n World\t\n'), isNot(hasAGoodToStringDeep)); // Leading whitespace on line 1. - expect(new _MockToStringDeep(' Hello\n World \n'), + expect(_MockToStringDeep(' Hello\n World \n'), isNot(hasAGoodToStringDeep)); // Single line. - expect(new _MockToStringDeep('Hello World'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('Hello World\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('Hello World'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('Hello World\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('Hello: World\nFoo: bar\n'), + expect(_MockToStringDeep('Hello: World\nFoo: bar\n'), hasAGoodToStringDeep); - expect(new _MockToStringDeep('Hello: World\nFoo: 42\n'), + expect(_MockToStringDeep('Hello: World\nFoo: 42\n'), hasAGoodToStringDeep); // Contains default Object.toString(). - expect(new _MockToStringDeep('Hello: World\nFoo: ${new Object()}\n'), + expect(_MockToStringDeep('Hello: World\nFoo: ${Object()}\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n'), hasAGoodToStringDeep); - expect(new _MockToStringDeep('A\n├─B\n╘══════\n'), hasAGoodToStringDeep); + expect(_MockToStringDeep('A\n├─B\n'), hasAGoodToStringDeep); + expect(_MockToStringDeep('A\n├─B\n╘══════\n'), hasAGoodToStringDeep); // Last line is all whitespace or vertical line art. - expect(new _MockToStringDeep('A\n├─B\n\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n│\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n│\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n│\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n╎\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n║\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n │\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n ╎\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n ║\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep('A\n├─B\n ││\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n│\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n│\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n│\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n╎\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n║\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n │\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n ╎\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n ║\n'), isNot(hasAGoodToStringDeep)); + expect(_MockToStringDeep('A\n├─B\n ││\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep( + expect(_MockToStringDeep( 'A\n' '├─B\n' '│\n' '└─C\n'), hasAGoodToStringDeep); // Last line is all whitespace or vertical line art. - expect(new _MockToStringDeep( + expect(_MockToStringDeep( 'A\n' '├─B\n' '│\n'), isNot(hasAGoodToStringDeep)); - expect(new _MockToStringDeep.fromLines( + expect(_MockToStringDeep.fromLines( ['Paragraph#00000\n', ' │ size: (400x200)\n', ' ╘═╦══ text ═══\n', @@ -114,7 +114,7 @@ void main() { ' ╚═══════════\n']), hasAGoodToStringDeep); // Text span - expect(new _MockToStringDeep.fromLines( + expect(_MockToStringDeep.fromLines( ['Paragraph#00000\n', ' │ size: (400x200)\n', ' ╘═╦══ text ═══\n', @@ -202,8 +202,8 @@ void main() { expect(const Offset(1.0, 0.0), within(distance: 1.0, from: const Offset(0.0, 0.0))); expect(const Offset(1.0, 0.0), isNot(within(distance: 1.0, from: const Offset(-1.0, 0.0)))); - expect(new Rect.fromLTRB(0.0, 1.0, 2.0, 3.0), within(distance: 4.0, from: new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0))); - expect(new Rect.fromLTRB(0.0, 1.0, 2.0, 3.0), isNot(within(distance: 3.9, from: new Rect.fromLTRB(1.0, 3.0, 5.0, 7.0)))); + expect(Rect.fromLTRB(0.0, 1.0, 2.0, 3.0), within(distance: 4.0, from: Rect.fromLTRB(1.0, 3.0, 5.0, 7.0))); + expect(Rect.fromLTRB(0.0, 1.0, 2.0, 3.0), isNot(within(distance: 3.9, from: Rect.fromLTRB(1.0, 3.0, 5.0, 7.0)))); expect(const Size(1.0, 1.0), within(distance: 1.415, from: const Size(2.0, 2.0))); expect(const Size(1.0, 1.0), isNot(within(distance: 1.414, from: const Size(2.0, 2.0)))); @@ -222,43 +222,43 @@ void main() { group('coversSameAreaAs', () { test('empty Paths', () { expect( - new Path(), + Path(), coversSameAreaAs( - new Path(), - areaToCompare: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) + Path(), + areaToCompare: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) ), ); }); test('mismatch', () { - final Path rectPath = new Path() - ..addRect(new Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); + final Path rectPath = Path() + ..addRect(Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); expect( - new Path(), + Path(), isNot(coversSameAreaAs( rectPath, - areaToCompare: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) + areaToCompare: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) )), ); }); test('mismatch out of examined area', () { - final Path rectPath = new Path() - ..addRect(new Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); - rectPath.addRect(new Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); + final Path rectPath = Path() + ..addRect(Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); + rectPath.addRect(Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); expect( - new Path(), + Path(), coversSameAreaAs( rectPath, - areaToCompare: new Rect.fromLTRB(0.0, 0.0, 4.0, 4.0) + areaToCompare: Rect.fromLTRB(0.0, 0.0, 4.0, 4.0) ), ); }); test('differently constructed rects match', () { - final Path rectPath = new Path() - ..addRect(new Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); - final Path linePath = new Path() + final Path rectPath = Path() + ..addRect(Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); + final Path linePath = Path() ..moveTo(5.0, 5.0) ..lineTo(5.0, 6.0) ..lineTo(6.0, 6.0) @@ -268,15 +268,15 @@ void main() { linePath, coversSameAreaAs( rectPath, - areaToCompare: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) + areaToCompare: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) ), ); }); test('partially overlapping paths', () { - final Path rectPath = new Path() - ..addRect(new Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); - final Path linePath = new Path() + final Path rectPath = Path() + ..addRect(Rect.fromLTRB(5.0, 5.0, 6.0, 6.0)); + final Path linePath = Path() ..moveTo(5.0, 5.0) ..lineTo(5.0, 6.0) ..lineTo(6.0, 6.0) @@ -286,7 +286,7 @@ void main() { linePath, isNot(coversSameAreaAs( rectPath, - areaToCompare: new Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) + areaToCompare: Rect.fromLTRB(0.0, 0.0, 10.0, 10.0) )), ); }); @@ -296,14 +296,14 @@ void main() { _FakeComparator comparator; Widget boilerplate(Widget child) { - return new Directionality( + return Directionality( textDirection: TextDirection.ltr, child: child, ); } setUp(() { - comparator = new _FakeComparator(); + comparator = _FakeComparator(); goldenFileComparator = comparator; }); @@ -346,7 +346,7 @@ void main() { }); testWidgets('if finder finds no widgets', (WidgetTester tester) async { - await tester.pumpWidget(boilerplate(new Container())); + await tester.pumpWidget(boilerplate(Container())); final Finder finder = find.byType(Text); try { await expectLater(finder, matchesGoldenFile('foo.png')); @@ -358,7 +358,7 @@ void main() { }); testWidgets('if finder finds multiple widgets', (WidgetTester tester) async { - await tester.pumpWidget(boilerplate(new Column( + await tester.pumpWidget(boilerplate(Column( children: const [Text('hello'), Text('world')], ))); final Finder finder = find.byType(Text); @@ -388,7 +388,7 @@ void main() { testWidgets('matches SemanticsData', (WidgetTester tester) async { final SemanticsHandle handle = tester.ensureSemantics(); const Key key = Key('semantics'); - await tester.pumpWidget(new Semantics( + await tester.pumpWidget(Semantics( key: key, namesRoute: true, header: true, @@ -484,7 +484,7 @@ void main() { actions |= index; for (int index in SemanticsFlag.values.keys) flags |= index; - final SemanticsData data = new SemanticsData( + final SemanticsData data = SemanticsData( flags: flags, actions: actions, label: 'a', @@ -575,13 +575,13 @@ class _FakeComparator implements GoldenFileComparator { this.golden = golden; switch (behavior) { case _ComparatorBehavior.returnTrue: - return new Future.value(true); + return Future.value(true); case _ComparatorBehavior.returnFalse: - return new Future.value(false); + return Future.value(false); case _ComparatorBehavior.throwTestFailure: - throw new TestFailure('fake message'); + throw TestFailure('fake message'); } - return new Future.value(false); + return Future.value(false); } @override @@ -589,6 +589,6 @@ class _FakeComparator implements GoldenFileComparator { invocation = _ComparatorInvocation.update; this.golden = golden; this.imageBytes = imageBytes; - return new Future.value(); + return Future.value(); } } diff --git a/packages/flutter_test/test/stack_manipulation_test.dart b/packages/flutter_test/test/stack_manipulation_test.dart index b388fd6bca..d0f16d709f 100644 --- a/packages/flutter_test/test/stack_manipulation_test.dart +++ b/packages/flutter_test/test/stack_manipulation_test.dart @@ -10,7 +10,7 @@ void main() { expect(false, isTrue); throw 'unexpectedly did not throw'; } catch (e, stack) { - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); expect(reportExpectCall(stack, information), 4); final List lines = information.toString().split('\n'); expect(lines[0], 'This was caught by the test expectation on the following line:'); @@ -20,7 +20,7 @@ void main() { try { throw null; } catch (e, stack) { - final StringBuffer information = new StringBuffer(); + final StringBuffer information = StringBuffer(); expect(reportExpectCall(stack, information), 0); expect(information.toString(), ''); } diff --git a/packages/flutter_test/test/test_async_utils_test.dart b/packages/flutter_test/test/test_async_utils_test.dart index e543106879..3c4f230f21 100644 --- a/packages/flutter_test/test/test_async_utils_test.dart +++ b/packages/flutter_test/test/test_async_utils_test.dart @@ -35,7 +35,7 @@ Future _guardedThrower() { void main() { test('TestAsyncUtils - one class', () async { - final TestAPI testAPI = new TestAPI(); + final TestAPI testAPI = TestAPI(); Future f1, f2; f1 = testAPI.testGuard1(); try { @@ -56,7 +56,7 @@ void main() { }); test('TestAsyncUtils - two classes, all callers in superclass', () async { - final TestAPI testAPI = new TestAPISubclass(); + final TestAPI testAPI = TestAPISubclass(); Future f1, f2; f1 = testAPI.testGuard1(); try { @@ -77,7 +77,7 @@ void main() { }); test('TestAsyncUtils - two classes, mixed callers', () async { - final TestAPISubclass testAPI = new TestAPISubclass(); + final TestAPISubclass testAPI = TestAPISubclass(); Future f1, f2; f1 = testAPI.testGuard1(); try { @@ -98,7 +98,7 @@ void main() { }); test('TestAsyncUtils - expect() catches pending async work', () async { - final TestAPI testAPI = new TestAPISubclass(); + final TestAPI testAPI = TestAPISubclass(); Future f1; f1 = testAPI.testGuard1(); try { diff --git a/packages/flutter_test/test/test_config/config_test_utils.dart b/packages/flutter_test/test/test_config/config_test_utils.dart index 90c1abefcf..1460e5307c 100644 --- a/packages/flutter_test/test/test_config/config_test_utils.dart +++ b/packages/flutter_test/test/test_config/config_test_utils.dart @@ -14,7 +14,7 @@ void testConfig( final String actualStringValue = Zone.current[String]; final Map otherActualValues = otherExpectedValues.map( (Type key, dynamic value) { - return new MapEntry(key, Zone.current[key]); + return MapEntry(key, Zone.current[key]); }, ); diff --git a/packages/flutter_test/test/test_text_input_test.dart b/packages/flutter_test/test/test_text_input_test.dart index d4198254b6..2c89f5669c 100644 --- a/packages/flutter_test/test/test_text_input_test.dart +++ b/packages/flutter_test/test/test_text_input_test.dart @@ -10,7 +10,7 @@ void main() { testWidgets('receiveAction() forwards exception when exception occurs during action processing', (WidgetTester tester) async { // Setup a widget that can receive focus so that we can open the keyboard. - final Widget widget = new MaterialApp( + final Widget widget = MaterialApp( home: const Material( child: TextField(), ), @@ -23,7 +23,7 @@ void main() { // Register a handler for the text input channel that throws an error. This // error should be reported within a PlatformException by TestTextInput. SystemChannels.textInput.setMethodCallHandler((MethodCall call) { - throw new FlutterError('A fake error occurred during action processing.'); + throw FlutterError('A fake error occurred during action processing.'); }); try { diff --git a/packages/flutter_test/test/widget_tester_test.dart b/packages/flutter_test/test/widget_tester_test.dart index da6c97c958..c26094f121 100644 --- a/packages/flutter_test/test/widget_tester_test.dart +++ b/packages/flutter_test/test/widget_tester_test.dart @@ -21,8 +21,8 @@ const List fooBarTexts = [ void main() { group('expectLater', () { testWidgets('completes when matcher completes', (WidgetTester tester) async { - final Completer completer = new Completer(); - final Future future = expectLater(null, new FakeMatcher(completer)); + final Completer completer = Completer(); + final Future future = expectLater(null, FakeMatcher(completer)); String value; future.then((void _) { value = '123'; @@ -36,8 +36,8 @@ void main() { }); testWidgets('respects the skip flag', (WidgetTester tester) async { - final Completer completer = new Completer(); - final Future future = expectLater(null, new FakeMatcher(completer), skip: 'testing skip'); + final Completer completer = Completer(); + final Future future = expectLater(null, FakeMatcher(completer), skip: 'testing skip'); bool completed = false; future.then((void _) { completed = true; @@ -115,7 +115,7 @@ void main() { await tester.pumpWidget(const Text('foo', textDirection: TextDirection.ltr)); int count; - final AnimationController test = new AnimationController( + final AnimationController test = AnimationController( duration: const Duration(milliseconds: 5100), vsync: tester, ); @@ -182,10 +182,10 @@ void main() { group('find.descendant', () { testWidgets('finds one descendant', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: fooBarTexts), + Column(children: fooBarTexts), ], )); @@ -196,11 +196,11 @@ void main() { }); testWidgets('finds two descendants with different ancestors', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: fooBarTexts), - new Column(children: fooBarTexts), + Column(children: fooBarTexts), + Column(children: fooBarTexts), ], )); @@ -211,10 +211,10 @@ void main() { }); testWidgets('fails with a descriptive message', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: const [Text('foo', textDirection: TextDirection.ltr)]), + Column(children: const [Text('foo', textDirection: TextDirection.ltr)]), const Text('bar', textDirection: TextDirection.ltr), ], )); @@ -241,10 +241,10 @@ void main() { group('find.ancestor', () { testWidgets('finds one ancestor', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: fooBarTexts), + Column(children: fooBarTexts), ], )); @@ -256,11 +256,11 @@ void main() { testWidgets('finds two matching ancestors, one descendant', (WidgetTester tester) async { await tester.pumpWidget( - new Directionality( + Directionality( textDirection: TextDirection.ltr, - child: new Row( + child: Row( children: [ - new Row(children: fooBarTexts), + Row(children: fooBarTexts), ], ), ), @@ -273,10 +273,10 @@ void main() { }); testWidgets('fails with a descriptive message', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: const [Text('foo', textDirection: TextDirection.ltr)]), + Column(children: const [Text('foo', textDirection: TextDirection.ltr)]), const Text('bar', textDirection: TextDirection.ltr), ], )); @@ -301,10 +301,10 @@ void main() { }); testWidgets('Root not matched by default', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: fooBarTexts), + Column(children: fooBarTexts), ], )); @@ -315,10 +315,10 @@ void main() { }); testWidgets('Match the root', (WidgetTester tester) async { - await tester.pumpWidget(new Row( + await tester.pumpWidget(Row( textDirection: TextDirection.ltr, children: [ - new Column(children: fooBarTexts), + Column(children: fooBarTexts), ], )); @@ -332,7 +332,7 @@ void main() { group('pageBack', (){ testWidgets('fails when there are no back buttons', (WidgetTester tester) async { - await tester.pumpWidget(new Container()); + await tester.pumpWidget(Container()); expect( expectAsync0(tester.pageBack), @@ -342,17 +342,17 @@ void main() { testWidgets('successfully taps material back buttons', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Builder( + MaterialApp( + home: Center( + child: Builder( builder: (BuildContext context) { - return new RaisedButton( + return RaisedButton( child: const Text('Next'), onPressed: () { - Navigator.push(context, new MaterialPageRoute( + Navigator.push(context, MaterialPageRoute( builder: (BuildContext context) { - return new Scaffold( - appBar: new AppBar( + return Scaffold( + appBar: AppBar( title: const Text('Page 2'), ), ); @@ -380,20 +380,20 @@ void main() { testWidgets('successfully taps cupertino back buttons', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Center( - child: new Builder( + MaterialApp( + home: Center( + child: Builder( builder: (BuildContext context) { - return new CupertinoButton( + return CupertinoButton( child: const Text('Next'), onPressed: () { - Navigator.push(context, new CupertinoPageRoute( + Navigator.push(context, CupertinoPageRoute( builder: (BuildContext context) { - return new CupertinoPageScaffold( + return CupertinoPageScaffold( navigationBar: const CupertinoNavigationBar( middle: Text('Page 2'), ), - child: new Container(), + child: Container(), ); }, )); @@ -419,7 +419,7 @@ void main() { }); testWidgets('hasRunningAnimations control test', (WidgetTester tester) async { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(seconds: 1), vsync: const TestVSync() ); @@ -435,7 +435,7 @@ void main() { }); testWidgets('pumpAndSettle control test', (WidgetTester tester) async { - final AnimationController controller = new AnimationController( + final AnimationController controller = AnimationController( duration: const Duration(minutes: 525600), vsync: const TestVSync() ); @@ -464,7 +464,7 @@ void main() { }); testWidgets('works with real async calls', (WidgetTester tester) async { - final StringBuffer buf = new StringBuffer('1'); + final StringBuffer buf = StringBuffer('1'); await tester.runAsync(() async { buf.write('2'); await Directory.current.stat(); @@ -483,21 +483,21 @@ void main() { testWidgets('reports errors via framework', (WidgetTester tester) async { final String value = await tester.runAsync(() async { - throw new ArgumentError(); + throw ArgumentError(); }); expect(value, isNull); expect(tester.takeException(), isArgumentError); }); testWidgets('disallows re-entry', (WidgetTester tester) async { - final Completer completer = new Completer(); + final Completer completer = Completer(); tester.runAsync(() => completer.future); expect(() => tester.runAsync(() async {}), throwsA(isInstanceOf())); completer.complete(); }); testWidgets('maintains existing zone values', (WidgetTester tester) async { - final Object key = new Object(); + final Object key = Object(); await runZoned(() { expect(Zone.current[key], 'abczed'); return tester.runAsync(() async { @@ -511,10 +511,10 @@ void main() { testWidgets('showKeyboard can be called twice', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( - home: new Material( - child: new Center( - child: new TextFormField(), + MaterialApp( + home: Material( + child: Center( + child: TextFormField(), ), ), ), @@ -533,7 +533,7 @@ void main() { group('getSemanticsData', () { testWidgets('throws when there are no semantics', (WidgetTester tester) async { await tester.pumpWidget( - new MaterialApp( + MaterialApp( home: const Scaffold( body: Text('hello'), ), @@ -548,9 +548,9 @@ void main() { final SemanticsHandle semanticsHandle = tester.ensureSemantics(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Row( + MaterialApp( + home: Scaffold( + body: Row( children: const [ Text('hello'), Text('hello'), @@ -569,10 +569,10 @@ void main() { final SemanticsHandle semanticsHandle = tester.ensureSemantics(); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Container( - child: new OutlineButton( + MaterialApp( + home: Scaffold( + body: Container( + child: OutlineButton( onPressed: () {}, child: const Text('hello') ), @@ -592,16 +592,16 @@ void main() { final SemanticsHandle semanticsHandle = tester.ensureSemantics(); const Key key = Key('test'); await tester.pumpWidget( - new MaterialApp( - home: new Scaffold( - body: new Semantics( + MaterialApp( + home: Scaffold( + body: Semantics( label: 'A', - child: new Semantics( + child: Semantics( label: 'B', - child: new Semantics( + child: Semantics( key: key, label: 'C', - child: new Container(), + child: Container(), ), ), ) diff --git a/packages/flutter_tools/bin/fuchsia_asset_builder.dart b/packages/flutter_tools/bin/fuchsia_asset_builder.dart index 9eac7f4064..e54702545a 100644 --- a/packages/flutter_tools/bin/fuchsia_asset_builder.dart +++ b/packages/flutter_tools/bin/fuchsia_asset_builder.dart @@ -32,7 +32,7 @@ const List _kRequiredOptions = [ Future main(List args) { return runInContext(() => run(args), overrides: { - Usage: () => new DisabledUsage(), + Usage: () => DisabledUsage(), }); } @@ -44,7 +44,7 @@ Future writeFile(libfs.File outputFile, DevFSContent content) async { } Future run(List args) async { - final ArgParser parser = new ArgParser() + final ArgParser parser = ArgParser() ..addOption(_kOptionPackages, help: 'The .packages file') ..addOption(_kOptionAsset, help: 'The directory where to put temporary files') diff --git a/packages/flutter_tools/bin/fuchsia_tester.dart b/packages/flutter_tools/bin/fuchsia_tester.dart index 151cdf8505..2f0dbf815a 100644 --- a/packages/flutter_tools/bin/fuchsia_tester.dart +++ b/packages/flutter_tools/bin/fuchsia_tester.dart @@ -43,12 +43,12 @@ const String _kOptionCoveragePath = 'coverage-path'; void main(List args) { runInContext(() => run(args), overrides: { - Usage: () => new DisabledUsage(), + Usage: () => DisabledUsage(), }); } Future run(List args) async { - final ArgParser parser = new ArgParser() + final ArgParser parser = ArgParser() ..addOption(_kOptionPackages, help: 'The .packages file') ..addOption(_kOptionShell, help: 'The Flutter shell binary') ..addOption(_kOptionTestDirectory, help: 'Directory containing the tests') @@ -108,7 +108,7 @@ Future run(List args) async { CoverageCollector collector; if (argResults['coverage']) { - collector = new CoverageCollector(); + collector = CoverageCollector(); } diff --git a/packages/flutter_tools/lib/executable.dart b/packages/flutter_tools/lib/executable.dart index 307daa34e8..6cb499645d 100644 --- a/packages/flutter_tools/lib/executable.dart +++ b/packages/flutter_tools/lib/executable.dart @@ -50,35 +50,35 @@ Future main(List args) async { final bool verboseHelp = help && verbose; await runner.run(args, [ - new AnalyzeCommand(verboseHelp: verboseHelp), - new AttachCommand(verboseHelp: verboseHelp), - new BuildCommand(verboseHelp: verboseHelp), - new ChannelCommand(verboseHelp: verboseHelp), - new CleanCommand(), - new ConfigCommand(verboseHelp: verboseHelp), - new CreateCommand(), - new DaemonCommand(hidden: !verboseHelp), - new DevicesCommand(), - new DoctorCommand(verbose: verbose), - new DriveCommand(), - new EmulatorsCommand(), - new FormatCommand(), - new FuchsiaReloadCommand(), - new IdeConfigCommand(hidden: !verboseHelp), - new InjectPluginsCommand(hidden: !verboseHelp), - new InstallCommand(), - new LogsCommand(), - new MaterializeCommand(), - new PackagesCommand(), - new PrecacheCommand(), - new RunCommand(verboseHelp: verboseHelp), - new ScreenshotCommand(), - new ShellCompletionCommand(), - new StopCommand(), - new TestCommand(verboseHelp: verboseHelp), - new TraceCommand(), - new UpdatePackagesCommand(hidden: !verboseHelp), - new UpgradeCommand(), + AnalyzeCommand(verboseHelp: verboseHelp), + AttachCommand(verboseHelp: verboseHelp), + BuildCommand(verboseHelp: verboseHelp), + ChannelCommand(verboseHelp: verboseHelp), + CleanCommand(), + ConfigCommand(verboseHelp: verboseHelp), + CreateCommand(), + DaemonCommand(hidden: !verboseHelp), + DevicesCommand(), + DoctorCommand(verbose: verbose), + DriveCommand(), + EmulatorsCommand(), + FormatCommand(), + FuchsiaReloadCommand(), + IdeConfigCommand(hidden: !verboseHelp), + InjectPluginsCommand(hidden: !verboseHelp), + InstallCommand(), + LogsCommand(), + MaterializeCommand(), + PackagesCommand(), + PrecacheCommand(), + RunCommand(verboseHelp: verboseHelp), + ScreenshotCommand(), + ShellCompletionCommand(), + StopCommand(), + TestCommand(verboseHelp: verboseHelp), + TraceCommand(), + UpdatePackagesCommand(hidden: !verboseHelp), + UpgradeCommand(), ], verbose: verbose, muteCommandLogging: muteCommandLogging, verboseHelp: verboseHelp); diff --git a/packages/flutter_tools/lib/runner.dart b/packages/flutter_tools/lib/runner.dart index 2154cd3b4b..a8f7a9a775 100644 --- a/packages/flutter_tools/lib/runner.dart +++ b/packages/flutter_tools/lib/runner.dart @@ -40,11 +40,11 @@ Future run( if (muteCommandLogging) { // Remove the verbose option; for help and doctor, users don't need to see // verbose logs. - args = new List.from(args); + args = List.from(args); args.removeWhere((String option) => option == '-v' || option == '--verbose'); } - final FlutterCommandRunner runner = new FlutterCommandRunner(verboseHelp: verboseHelp); + final FlutterCommandRunner runner = FlutterCommandRunner(verboseHelp: verboseHelp); commands.forEach(runner.addCommand); return runInContext(() async { @@ -138,7 +138,7 @@ Future _handleToolError( // get caught by our zone's `onError` handler. In order to avoid an // infinite error loop, we throw an error that is recognized above // and will trigger an immediate exit. - throw new ProcessExit(1, immediate: true); + throw ProcessExit(1, immediate: true); } } } @@ -156,7 +156,7 @@ FileSystem crashFileSystem = const LocalFileSystem(); Future _createLocalCrashReport(List args, dynamic error, StackTrace stackTrace) async { File crashFile = getUniqueFile(crashFileSystem.currentDirectory, 'flutter', 'log'); - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.writeln('Flutter crash report; please file at https://github.com/flutter/flutter/issues.\n'); @@ -188,7 +188,7 @@ Future _createLocalCrashReport(List args, dynamic error, StackTrac Future _doctorText() async { try { - final BufferLogger logger = new BufferLogger(); + final BufferLogger logger = BufferLogger(); await context.run( body: () => doctor.diagnose(verbose: true), @@ -210,7 +210,7 @@ Future _exit(int code) async { // Send any last analytics calls that are in progress without overly delaying // the tool's exit (we wait a maximum of 250ms). if (flutterUsage.enabled) { - final Stopwatch stopwatch = new Stopwatch()..start(); + final Stopwatch stopwatch = Stopwatch()..start(); await flutterUsage.ensureAnalyticsSent(); printTrace('ensureAnalyticsSent: ${stopwatch.elapsedMilliseconds}ms'); } @@ -218,7 +218,7 @@ Future _exit(int code) async { // Run shutdown hooks before flushing logs await runShutdownHooks(); - final Completer completer = new Completer(); + final Completer completer = Completer(); // Give the task / timer queue one cycle through before we hard exit. Timer.run(() { diff --git a/packages/flutter_tools/lib/src/android/adb.dart b/packages/flutter_tools/lib/src/android/adb.dart index 942dbd8757..4a3fc36094 100644 --- a/packages/flutter_tools/lib/src/android/adb.dart +++ b/packages/flutter_tools/lib/src/android/adb.dart @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. -final RegExp _whitespaceRegex = new RegExp(r'\s+'); +final RegExp _whitespaceRegex = RegExp(r'\s+'); String cleanAdbDeviceName(String name) { // Some emulators use `___` in the name as separators. diff --git a/packages/flutter_tools/lib/src/android/android_device.dart b/packages/flutter_tools/lib/src/android/android_device.dart index fec83dfdcb..582283c482 100644 --- a/packages/flutter_tools/lib/src/android/android_device.dart +++ b/packages/flutter_tools/lib/src/android/android_device.dart @@ -162,7 +162,7 @@ class AndroidDevice extends Device { bool _isValidAdbVersion(String adbVersion) { // Sample output: 'Android Debug Bridge version 1.0.31' - final Match versionFields = new RegExp(r'(\d+)\.(\d+)\.(\d+)').firstMatch(adbVersion); + final Match versionFields = RegExp(r'(\d+)\.(\d+)\.(\d+)').firstMatch(adbVersion); if (versionFields != null) { final int majorVersion = int.parse(versionFields[1]); final int minorVersion = int.parse(versionFields[2]); @@ -283,7 +283,7 @@ class AndroidDevice extends Device { status.stop(); // Some versions of adb exit with exit code 0 even on failure :( // Parsing the output to check for failures. - final RegExp failureExp = new RegExp(r'^Failure.*$', multiLine: true); + final RegExp failureExp = RegExp(r'^Failure.*$', multiLine: true); final String failure = failureExp.stringMatch(installResult.stdout); if (failure != null) { printError('Package install error: $failure'); @@ -307,7 +307,7 @@ class AndroidDevice extends Device { return false; final String uninstallOut = (await runCheckedAsync(adbCommandForDevice(['uninstall', app.id]))).stdout; - final RegExp failureExp = new RegExp(r'^Failure.*$', multiLine: true); + final RegExp failureExp = RegExp(r'^Failure.*$', multiLine: true); final String failure = failureExp.stringMatch(uninstallOut); if (failure != null) { printError('Package uninstall error: $failure'); @@ -358,14 +358,14 @@ class AndroidDevice extends Device { bool ipv6 = false, }) async { if (!await _checkForSupportedAdbVersion() || !await _checkForSupportedAndroidVersion()) - return new LaunchResult.failed(); + return LaunchResult.failed(); final TargetPlatform devicePlatform = await targetPlatform; if (!(devicePlatform == TargetPlatform.android_arm || devicePlatform == TargetPlatform.android_arm64) && !debuggingOptions.buildInfo.isDebug) { printError('Profile and release builds are only supported on ARM targets.'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } BuildInfo buildInfo = debuggingOptions.buildInfo; @@ -389,7 +389,7 @@ class AndroidDevice extends Device { await stopApp(package); if (!await _installLatestApp(package)) - return new LaunchResult.failed(); + return LaunchResult.failed(); final bool traceStartup = platformArgs['trace-startup'] ?? false; final AndroidApk apk = package; @@ -400,7 +400,7 @@ class AndroidDevice extends Device { if (debuggingOptions.debuggingEnabled) { // TODO(devoncarew): Remember the forwarding information (so we can later remove the // port forwarding or set it up again when adb fails on us). - observatoryDiscovery = new ProtocolDiscovery.observatory( + observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(), portForwarder: portForwarder, hostPort: debuggingOptions.observatoryPort, @@ -441,11 +441,11 @@ class AndroidDevice extends Device { // This invocation returns 0 even when it fails. if (result.contains('Error: ')) { printError(result.trim()); - return new LaunchResult.failed(); + return LaunchResult.failed(); } if (!debuggingOptions.debuggingEnabled) - return new LaunchResult.succeeded(); + return LaunchResult.succeeded(); // Wait for the service protocol port here. This will complete once the // device has printed "Observatory is listening on...". @@ -459,10 +459,10 @@ class AndroidDevice extends Device { observatoryUri = await observatoryDiscovery.uri; } - return new LaunchResult.succeeded(observatoryUri: observatoryUri); + return LaunchResult.succeeded(observatoryUri: observatoryUri); } catch (error) { printError('Error waiting for a debug connection: $error'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } finally { await observatoryDiscovery.cancel(); } @@ -485,14 +485,14 @@ class AndroidDevice extends Device { @override DeviceLogReader getLogReader({ApplicationPackage app}) { // The Android log reader isn't app-specific. - _logReader ??= new _AdbLogReader(this); + _logReader ??= _AdbLogReader(this); return _logReader; } @override - DevicePortForwarder get portForwarder => _portForwarder ??= new _AndroidDevicePortForwarder(this); + DevicePortForwarder get portForwarder => _portForwarder ??= _AndroidDevicePortForwarder(this); - static final RegExp _timeRegExp = new RegExp(r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}', multiLine: true); + static final RegExp _timeRegExp = RegExp(r'^\d{2}-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}', multiLine: true); /// Return the most recent timestamp in the Android log or null if there is /// no available timestamp. The format can be passed to logcat's -T option. @@ -522,7 +522,7 @@ class AndroidDevice extends Device { Map parseAdbDeviceProperties(String str) { final Map properties = {}; - final RegExp propertyExp = new RegExp(r'\[(.*?)\]: \[(.*?)\]'); + final RegExp propertyExp = RegExp(r'\[(.*?)\]: \[(.*?)\]'); for (Match match in propertyExp.allMatches(str)) properties[match.group(1)] = match.group(2); return properties; @@ -557,7 +557,7 @@ Future> getAdbDeviceDiagnostics() async { } // 015d172c98400a03 device usb:340787200X product:nakasi model:Nexus_7 device:grouper -final RegExp _kDeviceRegex = new RegExp(r'^(\S+)\s+(\S+)(.*)'); +final RegExp _kDeviceRegex = RegExp(r'^(\S+)\s+(\S+)(.*)'); /// Parse the given `adb devices` output in [text], and fill out the given list /// of devices and possible device issue diagnostics. Either argument can be null, @@ -579,7 +579,7 @@ void parseADBDeviceOutput(String text, { continue; // Skip lines about adb server and client version not matching - if (line.startsWith(new RegExp(r'adb server (version|is out of date)'))) { + if (line.startsWith(RegExp(r'adb server (version|is out of date)'))) { diagnostics?.add(line); continue; } @@ -616,7 +616,7 @@ void parseADBDeviceOutput(String text, { } else if (deviceState == 'offline') { diagnostics?.add('Device $deviceID is offline.'); } else { - devices?.add(new AndroidDevice( + devices?.add(AndroidDevice( deviceID, productID: info['product'], modelID: info['model'] ?? deviceID, @@ -635,7 +635,7 @@ void parseADBDeviceOutput(String text, { /// A log reader that logs from `adb logcat`. class _AdbLogReader extends DeviceLogReader { _AdbLogReader(this.device) { - _linesController = new StreamController.broadcast( + _linesController = StreamController.broadcast( onListen: _start, onCancel: _stop ); @@ -659,7 +659,7 @@ class _AdbLogReader extends DeviceLogReader { // Dart's DateTime parse function accepts this format so long as we provide // the year, resulting in: // yyyy-mm-dd hours:minutes:seconds.milliseconds. - return DateTime.parse('${new DateTime.now().year}-$adbTimestamp'); + return DateTime.parse('${DateTime.now().year}-$adbTimestamp'); } void _start() { @@ -683,25 +683,25 @@ class _AdbLogReader extends DeviceLogReader { } // 'W/ActivityManager(pid): ' - static final RegExp _logFormat = new RegExp(r'^[VDIWEF]\/.*?\(\s*(\d+)\):\s'); + static final RegExp _logFormat = RegExp(r'^[VDIWEF]\/.*?\(\s*(\d+)\):\s'); static final List _whitelistedTags = [ - new RegExp(r'^[VDIWEF]\/flutter[^:]*:\s+', caseSensitive: false), - new RegExp(r'^[IE]\/DartVM[^:]*:\s+'), - new RegExp(r'^[WEF]\/AndroidRuntime:\s+'), - new RegExp(r'^[WEF]\/ActivityManager:\s+.*(\bflutter\b|\bdomokit\b|\bsky\b)'), - new RegExp(r'^[WEF]\/System\.err:\s+'), - new RegExp(r'^[F]\/[\S^:]+:\s+') + RegExp(r'^[VDIWEF]\/flutter[^:]*:\s+', caseSensitive: false), + RegExp(r'^[IE]\/DartVM[^:]*:\s+'), + RegExp(r'^[WEF]\/AndroidRuntime:\s+'), + RegExp(r'^[WEF]\/ActivityManager:\s+.*(\bflutter\b|\bdomokit\b|\bsky\b)'), + RegExp(r'^[WEF]\/System\.err:\s+'), + RegExp(r'^[F]\/[\S^:]+:\s+') ]; // 'F/libc(pid): Fatal signal 11' - static final RegExp _fatalLog = new RegExp(r'^F\/libc\s*\(\s*\d+\):\sFatal signal (\d+)'); + static final RegExp _fatalLog = RegExp(r'^F\/libc\s*\(\s*\d+\):\sFatal signal (\d+)'); // 'I/DEBUG(pid): ...' - static final RegExp _tombstoneLine = new RegExp(r'^[IF]\/DEBUG\s*\(\s*\d+\):\s(.+)$'); + static final RegExp _tombstoneLine = RegExp(r'^[IF]\/DEBUG\s*\(\s*\d+\):\s(.+)$'); // 'I/DEBUG(pid): Tombstone written to: ' - static final RegExp _tombstoneTerminator = new RegExp(r'^Tombstone written to:\s'); + static final RegExp _tombstoneTerminator = RegExp(r'^Tombstone written to:\s'); // we default to true in case none of the log lines match bool _acceptedLastLine = true; @@ -826,7 +826,7 @@ class _AndroidDevicePortForwarder extends DevicePortForwarder { if (hostPort == null || devicePort == null) continue; - ports.add(new ForwardedPort(hostPort, devicePort)); + ports.add(ForwardedPort(hostPort, devicePort)); } } diff --git a/packages/flutter_tools/lib/src/android/android_emulator.dart b/packages/flutter_tools/lib/src/android/android_emulator.dart index 582bf0f5c4..22c32adc8c 100644 --- a/packages/flutter_tools/lib/src/android/android_emulator.dart +++ b/packages/flutter_tools/lib/src/android/android_emulator.dart @@ -56,7 +56,7 @@ class AndroidEmulator extends Emulator { // return. return Future.any(>[ launchResult, - new Future.delayed(const Duration(seconds: 3)) + Future.delayed(const Duration(seconds: 3)) ]); } } @@ -98,13 +98,13 @@ AndroidEmulator _loadEmulatorInfo(String id) { if (configFile.existsSync()) { final Map properties = parseIniLines(configFile.readAsLinesSync()); - return new AndroidEmulator(id, properties); + return AndroidEmulator(id, properties); } } } } - return new AndroidEmulator(id); + return AndroidEmulator(id); } @visibleForTesting diff --git a/packages/flutter_tools/lib/src/android/android_sdk.dart b/packages/flutter_tools/lib/src/android/android_sdk.dart index de20ccb9ef..72344d2b34 100644 --- a/packages/flutter_tools/lib/src/android/android_sdk.dart +++ b/packages/flutter_tools/lib/src/android/android_sdk.dart @@ -36,8 +36,8 @@ const String kAndroidHome = 'ANDROID_HOME'; // $ANDROID_HOME/platforms/android-23/android.jar // $ANDROID_HOME/platforms/android-N/android.jar -final RegExp _numberedAndroidPlatformRe = new RegExp(r'^android-([0-9]+)$'); -final RegExp _sdkVersionRe = new RegExp(r'^ro.build.version.sdk=([0-9]+)$'); +final RegExp _numberedAndroidPlatformRe = RegExp(r'^android-([0-9]+)$'); +final RegExp _sdkVersionRe = RegExp(r'^ro.build.version.sdk=([0-9]+)$'); /// The minimum Android SDK version we support. const int minimumAndroidSdkVersion = 25; @@ -127,13 +127,13 @@ class AndroidNdk { /// Locate NDK within the given SDK or throw [AndroidNdkSearchError]. static AndroidNdk locateNdk(String androidHomeDir) { if (androidHomeDir == null) { - throw new AndroidNdkSearchError('Can not locate NDK because no SDK is found'); + throw AndroidNdkSearchError('Can not locate NDK because no SDK is found'); } String findBundle(String androidHomeDir) { final String ndkDirectory = fs.path.join(androidHomeDir, 'ndk-bundle'); if (!fs.isDirectorySync(ndkDirectory)) { - throw new AndroidNdkSearchError('Can not locate ndk-bundle, tried: $ndkDirectory'); + throw AndroidNdkSearchError('Can not locate ndk-bundle, tried: $ndkDirectory'); } return ndkDirectory; } @@ -145,14 +145,14 @@ class AndroidNdk { } else if (platform.isMacOS) { directory = 'darwin-x86_64'; } else { - throw new AndroidNdkSearchError('Only Linux and macOS are supported'); + throw AndroidNdkSearchError('Only Linux and macOS are supported'); } final String ndkCompiler = fs.path.join(ndkDirectory, 'toolchains', 'arm-linux-androideabi-4.9', 'prebuilt', directory, 'bin', 'arm-linux-androideabi-gcc'); if (!fs.isFileSync(ndkCompiler)) { - throw new AndroidNdkSearchError('Can not locate GCC binary, tried $ndkCompiler'); + throw AndroidNdkSearchError('Can not locate GCC binary, tried $ndkCompiler'); } return ndkCompiler; @@ -193,7 +193,7 @@ class AndroidNdk { final int suitableVersion = versions .firstWhere((int version) => version >= 9, orElse: () => null); if (suitableVersion == null) { - throw new AndroidNdkSearchError('Can not locate a suitable platform ARM sysroot (need android-9 or newer), tried to look in $platformsDir'); + throw AndroidNdkSearchError('Can not locate a suitable platform ARM sysroot (need android-9 or newer), tried to look in $platformsDir'); } final String armPlatform = fs.path.join(ndkDirectory, 'platforms', @@ -204,7 +204,7 @@ class AndroidNdk { final String ndkDir = findBundle(androidHomeDir); final String ndkCompiler = findCompiler(ndkDir); final List ndkCompilerArgs = findSysroot(ndkDir); - return new AndroidNdk._(ndkDir, ndkCompiler, ndkCompilerArgs); + return AndroidNdk._(ndkDir, ndkCompiler, ndkCompilerArgs); } /// Returns a descriptive message explaining why NDK can not be found within @@ -300,7 +300,7 @@ class AndroidSdk { // exceptions. } - return new AndroidSdk(androidHomeDir, ndk); + return AndroidSdk(androidHomeDir, ndk); } static bool validSdkDirectory(String dir) { @@ -372,7 +372,7 @@ class AndroidSdk { .listSync() .map((FileSystemEntity entity) { try { - return new Version.parse(entity.basename); + return Version.parse(entity.basename); } catch (error) { return null; } @@ -412,7 +412,7 @@ class AndroidSdk { if (buildToolsVersion == null) return null; - return new AndroidSdkVersion._( + return AndroidSdkVersion._( this, sdkLevel: platformVersion, platformName: platformName, diff --git a/packages/flutter_tools/lib/src/android/android_studio.dart b/packages/flutter_tools/lib/src/android/android_studio.dart index d437162941..9cf6898a9b 100644 --- a/packages/flutter_tools/lib/src/android/android_studio.dart +++ b/packages/flutter_tools/lib/src/android/android_studio.dart @@ -25,7 +25,7 @@ AndroidStudio get androidStudio => context[AndroidStudio]; // $HOME/Applications/Android Studio.app/Contents/ final RegExp _dotHomeStudioVersionMatcher = - new RegExp(r'^\.AndroidStudio([^\d]*)([\d.]+)'); + RegExp(r'^\.AndroidStudio([^\d]*)([\d.]+)'); String get javaPath => androidStudio?.javaPath; @@ -54,8 +54,8 @@ class AndroidStudio implements Comparable { Version version; if (versionString != null) - version = new Version.parse(versionString); - return new AndroidStudio(studioPath, version: version); + version = Version.parse(versionString); + return AndroidStudio(studioPath, version: version); } factory AndroidStudio.fromHomeDot(Directory homeDotDir) { @@ -64,7 +64,7 @@ class AndroidStudio implements Comparable { if (versionMatch?.groupCount != 2) { return null; } - final Version version = new Version.parse(versionMatch[2]); + final Version version = Version.parse(versionMatch[2]); if (version == null) { return null; } @@ -77,7 +77,7 @@ class AndroidStudio implements Comparable { // ignored, installPath will be null, which is handled below } if (installPath != null && fs.isDirectorySync(installPath)) { - return new AndroidStudio(installPath, version: version); + return AndroidStudio(installPath, version: version); } return null; } @@ -123,7 +123,7 @@ class AndroidStudio implements Comparable { String configuredStudioPath = configuredStudio; if (platform.isMacOS && !configuredStudioPath.endsWith('Contents')) configuredStudioPath = fs.path.join(configuredStudioPath, 'Contents'); - return new AndroidStudio(configuredStudioPath, + return AndroidStudio(configuredStudioPath, configured: configuredStudio); } @@ -181,7 +181,7 @@ class AndroidStudio implements Comparable { } return candidatePaths - .map((FileSystemEntity e) => new AndroidStudio.fromMacOSBundle(e.path)) + .map((FileSystemEntity e) => AndroidStudio.fromMacOSBundle(e.path)) .where((AndroidStudio s) => s != null) .toList(); } @@ -205,7 +205,7 @@ class AndroidStudio implements Comparable { if (fs.directory(homeDirPath).existsSync()) { for (FileSystemEntity entity in fs.directory(homeDirPath).listSync()) { if (entity is Directory && entity.basename.startsWith('.AndroidStudio')) { - final AndroidStudio studio = new AndroidStudio.fromHomeDot(entity); + final AndroidStudio studio = AndroidStudio.fromHomeDot(entity); if (studio != null && !_hasStudioAt(studio.directory, newerThan: studio.version)) { studios.removeWhere((AndroidStudio other) => other.directory == studio.directory); studios.add(studio); @@ -216,14 +216,14 @@ class AndroidStudio implements Comparable { final String configuredStudioDir = config.getValue('android-studio-dir'); if (configuredStudioDir != null && !_hasStudioAt(configuredStudioDir)) { - studios.add(new AndroidStudio(configuredStudioDir, + studios.add(AndroidStudio(configuredStudioDir, configured: configuredStudioDir)); } if (platform.isLinux) { void _checkWellKnownPath(String path) { if (fs.isDirectorySync(path) && !_hasStudioAt(path)) { - studios.add(new AndroidStudio(path)); + studios.add(AndroidStudio(path)); } } diff --git a/packages/flutter_tools/lib/src/android/android_studio_validator.dart b/packages/flutter_tools/lib/src/android/android_studio_validator.dart index 9dafcdd7e4..50ae46ecdf 100644 --- a/packages/flutter_tools/lib/src/android/android_studio_validator.dart +++ b/packages/flutter_tools/lib/src/android/android_studio_validator.dart @@ -19,10 +19,10 @@ class AndroidStudioValidator extends DoctorValidator { final List validators = []; final List studios = AndroidStudio.allInstalled(); if (studios.isEmpty) { - validators.add(new NoAndroidStudioValidator()); + validators.add(NoAndroidStudioValidator()); } else { validators.addAll(studios - .map((AndroidStudio studio) => new AndroidStudioValidator(studio))); + .map((AndroidStudio studio) => AndroidStudioValidator(studio))); } return validators; } @@ -36,9 +36,9 @@ class AndroidStudioValidator extends DoctorValidator { ? null : 'version ${_studio.version}'; messages - .add(new ValidationMessage('Android Studio at ${_studio.directory}')); + .add(ValidationMessage('Android Studio at ${_studio.directory}')); - final IntelliJPlugins plugins = new IntelliJPlugins(_studio.pluginsPath); + final IntelliJPlugins plugins = IntelliJPlugins(_studio.pluginsPath); plugins.validatePackage(messages, ['flutter-intellij', 'flutter-intellij.jar'], 'Flutter', minVersion: IntelliJPlugins.kMinFlutterPluginVersion); plugins.validatePackage(messages, ['Dart'], 'Dart'); @@ -46,20 +46,20 @@ class AndroidStudioValidator extends DoctorValidator { if (_studio.isValid) { type = ValidationType.installed; messages.addAll(_studio.validationMessages - .map((String m) => new ValidationMessage(m))); + .map((String m) => ValidationMessage(m))); } else { type = ValidationType.partial; messages.addAll(_studio.validationMessages - .map((String m) => new ValidationMessage.error(m))); - messages.add(new ValidationMessage( + .map((String m) => ValidationMessage.error(m))); + messages.add(ValidationMessage( 'Try updating or re-installing Android Studio.')); if (_studio.configured != null) { - messages.add(new ValidationMessage( + messages.add(ValidationMessage( 'Consider removing your android-studio-dir setting by running:\nflutter config --android-studio-dir=')); } } - return new ValidationResult(type, messages, statusInfo: studioVersionText); + return ValidationResult(type, messages, statusInfo: studioVersionText); } } @@ -73,14 +73,14 @@ class NoAndroidStudioValidator extends DoctorValidator { final String cfgAndroidStudio = config.getValue('android-studio-dir'); if (cfgAndroidStudio != null) { messages.add( - new ValidationMessage.error('android-studio-dir = $cfgAndroidStudio\n' + ValidationMessage.error('android-studio-dir = $cfgAndroidStudio\n' 'but Android Studio not found at this location.')); } - messages.add(new ValidationMessage( + messages.add(ValidationMessage( 'Android Studio not found; download from https://developer.android.com/studio/index.html\n' '(or visit https://flutter.io/setup/#android-setup for detailed instructions).')); - return new ValidationResult(ValidationType.missing, messages, + return ValidationResult(ValidationType.missing, messages, statusInfo: 'not installed'); } } diff --git a/packages/flutter_tools/lib/src/android/android_workflow.dart b/packages/flutter_tools/lib/src/android/android_workflow.dart index 7f55676b5b..3cadb25849 100644 --- a/packages/flutter_tools/lib/src/android/android_workflow.dart +++ b/packages/flutter_tools/lib/src/android/android_workflow.dart @@ -27,9 +27,9 @@ enum LicensesAccepted { unknown, } -final RegExp licenseCounts = new RegExp(r'(\d+) of (\d+) SDK package licenses? not accepted.'); -final RegExp licenseNotAccepted = new RegExp(r'licenses? not accepted', caseSensitive: false); -final RegExp licenseAccepted = new RegExp(r'All SDK package licenses accepted.'); +final RegExp licenseCounts = RegExp(r'(\d+) of (\d+) SDK package licenses? not accepted.'); +final RegExp licenseNotAccepted = RegExp(r'licenses? not accepted', caseSensitive: false); +final RegExp licenseAccepted = RegExp(r'All SDK package licenses accepted.'); class AndroidWorkflow implements Workflow { @override @@ -55,7 +55,7 @@ class AndroidValidator extends DoctorValidator { /// is not compatible. bool _checkJavaVersion(String javaBinary, List messages) { if (!processManager.canRun(javaBinary)) { - messages.add(new ValidationMessage.error('Cannot execute $javaBinary to determine the version')); + messages.add(ValidationMessage.error('Cannot execute $javaBinary to determine the version')); return false; } String javaVersion; @@ -69,10 +69,10 @@ class AndroidValidator extends DoctorValidator { } catch (_) { /* ignore */ } if (javaVersion == null) { // Could not determine the java version. - messages.add(new ValidationMessage.error('Could not determine java version')); + messages.add(ValidationMessage.error('Could not determine java version')); return false; } - messages.add(new ValidationMessage('Java version $javaVersion')); + messages.add(ValidationMessage('Java version $javaVersion')); // TODO(johnmccutchan): Validate version. return true; } @@ -85,12 +85,12 @@ class AndroidValidator extends DoctorValidator { // No Android SDK found. if (platform.environment.containsKey(kAndroidHome)) { final String androidHomeDir = platform.environment[kAndroidHome]; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( '$kAndroidHome = $androidHomeDir\n' 'but Android SDK not found at this location.' )); } else { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Unable to locate Android SDK.\n' 'Install Android Studio from: https://developer.android.com/studio/index.html\n' 'On first launch it will assist you in installing the Android SDK components.\n' @@ -99,12 +99,12 @@ class AndroidValidator extends DoctorValidator { )); } - return new ValidationResult(ValidationType.missing, messages); + return ValidationResult(ValidationType.missing, messages); } - messages.add(new ValidationMessage('Android SDK at ${androidSdk.directory}')); + messages.add(ValidationMessage('Android SDK at ${androidSdk.directory}')); - messages.add(new ValidationMessage(androidSdk.ndk == null + messages.add(ValidationMessage(androidSdk.ndk == null ? 'Android NDK location not configured (optional; useful for native profiling support)' : 'Android NDK at ${androidSdk.ndk.directory}')); @@ -112,7 +112,7 @@ class AndroidValidator extends DoctorValidator { if (androidSdk.latestVersion != null) { sdkVersionText = 'Android SDK ${androidSdk.latestVersion.buildToolsVersionName}'; - messages.add(new ValidationMessage( + messages.add(ValidationMessage( 'Platform ${androidSdk.latestVersion.platformName}, ' 'build-tools ${androidSdk.latestVersion.buildToolsVersionName}' )); @@ -120,7 +120,7 @@ class AndroidValidator extends DoctorValidator { if (platform.environment.containsKey(kAndroidHome)) { final String androidHomeDir = platform.environment[kAndroidHome]; - messages.add(new ValidationMessage('$kAndroidHome = $androidHomeDir')); + messages.add(ValidationMessage('$kAndroidHome = $androidHomeDir')); } final List validationResult = androidSdk.validateSdkWellFormed(); @@ -128,48 +128,48 @@ class AndroidValidator extends DoctorValidator { if (validationResult.isNotEmpty) { // Android SDK is not functional. messages.addAll(validationResult.map((String message) { - return new ValidationMessage.error(message); + return ValidationMessage.error(message); })); - messages.add(new ValidationMessage( + messages.add(ValidationMessage( 'Try re-installing or updating your Android SDK,\n' 'visit https://flutter.io/setup/#android-setup for detailed instructions.')); - return new ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); + return ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); } // Now check for the JDK. final String javaBinary = AndroidSdk.findJavaBinary(); if (javaBinary == null) { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'No Java Development Kit (JDK) found; You must have the environment ' 'variable JAVA_HOME set and the java binary in your PATH. ' 'You can download the JDK from $_jdkDownload.')); - return new ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); + return ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); } - messages.add(new ValidationMessage('Java binary at: $javaBinary')); + messages.add(ValidationMessage('Java binary at: $javaBinary')); // Check JDK version. if (!_checkJavaVersion(javaBinary, messages)) { - return new ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); + return ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); } // Check for licenses. switch (await licensesAccepted) { case LicensesAccepted.all: - messages.add(new ValidationMessage('All Android licenses accepted.')); + messages.add(ValidationMessage('All Android licenses accepted.')); break; case LicensesAccepted.some: - messages.add(new ValidationMessage.hint('Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses')); - return new ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); + messages.add(ValidationMessage.hint('Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses')); + return ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); case LicensesAccepted.none: - messages.add(new ValidationMessage.error('Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses')); - return new ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); + messages.add(ValidationMessage.error('Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses')); + return ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); case LicensesAccepted.unknown: - messages.add(new ValidationMessage.error('Android license status unknown.')); - return new ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); + messages.add(ValidationMessage.error('Android license status unknown.')); + return ValidationResult(ValidationType.partial, messages, statusInfo: sdkVersionText); } // Success. - return new ValidationResult(ValidationType.installed, messages, statusInfo: sdkVersionText); + return ValidationResult(ValidationType.installed, messages, statusInfo: sdkVersionText); } Future get licensesAccepted async { @@ -227,7 +227,7 @@ class AndroidValidator extends DoctorValidator { _ensureCanRunSdkManager(); - final Version sdkManagerVersion = new Version.parse(androidSdk.sdkManagerVersion); + final Version sdkManagerVersion = Version.parse(androidSdk.sdkManagerVersion); if (sdkManagerVersion == null || sdkManagerVersion.major < 26) // SDK manager is found, but needs to be updated. throwToolExit( diff --git a/packages/flutter_tools/lib/src/android/gradle.dart b/packages/flutter_tools/lib/src/android/gradle.dart index bbe5c2f0be..e5bdc3669e 100644 --- a/packages/flutter_tools/lib/src/android/gradle.dart +++ b/packages/flutter_tools/lib/src/android/gradle.dart @@ -24,7 +24,7 @@ import 'android_sdk.dart'; import 'android_studio.dart'; const String gradleVersion = '4.4'; -final RegExp _assembleTaskPattern = new RegExp(r'assemble([^:]+): task '); +final RegExp _assembleTaskPattern = RegExp(r'assemble([^:]+): task '); GradleProject _cachedGradleProject; String _cachedGradleExecutable; @@ -39,7 +39,7 @@ enum FlutterPluginVersion { // Investigation documented in #13975 suggests the filter should be a subset // of the impact of -q, but users insist they see the error message sometimes // anyway. If we can prove it really is impossible, delete the filter. -final RegExp ndkMessageFilter = new RegExp(r'^(?!NDK is missing a ".*" directory' +final RegExp ndkMessageFilter = RegExp(r'^(?!NDK is missing a ".*" directory' r'|If you are not using NDK, unset the NDK variable from ANDROID_NDK_HOME or local.properties to remove this warning' r'|If you are using NDK, verify the ndk.dir is set to a valid NDK directory. It is currently set to .*)'); @@ -57,7 +57,7 @@ FlutterPluginVersion getFlutterPluginVersion(AndroidProject project) { fs.path.join('app', 'build.gradle')); if (appGradle.existsSync()) { for (String line in appGradle.readAsLinesSync()) { - if (line.contains(new RegExp(r'apply from: .*/flutter.gradle'))) { + if (line.contains(RegExp(r'apply from: .*/flutter.gradle'))) { return FlutterPluginVersion.managed; } if (line.contains("def flutterPluginVersion = 'managed'")) { @@ -103,7 +103,7 @@ Future _readGradleProject() async { environment: _gradleEnv, ); final String properties = runResult.stdout.trim(); - project = new GradleProject.fromAppProperties(properties); + project = GradleProject.fromAppProperties(properties); } catch (exception) { if (getFlutterPluginVersion(flutterProject.android) == FlutterPluginVersion.managed) { status.cancel(); @@ -115,7 +115,7 @@ Future _readGradleProject() async { throwToolExit('Please review your Gradle project setup in the android/ folder.'); } // Fall back to the default - project = new GradleProject( + project = GradleProject( ['debug', 'profile', 'release'], [], flutterProject.android.gradleAppOutV1Directory, ); @@ -131,7 +131,7 @@ void handleKnownGradleExceptions(String exceptionString) { const String matcher = r'You have not accepted the license agreements of the following SDK components:' r'\s*\[(.+)\]'; - final RegExp licenseFailure = new RegExp(matcher, multiLine: true); + final RegExp licenseFailure = RegExp(matcher, multiLine: true); final Match licenseMatch = licenseFailure.firstMatch(exceptionString); if (licenseMatch != null) { final String missingLicenses = licenseMatch.group(1); @@ -219,9 +219,9 @@ void updateLocalProperties({ SettingsFile settings; if (localProperties.existsSync()) { - settings = new SettingsFile.parseFromFile(localProperties); + settings = SettingsFile.parseFromFile(localProperties); } else { - settings = new SettingsFile(); + settings = SettingsFile(); changed = true; } @@ -254,7 +254,7 @@ void updateLocalProperties({ /// /// Writes the path to the Android SDK, if known. void writeLocalProperties(File properties) { - final SettingsFile settings = new SettingsFile(); + final SettingsFile settings = SettingsFile(); if (androidSdk != null) { settings.values['sdk.dir'] = escapePath(androidSdk.directory); } @@ -424,7 +424,7 @@ File _findApkFile(GradleProject project, BuildInfo buildInfo) { } Map get _gradleEnv { - final Map env = new Map.from(platform.environment); + final Map env = Map.from(platform.environment); if (javaPath != null) { // Use java bundled with Android Studio. env['JAVA_HOME'] = javaPath; @@ -444,7 +444,7 @@ class GradleProject { .trim(); // Extract build types and product flavors. - final Set variants = new Set(); + final Set variants = Set(); for (String s in properties.split('\n')) { final Match match = _assembleTaskPattern.matchAsPrefix(s); if (match != null) { @@ -453,8 +453,8 @@ class GradleProject { variants.add(variant); } } - final Set buildTypes = new Set(); - final Set productFlavors = new Set(); + final Set buildTypes = Set(); + final Set productFlavors = Set(); for (final String variant1 in variants) { for (final String variant2 in variants) { if (variant2.startsWith(variant1) && variant2 != variant1) { @@ -468,7 +468,7 @@ class GradleProject { } if (productFlavors.isEmpty) buildTypes.addAll(variants); - return new GradleProject( + return GradleProject( buildTypes.toList(), productFlavors.toList(), fs.directory(fs.path.join(buildDir, 'outputs', 'apk')), diff --git a/packages/flutter_tools/lib/src/application_package.dart b/packages/flutter_tools/lib/src/application_package.dart index f71c0aebac..03fbd9b0c5 100644 --- a/packages/flutter_tools/lib/src/application_package.dart +++ b/packages/flutter_tools/lib/src/application_package.dart @@ -81,7 +81,7 @@ class AndroidApk extends ApplicationPackage { return null; } - return new AndroidApk( + return AndroidApk( id: data.packageName, file: apk, launchActivity: '${data.packageName}/${data.launchableActivityName}' @@ -97,7 +97,7 @@ class AndroidApk extends ApplicationPackage { if (apkFile.existsSync()) { // Grab information from the .apk. The gradle build script might alter // the application Id, so we need to look at what was actually built. - return new AndroidApk.fromApk(apkFile); + return AndroidApk.fromApk(apkFile); } // The .apk hasn't been built yet, so we work with what we have. The run // command will grab a new AndroidApk after building, to get the updated @@ -135,7 +135,7 @@ class AndroidApk extends ApplicationPackage { if (packageId == null || launchActivity == null) return null; - return new AndroidApk( + return AndroidApk( id: packageId, file: apkFile, launchActivity: launchActivity @@ -209,7 +209,7 @@ abstract class IOSApp extends ApplicationPackage { return null; } - return new PrebuiltIOSApp( + return PrebuiltIOSApp( bundleDir: bundleDir, bundleName: fs.path.basename(bundleDir.path), projectBundleId: id, @@ -219,7 +219,7 @@ abstract class IOSApp extends ApplicationPackage { factory IOSApp.fromIosProject(IosProject project) { if (getCurrentHostPlatform() != HostPlatform.darwin_x64) return null; - return new BuildableIOSApp(project); + return BuildableIOSApp(project); } @override @@ -281,13 +281,13 @@ Future getApplicationPackageForPlatform( case TargetPlatform.android_x86: return applicationBinary == null ? await AndroidApk.fromAndroidProject((await FlutterProject.current()).android) - : new AndroidApk.fromApk(applicationBinary); + : AndroidApk.fromApk(applicationBinary); case TargetPlatform.ios: return applicationBinary == null - ? new IOSApp.fromIosProject((await FlutterProject.current()).ios) - : new IOSApp.fromPrebuiltApp(applicationBinary); + ? IOSApp.fromIosProject((await FlutterProject.current()).ios) + : IOSApp.fromPrebuiltApp(applicationBinary); case TargetPlatform.tester: - return new FlutterTesterApp.fromCurrentDirectory(); + return FlutterTesterApp.fromCurrentDirectory(); case TargetPlatform.darwin_x64: case TargetPlatform.linux_x64: case TargetPlatform.windows_x64: @@ -395,7 +395,7 @@ class ApkManifestData { final List lines = data.split('\n'); assert(lines.length > 3); - final _Element manifest = new _Element.fromLine(lines[1], null); + final _Element manifest = _Element.fromLine(lines[1], null); _Element currentElement = manifest; for (String line in lines.skip(2)) { @@ -411,10 +411,10 @@ class ApkManifestData { switch (trimLine[0]) { case 'A': currentElement - .addChild(new _Attribute.fromLine(line, currentElement)); + .addChild(_Attribute.fromLine(line, currentElement)); break; case 'E': - final _Element element = new _Element.fromLine(line, currentElement); + final _Element element = _Element.fromLine(line, currentElement); currentElement.addChild(element); currentElement = element; } @@ -453,14 +453,14 @@ class ApkManifestData { map['package'] = {'name': packageName}; map['launchable-activity'] = {'name': activityName}; - return new ApkManifestData._(map); + return ApkManifestData._(map); } final Map> _data; @visibleForTesting Map> get data => - new UnmodifiableMapView>(_data); + UnmodifiableMapView>(_data); String get packageName => _data['package'] == null ? null : _data['package']['name']; diff --git a/packages/flutter_tools/lib/src/artifacts.dart b/packages/flutter_tools/lib/src/artifacts.dart index 4d9a18c46f..06765c98b8 100644 --- a/packages/flutter_tools/lib/src/artifacts.dart +++ b/packages/flutter_tools/lib/src/artifacts.dart @@ -89,7 +89,7 @@ abstract class Artifacts { static Artifacts get instance => context[Artifacts]; static LocalEngineArtifacts getLocalEngine(String engineSrcPath, EngineBuildPaths engineBuildPaths) { - return new LocalEngineArtifacts(engineSrcPath, engineBuildPaths.targetEngine, engineBuildPaths.hostEngine); + return LocalEngineArtifacts(engineSrcPath, engineBuildPaths.targetEngine, engineBuildPaths.hostEngine); } // Returns the requested [artifact] for the [platform] and [mode] combination. @@ -233,7 +233,7 @@ class CachedArtifacts extends Artifacts { return TargetPlatform.linux_x64; if (platform.isWindows) return TargetPlatform.windows_x64; - throw new UnimplementedError('Host OS not supported.'); + throw UnimplementedError('Host OS not supported.'); } } @@ -300,7 +300,7 @@ class LocalEngineArtifacts extends Artifacts { if (processManager.canRun(genSnapshotPath)) return genSnapshotPath; } - throw new Exception('Unable to find $genSnapshotName'); + throw Exception('Unable to find $genSnapshotName'); } String _flutterTesterPath(TargetPlatform platform) { @@ -311,6 +311,6 @@ class LocalEngineArtifacts extends Artifacts { } else if (getCurrentHostPlatform() == HostPlatform.windows_x64) { return fs.path.join(engineOutPath, 'flutter_tester.exe'); } - throw new Exception('Unsupported platform $platform.'); + throw Exception('Unsupported platform $platform.'); } } diff --git a/packages/flutter_tools/lib/src/asset.dart b/packages/flutter_tools/lib/src/asset.dart index e0d84ebe6a..22b7b2465c 100644 --- a/packages/flutter_tools/lib/src/asset.dart +++ b/packages/flutter_tools/lib/src/asset.dart @@ -52,7 +52,7 @@ class _ManifestAssetBundleFactory implements AssetBundleFactory { const _ManifestAssetBundleFactory(); @override - AssetBundle createBundle() => new _ManifestAssetBundle(); + AssetBundle createBundle() => _ManifestAssetBundle(); } class _ManifestAssetBundle implements AssetBundle { @@ -108,15 +108,15 @@ class _ManifestAssetBundle implements AssetBundle { return 1; if (flutterManifest.isEmpty) { - entries[_assetManifestJson] = new DevFSStringContent('{}'); + entries[_assetManifestJson] = DevFSStringContent('{}'); return 0; } final String assetBasePath = fs.path.dirname(fs.path.absolute(manifestPath)); - _lastBuildTimestamp = new DateTime.now(); + _lastBuildTimestamp = DateTime.now(); - final PackageMap packageMap = new PackageMap(packagesPath); + final PackageMap packageMap = PackageMap(packagesPath); // The _assetVariants map contains an entry for each asset listed // in the pubspec.yaml file's assets and font and sections. The @@ -191,7 +191,7 @@ class _ManifestAssetBundle implements AssetBundle { } for (_Asset variant in assetVariants[asset]) { assert(variant.assetFileExists); - entries[variant.entryUri.path] = new DevFSFileContent(variant.assetFile); + entries[variant.entryUri.path] = DevFSFileContent(variant.assetFile); } } @@ -201,12 +201,12 @@ class _ManifestAssetBundle implements AssetBundle { } for (_Asset asset in materialAssets) { assert(asset.assetFileExists); - entries[asset.entryUri.path] = new DevFSFileContent(asset.assetFile); + entries[asset.entryUri.path] = DevFSFileContent(asset.assetFile); } entries[_assetManifestJson] = _createAssetManifest(assetVariants); - entries[_fontManifestJson] = new DevFSStringContent(json.encode(fonts)); + entries[_fontManifestJson] = DevFSStringContent(json.encode(fonts)); // TODO(ianh): Only do the following line if we've changed packages or if our LICENSE file changed entries[_license] = await _obtainLicenses(packageMap, assetBasePath, reportPackages: reportLicensedPackages); @@ -239,7 +239,7 @@ class _Asset { if (entryUri == relativeUri) return null; final int index = entryUri.path.indexOf(relativeUri.path); - return index == -1 ? null : new Uri(path: entryUri.path.substring(0, index)); + return index == -1 ? null : Uri(path: entryUri.path.substring(0, index)); } @override @@ -285,9 +285,9 @@ List<_Asset> _getMaterialAssets(String fontSet) { for (Map family in _getMaterialFonts(fontSet)) { for (Map font in family['fonts']) { final Uri entryUri = fs.path.toUri(font['asset']); - result.add(new _Asset( + result.add(_Asset( baseDir: fs.path.join(Cache.flutterRoot, 'bin', 'cache', 'artifacts', 'material_fonts'), - relativeUri: new Uri(path: entryUri.pathSegments.last), + relativeUri: Uri(path: entryUri.pathSegments.last), entryUri: entryUri )); } @@ -318,7 +318,7 @@ Future _obtainLicenses( // example, a package might itself contain code from multiple third-party // sources, and might need to include a license for each one.) final Map> packageLicenses = >{}; - final Set allPackages = new Set(); + final Set allPackages = Set(); for (String packageName in packageMap.map.keys) { final Uri package = packageMap.map[packageName]; if (package != null && package.scheme == 'file') { @@ -340,7 +340,7 @@ Future _obtainLicenses( packageNames = [packageName]; licenseText = rawLicense; } - packageLicenses.putIfAbsent(licenseText, () => new Set()) + packageLicenses.putIfAbsent(licenseText, () => Set()) ..addAll(packageNames); allPackages.addAll(packageNames); } @@ -365,7 +365,7 @@ Future _obtainLicenses( final String combinedLicenses = combinedLicensesList.join(_licenseSeparator); - return new DevFSStringContent(combinedLicenses); + return DevFSStringContent(combinedLicenses); } int _byBasename(_Asset a, _Asset b) { @@ -386,7 +386,7 @@ DevFSContent _createAssetManifest(Map<_Asset, List<_Asset>> assetVariants) { variants.add(variant.entryUri.path); jsonObject[main.entryUri.path] = variants; } - return new DevFSStringContent(json.encode(jsonObject)); + return DevFSStringContent(json.encode(jsonObject)); } List> _parseFonts( @@ -425,20 +425,20 @@ List _parsePackageFonts( final Uri assetUri = fontAsset.assetUri; if (assetUri.pathSegments.first == 'packages' && !fs.isFileSync(fs.path.fromUri(packageMap.map[packageName].resolve('../${assetUri.path}')))) { - packageFontAssets.add(new FontAsset( + packageFontAssets.add(FontAsset( fontAsset.assetUri, weight: fontAsset.weight, style: fontAsset.style, )); } else { - packageFontAssets.add(new FontAsset( - new Uri(pathSegments: ['packages', packageName]..addAll(assetUri.pathSegments)), + packageFontAssets.add(FontAsset( + Uri(pathSegments: ['packages', packageName]..addAll(assetUri.pathSegments)), weight: fontAsset.weight, style: fontAsset.style, )); } } - packageFonts.add(new Font('packages/$packageName/${font.familyName}', packageFontAssets)); + packageFonts.add(Font('packages/$packageName/${font.familyName}', packageFontAssets)); } return packageFonts; } @@ -528,7 +528,7 @@ Map<_Asset, List<_Asset>> _parseAssets( }) { final Map<_Asset, List<_Asset>> result = <_Asset, List<_Asset>>{}; - final _AssetDirectoryCache cache = new _AssetDirectoryCache(excludeDirs); + final _AssetDirectoryCache cache = _AssetDirectoryCache(excludeDirs); for (Uri assetUri in flutterManifest.assets) { if (assetUri.toString().endsWith('/')) { _parseAssetsFromFolder(packageMap, flutterManifest, assetBase, @@ -585,7 +585,7 @@ void _parseAssetsFromFolder(PackageMap packageMap, if (entity is File) { final String relativePath = fs.path.relative(entity.path, from: assetBase); - final Uri uri = new Uri.file(relativePath, windows: platform.isWindows); + final Uri uri = Uri.file(relativePath, windows: platform.isWindows); _parseAssetFromFile(packageMap, flutterManifest, assetBase, cache, result, uri, packageName: packageName); @@ -617,7 +617,7 @@ void _parseAssetFromFile(PackageMap packageMap, : asset.symbolicPrefixUri.resolveUri(relativeUri); variants.add( - new _Asset( + _Asset( baseDir: asset.baseDir, entryUri: entryUri, relativeUri: relativeUri, @@ -643,11 +643,11 @@ _Asset _resolveAsset( return packageAsset; } - return new _Asset( + return _Asset( baseDir: assetsBaseDir, entryUri: packageName == null ? assetUri // Asset from the current application. - : new Uri(pathSegments: ['packages', packageName]..addAll(assetUri.pathSegments)), // Asset from, and declared in $packageName. + : Uri(pathSegments: ['packages', packageName]..addAll(assetUri.pathSegments)), // Asset from, and declared in $packageName. relativeUri: assetUri, ); } @@ -658,10 +658,10 @@ _Asset _resolvePackageAsset(Uri assetUri, PackageMap packageMap) { final String packageName = assetUri.pathSegments[1]; final Uri packageUri = packageMap.map[packageName]; if (packageUri != null && packageUri.scheme == 'file') { - return new _Asset( + return _Asset( baseDir: fs.path.fromUri(packageUri), entryUri: assetUri, - relativeUri: new Uri(pathSegments: assetUri.pathSegments.sublist(2)), + relativeUri: Uri(pathSegments: assetUri.pathSegments.sublist(2)), ); } } diff --git a/packages/flutter_tools/lib/src/base/build.dart b/packages/flutter_tools/lib/src/base/build.dart index a463ac3d97..9f06f76d97 100644 --- a/packages/flutter_tools/lib/src/base/build.dart +++ b/packages/flutter_tools/lib/src/base/build.dart @@ -103,7 +103,7 @@ class AOTSnapshotter { return 1; } - final PackageMap packageMap = new PackageMap(packagesPath); + final PackageMap packageMap = PackageMap(packagesPath); final String packageMapError = packageMap.checkValid(); if (packageMapError != null) { printError(packageMapError); @@ -120,7 +120,7 @@ class AOTSnapshotter { final String ioEntryPoints = artifacts.getArtifactPath(Artifact.dartIoEntriesTxt, platform, buildMode); final List inputPaths = [uiPath, vmServicePath, vmEntryPoints, ioEntryPoints, mainPath]; - final Set outputPaths = new Set(); + final Set outputPaths = Set(); final String depfilePath = fs.path.join(outputDir.path, 'snapshot.d'); final List genSnapshotArgs = [ @@ -181,7 +181,7 @@ class AOTSnapshotter { } // If inputs and outputs have not changed since last run, skip the build. - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: '$depfilePath.fingerprint', paths: [mainPath]..addAll(inputPaths)..addAll(outputPaths), properties: { @@ -198,7 +198,7 @@ class AOTSnapshotter { return 0; } - final SnapshotType snapshotType = new SnapshotType(platform, buildMode); + final SnapshotType snapshotType = SnapshotType(platform, buildMode); final int genSnapshotExitCode = await genSnapshot.run( snapshotType: snapshotType, packagesPath: packageMap.packagesPath, @@ -369,7 +369,7 @@ class CoreJITSnapshotter { outputDir.createSync(recursive: true); final List inputPaths = [mainPath, compilationTraceFilePath]; - final Set outputPaths = new Set(); + final Set outputPaths = Set(); final String depfilePath = fs.path.join(outputDir.path, 'snapshot.d'); final List genSnapshotArgs = [ @@ -419,7 +419,7 @@ class CoreJITSnapshotter { } // If inputs and outputs have not changed since last run, skip the build. - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: '$depfilePath.fingerprint', paths: [mainPath]..addAll(inputPaths)..addAll(outputPaths), properties: { @@ -435,7 +435,7 @@ class CoreJITSnapshotter { return 0; } - final SnapshotType snapshotType = new SnapshotType(platform, buildMode); + final SnapshotType snapshotType = SnapshotType(platform, buildMode); final int genSnapshotExitCode = await genSnapshot.run( snapshotType: snapshotType, packagesPath: packagesPath, diff --git a/packages/flutter_tools/lib/src/base/common.dart b/packages/flutter_tools/lib/src/base/common.dart index 01c2cba801..3130576d79 100644 --- a/packages/flutter_tools/lib/src/base/common.dart +++ b/packages/flutter_tools/lib/src/base/common.dart @@ -23,7 +23,7 @@ String _homeDirPath; /// and no stack trace unless the --verbose option is specified. /// For example: network errors void throwToolExit(String message, { int exitCode }) { - throw new ToolExit(message, exitCode: exitCode); + throw ToolExit(message, exitCode: exitCode); } /// Specialized exception for expected situations diff --git a/packages/flutter_tools/lib/src/base/context.dart b/packages/flutter_tools/lib/src/base/context.dart index e4a20dd079..2f8fca10b0 100644 --- a/packages/flutter_tools/lib/src/base/context.dart +++ b/packages/flutter_tools/lib/src/base/context.dart @@ -61,7 +61,7 @@ class AppContext { List _reentrantChecks; /// Bootstrap context. - static final AppContext _root = new AppContext._(null, 'ROOT'); + static final AppContext _root = AppContext._(null, 'ROOT'); dynamic _boxNull(dynamic value) => value ?? _BoxedNull.instance; @@ -90,8 +90,8 @@ class AppContext { final int index = _reentrantChecks.indexOf(type); if (index >= 0) { // We're already in the process of trying to generate this type. - throw new ContextDependencyCycleException._( - new UnmodifiableListView(_reentrantChecks.sublist(index))); + throw ContextDependencyCycleException._( + UnmodifiableListView(_reentrantChecks.sublist(index))); } _reentrantChecks.add(type); @@ -132,11 +132,11 @@ class AppContext { Map overrides, Map fallbacks, }) async { - final AppContext child = new AppContext._( + final AppContext child = AppContext._( this, name, - new Map.unmodifiable(overrides ?? const {}), - new Map.unmodifiable(fallbacks ?? const {}), + Map.unmodifiable(overrides ?? const {}), + Map.unmodifiable(fallbacks ?? const {}), ); return await runZoned>( () async => await body(), @@ -146,7 +146,7 @@ class AppContext { @override String toString() { - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); String indent = ''; AppContext ctx = this; while (ctx != null) { diff --git a/packages/flutter_tools/lib/src/base/file_system.dart b/packages/flutter_tools/lib/src/base/file_system.dart index b15e0412a6..0aeebed305 100644 --- a/packages/flutter_tools/lib/src/base/file_system.dart +++ b/packages/flutter_tools/lib/src/base/file_system.dart @@ -33,7 +33,7 @@ FileSystem get fs => context[FileSystem] ?? _kLocalFs; /// directory as long as there is no collision with the `"file"` subdirectory. RecordingFileSystem getRecordingFileSystem(String location) { final Directory dir = getRecordingSink(location, _kRecordingType); - final RecordingFileSystem fileSystem = new RecordingFileSystem( + final RecordingFileSystem fileSystem = RecordingFileSystem( delegate: _kLocalFs, destination: dir); addShutdownHook(() async { await fileSystem.recording.flush( @@ -51,7 +51,7 @@ RecordingFileSystem getRecordingFileSystem(String location) { /// [getRecordingFileSystem]), or a [ToolExit] will be thrown. ReplayFileSystem getReplayFileSystem(String location) { final Directory dir = getReplaySource(location, _kRecordingType); - return new ReplayFileSystem(recording: dir); + return ReplayFileSystem(recording: dir); } /// Create the ancestor directories of a file path if they do not already exist. @@ -72,7 +72,7 @@ void ensureDirectoryExists(String filePath) { /// Creates `destDir` if needed. void copyDirectorySync(Directory srcDir, Directory destDir, [void onFileCopied(File srcFile, File destFile)]) { if (!srcDir.existsSync()) - throw new Exception('Source directory "${srcDir.path}" does not exist, nothing to copy'); + throw Exception('Source directory "${srcDir.path}" does not exist, nothing to copy'); if (!destDir.existsSync()) destDir.createSync(recursive: true); @@ -87,7 +87,7 @@ void copyDirectorySync(Directory srcDir, Directory destDir, [void onFileCopied(F copyDirectorySync( entity, destDir.fileSystem.directory(newPath)); } else { - throw new Exception('${entity.path} is neither File nor Directory'); + throw Exception('${entity.path} is neither File nor Directory'); } } } diff --git a/packages/flutter_tools/lib/src/base/fingerprint.dart b/packages/flutter_tools/lib/src/base/fingerprint.dart index a87fda3fd0..4d33ba4584 100644 --- a/packages/flutter_tools/lib/src/base/fingerprint.dart +++ b/packages/flutter_tools/lib/src/base/fingerprint.dart @@ -30,7 +30,7 @@ class Fingerprinter { Iterable depfilePaths = const [], FingerprintPathFilter pathFilter, }) : _paths = paths.toList(), - _properties = new Map.from(properties), + _properties = Map.from(properties), _depfilePaths = depfilePaths.toList(), _pathFilter = pathFilter, assert(fingerprintPath != null), @@ -46,7 +46,7 @@ class Fingerprinter { Future buildFingerprint() async { final List paths = await _getPaths(); - return new Fingerprint.fromBuildInputs(_properties, paths); + return Fingerprint.fromBuildInputs(_properties, paths); } Future doesFingerprintMatch() async { @@ -62,7 +62,7 @@ class Fingerprinter { if (!paths.every(fs.isFileSync)) return false; - final Fingerprint oldFingerprint = new Fingerprint.fromJson(await fingerprintFile.readAsString()); + final Fingerprint oldFingerprint = Fingerprint.fromJson(await fingerprintFile.readAsString()); final Fingerprint newFingerprint = await buildFingerprint(); return oldFingerprint == newFingerprint; } catch (e) { @@ -100,7 +100,7 @@ class Fingerprint { final Iterable files = inputPaths.map(fs.file); final Iterable missingInputs = files.where((File file) => !file.existsSync()); if (missingInputs.isNotEmpty) - throw new ArgumentError('Missing input files:\n' + missingInputs.join('\n')); + throw ArgumentError('Missing input files:\n' + missingInputs.join('\n')); _checksums = {}; for (File file in files) { @@ -119,7 +119,7 @@ class Fingerprint { final String version = content['version']; if (version != FlutterVersion.instance.frameworkRevision) - throw new ArgumentError('Incompatible fingerprint version: $version'); + throw ArgumentError('Incompatible fingerprint version: $version'); _checksums = content['files']?.cast() ?? {}; _properties = content['properties']?.cast() ?? {}; } @@ -158,8 +158,8 @@ class Fingerprint { String toString() => '{checksums: $_checksums, properties: $_properties}'; } -final RegExp _separatorExpr = new RegExp(r'([^\\]) '); -final RegExp _escapeExpr = new RegExp(r'\\(.)'); +final RegExp _separatorExpr = RegExp(r'([^\\]) '); +final RegExp _escapeExpr = RegExp(r'\\(.)'); /// Parses a VM snapshot dependency file. /// diff --git a/packages/flutter_tools/lib/src/base/io.dart b/packages/flutter_tools/lib/src/base/io.dart index be2dcb2e0d..4beb040bc7 100644 --- a/packages/flutter_tools/lib/src/base/io.dart +++ b/packages/flutter_tools/lib/src/base/io.dart @@ -97,7 +97,7 @@ ExitFunction get exit => _exitFunction; @visibleForTesting void setExitFunctionForTests([ExitFunction exitFunction]) { _exitFunction = exitFunction ?? (int exitCode) { - throw new ProcessExit(exitCode, immediate: true); + throw ProcessExit(exitCode, immediate: true); }; } diff --git a/packages/flutter_tools/lib/src/base/logger.dart b/packages/flutter_tools/lib/src/base/logger.dart index dcab62c15a..d71d97440b 100644 --- a/packages/flutter_tools/lib/src/base/logger.dart +++ b/packages/flutter_tools/lib/src/base/logger.dart @@ -108,10 +108,10 @@ class StdoutLogger extends Logger { }) { if (_status != null) { // Ignore nested progresses; return a no-op status object. - return new Status(onFinish: _clearStatus)..start(); + return Status(onFinish: _clearStatus)..start(); } if (terminal.supportsColor) { - _status = new AnsiStatus( + _status = AnsiStatus( message: message, expectSlowOperation: expectSlowOperation, padding: progressIndicatorPadding, @@ -119,7 +119,7 @@ class StdoutLogger extends Logger { )..start(); } else { printStatus(message); - _status = new Status(onFinish: _clearStatus)..start(); + _status = Status(onFinish: _clearStatus)..start(); } return _status; } @@ -153,9 +153,9 @@ class BufferLogger extends Logger { @override bool get isVerbose => false; - final StringBuffer _error = new StringBuffer(); - final StringBuffer _status = new StringBuffer(); - final StringBuffer _trace = new StringBuffer(); + final StringBuffer _error = StringBuffer(); + final StringBuffer _status = StringBuffer(); + final StringBuffer _trace = StringBuffer(); String get errorText => _error.toString(); String get statusText => _status.toString(); @@ -188,7 +188,7 @@ class BufferLogger extends Logger { int progressIndicatorPadding = kDefaultStatusPadding, }) { printStatus(message); - return new Status()..start(); + return Status()..start(); } /// Clears all buffers. @@ -207,7 +207,7 @@ class VerboseLogger extends Logger { final Logger parent; - Stopwatch stopwatch = new Stopwatch(); + Stopwatch stopwatch = Stopwatch(); @override bool get isVerbose => true; @@ -238,7 +238,7 @@ class VerboseLogger extends Logger { int progressIndicatorPadding = kDefaultStatusPadding, }) { printStatus(message); - return new Status(onFinish: () { + return Status(onFinish: () { printTrace('$message (completed)'); })..start(); } @@ -303,8 +303,8 @@ class Status { /// terminal is fancy enough), already started. factory Status.withSpinner({ VoidCallback onFinish }) { if (terminal.supportsColor) - return new AnsiSpinner(onFinish: onFinish)..start(); - return new Status(onFinish: onFinish)..start(); + return AnsiSpinner(onFinish: onFinish)..start(); + return Status(onFinish: onFinish)..start(); } final VoidCallback onFinish; @@ -353,7 +353,7 @@ class AnsiSpinner extends Status { super.start(); assert(timer == null); stdout.write(' '); - timer = new Timer.periodic(const Duration(milliseconds: 100), _callback); + timer = Timer.periodic(const Duration(milliseconds: 100), _callback); _callback(timer); } @@ -394,7 +394,7 @@ class AnsiStatus extends AnsiSpinner { @override void start() { - stopwatch = new Stopwatch()..start(); + stopwatch = Stopwatch()..start(); stdout.write('${message.padRight(padding)} '); super.start(); } diff --git a/packages/flutter_tools/lib/src/base/net.dart b/packages/flutter_tools/lib/src/base/net.dart index 343898f14c..1f761f3c43 100644 --- a/packages/flutter_tools/lib/src/base/net.dart +++ b/packages/flutter_tools/lib/src/base/net.dart @@ -23,7 +23,7 @@ Future> fetchUrl(Uri url) async { if (result != null) return result; printStatus('Download failed -- attempting retry $attempts in $duration second${ duration == 1 ? "" : "s"}...'); - await new Future.delayed(new Duration(seconds: duration)); + await Future.delayed(Duration(seconds: duration)); if (duration < 64) duration *= 2; } @@ -35,7 +35,7 @@ Future> _attempt(Uri url) async { if (context[HttpClientFactory] != null) { httpClient = context[HttpClientFactory](); } else { - httpClient = new HttpClient(); + httpClient = HttpClient(); } HttpClientRequest request; try { @@ -68,7 +68,7 @@ Future> _attempt(Uri url) async { } printTrace('Received response from server, collecting bytes...'); try { - final BytesBuilder responseBody = new BytesBuilder(copy: false); + final BytesBuilder responseBody = BytesBuilder(copy: false); await response.forEach(responseBody.add); return responseBody.takeBytes(); } on IOException catch (error) { diff --git a/packages/flutter_tools/lib/src/base/os.dart b/packages/flutter_tools/lib/src/base/os.dart index 1faa3d337e..8c3b30dd69 100644 --- a/packages/flutter_tools/lib/src/base/os.dart +++ b/packages/flutter_tools/lib/src/base/os.dart @@ -16,9 +16,9 @@ OperatingSystemUtils get os => context[OperatingSystemUtils]; abstract class OperatingSystemUtils { factory OperatingSystemUtils() { if (platform.isWindows) { - return new _WindowsUtils(); + return _WindowsUtils(); } else { - return new _PosixUtils(); + return _PosixUtils(); } } @@ -155,7 +155,7 @@ class _WindowsUtils extends OperatingSystemUtils { // This is a no-op. @override ProcessResult makeExecutable(File file) { - return new ProcessResult(0, 0, null, null); + return ProcessResult(0, 0, null, null); } @override @@ -172,7 +172,7 @@ class _WindowsUtils extends OperatingSystemUtils { @override void zip(Directory data, File zipFile) { - final Archive archive = new Archive(); + final Archive archive = Archive(); for (FileSystemEntity entity in data.listSync(recursive: true)) { if (entity is! File) { continue; @@ -180,21 +180,21 @@ class _WindowsUtils extends OperatingSystemUtils { final File file = entity; final String path = file.fileSystem.path.relative(file.path, from: data.path); final List bytes = file.readAsBytesSync(); - archive.addFile(new ArchiveFile(path, bytes.length, bytes)); + archive.addFile(ArchiveFile(path, bytes.length, bytes)); } - zipFile.writeAsBytesSync(new ZipEncoder().encode(archive), flush: true); + zipFile.writeAsBytesSync(ZipEncoder().encode(archive), flush: true); } @override void unzip(File file, Directory targetDirectory) { - final Archive archive = new ZipDecoder().decodeBytes(file.readAsBytesSync()); + final Archive archive = ZipDecoder().decodeBytes(file.readAsBytesSync()); _unpackArchive(archive, targetDirectory); } @override bool verifyZip(File zipFile) { try { - new ZipDecoder().decodeBytes(zipFile.readAsBytesSync(), verify: true); + ZipDecoder().decodeBytes(zipFile.readAsBytesSync(), verify: true); } on FileSystemException catch (_) { return false; } on ArchiveException catch (_) { @@ -205,8 +205,8 @@ class _WindowsUtils extends OperatingSystemUtils { @override void unpack(File gzippedTarFile, Directory targetDirectory) { - final Archive archive = new TarDecoder().decodeBytes( - new GZipDecoder().decodeBytes(gzippedTarFile.readAsBytesSync()), + final Archive archive = TarDecoder().decodeBytes( + GZipDecoder().decodeBytes(gzippedTarFile.readAsBytesSync()), ); _unpackArchive(archive, targetDirectory); } @@ -214,7 +214,7 @@ class _WindowsUtils extends OperatingSystemUtils { @override bool verifyGzip(File gzipFile) { try { - new GZipDecoder().decodeBytes(gzipFile.readAsBytesSync(), verify: true); + GZipDecoder().decodeBytes(gzipFile.readAsBytesSync(), verify: true); } on FileSystemException catch (_) { return false; } on ArchiveException catch (_) { @@ -238,7 +238,7 @@ class _WindowsUtils extends OperatingSystemUtils { @override File makePipe(String path) { - throw new UnsupportedError('makePipe is not implemented on Windows.'); + throw UnsupportedError('makePipe is not implemented on Windows.'); } String _name; diff --git a/packages/flutter_tools/lib/src/base/platform.dart b/packages/flutter_tools/lib/src/base/platform.dart index 1a45a08503..359cc5f826 100644 --- a/packages/flutter_tools/lib/src/base/platform.dart +++ b/packages/flutter_tools/lib/src/base/platform.dart @@ -36,7 +36,7 @@ Future getReplayPlatform(String location) async { final Directory dir = getReplaySource(location, _kRecordingType); final File file = _getPlatformManifest(dir); final String json = await file.readAsString(); - return new FakePlatform.fromJson(json); + return FakePlatform.fromJson(json); } File _getPlatformManifest(Directory dir) { diff --git a/packages/flutter_tools/lib/src/base/process.dart b/packages/flutter_tools/lib/src/base/process.dart index 247e5cef13..09c146c02e 100644 --- a/packages/flutter_tools/lib/src/base/process.dart +++ b/packages/flutter_tools/lib/src/base/process.dart @@ -205,7 +205,7 @@ Future runInteractively(List command, { Future runAndKill(List cmd, Duration timeout) { final Future proc = runDetached(cmd); - return new Future.delayed(timeout, () async { + return Future.delayed(timeout, () async { printTrace('Intentionally killing ${cmd[0]}'); processManager.killPid((await proc).pid); }); @@ -231,7 +231,7 @@ Future runAsync(List cmd, { workingDirectory: workingDirectory, environment: _environment(allowReentrantFlutter, environment), ); - final RunResult runResults = new RunResult(results, cmd); + final RunResult runResults = RunResult(results, cmd); printTrace(runResults.toString()); return runResults; } @@ -379,7 +379,7 @@ class RunResult { @override String toString() { - final StringBuffer out = new StringBuffer(); + final StringBuffer out = StringBuffer(); if (processResult.stdout.isNotEmpty) out.writeln(processResult.stdout); if (processResult.stderr.isNotEmpty) @@ -389,7 +389,7 @@ class RunResult { /// Throws a [ProcessException] with the given `message`. void throwException(String message) { - throw new ProcessException( + throw ProcessException( _command.first, _command.skip(1).toList(), message, diff --git a/packages/flutter_tools/lib/src/base/process_manager.dart b/packages/flutter_tools/lib/src/base/process_manager.dart index 4420e51e95..cbf866125c 100644 --- a/packages/flutter_tools/lib/src/base/process_manager.dart +++ b/packages/flutter_tools/lib/src/base/process_manager.dart @@ -28,7 +28,7 @@ ProcessManager get processManager => context[ProcessManager] ?? _kLocalProcessMa RecordingProcessManager getRecordingProcessManager(String location) { final Directory dir = getRecordingSink(location, _kRecordingType); const ProcessManager delegate = LocalProcessManager(); - final RecordingProcessManager manager = new RecordingProcessManager(delegate, dir); + final RecordingProcessManager manager = RecordingProcessManager(delegate, dir); addShutdownHook(() async { await manager.flush(finishRunningProcesses: true); }, ShutdownStage.SERIALIZE_RECORDING); diff --git a/packages/flutter_tools/lib/src/base/terminal.dart b/packages/flutter_tools/lib/src/base/terminal.dart index 2efff21c7a..c6c21b9d77 100644 --- a/packages/flutter_tools/lib/src/base/terminal.dart +++ b/packages/flutter_tools/lib/src/base/terminal.dart @@ -12,7 +12,7 @@ import 'context.dart'; import 'io.dart' as io; import 'platform.dart'; -final AnsiTerminal _kAnsiTerminal = new AnsiTerminal(); +final AnsiTerminal _kAnsiTerminal = AnsiTerminal(); AnsiTerminal get terminal { return (context == null || context[AnsiTerminal] == null) @@ -30,7 +30,7 @@ class AnsiTerminal { String bolden(String message) { if (!supportsColor) return message; - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); for (String line in message.split('\n')) buffer.writeln('$_bold$line$_reset'); final String result = buffer.toString(); @@ -88,7 +88,7 @@ class AnsiTerminal { List charactersToDisplay = acceptedCharacters; if (defaultChoiceIndex != null) { assert(defaultChoiceIndex >= 0 && defaultChoiceIndex < acceptedCharacters.length); - charactersToDisplay = new List.from(charactersToDisplay); + charactersToDisplay = List.from(charactersToDisplay); charactersToDisplay[defaultChoiceIndex] = bolden(charactersToDisplay[defaultChoiceIndex]); acceptedCharacters.add('\n'); } diff --git a/packages/flutter_tools/lib/src/base/utils.dart b/packages/flutter_tools/lib/src/base/utils.dart index 6756c71b2c..8b22e86671 100644 --- a/packages/flutter_tools/lib/src/base/utils.dart +++ b/packages/flutter_tools/lib/src/base/utils.dart @@ -53,7 +53,7 @@ bool get isRunningOnBot { } String hex(List bytes) { - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); for (int part in bytes) result.write('${part < 16 ? '0' : ''}${part.toRadixString(16)}'); return result.toString(); @@ -75,7 +75,7 @@ String camelCase(String str) { return str; } -final RegExp _upperRegex = new RegExp(r'[A-Z]'); +final RegExp _upperRegex = RegExp(r'[A-Z]'); /// Convert `fooBar` to `foo_bar`. String snakeCase(String str, [String sep = '_']) { @@ -121,8 +121,8 @@ String getSizeAsMB(int bytesLength) { return '${(bytesLength / (1024 * 1024)).toStringAsFixed(1)}MB'; } -final NumberFormat kSecondsFormat = new NumberFormat('0.0'); -final NumberFormat kMillisecondsFormat = new NumberFormat.decimalPattern(); +final NumberFormat kSecondsFormat = NumberFormat('0.0'); +final NumberFormat kMillisecondsFormat = NumberFormat.decimalPattern(); String getElapsedAsSeconds(Duration duration) { final double seconds = duration.inMilliseconds / Duration.millisecondsPerSecond; @@ -145,17 +145,17 @@ String getDisplayPath(String fullPath) { /// available. class ItemListNotifier { ItemListNotifier() { - _items = new Set(); + _items = Set(); } ItemListNotifier.from(List items) { - _items = new Set.from(items); + _items = Set.from(items); } Set _items; - final StreamController _addedController = new StreamController.broadcast(); - final StreamController _removedController = new StreamController.broadcast(); + final StreamController _addedController = StreamController.broadcast(); + final StreamController _removedController = StreamController.broadcast(); Stream get onAdded => _addedController.stream; Stream get onRemoved => _removedController.stream; @@ -163,7 +163,7 @@ class ItemListNotifier { List get items => _items.toList(); void updateWithNewList(List updatedList) { - final Set updatedSet = new Set.from(updatedList); + final Set updatedSet = Set.from(updatedList); final Set addedItems = updatedSet.difference(_items); final Set removedItems = _items.difference(updatedSet); @@ -196,7 +196,7 @@ class SettingsFile { } factory SettingsFile.parseFromFile(File file) { - return new SettingsFile.parse(file.readAsStringSync()); + return SettingsFile.parse(file.readAsStringSync()); } final Map values = {}; @@ -217,7 +217,7 @@ class SettingsFile { /// For more information, see /// http://en.wikipedia.org/wiki/Universally_unique_identifier. class Uuid { - final Random _random = new Random(); + final Random _random = Random(); /// Generate a version 4 (random) UUID. This is a UUID scheme that only uses /// random numbers as the source of the generated UUID. @@ -258,7 +258,7 @@ typedef Future AsyncCallback(); /// - waits for a callback to be complete before it starts the next timer class Poller { Poller(this.callback, this.pollingInterval, { this.initialDelay = Duration.zero }) { - new Future.delayed(initialDelay, _handleCallback); + Future.delayed(initialDelay, _handleCallback); } final AsyncCallback callback; @@ -279,7 +279,7 @@ class Poller { } if (!_cancelled) - _timer = new Timer(pollingInterval, _handleCallback); + _timer = Timer(pollingInterval, _handleCallback); } /// Cancels the poller. diff --git a/packages/flutter_tools/lib/src/base/version.dart b/packages/flutter_tools/lib/src/base/version.dart index 02aa239fa9..663c43e073 100644 --- a/packages/flutter_tools/lib/src/base/version.dart +++ b/packages/flutter_tools/lib/src/base/version.dart @@ -4,7 +4,7 @@ class Version implements Comparable { static final RegExp versionPattern = - new RegExp(r'^(\d+)(\.(\d+)(\.(\d+))?)?'); + RegExp(r'^(\d+)(\.(\d+)(\.(\d+))?)?'); /// The major version number: "1" in "1.2.3". final int major; @@ -31,16 +31,16 @@ class Version implements Comparable { text = '$text.$patch'; } - return new Version._(major ?? 0, minor ?? 0, patch ?? 0, text); + return Version._(major ?? 0, minor ?? 0, patch ?? 0, text); } Version._(this.major, this.minor, this.patch, this._text) { if (major < 0) - throw new ArgumentError('Major version must be non-negative.'); + throw ArgumentError('Major version must be non-negative.'); if (minor < 0) - throw new ArgumentError('Minor version must be non-negative.'); + throw ArgumentError('Minor version must be non-negative.'); if (patch < 0) - throw new ArgumentError('Patch version must be non-negative.'); + throw ArgumentError('Patch version must be non-negative.'); } /// Creates a new [Version] by parsing [text]. @@ -54,7 +54,7 @@ class Version implements Comparable { final int major = int.parse(match[1] ?? '0'); final int minor = int.parse(match[3] ?? '0'); final int patch = int.parse(match[5] ?? '0'); - return new Version._(major, minor, patch, text); + return Version._(major, minor, patch, text); } on FormatException { return null; } @@ -74,7 +74,7 @@ class Version implements Comparable { } - static Version get unknown => new Version(0, 0, 0, text: 'unknown'); + static Version get unknown => Version(0, 0, 0, text: 'unknown'); /// Two [Version]s are equal if their version numbers are. The version text /// is ignored. diff --git a/packages/flutter_tools/lib/src/build_info.dart b/packages/flutter_tools/lib/src/build_info.dart index 0b4e0312c6..7db6522249 100644 --- a/packages/flutter_tools/lib/src/build_info.dart +++ b/packages/flutter_tools/lib/src/build_info.dart @@ -94,7 +94,7 @@ class BuildInfo { String get modeName => getModeName(mode); BuildInfo withTargetPlatform(TargetPlatform targetPlatform) => - new BuildInfo(mode, flavor, + BuildInfo(mode, flavor, trackWidgetCreation: trackWidgetCreation, compilationTraceFilePath: compilationTraceFilePath, extraFrontEndOptions: extraFrontEndOptions, @@ -259,7 +259,7 @@ String getBuildDirectory() { final String buildDir = config.getValue('build-dir') ?? 'build'; if (fs.path.isAbsolute(buildDir)) { - throw new Exception( + throw Exception( 'build-dir config setting in ${config.configPath} must be relative'); } return buildDir; diff --git a/packages/flutter_tools/lib/src/bundle.dart b/packages/flutter_tools/lib/src/bundle.dart index 8f3fe07e43..4d75a3d468 100644 --- a/packages/flutter_tools/lib/src/bundle.dart +++ b/packages/flutter_tools/lib/src/bundle.dart @@ -79,13 +79,13 @@ Future build({ if (compilerOutput?.outputFilename == null) { throwToolExit('Compiler failed on $mainPath'); } - kernelContent = new DevFSFileContent(fs.file(compilerOutput.outputFilename)); + kernelContent = DevFSFileContent(fs.file(compilerOutput.outputFilename)); await fs.directory(getBuildDirectory()).childFile('frontend_server.d') .writeAsString('frontend_server.d: ${artifacts.getArtifactPath(Artifact.frontendServerSnapshotForEngineDartSdk)}\n'); if (compilationTraceFilePath != null) { - final CoreJITSnapshotter snapshotter = new CoreJITSnapshotter(); + final CoreJITSnapshotter snapshotter = CoreJITSnapshotter(); final int snapshotExitCode = await snapshotter.build( platform: platform, buildMode: buildMode, @@ -155,29 +155,29 @@ Future assemble({ assetDirPath ??= getAssetBuildDirectory(); printTrace('Building bundle'); - final Map assetEntries = new Map.from(assetBundle.entries); + final Map assetEntries = Map.from(assetBundle.entries); if (kernelContent != null) { if (compilationTraceFilePath != null) { final String vmSnapshotData = fs.path.join(getBuildDirectory(), _kVMSnapshotData); final String vmSnapshotInstr = fs.path.join(getBuildDirectory(), _kVMSnapshotInstr); final String isolateSnapshotData = fs.path.join(getBuildDirectory(), _kIsolateSnapshotData); final String isolateSnapshotInstr = fs.path.join(getBuildDirectory(), _kIsolateSnapshotInstr); - assetEntries[_kVMSnapshotData] = new DevFSFileContent(fs.file(vmSnapshotData)); - assetEntries[_kVMSnapshotInstr] = new DevFSFileContent(fs.file(vmSnapshotInstr)); - assetEntries[_kIsolateSnapshotData] = new DevFSFileContent(fs.file(isolateSnapshotData)); - assetEntries[_kIsolateSnapshotInstr] = new DevFSFileContent(fs.file(isolateSnapshotInstr)); + assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); + assetEntries[_kVMSnapshotInstr] = DevFSFileContent(fs.file(vmSnapshotInstr)); + assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); + assetEntries[_kIsolateSnapshotInstr] = DevFSFileContent(fs.file(isolateSnapshotInstr)); } else { final String platformKernelDill = artifacts.getArtifactPath(Artifact.platformKernelDill); final String vmSnapshotData = artifacts.getArtifactPath(Artifact.vmSnapshotData); final String isolateSnapshotData = artifacts.getArtifactPath(Artifact.isolateSnapshotData); assetEntries[_kKernelKey] = kernelContent; - assetEntries[_kPlatformKernelKey] = new DevFSFileContent(fs.file(platformKernelDill)); - assetEntries[_kVMSnapshotData] = new DevFSFileContent(fs.file(vmSnapshotData)); - assetEntries[_kIsolateSnapshotData] = new DevFSFileContent(fs.file(isolateSnapshotData)); + assetEntries[_kPlatformKernelKey] = DevFSFileContent(fs.file(platformKernelDill)); + assetEntries[_kVMSnapshotData] = DevFSFileContent(fs.file(vmSnapshotData)); + assetEntries[_kIsolateSnapshotData] = DevFSFileContent(fs.file(isolateSnapshotData)); } } if (dylibFile != null) - assetEntries[_kDylibKey] = new DevFSFileContent(dylibFile); + assetEntries[_kDylibKey] = DevFSFileContent(dylibFile); printTrace('Writing asset files to $assetDirPath'); ensureDirectoryExists(assetDirPath); diff --git a/packages/flutter_tools/lib/src/cache.dart b/packages/flutter_tools/lib/src/cache.dart index ffc4af5d07..8e2325c73e 100644 --- a/packages/flutter_tools/lib/src/cache.dart +++ b/packages/flutter_tools/lib/src/cache.dart @@ -21,9 +21,9 @@ class Cache { /// [artifacts] is configurable for testing. Cache({ Directory rootOverride, List artifacts }) : _rootOverride = rootOverride { if (artifacts == null) { - _artifacts.add(new MaterialFonts(this)); - _artifacts.add(new FlutterEngine(this)); - _artifacts.add(new GradleWrapper(this)); + _artifacts.add(MaterialFonts(this)); + _artifacts.add(FlutterEngine(this)); + _artifacts.add(GradleWrapper(this)); } else { _artifacts.addAll(artifacts); } @@ -87,7 +87,7 @@ class Cache { printStatus('Waiting for another flutter command to release the startup lock...'); printed = true; } - await new Future.delayed(const Duration(milliseconds: 50)); + await Future.delayed(const Duration(milliseconds: 50)); } } } @@ -104,7 +104,7 @@ class Cache { /// this very moment; throws a [StateError] if it doesn't. static void checkLockAcquired() { if (_lockEnabled && _lock == null && platform.environment['FLUTTER_ALREADY_LOCKED'] != 'true') { - throw new StateError( + throw StateError( 'The current process does not own the lock for the cache directory. This is a bug in Flutter CLI tools.', ); } @@ -554,7 +554,7 @@ String _flattenNameNoSubdirs(String fileName) { for (int codeUnit in fileName.codeUnits) { replacedCodeUnits.addAll(_flattenNameSubstitutions[codeUnit] ?? [codeUnit]); } - return new String.fromCharCodes(replacedCodeUnits); + return String.fromCharCodes(replacedCodeUnits); } @visibleForTesting diff --git a/packages/flutter_tools/lib/src/commands/analyze.dart b/packages/flutter_tools/lib/src/commands/analyze.dart index c79ba2960e..1da4c74362 100644 --- a/packages/flutter_tools/lib/src/commands/analyze.dart +++ b/packages/flutter_tools/lib/src/commands/analyze.dart @@ -82,13 +82,13 @@ class AnalyzeCommand extends FlutterCommand { @override Future runCommand() { if (argResults['watch']) { - return new AnalyzeContinuously( + return AnalyzeContinuously( argResults, runner.getRepoRoots(), runner.getRepoPackages(), ).analyze(); } else { - return new AnalyzeOnce( + return AnalyzeOnce( argResults, runner.getRepoRoots(), runner.getRepoPackages(), diff --git a/packages/flutter_tools/lib/src/commands/analyze_base.dart b/packages/flutter_tools/lib/src/commands/analyze_base.dart index 5e07adc00a..04547d28fb 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_base.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_base.dart @@ -123,7 +123,7 @@ class PackageDependencyTracker { Map packages = {}; PackageDependency getPackageDependency(String packageName) { - return packages.putIfAbsent(packageName, () => new PackageDependency()); + return packages.putIfAbsent(packageName, () => PackageDependency()); } /// Read the .packages file in [directory] and add referenced packages to [dependencies]. @@ -135,7 +135,7 @@ class PackageDependencyTracker { final Iterable lines = dotPackages .readAsStringSync() .split('\n') - .where((String line) => !line.startsWith(new RegExp(r'^ *#'))); + .where((String line) => !line.startsWith(RegExp(r'^ *#'))); for (String line in lines) { final int colon = line.indexOf(':'); if (colon > 0) { @@ -177,7 +177,7 @@ class PackageDependencyTracker { // prepare a union of all the .packages files if (dependencies.hasConflicts) { - final StringBuffer message = new StringBuffer(); + final StringBuffer message = StringBuffer(); message.writeln(dependencies.generateConflictReport()); message.writeln('Make sure you have run "pub upgrade" in all the directories mentioned above.'); if (dependencies.hasConflictsAffectingFlutterRepo) { @@ -205,7 +205,7 @@ class PackageDependencyTracker { String generateConflictReport() { assert(hasConflicts); - final StringBuffer result = new StringBuffer(); + final StringBuffer result = StringBuffer(); for (String package in packages.keys.where((String package) => packages[package].hasConflict)) { result.writeln('Package "$package" has conflicts:'); packages[package].describeConflict(result); diff --git a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart index 33097534a4..c326608f32 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_continuously.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_continuously.dart @@ -26,7 +26,7 @@ class AnalyzeContinuously extends AnalyzeBase { String analysisTarget; bool firstAnalysis = true; - Set analyzedPaths = new Set(); + Set analyzedPaths = Set(); Map> analysisErrors = >{}; Stopwatch analysisTimer; int lastErrorCount = 0; @@ -37,7 +37,7 @@ class AnalyzeContinuously extends AnalyzeBase { List directories; if (argResults['flutter-repo']) { - final PackageDependencyTracker dependencies = new PackageDependencyTracker(); + final PackageDependencyTracker dependencies = PackageDependencyTracker(); dependencies.checkForConflictingDependencies(repoPackages, dependencies); directories = repoRoots; @@ -54,7 +54,7 @@ class AnalyzeContinuously extends AnalyzeBase { final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath; - final AnalysisServer server = new AnalysisServer(sdkPath, directories); + final AnalysisServer server = AnalysisServer(sdkPath, directories); server.onAnalyzing.listen((bool isAnalyzing) => _handleAnalysisStatus(server, isAnalyzing)); server.onErrors.listen(_handleAnalysisErrors); @@ -76,7 +76,7 @@ class AnalyzeContinuously extends AnalyzeBase { printStatus('\n'); analysisStatus = logger.startProgress('Analyzing $analysisTarget...'); analyzedPaths.clear(); - analysisTimer = new Stopwatch()..start(); + analysisTimer = Stopwatch()..start(); } else { analysisStatus?.stop(); analysisTimer.stop(); diff --git a/packages/flutter_tools/lib/src/commands/analyze_once.dart b/packages/flutter_tools/lib/src/commands/analyze_once.dart index 84d02a3e76..ae14c97679 100644 --- a/packages/flutter_tools/lib/src/commands/analyze_once.dart +++ b/packages/flutter_tools/lib/src/commands/analyze_once.dart @@ -38,7 +38,7 @@ class AnalyzeOnce extends AnalyzeBase { (workingDirectory ?? fs.currentDirectory).path; // find directories from argResults.rest - final Set directories = new Set.from(argResults.rest + final Set directories = Set.from(argResults.rest .map((String path) => fs.path.canonicalize(path))); if (directories.isNotEmpty) { for (String directory in directories) { @@ -54,7 +54,7 @@ class AnalyzeOnce extends AnalyzeBase { if (argResults['flutter-repo']) { // check for conflicting dependencies - final PackageDependencyTracker dependencies = new PackageDependencyTracker(); + final PackageDependencyTracker dependencies = PackageDependencyTracker(); dependencies.checkForConflictingDependencies(repoPackages, dependencies); directories.addAll(repoRoots); if (argResults.wasParsed('current-package') && argResults['current-package']) @@ -68,12 +68,12 @@ class AnalyzeOnce extends AnalyzeBase { throwToolExit('Nothing to analyze.', exitCode: 0); // analyze all - final Completer analysisCompleter = new Completer(); + final Completer analysisCompleter = Completer(); final List errors = []; final String sdkPath = argResults['dart-sdk'] ?? sdk.dartSdkPath; - final AnalysisServer server = new AnalysisServer( + final AnalysisServer server = AnalysisServer( sdkPath, directories.toList(), ); @@ -101,7 +101,7 @@ class AnalyzeOnce extends AnalyzeBase { Cache.releaseLockEarly(); // collect results - final Stopwatch timer = new Stopwatch()..start(); + final Stopwatch timer = Stopwatch()..start(); final String message = directories.length > 1 ? '${directories.length} ${directories.length == 1 ? 'directory' : 'directories'}' : fs.path.basename(directories.first); diff --git a/packages/flutter_tools/lib/src/commands/attach.dart b/packages/flutter_tools/lib/src/commands/attach.dart index 09ad900f5f..bcd8b24267 100644 --- a/packages/flutter_tools/lib/src/commands/attach.dart +++ b/packages/flutter_tools/lib/src/commands/attach.dart @@ -53,7 +53,7 @@ class AttachCommand extends FlutterCommand { help: 'Handle machine structured JSON command input and provide output\n' 'and progress in machine friendly format.', ); - hotRunnerFactory ??= new HotRunnerFactory(); + hotRunnerFactory ??= HotRunnerFactory(); } HotRunnerFactory hotRunnerFactory; @@ -93,15 +93,15 @@ class AttachCommand extends FlutterCommand { final int devicePort = observatoryPort; final Daemon daemon = argResults['machine'] - ? new Daemon(stdinCommandStream, stdoutCommandResponse, - notifyingLogger: new NotifyingLogger(), logToStdout: true) + ? Daemon(stdinCommandStream, stdoutCommandResponse, + notifyingLogger: NotifyingLogger(), logToStdout: true) : null; Uri observatoryUri; if (devicePort == null) { ProtocolDiscovery observatoryDiscovery; try { - observatoryDiscovery = new ProtocolDiscovery.observatory( + observatoryDiscovery = ProtocolDiscovery.observatory( device.getLogReader(), portForwarder: device.portForwarder, ); @@ -116,7 +116,7 @@ class AttachCommand extends FlutterCommand { observatoryUri = Uri.parse('http://$ipv4Loopback:$localPort/'); } try { - final FlutterDevice flutterDevice = new FlutterDevice( + final FlutterDevice flutterDevice = FlutterDevice( device, trackWidgetCreation: false, dillOutputPath: argResults['output-dill'], @@ -127,7 +127,7 @@ class AttachCommand extends FlutterCommand { final HotRunner hotRunner = hotRunnerFactory.build( [flutterDevice], target: targetFile, - debuggingOptions: new DebuggingOptions.enabled(getBuildInfo()), + debuggingOptions: DebuggingOptions.enabled(getBuildInfo()), packagesFilePath: globalResults['packages'], usesTerminalUI: daemon == null, projectRootPath: argResults['project-root'], @@ -170,7 +170,7 @@ class HotRunnerFactory { String dillOutputPath, bool stayResident = true, bool ipv6 = false, - }) => new HotRunner( + }) => HotRunner( devices, target: target, debuggingOptions: debuggingOptions, diff --git a/packages/flutter_tools/lib/src/commands/build.dart b/packages/flutter_tools/lib/src/commands/build.dart index 5bf3990e59..eb5ab8e862 100644 --- a/packages/flutter_tools/lib/src/commands/build.dart +++ b/packages/flutter_tools/lib/src/commands/build.dart @@ -18,11 +18,11 @@ import 'build_ios.dart'; class BuildCommand extends FlutterCommand { BuildCommand({bool verboseHelp = false}) { - addSubcommand(new BuildApkCommand(verboseHelp: verboseHelp)); - addSubcommand(new BuildAotCommand()); - addSubcommand(new BuildIOSCommand()); - addSubcommand(new BuildFlxCommand()); - addSubcommand(new BuildBundleCommand(verboseHelp: verboseHelp)); + addSubcommand(BuildApkCommand(verboseHelp: verboseHelp)); + addSubcommand(BuildAotCommand()); + addSubcommand(BuildIOSCommand()); + addSubcommand(BuildFlxCommand()); + addSubcommand(BuildBundleCommand(verboseHelp: verboseHelp)); } @override diff --git a/packages/flutter_tools/lib/src/commands/build_aot.dart b/packages/flutter_tools/lib/src/commands/build_aot.dart index 4f379a5ae3..fb07c2311c 100644 --- a/packages/flutter_tools/lib/src/commands/build_aot.dart +++ b/packages/flutter_tools/lib/src/commands/build_aot.dart @@ -77,7 +77,7 @@ class BuildAotCommand extends BuildSubCommand { final String outputPath = argResults['output-dir'] ?? getAotBuildDirectory(); try { String mainPath = findMainDartFile(targetFile); - final AOTSnapshotter snapshotter = new AOTSnapshotter(); + final AOTSnapshotter snapshotter = AOTSnapshotter(); // Compile to kernel. mainPath = await snapshotter.compileKernel( diff --git a/packages/flutter_tools/lib/src/commands/channel.dart b/packages/flutter_tools/lib/src/commands/channel.dart index 6d141453fe..499fee1ddf 100644 --- a/packages/flutter_tools/lib/src/commands/channel.dart +++ b/packages/flutter_tools/lib/src/commands/channel.dart @@ -39,7 +39,7 @@ class ChannelCommand extends FlutterCommand { case 1: return _switchChannel(argResults.rest[0]); default: - throw new ToolExit('Too many arguments.\n$usage'); + throw ToolExit('Too many arguments.\n$usage'); } } @@ -47,7 +47,7 @@ class ChannelCommand extends FlutterCommand { // Beware: currentBranch could contain PII. See getBranchName(). final String currentChannel = FlutterVersion.instance.channel; final String currentBranch = FlutterVersion.instance.getBranchName(); - final Set seenChannels = new Set(); + final Set seenChannels = Set(); showAll = showAll || currentChannel != currentBranch; diff --git a/packages/flutter_tools/lib/src/commands/create.dart b/packages/flutter_tools/lib/src/commands/create.dart index 4f9f440078..a34ec89c59 100644 --- a/packages/flutter_tools/lib/src/commands/create.dart +++ b/packages/flutter_tools/lib/src/commands/create.dart @@ -360,7 +360,7 @@ To edit platform code in an IDE see https://flutter.io/developing-packages/#edit } int _renderTemplate(String templateName, Directory directory, Map context) { - final Template template = new Template.fromName(templateName); + final Template template = Template.fromName(templateName); return template.render(directory, context, overwriteExisting: false); } @@ -392,13 +392,13 @@ String _createPluginClassName(String name) { String _createUTIIdentifier(String organization, String name) { // Create a UTI (https://en.wikipedia.org/wiki/Uniform_Type_Identifier) from a base name - final RegExp disallowed = new RegExp(r'[^a-zA-Z0-9\-\.\u0080-\uffff]+'); + final RegExp disallowed = RegExp(r'[^a-zA-Z0-9\-\.\u0080-\uffff]+'); name = camelCase(name).replaceAll(disallowed, ''); name = name.isEmpty ? 'untitled' : name; return '$organization.$name'; } -final Set _packageDependencies = new Set.from([ +final Set _packageDependencies = Set.from([ 'analyzer', 'args', 'async', @@ -431,7 +431,7 @@ final Set _packageDependencies = new Set.from([ /// we should disallow the project name. String _validateProjectName(String projectName) { if (!linter_utils.isValidPackageName(projectName)) { - final String packageNameDetails = new package_names.PubPackageNames().details; + final String packageNameDetails = package_names.PubPackageNames().details; return '"$projectName" is not a valid Dart package name.\n\n$packageNameDetails'; } if (_packageDependencies.contains(projectName)) { diff --git a/packages/flutter_tools/lib/src/commands/daemon.dart b/packages/flutter_tools/lib/src/commands/daemon.dart index 5bb22bb99e..614f30ad23 100644 --- a/packages/flutter_tools/lib/src/commands/daemon.dart +++ b/packages/flutter_tools/lib/src/commands/daemon.dart @@ -52,13 +52,13 @@ class DaemonCommand extends FlutterCommand { Future runCommand() { printStatus('Starting device daemon...'); - final NotifyingLogger notifyingLogger = new NotifyingLogger(); + final NotifyingLogger notifyingLogger = NotifyingLogger(); Cache.releaseLockEarly(); return context.run( body: () async { - final Daemon daemon = new Daemon( + final Daemon daemon = Daemon( stdinCommandStream, stdoutCommandResponse, daemonCommand: this, notifyingLogger: notifyingLogger); @@ -86,10 +86,10 @@ class Daemon { this.logToStdout = false, }) { // Set up domains. - _registerDomain(daemonDomain = new DaemonDomain(this)); - _registerDomain(appDomain = new AppDomain(this)); - _registerDomain(deviceDomain = new DeviceDomain(this)); - _registerDomain(emulatorDomain = new EmulatorDomain(this)); + _registerDomain(daemonDomain = DaemonDomain(this)); + _registerDomain(appDomain = AppDomain(this)); + _registerDomain(deviceDomain = DeviceDomain(this)); + _registerDomain(emulatorDomain = EmulatorDomain(this)); // Start listening. _commandSubscription = commandStream.listen( @@ -112,7 +112,7 @@ class Daemon { final NotifyingLogger notifyingLogger; final bool logToStdout; - final Completer _onExitCompleter = new Completer(); + final Completer _onExitCompleter = Completer(); final Map _domainMap = {}; void _registerDomain(Domain domain) { @@ -184,7 +184,7 @@ abstract class Domain { String toString() => name; void handleCommand(String command, dynamic id, Map args) { - new Future.sync(() { + Future.sync(() { if (_handlers.containsKey(command)) return _handlers[command](args); throw 'command not understood: $name.$command'; @@ -289,12 +289,12 @@ class DaemonDomain extends Domain { StreamSubscription _subscription; Future version(Map args) { - return new Future.value(protocolVersion); + return Future.value(protocolVersion); } Future shutdown(Map args) { Timer.run(daemon.shutdown); - return new Future.value(); + return Future.value(); } @override @@ -319,7 +319,7 @@ class AppDomain extends Domain { registerHandler('detach', detach); } - static final Uuid _uuidGenerator = new Uuid(); + static final Uuid _uuidGenerator = Uuid(); static String _getNewAppId() => _uuidGenerator.generateV4(); @@ -343,7 +343,7 @@ class AppDomain extends Domain { final Directory cwd = fs.currentDirectory; fs.currentDirectory = fs.directory(projectDirectory); - final FlutterDevice flutterDevice = new FlutterDevice( + final FlutterDevice flutterDevice = FlutterDevice( device, trackWidgetCreation: trackWidgetCreation, dillOutputPath: dillOutputPath, @@ -352,7 +352,7 @@ class AppDomain extends Domain { ResidentRunner runner; if (enableHotReload) { - runner = new HotRunner( + runner = HotRunner( [flutterDevice], target: target, debuggingOptions: options, @@ -365,7 +365,7 @@ class AppDomain extends Domain { hostIsIde: true, ); } else { - runner = new ColdRunner( + runner = ColdRunner( [flutterDevice], target: target, debuggingOptions: options, @@ -395,7 +395,7 @@ class AppDomain extends Domain { String projectDirectory, bool enableHotReload, Directory cwd) async { - final AppInstance app = new AppInstance(_getNewAppId(), + final AppInstance app = AppInstance(_getNewAppId(), runner: runner, logToStdout: daemon.logToStdout); _apps.add(app); _sendAppEvent(app, 'start', { @@ -407,7 +407,7 @@ class AppDomain extends Domain { Completer connectionInfoCompleter; if (runner.debuggingOptions.debuggingEnabled) { - connectionInfoCompleter = new Completer(); + connectionInfoCompleter = Completer(); // We don't want to wait for this future to complete and callbacks won't fail. // As it just writes to stdout. connectionInfoCompleter.future.then((DebugConnectionInfo info) { // ignore: unawaited_futures @@ -420,7 +420,7 @@ class AppDomain extends Domain { _sendAppEvent(app, 'debugPort', params); }); } - final Completer appStartedCompleter = new Completer(); + final Completer appStartedCompleter = Completer(); // We don't want to wait for this future to complete and callbacks won't fail. // As it just writes to stdout. appStartedCompleter.future.timeout(const Duration(minutes: 1), onTimeout: () { // ignore: unawaited_futures @@ -565,10 +565,10 @@ class DeviceDomain extends Domain { registerHandler('forward', forward); registerHandler('unforward', unforward); - addDeviceDiscoverer(new AndroidDevices()); - addDeviceDiscoverer(new IOSDevices()); - addDeviceDiscoverer(new IOSSimulators()); - addDeviceDiscoverer(new FlutterTesterDevices()); + addDeviceDiscoverer(AndroidDevices()); + addDeviceDiscoverer(IOSDevices()); + addDeviceDiscoverer(IOSSimulators()); + addDeviceDiscoverer(FlutterTesterDevices()); } void addDeviceDiscoverer(PollingDeviceDiscovery discoverer) { @@ -596,7 +596,7 @@ class DeviceDomain extends Domain { discoverer.onRemoved.listen(_onDeviceEvent('device.removed')); } - Future _serializeDeviceEvents = new Future.value(); + Future _serializeDeviceEvents = Future.value(); _DeviceEventHandler _onDeviceEvent(String eventName) { return (Device device) { @@ -620,14 +620,14 @@ class DeviceDomain extends Domain { Future enable(Map args) { for (PollingDeviceDiscovery discoverer in _discoverers) discoverer.startPolling(); - return new Future.value(); + return Future.value(); } /// Disable device events. Future disable(Map args) { for (PollingDeviceDiscovery discoverer in _discoverers) discoverer.stopPolling(); - return new Future.value(); + return Future.value(); } /// Forward a host port to a device port. @@ -655,7 +655,7 @@ class DeviceDomain extends Domain { if (device == null) throw "device '$deviceId' not found"; - return device.portForwarder.unforward(new ForwardedPort(hostPort, devicePort)); + return device.portForwarder.unforward(ForwardedPort(hostPort, devicePort)); } @override @@ -739,13 +739,13 @@ dynamic _toJsonable(dynamic obj) { } class NotifyingLogger extends Logger { - final StreamController _messageController = new StreamController.broadcast(); + final StreamController _messageController = StreamController.broadcast(); Stream get onMessage => _messageController.stream; @override void printError(String message, { StackTrace stackTrace, bool emphasis = false }) { - _messageController.add(new LogMessage('error', message, stackTrace)); + _messageController.add(LogMessage('error', message, stackTrace)); } @override @@ -753,7 +753,7 @@ class NotifyingLogger extends Logger { String message, { bool emphasis = false, bool newline = true, String ansiAlternative, int indent } ) { - _messageController.add(new LogMessage('status', message)); + _messageController.add(LogMessage('status', message)); } @override @@ -769,7 +769,7 @@ class NotifyingLogger extends Logger { int progressIndicatorPadding = kDefaultStatusPadding, }) { printStatus(message); - return new Status(); + return Status(); } void dispose() { @@ -799,7 +799,7 @@ class AppInstance { } Future _runInZone(AppDomain domain, dynamic method()) { - _logger ??= new _AppRunLogger(domain, this, parent: logToStdout ? logger : null); + _logger ??= _AppRunLogger(domain, this, parent: logToStdout ? logger : null); return context.run( body: method, @@ -812,7 +812,7 @@ class AppInstance { /// This domain responds to methods like [getEmulators] and [launch]. class EmulatorDomain extends Domain { - EmulatorManager emulators = new EmulatorManager(); + EmulatorManager emulators = EmulatorManager(); EmulatorDomain(Daemon daemon) : super(daemon, 'emulator') { registerHandler('getEmulators', getEmulators); @@ -924,7 +924,7 @@ class _AppRunLogger extends Logger { 'message': message, }); - _status = new Status(onFinish: () { + _status = Status(onFinish: () { _status = null; _sendProgressEvent({ 'id': id.toString(), diff --git a/packages/flutter_tools/lib/src/commands/doctor.dart b/packages/flutter_tools/lib/src/commands/doctor.dart index 0dd0b80671..4010476fd4 100644 --- a/packages/flutter_tools/lib/src/commands/doctor.dart +++ b/packages/flutter_tools/lib/src/commands/doctor.dart @@ -27,6 +27,6 @@ class DoctorCommand extends FlutterCommand { @override Future runCommand() async { final bool success = await doctor.diagnose(androidLicenses: argResults['android-licenses'], verbose: verbose); - return new FlutterCommandResult(success ? ExitStatus.success : ExitStatus.warning); + return FlutterCommandResult(success ? ExitStatus.success : ExitStatus.warning); } } diff --git a/packages/flutter_tools/lib/src/commands/drive.dart b/packages/flutter_tools/lib/src/commands/drive.dart index 0d7b529e9a..61f8d11a8e 100644 --- a/packages/flutter_tools/lib/src/commands/drive.dart +++ b/packages/flutter_tools/lib/src/commands/drive.dart @@ -254,7 +254,7 @@ Future _startApp(DriveCommand command) async { package, mainPath: mainPath, route: command.route, - debuggingOptions: new DebuggingOptions.enabled( + debuggingOptions: DebuggingOptions.enabled( command.getBuildInfo(), startPaused: true, observatoryPort: command.observatoryPort, diff --git a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart index 317960e5ce..10ed98a488 100644 --- a/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart +++ b/packages/flutter_tools/lib/src/commands/fuchsia_reload.dart @@ -128,16 +128,16 @@ class FuchsiaReloadCommand extends FlutterCommand { final List observatoryUris = fullAddresses.map( (String a) => Uri.parse('http://$a') ).toList(); - final FuchsiaDevice device = new FuchsiaDevice( + final FuchsiaDevice device = FuchsiaDevice( fullAddresses[0], name: _address); - final FlutterDevice flutterDevice = new FlutterDevice( + final FlutterDevice flutterDevice = FlutterDevice( device, trackWidgetCreation: false, ); flutterDevice.observatoryUris = observatoryUris; - final HotRunner hotRunner = new HotRunner( + final HotRunner hotRunner = HotRunner( [flutterDevice], - debuggingOptions: new DebuggingOptions.enabled(getBuildInfo()), + debuggingOptions: DebuggingOptions.enabled(getBuildInfo()), target: _target, projectRootPath: _fuchsiaProjectPath, packagesFilePath: _dotPackagesPath @@ -150,7 +150,7 @@ class FuchsiaReloadCommand extends FlutterCommand { } // A cache of VMService connections. - final HashMap _vmServiceCache = new HashMap(); + final HashMap _vmServiceCache = HashMap(); Future _getVMService(int port) async { if (!_vmServiceCache.containsKey(port)) { @@ -217,7 +217,7 @@ class FuchsiaReloadCommand extends FlutterCommand { final String external = getSizeAsMB(totalExternal); final String tabs = '\t' * tabDepth; final String extraTabs = '\t' * (tabDepth + 1); - final StringBuffer stringBuffer = new StringBuffer( + final StringBuffer stringBuffer = StringBuffer( '$tabs$_bold$embedder at $addr$_reset\n' '${extraTabs}RSS: $maxRSS\n' '${extraTabs}Native allocations: $heapSize\n' @@ -372,7 +372,7 @@ class FuchsiaReloadCommand extends FlutterCommand { Future> _getServicePorts() async { final FuchsiaDeviceCommandRunner runner = - new FuchsiaDeviceCommandRunner(_address, _buildDir); + FuchsiaDeviceCommandRunner(_address, _buildDir); final List lsOutput = await runner.run('ls /tmp/dart.services'); final List ports = []; if (lsOutput != null) { @@ -427,7 +427,7 @@ class _PortForwarder { if (localPort == 0) { printStatus( '_PortForwarder failed to find a local port for $address:$remotePort'); - return new _PortForwarder._(null, 0, 0, null, null); + return _PortForwarder._(null, 0, 0, null, null); } const String dummyRemoteCommand = 'date'; final List command = [ @@ -444,7 +444,7 @@ class _PortForwarder { printTrace("'${command.join(' ')}' exited with exit code $c"); }); printTrace('Set up forwarding from $localPort to $address:$remotePort'); - return new _PortForwarder._(address, remotePort, localPort, process, sshConfig); + return _PortForwarder._(address, remotePort, localPort, process, sshConfig); } Future stop() async { diff --git a/packages/flutter_tools/lib/src/commands/ide_config.dart b/packages/flutter_tools/lib/src/commands/ide_config.dart index 1123cbd9d9..415555c2e9 100644 --- a/packages/flutter_tools/lib/src/commands/ide_config.dart +++ b/packages/flutter_tools/lib/src/commands/ide_config.dart @@ -121,7 +121,7 @@ class IdeConfigCommand extends FlutterCommand { return; } - final Set manifest = new Set(); + final Set manifest = Set(); final List flutterFiles = _flutterRoot.listSync(recursive: true); for (FileSystemEntity entity in flutterFiles) { final String relativePath = fs.path.relative(entity.path, from: _flutterRoot.absolute.path); @@ -139,7 +139,7 @@ class IdeConfigCommand extends FlutterCommand { } // Skip files we aren't interested in. - final RegExp _trackedIdeaFileRegExp = new RegExp( + final RegExp _trackedIdeaFileRegExp = RegExp( r'(\.name|modules.xml|vcs.xml)$', ); final bool isATrackedIdeaFile = _hasDirectoryInPath(srcFile, '.idea') && @@ -253,7 +253,7 @@ class IdeConfigCommand extends FlutterCommand { } int _renderTemplate(String templateName, String dirPath, Map context) { - final Template template = new Template(_templateDirectory, _templateDirectory); + final Template template = Template(_templateDirectory, _templateDirectory); return template.render( fs.directory(dirPath), context, diff --git a/packages/flutter_tools/lib/src/commands/logs.dart b/packages/flutter_tools/lib/src/commands/logs.dart index a16b23fd9b..56212ad863 100644 --- a/packages/flutter_tools/lib/src/commands/logs.dart +++ b/packages/flutter_tools/lib/src/commands/logs.dart @@ -47,7 +47,7 @@ class LogsCommand extends FlutterCommand { printStatus('Showing $logReader logs:'); - final Completer exitCompleter = new Completer(); + final Completer exitCompleter = Completer(); // Start reading. final StreamSubscription subscription = logReader.logLines.listen( diff --git a/packages/flutter_tools/lib/src/commands/materialize.dart b/packages/flutter_tools/lib/src/commands/materialize.dart index 0c0f27d1e0..c785ea446f 100644 --- a/packages/flutter_tools/lib/src/commands/materialize.dart +++ b/packages/flutter_tools/lib/src/commands/materialize.dart @@ -10,8 +10,8 @@ import '../runner/flutter_command.dart'; class MaterializeCommand extends FlutterCommand { MaterializeCommand() { - addSubcommand(new MaterializeAndroidCommand()); - addSubcommand(new MaterializeIosCommand()); + addSubcommand(MaterializeAndroidCommand()); + addSubcommand(MaterializeIosCommand()); } @override @@ -45,7 +45,7 @@ abstract class MaterializeSubCommand extends FlutterCommand { await super.validateCommand(); _project = await FlutterProject.current(); if (!_project.isModule) - throw new ToolExit("Only projects created using 'flutter create -t module' can be materialized."); + throw ToolExit("Only projects created using 'flutter create -t module' can be materialized."); } } diff --git a/packages/flutter_tools/lib/src/commands/packages.dart b/packages/flutter_tools/lib/src/commands/packages.dart index b78e25b7fb..e010a35eb4 100644 --- a/packages/flutter_tools/lib/src/commands/packages.dart +++ b/packages/flutter_tools/lib/src/commands/packages.dart @@ -12,10 +12,10 @@ import '../runner/flutter_command.dart'; class PackagesCommand extends FlutterCommand { PackagesCommand() { - addSubcommand(new PackagesGetCommand('get', false)); - addSubcommand(new PackagesGetCommand('upgrade', true)); - addSubcommand(new PackagesTestCommand()); - addSubcommand(new PackagesPassthroughCommand()); + addSubcommand(PackagesGetCommand('get', false)); + addSubcommand(PackagesGetCommand('upgrade', true)); + addSubcommand(PackagesTestCommand()); + addSubcommand(PackagesPassthroughCommand()); } @override diff --git a/packages/flutter_tools/lib/src/commands/run.dart b/packages/flutter_tools/lib/src/commands/run.dart index 9f6891e40c..3443010b52 100644 --- a/packages/flutter_tools/lib/src/commands/run.dart +++ b/packages/flutter_tools/lib/src/commands/run.dart @@ -244,9 +244,9 @@ class RunCommand extends RunCommandBase { DebuggingOptions _createDebuggingOptions() { final BuildInfo buildInfo = getBuildInfo(); if (buildInfo.isRelease) { - return new DebuggingOptions.disabled(buildInfo); + return DebuggingOptions.disabled(buildInfo); } else { - return new DebuggingOptions.enabled( + return DebuggingOptions.enabled( buildInfo, startPaused: argResults['start-paused'], useTestFonts: argResults['use-test-fonts'], @@ -269,8 +269,8 @@ class RunCommand extends RunCommandBase { if (argResults['machine']) { if (devices.length > 1) throwToolExit('--machine does not support -d all.'); - final Daemon daemon = new Daemon(stdinCommandStream, stdoutCommandResponse, - notifyingLogger: new NotifyingLogger(), logToStdout: true); + final Daemon daemon = Daemon(stdinCommandStream, stdoutCommandResponse, + notifyingLogger: NotifyingLogger(), logToStdout: true); AppInstance app; try { final String applicationBinaryPath = argResults['use-application-binary']; @@ -293,7 +293,7 @@ class RunCommand extends RunCommandBase { final int result = await app.runner.waitForAppToFinish(); if (result != 0) throwToolExit(null, exitCode: result); - return new FlutterCommandResult( + return FlutterCommandResult( ExitStatus.success, timingLabelParts: ['daemon'], endTimeOverride: appStartedTime, @@ -337,7 +337,7 @@ class RunCommand extends RunCommandBase { } final List flutterDevices = devices.map((Device device) { - return new FlutterDevice( + return FlutterDevice( device, trackWidgetCreation: argResults['track-widget-creation'], dillOutputPath: argResults['output-dill'], @@ -349,7 +349,7 @@ class RunCommand extends RunCommandBase { ResidentRunner runner; final String applicationBinaryPath = argResults['use-application-binary']; if (hotMode) { - runner = new HotRunner( + runner = HotRunner( flutterDevices, target: targetFile, debuggingOptions: _createDebuggingOptions(), @@ -364,7 +364,7 @@ class RunCommand extends RunCommandBase { ipv6: ipv6, ); } else { - runner = new ColdRunner( + runner = ColdRunner( flutterDevices, target: targetFile, debuggingOptions: _createDebuggingOptions(), @@ -382,7 +382,7 @@ class RunCommand extends RunCommandBase { // need to know about analytics. // // Do not add more operations to the future. - final Completer appStartedTimeRecorder = new Completer.sync(); + final Completer appStartedTimeRecorder = Completer.sync(); // This callback can't throw. appStartedTimeRecorder.future.then( // ignore: unawaited_futures (_) { appStartedTime = clock.now(); } @@ -395,7 +395,7 @@ class RunCommand extends RunCommandBase { ); if (result != 0) throwToolExit(null, exitCode: result); - return new FlutterCommandResult( + return FlutterCommandResult( ExitStatus.success, timingLabelParts: [ hotMode ? 'hot' : 'cold', diff --git a/packages/flutter_tools/lib/src/commands/screenshot.dart b/packages/flutter_tools/lib/src/commands/screenshot.dart index c4233d7593..be39b24938 100644 --- a/packages/flutter_tools/lib/src/commands/screenshot.dart +++ b/packages/flutter_tools/lib/src/commands/screenshot.dart @@ -122,7 +122,7 @@ class ScreenshotCommand extends FlutterCommand { } Future> _invokeVmServiceRpc(String method) async { - final Uri observatoryUri = new Uri(scheme: 'http', host: '127.0.0.1', + final Uri observatoryUri = Uri(scheme: 'http', host: '127.0.0.1', port: int.parse(argResults[_kObservatoryPort])); final VMService vmService = await VMService.connect(observatoryUri); return await vmService.vm.invokeRpcRaw(method); diff --git a/packages/flutter_tools/lib/src/commands/test.dart b/packages/flutter_tools/lib/src/commands/test.dart index 170f7e84df..4fc19e9301 100644 --- a/packages/flutter_tools/lib/src/commands/test.dart +++ b/packages/flutter_tools/lib/src/commands/test.dart @@ -140,7 +140,7 @@ class TestCommand extends FlutterCommand { CoverageCollector collector; if (argResults['coverage'] || argResults['merge-coverage']) { - collector = new CoverageCollector(); + collector = CoverageCollector(); } final bool machine = argResults['machine']; @@ -152,7 +152,7 @@ class TestCommand extends FlutterCommand { if (collector != null) { watcher = collector; } else if (machine) { - watcher = new EventPrinter(); + watcher = EventPrinter(); } Cache.releaseLockEarly(); diff --git a/packages/flutter_tools/lib/src/commands/trace.dart b/packages/flutter_tools/lib/src/commands/trace.dart index 3999a5bb47..0b5d44e86f 100644 --- a/packages/flutter_tools/lib/src/commands/trace.dart +++ b/packages/flutter_tools/lib/src/commands/trace.dart @@ -64,7 +64,7 @@ class TraceCommand extends FlutterCommand { Duration duration; if (argResults.wasParsed('duration')) { try { - duration = new Duration(seconds: int.parse(argResults['duration'])); + duration = Duration(seconds: int.parse(argResults['duration'])); } on FormatException { throwToolExit('Invalid duration passed to --duration; it should be a positive number of seconds.'); } @@ -88,7 +88,7 @@ class TraceCommand extends FlutterCommand { if (start) await tracing.startTracing(); - await new Future.delayed(duration); + await Future.delayed(duration); if (stop) await _stopTracing(tracing); } diff --git a/packages/flutter_tools/lib/src/commands/update_packages.dart b/packages/flutter_tools/lib/src/commands/update_packages.dart index 6f19cc2d21..c6e988a596 100644 --- a/packages/flutter_tools/lib/src/commands/update_packages.dart +++ b/packages/flutter_tools/lib/src/commands/update_packages.dart @@ -112,7 +112,7 @@ class UpdatePackagesCommand extends FlutterCommand { // package that is in the goldens repository. We need to make sure that the goldens // repository is cloned locally before we verify or update pubspecs. printStatus('Cloning goldens repository...'); - final GoldensClient goldensClient = new GoldensClient(); + final GoldensClient goldensClient = GoldensClient(); await goldensClient.prepare(); if (isVerifyOnly) { @@ -121,7 +121,7 @@ class UpdatePackagesCommand extends FlutterCommand { for (Directory directory in packages) { PubspecYaml pubspec; try { - pubspec = new PubspecYaml(directory); + pubspec = PubspecYaml(directory); } on String catch (message) { throwToolExit(message); } @@ -176,12 +176,12 @@ class UpdatePackagesCommand extends FlutterCommand { // First, collect up the explicit dependencies: final List pubspecs = []; final Map dependencies = {}; - final Set specialDependencies = new Set(); + final Set specialDependencies = Set(); for (Directory directory in packages) { // these are all the directories with pubspec.yamls we care about printTrace('Reading pubspec.yaml from: ${directory.path}'); PubspecYaml pubspec; try { - pubspec = new PubspecYaml(directory); // this parses the pubspec.yaml + pubspec = PubspecYaml(directory); // this parses the pubspec.yaml } on String catch (message) { throwToolExit(message); } @@ -222,7 +222,7 @@ class UpdatePackagesCommand extends FlutterCommand { // going to create a fake package and then run "pub upgrade" on it. The // pub tool will attempt to bring these dependencies up to the most recent // possible versions while honoring all their constraints. - final PubDependencyTree tree = new PubDependencyTree(); // object to collect results + final PubDependencyTree tree = PubDependencyTree(); // object to collect results final Directory tempDir = fs.systemTempDirectory.createTempSync('flutter_update_packages.'); try { final File fakePackage = _pubspecFor(tempDir); @@ -255,7 +255,7 @@ class UpdatePackagesCommand extends FlutterCommand { for (PubspecDependency dependency in pubspec.dependencies) { if (dependency.kind == DependencyKind.normal) { tree._versions[package] = version; - tree._dependencyTree[package] ??= new Set(); + tree._dependencyTree[package] ??= Set(); tree._dependencyTree[package].add(dependency.name); } } @@ -290,7 +290,7 @@ class UpdatePackagesCommand extends FlutterCommand { // the regular code path. } - final Stopwatch timer = new Stopwatch()..start(); + final Stopwatch timer = Stopwatch()..start(); int count = 0; for (Directory dir in packages) { @@ -314,11 +314,11 @@ class UpdatePackagesCommand extends FlutterCommand { if (!tree.contains(to)) throwToolExit('Package $to not found in the dependency tree.'); - final Queue<_DependencyLink> traversalQueue = new Queue<_DependencyLink>(); - final Set visited = new Set(); + final Queue<_DependencyLink> traversalQueue = Queue<_DependencyLink>(); + final Set visited = Set(); final List<_DependencyLink> paths = <_DependencyLink>[]; - traversalQueue.addFirst(new _DependencyLink(from: null, to: from)); + traversalQueue.addFirst(_DependencyLink(from: null, to: from)); while (traversalQueue.isNotEmpty) { final _DependencyLink link = traversalQueue.removeLast(); if (link.to == to) @@ -327,13 +327,13 @@ class UpdatePackagesCommand extends FlutterCommand { visited.add(link.from.to); for (String dependency in tree._dependencyTree[link.to]) { if (!visited.contains(dependency)) { - traversalQueue.addFirst(new _DependencyLink(from: link, to: dependency)); + traversalQueue.addFirst(_DependencyLink(from: link, to: dependency)); } } } for (_DependencyLink path in paths) { - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); while (path != null) { buf.write('${path.to}'); path = path.from; @@ -490,7 +490,7 @@ class PubspecYaml { } else { // This line isn't a section header, and we're not in a section we care about. // We just stick the line into the output unmodified. - result.add(new PubspecLine(line)); + result.add(PubspecLine(line)); } } else { // We're in a section we care about. Try to parse out the dependency: @@ -531,7 +531,7 @@ class PubspecYaml { // We're in a section we care about but got a line we didn't // recognize. Maybe it's a comment or a blank line or something. // Just pass it through. - result.add(new PubspecLine(line)); + result.add(PubspecLine(line)); } } } else { @@ -555,15 +555,15 @@ class PubspecYaml { // Remove the PubspecDependency entry we had for it and replace it // with a PubspecLine entry, and add such an entry for this line. result.removeLast(); - result.add(new PubspecLine(lastDependency.line)); - result.add(new PubspecLine(line)); + result.add(PubspecLine(lastDependency.line)); + result.add(PubspecLine(line)); } // We're done with this special dependency, so reset back to null so // we'll go in the top section next time instead. lastDependency = null; } } - return new PubspecYaml._(file, packageName, packageVersion, result, checksum ?? new PubspecChecksum(null, '')); + return PubspecYaml._(file, packageName, packageVersion, result, checksum ?? PubspecChecksum(null, '')); } /// This returns all the explicit dependencies that this pubspec.yaml lists under dependencies. @@ -594,8 +594,8 @@ class PubspecYaml { void apply(PubDependencyTree versions, Set specialDependencies) { assert(versions != null); final List output = []; // the string data to output to the file, line by line - final Set directDependencies = new Set(); // packages this pubspec directly depends on (i.e. not transitive) - final Set devDependencies = new Set(); + final Set directDependencies = Set(); // packages this pubspec directly depends on (i.e. not transitive) + final Set devDependencies = Set(); Section section = Section.other; // the section we're currently handling // the line number where we're going to insert the transitive dependencies. @@ -693,19 +693,19 @@ class PubspecYaml { final List transitiveDevDependencyOutput = []; // Which dependencies we need to handle for the transitive and dev dependency sections. - final Set transitiveDependencies = new Set(); - final Set transitiveDevDependencies = new Set(); + final Set transitiveDependencies = Set(); + final Set transitiveDevDependencies = Set(); // Merge the lists of dependencies we've seen in this file from dependencies, dev dependencies, // and the dependencies we know this file mentions that are already pinned // (and which didn't get special processing above). - final Set implied = new Set.from(directDependencies) + final Set implied = Set.from(directDependencies) ..addAll(specialDependencies) ..addAll(devDependencies); // Create a new set to hold the list of packages we've already processed, so // that we don't redundantly process them multiple times. - final Set done = new Set(); + final Set done = Set(); for (String package in directDependencies) transitiveDependencies.addAll(versions.getTransitiveDependenciesFor(package, seen: done, exclude: implied)); for (String package in devDependencies) @@ -722,7 +722,7 @@ class PubspecYaml { transitiveDevDependencyOutput.add(' $package: ${versions.versionFor(package)} $kTransitiveMagicString'); // Build a sorted list of all dependencies for the checksum. - final Set checksumDependencies = new Set() + final Set checksumDependencies = Set() ..addAll(directDependencies) ..addAll(devDependencies) ..addAll(transitiveDependenciesAsList) @@ -755,7 +755,7 @@ class PubspecYaml { // Output the result to the pubspec.yaml file, skipping leading and // duplicate blank lines and removing trailing spaces. - final StringBuffer contents = new StringBuffer(); + final StringBuffer contents = StringBuffer(); bool hadBlankLine = true; for (String line in output) { line = line.trimRight(); @@ -799,8 +799,8 @@ class PubspecChecksum extends PubspecLine { static PubspecChecksum parse(String line) { final List tokens = line.split(kDependencyChecksum); if (tokens.length != 2) - return new PubspecChecksum(null, line); - return new PubspecChecksum(tokens.last.trim(), line); + return PubspecChecksum(null, line); + return PubspecChecksum(tokens.last.trim(), line); } } @@ -852,16 +852,16 @@ class PubspecHeader extends PubspecLine { final String value = parts.last.trim(); switch (sectionName) { case 'dependencies': - return new PubspecHeader(line, Section.dependencies); + return PubspecHeader(line, Section.dependencies); case 'dev_dependencies': - return new PubspecHeader(line, Section.devDependencies); + return PubspecHeader(line, Section.devDependencies); case 'dependency_overrides': - return new PubspecHeader(line, Section.dependencyOverrides); + return PubspecHeader(line, Section.dependencyOverrides); case 'name': case 'version': - return new PubspecHeader(line, Section.header, name: sectionName, value: value); + return PubspecHeader(line, Section.header, name: sectionName, value: value); default: - return new PubspecHeader(line, Section.other); + return PubspecHeader(line, Section.other); } } @@ -930,7 +930,7 @@ class PubspecDependency extends PubspecLine { if (colonIndex != -1) { version = line.substring(colonIndex + 1, hashIndex != -1 ? hashIndex : line.length).trim(); } - return new PubspecDependency(line, package, suffix, isTransitive: isTransitive, version: version, kind: stripped.isEmpty ? DependencyKind.unknown : DependencyKind.normal, sourcePath: filename); + return PubspecDependency(line, package, suffix, isTransitive: isTransitive, version: version, kind: stripped.isEmpty ? DependencyKind.unknown : DependencyKind.normal, sourcePath: filename); } final String name; // the package name @@ -1066,8 +1066,8 @@ File _pubspecFor(Directory directory) { /// Generates the source of a fake pubspec.yaml file given a list of /// dependencies. String _generateFakePubspec(Iterable dependencies) { - final StringBuffer result = new StringBuffer(); - final StringBuffer overrides = new StringBuffer(); + final StringBuffer result = StringBuffer(); + final StringBuffer overrides = StringBuffer(); result.writeln('name: flutter_update_packages'); result.writeln('dependencies:'); overrides.writeln('dependency_overrides:'); @@ -1145,7 +1145,7 @@ class PubDependencyTree { dependencies = const []; } _versions[package] = version; - _dependencyTree[package] = new Set.from(dependencies); + _dependencyTree[package] = Set.from(dependencies); } } return null; diff --git a/packages/flutter_tools/lib/src/commands/upgrade.dart b/packages/flutter_tools/lib/src/commands/upgrade.dart index d6a1e82713..eefa606396 100644 --- a/packages/flutter_tools/lib/src/commands/upgrade.dart +++ b/packages/flutter_tools/lib/src/commands/upgrade.dart @@ -88,12 +88,12 @@ class UpgradeCommand extends FlutterCommand { } // dev/benchmarks/complex_layout/lib/main.dart | 24 +- - static final RegExp _gitDiffRegex = new RegExp(r' (\S+)\s+\|\s+\d+ [+-]+'); + static final RegExp _gitDiffRegex = RegExp(r' (\S+)\s+\|\s+\d+ [+-]+'); // rename {packages/flutter/doc => dev/docs}/styles.html (92%) // delete mode 100644 doc/index.html // create mode 100644 examples/flutter_gallery/lib/gallery/demo.dart - static final RegExp _gitChangedRegex = new RegExp(r' (rename|delete mode|create mode) .+'); + static final RegExp _gitChangedRegex = RegExp(r' (rename|delete mode|create mode) .+'); @visibleForTesting static bool matchesGitLine(String line) { diff --git a/packages/flutter_tools/lib/src/compile.dart b/packages/flutter_tools/lib/src/compile.dart index 7f37282922..ff1f3e7023 100644 --- a/packages/flutter_tools/lib/src/compile.dart +++ b/packages/flutter_tools/lib/src/compile.dart @@ -49,7 +49,7 @@ class _StdoutHandler { } final int spaceDelimiter = string.lastIndexOf(' '); compilerOutput.complete( - new CompilerOutput( + CompilerOutput( string.substring(boundaryKey.length + 1, spaceDelimiter), int.parse(string.substring(spaceDelimiter + 1).trim()))); } @@ -62,7 +62,7 @@ class _StdoutHandler { // with its own boundary key and new completer. void reset({bool suppressCompilerMessages = false}) { boundaryKey = null; - compilerOutput = new Completer(); + compilerOutput = Completer(); _suppressCompilerMessages = suppressCompilerMessages; } } @@ -95,7 +95,7 @@ class KernelCompiler { // depfile. None of these are available on the local host. Fingerprinter fingerprinter; if (depFilePath != null) { - fingerprinter = new Fingerprinter( + fingerprinter = Fingerprinter( fingerprintPath: '$depFilePath.fingerprint', paths: [mainPath], properties: { @@ -109,7 +109,7 @@ class KernelCompiler { if (await fingerprinter.doesFingerprintMatch()) { printTrace('Skipping kernel compilation. Fingerprint match.'); - return new CompilerOutput(outputFilePath, 0); + return CompilerOutput(outputFilePath, 0); } } @@ -175,7 +175,7 @@ class KernelCompiler { printError('Failed to start frontend server $error, $stack'); }); - final _StdoutHandler _stdoutHandler = new _StdoutHandler(); + final _StdoutHandler _stdoutHandler = _StdoutHandler(); server.stderr .transform(utf8.decoder) @@ -255,8 +255,8 @@ class ResidentCompiler { _packagesPath = packagesPath, _fileSystemRoots = fileSystemRoots, _fileSystemScheme = fileSystemScheme, - _stdoutHandler = new _StdoutHandler(consumer: compilerMessageConsumer), - _controller = new StreamController<_CompilationRequest>(), + _stdoutHandler = _StdoutHandler(consumer: compilerMessageConsumer), + _controller = StreamController<_CompilationRequest>(), _initializeFromDill = initializeFromDill { // This is a URI, not a file path, so the forward slash is correct even on Windows. if (!_sdkRoot.endsWith('/')) @@ -287,9 +287,9 @@ class ResidentCompiler { _controller.stream.listen(_handleCompilationRequest); } - final Completer completer = new Completer(); + final Completer completer = Completer(); _controller.add( - new _RecompileRequest(completer, mainPath, invalidatedFiles, outputPath, packagesFilePath) + _RecompileRequest(completer, mainPath, invalidatedFiles, outputPath, packagesFilePath) ); return completer.future; } @@ -304,7 +304,7 @@ class ResidentCompiler { request.outputPath, _mapFilename(request.packagesFilePath)); } - final String inputKey = new Uuid().generateV4(); + final String inputKey = Uuid().generateV4(); _server.stdin.writeln('recompile ${request.mainPath != null ? _mapFilename(request.mainPath) + " ": ""}$inputKey'); for (String fileUri in request.invalidatedFiles) { _server.stdin.writeln(_mapFileUri(fileUri)); @@ -399,9 +399,9 @@ class ResidentCompiler { _controller.stream.listen(_handleCompilationRequest); } - final Completer completer = new Completer(); + final Completer completer = Completer(); _controller.add( - new _CompileExpressionRequest( + _CompileExpressionRequest( completer, expression, definitions, typeDefinitions, libraryUri, klass, isStatic) ); return completer.future; @@ -416,7 +416,7 @@ class ResidentCompiler { if (_server == null) return null; - final String inputKey = new Uuid().generateV4(); + final String inputKey = Uuid().generateV4(); _server.stdin.writeln('compile-expression $inputKey'); _server.stdin.writeln(request.expression); request.definitions?.forEach(_server.stdin.writeln); @@ -455,7 +455,7 @@ class ResidentCompiler { if (_fileSystemRoots != null) { for (String root in _fileSystemRoots) { if (filename.startsWith(root)) { - return new Uri( + return Uri( scheme: _fileSystemScheme, path: filename.substring(root.length)) .toString(); } @@ -469,7 +469,7 @@ class ResidentCompiler { final String filename = Uri.parse(fileUri).toFilePath(); for (String root in _fileSystemRoots) { if (filename.startsWith(root)) { - return new Uri( + return Uri( scheme: _fileSystemScheme, path: filename.substring(root.length)) .toString(); } diff --git a/packages/flutter_tools/lib/src/context_runner.dart b/packages/flutter_tools/lib/src/context_runner.dart index 6a01414455..86c8ab5844 100644 --- a/packages/flutter_tools/lib/src/context_runner.dart +++ b/packages/flutter_tools/lib/src/context_runner.dart @@ -46,36 +46,36 @@ Future runInContext( fallbacks: { AndroidSdk: AndroidSdk.locateAndroidSdk, AndroidStudio: AndroidStudio.latestValid, - AndroidWorkflow: () => new AndroidWorkflow(), - AndroidValidator: () => new AndroidValidator(), - Artifacts: () => new CachedArtifacts(), + AndroidWorkflow: () => AndroidWorkflow(), + AndroidValidator: () => AndroidValidator(), + Artifacts: () => CachedArtifacts(), AssetBundleFactory: () => AssetBundleFactory.defaultInstance, BotDetector: () => const BotDetector(), - Cache: () => new Cache(), + Cache: () => Cache(), Clock: () => const Clock(), - CocoaPods: () => new CocoaPods(), - Config: () => new Config(), - DevFSConfig: () => new DevFSConfig(), - DeviceManager: () => new DeviceManager(), + CocoaPods: () => CocoaPods(), + Config: () => Config(), + DevFSConfig: () => DevFSConfig(), + DeviceManager: () => DeviceManager(), Doctor: () => const Doctor(), DoctorValidatorsProvider: () => DoctorValidatorsProvider.defaultInstance, - EmulatorManager: () => new EmulatorManager(), + EmulatorManager: () => EmulatorManager(), Flags: () => const EmptyFlags(), - FlutterVersion: () => new FlutterVersion(const Clock()), + FlutterVersion: () => FlutterVersion(const Clock()), GenSnapshot: () => const GenSnapshot(), - HotRunnerConfig: () => new HotRunnerConfig(), + HotRunnerConfig: () => HotRunnerConfig(), IMobileDevice: () => const IMobileDevice(), - IOSSimulatorUtils: () => new IOSSimulatorUtils(), + IOSSimulatorUtils: () => IOSSimulatorUtils(), IOSWorkflow: () => const IOSWorkflow(), IOSValidator: () => const IOSValidator(), KernelCompiler: () => const KernelCompiler(), - Logger: () => platform.isWindows ? new WindowsStdoutLogger() : new StdoutLogger(), - OperatingSystemUtils: () => new OperatingSystemUtils(), - SimControl: () => new SimControl(), + Logger: () => platform.isWindows ? WindowsStdoutLogger() : StdoutLogger(), + OperatingSystemUtils: () => OperatingSystemUtils(), + SimControl: () => SimControl(), Stdio: () => const Stdio(), - Usage: () => new Usage(), - Xcode: () => new Xcode(), - XcodeProjectInterpreter: () => new XcodeProjectInterpreter(), + Usage: () => Usage(), + Xcode: () => Xcode(), + XcodeProjectInterpreter: () => XcodeProjectInterpreter(), }, ); } diff --git a/packages/flutter_tools/lib/src/crash_reporting.dart b/packages/flutter_tools/lib/src/crash_reporting.dart index 1bf1cd1f79..9018ceed72 100644 --- a/packages/flutter_tools/lib/src/crash_reporting.dart +++ b/packages/flutter_tools/lib/src/crash_reporting.dart @@ -52,12 +52,12 @@ class CrashReportSender { CrashReportSender._(this._client); - static CrashReportSender get instance => _instance ?? new CrashReportSender._(new http.Client()); + static CrashReportSender get instance => _instance ?? CrashReportSender._(http.Client()); /// Overrides the default [http.Client] with [client] for testing purposes. @visibleForTesting static void initializeWith(http.Client client) { - _instance = new CrashReportSender._(client); + _instance = CrashReportSender._(client); } final http.Client _client; @@ -69,7 +69,7 @@ class CrashReportSender { if (overrideUrl != null) { return Uri.parse(overrideUrl); } - return new Uri( + return Uri( scheme: 'https', host: _kCrashServerHost, port: 443, @@ -99,7 +99,7 @@ class CrashReportSender { }, ); - final http.MultipartRequest req = new http.MultipartRequest('POST', uri); + final http.MultipartRequest req = http.MultipartRequest('POST', uri); req.fields['uuid'] = _usage.clientId; req.fields['product'] = _kProductId; req.fields['version'] = flutterVersion; @@ -108,8 +108,8 @@ class CrashReportSender { req.fields['type'] = _kDartTypeId; req.fields['error_runtime_type'] = '${error.runtimeType}'; - final String stackTraceWithRelativePaths = new Chain.parse(stackTrace.toString()).terse.toString(); - req.files.add(new http.MultipartFile.fromString( + final String stackTraceWithRelativePaths = Chain.parse(stackTrace.toString()).terse.toString(); + req.files.add(http.MultipartFile.fromString( _kStackTraceFileField, stackTraceWithRelativePaths, filename: _kStackTraceFilename, @@ -118,7 +118,7 @@ class CrashReportSender { final http.StreamedResponse resp = await _client.send(req); if (resp.statusCode == 200) { - final String reportId = await new http.ByteStream(resp.stream) + final String reportId = await http.ByteStream(resp.stream) .bytesToString(); printStatus('Crash report sent (report ID: $reportId)'); } else { diff --git a/packages/flutter_tools/lib/src/dart/analysis.dart b/packages/flutter_tools/lib/src/dart/analysis.dart index 5fce936045..0815190fe1 100644 --- a/packages/flutter_tools/lib/src/dart/analysis.dart +++ b/packages/flutter_tools/lib/src/dart/analysis.dart @@ -21,9 +21,9 @@ class AnalysisServer { Process _process; final StreamController _analyzingController = - new StreamController.broadcast(); + StreamController.broadcast(); final StreamController _errorsController = - new StreamController.broadcast(); + StreamController.broadcast(); int _id = 0; @@ -132,10 +132,10 @@ class AnalysisServer { final List errorsList = issueInfo['errors']; final List errors = errorsList .map>(castStringKeyedMap) - .map((Map json) => new AnalysisError(json)) + .map((Map json) => AnalysisError(json)) .toList(); if (!_errorsController.isClosed) - _errorsController.add(new FileAnalysisErrors(file, errors)); + _errorsController.add(FileAnalysisErrors(file, errors)); } Future dispose() async { diff --git a/packages/flutter_tools/lib/src/dart/dependencies.dart b/packages/flutter_tools/lib/src/dart/dependencies.dart index 28c74710fc..0b7fa12077 100644 --- a/packages/flutter_tools/lib/src/dart/dependencies.dart +++ b/packages/flutter_tools/lib/src/dart/dependencies.dart @@ -39,7 +39,7 @@ class DartDependencySetBuilder { Set build() { final List dependencies = [_mainScriptPath, _packagesFilePath]; final List toProcess = [_mainScriptUri]; - final PackageMap packageMap = new PackageMap(_packagesFilePath); + final PackageMap packageMap = PackageMap(_packagesFilePath); while (toProcess.isNotEmpty) { final Uri currentUri = toProcess.removeLast(); @@ -69,7 +69,7 @@ class DartDependencySetBuilder { try { uri = Uri.parse(uriAsString); } on FormatException { - throw new DartDependencyException('Unable to parse URI: $uriAsString'); + throw DartDependencyException('Unable to parse URI: $uriAsString'); } Uri resolvedUri = analyzer.resolveRelativeUri(currentUri, uri); if (resolvedUri.scheme.startsWith('dart')) @@ -77,7 +77,7 @@ class DartDependencySetBuilder { if (resolvedUri.scheme == 'package') { final Uri newResolvedUri = packageMap.uriForPackage(resolvedUri); if (newResolvedUri == null) { - throw new DartDependencyException( + throw DartDependencyException( 'The following Dart file:\n' ' ${currentUri.toFilePath()}\n' '...refers, in an import, to the following library:\n' @@ -91,7 +91,7 @@ class DartDependencySetBuilder { final String path = canonicalizePath(resolvedUri.toFilePath()); if (!dependencies.contains(path)) { if (!fs.isFileSync(path)) { - throw new DartDependencyException( + throw DartDependencyException( 'The following Dart file:\n' ' ${currentUri.toFilePath()}\n' '...refers, in an import, to the following library:\n' @@ -112,7 +112,7 @@ class DartDependencySetBuilder { try { body = fs.file(path).readAsStringSync(); } on FileSystemException catch (error) { - throw new DartDependencyException( + throw DartDependencyException( 'Could not read "$path" when determining Dart dependencies.', error, ); @@ -120,7 +120,7 @@ class DartDependencySetBuilder { try { return analyzer.parseDirectives(body, name: path); } on analyzer.AnalyzerError catch (error) { - throw new DartDependencyException( + throw DartDependencyException( 'When trying to parse this Dart file to find its dependencies:\n' ' $path\n' '...the analyzer failed with the following error:\n' @@ -128,7 +128,7 @@ class DartDependencySetBuilder { error, ); } on analyzer.AnalyzerErrorGroup catch (error) { - throw new DartDependencyException( + throw DartDependencyException( 'When trying to parse this Dart file to find its dependencies:\n' ' $path\n' '...the analyzer failed with the following error:\n' diff --git a/packages/flutter_tools/lib/src/dart/package_map.dart b/packages/flutter_tools/lib/src/dart/package_map.dart index c1b7bfca43..6d940128b3 100644 --- a/packages/flutter_tools/lib/src/dart/package_map.dart +++ b/packages/flutter_tools/lib/src/dart/package_map.dart @@ -12,7 +12,7 @@ const String kPackagesFileName = '.packages'; Map _parse(String packagesPath) { final List source = fs.file(packagesPath).readAsBytesSync(); return packages_file.parse(source, - new Uri.file(packagesPath, windows: platform.isWindows)); + Uri.file(packagesPath, windows: platform.isWindows)); } class PackageMap { diff --git a/packages/flutter_tools/lib/src/dart/pub.dart b/packages/flutter_tools/lib/src/dart/pub.dart index cd2d12c0ca..816c77560b 100644 --- a/packages/flutter_tools/lib/src/dart/pub.dart +++ b/packages/flutter_tools/lib/src/dart/pub.dart @@ -23,32 +23,32 @@ import 'sdk.dart'; // DO NOT update without contacting kevmoo. // We have server-side tooling that assumes the values are consistent. class PubContext { - static final RegExp _validContext = new RegExp('[a-z][a-z_]*[a-z]'); + static final RegExp _validContext = RegExp('[a-z][a-z_]*[a-z]'); - static final PubContext create = new PubContext._(['create']); - static final PubContext createPackage = new PubContext._(['create_pkg']); - static final PubContext createPlugin = new PubContext._(['create_plugin']); - static final PubContext interactive = new PubContext._(['interactive']); - static final PubContext pubGet = new PubContext._(['get']); - static final PubContext pubUpgrade = new PubContext._(['upgrade']); - static final PubContext runTest = new PubContext._(['run_test']); + static final PubContext create = PubContext._(['create']); + static final PubContext createPackage = PubContext._(['create_pkg']); + static final PubContext createPlugin = PubContext._(['create_plugin']); + static final PubContext interactive = PubContext._(['interactive']); + static final PubContext pubGet = PubContext._(['get']); + static final PubContext pubUpgrade = PubContext._(['upgrade']); + static final PubContext runTest = PubContext._(['run_test']); - static final PubContext flutterTests = new PubContext._(['flutter_tests']); - static final PubContext updatePackages = new PubContext._(['update_packages']); + static final PubContext flutterTests = PubContext._(['flutter_tests']); + static final PubContext updatePackages = PubContext._(['update_packages']); final List _values; PubContext._(this._values) { for (String item in _values) { if (!_validContext.hasMatch(item)) { - throw new ArgumentError.value( + throw ArgumentError.value( _values, 'value', 'Must match RegExp ${_validContext.pattern}'); } } } static PubContext getVerifyContext(String commandName) => - new PubContext._(['verify', commandName.replaceAll('-', '_')]); + PubContext._(['verify', commandName.replaceAll('-', '_')]); @override String toString() => 'PubContext: ${_values.join(':')}'; @@ -161,7 +161,7 @@ Future pub(List arguments, { if (code != 69) // UNAVAILABLE in https://github.com/dart-lang/pub/blob/master/lib/src/exit_codes.dart break; printStatus('$failureMessage ($code) -- attempting retry $attempts in $duration second${ duration == 1 ? "" : "s"}...'); - await new Future.delayed(new Duration(seconds: duration)); + await Future.delayed(Duration(seconds: duration)); if (duration < 64) duration *= 2; } @@ -207,7 +207,7 @@ Map _createPubEnvironment(PubContext context) { return environment; } -final RegExp _analyzerWarning = new RegExp(r'^! \w+ [^ ]+ from path \.\./\.\./bin/cache/dart-sdk/lib/\w+$'); +final RegExp _analyzerWarning = RegExp(r'^! \w+ [^ ]+ from path \.\./\.\./bin/cache/dart-sdk/lib/\w+$'); /// The console environment key used by the pub tool. const String _pubEnvironmentKey = 'PUB_ENVIRONMENT'; diff --git a/packages/flutter_tools/lib/src/dependency_checker.dart b/packages/flutter_tools/lib/src/dependency_checker.dart index 1ff6eaa4e8..8316443fdd 100644 --- a/packages/flutter_tools/lib/src/dependency_checker.dart +++ b/packages/flutter_tools/lib/src/dependency_checker.dart @@ -9,7 +9,7 @@ import 'globals.dart'; class DependencyChecker { final DartDependencySetBuilder builder; - final Set _dependencies = new Set(); + final Set _dependencies = Set(); final AssetBundle assets; DependencyChecker(this.builder, this.assets); diff --git a/packages/flutter_tools/lib/src/devfs.dart b/packages/flutter_tools/lib/src/devfs.dart index cb7f107742..fd47054fac 100644 --- a/packages/flutter_tools/lib/src/devfs.dart +++ b/packages/flutter_tools/lib/src/devfs.dart @@ -59,7 +59,7 @@ class DevFSFileContent extends DevFSContent { DevFSFileContent(this.file); static DevFSFileContent clone(DevFSFileContent fsFileContent) { - final DevFSFileContent newFsFileContent = new DevFSFileContent(fsFileContent.file); + final DevFSFileContent newFsFileContent = DevFSFileContent(fsFileContent.file); newFsFileContent._linkTarget = fsFileContent._linkTarget; newFsFileContent._fileStat = fsFileContent._fileStat; return newFsFileContent; @@ -137,14 +137,14 @@ class DevFSByteContent extends DevFSContent { List _bytes; bool _isModified = true; - DateTime _modificationTime = new DateTime.now(); + DateTime _modificationTime = DateTime.now(); List get bytes => _bytes; set bytes(List value) { _bytes = value; _isModified = true; - _modificationTime = new DateTime.now(); + _modificationTime = DateTime.now(); } /// Return true only once so that the content is written to the device only once. @@ -168,7 +168,7 @@ class DevFSByteContent extends DevFSContent { @override Stream> contentsAsStream() => - new Stream>.fromIterable(>[_bytes]); + Stream>.fromIterable(>[_bytes]); } /// String content to be copied to the device. @@ -268,10 +268,10 @@ class _DevFSHttpWriter { HttpClient _client; Future write(Map entries) async { - _client = new HttpClient(); + _client = HttpClient(); _client.maxConnectionsPerHost = kMaxInFlight; - _completer = new Completer(); - _outstanding = new Map.from(entries); + _completer = Completer(); + _outstanding = Map.from(entries); _scheduleWrites(); await _completer.future; _client.close(); @@ -336,8 +336,8 @@ class DevFS { this.rootDirectory, { String packagesFilePath }) - : _operations = new ServiceProtocolDevFSOperations(serviceProtocol), - _httpWriter = new _DevFSHttpWriter(fsName, serviceProtocol) { + : _operations = ServiceProtocolDevFSOperations(serviceProtocol), + _httpWriter = _DevFSHttpWriter(fsName, serviceProtocol) { _packagesFilePath = packagesFilePath ?? fs.path.join(rootDirectory.path, kPackagesFileName); } @@ -358,7 +358,7 @@ class DevFS { final Directory rootDirectory; String _packagesFilePath; final Map _entries = {}; - final Set assetPathsToEvict = new Set(); + final Set assetPathsToEvict = Set(); final List>> _pendingOperations = >>[]; @@ -485,7 +485,7 @@ class DevFS { // run with no changes is supposed to be fast (considering that it is // initiated by user key press). final List invalidatedFiles = []; - final Set filesUris = new Set(); + final Set filesUris = Set(); for (Uri uri in dirtyEntries.keys.toList()) { if (!uri.path.startsWith(assetBuildDirPrefix)) { final DevFSContent content = dirtyEntries[uri]; @@ -516,7 +516,7 @@ class DevFS { : pathToReload, ); if (!dirtyEntries.containsKey(entryUri)) { - final DevFSFileContent content = new DevFSFileContent(fs.file(compiledBinary)); + final DevFSFileContent content = DevFSFileContent(fs.file(compiledBinary)); dirtyEntries[entryUri] = content; numBytes += content.size; } @@ -528,10 +528,10 @@ class DevFS { await _httpWriter.write(dirtyEntries); } on SocketException catch (socketException, stackTrace) { printTrace('DevFS sync failed. Lost connection to device: $socketException'); - throw new DevFSException('Lost connection to device.', socketException, stackTrace); + throw DevFSException('Lost connection to device.', socketException, stackTrace); } catch (exception, stackTrace) { printError('Could not update files on device: $exception'); - throw new DevFSException('Sync failed', exception, stackTrace); + throw DevFSException('Sync failed', exception, stackTrace); } } else { // Make service protocol requests for each. @@ -552,7 +552,7 @@ class DevFS { } void _scanFile(Uri deviceUri, FileSystemEntity file) { - final DevFSContent content = _entries.putIfAbsent(deviceUri, () => new DevFSFileContent(file)); + final DevFSContent content = _entries.putIfAbsent(deviceUri, () => DevFSFileContent(file)); content._exists = true; } @@ -601,7 +601,7 @@ class DevFS { if (directoryUriOnDevice == null) { final String relativeRootPath = fs.path.relative(directory.path, from: rootDirectory.path); if (relativeRootPath == '.') { - directoryUriOnDevice = new Uri(); + directoryUriOnDevice = Uri(); } else { directoryUriOnDevice = fs.path.toUri(relativeRootPath); } @@ -699,7 +699,7 @@ class DevFS { Future _scanPackages(Set fileFilter) async { StringBuffer sb; - final PackageMap packageMap = new PackageMap(_packagesFilePath); + final PackageMap packageMap = PackageMap(_packagesFilePath); for (String packageName in packageMap.map.keys) { final Uri packageUri = packageMap.map[packageName]; @@ -726,7 +726,7 @@ class DevFS { fileFilter: fileFilter); } if (packageExists) { - sb ??= new StringBuffer(); + sb ??= StringBuffer(); sb.writeln('$packageName:$directoryUriOnDevice'); } } diff --git a/packages/flutter_tools/lib/src/device.dart b/packages/flutter_tools/lib/src/device.dart index 78121b004b..61ff0ab604 100644 --- a/packages/flutter_tools/lib/src/device.dart +++ b/packages/flutter_tools/lib/src/device.dart @@ -24,10 +24,10 @@ class DeviceManager { /// of their methods are called. DeviceManager() { // Register the known discoverers. - _deviceDiscoverers.add(new AndroidDevices()); - _deviceDiscoverers.add(new IOSDevices()); - _deviceDiscoverers.add(new IOSSimulators()); - _deviceDiscoverers.add(new FlutterTesterDevices()); + _deviceDiscoverers.add(AndroidDevices()); + _deviceDiscoverers.add(IOSDevices()); + _deviceDiscoverers.add(IOSSimulators()); + _deviceDiscoverers.add(FlutterTesterDevices()); } final List _deviceDiscoverers = []; @@ -121,7 +121,7 @@ abstract class DeviceDiscovery { /// Gets a list of diagnostic messages pertaining to issues with any connected /// devices (will be an empty list if there are no issues). - Future> getDiagnostics() => new Future>.value([]); + Future> getDiagnostics() => Future>.value([]); } /// A [DeviceDiscovery] implementation that uses polling to discover device adds @@ -140,9 +140,9 @@ abstract class PollingDeviceDiscovery extends DeviceDiscovery { void startPolling() { if (_poller == null) { - _items ??= new ItemListNotifier(); + _items ??= ItemListNotifier(); - _poller = new Poller(() async { + _poller = Poller(() async { try { final List devices = await pollingGetDevices().timeout(_pollingTimeout); _items.updateWithNewList(devices); @@ -160,17 +160,17 @@ abstract class PollingDeviceDiscovery extends DeviceDiscovery { @override Future> get devices async { - _items ??= new ItemListNotifier.from(await pollingGetDevices()); + _items ??= ItemListNotifier.from(await pollingGetDevices()); return _items.items; } Stream get onAdded { - _items ??= new ItemListNotifier(); + _items ??= ItemListNotifier(); return _items.onAdded; } Stream get onRemoved { - _items ??= new ItemListNotifier(); + _items ??= ItemListNotifier(); return _items.onRemoved; } @@ -275,7 +275,7 @@ abstract class Device { bool get supportsScreenshot => false; - Future takeScreenshot(File outputFile) => new Future.error('unimplemented'); + Future takeScreenshot(File outputFile) => Future.error('unimplemented'); @override int get hashCode => id.hashCode; @@ -314,7 +314,7 @@ abstract class Device { } // Calculate column widths - final List indices = new List.generate(table[0].length - 1, (int i) => i); + final List indices = List.generate(table[0].length - 1, (int i) => i); List widths = indices.map((int i) => 0).toList(); for (List row in table) { widths = indices.map((int i) => math.max(widths[i], row[i].length)).toList(); @@ -374,7 +374,7 @@ class LaunchResult { @override String toString() { - final StringBuffer buf = new StringBuffer('started=$started'); + final StringBuffer buf = StringBuffer('started=$started'); if (observatoryUri != null) buf.write(', observatory=$observatoryUri'); return buf.toString(); diff --git a/packages/flutter_tools/lib/src/disabled_usage.dart b/packages/flutter_tools/lib/src/disabled_usage.dart index 5705361591..a4990706fc 100644 --- a/packages/flutter_tools/lib/src/disabled_usage.dart +++ b/packages/flutter_tools/lib/src/disabled_usage.dart @@ -41,7 +41,7 @@ class DisabledUsage implements Usage { Stream> get onSend => null; @override - Future ensureAnalyticsSent() => new Future.value(); + Future ensureAnalyticsSent() => Future.value(); @override void printWelcome() { } diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 8d23024745..6cf154c918 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -31,7 +31,7 @@ abstract class DoctorValidatorsProvider { /// The singleton instance, pulled from the [AppContext]. static DoctorValidatorsProvider get instance => context[DoctorValidatorsProvider]; - static final DoctorValidatorsProvider defaultInstance = new _DefaultDoctorValidatorsProvider(); + static final DoctorValidatorsProvider defaultInstance = _DefaultDoctorValidatorsProvider(); List get validators; List get workflows; @@ -45,7 +45,7 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider { List get validators { if (_validators == null) { _validators = []; - _validators.add(new _FlutterValidator()); + _validators.add(_FlutterValidator()); if (androidWorkflow.appliesToHostPlatform) _validators.add(androidValidator); @@ -60,10 +60,10 @@ class _DefaultDoctorValidatorsProvider implements DoctorValidatorsProvider { if (ideValidators.isNotEmpty) _validators.addAll(ideValidators); else - _validators.add(new NoIdeValidator()); + _validators.add(NoIdeValidator()); if (deviceManager.canListAnything) - _validators.add(new DeviceValidator()); + _validators.add(DeviceValidator()); } return _validators; } @@ -102,7 +102,7 @@ class Doctor { List startValidatorTasks() { final List tasks = []; for (DoctorValidator validator in validators) { - tasks.add(new ValidatorTask(validator, validator.validate())); + tasks.add(ValidatorTask(validator, validator.validate())); } return tasks; } @@ -117,11 +117,11 @@ class Doctor { } Future get summaryText async { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); bool allGood = true; - final Set finishedGroups = new Set(); + final Set finishedGroups = Set(); for (DoctorValidator validator in validators) { final ValidatorCategory currentCategory = validator.category; ValidationResult result; @@ -182,11 +182,11 @@ class Doctor { final List taskList = startValidatorTasks(); - final Set finishedGroups = new Set(); + final Set finishedGroups = Set(); for (ValidatorTask validatorTask in taskList) { final DoctorValidator validator = validatorTask.validator; final ValidatorCategory currentCategory = validator.category; - final Status status = new Status.withSpinner(); + final Status status = Status.withSpinner(); ValidationResult result; if (currentCategory.isGrouped) { @@ -281,7 +281,7 @@ class Doctor { mergedMessages.addAll(result.messages); } - return new ValidationResult(mergedType, mergedMessages, + return ValidationResult(mergedType, mergedMessages, statusInfo: results[0].statusInfo); } @@ -392,19 +392,19 @@ class _FlutterValidator extends DoctorValidator { final FlutterVersion version = FlutterVersion.instance; - messages.add(new ValidationMessage('Flutter version ${version.frameworkVersion} at ${Cache.flutterRoot}')); - messages.add(new ValidationMessage( + messages.add(ValidationMessage('Flutter version ${version.frameworkVersion} at ${Cache.flutterRoot}')); + messages.add(ValidationMessage( 'Framework revision ${version.frameworkRevisionShort} ' '(${version.frameworkAge}), ${version.frameworkDate}' )); - messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}')); - messages.add(new ValidationMessage('Dart version ${version.dartSdkVersion}')); + messages.add(ValidationMessage('Engine revision ${version.engineRevisionShort}')); + messages.add(ValidationMessage('Dart version ${version.dartSdkVersion}')); final String genSnapshotPath = artifacts.getArtifactPath(Artifact.genSnapshot); // Check that the binaries we downloaded for this platform actually run on it. if (!_genSnapshotRuns(genSnapshotPath)) { - final StringBuffer buf = new StringBuffer(); + final StringBuffer buf = StringBuffer(); buf.writeln('Downloaded executables cannot execute on host.'); buf.writeln('See https://github.com/flutter/flutter/issues/6207 for more information'); if (platform.isLinux) { @@ -412,11 +412,11 @@ class _FlutterValidator extends DoctorValidator { buf.writeln('On Fedora: dnf install libstdc++.i686'); buf.writeln('On Arch: pacman -S lib32-libstdc++5'); } - messages.add(new ValidationMessage.error(buf.toString())); + messages.add(ValidationMessage.error(buf.toString())); valid = ValidationType.partial; } - return new ValidationResult(valid, messages, + return ValidationResult(valid, messages, statusInfo: 'Channel ${version.channel}, v${version.frameworkVersion}, on ${os.name}, locale ${platform.localeName}' ); } @@ -436,8 +436,8 @@ class NoIdeValidator extends DoctorValidator { @override Future validate() async { - return new ValidationResult(ValidationType.missing, [ - new ValidationMessage('IntelliJ - https://www.jetbrains.com/idea/'), + return ValidationResult(ValidationType.missing, [ + ValidationMessage('IntelliJ - https://www.jetbrains.com/idea/'), ], statusInfo: 'No supported IDEs installed'); } } @@ -455,7 +455,7 @@ abstract class IntelliJValidator extends DoctorValidator { 'IdeaIC' : 'IntelliJ IDEA Community Edition', }; - static final Version kMinIdeaVersion = new Version(2017, 1, 0); + static final Version kMinIdeaVersion = Version(2017, 1, 0); static Iterable get installedValidators { if (platform.isLinux || platform.isWindows) @@ -469,15 +469,15 @@ abstract class IntelliJValidator extends DoctorValidator { Future validate() async { final List messages = []; - messages.add(new ValidationMessage('IntelliJ at $installPath')); + messages.add(ValidationMessage('IntelliJ at $installPath')); - final IntelliJPlugins plugins = new IntelliJPlugins(pluginsPath); + final IntelliJPlugins plugins = IntelliJPlugins(pluginsPath); plugins.validatePackage(messages, ['flutter-intellij', 'flutter-intellij.jar'], 'Flutter', minVersion: IntelliJPlugins.kMinFlutterPluginVersion); plugins.validatePackage(messages, ['Dart'], 'Dart'); if (_hasIssues(messages)) { - messages.add(new ValidationMessage( + messages.add(ValidationMessage( 'For information about installing plugins, see\n' 'https://flutter.io/intellij-setup/#installing-the-plugins' )); @@ -485,7 +485,7 @@ abstract class IntelliJValidator extends DoctorValidator { _validateIntelliJVersion(messages, kMinIdeaVersion); - return new ValidationResult( + return ValidationResult( _hasIssues(messages) ? ValidationType.partial : ValidationType.installed, messages, statusInfo: 'version $version' @@ -501,12 +501,12 @@ abstract class IntelliJValidator extends DoctorValidator { if (minVersion == Version.unknown) return; - final Version installedVersion = new Version.parse(version); + final Version installedVersion = Version.parse(version); if (installedVersion == null) return; if (installedVersion < minVersion) { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'This install is older than the minimum recommended version of $minVersion.' )); } @@ -529,7 +529,7 @@ class IntelliJValidatorOnLinuxAndWindows extends IntelliJValidator { void addValidator(String title, String version, String installPath, String pluginsPath) { final IntelliJValidatorOnLinuxAndWindows validator = - new IntelliJValidatorOnLinuxAndWindows(title, version, installPath, pluginsPath); + IntelliJValidatorOnLinuxAndWindows(title, version, installPath, pluginsPath); for (int index = 0; index < validators.length; ++index) { final DoctorValidator other = validators[index]; if (other is IntelliJValidatorOnLinuxAndWindows && validator.installPath == other.installPath) { @@ -585,7 +585,7 @@ class IntelliJValidatorOnMac extends IntelliJValidator { _dirNameToId.forEach((String dirName, String id) { if (name == dirName) { final String title = IntelliJValidator._idToTitle[id]; - validators.add(new IntelliJValidatorOnMac(title, id, dir.path)); + validators.add(IntelliJValidatorOnMac(title, id, dir.path)); } }); } @@ -607,10 +607,10 @@ class IntelliJValidatorOnMac extends IntelliJValidator { } } } on FileSystemException catch (e) { - validators.add(new ValidatorWithResult( + validators.add(ValidatorWithResult( 'Cannot determine if IntelliJ is installed', - new ValidationResult(ValidationType.missing, [ - new ValidationMessage.error(e.message), + ValidationResult(ValidationType.missing, [ + ValidationMessage.error(e.message), ]), )); } @@ -649,19 +649,19 @@ class DeviceValidator extends DoctorValidator { if (devices.isEmpty) { final List diagnostics = await deviceManager.getDeviceDiagnostics(); if (diagnostics.isNotEmpty) { - messages = diagnostics.map((String message) => new ValidationMessage(message)).toList(); + messages = diagnostics.map((String message) => ValidationMessage(message)).toList(); } else { - messages = [new ValidationMessage.hint('No devices available')]; + messages = [ValidationMessage.hint('No devices available')]; } } else { messages = await Device.descriptions(devices) - .map((String msg) => new ValidationMessage(msg)).toList(); + .map((String msg) => ValidationMessage(msg)).toList(); } if (devices.isEmpty) { - return new ValidationResult(ValidationType.partial, messages); + return ValidationResult(ValidationType.partial, messages); } else { - return new ValidationResult(ValidationType.installed, messages, statusInfo: '${devices.length} available'); + return ValidationResult(ValidationType.installed, messages, statusInfo: '${devices.length} available'); } } } diff --git a/packages/flutter_tools/lib/src/emulator.dart b/packages/flutter_tools/lib/src/emulator.dart index e0e144af4d..c40497c77a 100644 --- a/packages/flutter_tools/lib/src/emulator.dart +++ b/packages/flutter_tools/lib/src/emulator.dart @@ -21,8 +21,8 @@ class EmulatorManager { /// of their methods are called. EmulatorManager() { // Register the known discoverers. - _emulatorDiscoverers.add(new AndroidEmulators()); - _emulatorDiscoverers.add(new IOSEmulators()); + _emulatorDiscoverers.add(AndroidEmulators()); + _emulatorDiscoverers.add(IOSEmulators()); } final List _emulatorDiscoverers = []; @@ -81,12 +81,12 @@ class EmulatorManager { final String device = await _getPreferredAvailableDevice(); if (device == null) - return new CreateEmulatorResult(name, + return CreateEmulatorResult(name, success: false, error: 'No device definitions are available'); final String sdkId = await _getPreferredSdkId(); if (sdkId == null) - return new CreateEmulatorResult(name, + return CreateEmulatorResult(name, success: false, error: 'No suitable Android AVD system images are available. You may need to install these' @@ -119,7 +119,7 @@ class EmulatorManager { ]; final ProcessResult runResult = processManager.runSync(args, environment: androidSdk?.sdkManagerEnv); - return new CreateEmulatorResult( + return CreateEmulatorResult( name, success: runResult.exitCode == 0, output: runResult.stdout, @@ -154,7 +154,7 @@ class EmulatorManager { ); } - RegExp androidApiVersion = new RegExp(r';android-(\d+);'); + RegExp androidApiVersion = RegExp(r';android-(\d+);'); Future _getPreferredSdkId() async { // It seems that to get the available list of images, we need to send a // request to create without the image and it'll provide us a list :-( @@ -252,14 +252,14 @@ abstract class Emulator { } // Calculate column widths - final List indices = new List.generate(table[0].length - 1, (int i) => i); + final List indices = List.generate(table[0].length - 1, (int i) => i); List widths = indices.map((int i) => 0).toList(); for (List row in table) { widths = indices.map((int i) => math.max(widths[i], row[i].length)).toList(); } // Join columns into lines of text - final RegExp whiteSpaceAndDots = new RegExp(r'[•\s]+$'); + final RegExp whiteSpaceAndDots = RegExp(r'[•\s]+$'); return table .map((List row) { return indices diff --git a/packages/flutter_tools/lib/src/flutter_manifest.dart b/packages/flutter_tools/lib/src/flutter_manifest.dart index 60b3fb3296..9e937f4ffc 100644 --- a/packages/flutter_tools/lib/src/flutter_manifest.dart +++ b/packages/flutter_tools/lib/src/flutter_manifest.dart @@ -14,7 +14,7 @@ import 'base/utils.dart'; import 'cache.dart'; import 'globals.dart'; -final RegExp _versionPattern = new RegExp(r'^(\d+)(\.(\d+)(\.(\d+))?)?(\+(\d+))?$'); +final RegExp _versionPattern = RegExp(r'^(\d+)(\.(\d+)(\.(\d+))?)?(\+(\d+))?$'); /// A wrapper around the `flutter` section in the `pubspec.yaml` file. class FlutterManifest { @@ -22,7 +22,7 @@ class FlutterManifest { /// Returns an empty manifest. static FlutterManifest empty() { - final FlutterManifest manifest = new FlutterManifest._(); + final FlutterManifest manifest = FlutterManifest._(); manifest._descriptor = const {}; manifest._flutterDescriptor = const {}; return manifest; @@ -43,7 +43,7 @@ class FlutterManifest { } static Future _createFromYaml(dynamic yamlDocument) async { - final FlutterManifest pubspec = new FlutterManifest._(); + final FlutterManifest pubspec = FlutterManifest._(); if (yamlDocument != null && !await _validate(yamlDocument)) return null; @@ -199,14 +199,14 @@ class FlutterManifest { continue; } - fontAssets.add(new FontAsset( + fontAssets.add(FontAsset( Uri.parse(asset), weight: fontFile['weight'], style: fontFile['style'], )); } if (fontAssets.isNotEmpty) - fonts.add(new Font(fontFamily['family'], fontAssets)); + fonts.add(Font(fontFamily['family'], fontAssets)); } return fonts; } @@ -277,7 +277,7 @@ Future _validate(dynamic manifest) async { final String schemaData = fs.file(schemaPath).readAsStringSync(); final Schema schema = await Schema.createSchema( convert.json.decode(schemaData)); - final Validator validator = new Validator(schema); + final Validator validator = Validator(schema); if (validator.validate(manifest)) { return true; } else { diff --git a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart index f6cb30f0ef..0c02bcc412 100644 --- a/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart +++ b/packages/flutter_tools/lib/src/fuchsia/fuchsia_device.dart @@ -49,7 +49,7 @@ class FuchsiaDevice extends Device { Future isLatestBuildInstalled(ApplicationPackage app) async => false; @override - Future installApp(ApplicationPackage app) => new Future.value(false); + Future installApp(ApplicationPackage app) => Future.value(false); @override Future uninstallApp(ApplicationPackage app) async => false; @@ -68,7 +68,7 @@ class FuchsiaDevice extends Device { bool applicationNeedsRebuild = false, bool usesTerminalUi = false, bool ipv6 = false, - }) => new Future.error('unimplemented'); + }) => Future.error('unimplemented'); @override Future stopApp(ApplicationPackage app) async { @@ -85,7 +85,7 @@ class FuchsiaDevice extends Device { _FuchsiaLogReader _logReader; @override DeviceLogReader getLogReader({ApplicationPackage app}) { - _logReader ??= new _FuchsiaLogReader(this); + _logReader ??= _FuchsiaLogReader(this); return _logReader; } diff --git a/packages/flutter_tools/lib/src/intellij/intellij.dart b/packages/flutter_tools/lib/src/intellij/intellij.dart index ced7d723d2..03f2d0f7ed 100644 --- a/packages/flutter_tools/lib/src/intellij/intellij.dart +++ b/packages/flutter_tools/lib/src/intellij/intellij.dart @@ -11,7 +11,7 @@ import '../base/version.dart'; import '../doctor.dart'; class IntelliJPlugins { - static final Version kMinFlutterPluginVersion = new Version(16, 0, 0); + static final Version kMinFlutterPluginVersion = Version(16, 0, 0); final String pluginsPath; @@ -26,19 +26,19 @@ class IntelliJPlugins { } final String versionText = _readPackageVersion(packageName); - final Version version = new Version.parse(versionText); + final Version version = Version.parse(versionText); if (version != null && minVersion != null && version < minVersion) { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( '$title plugin version $versionText - the recommended minimum version is $minVersion')); } else { - messages.add(new ValidationMessage( + messages.add(ValidationMessage( '$title plugin ${version != null ? "version $version" : "installed"}')); } return; } - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( '$title plugin not installed; this adds $title specific functionality.')); } @@ -57,7 +57,7 @@ class IntelliJPlugins { // rather than reading the entire file into memory. try { final Archive archive = - new ZipDecoder().decodeBytes(fs.file(jarPath).readAsBytesSync()); + ZipDecoder().decodeBytes(fs.file(jarPath).readAsBytesSync()); final ArchiveFile file = archive.findFile('META-INF/plugin.xml'); final String content = utf8.decode(file.content); const String versionStartTag = ''; diff --git a/packages/flutter_tools/lib/src/ios/cocoapods.dart b/packages/flutter_tools/lib/src/ios/cocoapods.dart index 1b98d2bd74..96f7d324f4 100644 --- a/packages/flutter_tools/lib/src/ios/cocoapods.dart +++ b/packages/flutter_tools/lib/src/ios/cocoapods.dart @@ -65,10 +65,10 @@ class CocoaPods { if (versionText == null) return CocoaPodsStatus.notInstalled; try { - final Version installedVersion = new Version.parse(versionText); - if (installedVersion < new Version.parse(cocoaPodsMinimumVersion)) + final Version installedVersion = Version.parse(versionText); + if (installedVersion < Version.parse(cocoaPodsMinimumVersion)) return CocoaPodsStatus.belowMinimumVersion; - else if (installedVersion < new Version.parse(cocoaPodsRecommendedVersion)) + else if (installedVersion < Version.parse(cocoaPodsRecommendedVersion)) return CocoaPodsStatus.belowRecommendedVersion; else return CocoaPodsStatus.recommended; diff --git a/packages/flutter_tools/lib/src/ios/code_signing.dart b/packages/flutter_tools/lib/src/ios/code_signing.dart index a060eb165d..0774bf14b4 100644 --- a/packages/flutter_tools/lib/src/ios/code_signing.dart +++ b/packages/flutter_tools/lib/src/ios/code_signing.dart @@ -79,9 +79,9 @@ const String fixWithDevelopmentTeamInstruction = ''' final RegExp _securityFindIdentityDeveloperIdentityExtractionPattern = - new RegExp(r'^\s*\d+\).+"(.+Developer.+)"$'); -final RegExp _securityFindIdentityCertificateCnExtractionPattern = new RegExp(r'.*\(([a-zA-Z0-9]+)\)'); -final RegExp _certificateOrganizationalUnitExtractionPattern = new RegExp(r'OU=([a-zA-Z0-9]+)'); + RegExp(r'^\s*\d+\).+"(.+Developer.+)"$'); +final RegExp _securityFindIdentityCertificateCnExtractionPattern = RegExp(r'.*\(([a-zA-Z0-9]+)\)'); +final RegExp _certificateOrganizationalUnitExtractionPattern = RegExp(r'OU=([a-zA-Z0-9]+)'); /// Given a [BuildableIOSApp], this will try to find valid development code /// signing identities in the user's keychain prompting a choice if multiple @@ -217,7 +217,7 @@ Future _chooseSigningIdentity(List validCodeSigningIdentities, b printStatus(' a) Abort', emphasis: true); final String choice = await terminal.promptForCharInput( - new List.generate(count, (int number) => '${number + 1}') + List.generate(count, (int number) => '${number + 1}') ..add('a'), prompt: 'Please select a certificate for code signing', displayAcceptedCharacters: true, diff --git a/packages/flutter_tools/lib/src/ios/devices.dart b/packages/flutter_tools/lib/src/ios/devices.dart index d9e7750579..111b654153 100644 --- a/packages/flutter_tools/lib/src/ios/devices.dart +++ b/packages/flutter_tools/lib/src/ios/devices.dart @@ -60,7 +60,7 @@ class IOSDeploy { // python at the front of the path, which may not include package 'six'. // Ensure that we pick up the system install of python, which does include // it. - final Map iosDeployEnv = new Map.from(platform.environment); + final Map iosDeployEnv = Map.from(platform.environment); iosDeployEnv['PATH'] = '/usr/bin:${iosDeployEnv['PATH']}'; return await runCommandAndStreamOutput( @@ -151,7 +151,7 @@ class IOSDevice extends Device { final String deviceName = await iMobileDevice.getInfoForDevice(id, 'DeviceName'); final String sdkVersion = await iMobileDevice.getInfoForDevice(id, 'ProductVersion'); - devices.add(new IOSDevice(id, name: deviceName, sdkVersion: sdkVersion)); + devices.add(IOSDevice(id, name: deviceName, sdkVersion: sdkVersion)); } return devices; } @@ -177,7 +177,7 @@ class IOSDevice extends Device { Future isAppInstalled(ApplicationPackage app) async { try { final RunResult apps = await runCheckedAsync([_installerPath, '--list-apps']); - if (new RegExp(app.id, multiLine: true).hasMatch(apps.stdout)) { + if (RegExp(app.id, multiLine: true).hasMatch(apps.stdout)) { return true; } } catch (e) { @@ -247,11 +247,11 @@ class IOSDevice extends Device { printError('Could not build the precompiled application for the device.'); await diagnoseXcodeBuildFailure(buildResult); printError(''); - return new LaunchResult.failed(); + return LaunchResult.failed(); } } else { if (!await installApp(package)) - return new LaunchResult.failed(); + return LaunchResult.failed(); } // Step 2: Check that the application exists at the specified path. @@ -259,7 +259,7 @@ class IOSDevice extends Device { final Directory bundle = fs.directory(iosApp.deviceBundlePath); if (!bundle.existsSync()) { printError('Could not find the built application bundle at ${bundle.path}.'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } // Step 3: Attempt to install the application on the device. @@ -305,7 +305,7 @@ class IOSDevice extends Device { // TODO(danrubel): The Android device class does something similar to this code below. // The various Device subclasses should be refactored and common code moved into the superclass. - final ProtocolDiscovery observatoryDiscovery = new ProtocolDiscovery.observatory( + final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(app: package), portForwarder: portForwarder, hostPort: debuggingOptions.observatoryPort, @@ -341,10 +341,10 @@ class IOSDevice extends Device { printError('Try launching Xcode and selecting "Product > Run" to fix the problem:'); printError(' open ios/Runner.xcworkspace'); printError(''); - return new LaunchResult.failed(); + return LaunchResult.failed(); } - return new LaunchResult.succeeded(observatoryUri: localObservatoryUri); + return LaunchResult.succeeded(observatoryUri: localObservatoryUri); } @override @@ -362,11 +362,11 @@ class IOSDevice extends Device { @override DeviceLogReader getLogReader({ApplicationPackage app}) { _logReaders ??= {}; - return _logReaders.putIfAbsent(app, () => new _IOSDeviceLogReader(this, app)); + return _logReaders.putIfAbsent(app, () => _IOSDeviceLogReader(this, app)); } @override - DevicePortForwarder get portForwarder => _portForwarder ??= new _IOSDevicePortForwarder(this); + DevicePortForwarder get portForwarder => _portForwarder ??= _IOSDevicePortForwarder(this); @override void clearLogs() { @@ -446,7 +446,7 @@ class _IOSDeviceLogReader extends DeviceLogReader { RegExp _anyLineRegex; _IOSDeviceLogReader(this.device, ApplicationPackage app) { - _linesController = new StreamController.broadcast( + _linesController = StreamController.broadcast( onListen: _start, onCancel: _stop ); @@ -456,11 +456,11 @@ class _IOSDeviceLogReader extends DeviceLogReader { // iOS 9 format: Runner[297] : // iOS 10 format: Runner(Flutter)[297] : final String appName = app == null ? '' : app.name.replaceAll('.app', ''); - _runnerLineRegex = new RegExp(appName + r'(\(Flutter\))?\[[\d]+\] <[A-Za-z]+>: '); + _runnerLineRegex = RegExp(appName + r'(\(Flutter\))?\[[\d]+\] <[A-Za-z]+>: '); // Similar to above, but allows ~arbitrary components instead of "Runner" // and "Flutter". The regex tries to strike a balance between not producing // false positives and not producing false negatives. - _anyLineRegex = new RegExp(r'\w+(\([^)]*\))?\[\d+\] <[A-Za-z]+>: '); + _anyLineRegex = RegExp(r'\w+(\([^)]*\))?\[\d+\] <[A-Za-z]+>: '); } final IOSDevice device; @@ -558,16 +558,16 @@ class _IOSDevicePortForwarder extends DevicePortForwarder { if (autoselect) { hostPort += 1; if (hostPort > 65535) - throw new Exception('Could not find open port on host.'); + throw Exception('Could not find open port on host.'); } else { - throw new Exception('Port $hostPort is not available.'); + throw Exception('Port $hostPort is not available.'); } } } assert(connected); assert(process != null); - final ForwardedPort forwardedPort = new ForwardedPort.withContext( + final ForwardedPort forwardedPort = ForwardedPort.withContext( hostPort, devicePort, process, ); printTrace('Forwarded port $forwardedPort'); diff --git a/packages/flutter_tools/lib/src/ios/ios_emulators.dart b/packages/flutter_tools/lib/src/ios/ios_emulators.dart index f9c3a579f6..a6d197dcb0 100644 --- a/packages/flutter_tools/lib/src/ios/ios_emulators.dart +++ b/packages/flutter_tools/lib/src/ios/ios_emulators.dart @@ -67,5 +67,5 @@ List getEmulators() { return []; } - return [new IOSEmulator('apple_ios_simulator')]; + return [IOSEmulator('apple_ios_simulator')]; } diff --git a/packages/flutter_tools/lib/src/ios/ios_workflow.dart b/packages/flutter_tools/lib/src/ios/ios_workflow.dart index 718d37c61c..c752ceffd9 100644 --- a/packages/flutter_tools/lib/src/ios/ios_workflow.dart +++ b/packages/flutter_tools/lib/src/ios/ios_workflow.dart @@ -61,8 +61,8 @@ class IOSValidator extends DoctorValidator { if (!await hasIosDeploy) return false; try { - final Version version = new Version.parse(await iosDeployVersionText); - return version >= new Version.parse(iosDeployMinimumVersion); + final Version version = Version.parse(await iosDeployVersionText); + return version >= Version.parse(iosDeployMinimumVersion); } on FormatException catch (_) { return false; } @@ -78,16 +78,16 @@ class IOSValidator extends DoctorValidator { if (xcode.isInstalled) { xcodeStatus = ValidationType.installed; - messages.add(new ValidationMessage('Xcode at ${xcode.xcodeSelectPath}')); + messages.add(ValidationMessage('Xcode at ${xcode.xcodeSelectPath}')); xcodeVersionInfo = xcode.versionText; if (xcodeVersionInfo.contains(',')) xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(',')); - messages.add(new ValidationMessage(xcode.versionText)); + messages.add(ValidationMessage(xcode.versionText)); if (!xcode.isInstalledAndMeetsVersionCheck) { xcodeStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Flutter requires a minimum Xcode version of $kXcodeRequiredVersionMajor.$kXcodeRequiredVersionMinor.0.\n' 'Download the latest version or update via the Mac App Store.' )); @@ -95,13 +95,13 @@ class IOSValidator extends DoctorValidator { if (!xcode.eulaSigned) { xcodeStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Xcode end user license agreement not signed; open Xcode or run the command \'sudo xcodebuild -license\'.' )); } if (!xcode.isSimctlInstalled) { xcodeStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Xcode requires additional components to be installed in order to run.\n' 'Launch Xcode and install additional required components when prompted.' )); @@ -110,12 +110,12 @@ class IOSValidator extends DoctorValidator { } else { xcodeStatus = ValidationType.missing; if (xcode.xcodeSelectPath == null || xcode.xcodeSelectPath.isEmpty) { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Xcode not installed; this is necessary for iOS development.\n' 'Download at https://developer.apple.com/xcode/download/.' )); } else { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Xcode installation is incomplete; a full installation is necessary for iOS development.\n' 'Download at: https://developer.apple.com/xcode/download/\n' 'Or install Xcode via the App Store.\n' @@ -131,14 +131,14 @@ class IOSValidator extends DoctorValidator { if (!iMobileDevice.isInstalled) { brewStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'libimobiledevice and ideviceinstaller are not installed. To install, run:\n' ' brew install --HEAD libimobiledevice\n' ' brew install ideviceinstaller' )); } else if (!await iMobileDevice.isWorking) { brewStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Verify that all connected devices have been paired with this computer in Xcode.\n' 'If all devices have been paired, libimobiledevice and ideviceinstaller may require updating.\n' 'To update, run:\n' @@ -148,7 +148,7 @@ class IOSValidator extends DoctorValidator { )); } else if (!await hasIDeviceInstaller) { brewStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'ideviceinstaller is not installed; this is used to discover connected iOS devices.\n' 'To install, run:\n' ' brew install --HEAD libimobiledevice\n' @@ -158,17 +158,17 @@ class IOSValidator extends DoctorValidator { // Check ios-deploy is installed at meets version requirements. if (await hasIosDeploy) { - messages.add(new ValidationMessage('ios-deploy ${await iosDeployVersionText}')); + messages.add(ValidationMessage('ios-deploy ${await iosDeployVersionText}')); } if (!await _iosDeployIsInstalledAndMeetsVersionCheck) { brewStatus = ValidationType.partial; if (await hasIosDeploy) { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'ios-deploy out of date ($iosDeployMinimumVersion is required). To upgrade:\n' ' brew upgrade ios-deploy' )); } else { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'ios-deploy not installed. To install:\n' ' brew install ios-deploy' )); @@ -179,10 +179,10 @@ class IOSValidator extends DoctorValidator { if (cocoaPodsStatus == CocoaPodsStatus.recommended) { if (await cocoaPods.isCocoaPodsInitialized) { - messages.add(new ValidationMessage('CocoaPods version ${await cocoaPods.cocoaPodsVersionText}')); + messages.add(ValidationMessage('CocoaPods version ${await cocoaPods.cocoaPodsVersionText}')); } else { brewStatus = ValidationType.partial; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'CocoaPods installed but not initialized.\n' '$noCocoaPodsConsequence\n' 'To initialize CocoaPods, run:\n' @@ -193,14 +193,14 @@ class IOSValidator extends DoctorValidator { } else { brewStatus = ValidationType.partial; if (cocoaPodsStatus == CocoaPodsStatus.notInstalled) { - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'CocoaPods not installed.\n' '$noCocoaPodsConsequence\n' 'To install:\n' '$cocoaPodsInstallInstructions' )); } else { - messages.add(new ValidationMessage.hint( + messages.add(ValidationMessage.hint( 'CocoaPods out of date (${cocoaPods.cocoaPodsRecommendedVersion} is recommended).\n' '$noCocoaPodsConsequence\n' 'To upgrade:\n' @@ -210,13 +210,13 @@ class IOSValidator extends DoctorValidator { } } else { brewStatus = ValidationType.missing; - messages.add(new ValidationMessage.error( + messages.add(ValidationMessage.error( 'Brew not installed; use this to install tools for iOS device development.\n' 'Download brew at https://brew.sh/.' )); } - return new ValidationResult( + return ValidationResult( [xcodeStatus, brewStatus].reduce(_mergeValidationTypes), messages, statusInfo: xcodeVersionInfo diff --git a/packages/flutter_tools/lib/src/ios/mac.dart b/packages/flutter_tools/lib/src/ios/mac.dart index 267961c309..294d7857dc 100644 --- a/packages/flutter_tools/lib/src/ios/mac.dart +++ b/packages/flutter_tools/lib/src/ios/mac.dart @@ -60,10 +60,10 @@ class IMobileDevice { try { final ProcessResult result = await processManager.run(['idevice_id', '-l']); if (result.exitCode != 0) - throw new ToolExit('idevice_id returned an error:\n${result.stderr}'); + throw ToolExit('idevice_id returned an error:\n${result.stderr}'); return result.stdout; } on ProcessException { - throw new ToolExit('Failed to invoke idevice_id. Run flutter doctor.'); + throw ToolExit('Failed to invoke idevice_id. Run flutter doctor.'); } } @@ -71,10 +71,10 @@ class IMobileDevice { try { final ProcessResult result = await processManager.run(['ideviceinfo', '-u', deviceID, '-k', key, '--simple']); if (result.exitCode != 0) - throw new ToolExit('idevice_id returned an error:\n${result.stderr}'); + throw ToolExit('idevice_id returned an error:\n${result.stderr}'); return result.stdout.trim(); } on ProcessException { - throw new ToolExit('Failed to invoke idevice_id. Run flutter doctor.'); + throw ToolExit('Failed to invoke idevice_id. Run flutter doctor.'); } } @@ -190,17 +190,17 @@ Future buildXcodeProject({ bool usesTerminalUi = true, }) async { if (!await upgradePbxProjWithFlutterAssets(app.project)) - return new XcodeBuildResult(success: false); + return XcodeBuildResult(success: false); if (!_checkXcodeVersion()) - return new XcodeBuildResult(success: false); + return XcodeBuildResult(success: false); final XcodeProjectInfo projectInfo = xcodeProjectInterpreter.getInfo(app.project.directory.path); if (!projectInfo.targets.contains('Runner')) { printError('The Xcode project does not define target "Runner" which is needed by Flutter tooling.'); printError('Open Xcode to fix the problem:'); printError(' open ios/Runner.xcworkspace'); - return new XcodeBuildResult(success: false); + return XcodeBuildResult(success: false); } final String scheme = projectInfo.schemeFor(buildInfo); if (scheme == null) { @@ -212,7 +212,7 @@ Future buildXcodeProject({ printError('The Xcode project does not define custom schemes.'); printError('You cannot use the --flavor option.'); } - return new XcodeBuildResult(success: false); + return XcodeBuildResult(success: false); } final String configuration = projectInfo.buildConfigurationFor(buildInfo, scheme); if (configuration == null) { @@ -221,7 +221,7 @@ Future buildXcodeProject({ printError('Flutter expects a build configuration named ${XcodeProjectInfo.expectedBuildConfigurationFor(buildInfo, scheme)} or similar.'); printError('Open Xcode to fix the problem:'); printError(' open ios/Runner.xcworkspace'); - return new XcodeBuildResult(success: false); + return XcodeBuildResult(success: false); } Map autoSigningConfigs; @@ -242,7 +242,7 @@ Future buildXcodeProject({ if (hasPlugins(project)) { // If the Xcode project, Podfile, or Generated.xcconfig have changed since // last run, pods should be updated. - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: fs.path.join(getIosBuildDirectory(), 'pod_inputs.fingerprint'), paths: [ app.project.xcodeProjectInfoFile.path, @@ -346,7 +346,7 @@ Future buildXcodeProject({ buildCommands.add('SCRIPT_OUTPUT_STREAM_FILE=${scriptOutputPipeFile.absolute.path}'); } - final Stopwatch buildStopwatch = new Stopwatch()..start(); + final Stopwatch buildStopwatch = Stopwatch()..start(); initialBuildStatus = logger.startProgress('Starting Xcode build...'); final RunResult buildResult = await runAsync( buildCommands, @@ -366,7 +366,7 @@ Future buildXcodeProject({ // Run -showBuildSettings again but with the exact same parameters as the build. final Map buildSettings = parseXcodeBuildSettings(runCheckedSync( - (new List + (List .from(buildCommands) ..add('-showBuildSettings')) // Undocumented behaviour: xcodebuild craps out if -showBuildSettings @@ -391,11 +391,11 @@ Future buildXcodeProject({ printStatus('Xcode\'s output:\n↳'); printStatus(buildResult.stdout, indent: 4); } - return new XcodeBuildResult( + return XcodeBuildResult( success: false, stdout: buildResult.stdout, stderr: buildResult.stderr, - xcodeBuildExecution: new XcodeBuildExecution( + xcodeBuildExecution: XcodeBuildExecution( buildCommands: buildCommands, appDirectory: app.project.directory.path, buildForPhysicalDevice: buildForDevice, @@ -422,7 +422,7 @@ Future buildXcodeProject({ } else { printError('Build succeeded but the expected app at $expectedOutputDirectory not found'); } - return new XcodeBuildResult(success: true, output: outputDir); + return XcodeBuildResult(success: true, output: outputDir); } } @@ -632,7 +632,7 @@ Future upgradePbxProjWithFlutterAssets(IosProject project) async { lines.remove(l12); } - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); lines.forEach(buffer.writeln); await xcodeProjectFile.writeAsString(buffer.toString()); return true; diff --git a/packages/flutter_tools/lib/src/ios/simulators.dart b/packages/flutter_tools/lib/src/ios/simulators.dart index 39c0cee5b5..e4ba8301ed 100644 --- a/packages/flutter_tools/lib/src/ios/simulators.dart +++ b/packages/flutter_tools/lib/src/ios/simulators.dart @@ -47,7 +47,7 @@ class IOSSimulatorUtils { return []; return SimControl.instance.getConnectedDevices().map((SimDevice device) { - return new IOSSimulator(device.udid, name: device.name, category: device.category); + return IOSSimulator(device.udid, name: device.name, category: device.category); }).toList(); } } @@ -97,7 +97,7 @@ class SimControl { for (String deviceCategory in devicesSection.keys) { final List devicesData = devicesSection[deviceCategory]; for (Map data in devicesData.map>(castStringKeyedMap)) { - devices.add(new SimDevice(deviceCategory, data)); + devices.add(SimDevice(deviceCategory, data)); } } @@ -246,7 +246,7 @@ class IOSSimulator extends Device { // Check if the device is part of a blacklisted category. // We do not yet support WatchOS or tvOS devices. - final RegExp blacklist = new RegExp(r'Apple (TV|Watch)', caseSensitive: false); + final RegExp blacklist = RegExp(r'Apple (TV|Watch)', caseSensitive: false); if (blacklist.hasMatch(name)) { _supportMessage = 'Flutter does not support Apple TV or Apple Watch.'; return false; @@ -283,11 +283,11 @@ class IOSSimulator extends Device { await _setupUpdatedApplicationBundle(package, debuggingOptions.buildInfo, mainPath, usesTerminalUi); } on ToolExit catch (e) { printError(e.message); - return new LaunchResult.failed(); + return LaunchResult.failed(); } } else { if (!await installApp(package)) - return new LaunchResult.failed(); + return LaunchResult.failed(); } // Prepare launch arguments. @@ -308,7 +308,7 @@ class IOSSimulator extends Device { ProtocolDiscovery observatoryDiscovery; if (debuggingOptions.debuggingEnabled) - observatoryDiscovery = new ProtocolDiscovery.observatory( + observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(app: package), ipv6: ipv6); // Launch the updated application in the simulator. @@ -316,11 +316,11 @@ class IOSSimulator extends Device { await SimControl.instance.launch(id, package.id, args); } catch (error) { printError('$error'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } if (!debuggingOptions.debuggingEnabled) { - return new LaunchResult.succeeded(); + return LaunchResult.succeeded(); } // Wait for the service protocol port here. This will complete once the @@ -329,10 +329,10 @@ class IOSSimulator extends Device { try { final Uri deviceUri = await observatoryDiscovery.uri; - return new LaunchResult.succeeded(observatoryUri: deviceUri); + return LaunchResult.succeeded(observatoryUri: deviceUri); } catch (error) { printError('Error waiting for a debug connection: $error'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } finally { await observatoryDiscovery.cancel(); } @@ -357,7 +357,7 @@ class IOSSimulator extends Device { // Step 1: Build the Xcode project. // The build mode for the simulator is always debug. - final BuildInfo debugBuildInfo = new BuildInfo(BuildMode.debug, buildInfo.flavor, + final BuildInfo debugBuildInfo = BuildInfo(BuildMode.debug, buildInfo.flavor, trackWidgetCreation: buildInfo.trackWidgetCreation, extraFrontEndOptions: buildInfo.extraFrontEndOptions, extraGenSnapshotOptions: buildInfo.extraGenSnapshotOptions, @@ -411,7 +411,7 @@ class IOSSimulator extends Device { @override Future get sdkNameAndVersion async => category; - final RegExp _iosSdkRegExp = new RegExp(r'iOS( |-)(\d+)'); + final RegExp _iosSdkRegExp = RegExp(r'iOS( |-)(\d+)'); Future get sdkMajorVersion async { final Match sdkMatch = _iosSdkRegExp.firstMatch(await sdkNameAndVersion); @@ -422,11 +422,11 @@ class IOSSimulator extends Device { DeviceLogReader getLogReader({ApplicationPackage app}) { assert(app is IOSApp); _logReaders ??= {}; - return _logReaders.putIfAbsent(app, () => new _IOSSimulatorLogReader(this, app)); + return _logReaders.putIfAbsent(app, () => _IOSSimulatorLogReader(this, app)); } @override - DevicePortForwarder get portForwarder => _portForwarder ??= new _IOSSimulatorDevicePortForwarder(this); + DevicePortForwarder get portForwarder => _portForwarder ??= _IOSSimulatorDevicePortForwarder(this); @override void clearLogs() { @@ -485,7 +485,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader { String _appName; _IOSSimulatorLogReader(this.device, IOSApp app) { - _linesController = new StreamController.broadcast( + _linesController = StreamController.broadcast( onListen: _start, onCancel: _stop ); @@ -532,13 +532,13 @@ class _IOSSimulatorLogReader extends DeviceLogReader { // Match the log prefix (in order to shorten it): // * Xcode 8: Sep 13 15:28:51 cbracken-macpro localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/ // * Xcode 9: 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/ - static final RegExp _mapRegex = new RegExp(r'\S+ +\S+ +\S+ +(\S+ +)?(\S+)\[\d+\]\)?: (\(.*?\))? *(.*)$'); + static final RegExp _mapRegex = RegExp(r'\S+ +\S+ +\S+ +(\S+ +)?(\S+)\[\d+\]\)?: (\(.*?\))? *(.*)$'); // Jan 31 19:23:28 --- last message repeated 1 time --- - static final RegExp _lastMessageSingleRegex = new RegExp(r'\S+ +\S+ +\S+ --- last message repeated 1 time ---$'); - static final RegExp _lastMessageMultipleRegex = new RegExp(r'\S+ +\S+ +\S+ --- last message repeated (\d+) times ---$'); + static final RegExp _lastMessageSingleRegex = RegExp(r'\S+ +\S+ +\S+ --- last message repeated 1 time ---$'); + static final RegExp _lastMessageMultipleRegex = RegExp(r'\S+ +\S+ +\S+ --- last message repeated (\d+) times ---$'); - static final RegExp _flutterRunnerRegex = new RegExp(r' FlutterRunner\[\d+\] '); + static final RegExp _flutterRunnerRegex = RegExp(r' FlutterRunner\[\d+\] '); String _filterDeviceLine(String string) { final Match match = _mapRegex.matchAsPrefix(string); @@ -579,7 +579,7 @@ class _IOSSimulatorLogReader extends DeviceLogReader { if (_lastMessageSingleRegex.matchAsPrefix(string) != null) return null; - if (new RegExp(r'assertion failed: .* libxpc.dylib .* 0x7d$').matchAsPrefix(string) != null) + if (RegExp(r'assertion failed: .* libxpc.dylib .* 0x7d$').matchAsPrefix(string) != null) return null; return string; @@ -652,7 +652,7 @@ int compareIosVersions(String v1, String v2) { /// ✗ com.apple.CoreSimulator.SimDeviceType.iPad-2 /// ✗ com.apple.CoreSimulator.SimDeviceType.Apple-Watch-38mm final RegExp _iosDeviceTypePattern = - new RegExp(r'com.apple.CoreSimulator.SimDeviceType.iPhone-(\d+)(.*)'); + RegExp(r'com.apple.CoreSimulator.SimDeviceType.iPhone-(\d+)(.*)'); int compareIphoneVersions(String id1, String id2) { final Match m1 = _iosDeviceTypePattern.firstMatch(id1); @@ -690,7 +690,7 @@ class _IOSSimulatorDevicePortForwarder extends DevicePortForwarder { hostPort = devicePort; } assert(devicePort == hostPort); - _ports.add(new ForwardedPort(devicePort, hostPort)); + _ports.add(ForwardedPort(devicePort, hostPort)); return hostPort; } diff --git a/packages/flutter_tools/lib/src/ios/xcodeproj.dart b/packages/flutter_tools/lib/src/ios/xcodeproj.dart index 584f66bc92..9e638650aa 100644 --- a/packages/flutter_tools/lib/src/ios/xcodeproj.dart +++ b/packages/flutter_tools/lib/src/ios/xcodeproj.dart @@ -19,8 +19,8 @@ import '../cache.dart'; import '../globals.dart'; import '../project.dart'; -final RegExp _settingExpr = new RegExp(r'(\w+)\s*=\s*(.*)$'); -final RegExp _varExpr = new RegExp(r'\$\(([^)]*)\)'); +final RegExp _settingExpr = RegExp(r'(\w+)\s*=\s*(.*)$'); +final RegExp _varExpr = RegExp(r'\$\(([^)]*)\)'); String flutterFrameworkDir(BuildMode mode) { return fs.path.normalize(fs.path.dirname(artifacts.getArtifactPath(Artifact.flutterFramework, TargetPlatform.ios, mode))); @@ -35,7 +35,7 @@ Future updateGeneratedXcodeProperties({ @required BuildInfo buildInfo, String targetOverride, }) async { - final StringBuffer localsBuffer = new StringBuffer(); + final StringBuffer localsBuffer = StringBuffer(); localsBuffer.writeln('// This is a generated file; do not edit or check into version control.'); @@ -102,7 +102,7 @@ XcodeProjectInterpreter get xcodeProjectInterpreter => context[XcodeProjectInter /// Interpreter of Xcode projects. class XcodeProjectInterpreter { static const String _executable = '/usr/bin/xcodebuild'; - static final RegExp _versionRegex = new RegExp(r'Xcode ([0-9.]+)'); + static final RegExp _versionRegex = RegExp(r'Xcode ([0-9.]+)'); void _updateVersion() { if (!platform.isMacOS || !fs.file(_executable).existsSync()) { @@ -165,7 +165,7 @@ class XcodeProjectInterpreter { final String out = runCheckedSync([ _executable, '-list', ], workingDirectory: projectPath); - return new XcodeProjectInfo.fromXcodeBuildOutput(out); + return XcodeProjectInfo.fromXcodeBuildOutput(out); } } @@ -218,7 +218,7 @@ class XcodeProjectInfo { } if (schemes.isEmpty) schemes.add('Runner'); - return new XcodeProjectInfo(targets, buildConfigurations, schemes); + return XcodeProjectInfo(targets, buildConfigurations, schemes); } final List targets; diff --git a/packages/flutter_tools/lib/src/plugins.dart b/packages/flutter_tools/lib/src/plugins.dart index 288d87a35c..ea5f79829e 100644 --- a/packages/flutter_tools/lib/src/plugins.dart +++ b/packages/flutter_tools/lib/src/plugins.dart @@ -15,7 +15,7 @@ import 'project.dart'; void _renderTemplateToFile(String template, dynamic context, String filePath) { final String renderedTemplate = - new mustache.Template(template).renderString(context); + mustache.Template(template).renderString(context); final File file = fs.file(filePath); file.createSync(recursive: true); file.writeAsStringSync(renderedTemplate); @@ -45,7 +45,7 @@ class Plugin { iosPrefix = pluginYaml['iosPrefix'] ?? ''; pluginClass = pluginYaml['pluginClass']; } - return new Plugin( + return Plugin( name: name, path: path, androidPackage: androidPackage, @@ -67,7 +67,7 @@ Plugin _pluginFromPubspec(String name, Uri packageRoot) { return null; final String packageRootPath = fs.path.fromUri(packageRoot); printTrace('Found plugin $name at $packageRootPath'); - return new Plugin.fromYaml(name, packageRootPath, flutterConfig['plugin']); + return Plugin.fromYaml(name, packageRootPath, flutterConfig['plugin']); } List findPlugins(FlutterProject project) { @@ -75,7 +75,7 @@ List findPlugins(FlutterProject project) { Map packages; try { final String packagesFile = fs.path.join(project.directory.path, PackageMap.globalPackagesPath); - packages = new PackageMap(packagesFile).map; + packages = PackageMap(packagesFile).map; } on FormatException catch (e) { printTrace('Invalid .packages file: $e'); return plugins; @@ -297,7 +297,7 @@ Future injectPlugins(FlutterProject project) async { await _writeAndroidPluginRegistrant(project, plugins); await _writeIOSPluginRegistrant(project, plugins); if (!project.isModule && project.ios.directory.existsSync()) { - final CocoaPods cocoaPods = new CocoaPods(); + final CocoaPods cocoaPods = CocoaPods(); if (plugins.isNotEmpty) cocoaPods.setupPodfile(project.ios); } diff --git a/packages/flutter_tools/lib/src/project.dart b/packages/flutter_tools/lib/src/project.dart index ce8779c6ec..6f11e0505e 100644 --- a/packages/flutter_tools/lib/src/project.dart +++ b/packages/flutter_tools/lib/src/project.dart @@ -45,7 +45,7 @@ class FlutterProject { final FlutterManifest exampleManifest = await _readManifest( _exampleDirectory(directory).childFile(bundle.defaultManifestPath).path, ); - return new FlutterProject(directory, manifest, exampleManifest); + return FlutterProject(directory, manifest, exampleManifest); } /// Returns a future that completes with a [FlutterProject] view of the current directory. @@ -76,7 +76,7 @@ class FlutterProject { example.android.applicationId, example.ios.productBundleIdentifier, ]; - return new Set.from(candidates + return Set.from(candidates .map(_organizationNameFromPackageName) .where((String name) => name != null)); } @@ -89,10 +89,10 @@ class FlutterProject { } /// The iOS sub project of this project. - IosProject get ios => new IosProject._(this); + IosProject get ios => IosProject._(this); /// The Android sub project of this project. - AndroidProject get android => new AndroidProject._(this); + AndroidProject get android => AndroidProject._(this); /// The `pubspec.yaml` file of this project. File get pubspecFile => directory.childFile('pubspec.yaml'); @@ -104,7 +104,7 @@ class FlutterProject { File get flutterPluginsFile => directory.childFile('.flutter-plugins'); /// The example sub-project of this project. - FlutterProject get example => new FlutterProject( + FlutterProject get example => FlutterProject( _exampleDirectory(directory), _exampleManifest, FlutterManifest.empty(), @@ -148,7 +148,7 @@ class FlutterProject { /// Instances will reflect the contents of the `ios/` sub-folder of /// Flutter applications and the `.ios/` sub-folder of Flutter modules. class IosProject { - static final RegExp _productBundleIdPattern = new RegExp(r'^\s*PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(.*);\s*$'); + static final RegExp _productBundleIdPattern = RegExp(r'^\s*PRODUCT_BUNDLE_IDENTIFIER\s*=\s*(.*);\s*$'); static const String _productBundleIdVariable = r'$(PRODUCT_BUNDLE_IDENTIFIER)'; static const String _hostAppBundleName = 'Runner'; @@ -262,7 +262,7 @@ class IosProject { } void _overwriteFromTemplate(String path, Directory target) { - final Template template = new Template.fromName(path); + final Template template = Template.fromName(path); template.render( target, { @@ -280,8 +280,8 @@ class IosProject { /// Instances will reflect the contents of the `android/` sub-folder of /// Flutter applications and the `.android/` sub-folder of Flutter modules. class AndroidProject { - static final RegExp _applicationIdPattern = new RegExp('^\\s*applicationId\\s+[\'\"](.*)[\'\"]\\s*\$'); - static final RegExp _groupPattern = new RegExp('^\\s*group\\s+[\'\"](.*)[\'\"]\\s*\$'); + static final RegExp _applicationIdPattern = RegExp('^\\s*applicationId\\s+[\'\"](.*)[\'\"]\\s*\$'); + static final RegExp _groupPattern = RegExp('^\\s*group\\s+[\'\"](.*)[\'\"]\\s*\$'); AndroidProject._(this.parent); @@ -379,7 +379,7 @@ class AndroidProject { } void _overwriteFromTemplate(String path, Directory target) { - final Template template = new Template.fromName(path); + final Template template = Template.fromName(path); template.render( target, { diff --git a/packages/flutter_tools/lib/src/protocol_discovery.dart b/packages/flutter_tools/lib/src/protocol_discovery.dart index ca3ee11f85..ff6664acac 100644 --- a/packages/flutter_tools/lib/src/protocol_discovery.dart +++ b/packages/flutter_tools/lib/src/protocol_discovery.dart @@ -28,7 +28,7 @@ class ProtocolDiscovery { bool ipv6 = false, }) { const String kObservatoryService = 'Observatory'; - return new ProtocolDiscovery._( + return ProtocolDiscovery._( logReader, kObservatoryService, portForwarder: portForwarder, @@ -43,7 +43,7 @@ class ProtocolDiscovery { final int hostPort; final bool ipv6; - final Completer _completer = new Completer(); + final Completer _completer = Completer(); StreamSubscription _deviceLogSubscription; @@ -60,7 +60,7 @@ class ProtocolDiscovery { void _handleLine(String line) { Uri uri; - final RegExp r = new RegExp('${RegExp.escape(serviceName)} listening on ((http|\/\/)[a-zA-Z0-9:/=\.\\[\\]]+)'); + final RegExp r = RegExp('${RegExp.escape(serviceName)} listening on ((http|\/\/)[a-zA-Z0-9:/=\.\\[\\]]+)'); final Match match = r.firstMatch(line); if (match != null) { @@ -91,7 +91,7 @@ class ProtocolDiscovery { hostUri = deviceUri.replace(port: actualHostPort); } - assert(new InternetAddress(hostUri.host).isLoopback); + assert(InternetAddress(hostUri.host).isLoopback); if (ipv6) { hostUri = hostUri.replace(host: InternetAddress.loopbackIPv6.host); } diff --git a/packages/flutter_tools/lib/src/resident_runner.dart b/packages/flutter_tools/lib/src/resident_runner.dart index 57c4569a78..d2706b85bf 100644 --- a/packages/flutter_tools/lib/src/resident_runner.dart +++ b/packages/flutter_tools/lib/src/resident_runner.dart @@ -35,7 +35,7 @@ class FlutterDevice { this.fileSystemRoots, this.fileSystemScheme, ResidentCompiler generator, - }) : this.generator = generator ?? new ResidentCompiler( + }) : this.generator = generator ?? ResidentCompiler( artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), trackWidgetCreation: trackWidgetCreation, fileSystemRoots: fileSystemRoots, fileSystemScheme: fileSystemScheme @@ -65,7 +65,7 @@ class FlutterDevice { Future _connect({ReloadSources reloadSources, CompileExpression compileExpression}) async { if (vmServices != null) return; - final List localVmServices = new List(observatoryUris.length); + final List localVmServices = List(observatoryUris.length); for (int i = 0; i < observatoryUris.length; i++) { printTrace('Connecting to service protocol: ${observatoryUris[i]}'); localVmServices[i] = await VMService.connect(observatoryUris[i], @@ -116,7 +116,7 @@ class FlutterDevice { view.uiIsolate.flutterExit(); // ignore: unawaited_futures } } - await new Future.delayed(const Duration(milliseconds: 100)); + await Future.delayed(const Duration(milliseconds: 100)); } Future setupDevFS(String fsName, @@ -124,7 +124,7 @@ class FlutterDevice { String packagesFilePath }) { // One devFS per device. Shared by all running instances. - devFS = new DevFS( + devFS = DevFS( vmServices[0], fsName, rootDirectory, @@ -170,7 +170,7 @@ class FlutterDevice { final List elements = []; for (Future> report in reports) { for (ProgramElement element in await report) - elements.add(new ProgramElement(element.qualifiedName, + elements.add(ProgramElement(element.qualifiedName, devFS.deviceUriToHostUri(element.uri), element.line, element.column)); @@ -439,7 +439,7 @@ abstract class ResidentRunner { final bool usesTerminalUI; final bool stayResident; final bool ipv6; - final Completer _finished = new Completer(); + final Completer _finished = Completer(); bool _stopped = false; String _packagesFilePath; String get packagesFilePath => _packagesFilePath; @@ -627,7 +627,7 @@ abstract class ResidentRunner { Future connectToServiceProtocol({String viewFilter, ReloadSources reloadSources, CompileExpression compileExpression}) async { if (!debuggingOptions.debuggingEnabled) - return new Future.error('Error the service protocol is not enabled.'); + return Future.error('Error the service protocol is not enabled.'); bool viewFound = false; for (FlutterDevice device in flutterDevices) { @@ -660,12 +660,12 @@ abstract class ResidentRunner { Future _serviceProtocolDone(dynamic object) { printTrace('Service protocol connection closed.'); - return new Future.value(object); + return Future.value(object); } Future _serviceProtocolError(dynamic error, StackTrace stack) { printTrace('Service protocol connection closed with an error: $error\n$stack'); - return new Future.error(error, stack); + return Future.error(error, stack); } /// Returns [true] if the input has been handled by this function. @@ -805,9 +805,9 @@ abstract class ResidentRunner { bool hasDirtyDependencies(FlutterDevice device) { final DartDependencySetBuilder dartDependencySetBuilder = - new DartDependencySetBuilder(mainPath, packagesFilePath); + DartDependencySetBuilder(mainPath, packagesFilePath); final DependencyChecker dependencyChecker = - new DependencyChecker(dartDependencySetBuilder, assetBundle); + DependencyChecker(dartDependencySetBuilder, assetBundle); if (device.package.packagesFile == null || !device.package.packagesFile.existsSync()) { return true; } @@ -876,7 +876,7 @@ class OperationResult { bool get isOk => code == 0; - static final OperationResult ok = new OperationResult(0, ''); + static final OperationResult ok = OperationResult(0, ''); } /// Given the value of the --target option, return the path of the Dart file diff --git a/packages/flutter_tools/lib/src/run_cold.dart b/packages/flutter_tools/lib/src/run_cold.dart index a7fddb2805..18a12c547b 100644 --- a/packages/flutter_tools/lib/src/run_cold.dart +++ b/packages/flutter_tools/lib/src/run_cold.dart @@ -66,7 +66,7 @@ class ColdRunner extends ResidentRunner { if (flutterDevices.first.observatoryUris != null) { // For now, only support one debugger connection. - connectionInfoCompleter?.complete(new DebugConnectionInfo( + connectionInfoCompleter?.complete(DebugConnectionInfo( httpUri: flutterDevices.first.observatoryUris.first, wsUri: flutterDevices.first.vmServices.first.wsAddress, )); diff --git a/packages/flutter_tools/lib/src/run_hot.dart b/packages/flutter_tools/lib/src/run_hot.dart index 40a3340285..f1c1a50bc8 100644 --- a/packages/flutter_tools/lib/src/run_hot.dart +++ b/packages/flutter_tools/lib/src/run_hot.dart @@ -106,9 +106,9 @@ class HotRunner extends ResidentRunner { } final DartDependencySetBuilder dartDependencySetBuilder = - new DartDependencySetBuilder(mainPath, packagesFilePath); + DartDependencySetBuilder(mainPath, packagesFilePath); try { - _dartDependencies = new Set.from(dartDependencySetBuilder.build()); + _dartDependencies = Set.from(dartDependencySetBuilder.build()); } on DartDependencyException catch (error) { printError( 'Your application could not be compiled, because its dependencies could not be established.\n' @@ -124,7 +124,7 @@ class HotRunner extends ResidentRunner { // TODO(cbernaschina): check that isolateId is the id of the UI isolate. final OperationResult result = await restart(pauseAfterRestart: pause); if (!result.isOk) { - throw new rpc.RpcException( + throw rpc.RpcException( rpc_error_code.INTERNAL_ERROR, 'Unable to reload sources', ); @@ -170,7 +170,7 @@ class HotRunner extends ResidentRunner { if (connectionInfoCompleter != null) { // Only handle one debugger connection. connectionInfoCompleter.complete( - new DebugConnectionInfo( + DebugConnectionInfo( httpUri: flutterDevices.first.observatoryUris.first, wsUri: flutterDevices.first.vmServices.first.wsAddress, baseUri: baseUris.first.toString() @@ -181,7 +181,7 @@ class HotRunner extends ResidentRunner { printError('Error initializing DevFS: $error'); return 3; } - final Stopwatch initialUpdateDevFSsTimer = new Stopwatch()..start(); + final Stopwatch initialUpdateDevFSsTimer = Stopwatch()..start(); final bool devfsResult = await _updateDevFS(fullRestart: true); _addBenchmarkData('hotReloadInitialDevFSSyncMilliseconds', initialUpdateDevFSsTimer.elapsed.inMilliseconds); @@ -255,7 +255,7 @@ class HotRunner extends ResidentRunner { return 1; } - firstBuildTime = new DateTime.now(); + firstBuildTime = DateTime.now(); for (FlutterDevice device in flutterDevices) { final int result = await device.runHot( @@ -404,7 +404,7 @@ class HotRunner extends ResidentRunner { await refreshViews(); } - final Stopwatch restartTimer = new Stopwatch()..start(); + final Stopwatch restartTimer = Stopwatch()..start(); // TODO(aam): Add generator reset logic once we switch to using incremental // compiler for full application recompilation on restart. final bool updatedDevFS = await _updateDevFS(fullRestart: true); @@ -413,7 +413,7 @@ class HotRunner extends ResidentRunner { if (device.generator != null) device.generator.reject(); } - return new OperationResult(1, 'DevFS synchronization failed'); + return OperationResult(1, 'DevFS synchronization failed'); } _resetDirtyAssets(); for (FlutterDevice device in flutterDevices) { @@ -492,7 +492,7 @@ class HotRunner extends ResidentRunner { @override Future restart({ bool fullRestart = false, bool pauseAfterRestart = false }) async { - final Stopwatch timer = new Stopwatch()..start(); + final Stopwatch timer = Stopwatch()..start(); if (fullRestart) { final Status status = logger.startProgress( 'Performing hot restart...', @@ -500,7 +500,7 @@ class HotRunner extends ResidentRunner { ); try { if (!(await hotRunnerConfig.setupHotRestart())) - return new OperationResult(1, 'setupHotRestart failed'); + return OperationResult(1, 'setupHotRestart failed'); await _restartFromSources(); } finally { status.cancel(); @@ -548,23 +548,23 @@ class HotRunner extends ResidentRunner { // not be affected, so we resume reporting reload times on the second // reload. final bool shouldReportReloadTime = !_runningFromSnapshot; - final Stopwatch reloadTimer = new Stopwatch()..start(); + final Stopwatch reloadTimer = Stopwatch()..start(); - final Stopwatch devFSTimer = new Stopwatch()..start(); + final Stopwatch devFSTimer = Stopwatch()..start(); final bool updatedDevFS = await _updateDevFS(); // Record time it took to synchronize to DevFS. _addBenchmarkData('hotReloadDevFSSyncMilliseconds', devFSTimer.elapsed.inMilliseconds); if (!updatedDevFS) - return new OperationResult(1, 'DevFS synchronization failed'); + return OperationResult(1, 'DevFS synchronization failed'); String reloadMessage; - final Stopwatch vmReloadTimer = new Stopwatch()..start(); + final Stopwatch vmReloadTimer = Stopwatch()..start(); try { final String entryPath = fs.path.relative( getReloadPath(fullRestart: false), from: projectRootPath, ); - final Completer> retrieveFirstReloadReport = new Completer>(); + final Completer> retrieveFirstReloadReport = Completer>(); int countExpectedReports = 0; for (FlutterDevice device in flutterDevices) { @@ -606,13 +606,13 @@ class HotRunner extends ResidentRunner { if (countExpectedReports == 0) { printError('Unable to hot reload. No instance of Flutter is currently running.'); - return new OperationResult(1, 'No instances running'); + return OperationResult(1, 'No instances running'); } final Map reloadReport = await retrieveFirstReloadReport.future; if (!validateReloadReport(reloadReport)) { // Reload failed. flutterUsage.sendEvent('hot', 'reload-reject'); - return new OperationResult(1, 'Reload rejected'); + return OperationResult(1, 'Reload rejected'); } else { flutterUsage.sendEvent('hot', 'reload'); final int loadedLibraryCount = reloadReport['details']['loadedLibraryCount']; @@ -631,19 +631,19 @@ class HotRunner extends ResidentRunner { 'restart the app.' ); flutterUsage.sendEvent('hot', 'reload-barred'); - return new OperationResult(errorCode, errorMessage); + return OperationResult(errorCode, errorMessage); } printError('Hot reload failed:\ncode = $errorCode\nmessage = $errorMessage\n$st'); - return new OperationResult(errorCode, errorMessage); + return OperationResult(errorCode, errorMessage); } catch (error, st) { printError('Hot reload failed: $error\n$st'); - return new OperationResult(1, '$error'); + return OperationResult(1, '$error'); } // Record time it took for the VM to reload the sources. _addBenchmarkData('hotReloadVMReloadMilliseconds', vmReloadTimer.elapsed.inMilliseconds); - final Stopwatch reassembleTimer = new Stopwatch()..start(); + final Stopwatch reassembleTimer = Stopwatch()..start(); // Reload the isolate. for (FlutterDevice device in flutterDevices) { printTrace('Sending reload events to ${device.device.name}'); @@ -671,7 +671,7 @@ class HotRunner extends ResidentRunner { } if (reassembleViews.isEmpty) { printTrace('Skipping reassemble because all isolates are paused.'); - return new OperationResult(OperationResult.ok.code, reloadMessage); + return OperationResult(OperationResult.ok.code, reloadMessage); } printTrace('Evicting dirty assets'); await _evictDirtyAssets(); @@ -716,7 +716,7 @@ class HotRunner extends ResidentRunner { shouldReportReloadTime) flutterUsage.sendTiming('hot', 'reload', reloadTimer.elapsed); - return new OperationResult( + return OperationResult( reassembleAndScheduleErrors ? 1 : OperationResult.ok.code, reloadMessage, ); diff --git a/packages/flutter_tools/lib/src/runner/flutter_command.dart b/packages/flutter_tools/lib/src/runner/flutter_command.dart index c7fffcdab8..824d46156c 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command.dart @@ -73,7 +73,7 @@ abstract class FlutterCommand extends Command { @override ArgParser get argParser => _argParser; - final ArgParser _argParser = new ArgParser(allowTrailingOptions: false); + final ArgParser _argParser = ArgParser(allowTrailingOptions: false); @override FlutterCommandRunner get runner => super.runner; @@ -192,7 +192,7 @@ abstract class FlutterCommand extends Command { BuildMode getBuildMode() { final List modeFlags = [argResults['debug'], argResults['profile'], argResults['release']]; if (modeFlags.where((bool flag) => flag).length > 1) - throw new UsageException('Only one of --debug, --profile, or --release can be specified.', null); + throw UsageException('Only one of --debug, --profile, or --release can be specified.', null); final bool dynamicFlag = argParser.options.containsKey('dynamic') ? argResults['dynamic'] : false; @@ -231,11 +231,11 @@ abstract class FlutterCommand extends Command { ? int.parse(argResults['build-number']) : null; } catch (e) { - throw new UsageException( + throw UsageException( '--build-number (${argResults['build-number']}) must be an int.', null); } - return new BuildInfo(getBuildMode(), + return BuildInfo(getBuildMode(), argParser.options.containsKey('flavor') ? argResults['flavor'] : null, @@ -265,7 +265,7 @@ abstract class FlutterCommand extends Command { } void setupApplicationPackages() { - applicationPackages ??= new ApplicationPackageStore(); + applicationPackages ??= ApplicationPackageStore(); } /// The path to send to Google Analytics. Return null here to disable @@ -452,7 +452,7 @@ abstract class FlutterCommand extends Command { if (_requiresPubspecYaml && !PackageMap.isUsingCustomPackagesPath) { // Don't expect a pubspec.yaml file if the user passed in an explicit .packages file path. if (!fs.isFileSync('pubspec.yaml')) { - throw new ToolExit( + throw ToolExit( 'Error: No pubspec.yaml file found.\n' 'This command should be run from the root of your Flutter project.\n' 'Do not run this command from the root of your git clone of Flutter.' @@ -460,7 +460,7 @@ abstract class FlutterCommand extends Command { } if (fs.isFileSync('flutter.yaml')) { - throw new ToolExit( + throw ToolExit( 'Please merge your flutter.yaml into your pubspec.yaml.\n\n' 'We have changed from having separate flutter.yaml and pubspec.yaml\n' 'files to having just one pubspec.yaml file. Transitioning is simple:\n' @@ -479,16 +479,16 @@ abstract class FlutterCommand extends Command { // Validate the current package map only if we will not be running "pub get" later. if (parent?.name != 'packages' && !(_usesPubOption && argResults['pub'])) { - final String error = new PackageMap(PackageMap.globalPackagesPath).checkValid(); + final String error = PackageMap(PackageMap.globalPackagesPath).checkValid(); if (error != null) - throw new ToolExit(error); + throw ToolExit(error); } } if (_usesTargetOption) { final String targetPath = targetFile; if (!fs.isFileSync(targetPath)) - throw new ToolExit('Target file "$targetPath" not found.'); + throw ToolExit('Target file "$targetPath" not found.'); } final bool dynamicFlag = argParser.options.containsKey('dynamic') @@ -496,9 +496,9 @@ abstract class FlutterCommand extends Command { final String compilationTraceFilePath = argParser.options.containsKey('precompile') ? argResults['precompile'] : null; if (compilationTraceFilePath != null && getBuildMode() == BuildMode.debug) - throw new ToolExit('Error: --precompile is not allowed when --debug is specified.'); + throw ToolExit('Error: --precompile is not allowed when --debug is specified.'); if (compilationTraceFilePath != null && !dynamicFlag) - throw new ToolExit('Error: --precompile is allowed only when --dynamic is specified.'); + throw ToolExit('Error: --precompile is allowed only when --dynamic is specified.'); } ApplicationPackageStore applicationPackages; diff --git a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart index 454fac9843..b0ef55bb59 100644 --- a/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart +++ b/packages/flutter_tools/lib/src/runner/flutter_command_runner.dart @@ -146,7 +146,7 @@ class FlutterCommandRunner extends CommandRunner { @override ArgParser get argParser => _argParser; - final ArgParser _argParser = new ArgParser(allowTrailingOptions: false); + final ArgParser _argParser = ArgParser(allowTrailingOptions: false); @override String get usageFooter { @@ -214,13 +214,13 @@ class FlutterCommandRunner extends CommandRunner { @override Future runCommand(ArgResults topLevelResults) async { final Map contextOverrides = { - Flags: new Flags(topLevelResults), + Flags: Flags(topLevelResults), }; // Check for verbose. if (topLevelResults['verbose']) { // Override the logger. - contextOverrides[Logger] = new VerboseLogger(logger); + contextOverrides[Logger] = VerboseLogger(logger); } if (topLevelResults['show-test-device'] || @@ -240,7 +240,7 @@ class FlutterCommandRunner extends CommandRunner { // Record the arguments that were used to invoke this runner. final File manifest = tempDir.childFile('MANIFEST.txt'); - final StringBuffer buffer = new StringBuffer() + final StringBuffer buffer = StringBuffer() ..writeln('# arguments') ..writeln(topLevelResults.arguments) ..writeln() @@ -302,7 +302,7 @@ class FlutterCommandRunner extends CommandRunner { await context.run( overrides: contextOverrides.map((Type type, dynamic value) { - return new MapEntry(type, () => value); + return MapEntry(type, () => value); }), body: () async { logger.quiet = topLevelResults['quiet']; @@ -360,7 +360,7 @@ class FlutterCommandRunner extends CommandRunner { if (engineSourcePath == null && globalResults['local-engine'] != null) { try { - final Uri engineUri = new PackageMap(PackageMap.globalPackagesPath).map[kFlutterEnginePackageName]; + final Uri engineUri = PackageMap(PackageMap.globalPackagesPath).map[kFlutterEnginePackageName]; if (engineUri != null) { engineSourcePath = fs.path.dirname(fs.path.dirname(fs.path.dirname(fs.path.dirname(engineUri.path)))); final bool dirExists = fs.isDirectorySync(fs.path.join(engineSourcePath, 'out')); @@ -414,7 +414,7 @@ class FlutterCommandRunner extends CommandRunner { final String hostBasename = 'host_' + basename.replaceFirst('_sim_', '_').substring(basename.indexOf('_') + 1); final String engineHostBuildPath = fs.path.normalize(fs.path.join(fs.path.dirname(engineBuildPath), hostBasename)); - return new EngineBuildPaths(targetEngine: engineBuildPath, hostEngine: engineHostBuildPath); + return EngineBuildPaths(targetEngine: engineBuildPath, hostEngine: engineHostBuildPath); } static void initFlutterRoot() { @@ -485,7 +485,7 @@ class FlutterCommandRunner extends CommandRunner { // Check that the flutter running is that same as the one referenced in the pubspec. if (fs.isFileSync(kPackagesFileName)) { - final PackageMap packageMap = new PackageMap(kPackagesFileName); + final PackageMap packageMap = PackageMap(kPackagesFileName); final Uri flutterUri = packageMap.map['flutter']; if (flutterUri != null && (flutterUri.scheme == 'file' || flutterUri.scheme == '')) { diff --git a/packages/flutter_tools/lib/src/services.dart b/packages/flutter_tools/lib/src/services.dart index 5668efc602..2edceb70de 100644 --- a/packages/flutter_tools/lib/src/services.dart +++ b/packages/flutter_tools/lib/src/services.dart @@ -30,7 +30,7 @@ Future parseServiceConfigs( ) async { Map packageMap; try { - packageMap = new PackageMap(PackageMap.globalPackagesPath).map; + packageMap = PackageMap(PackageMap.globalPackagesPath).map; } on FormatException catch (error) { printTrace('Invalid ".packages" file while parsing service configs:\n$error'); return; diff --git a/packages/flutter_tools/lib/src/template.dart b/packages/flutter_tools/lib/src/template.dart index ab998586af..97bc18b63b 100644 --- a/packages/flutter_tools/lib/src/template.dart +++ b/packages/flutter_tools/lib/src/template.dart @@ -53,12 +53,12 @@ class Template { factory Template.fromName(String name) { // All named templates are placed in the 'templates' directory final Directory templateDir = templateDirectoryInPackage(name); - return new Template(templateDir, templateDir); + return Template(templateDir, templateDir); } static const String templateExtension = '.tmpl'; static const String copyTemplateExtension = '.copy.tmpl'; - final Pattern _kTemplateLanguageVariant = new RegExp(r'(\w+)-(\w+)\.tmpl.*'); + final Pattern _kTemplateLanguageVariant = RegExp(r'(\w+)-(\w+)\.tmpl.*'); Map _templateFilePaths; @@ -154,7 +154,7 @@ class Template { if (sourceFile.path.endsWith(templateExtension)) { final String templateContents = sourceFile.readAsStringSync(); - final String renderedContents = new mustache.Template(templateContents).renderString(context); + final String renderedContents = mustache.Template(templateContents).renderString(context); finalDestinationFile.writeAsStringSync(renderedContents); diff --git a/packages/flutter_tools/lib/src/test/coverage_collector.dart b/packages/flutter_tools/lib/src/test/coverage_collector.dart index a86b2555fe..8d16526f94 100644 --- a/packages/flutter_tools/lib/src/test/coverage_collector.dart +++ b/packages/flutter_tools/lib/src/test/coverage_collector.dart @@ -50,18 +50,18 @@ class CoverageCollector extends TestWatcher { Map data; final Future processComplete = process.exitCode .then((int code) { - throw new Exception('Failed to collect coverage, process terminated prematurely with exit code $code.'); + throw Exception('Failed to collect coverage, process terminated prematurely with exit code $code.'); }); final Future collectionComplete = coverage.collect(observatoryUri, false, false) .then((Map result) { if (result == null) - throw new Exception('Failed to collect coverage.'); + throw Exception('Failed to collect coverage.'); data = result; }) .timeout( const Duration(minutes: 10), onTimeout: () { - throw new Exception('Timed out while collecting coverage.'); + throw Exception('Timed out while collecting coverage.'); }, ); await Future.any(>[ processComplete, collectionComplete ]); @@ -88,10 +88,10 @@ class CoverageCollector extends TestWatcher { if (_globalHitmap == null) return null; if (formatter == null) { - final coverage.Resolver resolver = new coverage.Resolver(packagesPath: PackageMap.globalPackagesPath); + final coverage.Resolver resolver = coverage.Resolver(packagesPath: PackageMap.globalPackagesPath); final String packagePath = fs.currentDirectory.path; final List reportOn = [fs.path.join(packagePath, 'lib')]; - formatter = new coverage.LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath); + formatter = coverage.LcovFormatter(resolver, reportOn: reportOn, basePath: packagePath); } final String result = await formatter.format(_globalHitmap); _globalHitmap = null; diff --git a/packages/flutter_tools/lib/src/test/flutter_platform.dart b/packages/flutter_tools/lib/src/test/flutter_platform.dart index 9538df9c87..7e171d5b3d 100644 --- a/packages/flutter_tools/lib/src/test/flutter_platform.dart +++ b/packages/flutter_tools/lib/src/test/flutter_platform.dart @@ -80,7 +80,7 @@ void installHook({ assert(!enableObservatory || (!startPaused && observatoryPort == null)); hack.registerPlatformPlugin( [Runtime.vm], - () => new _FlutterPlatform( + () => _FlutterPlatform( shellPath: shellPath, watcher: watcher, machine: machine, @@ -128,7 +128,7 @@ String generateTestBootstrap({ : 'ws://[${host.address}]'; final String encodedWebsocketUrl = Uri.encodeComponent(websocketUrl); - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.write(''' import 'dart:convert'; import 'dart:io'; // ignore: dart_io_import @@ -147,7 +147,7 @@ import '$testUrl' as test; ); if (testConfigFile != null) { buffer.write(''' -import '${new Uri.file(testConfigFile.path)}' as test_config; +import '${Uri.file(testConfigFile.path)}' as test_config; ''' ); } @@ -229,7 +229,7 @@ class _Compiler { final String testFilePath = fs.path.join(fs.path.fromUri(projectRootDirectory), getBuildDirectory(), 'testfile.dill'); ResidentCompiler createCompiler() { - return new ResidentCompiler( + return ResidentCompiler( artifacts.getArtifactPath(Artifact.flutterPatchedSdkPath), packagesPath: PackageMap.globalPackagesPath, trackWidgetCreation: trackWidgetCreation, @@ -249,7 +249,7 @@ class _Compiler { while (compilationQueue.isNotEmpty) { final _CompilationRequest request = compilationQueue.first; printTrace('Compiling ${request.path}'); - final Stopwatch compilerTime = new Stopwatch()..start(); + final Stopwatch compilerTime = Stopwatch()..start(); bool firstCompile = false; if (compiler == null) { compiler = createCompiler(); @@ -298,13 +298,13 @@ class _Compiler { } final StreamController<_CompilationRequest> compilerController = - new StreamController<_CompilationRequest>(); + StreamController<_CompilationRequest>(); final List<_CompilationRequest> compilationQueue = <_CompilationRequest>[]; ResidentCompiler compiler; Future compile(String mainDart) { - final Completer completer = new Completer(); - compilerController.add(new _CompilationRequest(mainDart, completer)); + final Completer completer = Completer(); + compilerController.add(_CompilationRequest(mainDart, completer)); return handleTimeout(completer.future, mainDart); } @@ -385,18 +385,18 @@ class _FlutterPlatform extends PlatformPlugin { } final int ourTestCount = _testCount; _testCount += 1; - final StreamController localController = new StreamController(); - final StreamController remoteController = new StreamController(); - final Completer<_AsyncError> testCompleteCompleter = new Completer<_AsyncError>(); - final _FlutterPlatformStreamSinkWrapper remoteSink = new _FlutterPlatformStreamSinkWrapper( + final StreamController localController = StreamController(); + final StreamController remoteController = StreamController(); + final Completer<_AsyncError> testCompleteCompleter = Completer<_AsyncError>(); + final _FlutterPlatformStreamSinkWrapper remoteSink = _FlutterPlatformStreamSinkWrapper( remoteController.sink, testCompleteCompleter.future, ); - final StreamChannel localChannel = new StreamChannel.withGuarantees( + final StreamChannel localChannel = StreamChannel.withGuarantees( remoteController.stream, localController.sink, ); - final StreamChannel remoteChannel = new StreamChannel.withGuarantees( + final StreamChannel remoteChannel = StreamChannel.withGuarantees( localController.stream, remoteSink, ); @@ -426,7 +426,7 @@ class _FlutterPlatform extends PlatformPlugin { printTrace('test $ourTestCount: shutting down test harness socket server'); await server.close(force: true); }); - final Completer webSocket = new Completer(); + final Completer webSocket = Completer(); server.listen( (HttpRequest request) { if (!webSocket.isCompleted) @@ -460,7 +460,7 @@ class _FlutterPlatform extends PlatformPlugin { if (precompiledDillPath == null && precompiledDillFiles == null) { // Lazily instantiate compiler so it is built only if it is actually used. - compiler ??= new _Compiler(trackWidgetCreation, projectRootDirectory); + compiler ??= _Compiler(trackWidgetCreation, projectRootDirectory); mainDart = await compiler.compile(mainDart); if (mainDart == null) { @@ -495,8 +495,8 @@ class _FlutterPlatform extends PlatformPlugin { } }); - final Completer timeout = new Completer(); - final Completer gotProcessObservatoryUri = new Completer(); + final Completer timeout = Completer(); + final Completer gotProcessObservatoryUri = Completer(); if (!enableObservatory) gotProcessObservatoryUri.complete(); @@ -519,10 +519,10 @@ class _FlutterPlatform extends PlatformPlugin { } processObservatoryUri = detectedUri; gotProcessObservatoryUri.complete(); - watcher?.handleStartedProcess(new ProcessEvent(ourTestCount, process, processObservatoryUri)); + watcher?.handleStartedProcess(ProcessEvent(ourTestCount, process, processObservatoryUri)); }, startTimeoutTimer: () { - new Future<_InitialResult>.delayed(_kTestStartupTimeout).then((_) => timeout.complete()); + Future<_InitialResult>.delayed(_kTestStartupTimeout).then((_) => timeout.complete()); }, ); @@ -535,7 +535,7 @@ class _FlutterPlatform extends PlatformPlugin { final _InitialResult initialResult = await Future.any(>[ process.exitCode.then<_InitialResult>((int exitCode) => _InitialResult.crashed), timeout.future.then<_InitialResult>((void value) => _InitialResult.timedOut), - new Future<_InitialResult>.delayed(_kTestProcessTimeout, () => _InitialResult.timedOut), + Future<_InitialResult>.delayed(_kTestProcessTimeout, () => _InitialResult.timedOut), gotProcessObservatoryUri.future.then<_InitialResult>((void value) { return webSocket.future.then<_InitialResult>( (WebSocket webSocket) => _InitialResult.connected, @@ -554,7 +554,7 @@ class _FlutterPlatform extends PlatformPlugin { controller.sink.close(); // ignore: unawaited_futures printTrace('test $ourTestCount: waiting for controller sink to close'); await controller.sink.done; - await watcher?.handleTestCrashed(new ProcessEvent(ourTestCount, process)); + await watcher?.handleTestCrashed(ProcessEvent(ourTestCount, process)); break; case _InitialResult.timedOut: // Could happen either if the process takes a long time starting @@ -567,13 +567,13 @@ class _FlutterPlatform extends PlatformPlugin { controller.sink.close(); // ignore: unawaited_futures printTrace('test $ourTestCount: waiting for controller sink to close'); await controller.sink.done; - await watcher?.handleTestTimedOut(new ProcessEvent(ourTestCount, process)); + await watcher?.handleTestTimedOut(ProcessEvent(ourTestCount, process)); break; case _InitialResult.connected: printTrace('test $ourTestCount: process with pid ${process.pid} connected to test harness'); final WebSocket testSocket = await webSocket.future; - final Completer harnessDone = new Completer(); + final Completer harnessDone = Completer(); final StreamSubscription harnessToTest = controller.stream.listen( (dynamic event) { testSocket.add(json.encode(event)); }, onDone: harnessDone.complete, @@ -590,7 +590,7 @@ class _FlutterPlatform extends PlatformPlugin { cancelOnError: true, ); - final Completer testDone = new Completer(); + final Completer testDone = Completer(); final StreamSubscription testToHarness = testSocket.listen( (dynamic encodedEvent) { assert(encodedEvent is String); // we shouldn't ever get binary messages @@ -642,7 +642,7 @@ class _FlutterPlatform extends PlatformPlugin { assert(testResult == _TestResult.testBailed); printTrace('test $ourTestCount: process with pid ${process.pid} no longer needs test harness'); } - await watcher?.handleFinishedTest(new ProcessEvent(ourTestCount, process, processObservatoryUri)); + await watcher?.handleFinishedTest(ProcessEvent(ourTestCount, process, processObservatoryUri)); break; } break; @@ -653,7 +653,7 @@ class _FlutterPlatform extends PlatformPlugin { controller.sink.addError(error, stack); } else { printError('unhandled error during test:\n$testPath\n$error\n$stack'); - outOfBandError ??= new _AsyncError(error, stack); + outOfBandError ??= _AsyncError(error, stack); } } finally { printTrace('test $ourTestCount: cleaning up...'); @@ -667,7 +667,7 @@ class _FlutterPlatform extends PlatformPlugin { controller.sink.addError(error, stack); } else { printError('unhandled error during finalization of test:\n$testPath\n$error\n$stack'); - outOfBandError ??= new _AsyncError(error, stack); + outOfBandError ??= _AsyncError(error, stack); } } } @@ -787,7 +787,7 @@ class _FlutterPlatform extends PlatformPlugin { if (_cachedFontConfig != null) return _cachedFontConfig; - final StringBuffer sb = new StringBuffer(); + final StringBuffer sb = StringBuffer(); sb.writeln(''); sb.writeln(' ${cache.getCacheArtifacts().path}'); sb.writeln(' /var/cache/fontconfig'); @@ -942,7 +942,7 @@ class _FlutterPlatformStreamSinkWrapper implements StreamSink { @override Future get done => _done.future; - final Completer _done = new Completer(); + final Completer _done = Completer(); @override Future close() { diff --git a/packages/flutter_tools/lib/src/tester/flutter_tester.dart b/packages/flutter_tools/lib/src/tester/flutter_tester.dart index adf2905b59..2487d63fb2 100644 --- a/packages/flutter_tools/lib/src/tester/flutter_tester.dart +++ b/packages/flutter_tools/lib/src/tester/flutter_tester.dart @@ -25,7 +25,7 @@ class FlutterTesterApp extends ApplicationPackage { final Directory _directory; factory FlutterTesterApp.fromCurrentDirectory() { - return new FlutterTesterApp._(fs.currentDirectory); + return FlutterTesterApp._(fs.currentDirectory); } FlutterTesterApp._(Directory directory) @@ -44,7 +44,7 @@ class FlutterTesterDevice extends Device { FlutterTesterDevice(String deviceId) : super(deviceId); Process _process; - final DevicePortForwarder _portForwarder = new _NoopPortForwarder(); + final DevicePortForwarder _portForwarder = _NoopPortForwarder(); @override Future get isLocalEmulator async => false; @@ -68,7 +68,7 @@ class FlutterTesterDevice extends Device { void clearLogs() {} final _FlutterTesterDeviceLogReader _logReader = - new _FlutterTesterDeviceLogReader(); + _FlutterTesterDeviceLogReader(); @override DeviceLogReader getLogReader({ApplicationPackage app}) => _logReader; @@ -104,7 +104,7 @@ class FlutterTesterDevice extends Device { if (!buildInfo.isDebug) { printError('This device only supports debug mode.'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } final String shellPath = artifacts.getArtifactPath(Artifact.flutterTester); @@ -168,18 +168,18 @@ class FlutterTesterDevice extends Device { }); if (!debuggingOptions.debuggingEnabled) - return new LaunchResult.succeeded(); + return LaunchResult.succeeded(); - final ProtocolDiscovery observatoryDiscovery = new ProtocolDiscovery.observatory( + final ProtocolDiscovery observatoryDiscovery = ProtocolDiscovery.observatory( getLogReader(), hostPort: debuggingOptions.observatoryPort, ); final Uri observatoryUri = await observatoryDiscovery.uri; - return new LaunchResult.succeeded(observatoryUri: observatoryUri); + return LaunchResult.succeeded(observatoryUri: observatoryUri); } catch (error) { printError('Failed to launch $package: $error'); - return new LaunchResult.failed(); + return LaunchResult.failed(); } } @@ -202,7 +202,7 @@ class FlutterTesterDevices extends PollingDeviceDiscovery { static bool showFlutterTesterDevice = false; final FlutterTesterDevice _testerDevice = - new FlutterTesterDevice(kTesterDeviceId); + FlutterTesterDevice(kTesterDeviceId); @override bool get canListAnything => true; @@ -218,7 +218,7 @@ class FlutterTesterDevices extends PollingDeviceDiscovery { class _FlutterTesterDeviceLogReader extends DeviceLogReader { final StreamController _logLinesController = - new StreamController.broadcast(); + StreamController.broadcast(); @override int get appPid => 0; @@ -239,7 +239,7 @@ class _NoopPortForwarder extends DevicePortForwarder { Future forward(int devicePort, {int hostPort}) { if (hostPort != null && hostPort != devicePort) throw 'Forwarding to a different port is not supported by flutter tester'; - return new Future.value(devicePort); + return Future.value(devicePort); } @override diff --git a/packages/flutter_tools/lib/src/tracing.dart b/packages/flutter_tools/lib/src/tracing.dart index 132cf0af14..0a72a48cae 100644 --- a/packages/flutter_tools/lib/src/tracing.dart +++ b/packages/flutter_tools/lib/src/tracing.dart @@ -20,7 +20,7 @@ class Tracing { static Future connect(Uri uri) async { final VMService observatory = await VMService.connect(uri); - return new Tracing(observatory); + return Tracing(observatory); } final VMService vmService; @@ -41,7 +41,7 @@ class Tracing { await vmService.vm.setVMTimelineFlags([]); timeline = await vmService.vm.getVMTimeline(); } else { - final Completer whenFirstFrameRendered = new Completer(); + final Completer whenFirstFrameRendered = Completer(); (await vmService.onTimelineEvent).listen((ServiceEvent timelineEvent) { final List> events = timelineEvent.timelineEvents; @@ -86,7 +86,7 @@ Future downloadStartupTrace(VMService observatory) async { if (!(await traceInfoFile.parent.exists())) await traceInfoFile.parent.create(); - final Tracing tracing = new Tracing(observatory); + final Tracing tracing = Tracing(observatory); final Map timeline = await tracing.stopTracingAndDownloadTimeline( waitForFirstFrame: true @@ -94,7 +94,7 @@ Future downloadStartupTrace(VMService observatory) async { int extractInstantEventTimestamp(String eventName) { final List> events = - new List>.from(timeline['traceEvents']); + List>.from(timeline['traceEvents']); final Map event = events.firstWhere( (Map event) => event['name'] == eventName, orElse: () => null ); diff --git a/packages/flutter_tools/lib/src/usage.dart b/packages/flutter_tools/lib/src/usage.dart index 06b2d4bdf4..a49553d03a 100644 --- a/packages/flutter_tools/lib/src/usage.dart +++ b/packages/flutter_tools/lib/src/usage.dart @@ -25,7 +25,7 @@ class Usage { Usage({ String settingsName = 'flutter', String versionOverride, String configDirOverride}) { final FlutterVersion flutterVersion = FlutterVersion.instance; final String version = versionOverride ?? flutterVersion.getVersionString(redactUnknownBranches: true); - _analytics = new AnalyticsIO(_kFlutterUA, settingsName, version, + _analytics = AnalyticsIO(_kFlutterUA, settingsName, version, // Analyzer doesn't recognize that [Directory] objects match up due to a // conditional import. // ignore: argument_type_not_assignable diff --git a/packages/flutter_tools/lib/src/version.dart b/packages/flutter_tools/lib/src/version.dart index 728d446e77..e1dea0e1ab 100644 --- a/packages/flutter_tools/lib/src/version.dart +++ b/packages/flutter_tools/lib/src/version.dart @@ -43,7 +43,7 @@ class FlutterVersion { String _repositoryUrl; String get repositoryUrl => _repositoryUrl; - static Set officialChannels = new Set.from([ + static Set officialChannels = Set.from([ 'master', 'dev', 'beta', @@ -292,7 +292,7 @@ class FlutterVersion { stamp.store( newTimeWarningWasPrinted: _clock.now(), ), - new Future.delayed(timeToPauseToLetUserReadTheMessage), + Future.delayed(timeToPauseToLetUserReadTheMessage), ]); } } @@ -411,7 +411,7 @@ class VersionCheckStamp { : null; } - return new VersionCheckStamp( + return VersionCheckStamp( lastTimeVersionWasChecked: readDateTime('lastTimeVersionWasChecked'), lastKnownRemoteVersion: readDateTime('lastKnownRemoteVersion'), lastTimeWarningWasPrinted: readDateTime('lastTimeWarningWasPrinted'), @@ -488,7 +488,7 @@ String _runSync(List command, {bool lenient = true}) { return results.stdout.trim(); if (!lenient) { - throw new VersionCheckError( + throw VersionCheckError( 'Command exited with code ${results.exitCode}: ${command.join(' ')}\n' 'Standard error: ${results.stderr}' ); @@ -511,7 +511,7 @@ Future _run(List command) async { if (results.exitCode == 0) return results.stdout.trim(); - throw new VersionCheckError( + throw VersionCheckError( 'Command exited with code ${results.exitCode}: ${command.join(' ')}\n' 'Standard error: ${results.stderr}' ); @@ -544,14 +544,14 @@ class GitTagVersion { static GitTagVersion determine() { final String version = _runGit('git describe --match v*.*.* --first-parent --long --tags'); - final RegExp versionPattern = new RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$'); + final RegExp versionPattern = RegExp('^v([0-9]+)\.([0-9]+)\.([0-9]+)-([0-9]+)-g([a-f0-9]+)\$'); final List parts = versionPattern.matchAsPrefix(version)?.groups([1, 2, 3, 4, 5]); if (parts == null) { printTrace('Could not interpret results of "git describe": $version'); return const GitTagVersion.unknown(); } final List parsedParts = parts.take(4).map(int.tryParse).toList(); - return new GitTagVersion(parsedParts[0], parsedParts[1], parsedParts[2], parsedParts[3], parts[4]); + return GitTagVersion(parsedParts[0], parsedParts[1], parsedParts[2], parsedParts[3], parts[4]); } String frameworkVersionFor(String revision) { diff --git a/packages/flutter_tools/lib/src/vmservice.dart b/packages/flutter_tools/lib/src/vmservice.dart index 51bc7fae68..a99c278738 100644 --- a/packages/flutter_tools/lib/src/vmservice.dart +++ b/packages/flutter_tools/lib/src/vmservice.dart @@ -66,7 +66,7 @@ Future> _defaultOpenChannel(Uri uri) async { printTrace('This was attempt #$attempts. Will retry in $delay.'); // Delay next attempt. - await new Future.delayed(delay); + await Future.delayed(delay); // Back off exponentially. delay *= 2; @@ -84,13 +84,13 @@ Future> _defaultOpenChannel(Uri uri) async { } if (socket == null) { - throw new ToolExit( + throw ToolExit( 'Attempted to connect to Dart observatory $_kMaxAttempts times, and ' 'all attempts failed. Giving up. The URL was $uri' ); } - return new IOWebSocketChannel(socket).cast(); + return IOWebSocketChannel(socket).cast(); } /// The default VM service request timeout. @@ -112,7 +112,7 @@ class VMService { ReloadSources reloadSources, CompileExpression compileExpression, ) { - _vm = new VM._empty(this); + _vm = VM._empty(this); _peer.listen().catchError(_connectionError.completeError); _peer.registerMethod('streamNotify', (rpc.Parameters event) { @@ -126,11 +126,11 @@ class VMService { final bool pause = params.asMap['pause'] ?? false; if (isolateId is! String || isolateId.isEmpty) - throw new rpc.RpcException.invalidParams('Invalid \'isolateId\': $isolateId'); + throw rpc.RpcException.invalidParams('Invalid \'isolateId\': $isolateId'); if (force is! bool) - throw new rpc.RpcException.invalidParams('Invalid \'force\': $force'); + throw rpc.RpcException.invalidParams('Invalid \'force\': $force'); if (pause is! bool) - throw new rpc.RpcException.invalidParams('Invalid \'pause\': $pause'); + throw rpc.RpcException.invalidParams('Invalid \'pause\': $pause'); try { await reloadSources(isolateId, force: force, pause: pause); @@ -138,7 +138,7 @@ class VMService { } on rpc.RpcException { rethrow; } catch (e, st) { - throw new rpc.RpcException(rpc_error_code.SERVER_ERROR, + throw rpc.RpcException(rpc_error_code.SERVER_ERROR, 'Error during Sources Reload: $e\n$st'); } }); @@ -155,16 +155,16 @@ class VMService { _peer.registerMethod('compileExpression', (rpc.Parameters params) async { final String isolateId = params['isolateId'].asString; if (isolateId is! String || isolateId.isEmpty) - throw new rpc.RpcException.invalidParams( + throw rpc.RpcException.invalidParams( 'Invalid \'isolateId\': $isolateId'); final String expression = params['expression'].asString; if (expression is! String || expression.isEmpty) - throw new rpc.RpcException.invalidParams( + throw rpc.RpcException.invalidParams( 'Invalid \'expression\': $expression'); final List definitions = - new List.from(params['definitions'].asList); + List.from(params['definitions'].asList); final List typeDefinitions = - new List.from(params['typeDefinitions'].asList); + List.from(params['typeDefinitions'].asList); final String libraryUri = params['libraryUri'].asString; final String klass = params['klass'].exists ? params['klass'].asString : null; final bool isStatic = params['isStatic'].asBoolOr(false); @@ -178,7 +178,7 @@ class VMService { } on rpc.RpcException { rethrow; } catch (e, st) { - throw new rpc.RpcException(rpc_error_code.SERVER_ERROR, + throw rpc.RpcException(rpc_error_code.SERVER_ERROR, 'Error during expression compilation: $e\n$st'); } }); @@ -201,7 +201,7 @@ class VMService { final Directory dir = getRecordingSink(location, _kRecordingType); _openChannel = (Uri uri) async { final StreamChannel delegate = await _defaultOpenChannel(uri); - return new RecordingVMServiceChannel(delegate, dir); + return RecordingVMServiceChannel(delegate, dir); }; } @@ -212,7 +212,7 @@ class VMService { /// passed to [enableRecordingConnection]), or a [ToolExit] will be thrown. static void enableReplayConnection(String location) { final Directory dir = getReplaySource(location, _kRecordingType); - _openChannel = (Uri uri) async => new ReplayVMServiceChannel(dir); + _openChannel = (Uri uri) async => ReplayVMServiceChannel(dir); } /// Connect to a Dart VM Service at [httpUri]. @@ -234,8 +234,8 @@ class VMService { }) async { final Uri wsUri = httpUri.replace(scheme: 'ws', path: fs.path.join(httpUri.path, 'ws')); final StreamChannel channel = await _openChannel(wsUri); - final rpc.Peer peer = new rpc.Peer.withoutJson(jsonDocument.bind(channel)); - final VMService service = new VMService._(peer, httpUri, wsUri, requestTimeout, reloadSources, compileExpression); + final rpc.Peer peer = rpc.Peer.withoutJson(jsonDocument.bind(channel)); + final VMService service = VMService._(peer, httpUri, wsUri, requestTimeout, reloadSources, compileExpression); // This call is to ensure we are able to establish a connection instead of // keeping on trucking and failing farther down the process. await service._sendRequest('getVersion', const {}); @@ -246,7 +246,7 @@ class VMService { final Uri wsAddress; final rpc.Peer _peer; final Duration _requestTimeout; - final Completer> _connectionError = new Completer>(); + final Completer> _connectionError = Completer>(); VM _vm; /// The singleton [VM] object. Owns [Isolate] and [FlutterView] objects. @@ -255,7 +255,7 @@ class VMService { final Map> _eventControllers = >{}; - final Set _listeningFor = new Set(); + final Set _listeningFor = Set(); /// Whether our connection to the VM service has been closed; bool get isClosed => _peer.isClosed; @@ -298,7 +298,7 @@ class VMService { StreamController _getEventController(String eventName) { StreamController controller = _eventControllers[eventName]; if (controller == null) { - controller = new StreamController.broadcast(); + controller = StreamController.broadcast(); _eventControllers[eventName] = controller; } return controller; @@ -316,7 +316,7 @@ class VMService { if (eventIsolate != null) { // getFromMap creates the Isolate if necessary. final Isolate isolate = vm.getFromMap(eventIsolate); - event = new ServiceObject._fromMap(isolate, eventData); + event = ServiceObject._fromMap(isolate, eventData); if (event.kind == ServiceEvent.kIsolateExit) { vm._isolateCache.remove(isolate.id); vm._buildIsolateList(); @@ -327,7 +327,7 @@ class VMService { } } else { // The event doesn't have an isolate, so it is owned by the VM. - event = new ServiceObject._fromMap(vm, eventData); + event = ServiceObject._fromMap(vm, eventData); } _getEventController(streamId).add(event); } @@ -351,7 +351,7 @@ class VMService { for (int i = 0; (vm.firstView == null) && (i < attempts); i++) { // If the VM doesn't yet have a view, wait for one to show up. printTrace('Waiting for Flutter view'); - await new Future.delayed(new Duration(seconds: attemptSeconds)); + await Future.delayed(Duration(seconds: attemptSeconds)); await getVM(); await vm.refreshViews(); } @@ -425,25 +425,25 @@ abstract class ServiceObject { return null; if (!_isServiceMap(map)) - throw new VMServiceObjectLoadError('Expected a service map', map); + throw VMServiceObjectLoadError('Expected a service map', map); final String type = _stripRef(map['type']); ServiceObject serviceObject; switch (type) { case 'Event': - serviceObject = new ServiceEvent._empty(owner); + serviceObject = ServiceEvent._empty(owner); break; case 'FlutterView': - serviceObject = new FlutterView._empty(owner.vm); + serviceObject = FlutterView._empty(owner.vm); break; case 'Isolate': - serviceObject = new Isolate._empty(owner.vm); + serviceObject = Isolate._empty(owner.vm); break; } // If we don't have a model object for this service object type, as a // fallback return a ServiceMap object. - serviceObject ??= new ServiceMap._empty(owner); + serviceObject ??= ServiceMap._empty(owner); // We have now constructed an empty service object, call update to populate it. serviceObject.updateFromMap(map); return serviceObject; @@ -511,14 +511,14 @@ abstract class ServiceObject { } if (_inProgressReload == null) { - final Completer completer = new Completer(); + final Completer completer = Completer(); _inProgressReload = completer.future; try { final Map response = await _fetchDirect(); if (_stripRef(response['type']) == 'Sentinel') { // An object may have been collected. - completer.complete(new ServiceObject._fromMap(owner, response)); + completer.complete(ServiceObject._fromMap(owner, response)); } else { updateFromMap(response); completer.complete(this); @@ -540,7 +540,7 @@ abstract class ServiceObject { final String mapType = _stripRef(map['type']); if ((_type != null) && (_type != mapType)) { - throw new VMServiceObjectLoadError('ServiceObject types must not change', + throw VMServiceObjectLoadError('ServiceObject types must not change', map); } _type = mapType; @@ -548,7 +548,7 @@ abstract class ServiceObject { _canCache = map['fixedId'] == true; if ((_id != null) && (_id != map['id']) && _canCache) { - throw new VMServiceObjectLoadError('ServiceObject id changed', map); + throw VMServiceObjectLoadError('ServiceObject id changed', map); } _id = map['id']; @@ -614,7 +614,7 @@ class ServiceEvent extends ServiceObject { _kind = map['kind']; assert(map['isolate'] == null || owner == map['isolate']); _timestamp = - new DateTime.fromMillisecondsSinceEpoch(map['timestamp']); + DateTime.fromMillisecondsSinceEpoch(map['timestamp']); if (map['extensionKind'] != null) { _extensionKind = map['extensionKind']; _extensionData = map['extensionData']; @@ -747,7 +747,7 @@ class VM extends ServiceObjectOwner { void _removeDeadIsolates(List newIsolates) { // Build a set of new isolates. - final Set newIsolateSet = new Set(); + final Set newIsolateSet = Set(); for (Isolate iso in newIsolates) newIsolateSet.add(iso.id); @@ -782,7 +782,7 @@ class VM extends ServiceObjectOwner { Isolate isolate = _isolateCache[mapId]; if (isolate == null) { // Add new isolate to the cache. - isolate = new ServiceObject._fromMap(this, map); + isolate = ServiceObject._fromMap(this, map); _isolateCache[mapId] = isolate; _buildIsolateList(); @@ -801,7 +801,7 @@ class VM extends ServiceObjectOwner { FlutterView view = _viewCache[mapId]; if (view == null) { // Add new view to the cache. - view = new ServiceObject._fromMap(this, map); + view = ServiceObject._fromMap(this, map); _viewCache[mapId] = view; } else { view.updateFromMap(map); @@ -810,7 +810,7 @@ class VM extends ServiceObjectOwner { } break; default: - throw new VMServiceObjectLoadError( + throw VMServiceObjectLoadError( 'VM.getFromMap called for something other than an isolate', map); } } @@ -821,7 +821,7 @@ class VM extends ServiceObjectOwner { // Trigger a VM load, then get the isolate. Ignore any errors. return load().then((ServiceObject serviceObject) => getIsolate(isolateId)).catchError((dynamic error) => null); } - return new Future.value(_isolateCache[isolateId]); + return Future.value(_isolateCache[isolateId]); } /// Invoke the RPC and return the raw response. @@ -845,7 +845,7 @@ class VM extends ServiceObjectOwner { } on TimeoutException { printTrace('Request to Dart VM Service timed out: $method($params)'); if (timeoutFatal) - throw new TimeoutException('Request to Dart VM Service timed out: $method($params)'); + throw TimeoutException('Request to Dart VM Service timed out: $method($params)'); return null; } on WebSocketChannelException catch (error) { throwToolExit('Error connecting to observatory: $error'); @@ -867,7 +867,7 @@ class VM extends ServiceObjectOwner { params: params, timeout: timeout, ); - final ServiceObject serviceObject = new ServiceObject._fromMap(this, response); + final ServiceObject serviceObject = ServiceObject._fromMap(this, response); if ((serviceObject != null) && (serviceObject._canCache)) { final String serviceObjectId = serviceObject.id; _cache.putIfAbsent(serviceObjectId, () => serviceObject); @@ -1000,13 +1000,13 @@ class HeapSpace extends ServiceObject { final double mcs = _totalCollectionTimeInSeconds * Duration.microsecondsPerSecond / math.max(_collections, 1); - return new Duration(microseconds: mcs.ceil()); + return Duration(microseconds: mcs.ceil()); } Duration get avgCollectionPeriod { final double mcs = _averageCollectionPeriodInMillis * Duration.microsecondsPerMillisecond; - return new Duration(microseconds: mcs.ceil()); + return Duration(microseconds: mcs.ceil()); } @override @@ -1083,7 +1083,7 @@ class Isolate extends ServiceObjectOwner { return serviceObject; } // Build the object from the map directly. - serviceObject = new ServiceObject._fromMap(this, map); + serviceObject = ServiceObject._fromMap(this, map); if ((serviceObject != null) && serviceObject.canCache) _cache[mapId] = serviceObject; return serviceObject; @@ -1117,9 +1117,9 @@ class Isolate extends ServiceObjectOwner { } void _updateHeaps(Map map, bool mapIsRef) { - _newSpace ??= new HeapSpace._empty(this); + _newSpace ??= HeapSpace._empty(this); _newSpace._update(map['new'], mapIsRef); - _oldSpace ??= new HeapSpace._empty(this); + _oldSpace ??= HeapSpace._empty(this); _oldSpace._update(map['old'], mapIsRef); } @@ -1130,7 +1130,7 @@ class Isolate extends ServiceObjectOwner { _loaded = true; final int startTimeMillis = map['startTime']; - startTime = new DateTime.fromMillisecondsSinceEpoch(startTimeMillis); + startTime = DateTime.fromMillisecondsSinceEpoch(startTimeMillis); _upgradeCollection(map, this); @@ -1158,7 +1158,7 @@ class Isolate extends ServiceObjectOwner { final Map response = await invokeRpcRaw('_reloadSources', params: arguments); return response; } on rpc.RpcException catch (e) { - return new Future>.error({ + return Future>.error({ 'code': e.code, 'message': e.message, 'data': e.data, @@ -1199,11 +1199,11 @@ class Isolate extends ServiceObjectOwner { for (int i = 1; i < lineTuple.length; i += 2) { if (lineTuple[i] == tokenPos) { final int column = lineTuple[i + 1]; - return new ProgramElement(name, uri, line, column); + return ProgramElement(name, uri, line, column); } } } - return new ProgramElement(name, uri); + return ProgramElement(name, uri); } // Lists program elements changed in the most recent reload that have not @@ -1425,7 +1425,7 @@ class FlutterView extends ServiceObject { Uri assetsDirectoryUri) async { final String viewId = id; // When this completer completes the isolate is running. - final Completer completer = new Completer(); + final Completer completer = Completer(); final StreamSubscription subscription = (await owner.vm.vmService.onIsolateEvent).listen((ServiceEvent event) { // TODO(johnmccutchan): Listen to the debug stream and catch initial diff --git a/packages/flutter_tools/lib/src/vmservice_record_replay.dart b/packages/flutter_tools/lib/src/vmservice_record_replay.dart index cce144204d..49dd7c3c5a 100644 --- a/packages/flutter_tools/lib/src/vmservice_record_replay.dart +++ b/packages/flutter_tools/lib/src/vmservice_record_replay.dart @@ -43,12 +43,12 @@ class RecordingVMServiceChannel extends DelegatingStreamChannel { @override Stream get stream { - _streamRecorder ??= new _RecordingStream(super.stream, _messages); + _streamRecorder ??= _RecordingStream(super.stream, _messages); return _streamRecorder.stream; } @override - StreamSink get sink => _sinkRecorder ??= new _RecordingSink(super.sink, _messages); + StreamSink get sink => _sinkRecorder ??= _RecordingSink(super.sink, _messages); } /// Base class for request and response JSON-rpc messages. @@ -60,8 +60,8 @@ abstract class _Message implements Comparable<_Message> { factory _Message.fromRecording(Map recordingData) { return recordingData[_kType] == _kRequest - ? new _Request(recordingData[_kData]) - : new _Response(recordingData[_kData]); + ? _Request(recordingData[_kData]) + : _Response(recordingData[_kData]); } int get id => data[_kId]; @@ -123,8 +123,8 @@ class _RecordingStream { _RecordingStream(Stream stream, this._recording) : _delegate = stream, _controller = stream.isBroadcast - ? new StreamController.broadcast() - : new StreamController() { + ? StreamController.broadcast() + : StreamController() { _controller.onListen = () { assert(_subscription == null); _subscription = _listenToStream(); @@ -147,7 +147,7 @@ class _RecordingStream { StreamSubscription _listenToStream() { return _delegate.listen( (String element) { - _recording.add(new _Response.fromString(element)); + _recording.add(_Response.fromString(element)); _controller.add(element); }, onError: _controller.addError, // We currently don't support recording of errors. @@ -176,17 +176,17 @@ class _RecordingSink implements StreamSink { @override void add(String data) { _delegate.add(data); - _recording.add(new _Request.fromString(data)); + _recording.add(_Request.fromString(data)); } @override void addError(dynamic errorEvent, [StackTrace stackTrace]) { - throw new UnimplementedError('Add support for this if the need ever arises'); + throw UnimplementedError('Add support for this if the need ever arises'); } @override Future addStream(Stream stream) { - throw new UnimplementedError('Add support for this if the need ever arises'); + throw UnimplementedError('Add support for this if the need ever arises'); } } @@ -195,7 +195,7 @@ class _RecordingSink implements StreamSink { /// replays the corresponding responses back from the recording. class ReplayVMServiceChannel extends StreamChannelMixin { final Map _transactions; - final StreamController _controller = new StreamController(); + final StreamController _controller = StreamController(); _ReplaySink _replaySink; ReplayVMServiceChannel(Directory location) @@ -208,7 +208,7 @@ class ReplayVMServiceChannel extends StreamChannelMixin { final Map transactions = {}; for (_Message message in messages) { final _Transaction transaction = - transactions.putIfAbsent(message.id, () => new _Transaction()); + transactions.putIfAbsent(message.id, () => _Transaction()); if (message.type == _kRequest) { assert(transaction.request == null); transaction.request = message; @@ -221,12 +221,12 @@ class ReplayVMServiceChannel extends StreamChannelMixin { } static _Message _toMessage(Map jsonData) { - return new _Message.fromRecording(jsonData); + return _Message.fromRecording(jsonData); } void send(_Request request) { if (!_transactions.containsKey(request.id)) - throw new ArgumentError('No matching invocation found'); + throw ArgumentError('No matching invocation found'); final _Transaction transaction = _transactions.remove(request.id); // TODO(tvolkert): validate that `transaction.request` matches `request` if (transaction.response == null) { @@ -243,7 +243,7 @@ class ReplayVMServiceChannel extends StreamChannelMixin { } @override - StreamSink get sink => _replaySink ??= new _ReplaySink(this); + StreamSink get sink => _replaySink ??= _ReplaySink(this); @override Stream get stream => _controller.stream; @@ -251,7 +251,7 @@ class ReplayVMServiceChannel extends StreamChannelMixin { class _ReplaySink implements StreamSink { final ReplayVMServiceChannel channel; - final Completer _completer = new Completer(); + final Completer _completer = Completer(); _ReplaySink(this.channel); @@ -267,18 +267,18 @@ class _ReplaySink implements StreamSink { @override void add(String data) { if (_completer.isCompleted) - throw new StateError('Sink already closed'); - channel.send(new _Request.fromString(data)); + throw StateError('Sink already closed'); + channel.send(_Request.fromString(data)); } @override void addError(dynamic errorEvent, [StackTrace stackTrace]) { - throw new UnimplementedError('Add support for this if the need ever arises'); + throw UnimplementedError('Add support for this if the need ever arises'); } @override Future addStream(Stream stream) { - throw new UnimplementedError('Add support for this if the need ever arises'); + throw UnimplementedError('Add support for this if the need ever arises'); } } diff --git a/packages/flutter_tools/lib/src/vscode/vscode.dart b/packages/flutter_tools/lib/src/vscode/vscode.dart index ddbd086f25..3ea9a3fe5e 100644 --- a/packages/flutter_tools/lib/src/vscode/vscode.dart +++ b/packages/flutter_tools/lib/src/vscode/vscode.dart @@ -39,7 +39,7 @@ class VsCode { final FileSystemEntity extensionDir = extensionDirs.first; _isValid = true; - _extensionVersion = new Version.parse( + _extensionVersion = Version.parse( extensionDir.basename.substring('$extensionIdentifier-'.length)); _validationMessages.add('Flutter extension version $_extensionVersion'); } @@ -63,8 +63,8 @@ class VsCode { final String versionString = _getVersionFromPackageJson(packageJsonPath); Version version; if (versionString != null) - version = new Version.parse(versionString); - return new VsCode._(installPath, extensionDirectory, version: version, edition: edition); + version = Version.parse(versionString); + return VsCode._(installPath, extensionDirectory, version: version, edition: edition); } bool get isValid => _isValid; @@ -94,20 +94,20 @@ class VsCode { // $HOME/.vscode-insiders/extensions static List _installedMacOS() { return _findInstalled(<_VsCodeInstallLocation>[ - new _VsCodeInstallLocation( + _VsCodeInstallLocation( fs.path.join('/Applications', 'Visual Studio Code.app', 'Contents'), '.vscode', ), - new _VsCodeInstallLocation( + _VsCodeInstallLocation( fs.path.join(homeDirPath, 'Applications', 'Visual Studio Code.app', 'Contents'), '.vscode', ), - new _VsCodeInstallLocation( + _VsCodeInstallLocation( fs.path.join('/Applications', 'Visual Studio Code - Insiders.app', 'Contents'), '.vscode-insiders', isInsiders: true, ), - new _VsCodeInstallLocation( + _VsCodeInstallLocation( fs.path.join(homeDirPath, 'Applications', 'Visual Studio Code - Insiders.app', 'Contents'), '.vscode-insiders', isInsiders: true, @@ -133,16 +133,16 @@ class VsCode { final String localAppData = platform.environment['localappdata']; return _findInstalled(<_VsCodeInstallLocation>[ - new _VsCodeInstallLocation(fs.path.join(localAppData, 'Programs\\Microsoft VS Code'), '.vscode'), - new _VsCodeInstallLocation(fs.path.join(progFiles86, 'Microsoft VS Code'), '.vscode', + _VsCodeInstallLocation(fs.path.join(localAppData, 'Programs\\Microsoft VS Code'), '.vscode'), + _VsCodeInstallLocation(fs.path.join(progFiles86, 'Microsoft VS Code'), '.vscode', edition: '32-bit edition'), - new _VsCodeInstallLocation(fs.path.join(progFiles, 'Microsoft VS Code'), '.vscode', + _VsCodeInstallLocation(fs.path.join(progFiles, 'Microsoft VS Code'), '.vscode', edition: '64-bit edition'), - new _VsCodeInstallLocation(fs.path.join(localAppData, 'Programs\\Microsoft VS Code Insiders'), '.vscode-insiders', + _VsCodeInstallLocation(fs.path.join(localAppData, 'Programs\\Microsoft VS Code Insiders'), '.vscode-insiders', isInsiders: true), - new _VsCodeInstallLocation(fs.path.join(progFiles86 , 'Microsoft VS Code Insiders'), '.vscode-insiders', + _VsCodeInstallLocation(fs.path.join(progFiles86 , 'Microsoft VS Code Insiders'), '.vscode-insiders', edition: '32-bit edition', isInsiders: true), - new _VsCodeInstallLocation(fs.path.join(progFiles, 'Microsoft VS Code Insiders'), '.vscode-insiders', + _VsCodeInstallLocation(fs.path.join(progFiles, 'Microsoft VS Code Insiders'), '.vscode-insiders', edition: '64-bit edition', isInsiders: true), ]); } @@ -173,7 +173,7 @@ class VsCode { if (fs.isDirectorySync(searchLocation.installPath)) { final String extensionDirectory = fs.path.join(homeDirPath, searchLocation.extensionsFolder, 'extensions'); - results.add(new VsCode.fromDirectory(searchLocation.installPath, extensionDirectory, edition: searchLocation.edition)); + results.add(VsCode.fromDirectory(searchLocation.installPath, extensionDirectory, edition: searchLocation.edition)); } } diff --git a/packages/flutter_tools/lib/src/vscode/vscode_validator.dart b/packages/flutter_tools/lib/src/vscode/vscode_validator.dart index 0bfe602def..115f50f333 100644 --- a/packages/flutter_tools/lib/src/vscode/vscode_validator.dart +++ b/packages/flutter_tools/lib/src/vscode/vscode_validator.dart @@ -18,7 +18,7 @@ class VsCodeValidator extends DoctorValidator { static Iterable get installedValidators { return VsCode .allInstalled() - .map((VsCode vsCode) => new VsCodeValidator(vsCode)); + .map((VsCode vsCode) => VsCodeValidator(vsCode)); } @override @@ -28,19 +28,19 @@ class VsCodeValidator extends DoctorValidator { final String vsCodeVersionText = _vsCode.version == Version.unknown ? null : 'version ${_vsCode.version}'; - messages.add(new ValidationMessage('VS Code at ${_vsCode.directory}')); + messages.add(ValidationMessage('VS Code at ${_vsCode.directory}')); if (_vsCode.isValid) { type = ValidationType.installed; messages.addAll(_vsCode.validationMessages - .map((String m) => new ValidationMessage(m))); + .map((String m) => ValidationMessage(m))); } else { type = ValidationType.partial; messages.addAll(_vsCode.validationMessages - .map((String m) => new ValidationMessage.error(m))); - messages.add(new ValidationMessage( + .map((String m) => ValidationMessage.error(m))); + messages.add(ValidationMessage( 'Flutter extension not installed; install from\n$extensionMarketplaceUrl')); } - return new ValidationResult(type, messages, statusInfo: vsCodeVersionText); + return ValidationResult(type, messages, statusInfo: vsCodeVersionText); } } diff --git a/packages/flutter_tools/test/analytics_test.dart b/packages/flutter_tools/test/analytics_test.dart index f6f2b75945..ee99ace266 100644 --- a/packages/flutter_tools/test/analytics_test.dart +++ b/packages/flutter_tools/test/analytics_test.dart @@ -51,13 +51,13 @@ void main() { count = 0; flutterUsage.enabled = false; - final DoctorCommand doctorCommand = new DoctorCommand(); + final DoctorCommand doctorCommand = DoctorCommand(); final CommandRunnerrunner = createTestCommandRunner(doctorCommand); await runner.run(['doctor']); expect(count, 0); }, overrides: { - FlutterVersion: () => new FlutterVersion(const Clock()), - Usage: () => new Usage(configDirOverride: tempDir.path), + FlutterVersion: () => FlutterVersion(const Clock()), + Usage: () => Usage(configDirOverride: tempDir.path), }); // Ensure we don't send for the 'flutter config' command. @@ -66,7 +66,7 @@ void main() { flutterUsage.onSend.listen((Map data) => count++); flutterUsage.enabled = false; - final ConfigCommand command = new ConfigCommand(); + final ConfigCommand command = ConfigCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['config']); expect(count, 0); @@ -75,8 +75,8 @@ void main() { await runner.run(['config']); expect(count, 0); }, overrides: { - FlutterVersion: () => new FlutterVersion(const Clock()), - Usage: () => new Usage(configDirOverride: tempDir.path), + FlutterVersion: () => FlutterVersion(const Clock()), + Usage: () => Usage(configDirOverride: tempDir.path), }); }); @@ -87,19 +87,19 @@ void main() { List mockTimes; setUp(() { - mockUsage = new MockUsage(); + mockUsage = MockUsage(); when(mockUsage.isFirstRun).thenReturn(false); - mockClock = new MockClock(); - mockDoctor = new MockDoctor(); + mockClock = MockClock(); + mockDoctor = MockDoctor(); when(mockClock.now()).thenAnswer( - (Invocation _) => new DateTime.fromMillisecondsSinceEpoch(mockTimes.removeAt(0)) + (Invocation _) => DateTime.fromMillisecondsSinceEpoch(mockTimes.removeAt(0)) ); }); testUsingContext('flutter commands send timing events', () async { mockTimes = [1000, 2000]; when(mockDoctor.diagnose(androidLicenses: false, verbose: false)).thenAnswer((_) async => true); - final DoctorCommand command = new DoctorCommand(); + final DoctorCommand command = DoctorCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['doctor']); @@ -118,7 +118,7 @@ void main() { testUsingContext('doctor fail sends warning', () async { mockTimes = [1000, 2000]; when(mockDoctor.diagnose(androidLicenses: false, verbose: false)).thenAnswer((_) async => false); - final DoctorCommand command = new DoctorCommand(); + final DoctorCommand command = DoctorCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['doctor']); @@ -135,14 +135,14 @@ void main() { }); testUsingContext('single command usage path', () async { - final FlutterCommand doctorCommand = new DoctorCommand(); + final FlutterCommand doctorCommand = DoctorCommand(); expect(await doctorCommand.usagePath, 'doctor'); }, overrides: { Usage: () => mockUsage, }); testUsingContext('compound command usage path', () async { - final BuildCommand buildCommand = new BuildCommand(); + final BuildCommand buildCommand = BuildCommand(); final FlutterCommand buildApkCommand = buildCommand.subcommands['apk']; expect(await buildApkCommand.usagePath, 'build/apk'); }, overrides: { @@ -168,7 +168,7 @@ void main() { await createTestCommandRunner().run(['--version']); expect(count, 0); }, overrides: { - Usage: () => new Usage( + Usage: () => Usage( settingsName: 'flutter_bot_test', versionOverride: 'dev/unknown', configDirOverride: tempDir.path, @@ -183,7 +183,7 @@ void main() { await createTestCommandRunner().run(['--version']); expect(count, 0); }, overrides: { - Usage: () => new Usage( + Usage: () => Usage( settingsName: 'flutter_bot_test', versionOverride: 'dev/unknown', configDirOverride: tempDir.path, diff --git a/packages/flutter_tools/test/android/android_device_test.dart b/packages/flutter_tools/test/android/android_device_test.dart index 46edcff380..e29a7ef462 100644 --- a/packages/flutter_tools/test/android/android_device_test.dart +++ b/packages/flutter_tools/test/android/android_device_test.dart @@ -16,7 +16,7 @@ void main() { group('android_device', () { testUsingContext('stores the requested id', () { const String deviceId = '1234'; - final AndroidDevice device = new AndroidDevice(deviceId); + final AndroidDevice device = AndroidDevice(deviceId); expect(device.id, deviceId); }); }); @@ -81,7 +81,7 @@ Use the 'android' tool to install them: }); group('isLocalEmulator', () { - final ProcessManager mockProcessManager = new MockProcessManager(); + final ProcessManager mockProcessManager = MockProcessManager(); String hardware; String buildCharacteristics; @@ -91,17 +91,17 @@ Use the 'android' tool to install them: when(mockProcessManager.run(argThat(contains('getprop')), stderrEncoding: anyNamed('stderrEncoding'), stdoutEncoding: anyNamed('stdoutEncoding'))).thenAnswer((_) { - final StringBuffer buf = new StringBuffer() + final StringBuffer buf = StringBuffer() ..writeln('[ro.hardware]: [$hardware]') ..writeln('[ro.build.characteristics]: [$buildCharacteristics]'); - final ProcessResult result = new ProcessResult(1, 0, buf.toString(), ''); - return new Future.value(result); + final ProcessResult result = ProcessResult(1, 0, buf.toString(), ''); + return Future.value(result); }); }); testUsingContext('knownPhysical', () async { hardware = 'samsungexynos7420'; - final AndroidDevice device = new AndroidDevice('test'); + final AndroidDevice device = AndroidDevice('test'); expect(await device.isLocalEmulator, false); }, overrides: { ProcessManager: () => mockProcessManager, @@ -109,7 +109,7 @@ Use the 'android' tool to install them: testUsingContext('knownEmulator', () async { hardware = 'goldfish'; - final AndroidDevice device = new AndroidDevice('test'); + final AndroidDevice device = AndroidDevice('test'); expect(await device.isLocalEmulator, true); expect(await device.supportsHardwareRendering, true); }, overrides: { @@ -118,7 +118,7 @@ Use the 'android' tool to install them: testUsingContext('unknownPhysical', () async { buildCharacteristics = 'att'; - final AndroidDevice device = new AndroidDevice('test'); + final AndroidDevice device = AndroidDevice('test'); expect(await device.isLocalEmulator, false); }, overrides: { ProcessManager: () => mockProcessManager, @@ -126,7 +126,7 @@ Use the 'android' tool to install them: testUsingContext('unknownEmulator', () async { buildCharacteristics = 'att,emulator'; - final AndroidDevice device = new AndroidDevice('test'); + final AndroidDevice device = AndroidDevice('test'); expect(await device.isLocalEmulator, true); expect(await device.supportsHardwareRendering, true); }, overrides: { diff --git a/packages/flutter_tools/test/android/android_emulator_test.dart b/packages/flutter_tools/test/android/android_emulator_test.dart index e4256d8ca0..28046c1249 100644 --- a/packages/flutter_tools/test/android/android_emulator_test.dart +++ b/packages/flutter_tools/test/android/android_emulator_test.dart @@ -11,14 +11,14 @@ void main() { group('android_emulator', () { testUsingContext('flags emulators without config', () { const String emulatorID = '1234'; - final AndroidEmulator emulator = new AndroidEmulator(emulatorID); + final AndroidEmulator emulator = AndroidEmulator(emulatorID); expect(emulator.id, emulatorID); expect(emulator.hasConfig, false); }); testUsingContext('flags emulators with config', () { const String emulatorID = '1234'; final AndroidEmulator emulator = - new AndroidEmulator(emulatorID, {'name': 'test'}); + AndroidEmulator(emulatorID, {'name': 'test'}); expect(emulator.id, emulatorID); expect(emulator.hasConfig, true); }); @@ -33,7 +33,7 @@ void main() { 'avd.ini.displayname': label }; final AndroidEmulator emulator = - new AndroidEmulator(emulatorID, properties); + AndroidEmulator(emulatorID, properties); expect(emulator.id, emulatorID); expect(emulator.name, name); expect(emulator.manufacturer, manufacturer); diff --git a/packages/flutter_tools/test/android/android_sdk_test.dart b/packages/flutter_tools/test/android/android_sdk_test.dart index 870a0bf81b..d2b6522b1a 100644 --- a/packages/flutter_tools/test/android/android_sdk_test.dart +++ b/packages/flutter_tools/test/android/android_sdk_test.dart @@ -22,8 +22,8 @@ void main() { MockProcessManager processManager; setUp(() { - fs = new MemoryFileSystem(); - processManager = new MockProcessManager(); + fs = MemoryFileSystem(); + processManager = MockProcessManager(); }); group('android_sdk AndroidSdk', () { @@ -76,7 +76,7 @@ void main() { when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(true); when(processManager.runSync([sdk.sdkManagerPath, '--version'], environment: argThat(isNotNull, named: 'environment'))) - .thenReturn(new ProcessResult(1, 0, '26.1.1\n', '')); + .thenReturn(ProcessResult(1, 0, '26.1.1\n', '')); expect(sdk.sdkManagerVersion, '26.1.1'); }, overrides: { FileSystem: () => fs, @@ -91,7 +91,7 @@ void main() { when(processManager.canRun(sdk.sdkManagerPath)).thenReturn(true); when(processManager.runSync([sdk.sdkManagerPath, '--version'], environment: argThat(isNotNull, named: 'environment'))) - .thenReturn(new ProcessResult(1, 1, '26.1.1\n', 'Mystery error')); + .thenReturn(ProcessResult(1, 1, '26.1.1\n', 'Mystery error')); expect(sdk.sdkManagerVersion, isNull); }, overrides: { FileSystem: () => fs, @@ -141,7 +141,7 @@ void main() { expect(sdk.ndk.compilerArgs, ['--sysroot', realNdkSysroot]); }, overrides: { FileSystem: () => fs, - Platform: () => new FakePlatform(operatingSystem: os), + Platform: () => FakePlatform(operatingSystem: os), }); }); @@ -158,7 +158,7 @@ void main() { expect(explanation, contains('Can not locate ndk-bundle')); }, overrides: { FileSystem: () => fs, - Platform: () => new FakePlatform(operatingSystem: os), + Platform: () => FakePlatform(operatingSystem: os), }); } }); diff --git a/packages/flutter_tools/test/android/android_workflow_test.dart b/packages/flutter_tools/test/android/android_workflow_test.dart index 0f3f916ece..73c9dc1a80 100644 --- a/packages/flutter_tools/test/android/android_workflow_test.dart +++ b/packages/flutter_tools/test/android/android_workflow_test.dart @@ -24,35 +24,35 @@ void main() { MockStdio stdio; setUp(() { - sdk = new MockAndroidSdk(); - fs = new MemoryFileSystem(); + sdk = MockAndroidSdk(); + fs = MemoryFileSystem(); fs.directory('/home/me').createSync(recursive: true); - processManager = new MockProcessManager(); - stdio = new MockStdio(); + processManager = MockProcessManager(); + stdio = MockStdio(); }); MockProcess Function(List) processMetaFactory(List stdout) { - final Stream> stdoutStream = new Stream>.fromIterable( + final Stream> stdoutStream = Stream>.fromIterable( stdout.map((String s) => s.codeUnits)); - return (List command) => new MockProcess(stdout: stdoutStream); + return (List command) => MockProcess(stdout: stdoutStream); } testUsingContext('licensesAccepted throws if cannot run sdkmanager', () async { processManager.succeed = false; when(sdk.sdkManagerPath).thenReturn('/foo/bar/sdkmanager'); - final AndroidValidator androidValidator = new AndroidValidator(); + final AndroidValidator androidValidator = AndroidValidator(); expect(androidValidator.licensesAccepted, throwsToolExit()); }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); testUsingContext('licensesAccepted handles garbage/no output', () async { when(sdk.sdkManagerPath).thenReturn('/foo/bar/sdkmanager'); - final AndroidValidator androidValidator = new AndroidValidator(); + final AndroidValidator androidValidator = AndroidValidator(); final LicensesAccepted result = await androidValidator.licensesAccepted; expect(result, equals(LicensesAccepted.unknown)); expect(processManager.commands.first, equals('/foo/bar/sdkmanager')); @@ -60,7 +60,7 @@ void main() { }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -72,13 +72,13 @@ void main() { 'All SDK package licenses accepted.' ]); - final AndroidValidator androidValidator = new AndroidValidator(); + final AndroidValidator androidValidator = AndroidValidator(); final LicensesAccepted result = await androidValidator.licensesAccepted; expect(result, equals(LicensesAccepted.all)); }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -91,13 +91,13 @@ void main() { 'Review licenses that have not been accepted (y/N)?', ]); - final AndroidValidator androidValidator = new AndroidValidator(); + final AndroidValidator androidValidator = AndroidValidator(); final LicensesAccepted result = await androidValidator.licensesAccepted; expect(result, equals(LicensesAccepted.some)); }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -110,13 +110,13 @@ void main() { 'Review licenses that have not been accepted (y/N)?', ]); - final AndroidValidator androidValidator = new AndroidValidator(); + final AndroidValidator androidValidator = AndroidValidator(); final LicensesAccepted result = await androidValidator.licensesAccepted; expect(result, equals(LicensesAccepted.none)); }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -129,7 +129,7 @@ void main() { }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -142,7 +142,7 @@ void main() { }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -155,7 +155,7 @@ void main() { }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); @@ -168,7 +168,7 @@ void main() { }, overrides: { AndroidSdk: () => sdk, FileSystem: () => fs, - Platform: () => new FakePlatform()..environment = {'HOME': '/home/me'}, + Platform: () => FakePlatform()..environment = {'HOME': '/home/me'}, ProcessManager: () => processManager, Stdio: () => stdio, }); diff --git a/packages/flutter_tools/test/android/gradle_test.dart b/packages/flutter_tools/test/android/gradle_test.dart index 634ddc750d..af6b012e25 100644 --- a/packages/flutter_tools/test/android/gradle_test.dart +++ b/packages/flutter_tools/test/android/gradle_test.dart @@ -63,7 +63,7 @@ void main() { }); group('gradle project', () { - GradleProject projectFrom(String properties) => new GradleProject.fromAppProperties(properties); + GradleProject projectFrom(String properties) => GradleProject.fromAppProperties(properties); test('should extract build directory from app properties', () { final GradleProject project = projectFrom(''' @@ -115,27 +115,27 @@ someOtherProperty: someOtherValue expect(project.productFlavors, ['free', 'paid']); }); test('should provide apk file name for default build types', () { - final GradleProject project = new GradleProject(['debug', 'profile', 'release'], [], fs.directory('/some/dir')); + final GradleProject project = GradleProject(['debug', 'profile', 'release'], [], fs.directory('/some/dir')); expect(project.apkFileFor(BuildInfo.debug), 'app-debug.apk'); expect(project.apkFileFor(BuildInfo.profile), 'app-profile.apk'); expect(project.apkFileFor(BuildInfo.release), 'app-release.apk'); expect(project.apkFileFor(const BuildInfo(BuildMode.release, 'unknown')), isNull); }); test('should provide apk file name for flavored build types', () { - final GradleProject project = new GradleProject(['debug', 'profile', 'release'], ['free', 'paid'], fs.directory('/some/dir')); + final GradleProject project = GradleProject(['debug', 'profile', 'release'], ['free', 'paid'], fs.directory('/some/dir')); expect(project.apkFileFor(const BuildInfo(BuildMode.debug, 'free')), 'app-free-debug.apk'); expect(project.apkFileFor(const BuildInfo(BuildMode.release, 'paid')), 'app-paid-release.apk'); expect(project.apkFileFor(const BuildInfo(BuildMode.release, 'unknown')), isNull); }); test('should provide assemble task name for default build types', () { - final GradleProject project = new GradleProject(['debug', 'profile', 'release'], [], fs.directory('/some/dir')); + final GradleProject project = GradleProject(['debug', 'profile', 'release'], [], fs.directory('/some/dir')); expect(project.assembleTaskFor(BuildInfo.debug), 'assembleDebug'); expect(project.assembleTaskFor(BuildInfo.profile), 'assembleProfile'); expect(project.assembleTaskFor(BuildInfo.release), 'assembleRelease'); expect(project.assembleTaskFor(const BuildInfo(BuildMode.release, 'unknown')), isNull); }); test('should provide assemble task name for flavored build types', () { - final GradleProject project = new GradleProject(['debug', 'profile', 'release'], ['free', 'paid'], fs.directory('/some/dir')); + final GradleProject project = GradleProject(['debug', 'profile', 'release'], ['free', 'paid'], fs.directory('/some/dir')); expect(project.assembleTaskFor(const BuildInfo(BuildMode.debug, 'free')), 'assembleFreeDebug'); expect(project.assembleTaskFor(const BuildInfo(BuildMode.release, 'paid')), 'assemblePaidRelease'); expect(project.assembleTaskFor(const BuildInfo(BuildMode.release, 'unknown')), isNull); @@ -149,9 +149,9 @@ someOtherProperty: someOtherValue FileSystem fs; setUp(() { - fs = new MemoryFileSystem(); - mockArtifacts = new MockLocalEngineArtifacts(); - mockProcessManager = new MockProcessManager(); + fs = MemoryFileSystem(); + mockArtifacts = MockLocalEngineArtifacts(); + mockProcessManager = MockProcessManager(); android = fakePlatform('android'); }); @@ -331,7 +331,7 @@ flutter: } Platform fakePlatform(String name) { - return new FakePlatform.fromPlatform(const LocalPlatform())..operatingSystem = name; + return FakePlatform.fromPlatform(const LocalPlatform())..operatingSystem = name; } class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {} diff --git a/packages/flutter_tools/test/application_package_test.dart b/packages/flutter_tools/test/application_package_test.dart index bdd679216d..3b15cc300f 100644 --- a/packages/flutter_tools/test/application_package_test.dart +++ b/packages/flutter_tools/test/application_package_test.dart @@ -43,12 +43,12 @@ void main() { group('PrebuiltIOSApp', () { final Map overrides = { - FileSystem: () => new MemoryFileSystem(), - IOSWorkflow: () => new MockIosWorkFlow() + FileSystem: () => MemoryFileSystem(), + IOSWorkflow: () => MockIosWorkFlow() }; testUsingContext('Error on non-existing file', () { final PrebuiltIOSApp iosApp = - new IOSApp.fromPrebuiltApp(fs.file('not_existing.ipa')); + IOSApp.fromPrebuiltApp(fs.file('not_existing.ipa')); expect(iosApp, isNull); final BufferLogger logger = context[Logger]; expect( @@ -59,7 +59,7 @@ void main() { testUsingContext('Error on non-app-bundle folder', () { fs.directory('regular_folder').createSync(); final PrebuiltIOSApp iosApp = - new IOSApp.fromPrebuiltApp(fs.file('regular_folder')); + IOSApp.fromPrebuiltApp(fs.file('regular_folder')); expect(iosApp, isNull); final BufferLogger logger = context[Logger]; expect( @@ -67,7 +67,7 @@ void main() { }, overrides: overrides); testUsingContext('Error on no info.plist', () { fs.directory('bundle.app').createSync(); - final PrebuiltIOSApp iosApp = new IOSApp.fromPrebuiltApp(fs.file('bundle.app')); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')); expect(iosApp, isNull); final BufferLogger logger = context[Logger]; expect( @@ -78,7 +78,7 @@ void main() { testUsingContext('Error on bad info.plist', () { fs.directory('bundle.app').createSync(); fs.file('bundle.app/Info.plist').writeAsStringSync(badPlistData); - final PrebuiltIOSApp iosApp = new IOSApp.fromPrebuiltApp(fs.file('bundle.app')); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')); expect(iosApp, isNull); final BufferLogger logger = context[Logger]; expect( @@ -90,7 +90,7 @@ void main() { testUsingContext('Success with app bundle', () { fs.directory('bundle.app').createSync(); fs.file('bundle.app/Info.plist').writeAsStringSync(plistData); - final PrebuiltIOSApp iosApp = new IOSApp.fromPrebuiltApp(fs.file('bundle.app')); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('bundle.app')); final BufferLogger logger = context[Logger]; expect(logger.errorText, isEmpty); expect(iosApp.bundleDir.path, 'bundle.app'); @@ -100,7 +100,7 @@ void main() { testUsingContext('Bad ipa zip-file, no payload dir', () { fs.file('app.ipa').createSync(); when(os.unzip(fs.file('app.ipa'), any)).thenAnswer((Invocation _) {}); - final PrebuiltIOSApp iosApp = new IOSApp.fromPrebuiltApp(fs.file('app.ipa')); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')); expect(iosApp, isNull); final BufferLogger logger = context[Logger]; expect( @@ -123,7 +123,7 @@ void main() { fs.directory(bundlePath1).createSync(recursive: true); fs.directory(bundlePath2).createSync(recursive: true); }); - final PrebuiltIOSApp iosApp = new IOSApp.fromPrebuiltApp(fs.file('app.ipa')); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')); expect(iosApp, isNull); final BufferLogger logger = context[Logger]; expect(logger.errorText, @@ -144,7 +144,7 @@ void main() { .file(fs.path.join(bundleAppDir.path, 'Info.plist')) .writeAsStringSync(plistData); }); - final PrebuiltIOSApp iosApp = new IOSApp.fromPrebuiltApp(fs.file('app.ipa')); + final PrebuiltIOSApp iosApp = IOSApp.fromPrebuiltApp(fs.file('app.ipa')); final BufferLogger logger = context[Logger]; expect(logger.errorText, isEmpty); expect(iosApp.bundleDir.path, endsWith('bundle.app')); diff --git a/packages/flutter_tools/test/artifacts_test.dart b/packages/flutter_tools/test/artifacts_test.dart index ac1c8fe776..24a8c820a0 100644 --- a/packages/flutter_tools/test/artifacts_test.dart +++ b/packages/flutter_tools/test/artifacts_test.dart @@ -19,7 +19,7 @@ void main() { setUp(() { tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_artifacts_test_cached.'); - artifacts = new CachedArtifacts(); + artifacts = CachedArtifacts(); }); tearDown(() { @@ -40,8 +40,8 @@ void main() { fs.path.join(tempDir.path, 'bin', 'cache', 'artifacts', 'engine', 'linux-x64', 'flutter_tester') ); }, overrides: { - Cache: () => new Cache(rootOverride: tempDir), - Platform: () => new FakePlatform(operatingSystem: 'linux') + Cache: () => Cache(rootOverride: tempDir), + Platform: () => FakePlatform(operatingSystem: 'linux') }); testUsingContext('getEngineType', () { @@ -58,8 +58,8 @@ void main() { 'darwin-x64' ); }, overrides: { - Cache: () => new Cache(rootOverride: tempDir), - Platform: () => new FakePlatform(operatingSystem: 'linux') + Cache: () => Cache(rootOverride: tempDir), + Platform: () => FakePlatform(operatingSystem: 'linux') }); }); @@ -70,7 +70,7 @@ void main() { setUp(() { tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_artifacts_test_local.'); - artifacts = new LocalEngineArtifacts(tempDir.path, + artifacts = LocalEngineArtifacts(tempDir.path, fs.path.join(tempDir.path, 'out', 'android_debug_unopt'), fs.path.join(tempDir.path, 'out', 'host_debug_unopt'), ); @@ -102,7 +102,7 @@ void main() { fs.path.join(tempDir.path, 'out', 'host_debug_unopt', 'dart-sdk') ); }, overrides: { - Platform: () => new FakePlatform(operatingSystem: 'linux') + Platform: () => FakePlatform(operatingSystem: 'linux') }); testUsingContext('getEngineType', () { @@ -119,7 +119,7 @@ void main() { 'android_debug_unopt' ); }, overrides: { - Platform: () => new FakePlatform(operatingSystem: 'linux') + Platform: () => FakePlatform(operatingSystem: 'linux') }); }); } diff --git a/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart b/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart index 393b89d73e..4c4eb2172f 100644 --- a/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart +++ b/packages/flutter_tools/test/asset_bundle_package_fonts_test.dart @@ -104,7 +104,7 @@ $fontsSection FileSystem testFileSystem; setUp(() async { - testFileSystem = new MemoryFileSystem( + testFileSystem = MemoryFileSystem( style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, diff --git a/packages/flutter_tools/test/asset_bundle_package_test.dart b/packages/flutter_tools/test/asset_bundle_package_test.dart index 8e63c6ce84..17b3c4285d 100644 --- a/packages/flutter_tools/test/asset_bundle_package_test.dart +++ b/packages/flutter_tools/test/asset_bundle_package_test.dart @@ -31,7 +31,7 @@ void main() { if (assets == null) { assetsSection = ''; } else { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); buffer.write(''' flutter: assets: @@ -104,7 +104,7 @@ $assetsSection FileSystem testFileSystem; setUp(() async { - testFileSystem = new MemoryFileSystem( + testFileSystem = MemoryFileSystem( style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, diff --git a/packages/flutter_tools/test/asset_bundle_test.dart b/packages/flutter_tools/test/asset_bundle_test.dart index 50991b2a1b..7a0bb002b3 100644 --- a/packages/flutter_tools/test/asset_bundle_test.dart +++ b/packages/flutter_tools/test/asset_bundle_test.dart @@ -24,7 +24,7 @@ void main() { FileSystem testFileSystem; setUp(() async { - testFileSystem = new MemoryFileSystem( + testFileSystem = MemoryFileSystem( style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, diff --git a/packages/flutter_tools/test/asset_bundle_variant_test.dart b/packages/flutter_tools/test/asset_bundle_variant_test.dart index fd509295e5..9a7b9f5335 100644 --- a/packages/flutter_tools/test/asset_bundle_variant_test.dart +++ b/packages/flutter_tools/test/asset_bundle_variant_test.dart @@ -29,7 +29,7 @@ void main() { group('AssetBundle asset variants', () { FileSystem testFileSystem; setUp(() async { - testFileSystem = new MemoryFileSystem( + testFileSystem = MemoryFileSystem( style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, diff --git a/packages/flutter_tools/test/asset_test.dart b/packages/flutter_tools/test/asset_test.dart index 79bd611d1a..c681ca562d 100644 --- a/packages/flutter_tools/test/asset_test.dart +++ b/packages/flutter_tools/test/asset_test.dart @@ -47,5 +47,5 @@ void main() { } Future getValueAsString(String key, AssetBundle asset) async { - return new String.fromCharCodes(await asset.entries[key].contentsAsBytes()); + return String.fromCharCodes(await asset.entries[key].contentsAsBytes()); } diff --git a/packages/flutter_tools/test/base/build_test.dart b/packages/flutter_tools/test/base/build_test.dart index b95e72bf1a..663b6b08c6 100644 --- a/packages/flutter_tools/test/base/build_test.dart +++ b/packages/flutter_tools/test/base/build_test.dart @@ -75,12 +75,12 @@ void main() { group('SnapshotType', () { test('throws, if build mode is null', () { expect( - () => new SnapshotType(TargetPlatform.android_x64, null), + () => SnapshotType(TargetPlatform.android_x64, null), throwsA(anything), ); }); test('does not throw, if target platform is null', () { - expect(new SnapshotType(null, BuildMode.release), isNotNull); + expect(SnapshotType(null, BuildMode.release), isNotNull); }); }); @@ -100,7 +100,7 @@ void main() { MockXcode mockXcode; setUp(() async { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); fs.file(kVmEntrypoints).createSync(); fs.file(kIoEntries).createSync(); fs.file(kSnapshotDart).createSync(); @@ -108,18 +108,18 @@ void main() { fs.file(kEntrypointsExtraJson).createSync(); fs.file('.packages').writeAsStringSync('sky_engine:file:///flutter/bin/cache/pkg/sky_engine/lib/'); - skyEnginePath = fs.path.fromUri(new Uri.file('/flutter/bin/cache/pkg/sky_engine')); + skyEnginePath = fs.path.fromUri(Uri.file('/flutter/bin/cache/pkg/sky_engine')); fs.directory(fs.path.join(skyEnginePath, 'lib', 'ui')).createSync(recursive: true); fs.directory(fs.path.join(skyEnginePath, 'sdk_ext')).createSync(recursive: true); fs.file(fs.path.join(skyEnginePath, '.packages')).createSync(); fs.file(fs.path.join(skyEnginePath, 'lib', 'ui', 'ui.dart')).createSync(); fs.file(fs.path.join(skyEnginePath, 'sdk_ext', 'vmservice_io.dart')).createSync(); - genSnapshot = new _FakeGenSnapshot(); - snapshotter = new AOTSnapshotter(); - mockAndroidSdk = new MockAndroidSdk(); - mockArtifacts = new MockArtifacts(); - mockXcode = new MockXcode(); + genSnapshot = _FakeGenSnapshot(); + snapshotter = AOTSnapshotter(); + mockAndroidSdk = MockAndroidSdk(); + mockArtifacts = MockArtifacts(); + mockXcode = MockXcode(); for (BuildMode mode in BuildMode.values) { when(mockArtifacts.getArtifactPath(Artifact.dartVmEntryPointsTxt, any, mode)).thenReturn(kVmEntrypoints); when(mockArtifacts.getArtifactPath(Artifact.dartIoEntriesTxt, any, mode)).thenReturn(kIoEntries); @@ -184,9 +184,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'snapshot_assembly.S')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.ios, @@ -230,9 +230,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'snapshot_assembly.S')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.ios, @@ -277,9 +277,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.android_arm, @@ -328,9 +328,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.android_arm64, @@ -374,9 +374,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'snapshot_assembly.S')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.ios, @@ -420,9 +420,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'snapshot_assembly.S')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.ios, @@ -485,9 +485,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.android_arm, @@ -536,9 +536,9 @@ void main() { fs.path.join(outputPath, 'snapshot.d'): '${fs.path.join(outputPath, 'vm_snapshot_data')} : ', }; - final RunResult successResult = new RunResult(new ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); - when(xcode.cc(any)).thenAnswer((_) => new Future.value(successResult)); - when(xcode.clang(any)).thenAnswer((_) => new Future.value(successResult)); + final RunResult successResult = RunResult(ProcessResult(1, 0, '', ''), ['command name', 'arguments...']); + when(xcode.cc(any)).thenAnswer((_) => Future.value(successResult)); + when(xcode.clang(any)).thenAnswer((_) => Future.value(successResult)); final int genSnapshotExitCode = await snapshotter.build( platform: TargetPlatform.android_arm64, @@ -583,13 +583,13 @@ void main() { MockArtifacts mockArtifacts; setUp(() async { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); fs.file(kTrace).createSync(); - genSnapshot = new _FakeGenSnapshot(); - snapshotter = new CoreJITSnapshotter(); - mockAndroidSdk = new MockAndroidSdk(); - mockArtifacts = new MockArtifacts(); + genSnapshot = _FakeGenSnapshot(); + snapshotter = CoreJITSnapshotter(); + mockAndroidSdk = MockAndroidSdk(); + mockArtifacts = MockArtifacts(); }); final Map contextOverrides = { diff --git a/packages/flutter_tools/test/base/context_test.dart b/packages/flutter_tools/test/base/context_test.dart index 6b79495ad4..f7291dc3d0 100644 --- a/packages/flutter_tools/test/base/context_test.dart +++ b/packages/flutter_tools/test/base/context_test.dart @@ -74,8 +74,8 @@ void main() { group('operator[]', () { test('still finds values if async code runs after body has finished', () async { - final Completer outer = new Completer(); - final Completer inner = new Completer(); + final Completer outer = Completer(); + final Completer inner = Completer(); String value; await context.run( body: () { @@ -99,7 +99,7 @@ void main() { String value; await context.run( body: () async { - final StringBuffer buf = new StringBuffer(context[String]); + final StringBuffer buf = StringBuffer(context[String]); buf.write(context[String]); await context.run(body: () { buf.write(context[String]); @@ -122,7 +122,7 @@ void main() { String value; await context.run( body: () async { - final StringBuffer buf = new StringBuffer(context[String]); + final StringBuffer buf = StringBuffer(context[String]); buf.write(context[String]); await context.run(body: () { buf.write(context[String]); diff --git a/packages/flutter_tools/test/base/file_system_test.dart b/packages/flutter_tools/test/base/file_system_test.dart index 7f6c6c9db5..3652e7970a 100644 --- a/packages/flutter_tools/test/base/file_system_test.dart +++ b/packages/flutter_tools/test/base/file_system_test.dart @@ -14,7 +14,7 @@ void main() { MemoryFileSystem fs; setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); }); testUsingContext('recursively creates a directory if it does not exist', () async { @@ -32,7 +32,7 @@ void main() { /// Test file_systems.copyDirectorySync() using MemoryFileSystem. /// Copies between 2 instances of file systems which is also supported by copyDirectorySync(). test('test directory copy', () async { - final MemoryFileSystem sourceMemoryFs = new MemoryFileSystem(); + final MemoryFileSystem sourceMemoryFs = MemoryFileSystem(); const String sourcePath = '/some/origin'; final Directory sourceDirectory = await sourceMemoryFs.directory(sourcePath).create(recursive: true); sourceMemoryFs.currentDirectory = sourcePath; @@ -42,7 +42,7 @@ void main() { sourceMemoryFs.directory('empty_directory').createSync(); // Copy to another memory file system instance. - final MemoryFileSystem targetMemoryFs = new MemoryFileSystem(); + final MemoryFileSystem targetMemoryFs = MemoryFileSystem(); const String targetPath = '/some/non-existent/target'; final Directory targetDirectory = targetMemoryFs.directory(targetPath); copyDirectorySync(sourceDirectory, targetDirectory); @@ -92,7 +92,7 @@ void main() { expect(escapePath('foo\\bar\\cool.dart'), 'foo\\\\bar\\\\cool.dart'); expect(escapePath('C:/foo/bar/cool.dart'), 'C:/foo/bar/cool.dart'); }, overrides: { - Platform: () => new FakePlatform(operatingSystem: 'windows') + Platform: () => FakePlatform(operatingSystem: 'windows') }); testUsingContext('on Linux', () { @@ -100,7 +100,7 @@ void main() { expect(escapePath('foo/bar/cool.dart'), 'foo/bar/cool.dart'); expect(escapePath('foo\\cool.dart'), 'foo\\cool.dart'); }, overrides: { - Platform: () => new FakePlatform(operatingSystem: 'linux') + Platform: () => FakePlatform(operatingSystem: 'linux') }); }); } diff --git a/packages/flutter_tools/test/base/fingerprint_test.dart b/packages/flutter_tools/test/base/fingerprint_test.dart index bf989fce6d..e9e15e7f70 100644 --- a/packages/flutter_tools/test/base/fingerprint_test.dart +++ b/packages/flutter_tools/test/base/fingerprint_test.dart @@ -22,8 +22,8 @@ void main() { MockFlutterVersion mockVersion; setUp(() { - fs = new MemoryFileSystem(); - mockVersion = new MockFlutterVersion(); + fs = MemoryFileSystem(); + mockVersion = MockFlutterVersion(); when(mockVersion.frameworkRevision).thenReturn(kVersion); }); @@ -36,7 +36,7 @@ void main() { await fs.file('b.dart').create(); await fs.file('depfile').create(); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart'], depfilePaths: ['depfile'], @@ -51,7 +51,7 @@ void main() { testUsingContext('creates fingerprint with specified properties and files', () async { await fs.file('a.dart').create(); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart'], properties: { @@ -60,7 +60,7 @@ void main() { }, ); final Fingerprint fingerprint = await fingerprinter.buildFingerprint(); - expect(fingerprint, new Fingerprint.fromBuildInputs({ + expect(fingerprint, Fingerprint.fromBuildInputs({ 'foo': 'bar', 'wibble': 'wobble', }, ['a.dart'])); @@ -71,7 +71,7 @@ void main() { await fs.file('b.dart').create(); await fs.file('depfile').writeAsString('depfile : b.dart'); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart'], depfilePaths: ['depfile'], @@ -81,7 +81,7 @@ void main() { }, ); final Fingerprint fingerprint = await fingerprinter.buildFingerprint(); - expect(fingerprint, new Fingerprint.fromBuildInputs({ + expect(fingerprint, Fingerprint.fromBuildInputs({ 'bar': 'baz', 'wobble': 'womble', }, ['a.dart', 'b.dart'])); @@ -91,7 +91,7 @@ void main() { await fs.file('a.dart').create(); await fs.file('b.dart').create(); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], properties: { @@ -106,7 +106,7 @@ void main() { await fs.file('a.dart').create(); await fs.file('b.dart').create(); - final Fingerprinter fingerprinter1 = new Fingerprinter( + final Fingerprinter fingerprinter1 = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], properties: { @@ -116,7 +116,7 @@ void main() { ); await fingerprinter1.writeFingerprint(); - final Fingerprinter fingerprinter2 = new Fingerprinter( + final Fingerprinter fingerprinter2 = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], properties: { @@ -133,7 +133,7 @@ void main() { await fs.file('depfile').writeAsString('depfile : b.dart'); // Write a valid fingerprint - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], depfilePaths: ['depfile'], @@ -146,7 +146,7 @@ void main() { // Write a corrupt depfile. await fs.file('depfile').writeAsString(''); - final Fingerprinter badFingerprinter = new Fingerprinter( + final Fingerprinter badFingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], depfilePaths: ['depfile'], @@ -164,7 +164,7 @@ void main() { await fs.file('b.dart').create(); await fs.file('out.fingerprint').writeAsString('** not JSON **'); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], depfilePaths: ['depfile'], @@ -180,7 +180,7 @@ void main() { await fs.file('a.dart').create(); await fs.file('b.dart').create(); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart', 'b.dart'], properties: { @@ -193,7 +193,7 @@ void main() { }, overrides: contextOverrides); testUsingContext('fails to write fingerprint if inputs are missing', () async { - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart'], properties: { @@ -210,7 +210,7 @@ void main() { await fs.file('ab.dart').create(); await fs.file('depfile').writeAsString('depfile : ab.dart c.dart'); - final Fingerprinter fingerprinter = new Fingerprinter( + final Fingerprinter fingerprinter = Fingerprinter( fingerprintPath: 'out.fingerprint', paths: ['a.dart'], depfilePaths: ['depfile'], @@ -230,7 +230,7 @@ void main() { const String kVersion = '123456abcdef'; setUp(() { - mockVersion = new MockFlutterVersion(); + mockVersion = MockFlutterVersion(); when(mockVersion.frameworkRevision).thenReturn(kVersion); }); @@ -238,13 +238,13 @@ void main() { MemoryFileSystem fs; setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); }); testUsingContext('throws if any input file does not exist', () async { await fs.file('a.dart').create(); expect( - () => new Fingerprint.fromBuildInputs({}, ['a.dart', 'b.dart']), + () => Fingerprint.fromBuildInputs({}, ['a.dart', 'b.dart']), throwsArgumentError, ); }, overrides: { FileSystem: () => fs }); @@ -252,7 +252,7 @@ void main() { testUsingContext('populates checksums for valid files', () async { await fs.file('a.dart').writeAsString('This is a'); await fs.file('b.dart').writeAsString('This is b'); - final Fingerprint fingerprint = new Fingerprint.fromBuildInputs({}, ['a.dart', 'b.dart']); + final Fingerprint fingerprint = Fingerprint.fromBuildInputs({}, ['a.dart', 'b.dart']); final Map jsonObject = json.decode(fingerprint.toJson()); expect(jsonObject['files'], hasLength(2)); @@ -261,14 +261,14 @@ void main() { }, overrides: { FileSystem: () => fs }); testUsingContext('includes framework version', () { - final Fingerprint fingerprint = new Fingerprint.fromBuildInputs({}, []); + final Fingerprint fingerprint = Fingerprint.fromBuildInputs({}, []); final Map jsonObject = json.decode(fingerprint.toJson()); expect(jsonObject['version'], mockVersion.frameworkRevision); }, overrides: { FlutterVersion: () => mockVersion }); testUsingContext('includes provided properties', () { - final Fingerprint fingerprint = new Fingerprint.fromBuildInputs({'a': 'A', 'b': 'B'}, []); + final Fingerprint fingerprint = Fingerprint.fromBuildInputs({'a': 'A', 'b': 'B'}, []); final Map jsonObject = json.decode(fingerprint.toJson()); expect(jsonObject['properties'], hasLength(2)); @@ -279,7 +279,7 @@ void main() { group('fromJson', () { testUsingContext('throws if JSON is invalid', () async { - expect(() => new Fingerprint.fromJson(''), throwsA(anything)); + expect(() => Fingerprint.fromJson(''), throwsA(anything)); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -297,7 +297,7 @@ void main() { 'b.dart': '6f144e08b58cd0925328610fad7ac07c', }, }); - final Fingerprint fingerprint = new Fingerprint.fromJson(jsonString); + final Fingerprint fingerprint = Fingerprint.fromJson(jsonString); final Map content = json.decode(fingerprint.toJson()); expect(content, hasLength(3)); expect(content['version'], mockVersion.frameworkRevision); @@ -318,7 +318,7 @@ void main() { 'properties':{}, 'files':{}, }); - expect(() => new Fingerprint.fromJson(jsonString), throwsArgumentError); + expect(() => Fingerprint.fromJson(jsonString), throwsArgumentError); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -328,7 +328,7 @@ void main() { 'properties':{}, 'files':{}, }); - expect(() => new Fingerprint.fromJson(jsonString), throwsArgumentError); + expect(() => Fingerprint.fromJson(jsonString), throwsArgumentError); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -337,7 +337,7 @@ void main() { final String jsonString = json.encode({ 'version': kVersion, }); - expect(new Fingerprint.fromJson(jsonString), new Fingerprint.fromBuildInputs({}, [])); + expect(Fingerprint.fromJson(jsonString), Fingerprint.fromBuildInputs({}, [])); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -352,11 +352,11 @@ void main() { }, 'files': {}, }; - final Map b = new Map.from(a); + final Map b = Map.from(a); b['properties'] = { 'buildMode': BuildMode.release.toString(), }; - expect(new Fingerprint.fromJson(json.encode(a)) == new Fingerprint.fromJson(json.encode(b)), isFalse); + expect(Fingerprint.fromJson(json.encode(a)) == Fingerprint.fromJson(json.encode(b)), isFalse); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -370,12 +370,12 @@ void main() { 'b.dart': '6f144e08b58cd0925328610fad7ac07c', }, }; - final Map b = new Map.from(a); + final Map b = Map.from(a); b['files'] = { 'a.dart': '8a21a15fad560b799f6731d436c1b698', 'b.dart': '6f144e08b58cd0925328610fad7ac07d', }; - expect(new Fingerprint.fromJson(json.encode(a)) == new Fingerprint.fromJson(json.encode(b)), isFalse); + expect(Fingerprint.fromJson(json.encode(a)) == Fingerprint.fromJson(json.encode(b)), isFalse); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -389,12 +389,12 @@ void main() { 'b.dart': '6f144e08b58cd0925328610fad7ac07c', }, }; - final Map b = new Map.from(a); + final Map b = Map.from(a); b['files'] = { 'a.dart': '8a21a15fad560b799f6731d436c1b698', 'c.dart': '6f144e08b58cd0925328610fad7ac07d', }; - expect(new Fingerprint.fromJson(json.encode(a)) == new Fingerprint.fromJson(json.encode(b)), isFalse); + expect(Fingerprint.fromJson(json.encode(a)) == Fingerprint.fromJson(json.encode(b)), isFalse); }, overrides: { FlutterVersion: () => mockVersion, }); @@ -412,15 +412,15 @@ void main() { 'b.dart': '6f144e08b58cd0925328610fad7ac07c', }, }; - expect(new Fingerprint.fromJson(json.encode(a)) == new Fingerprint.fromJson(json.encode(a)), isTrue); + expect(Fingerprint.fromJson(json.encode(a)) == Fingerprint.fromJson(json.encode(a)), isTrue); }, overrides: { FlutterVersion: () => mockVersion, }); }); group('hashCode', () { testUsingContext('is consistent with equals, even if map entries are reordered', () async { - final Fingerprint a = new Fingerprint.fromJson('{"version":"$kVersion","properties":{"a":"A","b":"B"},"files":{}}'); - final Fingerprint b = new Fingerprint.fromJson('{"version":"$kVersion","properties":{"b":"B","a":"A"},"files":{}}'); + final Fingerprint a = Fingerprint.fromJson('{"version":"$kVersion","properties":{"a":"A","b":"B"},"files":{}}'); + final Fingerprint b = Fingerprint.fromJson('{"version":"$kVersion","properties":{"b":"B","a":"A"},"files":{}}'); expect(a, b); expect(a.hashCode, b.hashCode); }, overrides: { @@ -434,7 +434,7 @@ void main() { MemoryFileSystem fs; setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); }); final Map contextOverrides = { FileSystem: () => fs }; diff --git a/packages/flutter_tools/test/base/flags_test.dart b/packages/flutter_tools/test/base/flags_test.dart index cd79cbf7c7..8f6569037e 100644 --- a/packages/flutter_tools/test/base/flags_test.dart +++ b/packages/flutter_tools/test/base/flags_test.dart @@ -18,7 +18,7 @@ void main() { Future runCommand(Iterable flags, _TestMethod testMethod) async { final List args = ['test']..addAll(flags); - final _TestCommand command = new _TestCommand(testMethod); + final _TestCommand command = _TestCommand(testMethod); await createTestCommandRunner(command).run(args); } diff --git a/packages/flutter_tools/test/base/io_test.dart b/packages/flutter_tools/test/base/io_test.dart index be3cd3c410..21013d5829 100644 --- a/packages/flutter_tools/test/base/io_test.dart +++ b/packages/flutter_tools/test/base/io_test.dart @@ -15,9 +15,9 @@ void main() { group('ProcessSignal', () { testUsingContext('signals are properly delegated', () async { - final MockIoProcessSignal mockSignal = new MockIoProcessSignal(); - final ProcessSignal signalUnderTest = new ProcessSignal(mockSignal); - final StreamController controller = new StreamController(); + final MockIoProcessSignal mockSignal = MockIoProcessSignal(); + final ProcessSignal signalUnderTest = ProcessSignal(mockSignal); + final StreamController controller = StreamController(); when(mockSignal.watch()).thenAnswer((Invocation invocation) => controller.stream); controller.add(mockSignal); diff --git a/packages/flutter_tools/test/base/logger_test.dart b/packages/flutter_tools/test/base/logger_test.dart index c2fe6056bb..fd8a1bdf8a 100644 --- a/packages/flutter_tools/test/base/logger_test.dart +++ b/packages/flutter_tools/test/base/logger_test.dart @@ -15,8 +15,8 @@ import '../src/mocks.dart'; void main() { group('AppContext', () { test('error', () async { - final BufferLogger mockLogger = new BufferLogger(); - final VerboseLogger verboseLogger = new VerboseLogger(mockLogger); + final BufferLogger mockLogger = BufferLogger(); + final VerboseLogger verboseLogger = VerboseLogger(mockLogger); verboseLogger.supportsColor = false; verboseLogger.printStatus('Hey Hey Hey Hey'); @@ -35,13 +35,13 @@ void main() { AnsiSpinner ansiSpinner; AnsiStatus ansiStatus; int called; - final RegExp secondDigits = new RegExp(r'[^\b]\b\b\b\b\b[0-9]+[.][0-9]+(?:s|ms)'); + final RegExp secondDigits = RegExp(r'[^\b]\b\b\b\b\b[0-9]+[.][0-9]+(?:s|ms)'); setUp(() { - mockStdio = new MockStdio(); - ansiSpinner = new AnsiSpinner(); + mockStdio = MockStdio(); + ansiSpinner = AnsiSpinner(); called = 0; - ansiStatus = new AnsiStatus( + ansiStatus = AnsiStatus( message: 'Hello world', expectSlowOperation: true, padding: 20, @@ -133,7 +133,7 @@ void main() { ]); }, overrides: { Stdio: () => mockStdio, - Logger: () => new StdoutLogger(), + Logger: () => StdoutLogger(), }); testUsingContext('sequential startProgress calls with VerboseLogger and StdoutLogger', () async { @@ -148,7 +148,7 @@ void main() { ]); }, overrides: { Stdio: () => mockStdio, - Logger: () => new VerboseLogger(new StdoutLogger()), + Logger: () => VerboseLogger(StdoutLogger()), }); testUsingContext('sequential startProgress calls with BufferLogger', () async { @@ -157,7 +157,7 @@ void main() { final BufferLogger logger = context[Logger]; expect(logger.statusText, 'AAA\nBBB\n'); }, overrides: { - Logger: () => new BufferLogger(), + Logger: () => BufferLogger(), }); }); } diff --git a/packages/flutter_tools/test/base/logs_test.dart b/packages/flutter_tools/test/base/logs_test.dart index ff74ed1ef8..ab503c66de 100644 --- a/packages/flutter_tools/test/base/logs_test.dart +++ b/packages/flutter_tools/test/base/logs_test.dart @@ -12,7 +12,7 @@ import '../src/mocks.dart'; void main() { group('logs', () { testUsingContext('fail with a bad device id', () async { - final LogsCommand command = new LogsCommand(); + final LogsCommand command = LogsCommand(); applyMocksToCommand(command); try { await createTestCommandRunner(command).run(['-d', 'abc123', 'logs']); diff --git a/packages/flutter_tools/test/base/net_test.dart b/packages/flutter_tools/test/base/net_test.dart index 05ef212111..9eb65b0887 100644 --- a/packages/flutter_tools/test/base/net_test.dart +++ b/packages/flutter_tools/test/base/net_test.dart @@ -14,7 +14,7 @@ import '../src/context.dart'; void main() { testUsingContext('retry from 500', () async { String error; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { fetchUrl(Uri.parse('http://example.invalid/')).then((List value) { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { @@ -32,12 +32,12 @@ void main() { expect(testLogger.errorText, isEmpty); expect(error, isNull); }, overrides: { - HttpClientFactory: () => () => new MockHttpClient(500), + HttpClientFactory: () => () => MockHttpClient(500), }); testUsingContext('retry from network error', () async { String error; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { fetchUrl(Uri.parse('http://example.invalid/')).then((List value) { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { @@ -55,12 +55,12 @@ void main() { expect(testLogger.errorText, isEmpty); expect(error, isNull); }, overrides: { - HttpClientFactory: () => () => new MockHttpClient(200), + HttpClientFactory: () => () => MockHttpClient(200), }); testUsingContext('retry from SocketException', () async { String error; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { fetchUrl(Uri.parse('http://example.invalid/')).then((List value) { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { @@ -79,14 +79,14 @@ void main() { expect(error, isNull); expect(testLogger.traceText, contains('Download error: SocketException')); }, overrides: { - HttpClientFactory: () => () => new MockHttpClientThrowing( + HttpClientFactory: () => () => MockHttpClientThrowing( const io.SocketException('test exception handling'), ), }); testUsingContext('no retry from HandshakeException', () async { String error; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { fetchUrl(Uri.parse('http://example.invalid/')).then((List value) { error = 'test completed unexpectedly'; }, onError: (dynamic exception) { @@ -99,7 +99,7 @@ void main() { expect(error, startsWith('test failed')); expect(testLogger.traceText, contains('HandshakeException')); }, overrides: { - HttpClientFactory: () => () => new MockHttpClientThrowing( + HttpClientFactory: () => () => MockHttpClientThrowing( const io.HandshakeException('test exception handling'), ), }); @@ -128,7 +128,7 @@ class MockHttpClient implements io.HttpClient { @override Future getUrl(Uri url) async { - return new MockHttpClientRequest(statusCode); + return MockHttpClientRequest(statusCode); } @override @@ -144,7 +144,7 @@ class MockHttpClientRequest implements io.HttpClientRequest { @override Future close() async { - return new MockHttpClientResponse(statusCode); + return MockHttpClientResponse(statusCode); } @override @@ -166,7 +166,7 @@ class MockHttpClientResponse extends Stream> implements io.HttpClientR StreamSubscription> listen(void onData(List event), { Function onError, void onDone(), bool cancelOnError }) { - return new Stream>.fromFuture(new Future>.error(const io.SocketException('test'))) + return Stream>.fromFuture(Future>.error(const io.SocketException('test'))) .listen(onData, onError: onError, onDone: onDone, cancelOnError: cancelOnError); } diff --git a/packages/flutter_tools/test/base/os_test.dart b/packages/flutter_tools/test/base/os_test.dart index d4385d7cc7..21752a4bda 100644 --- a/packages/flutter_tools/test/base/os_test.dart +++ b/packages/flutter_tools/test/base/os_test.dart @@ -20,42 +20,42 @@ void main() { ProcessManager mockProcessManager; setUp(() { - mockProcessManager = new MockProcessManager(); + mockProcessManager = MockProcessManager(); }); group('which on POSIX', () { testUsingContext('returns null when executable does not exist', () async { when(mockProcessManager.runSync(['which', kExecutable])) - .thenReturn(new ProcessResult(0, 1, null, null)); - final OperatingSystemUtils utils = new OperatingSystemUtils(); + .thenReturn(ProcessResult(0, 1, null, null)); + final OperatingSystemUtils utils = OperatingSystemUtils(); expect(utils.which(kExecutable), isNull); }, overrides: { ProcessManager: () => mockProcessManager, - Platform: () => new FakePlatform(operatingSystem: 'linux') + Platform: () => FakePlatform(operatingSystem: 'linux') }); testUsingContext('returns exactly one result', () async { when(mockProcessManager.runSync(['which', 'foo'])) - .thenReturn(new ProcessResult(0, 0, kPath1, null)); - final OperatingSystemUtils utils = new OperatingSystemUtils(); + .thenReturn(ProcessResult(0, 0, kPath1, null)); + final OperatingSystemUtils utils = OperatingSystemUtils(); expect(utils.which(kExecutable).path, kPath1); }, overrides: { ProcessManager: () => mockProcessManager, - Platform: () => new FakePlatform(operatingSystem: 'linux') + Platform: () => FakePlatform(operatingSystem: 'linux') }); testUsingContext('returns all results for whichAll', () async { when(mockProcessManager.runSync(['which', '-a', kExecutable])) - .thenReturn(new ProcessResult(0, 0, '$kPath1\n$kPath2', null)); - final OperatingSystemUtils utils = new OperatingSystemUtils(); + .thenReturn(ProcessResult(0, 0, '$kPath1\n$kPath2', null)); + final OperatingSystemUtils utils = OperatingSystemUtils(); final List result = utils.whichAll(kExecutable); expect(result, hasLength(2)); expect(result[0].path, kPath1); expect(result[1].path, kPath2); }, overrides: { ProcessManager: () => mockProcessManager, - Platform: () => new FakePlatform(operatingSystem: 'linux') + Platform: () => FakePlatform(operatingSystem: 'linux') }); }); @@ -63,35 +63,35 @@ void main() { testUsingContext('returns null when executable does not exist', () async { when(mockProcessManager.runSync(['where', kExecutable])) - .thenReturn(new ProcessResult(0, 1, null, null)); - final OperatingSystemUtils utils = new OperatingSystemUtils(); + .thenReturn(ProcessResult(0, 1, null, null)); + final OperatingSystemUtils utils = OperatingSystemUtils(); expect(utils.which(kExecutable), isNull); }, overrides: { ProcessManager: () => mockProcessManager, - Platform: () => new FakePlatform(operatingSystem: 'windows') + Platform: () => FakePlatform(operatingSystem: 'windows') }); testUsingContext('returns exactly one result', () async { when(mockProcessManager.runSync(['where', 'foo'])) - .thenReturn(new ProcessResult(0, 0, '$kPath1\n$kPath2', null)); - final OperatingSystemUtils utils = new OperatingSystemUtils(); + .thenReturn(ProcessResult(0, 0, '$kPath1\n$kPath2', null)); + final OperatingSystemUtils utils = OperatingSystemUtils(); expect(utils.which(kExecutable).path, kPath1); }, overrides: { ProcessManager: () => mockProcessManager, - Platform: () => new FakePlatform(operatingSystem: 'windows') + Platform: () => FakePlatform(operatingSystem: 'windows') }); testUsingContext('returns all results for whichAll', () async { when(mockProcessManager.runSync(['where', kExecutable])) - .thenReturn(new ProcessResult(0, 0, '$kPath1\n$kPath2', null)); - final OperatingSystemUtils utils = new OperatingSystemUtils(); + .thenReturn(ProcessResult(0, 0, '$kPath1\n$kPath2', null)); + final OperatingSystemUtils utils = OperatingSystemUtils(); final List result = utils.whichAll(kExecutable); expect(result, hasLength(2)); expect(result[0].path, kPath1); expect(result[1].path, kPath2); }, overrides: { ProcessManager: () => mockProcessManager, - Platform: () => new FakePlatform(operatingSystem: 'windows') + Platform: () => FakePlatform(operatingSystem: 'windows') }); }); } diff --git a/packages/flutter_tools/test/base/os_utils_test.dart b/packages/flutter_tools/test/base/os_utils_test.dart index 27c9849707..6df34075cc 100644 --- a/packages/flutter_tools/test/base/os_utils_test.dart +++ b/packages/flutter_tools/test/base/os_utils_test.dart @@ -33,7 +33,7 @@ void main() { expect(mode.substring(0, 3), endsWith('x')); } }, overrides: { - OperatingSystemUtils: () => new OperatingSystemUtils(), + OperatingSystemUtils: () => OperatingSystemUtils(), }); }); } diff --git a/packages/flutter_tools/test/base/terminal_test.dart b/packages/flutter_tools/test/base/terminal_test.dart index 9660fc0b6e..53d9221d8e 100644 --- a/packages/flutter_tools/test/base/terminal_test.dart +++ b/packages/flutter_tools/test/base/terminal_test.dart @@ -14,14 +14,14 @@ void main() { AnsiTerminal terminalUnderTest; setUp(() { - terminalUnderTest = new TestTerminal(); + terminalUnderTest = TestTerminal(); }); testUsingContext('character prompt', () async { - mockStdInStream = new Stream.fromFutures(>[ - new Future.value('d'), // Not in accepted list. - new Future.value('\n'), // Not in accepted list - new Future.value('b'), + mockStdInStream = Stream.fromFutures(>[ + Future.value('d'), // Not in accepted list. + Future.value('\n'), // Not in accepted list + Future.value('b'), ]).asBroadcastStream(); final String choice = await terminalUnderTest.promptForCharInput( @@ -39,8 +39,8 @@ void main() { }); testUsingContext('default character choice without displayAcceptedCharacters', () async { - mockStdInStream = new Stream.fromFutures(>[ - new Future.value('\n'), // Not in accepted list + mockStdInStream = Stream.fromFutures(>[ + Future.value('\n'), // Not in accepted list ]).asBroadcastStream(); final String choice = await terminalUnderTest.promptForCharInput( diff --git a/packages/flutter_tools/test/base_utils_test.dart b/packages/flutter_tools/test/base_utils_test.dart index d4d032f171..8cb771aaa4 100644 --- a/packages/flutter_tools/test/base_utils_test.dart +++ b/packages/flutter_tools/test/base_utils_test.dart @@ -11,7 +11,7 @@ import 'src/common.dart'; void main() { group('ItemListNotifier', () { test('sends notifications', () async { - final ItemListNotifier list = new ItemListNotifier(); + final ItemListNotifier list = ItemListNotifier(); expect(list.items, isEmpty); final Future> addedStreamItems = list.onAdded.toList(); diff --git a/packages/flutter_tools/test/cache_test.dart b/packages/flutter_tools/test/cache_test.dart index 4797379735..2c3e03fc65 100644 --- a/packages/flutter_tools/test/cache_test.dart +++ b/packages/flutter_tools/test/cache_test.dart @@ -40,55 +40,55 @@ void main() { await Cache.lock(); Cache.checkLockAcquired(); }, overrides: { - FileSystem: () => new MockFileSystem(), + FileSystem: () => MockFileSystem(), }); testUsingContext('should not throw when FLUTTER_ALREADY_LOCKED is set', () async { Cache.checkLockAcquired(); }, overrides: { - Platform: () => new FakePlatform()..environment = {'FLUTTER_ALREADY_LOCKED': 'true'}, + Platform: () => FakePlatform()..environment = {'FLUTTER_ALREADY_LOCKED': 'true'}, }); }); group('Cache', () { test('should not be up to date, if some cached artifact is not', () { - final CachedArtifact artifact1 = new MockCachedArtifact(); - final CachedArtifact artifact2 = new MockCachedArtifact(); + final CachedArtifact artifact1 = MockCachedArtifact(); + final CachedArtifact artifact2 = MockCachedArtifact(); when(artifact1.isUpToDate()).thenReturn(true); when(artifact2.isUpToDate()).thenReturn(false); - final Cache cache = new Cache(artifacts: [artifact1, artifact2]); + final Cache cache = Cache(artifacts: [artifact1, artifact2]); expect(cache.isUpToDate(), isFalse); }); test('should be up to date, if all cached artifacts are', () { - final CachedArtifact artifact1 = new MockCachedArtifact(); - final CachedArtifact artifact2 = new MockCachedArtifact(); + final CachedArtifact artifact1 = MockCachedArtifact(); + final CachedArtifact artifact2 = MockCachedArtifact(); when(artifact1.isUpToDate()).thenReturn(true); when(artifact2.isUpToDate()).thenReturn(true); - final Cache cache = new Cache(artifacts: [artifact1, artifact2]); + final Cache cache = Cache(artifacts: [artifact1, artifact2]); expect(cache.isUpToDate(), isTrue); }); test('should update cached artifacts which are not up to date', () async { - final CachedArtifact artifact1 = new MockCachedArtifact(); - final CachedArtifact artifact2 = new MockCachedArtifact(); + final CachedArtifact artifact1 = MockCachedArtifact(); + final CachedArtifact artifact2 = MockCachedArtifact(); when(artifact1.isUpToDate()).thenReturn(true); when(artifact2.isUpToDate()).thenReturn(false); - final Cache cache = new Cache(artifacts: [artifact1, artifact2]); + final Cache cache = Cache(artifacts: [artifact1, artifact2]); await cache.updateAll(); verifyNever(artifact1.update()); verify(artifact2.update()); }); testUsingContext('failed storage.googleapis.com download shows China warning', () async { - final CachedArtifact artifact1 = new MockCachedArtifact(); - final CachedArtifact artifact2 = new MockCachedArtifact(); + final CachedArtifact artifact1 = MockCachedArtifact(); + final CachedArtifact artifact2 = MockCachedArtifact(); when(artifact1.isUpToDate()).thenReturn(false); when(artifact2.isUpToDate()).thenReturn(false); - final MockInternetAddress address = new MockInternetAddress(); + final MockInternetAddress address = MockInternetAddress(); when(address.host).thenReturn('storage.googleapis.com'); - when(artifact1.update()).thenThrow(new SocketException( + when(artifact1.update()).thenThrow(SocketException( 'Connection reset by peer', address: address, )); - final Cache cache = new Cache(artifacts: [artifact1, artifact2]); + final Cache cache = Cache(artifacts: [artifact1, artifact2]); try { await cache.updateAll(); fail('Mock thrown exception expected'); @@ -109,23 +109,23 @@ void main() { expect(flattenNameSubdirs(Uri.parse('http://docs.flutter.io/foo/bar')), 'docs.flutter.io/foo/bar'); expect(flattenNameSubdirs(Uri.parse('https://www.flutter.io')), 'www.flutter.io'); }, overrides: { - FileSystem: () => new MockFileSystem(), + FileSystem: () => MockFileSystem(), }); } class MockFileSystem extends ForwardingFileSystem { - MockFileSystem() : super(new MemoryFileSystem()); + MockFileSystem() : super(MemoryFileSystem()); @override File file(dynamic path) { - return new MockFile(); + return MockFile(); } } class MockFile extends Mock implements File { @override Future open({FileMode mode = FileMode.read}) async { - return new MockRandomAccessFile(); + return MockRandomAccessFile(); } } diff --git a/packages/flutter_tools/test/channel_test.dart b/packages/flutter_tools/test/channel_test.dart index ff832d5ca7..ed12dedd66 100644 --- a/packages/flutter_tools/test/channel_test.dart +++ b/packages/flutter_tools/test/channel_test.dart @@ -19,30 +19,30 @@ import 'src/common.dart'; import 'src/context.dart'; Process createMockProcess({int exitCode = 0, String stdout = '', String stderr = ''}) { - final Stream> stdoutStream = new Stream>.fromIterable(>[ + final Stream> stdoutStream = Stream>.fromIterable(>[ utf8.encode(stdout), ]); - final Stream> stderrStream = new Stream>.fromIterable(>[ + final Stream> stderrStream = Stream>.fromIterable(>[ utf8.encode(stderr), ]); - final Process process = new MockProcess(); + final Process process = MockProcess(); when(process.stdout).thenAnswer((_) => stdoutStream); when(process.stderr).thenAnswer((_) => stderrStream); - when(process.exitCode).thenAnswer((_) => new Future.value(exitCode)); + when(process.exitCode).thenAnswer((_) => Future.value(exitCode)); return process; } void main() { group('channel', () { - final MockProcessManager mockProcessManager = new MockProcessManager(); + final MockProcessManager mockProcessManager = MockProcessManager(); setUpAll(() { Cache.disableLocking(); }); testUsingContext('list', () async { - final ChannelCommand command = new ChannelCommand(); + final ChannelCommand command = ChannelCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['channel']); expect(testLogger.errorText, hasLength(0)); @@ -62,9 +62,9 @@ void main() { ['git', 'branch', '-r'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(process)); + )).thenAnswer((_) => Future.value(process)); - final ChannelCommand command = new ChannelCommand(); + final ChannelCommand command = ChannelCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['channel']); @@ -93,19 +93,19 @@ void main() { ['git', 'fetch'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(createMockProcess())); + )).thenAnswer((_) => Future.value(createMockProcess())); when(mockProcessManager.start( ['git', 'show-ref', '--verify', '--quiet', 'refs/heads/beta'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(createMockProcess())); + )).thenAnswer((_) => Future.value(createMockProcess())); when(mockProcessManager.start( ['git', 'checkout', 'beta', '--'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(createMockProcess())); + )).thenAnswer((_) => Future.value(createMockProcess())); - final ChannelCommand command = new ChannelCommand(); + final ChannelCommand command = ChannelCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['channel', 'beta']); @@ -129,7 +129,7 @@ void main() { expect(testLogger.errorText, hasLength(0)); }, overrides: { ProcessManager: () => mockProcessManager, - FileSystem: () => new MemoryFileSystem(), + FileSystem: () => MemoryFileSystem(), }); // This verifies that bug https://github.com/flutter/flutter/issues/21134 @@ -139,17 +139,17 @@ void main() { ['git', 'fetch'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(createMockProcess())); + )).thenAnswer((_) => Future.value(createMockProcess())); when(mockProcessManager.start( ['git', 'show-ref', '--verify', '--quiet', 'refs/heads/beta'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(createMockProcess())); + )).thenAnswer((_) => Future.value(createMockProcess())); when(mockProcessManager.start( ['git', 'checkout', 'beta', '--'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenAnswer((_) => new Future.value(createMockProcess())); + )).thenAnswer((_) => Future.value(createMockProcess())); final File versionCheckFile = Cache.instance.getStampFileFor( VersionCheckStamp.kFlutterVersionCheckStampFile, @@ -165,7 +165,7 @@ void main() { } '''); - final ChannelCommand command = new ChannelCommand(); + final ChannelCommand command = ChannelCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['channel', 'beta']); @@ -190,7 +190,7 @@ void main() { expect(versionCheckFile.existsSync(), isFalse); }, overrides: { ProcessManager: () => mockProcessManager, - FileSystem: () => new MemoryFileSystem(), + FileSystem: () => MemoryFileSystem(), }); }); } diff --git a/packages/flutter_tools/test/commands/analyze_continuously_test.dart b/packages/flutter_tools/test/commands/analyze_continuously_test.dart index 49763f55f8..d03cf66a6e 100644 --- a/packages/flutter_tools/test/commands/analyze_continuously_test.dart +++ b/packages/flutter_tools/test/commands/analyze_continuously_test.dart @@ -34,7 +34,7 @@ void main() { await pubGet(context: PubContext.flutterTests, directory: tempDir.path); - server = new AnalysisServer(dartSdkPath, [tempDir.path]); + server = AnalysisServer(dartSdkPath, [tempDir.path]); int errorCount = 0; final Future onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; @@ -54,7 +54,7 @@ void main() { await pubGet(context: PubContext.flutterTests, directory: tempDir.path); - server = new AnalysisServer(dartSdkPath, [tempDir.path]); + server = AnalysisServer(dartSdkPath, [tempDir.path]); int errorCount = 0; final Future onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; @@ -73,7 +73,7 @@ void main() { testUsingContext('Returns no errors when source is error-free', () async { const String contents = "StringBuffer bar = StringBuffer('baz');"; tempDir.childFile('main.dart').writeAsStringSync(contents); - server = new AnalysisServer(dartSdkPath, [tempDir.path]); + server = AnalysisServer(dartSdkPath, [tempDir.path]); int errorCount = 0; final Future onDone = server.onAnalyzing.where((bool analyzing) => analyzing == false).first; diff --git a/packages/flutter_tools/test/commands/analyze_once_test.dart b/packages/flutter_tools/test/commands/analyze_once_test.dart index 8ada5d0f59..638c60e6fa 100644 --- a/packages/flutter_tools/test/commands/analyze_once_test.dart +++ b/packages/flutter_tools/test/commands/analyze_once_test.dart @@ -40,7 +40,7 @@ void main() { // Create a project to be analyzed testUsingContext('flutter create', () async { await runCommand( - command: new CreateCommand(), + command: CreateCommand(), arguments: ['create', projectPath], statusTextContains: [ 'All done!', @@ -53,7 +53,7 @@ void main() { // Analyze in the current directory - no arguments testUsingContext('working directory', () async { await runCommand( - command: new AnalyzeCommand(workingDirectory: fs.directory(projectPath)), + command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)), arguments: ['analyze'], statusTextContains: ['No issues found!'], ); @@ -62,7 +62,7 @@ void main() { // Analyze a specific file outside the current directory testUsingContext('passing one file throws', () async { await runCommand( - command: new AnalyzeCommand(), + command: AnalyzeCommand(), arguments: ['analyze', libMain.path], toolExit: true, exitMessageContains: 'is not a directory', @@ -89,7 +89,7 @@ void main() { // Analyze in the current directory - no arguments await runCommand( - command: new AnalyzeCommand(workingDirectory: fs.directory(projectPath)), + command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)), arguments: ['analyze'], statusTextContains: [ 'Analyzing', @@ -115,7 +115,7 @@ void main() { // Analyze in the current directory - no arguments await runCommand( - command: new AnalyzeCommand(workingDirectory: fs.directory(projectPath)), + command: AnalyzeCommand(workingDirectory: fs.directory(projectPath)), arguments: ['analyze'], statusTextContains: [ 'Analyzing', @@ -149,7 +149,7 @@ void bar() { // Analyze in the current directory - no arguments await runCommand( - command: new AnalyzeCommand(workingDirectory: tempDir), + command: AnalyzeCommand(workingDirectory: tempDir), arguments: ['analyze'], statusTextContains: [ 'Analyzing', @@ -170,7 +170,7 @@ StringBuffer bar = StringBuffer('baz'); tempDir.childFile('main.dart').writeAsStringSync(contents); try { await runCommand( - command: new AnalyzeCommand(workingDirectory: fs.directory(tempDir)), + command: AnalyzeCommand(workingDirectory: fs.directory(tempDir)), arguments: ['analyze'], statusTextContains: ['No issues found!'], ); diff --git a/packages/flutter_tools/test/commands/analyze_test.dart b/packages/flutter_tools/test/commands/analyze_test.dart index d86b5745c6..115a3d0c47 100644 --- a/packages/flutter_tools/test/commands/analyze_test.dart +++ b/packages/flutter_tools/test/commands/analyze_test.dart @@ -17,7 +17,7 @@ void main() { Directory tempDir; setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); fs.directory(_kFlutterRoot).createSync(recursive: true); Cache.flutterRoot = _kFlutterRoot; tempDir = fs.systemTempDirectory.createTempSync('flutter_analysis_test.'); diff --git a/packages/flutter_tools/test/commands/attach_test.dart b/packages/flutter_tools/test/commands/attach_test.dart index 8326f2b541..9f4e67c397 100644 --- a/packages/flutter_tools/test/commands/attach_test.dart +++ b/packages/flutter_tools/test/commands/attach_test.dart @@ -21,7 +21,7 @@ import '../src/mocks.dart'; void main() { group('attach', () { - final FileSystem testFileSystem = new MemoryFileSystem( + final FileSystem testFileSystem = MemoryFileSystem( style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle .posix, ); @@ -41,9 +41,9 @@ void main() { MockAndroidDevice device; setUp(() { - mockLogReader = new MockDeviceLogReader(); - portForwarder = new MockPortForwarder(); - device = new MockAndroidDevice(); + mockLogReader = MockDeviceLogReader(); + portForwarder = MockPortForwarder(); + device = MockAndroidDevice(); when(device.getLogReader()).thenAnswer((_) { // Now that the reader is used, start writing messages to it. Timer.run(() { @@ -58,7 +58,7 @@ void main() { when(portForwarder.forward(devicePort, hostPort: anyNamed('hostPort'))) .thenAnswer((_) async => hostPort); when(portForwarder.forwardedPorts).thenReturn( - [new ForwardedPort(hostPort, devicePort)]); + [ForwardedPort(hostPort, devicePort)]); when(portForwarder.unforward(any)).thenAnswer((_) async => null); // We cannot add the device to a device manager because that is @@ -75,7 +75,7 @@ void main() { testUsingContext('finds observatory port and forwards', () async { testDeviceManager.addDevice(device); - final AttachCommand command = new AttachCommand(); + final AttachCommand command = AttachCommand(); await createTestCommandRunner(command).run(['attach']); @@ -94,7 +94,7 @@ void main() { const String projectRoot = '/build-output/project-root'; const String outputDill = '/tmp/output.dill'; - final MockHotRunnerFactory mockHotRunnerFactory = new MockHotRunnerFactory(); + final MockHotRunnerFactory mockHotRunnerFactory = MockHotRunnerFactory(); when( mockHotRunnerFactory.build( any, @@ -105,9 +105,9 @@ void main() { packagesFilePath: anyNamed('packagesFilePath'), usesTerminalUI: anyNamed('usesTerminalUI'), ), - )..thenReturn(new MockHotRunner()); + )..thenReturn(MockHotRunner()); - final AttachCommand command = new AttachCommand( + final AttachCommand command = AttachCommand( hotRunnerFactory: mockHotRunnerFactory, ); await createTestCommandRunner(command).run([ @@ -156,22 +156,22 @@ void main() { testUsingContext('selects specified target', () async { const int devicePort = 499; const int hostPort = 42; - final MockDeviceLogReader mockLogReader = new MockDeviceLogReader(); - final MockPortForwarder portForwarder = new MockPortForwarder(); - final MockAndroidDevice device = new MockAndroidDevice(); - final MockHotRunnerFactory mockHotRunnerFactory = new MockHotRunnerFactory(); + final MockDeviceLogReader mockLogReader = MockDeviceLogReader(); + final MockPortForwarder portForwarder = MockPortForwarder(); + final MockAndroidDevice device = MockAndroidDevice(); + final MockHotRunnerFactory mockHotRunnerFactory = MockHotRunnerFactory(); when(device.portForwarder).thenReturn(portForwarder); when(portForwarder.forward(devicePort, hostPort: anyNamed('hostPort'))) .thenAnswer((_) async => hostPort); when(portForwarder.forwardedPorts).thenReturn( - [new ForwardedPort(hostPort, devicePort)]); + [ForwardedPort(hostPort, devicePort)]); when(portForwarder.unforward(any)).thenAnswer((_) async => null); when(mockHotRunnerFactory.build(any, target: anyNamed('target'), debuggingOptions: anyNamed('debuggingOptions'), packagesFilePath: anyNamed('packagesFilePath'), usesTerminalUI: anyNamed('usesTerminalUI'))).thenReturn( - new MockHotRunner()); + MockHotRunner()); testDeviceManager.addDevice(device); when(device.getLogReader()).thenAnswer((_) { @@ -190,7 +190,7 @@ void main() { // Delete the main.dart file to be sure that attach works without it. fs.file('lib/main.dart').deleteSync(); - final AttachCommand command = new AttachCommand( + final AttachCommand command = AttachCommand( hotRunnerFactory: mockHotRunnerFactory); await createTestCommandRunner(command).run( ['attach', '-t', foo.path, '-v']); @@ -207,17 +207,17 @@ void main() { testUsingContext('forwards to given port', () async { const int devicePort = 499; const int hostPort = 42; - final MockPortForwarder portForwarder = new MockPortForwarder(); - final MockAndroidDevice device = new MockAndroidDevice(); + final MockPortForwarder portForwarder = MockPortForwarder(); + final MockAndroidDevice device = MockAndroidDevice(); when(device.portForwarder).thenReturn(portForwarder); when(portForwarder.forward(devicePort)).thenAnswer((_) async => hostPort); when(portForwarder.forwardedPorts).thenReturn( - [new ForwardedPort(hostPort, devicePort)]); + [ForwardedPort(hostPort, devicePort)]); when(portForwarder.unforward(any)).thenAnswer((_) async => null); testDeviceManager.addDevice(device); - final AttachCommand command = new AttachCommand(); + final AttachCommand command = AttachCommand(); await createTestCommandRunner(command).run( ['attach', '--debug-port', '$devicePort']); @@ -228,7 +228,7 @@ void main() { },); testUsingContext('exits when no device connected', () async { - final AttachCommand command = new AttachCommand(); + final AttachCommand command = AttachCommand(); await expectLater( createTestCommandRunner(command).run(['attach']), throwsA(isInstanceOf()), @@ -240,7 +240,7 @@ void main() { testUsingContext('exits when multiple devices connected', () async { Device aDeviceWithId(String id) { - final MockAndroidDevice device = new MockAndroidDevice(); + final MockAndroidDevice device = MockAndroidDevice(); when(device.name).thenReturn('d$id'); when(device.id).thenReturn(id); when(device.isLocalEmulator).thenAnswer((_) async => false); @@ -248,7 +248,7 @@ void main() { return device; } - final AttachCommand command = new AttachCommand(); + final AttachCommand command = AttachCommand(); testDeviceManager.addDevice(aDeviceWithId('xx1')); testDeviceManager.addDevice(aDeviceWithId('yy2')); await expectLater( diff --git a/packages/flutter_tools/test/commands/config_test.dart b/packages/flutter_tools/test/commands/config_test.dart index d383da499d..c93c20420b 100644 --- a/packages/flutter_tools/test/commands/config_test.dart +++ b/packages/flutter_tools/test/commands/config_test.dart @@ -19,14 +19,14 @@ void main() { MockAndroidSdk mockAndroidSdk; setUp(() { - mockAndroidStudio = new MockAndroidStudio(); - mockAndroidSdk = new MockAndroidSdk(); + mockAndroidStudio = MockAndroidStudio(); + mockAndroidSdk = MockAndroidSdk(); }); group('config', () { testUsingContext('machine flag', () async { final BufferLogger logger = context[Logger]; - final ConfigCommand command = new ConfigCommand(); + final ConfigCommand command = ConfigCommand(); await command.handleMachine(); expect(logger.statusText, isNotEmpty); diff --git a/packages/flutter_tools/test/commands/create_test.dart b/packages/flutter_tools/test/commands/create_test.dart index 33530b6bd6..ab848f0220 100644 --- a/packages/flutter_tools/test/commands/create_test.dart +++ b/packages/flutter_tools/test/commands/create_test.dart @@ -34,10 +34,10 @@ void main() { }); setUp(() { - loggingProcessManager = new LoggingProcessManager(); + loggingProcessManager = LoggingProcessManager(); tempDir = fs.systemTempDirectory.createTempSync('flutter_tools_create_test.'); projectDir = tempDir.childDirectory('flutter_project'); - mockFlutterVersion = new MockFlutterVersion(); + mockFlutterVersion = MockFlutterVersion(); }); tearDown(() { @@ -239,7 +239,7 @@ void main() { when(mockFlutterVersion.frameworkRevision).thenReturn(frameworkRevision); when(mockFlutterVersion.channel).thenReturn(frameworkChannel); - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['create', '--no-pub', '--org', 'com.foo.bar', projectDir.path]); @@ -303,7 +303,7 @@ void main() { testUsingContext('can re-gen over existing project', () async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['create', '--no-pub', projectDir.path]); @@ -394,7 +394,7 @@ void main() { testUsingContext('produces sensible error message', () async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); expect( @@ -406,7 +406,7 @@ void main() { // Verify that we fail with an error code when the file exists. testUsingContext('fails when file exists', () async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); final File existingFile = fs.file('${projectDir.path.toString()}/bad'); if (!existingFile.existsSync()) @@ -419,7 +419,7 @@ void main() { testUsingContext('fails when invalid package name', () async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); expect( runner.run(['create', fs.path.join(projectDir.path, 'invalidName')]), @@ -430,7 +430,7 @@ void main() { testUsingContext('invokes pub offline when requested', () async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['create', '--pub', '--offline', projectDir.path]); @@ -446,7 +446,7 @@ void main() { testUsingContext('invokes pub online when offline not requested', () async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['create', '--pub', projectDir.path]); @@ -465,7 +465,7 @@ Future _createProject( Directory dir, List createArgs, List expectedPaths, { List unexpectedPaths = const [], bool plugin = false}) async { Cache.flutterRoot = '../..'; - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); final List args = ['create']; args.addAll(createArgs); diff --git a/packages/flutter_tools/test/commands/daemon_test.dart b/packages/flutter_tools/test/commands/daemon_test.dart index f880e59308..15301da9ff 100644 --- a/packages/flutter_tools/test/commands/daemon_test.dart +++ b/packages/flutter_tools/test/commands/daemon_test.dart @@ -21,7 +21,7 @@ void main() { group('daemon', () { setUp(() { - notifyingLogger = new NotifyingLogger(); + notifyingLogger = NotifyingLogger(); }); tearDown(() { @@ -31,9 +31,9 @@ void main() { }); testUsingContext('daemon.version command should succeed', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger @@ -48,9 +48,9 @@ void main() { }); testUsingContext('printError should send daemon.logMessage event', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger, @@ -71,12 +71,12 @@ void main() { }); testUsingContext('printStatus should log to stdout when logToStdout is enabled', () async { - final StringBuffer buffer = new StringBuffer(); + final StringBuffer buffer = StringBuffer(); await runZoned(() async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger, @@ -84,8 +84,8 @@ void main() { ); printStatus('daemon.logMessage test'); // Service the event loop. - await new Future.value(); - }, zoneSpecification: new ZoneSpecification(print: (Zone self, ZoneDelegate parent, Zone zone, String line) { + await Future.value(); + }, zoneSpecification: ZoneSpecification(print: (Zone self, ZoneDelegate parent, Zone zone, String line) { buffer.writeln(line); })); @@ -95,9 +95,9 @@ void main() { }); testUsingContext('daemon.shutdown command should stop daemon', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger @@ -110,12 +110,12 @@ void main() { }); testUsingContext('app.restart without an appId should report an error', () async { - final DaemonCommand command = new DaemonCommand(); + final DaemonCommand command = DaemonCommand(); applyMocksToCommand(command); - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, daemonCommand: command, @@ -131,12 +131,12 @@ void main() { }); testUsingContext('ext.flutter.debugPaint via service extension without an appId should report an error', () async { - final DaemonCommand command = new DaemonCommand(); + final DaemonCommand command = DaemonCommand(); applyMocksToCommand(command); - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, daemonCommand: command, @@ -158,12 +158,12 @@ void main() { }); testUsingContext('app.stop without appId should report an error', () async { - final DaemonCommand command = new DaemonCommand(); + final DaemonCommand command = DaemonCommand(); applyMocksToCommand(command); - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, daemonCommand: command, @@ -179,9 +179,9 @@ void main() { }); testUsingContext('daemon should send showMessage on startup if no Android devices are available', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger, @@ -195,14 +195,14 @@ void main() { expect(response['params'], containsPair('title', 'Unable to list devices')); expect(response['params'], containsPair('message', contains('Unable to discover Android devices'))); }, overrides: { - AndroidWorkflow: () => new MockAndroidWorkflow(canListDevices: false), - IOSWorkflow: () => new MockIOSWorkflow(), + AndroidWorkflow: () => MockAndroidWorkflow(canListDevices: false), + IOSWorkflow: () => MockIOSWorkflow(), }); testUsingContext('device.getDevices should respond with list', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger @@ -216,17 +216,17 @@ void main() { }); testUsingContext('should send device.added event when device is discovered', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger ); - final MockPollingDeviceDiscovery discoverer = new MockPollingDeviceDiscovery(); + final MockPollingDeviceDiscovery discoverer = MockPollingDeviceDiscovery(); daemon.deviceDomain.addDeviceDiscoverer(discoverer); - discoverer.addDevice(new MockAndroidDevice()); + discoverer.addDevice(MockAndroidDevice()); return await responses.stream.skipWhile(_isConnectedEvent).first.then((Map response) async { expect(response['event'], 'device.added'); @@ -239,17 +239,17 @@ void main() { await commands.close(); }); }, overrides: { - AndroidWorkflow: () => new MockAndroidWorkflow(), - IOSWorkflow: () => new MockIOSWorkflow(), + AndroidWorkflow: () => MockAndroidWorkflow(), + IOSWorkflow: () => MockIOSWorkflow(), }); testUsingContext('emulator.launch without an emulatorId should report an error', () async { - final DaemonCommand command = new DaemonCommand(); + final DaemonCommand command = DaemonCommand(); applyMocksToCommand(command); - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, daemonCommand: command, @@ -265,9 +265,9 @@ void main() { }); testUsingContext('emulator.getEmulators should respond with list', () async { - final StreamController> commands = new StreamController>(); - final StreamController> responses = new StreamController>(); - daemon = new Daemon( + final StreamController> commands = StreamController>(); + final StreamController> responses = StreamController>(); + daemon = Daemon( commands.stream, responses.add, notifyingLogger: notifyingLogger @@ -288,11 +288,11 @@ void main() { '{"code":0,"message":""}' ); expect( - jsonEncodeObject(new OperationResult(1, 'foo')), + jsonEncodeObject(OperationResult(1, 'foo')), '{"code":1,"message":"foo"}' ); expect( - jsonEncodeObject(new OperationResult(0, 'foo', hintMessage: 'my hint', hintId: 'myId')), + jsonEncodeObject(OperationResult(0, 'foo', hintMessage: 'my hint', hintId: 'myId')), '{"code":0,"message":"foo","hintMessage":"my hint","hintId":"myId"}' ); }); diff --git a/packages/flutter_tools/test/commands/devices_test.dart b/packages/flutter_tools/test/commands/devices_test.dart index 14b9087c93..f3fa1260b9 100644 --- a/packages/flutter_tools/test/commands/devices_test.dart +++ b/packages/flutter_tools/test/commands/devices_test.dart @@ -23,18 +23,18 @@ void main() { }); testUsingContext('returns 0 when called', () async { - final DevicesCommand command = new DevicesCommand(); + final DevicesCommand command = DevicesCommand(); await createTestCommandRunner(command).run(['devices']); }); testUsingContext('no error when no connected devices', () async { - final DevicesCommand command = new DevicesCommand(); + final DevicesCommand command = DevicesCommand(); await createTestCommandRunner(command).run(['devices']); expect(testLogger.statusText, contains('No devices detected')); }, overrides: { AndroidSdk: () => null, - DeviceManager: () => new DeviceManager(), - ProcessManager: () => new MockProcessManager(), + DeviceManager: () => DeviceManager(), + ProcessManager: () => MockProcessManager(), }); }); } @@ -50,7 +50,7 @@ class MockProcessManager extends Mock implements ProcessManager { Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding, }) async { - return new ProcessResult(0, 0, '', ''); + return ProcessResult(0, 0, '', ''); } @override @@ -63,6 +63,6 @@ class MockProcessManager extends Mock implements ProcessManager { Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding, }) { - return new ProcessResult(0, 0, '', ''); + return ProcessResult(0, 0, '', ''); } } diff --git a/packages/flutter_tools/test/commands/doctor_test.dart b/packages/flutter_tools/test/commands/doctor_test.dart index d192d1b718..c74a159815 100644 --- a/packages/flutter_tools/test/commands/doctor_test.dart +++ b/packages/flutter_tools/test/commands/doctor_test.dart @@ -16,7 +16,7 @@ void main() { group('doctor', () { testUsingContext('intellij validator', () async { const String installPath = '/path/to/intelliJ'; - final ValidationResult result = await new IntelliJValidatorTestTarget('Test', installPath).validate(); + final ValidationResult result = await IntelliJValidatorTestTarget('Test', installPath).validate(); expect(result.type, ValidationType.partial); expect(result.statusInfo, 'version test.test.test'); expect(result.messages, hasLength(4)); @@ -94,14 +94,14 @@ void main() { '• No issues found!\n' )); }, overrides: { - DoctorValidatorsProvider: () => new FakeDoctorValidatorsProvider() + DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider() }); }); group('doctor with fake validators', () { testUsingContext('validate non-verbose output format for run without issues', () async { - expect(await new FakeQuietDoctor().diagnose(verbose: false), isTrue); + expect(await FakeQuietDoctor().diagnose(verbose: false), isTrue); expect(testLogger.statusText, equals( 'Doctor summary (to see all details, run flutter doctor -v):\n' '[✓] Passing Validator (with statusInfo)\n' @@ -114,7 +114,7 @@ void main() { }); testUsingContext('validate non-verbose output format when only one category fails', () async { - expect(await new FakeSinglePassingDoctor().diagnose(verbose: false), isTrue); + expect(await FakeSinglePassingDoctor().diagnose(verbose: false), isTrue); expect(testLogger.statusText, equals( 'Doctor summary (to see all details, run flutter doctor -v):\n' '[!] Partial Validator with only a Hint\n' @@ -125,7 +125,7 @@ void main() { }); testUsingContext('validate non-verbose output format for a passing run', () async { - expect(await new FakePassingDoctor().diagnose(verbose: false), isTrue); + expect(await FakePassingDoctor().diagnose(verbose: false), isTrue); expect(testLogger.statusText, equals( 'Doctor summary (to see all details, run flutter doctor -v):\n' '[✓] Passing Validator (with statusInfo)\n' @@ -141,7 +141,7 @@ void main() { }); testUsingContext('validate non-verbose output format', () async { - expect(await new FakeDoctor().diagnose(verbose: false), isFalse); + expect(await FakeDoctor().diagnose(verbose: false), isFalse); expect(testLogger.statusText, equals( 'Doctor summary (to see all details, run flutter doctor -v):\n' '[✓] Passing Validator (with statusInfo)\n' @@ -159,7 +159,7 @@ void main() { }); testUsingContext('validate verbose output format', () async { - expect(await new FakeDoctor().diagnose(verbose: true), isFalse); + expect(await FakeDoctor().diagnose(verbose: true), isFalse); expect(testLogger.statusText, equals( '[✓] Passing Validator (with statusInfo)\n' ' • A helpful message\n' @@ -187,7 +187,7 @@ void main() { group('doctor with grouped validators', () { testUsingContext('validate diagnose combines validator output', () async { - expect(await new FakeGroupedDoctor().diagnose(), isTrue); + expect(await FakeGroupedDoctor().diagnose(), isTrue); expect(testLogger.statusText, equals( '[✓] Category 1\n' ' • A helpful message\n' @@ -202,7 +202,7 @@ void main() { }); testUsingContext('validate summary combines validator output', () async { - expect(await new FakeGroupedDoctor().summaryText, equals( + expect(await FakeGroupedDoctor().summaryText, equals( '[✓] Category 1 is fully installed.\n' '[!] Category 2 is partially installed; more components are available.\n' '\n' @@ -214,52 +214,52 @@ void main() { group('doctor merging validator results', () { - final PassingGroupedValidator installed = new PassingGroupedValidator('Category', groupedCategory1); - final PartialGroupedValidator partial = new PartialGroupedValidator('Category', groupedCategory1); - final MissingGroupedValidator missing = new MissingGroupedValidator('Category', groupedCategory1); + final PassingGroupedValidator installed = PassingGroupedValidator('Category', groupedCategory1); + final PartialGroupedValidator partial = PartialGroupedValidator('Category', groupedCategory1); + final MissingGroupedValidator missing = MissingGroupedValidator('Category', groupedCategory1); testUsingContext('validate installed + installed = installed', () async { - expect(await new FakeSmallGroupDoctor(installed, installed).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(installed, installed).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[✓]')); }); testUsingContext('validate installed + partial = partial', () async { - expect(await new FakeSmallGroupDoctor(installed, partial).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(installed, partial).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate installed + missing = partial', () async { - expect(await new FakeSmallGroupDoctor(installed, missing).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(installed, missing).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate partial + installed = partial', () async { - expect(await new FakeSmallGroupDoctor(partial, installed).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(partial, installed).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate partial + partial = partial', () async { - expect(await new FakeSmallGroupDoctor(partial, partial).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(partial, partial).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate partial + missing = partial', () async { - expect(await new FakeSmallGroupDoctor(partial, missing).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(partial, missing).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate missing + installed = partial', () async { - expect(await new FakeSmallGroupDoctor(missing, installed).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(missing, installed).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate missing + partial = partial', () async { - expect(await new FakeSmallGroupDoctor(missing, partial).diagnose(), isTrue); + expect(await FakeSmallGroupDoctor(missing, partial).diagnose(), isTrue); expect(testLogger.statusText, startsWith('[!]')); }); testUsingContext('validate missing + missing = missing', () async { - expect(await new FakeSmallGroupDoctor(missing, missing).diagnose(), isFalse); + expect(await FakeSmallGroupDoctor(missing, missing).diagnose(), isFalse); expect(testLogger.statusText, startsWith('[✗]')); }); }); @@ -281,9 +281,9 @@ class PassingValidator extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage('A helpful message')); - messages.add(new ValidationMessage('A second, somewhat longer helpful message')); - return new ValidationResult(ValidationType.installed, messages, statusInfo: 'with statusInfo'); + messages.add(ValidationMessage('A helpful message')); + messages.add(ValidationMessage('A second, somewhat longer helpful message')); + return ValidationResult(ValidationType.installed, messages, statusInfo: 'with statusInfo'); } } @@ -293,10 +293,10 @@ class MissingValidator extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage.error('A useful error message')); - messages.add(new ValidationMessage('A message that is not an error')); - messages.add(new ValidationMessage.hint('A hint message')); - return new ValidationResult(ValidationType.missing, messages); + messages.add(ValidationMessage.error('A useful error message')); + messages.add(ValidationMessage('A message that is not an error')); + messages.add(ValidationMessage.hint('A hint message')); + return ValidationResult(ValidationType.missing, messages); } } @@ -306,10 +306,10 @@ class PartialValidatorWithErrors extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage.error('A error message indicating partial installation')); - messages.add(new ValidationMessage.hint('Maybe a hint will help the user')); - messages.add(new ValidationMessage('An extra message with some verbose details')); - return new ValidationResult(ValidationType.partial, messages); + messages.add(ValidationMessage.error('A error message indicating partial installation')); + messages.add(ValidationMessage.hint('Maybe a hint will help the user')); + messages.add(ValidationMessage('An extra message with some verbose details')); + return ValidationResult(ValidationType.partial, messages); } } @@ -319,9 +319,9 @@ class PartialValidatorWithHintsOnly extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage.hint('There is a hint here')); - messages.add(new ValidationMessage('But there is no error')); - return new ValidationResult(ValidationType.partial, messages); + messages.add(ValidationMessage.hint('There is a hint here')); + messages.add(ValidationMessage('But there is no error')); + return ValidationResult(ValidationType.partial, messages); } } @@ -333,10 +333,10 @@ class FakeDoctor extends Doctor { List get validators { if (_validators == null) { _validators = []; - _validators.add(new PassingValidator('Passing Validator')); - _validators.add(new MissingValidator()); - _validators.add(new PartialValidatorWithHintsOnly()); - _validators.add(new PartialValidatorWithErrors()); + _validators.add(PassingValidator('Passing Validator')); + _validators.add(MissingValidator()); + _validators.add(PartialValidatorWithHintsOnly()); + _validators.add(PartialValidatorWithErrors()); } return _validators; } @@ -349,10 +349,10 @@ class FakePassingDoctor extends Doctor { List get validators { if (_validators == null) { _validators = []; - _validators.add(new PassingValidator('Passing Validator')); - _validators.add(new PartialValidatorWithHintsOnly()); - _validators.add(new PartialValidatorWithErrors()); - _validators.add(new PassingValidator('Another Passing Validator')); + _validators.add(PassingValidator('Passing Validator')); + _validators.add(PartialValidatorWithHintsOnly()); + _validators.add(PartialValidatorWithErrors()); + _validators.add(PassingValidator('Another Passing Validator')); } return _validators; } @@ -366,7 +366,7 @@ class FakeSinglePassingDoctor extends Doctor { List get validators { if (_validators == null) { _validators = []; - _validators.add(new PartialValidatorWithHintsOnly()); + _validators.add(PartialValidatorWithHintsOnly()); } return _validators; } @@ -379,10 +379,10 @@ class FakeQuietDoctor extends Doctor { List get validators { if (_validators == null) { _validators = []; - _validators.add(new PassingValidator('Passing Validator')); - _validators.add(new PassingValidator('Another Passing Validator')); - _validators.add(new PassingValidator('Validators are fun')); - _validators.add(new PassingValidator('Four score and seven validators ago')); + _validators.add(PassingValidator('Passing Validator')); + _validators.add(PassingValidator('Another Passing Validator')); + _validators.add(PassingValidator('Validators are fun')); + _validators.add(PassingValidator('Four score and seven validators ago')); } return _validators; } @@ -394,9 +394,9 @@ class FakeDoctorValidatorsProvider implements DoctorValidatorsProvider { @override List get validators { return [ - new PassingValidator('Passing Validator'), - new PassingValidator('Another Passing Validator'), - new PassingValidator('Providing validators is fun') + PassingValidator('Passing Validator'), + PassingValidator('Another Passing Validator'), + PassingValidator('Providing validators is fun') ]; } @@ -414,8 +414,8 @@ class PassingGroupedValidator extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage('A helpful message')); - return new ValidationResult(ValidationType.installed, messages); + messages.add(ValidationMessage('A helpful message')); + return ValidationResult(ValidationType.installed, messages); } } @@ -426,8 +426,8 @@ class MissingGroupedValidator extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage.error('A useful error message')); - return new ValidationResult(ValidationType.missing, messages); + messages.add(ValidationMessage.error('A useful error message')); + return ValidationResult(ValidationType.missing, messages); } } @@ -437,8 +437,8 @@ class PartialGroupedValidator extends DoctorValidator { @override Future validate() async { final List messages = []; - messages.add(new ValidationMessage.error('An error message for partial installation')); - return new ValidationResult(ValidationType.partial, messages); + messages.add(ValidationMessage.error('An error message for partial installation')); + return ValidationResult(ValidationType.partial, messages); } } @@ -449,10 +449,10 @@ class FakeGroupedDoctor extends Doctor { List get validators { if (_validators == null) { _validators = []; - _validators.add(new PassingGroupedValidator('Category 1', groupedCategory1)); - _validators.add(new PassingGroupedValidator('Category 1', groupedCategory1)); - _validators.add(new PassingGroupedValidator('Category 2', groupedCategory2)); - _validators.add(new MissingGroupedValidator('Category 2', groupedCategory2)); + _validators.add(PassingGroupedValidator('Category 1', groupedCategory1)); + _validators.add(PassingGroupedValidator('Category 1', groupedCategory1)); + _validators.add(PassingGroupedValidator('Category 2', groupedCategory2)); + _validators.add(MissingGroupedValidator('Category 2', groupedCategory2)); } return _validators; } @@ -474,14 +474,14 @@ class VsCodeValidatorTestTargets extends VsCodeValidator { static final String validExtensions = fs.path.join('test', 'data', 'vscode', 'extensions'); static final String missingExtensions = fs.path.join('test', 'data', 'vscode', 'notExtensions'); VsCodeValidatorTestTargets._(String installDirectory, String extensionDirectory, {String edition}) - : super(new VsCode.fromDirectory(installDirectory, extensionDirectory, edition: edition)); + : super(VsCode.fromDirectory(installDirectory, extensionDirectory, edition: edition)); static VsCodeValidatorTestTargets get installedWithExtension => - new VsCodeValidatorTestTargets._(validInstall, validExtensions); + VsCodeValidatorTestTargets._(validInstall, validExtensions); static VsCodeValidatorTestTargets get installedWithExtension64bit => - new VsCodeValidatorTestTargets._(validInstall, validExtensions, edition: '64-bit edition'); + VsCodeValidatorTestTargets._(validInstall, validExtensions, edition: '64-bit edition'); static VsCodeValidatorTestTargets get installedWithoutExtension => - new VsCodeValidatorTestTargets._(validInstall, missingExtensions); + VsCodeValidatorTestTargets._(validInstall, missingExtensions); } diff --git a/packages/flutter_tools/test/commands/drive_test.dart b/packages/flutter_tools/test/commands/drive_test.dart index a9d673d92d..f154204ca7 100644 --- a/packages/flutter_tools/test/commands/drive_test.dart +++ b/packages/flutter_tools/test/commands/drive_test.dart @@ -27,7 +27,7 @@ void main() { Directory tempDir; void withMockDevice([Device mock]) { - mockDevice = mock ?? new MockDevice(); + mockDevice = mock ?? MockDevice(); targetDeviceFinder = () async => mockDevice; testDeviceManager.addDevice(mockDevice); } @@ -37,9 +37,9 @@ void main() { }); setUp(() { - command = new DriveCommand(); + command = DriveCommand(); applyMocksToCommand(command); - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); tempDir = fs.systemTempDirectory.createTempSync('flutter_drive_test.'); fs.currentDirectory = tempDir; fs.directory('test').createSync(); @@ -167,7 +167,7 @@ void main() { final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); appStarter = expectAsync1((DriveCommand command) async { - return new LaunchResult.succeeded(); + return LaunchResult.succeeded(); }); testRunner = expectAsync2((List testArgs, String observatoryUri) async { expect(testArgs, [testFile]); @@ -198,7 +198,7 @@ void main() { final String testFile = fs.path.join(tempDir.path, 'test_driver', 'e2e_test.dart'); appStarter = expectAsync1((DriveCommand command) async { - return new LaunchResult.succeeded(); + return LaunchResult.succeeded(); }); testRunner = (List testArgs, String observatoryUri) async { throwToolExit(null, exitCode: 123); @@ -241,7 +241,7 @@ void main() { }); void findTargetDeviceOnOperatingSystem(String operatingSystem) { - Platform platform() => new FakePlatform(operatingSystem: operatingSystem); + Platform platform() => FakePlatform(operatingSystem: operatingSystem); testUsingContext('returns null if no devices found', () async { expect(await findTargetDevice(), isNull); @@ -251,7 +251,7 @@ void main() { }); testUsingContext('uses existing Android device', () async { - mockDevice = new MockAndroidDevice(); + mockDevice = MockAndroidDevice(); when(mockDevice.name).thenReturn('mock-android-device'); withMockDevice(mockDevice); @@ -274,13 +274,13 @@ void main() { group('findTargetDevice on macOS', () { findTargetDeviceOnOperatingSystem('macos'); - Platform macOsPlatform() => new FakePlatform(operatingSystem: 'macos'); + Platform macOsPlatform() => FakePlatform(operatingSystem: 'macos'); testUsingContext('uses existing simulator', () async { withMockDevice(); when(mockDevice.name).thenReturn('mock-simulator'); when(mockDevice.isLocalEmulator) - .thenAnswer((Invocation invocation) => new Future.value(true)); + .thenAnswer((Invocation invocation) => Future.value(true)); final Device device = await findTargetDevice(); expect(device.name, 'mock-simulator'); diff --git a/packages/flutter_tools/test/commands/format_test.dart b/packages/flutter_tools/test/commands/format_test.dart index 752e720da1..526fa38f31 100644 --- a/packages/flutter_tools/test/commands/format_test.dart +++ b/packages/flutter_tools/test/commands/format_test.dart @@ -30,7 +30,7 @@ void main() { final String original = srcFile.readAsStringSync(); srcFile.writeAsStringSync(original.replaceFirst('main()', 'main( )')); - final FormatCommand command = new FormatCommand(); + final FormatCommand command = FormatCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['format', srcFile.path]); @@ -47,7 +47,7 @@ void main() { 'main()', 'main( )'); srcFile.writeAsStringSync(nonFormatted); - final FormatCommand command = new FormatCommand(); + final FormatCommand command = FormatCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['format', '--dry-run', srcFile.path]); @@ -64,7 +64,7 @@ void main() { 'main()', 'main( )'); srcFile.writeAsStringSync(nonFormatted); - final FormatCommand command = new FormatCommand(); + final FormatCommand command = FormatCommand(); final CommandRunner runner = createTestCommandRunner(command); expect(runner.run([ diff --git a/packages/flutter_tools/test/commands/fuchsia_reload_test.dart b/packages/flutter_tools/test/commands/fuchsia_reload_test.dart index 8d128cd861..1c32964c86 100644 --- a/packages/flutter_tools/test/commands/fuchsia_reload_test.dart +++ b/packages/flutter_tools/test/commands/fuchsia_reload_test.dart @@ -17,7 +17,7 @@ void main() { group('FuchsiaDeviceCommandRunner', () { testUsingContext('a test', () async { final FuchsiaDeviceCommandRunner commandRunner = - new FuchsiaDeviceCommandRunner('8.8.9.9', + FuchsiaDeviceCommandRunner('8.8.9.9', '~/fuchsia/out/release-x86-64'); final List ports = await commandRunner.run('ls /tmp'); expect(ports, hasLength(3)); @@ -25,7 +25,7 @@ void main() { expect(ports[1], equals('5678')); expect(ports[2], equals('5')); }, overrides: { - ProcessManager: () => new MockProcessManager(), + ProcessManager: () => MockProcessManager(), }); }); } @@ -41,6 +41,6 @@ class MockProcessManager extends Mock implements ProcessManager { Encoding stdoutEncoding = systemEncoding, Encoding stderrEncoding = systemEncoding, }) async { - return new ProcessResult(0, 0, '1234\n5678\n5', ''); + return ProcessResult(0, 0, '1234\n5678\n5', ''); } } diff --git a/packages/flutter_tools/test/commands/ide_config_test.dart b/packages/flutter_tools/test/commands/ide_config_test.dart index 79e799f952..1e7a0fe140 100644 --- a/packages/flutter_tools/test/commands/ide_config_test.dart +++ b/packages/flutter_tools/test/commands/ide_config_test.dart @@ -83,7 +83,7 @@ void main() { List unexpectedPaths = const [], }) async { dir ??= tempDir; - final IdeConfigCommand command = new IdeConfigCommand(); + final IdeConfigCommand command = IdeConfigCommand(); final CommandRunner runner = createTestCommandRunner(command); final List finalArgs = ['--flutter-root=${tempDir.absolute.path}', 'ide-config']; finalArgs.addAll(args); diff --git a/packages/flutter_tools/test/commands/install_test.dart b/packages/flutter_tools/test/commands/install_test.dart index 07d9eb69c4..1f56cb0900 100644 --- a/packages/flutter_tools/test/commands/install_test.dart +++ b/packages/flutter_tools/test/commands/install_test.dart @@ -12,10 +12,10 @@ import '../src/mocks.dart'; void main() { group('install', () { testUsingContext('returns 0 when Android is connected and ready for an install', () async { - final InstallCommand command = new InstallCommand(); + final InstallCommand command = InstallCommand(); applyMocksToCommand(command); - final MockAndroidDevice device = new MockAndroidDevice(); + final MockAndroidDevice device = MockAndroidDevice(); when(device.isAppInstalled(any)).thenAnswer((_) async => false); when(device.installApp(any)).thenAnswer((_) async => true); testDeviceManager.addDevice(device); @@ -24,10 +24,10 @@ void main() { }); testUsingContext('returns 0 when iOS is connected and ready for an install', () async { - final InstallCommand command = new InstallCommand(); + final InstallCommand command = InstallCommand(); applyMocksToCommand(command); - final MockIOSDevice device = new MockIOSDevice(); + final MockIOSDevice device = MockIOSDevice(); when(device.isAppInstalled(any)).thenAnswer((_) async => false); when(device.installApp(any)).thenAnswer((_) async => true); testDeviceManager.addDevice(device); diff --git a/packages/flutter_tools/test/commands/packages_test.dart b/packages/flutter_tools/test/commands/packages_test.dart index efa71ddabf..95c7f461be 100644 --- a/packages/flutter_tools/test/commands/packages_test.dart +++ b/packages/flutter_tools/test/commands/packages_test.dart @@ -58,7 +58,7 @@ void main() { } Future runCommandIn(String projectPath, String verb, { List args }) async { - final PackagesCommand command = new PackagesCommand(); + final PackagesCommand command = PackagesCommand(); final CommandRunner runner = createTestCommandRunner(command); final List commandArgs = ['packages', verb]; @@ -233,12 +233,12 @@ void main() { MockStdio mockStdio; setUp(() { - mockProcessManager = new MockProcessManager(); - mockStdio = new MockStdio(); + mockProcessManager = MockProcessManager(); + mockStdio = MockStdio(); }); testUsingContext('test without bot', () async { - await createTestCommandRunner(new PackagesCommand()).run(['packages', 'test']); + await createTestCommandRunner(PackagesCommand()).run(['packages', 'test']); final List commands = mockProcessManager.commands; expect(commands, hasLength(3)); expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); @@ -251,7 +251,7 @@ void main() { }); testUsingContext('test with bot', () async { - await createTestCommandRunner(new PackagesCommand()).run(['packages', 'test']); + await createTestCommandRunner(PackagesCommand()).run(['packages', 'test']); final List commands = mockProcessManager.commands; expect(commands, hasLength(4)); expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); @@ -265,7 +265,7 @@ void main() { }); testUsingContext('run', () async { - await createTestCommandRunner(new PackagesCommand()).run(['packages', '--verbose', 'pub', 'run', '--foo', 'bar']); + await createTestCommandRunner(PackagesCommand()).run(['packages', '--verbose', 'pub', 'run', '--foo', 'bar']); final List commands = mockProcessManager.commands; expect(commands, hasLength(4)); expect(commands[0], matches(r'dart-sdk[\\/]bin[\\/]pub')); @@ -278,11 +278,11 @@ void main() { }); testUsingContext('publish', () async { - final PromptingProcess process = new PromptingProcess(); + final PromptingProcess process = PromptingProcess(); mockProcessManager.processFactory = (List commands) => process; - final Future runPackages = createTestCommandRunner(new PackagesCommand()).run(['packages', 'pub', 'publish']); + final Future runPackages = createTestCommandRunner(PackagesCommand()).run(['packages', 'pub', 'publish']); final Future runPrompt = process.showPrompt('Proceed (y/n)? ', ['hello', 'world']); - final Future simulateUserInput = new Future(() { + final Future simulateUserInput = Future(() { mockStdio.simulateStdin('y'); }); await Future.wait(>[runPackages, runPrompt, simulateUserInput]); diff --git a/packages/flutter_tools/test/commands/run_test.dart b/packages/flutter_tools/test/commands/run_test.dart index fde6043d80..16c4efe65a 100644 --- a/packages/flutter_tools/test/commands/run_test.dart +++ b/packages/flutter_tools/test/commands/run_test.dart @@ -12,7 +12,7 @@ import '../src/mocks.dart'; void main() { group('run', () { testUsingContext('fails when target not found', () async { - final RunCommand command = new RunCommand(); + final RunCommand command = RunCommand(); applyMocksToCommand(command); try { await createTestCommandRunner(command).run(['run', '-t', 'abc123']); diff --git a/packages/flutter_tools/test/commands/shell_completion_test.dart b/packages/flutter_tools/test/commands/shell_completion_test.dart index c55dc8369a..6b1498be94 100644 --- a/packages/flutter_tools/test/commands/shell_completion_test.dart +++ b/packages/flutter_tools/test/commands/shell_completion_test.dart @@ -20,11 +20,11 @@ void main() { setUp(() { Cache.disableLocking(); - mockStdio = new MockStdio(); + mockStdio = MockStdio(); }); testUsingContext('generates bash initialization script to stdout', () async { - final ShellCompletionCommand command = new ShellCompletionCommand(); + final ShellCompletionCommand command = ShellCompletionCommand(); await createTestCommandRunner(command).run(['bash-completion']); expect(mockStdio.writtenToStdout.length, equals(1)); expect(mockStdio.writtenToStdout.first, contains('__flutter_completion')); @@ -33,7 +33,7 @@ void main() { }); testUsingContext('generates bash initialization script to stdout with arg', () async { - final ShellCompletionCommand command = new ShellCompletionCommand(); + final ShellCompletionCommand command = ShellCompletionCommand(); await createTestCommandRunner(command).run(['bash-completion', '-']); expect(mockStdio.writtenToStdout.length, equals(1)); expect(mockStdio.writtenToStdout.first, contains('__flutter_completion')); @@ -42,7 +42,7 @@ void main() { }); testUsingContext('generates bash initialization script to output file', () async { - final ShellCompletionCommand command = new ShellCompletionCommand(); + final ShellCompletionCommand command = ShellCompletionCommand(); const String outputFile = 'bash-setup.sh'; await createTestCommandRunner(command).run( ['bash-completion', outputFile], @@ -50,12 +50,12 @@ void main() { expect(fs.isFileSync(outputFile), isTrue); expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion')); }, overrides: { - FileSystem: () => new MemoryFileSystem(), + FileSystem: () => MemoryFileSystem(), Stdio: () => mockStdio, }); testUsingContext("won't overwrite existing output file ", () async { - final ShellCompletionCommand command = new ShellCompletionCommand(); + final ShellCompletionCommand command = ShellCompletionCommand(); const String outputFile = 'bash-setup.sh'; fs.file(outputFile).createSync(); try { @@ -70,12 +70,12 @@ void main() { expect(fs.isFileSync(outputFile), isTrue); expect(fs.file(outputFile).readAsStringSync(), isEmpty); }, overrides: { - FileSystem: () => new MemoryFileSystem(), + FileSystem: () => MemoryFileSystem(), Stdio: () => mockStdio, }); testUsingContext('will overwrite existing output file if given --overwrite', () async { - final ShellCompletionCommand command = new ShellCompletionCommand(); + final ShellCompletionCommand command = ShellCompletionCommand(); const String outputFile = 'bash-setup.sh'; fs.file(outputFile).createSync(); await createTestCommandRunner(command).run( @@ -84,7 +84,7 @@ void main() { expect(fs.isFileSync(outputFile), isTrue); expect(fs.file(outputFile).readAsStringSync(), contains('__flutter_completion')); }, overrides: { - FileSystem: () => new MemoryFileSystem(), + FileSystem: () => MemoryFileSystem(), Stdio: () => mockStdio, }); }); diff --git a/packages/flutter_tools/test/commands/test_test.dart b/packages/flutter_tools/test/commands/test_test.dart index 6aa542ffa5..d576023967 100644 --- a/packages/flutter_tools/test/commands/test_test.dart +++ b/packages/flutter_tools/test/commands/test_test.dart @@ -125,7 +125,7 @@ Future _testFile(String testName, String workingDirectory, String testDire continue; } if (allowSkip) { - if (!new RegExp(expectationLine).hasMatch(outputLine)) { + if (!RegExp(expectationLine).hasMatch(outputLine)) { outputLineNumber += 1; continue; } @@ -167,7 +167,7 @@ Future _runFlutterTest( while (_testExclusionLock != null) await _testExclusionLock; - final Completer testExclusionCompleter = new Completer(); + final Completer testExclusionCompleter = Completer(); _testExclusionLock = testExclusionCompleter.future; try { return await Process.run( diff --git a/packages/flutter_tools/test/compile_test.dart b/packages/flutter_tools/test/compile_test.dart index 3ddb5be980..1565f74573 100644 --- a/packages/flutter_tools/test/compile_test.dart +++ b/packages/flutter_tools/test/compile_test.dart @@ -22,27 +22,27 @@ void main() { MockStdIn mockFrontendServerStdIn; MockStream mockFrontendServerStdErr; setUp(() { - mockProcessManager = new MockProcessManager(); - mockFrontendServer = new MockProcess(); - mockFrontendServerStdIn = new MockStdIn(); - mockFrontendServerStdErr = new MockStream(); + mockProcessManager = MockProcessManager(); + mockFrontendServer = MockProcess(); + mockFrontendServerStdIn = MockStdIn(); + mockFrontendServerStdErr = MockStream(); when(mockFrontendServer.stderr) .thenAnswer((Invocation invocation) => mockFrontendServerStdErr); - final StreamController stdErrStreamController = new StreamController(); + final StreamController stdErrStreamController = StreamController(); when(mockFrontendServerStdErr.transform(any)).thenAnswer((_) => stdErrStreamController.stream); when(mockFrontendServer.stdin).thenReturn(mockFrontendServerStdIn); when(mockProcessManager.canRun(any)).thenReturn(true); when(mockProcessManager.start(any)).thenAnswer( - (Invocation invocation) => new Future.value(mockFrontendServer)); + (Invocation invocation) => Future.value(mockFrontendServer)); when(mockFrontendServer.exitCode).thenAnswer((_) async => 0); }); testUsingContext('single dart successful compilation', () async { final BufferLogger logger = context[Logger]; when(mockFrontendServer.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0' )) )); @@ -60,8 +60,8 @@ void main() { final BufferLogger logger = context[Logger]; when(mockFrontendServer.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'result abc\nline1\nline2\nabc' )) )); @@ -82,8 +82,8 @@ void main() { final BufferLogger logger = context[Logger]; when(mockFrontendServer.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'result abc\nline1\nline2\nabc' )) )); @@ -108,22 +108,22 @@ void main() { StreamController stdErrStreamController; setUp(() { - generator = new ResidentCompiler('sdkroot'); - mockProcessManager = new MockProcessManager(); - mockFrontendServer = new MockProcess(); - mockFrontendServerStdIn = new MockStdIn(); - mockFrontendServerStdErr = new MockStream(); + generator = ResidentCompiler('sdkroot'); + mockProcessManager = MockProcessManager(); + mockFrontendServer = MockProcess(); + mockFrontendServerStdIn = MockStdIn(); + mockFrontendServerStdErr = MockStream(); when(mockFrontendServer.stdin).thenReturn(mockFrontendServerStdIn); when(mockFrontendServer.stderr) .thenAnswer((Invocation invocation) => mockFrontendServerStdErr); - stdErrStreamController = new StreamController(); + stdErrStreamController = StreamController(); when(mockFrontendServerStdErr.transform(any)) .thenAnswer((Invocation invocation) => stdErrStreamController.stream); when(mockProcessManager.canRun(any)).thenReturn(true); when(mockProcessManager.start(any)).thenAnswer( - (Invocation invocation) => new Future.value(mockFrontendServer) + (Invocation invocation) => Future.value(mockFrontendServer) ); }); @@ -135,8 +135,8 @@ void main() { final BufferLogger logger = context[Logger]; when(mockFrontendServer.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0' )) )); @@ -168,7 +168,7 @@ void main() { testUsingContext('compile and recompile', () async { final BufferLogger logger = context[Logger]; - final StreamController> streamController = new StreamController>(); + final StreamController> streamController = StreamController>(); when(mockFrontendServer.stdout) .thenAnswer((Invocation invocation) => streamController.stream); streamController.add(utf8.encode('result abc\nline0\nline1\nabc /path/to/main.dart.dill 0\n')); @@ -191,7 +191,7 @@ void main() { testUsingContext('compile and recompile twice', () async { final BufferLogger logger = context[Logger]; - final StreamController> streamController = new StreamController>(); + final StreamController> streamController = StreamController>(); when(mockFrontendServer.stdout) .thenAnswer((Invocation invocation) => streamController.stream); streamController.add(utf8.encode( @@ -227,23 +227,23 @@ void main() { StreamController stdErrStreamController; setUp(() { - generator = new ResidentCompiler('sdkroot'); - mockProcessManager = new MockProcessManager(); - mockFrontendServer = new MockProcess(); - mockFrontendServerStdIn = new MockStdIn(); - mockFrontendServerStdErr = new MockStream(); + generator = ResidentCompiler('sdkroot'); + mockProcessManager = MockProcessManager(); + mockFrontendServer = MockProcess(); + mockFrontendServerStdIn = MockStdIn(); + mockFrontendServerStdErr = MockStream(); when(mockFrontendServer.stdin).thenReturn(mockFrontendServerStdIn); when(mockFrontendServer.stderr) .thenAnswer((Invocation invocation) => mockFrontendServerStdErr); - stdErrStreamController = new StreamController(); + stdErrStreamController = StreamController(); when(mockFrontendServerStdErr.transform(any)) .thenAnswer((Invocation invocation) => stdErrStreamController.stream); when(mockProcessManager.canRun(any)).thenReturn(true); when(mockProcessManager.start(any)).thenAnswer( (Invocation invocation) => - new Future.value(mockFrontendServer) + Future.value(mockFrontendServer) ); }); @@ -261,18 +261,18 @@ void main() { final BufferLogger logger = context[Logger]; final Completer> compileResponseCompleter = - new Completer>(); + Completer>(); final Completer> compileExpressionResponseCompleter = - new Completer>(); + Completer>(); when(mockFrontendServer.stdout) .thenAnswer((Invocation invocation) => - new Stream>.fromFutures( + Stream>.fromFutures( >>[ compileResponseCompleter.future, compileExpressionResponseCompleter.future])); - compileResponseCompleter.complete(new Future>.value(utf8.encode( + compileResponseCompleter.complete(Future>.value(utf8.encode( 'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0\n' ))); @@ -287,7 +287,7 @@ void main() { expect(output.outputFilename, equals('/path/to/main.dart.dill')); compileExpressionResponseCompleter.complete( - new Future>.value(utf8.encode( + Future>.value(utf8.encode( 'result def\nline1\nline2\ndef /path/to/main.dart.dill.incremental 0\n' ))); generator.compileExpression( @@ -307,13 +307,13 @@ void main() { testUsingContext('compile expressions without awaiting', () async { final BufferLogger logger = context[Logger]; - final Completer> compileResponseCompleter = new Completer>(); - final Completer> compileExpressionResponseCompleter1 = new Completer>(); - final Completer> compileExpressionResponseCompleter2 = new Completer>(); + final Completer> compileResponseCompleter = Completer>(); + final Completer> compileExpressionResponseCompleter1 = Completer>(); + final Completer> compileExpressionResponseCompleter2 = Completer>(); when(mockFrontendServer.stdout) .thenAnswer((Invocation invocation) => - new Stream>.fromFutures( + Stream>.fromFutures( >>[ compileResponseCompleter.future, compileExpressionResponseCompleter1.future, @@ -328,20 +328,20 @@ void main() { equals('compiler message: line1\ncompiler message: line2\n')); expect(outputCompile.outputFilename, equals('/path/to/main.dart.dill')); - compileExpressionResponseCompleter1.complete(new Future>.value(utf8.encode( + compileExpressionResponseCompleter1.complete(Future>.value(utf8.encode( 'result def\nline1\nline2\ndef /path/to/main.dart.dill.incremental 0\n' ))); }); // The test manages timing via completers. - final Completer lastExpressionCompleted = new Completer(); + final Completer lastExpressionCompleted = Completer(); generator.compileExpression('0+1', null, null, null, null, false).then( // ignore: unawaited_futures (CompilerOutput outputExpression) { expect(outputExpression, isNotNull); expect(outputExpression.outputFilename, equals('/path/to/main.dart.dill.incremental')); expect(outputExpression.errorCount, 0); - compileExpressionResponseCompleter2.complete(new Future>.value(utf8.encode( + compileExpressionResponseCompleter2.complete(Future>.value(utf8.encode( 'result def\nline1\nline2\ndef /path/to/main.dart.dill.incremental 0\n' ))); }); @@ -356,7 +356,7 @@ void main() { lastExpressionCompleted.complete(true); }); - compileResponseCompleter.complete(new Future>.value(utf8.encode( + compileResponseCompleter.complete(Future>.value(utf8.encode( 'result abc\nline1\nline2\nabc /path/to/main.dart.dill 0\n' ))); @@ -378,7 +378,7 @@ Future _recompile(StreamController> streamController, final CompilerOutput output = await generator.recompile(null /* mainPath */, ['/path/to/main.dart']); expect(output.outputFilename, equals('/path/to/main.dart.dill')); final String commands = mockFrontendServerStdIn.getAndClear(); - final RegExp re = new RegExp('^recompile (.*)\\n/path/to/main.dart\\n(.*)\\n\$'); + final RegExp re = RegExp('^recompile (.*)\\n/path/to/main.dart\\n(.*)\\n\$'); expect(commands, matches(re)); final Match match = re.firstMatch(commands); expect(match[1] == match[2], isTrue); @@ -389,7 +389,7 @@ class MockProcessManager extends Mock implements ProcessManager {} class MockProcess extends Mock implements Process {} class MockStream extends Mock implements Stream> {} class MockStdIn extends Mock implements IOSink { - final StringBuffer _stdInWrites = new StringBuffer(); + final StringBuffer _stdInWrites = StringBuffer(); String getAndClear() { final String result = _stdInWrites.toString(); diff --git a/packages/flutter_tools/test/config_test.dart b/packages/flutter_tools/test/config_test.dart index 30edb71d5d..63e1d71980 100644 --- a/packages/flutter_tools/test/config_test.dart +++ b/packages/flutter_tools/test/config_test.dart @@ -14,7 +14,7 @@ void main() { setUp(() { tempDir = fs.systemTempDirectory.createTempSync('flutter_config_test.'); final File file = fs.file(fs.path.join(tempDir.path, '.settings')); - config = new Config(file); + config = Config(file); }); tearDown(() { diff --git a/packages/flutter_tools/test/crash_reporting_test.dart b/packages/flutter_tools/test/crash_reporting_test.dart index d7a7c4f675..2eab59145e 100644 --- a/packages/flutter_tools/test/crash_reporting_test.dart +++ b/packages/flutter_tools/test/crash_reporting_test.dart @@ -30,7 +30,7 @@ void main() { }); setUp(() async { - tools.crashFileSystem = new MemoryFileSystem(); + tools.crashFileSystem = MemoryFileSystem(); setExitFunctionForTests((_) { }); }); @@ -44,18 +44,18 @@ void main() { Uri uri; Map fields; - CrashReportSender.initializeWith(new MockClient((Request request) async { + CrashReportSender.initializeWith(MockClient((Request request) async { method = request.method; uri = request.url; // A very ad-hoc multipart request parser. Good enough for this test. String boundary = request.headers['Content-Type']; boundary = boundary.substring(boundary.indexOf('boundary=') + 9); - fields = new Map.fromIterable( + fields = Map.fromIterable( utf8.decode(request.bodyBytes) .split('--$boundary') .map>((String part) { - final Match nameMatch = new RegExp(r'name="(.*)"').firstMatch(part); + final Match nameMatch = RegExp(r'name="(.*)"').firstMatch(part); if (nameMatch == null) return null; final String name = nameMatch[1]; @@ -73,7 +73,7 @@ void main() { } ); - return new Response( + return Response( 'test-report-id', 200 ); @@ -81,7 +81,7 @@ void main() { final int exitCode = await tools.run( ['crash'], - [new _CrashCommand()], + [_CrashCommand()], reportCrashes: true, flutterVersion: 'test-version', ); @@ -90,7 +90,7 @@ void main() { // Verify that we sent the crash report. expect(method, 'POST'); - expect(uri, new Uri( + expect(uri, Uri( scheme: 'https', host: 'clients2.google.com', port: 443, @@ -124,14 +124,14 @@ void main() { testUsingContext('can override base URL', () async { Uri uri; - CrashReportSender.initializeWith(new MockClient((Request request) async { + CrashReportSender.initializeWith(MockClient((Request request) async { uri = request.url; - return new Response('test-report-id', 200); + return Response('test-report-id', 200); })); final int exitCode = await tools.run( ['crash'], - [new _CrashCommand()], + [_CrashCommand()], reportCrashes: true, flutterVersion: 'test-version', ); @@ -140,7 +140,7 @@ void main() { // Verify that we sent the crash report. expect(uri, isNotNull); - expect(uri, new Uri( + expect(uri, Uri( scheme: 'https', host: 'localhost', port: 12345, @@ -151,12 +151,12 @@ void main() { }, )); }, overrides: { - Platform: () => new FakePlatform( + Platform: () => FakePlatform( operatingSystem: 'linux', environment: { 'FLUTTER_CRASH_SERVER_BASE_URL': 'https://localhost:12345/fake_server', }, - script: new Uri(scheme: 'data'), + script: Uri(scheme: 'data'), ), Stdio: () => const _NoStderr(), }); @@ -175,7 +175,7 @@ class _CrashCommand extends FlutterCommand { @override Future runCommand() async { void fn1() { - throw new StateError('Test bad state error'); + throw StateError('Test bad state error'); } void fn2() { @@ -204,7 +204,7 @@ class _NoopIOSink implements IOSink { Encoding get encoding => utf8; @override - set encoding(_) => throw new UnsupportedError(''); + set encoding(_) => throw UnsupportedError(''); @override void add(_) {} diff --git a/packages/flutter_tools/test/dart/pub_get_test.dart b/packages/flutter_tools/test/dart/pub_get_test.dart index 3bbbdf0cd2..373ef1796c 100644 --- a/packages/flutter_tools/test/dart/pub_get_test.dart +++ b/packages/flutter_tools/test/dart/pub_get_test.dart @@ -29,7 +29,7 @@ void main() { final MockProcessManager processMock = context[ProcessManager]; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { expect(processMock.lastPubEnvironment, isNull); expect(testLogger.statusText, ''); pubGet(context: PubContext.flutterTests, checkLastModified: false).then((Null value) { @@ -85,9 +85,9 @@ void main() { expect(testLogger.errorText, isEmpty); expect(error, isNull); }, overrides: { - ProcessManager: () => new MockProcessManager(69), - FileSystem: () => new MockFileSystem(), - Platform: () => new FakePlatform( + ProcessManager: () => MockProcessManager(69), + FileSystem: () => MockFileSystem(), + Platform: () => FakePlatform( environment: {}, ), }); @@ -98,7 +98,7 @@ void main() { final MockProcessManager processMock = context[ProcessManager]; final MockFileSystem fsMock = context[FileSystem]; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { MockDirectory.findCache = true; expect(processMock.lastPubEnvironment, isNull); expect(processMock.lastPubCache, isNull); @@ -112,9 +112,9 @@ void main() { expect(error, isNull); }); }, overrides: { - ProcessManager: () => new MockProcessManager(69), - FileSystem: () => new MockFileSystem(), - Platform: () => new FakePlatform( + ProcessManager: () => MockProcessManager(69), + FileSystem: () => MockFileSystem(), + Platform: () => FakePlatform( environment: {}, ), }); @@ -124,7 +124,7 @@ void main() { final MockProcessManager processMock = context[ProcessManager]; - new FakeAsync().run((FakeAsync time) { + FakeAsync().run((FakeAsync time) { MockDirectory.findCache = true; expect(processMock.lastPubEnvironment, isNull); expect(processMock.lastPubCache, isNull); @@ -138,9 +138,9 @@ void main() { expect(error, isNull); }); }, overrides: { - ProcessManager: () => new MockProcessManager(69), - FileSystem: () => new MockFileSystem(), - Platform: () => new FakePlatform( + ProcessManager: () => MockProcessManager(69), + FileSystem: () => MockFileSystem(), + Platform: () => FakePlatform( environment: {'PUB_CACHE': 'custom/pub-cache/path'}, ), }); @@ -167,7 +167,7 @@ class MockProcessManager implements ProcessManager { }) { lastPubEnvironment = environment['PUB_ENVIRONMENT']; lastPubCache = environment['PUB_CACHE']; - return new Future.value(new MockProcess(fakeExitCode)); + return Future.value(MockProcess(fakeExitCode)); } @override @@ -180,13 +180,13 @@ class MockProcess implements Process { final int fakeExitCode; @override - Stream> get stdout => new MockStream>(); + Stream> get stdout => MockStream>(); @override - Stream> get stderr => new MockStream>(); + Stream> get stderr => MockStream>(); @override - Future get exitCode => new Future.value(fakeExitCode); + Future get exitCode => Future.value(fakeExitCode); @override dynamic noSuchMethod(Invocation invocation) => null; @@ -194,14 +194,14 @@ class MockProcess implements Process { class MockStream implements Stream { @override - Stream transform(StreamTransformer streamTransformer) => new MockStream(); + Stream transform(StreamTransformer streamTransformer) => MockStream(); @override - Stream where(bool test(T event)) => new MockStream(); + Stream where(bool test(T event)) => MockStream(); @override StreamSubscription listen(void onData(T event), {Function onError, void onDone(), bool cancelOnError}) { - return new MockStreamSubscription(); + return MockStreamSubscription(); } @override @@ -210,7 +210,7 @@ class MockStream implements Stream { class MockStreamSubscription implements StreamSubscription { @override - Future asFuture([E futureValue]) => new Future.value(); + Future asFuture([E futureValue]) => Future.value(); @override Future cancel() => null; @@ -221,30 +221,30 @@ class MockStreamSubscription implements StreamSubscription { class MockFileSystem extends ForwardingFileSystem { - MockFileSystem() : super(new MemoryFileSystem()); + MockFileSystem() : super(MemoryFileSystem()); @override File file(dynamic path) { - return new MockFile(); + return MockFile(); } @override Directory directory(dynamic path) { - return new MockDirectory(path); + return MockDirectory(path); } } class MockFile implements File { @override Future open({FileMode mode = FileMode.read}) async { - return new MockRandomAccessFile(); + return MockRandomAccessFile(); } @override bool existsSync() => true; @override - DateTime lastModifiedSync() => new DateTime(0); + DateTime lastModifiedSync() => DateTime(0); @override dynamic noSuchMethod(Invocation invocation) => null; diff --git a/packages/flutter_tools/test/dart_dependencies_test.dart b/packages/flutter_tools/test/dart_dependencies_test.dart index 0a56c7a9b5..dbfdc26509 100644 --- a/packages/flutter_tools/test/dart_dependencies_test.dart +++ b/packages/flutter_tools/test/dart_dependencies_test.dart @@ -24,7 +24,7 @@ void main() { final String mainPath = fs.path.join(testPath, 'main.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); final Set dependencies = builder.build(); expect(dependencies.contains(canonicalizePath(mainPath)), isTrue); expect(dependencies.contains(canonicalizePath(fs.path.join(testPath, 'foo.dart'))), isTrue); @@ -35,7 +35,7 @@ void main() { final String mainPath = fs.path.join(testPath, 'main.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); try { builder.build(); fail('expect an exception to be thrown.'); @@ -49,7 +49,7 @@ void main() { final String mainPath = fs.path.join(testPath, 'main.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); try { builder.build(); fail('expect an exception to be thrown.'); @@ -63,7 +63,7 @@ void main() { final String mainPath = fs.path.join(testPath, 'main.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); try { builder.build(); fail('expect an exception to be thrown.'); @@ -77,7 +77,7 @@ void main() { final String testPath = fs.path.join(dataPath, 'asci_casing'); final String mainPath = fs.path.join(testPath, 'main.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); - final DartDependencySetBuilder builder = new DartDependencySetBuilder(mainPath, packagesPath); + final DartDependencySetBuilder builder = DartDependencySetBuilder(mainPath, packagesPath); final Set deps = builder.build(); expect(deps, contains(endsWith('This_Import_Has_fuNNy_casING.dart'))); }); @@ -87,7 +87,7 @@ void main() { final String mainPath = fs.path.join(testPath, 'main.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); try { builder.build(); fail('expect an exception to be thrown.'); diff --git a/packages/flutter_tools/test/dependency_checker_test.dart b/packages/flutter_tools/test/dependency_checker_test.dart index 1fdbc7c992..a815ff2649 100644 --- a/packages/flutter_tools/test/dependency_checker_test.dart +++ b/packages/flutter_tools/test/dependency_checker_test.dart @@ -30,7 +30,7 @@ void main() { }); setUp(() { - testFileSystem = new MemoryFileSystem(); + testFileSystem = MemoryFileSystem(); }); testUsingContext('good', () { @@ -40,12 +40,12 @@ void main() { final String barPath = fs.path.join(testPath, 'lib', 'bar.dart'); final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); final DependencyChecker dependencyChecker = - new DependencyChecker(builder, null); + DependencyChecker(builder, null); // Set file modification time on all dependencies to be in the past. - final DateTime baseTime = new DateTime.now(); + final DateTime baseTime = DateTime.now(); updateFileModificationTime(packagesPath, baseTime, -10); updateFileModificationTime(mainPath, baseTime, -10); updateFileModificationTime(fooPath, baseTime, -10); @@ -72,11 +72,11 @@ void main() { final String packagesPath = fs.path.join(testPath, '.packages'); final DartDependencySetBuilder builder = - new DartDependencySetBuilder(mainPath, packagesPath); + DartDependencySetBuilder(mainPath, packagesPath); final DependencyChecker dependencyChecker = - new DependencyChecker(builder, null); + DependencyChecker(builder, null); - final DateTime baseTime = new DateTime.now(); + final DateTime baseTime = DateTime.now(); // Set file modification time on all dependencies to be in the past. updateFileModificationTime(packagesPath, baseTime, -10); @@ -102,7 +102,7 @@ void main() { fs.currentDirectory = tempDir; // Doesn't matter what commands we run. Arbitrarily list devices here. - await createTestCommandRunner(new DevicesCommand()).run(['devices']); + await createTestCommandRunner(DevicesCommand()).run(['devices']); expect(testLogger.errorText, contains('.packages')); tryToDelete(tempDir); }, overrides: { diff --git a/packages/flutter_tools/test/devfs_test.dart b/packages/flutter_tools/test/devfs_test.dart index 52ade17329..c834d02b72 100644 --- a/packages/flutter_tools/test/devfs_test.dart +++ b/packages/flutter_tools/test/devfs_test.dart @@ -29,14 +29,14 @@ void main() { final AssetBundle assetBundle = AssetBundleFactory.defaultInstance.createBundle(); setUpAll(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); filePath = fs.path.join('lib', 'foo.txt'); filePath2 = fs.path.join('foo', 'bar.txt'); }); group('DevFSContent', () { test('bytes', () { - final DevFSByteContent content = new DevFSByteContent([4, 5, 6]); + final DevFSByteContent content = DevFSByteContent([4, 5, 6]); expect(content.bytes, orderedEquals([4, 5, 6])); expect(content.isModified, isTrue); expect(content.isModified, isFalse); @@ -46,7 +46,7 @@ void main() { expect(content.isModified, isFalse); }); test('string', () { - final DevFSStringContent content = new DevFSStringContent('some string'); + final DevFSStringContent content = DevFSStringContent('some string'); expect(content.string, 'some string'); expect(content.bytes, orderedEquals(utf8.encode('some string'))); expect(content.isModified, isTrue); @@ -65,8 +65,8 @@ void main() { }); group('devfs local', () { - final MockDevFSOperations devFSOperations = new MockDevFSOperations(); - final MockResidentCompiler residentCompiler = new MockResidentCompiler(); + final MockDevFSOperations devFSOperations = MockDevFSOperations(); + final MockResidentCompiler residentCompiler = MockResidentCompiler(); setUpAll(() { tempDir = _newTempDir(fs); @@ -84,7 +84,7 @@ void main() { // simulate package await _createPackage(fs, 'somepkg', 'somefile.txt'); - devFS = new DevFS.operations(devFSOperations, 'test', tempDir); + devFS = DevFS.operations(devFSOperations, 'test', tempDir); await devFS.create(); devFSOperations.expectMessages(['create test']); expect(devFS.assetPathsToEvict, isEmpty); @@ -136,7 +136,7 @@ void main() { final File file = fs.file(fs.path.join(basePath, filePath)); // Set the last modified time to 5 seconds in the past. - updateFileModificationTime(file.path, new DateTime.now(), -5); + updateFileModificationTime(file.path, DateTime.now(), -5); bytes = await devFS.update( mainPath: 'lib/foo.txt', generator: residentCompiler, @@ -201,7 +201,7 @@ void main() { const String packageName = 'doubleslashpkg'; await _createPackage(fs, packageName, 'somefile.txt', doubleSlash: true); - final Set fileFilter = new Set(); + final Set fileFilter = Set(); final List pkgUris = [fs.path.toUri(basePath)]..addAll(_packages.values); for (Uri pkgUri in pkgUris) { if (!pkgUri.isAbsolute) { @@ -229,7 +229,7 @@ void main() { }); testUsingContext('add an asset bundle', () async { - assetBundle.entries['a.txt'] = new DevFSStringContent('abc'); + assetBundle.entries['a.txt'] = DevFSStringContent('abc'); final int bytes = await devFS.update( mainPath: 'lib/foo.txt', bundle: assetBundle, @@ -249,7 +249,7 @@ void main() { }); testUsingContext('add a file to the asset bundle - bundleDirty', () async { - assetBundle.entries['b.txt'] = new DevFSStringContent('abcd'); + assetBundle.entries['b.txt'] = DevFSStringContent('abcd'); final int bytes = await devFS.update( mainPath: 'lib/foo.txt', bundle: assetBundle, @@ -272,7 +272,7 @@ void main() { }); testUsingContext('add a file to the asset bundle', () async { - assetBundle.entries['c.txt'] = new DevFSStringContent('12'); + assetBundle.entries['c.txt'] = DevFSStringContent('12'); final int bytes = await devFS.update( mainPath: 'lib/foo.txt', bundle: assetBundle, @@ -344,12 +344,12 @@ void main() { group('devfs remote', () { MockVMService vmService; - final MockResidentCompiler residentCompiler = new MockResidentCompiler(); + final MockResidentCompiler residentCompiler = MockResidentCompiler(); setUpAll(() async { tempDir = _newTempDir(fs); basePath = tempDir.path; - vmService = new MockVMService(); + vmService = MockVMService(); await vmService.setUp(); }); tearDownAll(() async { @@ -366,7 +366,7 @@ void main() { // simulate package await _createPackage(fs, 'somepkg', 'somefile.txt'); - devFS = new DevFS(vmService, 'test', tempDir); + devFS = DevFS(vmService, 'test', tempDir); await devFS.create(); vmService.expectMessages(['create test']); expect(devFS.assetPathsToEvict, isEmpty); @@ -403,7 +403,7 @@ void main() { // simulate package await _createPackage(fs, 'somepkg', 'somefile.txt'); - devFS = new DevFS(vmService, 'test', tempDir); + devFS = DevFS(vmService, 'test', tempDir); await devFS.create(); vmService.expectMessages(['create test']); expect(devFS.assetPathsToEvict, isEmpty); @@ -429,7 +429,7 @@ class MockVMService extends BasicMock implements VMService { MockVM _vm; MockVMService() { - _vm = new MockVM(this); + _vm = MockVM(this); } @override @@ -480,7 +480,7 @@ class MockVM implements VM { Future> createDevFS(String fsName) async { _service.messages.add('create $fsName'); if (_devFSExists) { - throw new rpc.RpcException(kFileSystemAlreadyExists, 'File system already exists'); + throw rpc.RpcException(kFileSystemAlreadyExists, 'File system already exists'); } _devFSExists = true; return {'uri': '$_baseUri'}; @@ -534,7 +534,7 @@ Future _createPackage(FileSystem fs, String pkgName, String pkgFileName, { await pkgFile.parent.create(recursive: true); pkgFile.writeAsBytesSync([11, 12, 13]); _packages[pkgName] = fs.path.toUri(pkgFile.parent.path); - final StringBuffer sb = new StringBuffer(); + final StringBuffer sb = StringBuffer(); _packages.forEach((String pkgName, Uri pkgUri) { sb.writeln('$pkgName:$pkgUri'); }); diff --git a/packages/flutter_tools/test/device_test.dart b/packages/flutter_tools/test/device_test.dart index 94cf23cc03..286ee49348 100644 --- a/packages/flutter_tools/test/device_test.dart +++ b/packages/flutter_tools/test/device_test.dart @@ -13,17 +13,17 @@ void main() { group('DeviceManager', () { testUsingContext('getDevices', () async { // Test that DeviceManager.getDevices() doesn't throw. - final DeviceManager deviceManager = new DeviceManager(); + final DeviceManager deviceManager = DeviceManager(); final List devices = await deviceManager.getDevices().toList(); expect(devices, isList); }); testUsingContext('getDeviceById', () async { - final _MockDevice device1 = new _MockDevice('Nexus 5', '0553790d0a4e726f'); - final _MockDevice device2 = new _MockDevice('Nexus 5X', '01abfc49119c410e'); - final _MockDevice device3 = new _MockDevice('iPod touch', '82564b38861a9a5'); + final _MockDevice device1 = _MockDevice('Nexus 5', '0553790d0a4e726f'); + final _MockDevice device2 = _MockDevice('Nexus 5X', '01abfc49119c410e'); + final _MockDevice device3 = _MockDevice('iPod touch', '82564b38861a9a5'); final List devices = [device1, device2, device3]; - final DeviceManager deviceManager = new TestDeviceManager(devices); + final DeviceManager deviceManager = TestDeviceManager(devices); Future expectDevice(String id, List expected) async { expect(await deviceManager.getDevicesById(id).toList(), expected); @@ -45,7 +45,7 @@ class TestDeviceManager extends DeviceManager { @override Stream getAllConnectedDevices() { - return new Stream.fromIterable(allDevices); + return Stream.fromIterable(allDevices); } } diff --git a/packages/flutter_tools/test/emulator_test.dart b/packages/flutter_tools/test/emulator_test.dart index 64f04e2651..01c7d4ce76 100644 --- a/packages/flutter_tools/test/emulator_test.dart +++ b/packages/flutter_tools/test/emulator_test.dart @@ -26,10 +26,10 @@ void main() { MockXcode mockXcode; setUp(() { - mockProcessManager = new MockProcessManager(); - mockConfig = new MockConfig(); - mockSdk = new MockAndroidSdk(); - mockXcode = new MockXcode(); + mockProcessManager = MockProcessManager(); + mockConfig = MockConfig(); + mockSdk = MockAndroidSdk(); + mockXcode = MockXcode(); when(mockSdk.avdManagerPath).thenReturn('avdmanager'); when(mockSdk.emulatorPath).thenReturn('emulator'); @@ -45,18 +45,18 @@ void main() { testUsingContext('getEmulatorsById', () async { final _MockEmulator emulator1 = - new _MockEmulator('Nexus_5', 'Nexus 5', 'Google', ''); + _MockEmulator('Nexus_5', 'Nexus 5', 'Google', ''); final _MockEmulator emulator2 = - new _MockEmulator('Nexus_5X_API_27_x86', 'Nexus 5X', 'Google', ''); + _MockEmulator('Nexus_5X_API_27_x86', 'Nexus 5X', 'Google', ''); final _MockEmulator emulator3 = - new _MockEmulator('iOS Simulator', 'iOS Simulator', 'Apple', ''); + _MockEmulator('iOS Simulator', 'iOS Simulator', 'Apple', ''); final List emulators = [ emulator1, emulator2, emulator3 ]; final TestEmulatorManager testEmulatorManager = - new TestEmulatorManager(emulators); + TestEmulatorManager(emulators); Future expectEmulator(String id, List expected) async { expect(await testEmulatorManager.getEmulatorsMatching(id), expected); @@ -136,11 +136,11 @@ void main() { if (args.length >= 3 && args[0] == 'open' && args[1] == '-a' && args[2] == '/fake/simulator.app') { didAttemptToRunSimulator = true; } - return new ProcessResult(101, 0, '', ''); + return ProcessResult(101, 0, '', ''); }); }); testUsingContext('runs correct launch commands', () async { - final Emulator emulator = new IOSEmulator('ios'); + final Emulator emulator = IOSEmulator('ios'); await emulator.launch(); expect(didAttemptToRunSimulator, equals(true)); }, overrides: { @@ -158,7 +158,7 @@ class TestEmulatorManager extends EmulatorManager { @override Future> getAllAvailableEmulators() { - return new Future>.value(allEmulators); + return Future>.value(allEmulators); } } @@ -177,7 +177,7 @@ class _MockEmulator extends Emulator { @override Future launch() { - throw new UnimplementedError('Not implemented in Mock'); + throw UnimplementedError('Not implemented in Mock'); } } @@ -210,29 +210,29 @@ class MockProcessManager extends Mock implements ProcessManager { final List args = command.sublist(1); switch (command[0]) { case '/usr/bin/xcode-select': - throw new ProcessException(program, args); + throw ProcessException(program, args); break; case 'emulator': return _handleEmulator(args); case 'avdmanager': return _handleAvdManager(args); } - throw new StateError('Unexpected process call: $command'); + throw StateError('Unexpected process call: $command'); } ProcessResult _handleEmulator(List args) { if (_equality.equals(args, ['-list-avds'])) { - return new ProcessResult(101, 0, '${_existingAvds.join('\n')}\n', ''); + return ProcessResult(101, 0, '${_existingAvds.join('\n')}\n', ''); } - throw new ProcessException('emulator', args); + throw ProcessException('emulator', args); } ProcessResult _handleAvdManager(List args) { if (_equality.equals(args, ['list', 'device', '-c'])) { - return new ProcessResult(101, 0, 'test\ntest2\npixel\npixel-xl\n', ''); + return ProcessResult(101, 0, 'test\ntest2\npixel\npixel-xl\n', ''); } if (_equality.equals(args, ['create', 'avd', '-n', 'temp'])) { - return new ProcessResult(101, 1, '', mockCreateFailureOutput); + return ProcessResult(101, 1, '', mockCreateFailureOutput); } if (args.length == 8 && _equality.equals(args, @@ -244,7 +244,7 @@ class MockProcessManager extends Mock implements ProcessManager { final String name = args[3]; // Error if this AVD already existed if (_existingAvds.contains(name)) { - return new ProcessResult( + return ProcessResult( 101, 1, '', @@ -252,10 +252,10 @@ class MockProcessManager extends Mock implements ProcessManager { 'Use --force if you want to replace it.'); } else { _existingAvds.add(name); - return new ProcessResult(101, 0, '', ''); + return ProcessResult(101, 0, '', ''); } } - throw new ProcessException('emulator', args); + throw ProcessException('emulator', args); } } diff --git a/packages/flutter_tools/test/flutter_manifest_test.dart b/packages/flutter_tools/test/flutter_manifest_test.dart index 2c29651e88..794ee95eee 100644 --- a/packages/flutter_tools/test/flutter_manifest_test.dart +++ b/packages/flutter_tools/test/flutter_manifest_test.dart @@ -534,13 +534,13 @@ flutter: }); testUsingContextAndFs('Validate manifest on Posix FS', - new MemoryFileSystem(style: FileSystemStyle.posix), () { + MemoryFileSystem(style: FileSystemStyle.posix), () { assertSchemaIsReadable(); } ); testUsingContextAndFs('Validate manifest on Windows FS', - new MemoryFileSystem(style: FileSystemStyle.windows), () { + MemoryFileSystem(style: FileSystemStyle.windows), () { assertSchemaIsReadable(); } ); diff --git a/packages/flutter_tools/test/forbidden_imports_test.dart b/packages/flutter_tools/test/forbidden_imports_test.dart index 16efccb076..cf3b387827 100644 --- a/packages/flutter_tools/test/forbidden_imports_test.dart +++ b/packages/flutter_tools/test/forbidden_imports_test.dart @@ -21,7 +21,7 @@ void main() { .map(_asFile); for (File file in files) { for (String line in file.readAsLinesSync()) { - if (line.startsWith(new RegExp(r'import.*dart:io')) && + if (line.startsWith(RegExp(r'import.*dart:io')) && !line.contains('ignore: dart_io_import')) { final String relativePath = fs.path.relative(file.path, from:flutterTools); fail("$relativePath imports 'dart:io'; import 'lib/src/base/io.dart' instead"); @@ -39,7 +39,7 @@ void main() { .map(_asFile); for (File file in files) { for (String line in file.readAsLinesSync()) { - if (line.startsWith(new RegExp(r'import.*package:path/path.dart'))) { + if (line.startsWith(RegExp(r'import.*package:path/path.dart'))) { final String relativePath = fs.path.relative(file.path, from:flutterTools); fail("$relativePath imports 'package:path/path.dart'; use 'fs.path' instead"); } diff --git a/packages/flutter_tools/test/hot_test.dart b/packages/flutter_tools/test/hot_test.dart index d074ff1b7a..9d92cd2d8a 100644 --- a/packages/flutter_tools/test/hot_test.dart +++ b/packages/flutter_tools/test/hot_test.dart @@ -93,35 +93,35 @@ void main() { }); group('hotRestart', () { - final MockResidentCompiler residentCompiler = new MockResidentCompiler(); + final MockResidentCompiler residentCompiler = MockResidentCompiler(); MockLocalEngineArtifacts mockArtifacts; setUp(() { - mockArtifacts = new MockLocalEngineArtifacts(); + mockArtifacts = MockLocalEngineArtifacts(); when(mockArtifacts.getArtifactPath(Artifact.flutterPatchedSdkPath)).thenReturn('some/path'); }); testUsingContext('no setup', () async { - final List devices = [new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false)]; - expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, true); + final List devices = [FlutterDevice(MockDevice(), generator: residentCompiler, trackWidgetCreation: false)]; + expect((await HotRunner(devices).restart(fullRestart: true)).isOk, true); }, overrides: { Artifacts: () => mockArtifacts, }); testUsingContext('setup function succeeds', () async { - final List devices = [new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false)]; - expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, true); + final List devices = [FlutterDevice(MockDevice(), generator: residentCompiler, trackWidgetCreation: false)]; + expect((await HotRunner(devices).restart(fullRestart: true)).isOk, true); }, overrides: { Artifacts: () => mockArtifacts, - HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: true), + HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: true), }); testUsingContext('setup function fails', () async { - final List devices = [new FlutterDevice(new MockDevice(), generator: residentCompiler, trackWidgetCreation: false)]; - expect((await new HotRunner(devices).restart(fullRestart: true)).isOk, false); + final List devices = [FlutterDevice(MockDevice(), generator: residentCompiler, trackWidgetCreation: false)]; + expect((await HotRunner(devices).restart(fullRestart: true)).isOk, false); }, overrides: { Artifacts: () => mockArtifacts, - HotRunnerConfig: () => new TestHotRunnerConfig(successfulSetup: false), + HotRunnerConfig: () => TestHotRunnerConfig(successfulSetup: false), }); }); } diff --git a/packages/flutter_tools/test/integration/expression_evaluation_test.dart b/packages/flutter_tools/test/integration/expression_evaluation_test.dart index c7401fcfef..3648669612 100644 --- a/packages/flutter_tools/test/integration/expression_evaluation_test.dart +++ b/packages/flutter_tools/test/integration/expression_evaluation_test.dart @@ -17,13 +17,13 @@ import 'test_driver.dart'; void main() { group('expression evaluation', () { Directory tempDir; - final BasicProject _project = new BasicProject(); + final BasicProject _project = BasicProject(); FlutterTestDriver _flutter; setUp(() async { tempDir = fs.systemTempDirectory.createTempSync('flutter_expression_test.'); await _project.setUpIn(tempDir); - _flutter = new FlutterTestDriver(tempDir); + _flutter = FlutterTestDriver(tempDir); }); tearDown(() async { @@ -58,11 +58,11 @@ void main() { Future evaluateComplexExpressions() async { final VMInstanceRef res = await _flutter.evaluateExpression('new DateTime.now().year'); - expect(res is VMIntInstanceRef && res.value == new DateTime.now().year, isTrue); + expect(res is VMIntInstanceRef && res.value == DateTime.now().year, isTrue); } Future evaluateComplexReturningExpressions() async { - final DateTime now = new DateTime.now(); + final DateTime now = DateTime.now(); final VMInstanceRef resp = await _flutter.evaluateExpression('new DateTime.now()'); expect(resp.klass.name, equals('DateTime')); // Ensure we got a reasonable approximation. The more accurate we try to diff --git a/packages/flutter_tools/test/integration/flutter_attach_test.dart b/packages/flutter_tools/test/integration/flutter_attach_test.dart index b31d5f896f..61452b7fb2 100644 --- a/packages/flutter_tools/test/integration/flutter_attach_test.dart +++ b/packages/flutter_tools/test/integration/flutter_attach_test.dart @@ -11,14 +11,14 @@ import 'test_driver.dart'; void main() { FlutterTestDriver _flutterRun, _flutterAttach; - final BasicProject _project = new BasicProject(); + final BasicProject _project = BasicProject(); Directory tempDir; setUp(() async { tempDir = fs.systemTempDirectory.createTempSync('flutter_attach_test.'); await _project.setUpIn(tempDir); - _flutterRun = new FlutterTestDriver(tempDir, logPrefix: 'RUN'); - _flutterAttach = new FlutterTestDriver(tempDir, logPrefix: 'ATTACH'); + _flutterRun = FlutterTestDriver(tempDir, logPrefix: 'RUN'); + _flutterAttach = FlutterTestDriver(tempDir, logPrefix: 'ATTACH'); }); tearDown(() async { @@ -44,7 +44,7 @@ void main() { await _flutterRun.run(withDebugger: true); await _flutterAttach.attach(_flutterRun.vmServicePort); await _flutterAttach.quit(); - _flutterAttach = new FlutterTestDriver(tempDir, logPrefix: 'ATTACH-2'); + _flutterAttach = FlutterTestDriver(tempDir, logPrefix: 'ATTACH-2'); await _flutterAttach.attach(_flutterRun.vmServicePort); await _flutterAttach.hotReload(); }); diff --git a/packages/flutter_tools/test/integration/flutter_run_test.dart b/packages/flutter_tools/test/integration/flutter_run_test.dart index 8374eebe9a..7cbc97bbc6 100644 --- a/packages/flutter_tools/test/integration/flutter_run_test.dart +++ b/packages/flutter_tools/test/integration/flutter_run_test.dart @@ -13,7 +13,7 @@ import 'test_data/basic_project.dart'; void main() { group('flutter_run', () { Directory tempDir; - final BasicProject _project = new BasicProject(); + final BasicProject _project = BasicProject(); setUp(() async { tempDir = fs.systemTempDirectory.createTempSync('flutter_run_integration_test.'); diff --git a/packages/flutter_tools/test/integration/hot_reload_test.dart b/packages/flutter_tools/test/integration/hot_reload_test.dart index 28330c1522..97eb158bdf 100644 --- a/packages/flutter_tools/test/integration/hot_reload_test.dart +++ b/packages/flutter_tools/test/integration/hot_reload_test.dart @@ -15,13 +15,13 @@ import 'test_driver.dart'; void main() { group('hot', () { Directory tempDir; - final BasicProject _project = new BasicProject(); + final BasicProject _project = BasicProject(); FlutterTestDriver _flutter; setUp(() async { tempDir = fs.systemTempDirectory.createTempSync('flutter_hot_reload_test_app.'); await _project.setUpIn(tempDir); - _flutter = new FlutterTestDriver(tempDir); + _flutter = FlutterTestDriver(tempDir); }); tearDown(() async { @@ -46,7 +46,7 @@ void main() { // Hit breakpoint using a file:// URI. final VMIsolate isolate = await _flutter.breakAt( - new Uri.file(_project.breakpointFile).toString(), + Uri.file(_project.breakpointFile).toString(), _project.breakpointLine); expect(isolate.pauseEvent, isInstanceOf()); diff --git a/packages/flutter_tools/test/integration/lifetime_test.dart b/packages/flutter_tools/test/integration/lifetime_test.dart index 471f59e248..76aa6444cd 100644 --- a/packages/flutter_tools/test/integration/lifetime_test.dart +++ b/packages/flutter_tools/test/integration/lifetime_test.dart @@ -18,14 +18,14 @@ const Duration requiredLifespan = Duration(seconds: 5); void main() { group('flutter run', () { - final BasicProject _project = new BasicProject(); + final BasicProject _project = BasicProject(); FlutterTestDriver _flutter; Directory tempDir; setUp(() async { tempDir = fs.systemTempDirectory.createTempSync('flutter_lifetime_test.'); await _project.setUpIn(tempDir); - _flutter = new FlutterTestDriver(tempDir); + _flutter = FlutterTestDriver(tempDir); }); tearDown(() async { @@ -35,13 +35,13 @@ void main() { test('does not terminate when a debugger is attached', () async { await _flutter.run(withDebugger: true); - await new Future.delayed(requiredLifespan); + await Future.delayed(requiredLifespan); expect(_flutter.hasExited, equals(false)); }); test('does not terminate when a debugger is attached and pause-on-exceptions', () async { await _flutter.run(withDebugger: true, pauseOnExceptions: true); - await new Future.delayed(requiredLifespan); + await Future.delayed(requiredLifespan); expect(_flutter.hasExited, equals(false)); }); }, timeout: const Timeout.factor(6)); diff --git a/packages/flutter_tools/test/integration/test_data/test_project.dart b/packages/flutter_tools/test/integration/test_data/test_project.dart index 1b73c45c1b..ae9b739344 100644 --- a/packages/flutter_tools/test/integration/test_data/test_project.dart +++ b/packages/flutter_tools/test/integration/test_data/test_project.dart @@ -29,7 +29,7 @@ abstract class TestProject { int lineContaining(String contents, String search) { final int index = contents.split('\n').indexWhere((String l) => l.contains(search)); if (index == -1) - throw new Exception("Did not find '$search' inside the file"); + throw Exception("Did not find '$search' inside the file"); return index; } } diff --git a/packages/flutter_tools/test/integration/test_driver.dart b/packages/flutter_tools/test/integration/test_driver.dart index fb350f4348..e70eb1573c 100644 --- a/packages/flutter_tools/test/integration/test_driver.dart +++ b/packages/flutter_tools/test/integration/test_driver.dart @@ -30,10 +30,10 @@ class FlutterTestDriver { final String _logPrefix; Process _proc; int _procPid; - final StreamController _stdout = new StreamController.broadcast(); - final StreamController _stderr = new StreamController.broadcast(); - final StreamController _allMessages = new StreamController.broadcast(); - final StringBuffer _errorBuffer = new StringBuffer(); + final StreamController _stdout = StreamController.broadcast(); + final StreamController _stderr = StreamController.broadcast(); + final StreamController _allMessages = StreamController.broadcast(); + final StringBuffer _errorBuffer = StringBuffer(); String _lastResponse; String _currentRunningAppId; Uri _vmServiceWsUri; @@ -125,13 +125,13 @@ class FlutterTestDriver { _vmServiceWsUri = Uri.parse(wsUriString); _vmServicePort = debugPort['params']['port']; // Proxy the stream/sink for the VM Client so we can debugPrint it. - final StreamChannel channel = new IOWebSocketChannel.connect(_vmServiceWsUri) + final StreamChannel channel = IOWebSocketChannel.connect(_vmServiceWsUri) .cast() .changeStream((Stream stream) => stream.map(_debugPrint)) .changeSink((StreamSink sink) => - new StreamController() + StreamController() ..stream.listen((String s) => sink.add(_debugPrint(s)))); - vmService = new VMServiceClient(channel); + vmService = VMServiceClient(channel); // Because we start paused, resume so the app is in a "running" state as // expected by tests. Tests will reload/restart as required if they need @@ -153,7 +153,7 @@ class FlutterTestDriver { Future _restart({bool fullRestart = false, bool pause = false}) async { if (_currentRunningAppId == null) - throw new Exception('App has not started yet'); + throw Exception('App has not started yet'); final dynamic hotReloadResp = await _sendRequest( 'app.restart', @@ -291,7 +291,7 @@ class FlutterTestDriver { final VMIsolate isolate = await vm.isolates.first.load(); final VMStack stack = await isolate.getStack(); if (stack.frames.isEmpty) { - throw new Exception('Stack is empty'); + throw Exception('Stack is empty'); } return stack.frames.first; } @@ -308,7 +308,7 @@ class FlutterTestDriver { Duration timeout, bool ignoreAppStopEvent = false, }) async { - final Completer> response = new Completer>(); + final Completer> response = Completer>(); StreamSubscription sub; sub = _stdout.stream.listen((String line) async { final dynamic json = _parseFlutterResponse(line); @@ -321,7 +321,7 @@ class FlutterTestDriver { response.complete(json); } else if (!ignoreAppStopEvent && json['event'] == 'app.stop') { await sub.cancel(); - final StringBuffer error = new StringBuffer(); + final StringBuffer error = StringBuffer(); error.write('Received app.stop event while waiting for '); error.write('${event != null ? '$event event' : 'response to request $id.'}.\n\n'); if (json['params'] != null && json['params']['error'] != null) { @@ -345,10 +345,10 @@ class FlutterTestDriver { Future _timeoutWithMessages(Future Function() f, {Duration timeout, String message}) { // Capture output to a buffer so if we don't get the response we want we can show // the output that did arrive in the timeout error. - final StringBuffer messages = new StringBuffer(); - final DateTime start = new DateTime.now(); + final StringBuffer messages = StringBuffer(); + final DateTime start = DateTime.now(); void logMessage(String m) { - final int ms = new DateTime.now().difference(start).inMilliseconds; + final int ms = DateTime.now().difference(start).inMilliseconds; messages.writeln('[+ ${ms.toString().padLeft(5)}] $m'); } final StreamSubscription sub = _allMessages.stream.listen(logMessage); diff --git a/packages/flutter_tools/test/integration/test_utils.dart b/packages/flutter_tools/test/integration/test_utils.dart index 8f8a9d8a11..b75543a46c 100644 --- a/packages/flutter_tools/test/integration/test_utils.dart +++ b/packages/flutter_tools/test/integration/test_utils.dart @@ -39,10 +39,10 @@ Future getPackages(String folder) async { 'get' ]; final Process process = await processManager.start(command, workingDirectory: folder); - final StringBuffer errorOutput = new StringBuffer(); + final StringBuffer errorOutput = StringBuffer(); process.stderr.transform(utf8.decoder).listen(errorOutput.write); final int exitCode = await process.exitCode; if (exitCode != 0) - throw new Exception( + throw Exception( 'flutter packages get failed: ${errorOutput.toString()}'); } diff --git a/packages/flutter_tools/test/intellij/intellij_test.dart b/packages/flutter_tools/test/intellij/intellij_test.dart index 2236616359..2da197ff6d 100644 --- a/packages/flutter_tools/test/intellij/intellij_test.dart +++ b/packages/flutter_tools/test/intellij/intellij_test.dart @@ -23,13 +23,13 @@ void main() { } setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); }); group('IntelliJ', () { group('plugins', () { testUsingContext('found', () async { - final IntelliJPlugins plugins = new IntelliJPlugins(_kPluginsPath); + final IntelliJPlugins plugins = IntelliJPlugins(_kPluginsPath); final Archive dartJarArchive = buildSingleFileArchive('META-INF/plugin.xml', r''' @@ -40,7 +40,7 @@ void main() { '''); writeFileCreatingDirectories( fs.path.join(_kPluginsPath, 'Dart', 'lib', 'Dart.jar'), - new ZipEncoder().encode(dartJarArchive)); + ZipEncoder().encode(dartJarArchive)); final Archive flutterJarArchive = buildSingleFileArchive('META-INF/plugin.xml', r''' @@ -51,7 +51,7 @@ void main() { '''); writeFileCreatingDirectories( fs.path.join(_kPluginsPath, 'flutter-intellij.jar'), - new ZipEncoder().encode(flutterJarArchive)); + ZipEncoder().encode(flutterJarArchive)); final List messages = []; plugins.validatePackage(messages, ['Dart'], 'Dart'); @@ -72,7 +72,7 @@ void main() { }); testUsingContext('not found', () async { - final IntelliJPlugins plugins = new IntelliJPlugins(_kPluginsPath); + final IntelliJPlugins plugins = IntelliJPlugins(_kPluginsPath); final List messages = []; plugins.validatePackage(messages, ['Dart'], 'Dart'); @@ -97,10 +97,10 @@ void main() { const String _kPluginsPath = '/data/intellij/plugins'; Archive buildSingleFileArchive(String path, String content) { - final Archive archive = new Archive(); + final Archive archive = Archive(); final List bytes = utf8.encode(content); - archive.addFile(new ArchiveFile(path, bytes.length, bytes)); + archive.addFile(ArchiveFile(path, bytes.length, bytes)); return archive; } diff --git a/packages/flutter_tools/test/ios/cocoapods_test.dart b/packages/flutter_tools/test/ios/cocoapods_test.dart index e732615441..a39c8d2a22 100644 --- a/packages/flutter_tools/test/ios/cocoapods_test.dart +++ b/packages/flutter_tools/test/ios/cocoapods_test.dart @@ -42,12 +42,12 @@ void main() { setUp(() async { Cache.flutterRoot = 'flutter'; - fs = new MemoryFileSystem(); - mockProcessManager = new MockProcessManager(); - mockXcodeProjectInterpreter = new MockXcodeProjectInterpreter(); + fs = MemoryFileSystem(); + mockProcessManager = MockProcessManager(); + mockXcodeProjectInterpreter = MockXcodeProjectInterpreter(); projectUnderTest = await FlutterProject.fromDirectory(fs.directory('project')); projectUnderTest.ios.directory.childDirectory('Runner.xcodeproj').createSync(recursive: true); - cocoaPodsUnderTest = new CocoaPods(); + cocoaPodsUnderTest = CocoaPods(); pretendPodVersionIs('1.5.0'); fs.file(fs.path.join( Cache.flutterRoot, 'packages', 'flutter_tools', 'templates', 'cocoapods', 'Podfile-objc' @@ -399,7 +399,7 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by projectUnderTest.ios.podManifestLock ..createSync(recursive: true) ..writeAsStringSync('Existing lock file.'); - await new Future.delayed(const Duration(milliseconds: 10)); + await Future.delayed(const Duration(milliseconds: 10)); projectUnderTest.ios.podfile ..writeAsStringSync('Updated Podfile'); await cocoaPodsUnderTest.processPods( @@ -488,5 +488,5 @@ Note: as of CocoaPods 1.0, `pod repo update` does not happen on `pod install` by class MockProcessManager extends Mock implements ProcessManager {} class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterpreter {} -ProcessResult exitsWithError([String stdout = '']) => new ProcessResult(1, 1, stdout, ''); -ProcessResult exitsHappy([String stdout = '']) => new ProcessResult(1, 0, stdout, ''); +ProcessResult exitsWithError([String stdout = '']) => ProcessResult(1, 1, stdout, ''); +ProcessResult exitsHappy([String stdout = '']) => ProcessResult(1, 0, stdout, ''); diff --git a/packages/flutter_tools/test/ios/code_signing_test.dart b/packages/flutter_tools/test/ios/code_signing_test.dart index 38b6b09685..be540de1e0 100644 --- a/packages/flutter_tools/test/ios/code_signing_test.dart +++ b/packages/flutter_tools/test/ios/code_signing_test.dart @@ -28,14 +28,14 @@ void main() { AnsiTerminal testTerminal; setUp(() { - mockProcessManager = new MockProcessManager(); - mockConfig = new MockConfig(); - mockIosProject = new MockIosProject(); + mockProcessManager = MockProcessManager(); + mockConfig = MockConfig(); + mockIosProject = MockIosProject(); when(mockIosProject.buildSettings).thenReturn({ 'For our purposes': 'a non-empty build settings map is valid', }); - testTerminal = new TestTerminal(); - app = new BuildableIOSApp(mockIosProject); + testTerminal = TestTerminal(); + app = BuildableIOSApp(mockIosProject); }); testUsingContext('No auto-sign if Xcode project settings are not available', () async { @@ -99,7 +99,7 @@ void main() { argThat(contains('find-identity')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode ''' @@ -111,27 +111,27 @@ void main() { ['security', 'find-certificate', '-c', '1111AAAA11', '-p'], environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode 'This is a mock certificate', '', )); - final MockProcess mockProcess = new MockProcess(); - final MockStdIn mockStdIn = new MockStdIn(); - final MockStream mockStdErr = new MockStream(); + final MockProcess mockProcess = MockProcess(); + final MockStdIn mockStdIn = MockStdIn(); + final MockStream mockStdErr = MockStream(); when(mockProcessManager.start( argThat(contains('openssl')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenAnswer((Invocation invocation) => new Future.value(mockProcess)); + )).thenAnswer((Invocation invocation) => Future.value(mockProcess)); when(mockProcess.stdin).thenReturn(mockStdIn); when(mockProcess.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'subject= /CN=iPhone Developer: Profile 1 (1111AAAA11)/OU=3333CCCC33/O=My Team/C=US' )) )); @@ -158,7 +158,7 @@ void main() { argThat(contains('find-identity')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode ''' @@ -170,27 +170,27 @@ void main() { ['security', 'find-certificate', '-c', '1111AAAA11', '-p'], environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode 'This is a mock certificate', '', )); - final MockProcess mockProcess = new MockProcess(); - final MockStdIn mockStdIn = new MockStdIn(); - final MockStream mockStdErr = new MockStream(); + final MockProcess mockProcess = MockProcess(); + final MockStdIn mockStdIn = MockStdIn(); + final MockStream mockStdErr = MockStream(); when(mockProcessManager.start( argThat(contains('openssl')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenAnswer((Invocation invocation) => new Future.value(mockProcess)); + )).thenAnswer((Invocation invocation) => Future.value(mockProcess)); when(mockProcess.stdin).thenReturn(mockStdIn); when(mockProcess.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'subject= /CN=iPhone Developer: Google Development (1111AAAA11)/OU=3333CCCC33/O=My Team/C=US' )) )); @@ -221,7 +221,7 @@ void main() { argThat(contains('find-identity')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode ''' @@ -232,37 +232,37 @@ void main() { '' )); mockTerminalStdInStream = - new Stream.fromFuture(new Future.value('3')); + Stream.fromFuture(Future.value('3')); when(mockProcessManager.runSync( ['security', 'find-certificate', '-c', '3333CCCC33', '-p'], environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode 'This is a mock certificate', '', )); - final MockProcess mockOpenSslProcess = new MockProcess(); - final MockStdIn mockOpenSslStdIn = new MockStdIn(); - final MockStream mockOpenSslStdErr = new MockStream(); + final MockProcess mockOpenSslProcess = MockProcess(); + final MockStdIn mockOpenSslStdIn = MockStdIn(); + final MockStream mockOpenSslStdErr = MockStream(); when(mockProcessManager.start( argThat(contains('openssl')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenAnswer((Invocation invocation) => new Future.value(mockOpenSslProcess)); + )).thenAnswer((Invocation invocation) => Future.value(mockOpenSslProcess)); when(mockOpenSslProcess.stdin).thenReturn(mockOpenSslStdIn); when(mockOpenSslProcess.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'subject= /CN=iPhone Developer: Profile 3 (3333CCCC33)/OU=4444DDDD44/O=My Team/C=US' )) )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => Future.value(0)); final Map signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); @@ -295,7 +295,7 @@ void main() { argThat(contains('find-identity')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode ''' @@ -306,37 +306,37 @@ void main() { '' )); mockTerminalStdInStream = - new Stream.fromFuture(new Future.error(new Exception('Cannot read from StdIn'))); + Stream.fromFuture(Future.error(Exception('Cannot read from StdIn'))); when(mockProcessManager.runSync( ['security', 'find-certificate', '-c', '1111AAAA11', '-p'], environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode 'This is a mock certificate', '', )); - final MockProcess mockOpenSslProcess = new MockProcess(); - final MockStdIn mockOpenSslStdIn = new MockStdIn(); - final MockStream mockOpenSslStdErr = new MockStream(); + final MockProcess mockOpenSslProcess = MockProcess(); + final MockStdIn mockOpenSslStdIn = MockStdIn(); + final MockStream mockOpenSslStdErr = MockStream(); when(mockProcessManager.start( argThat(contains('openssl')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenAnswer((Invocation invocation) => new Future.value(mockOpenSslProcess)); + )).thenAnswer((Invocation invocation) => Future.value(mockOpenSslProcess)); when(mockOpenSslProcess.stdin).thenReturn(mockOpenSslStdIn); when(mockOpenSslProcess.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'subject= /CN=iPhone Developer: Profile 1 (1111AAAA11)/OU=5555EEEE55/O=My Team/C=US' )), )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => Future.value(0)); final Map signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app, usesTerminalUi: false); @@ -363,7 +363,7 @@ void main() { argThat(contains('find-identity')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode ''' @@ -377,32 +377,32 @@ void main() { ['security', 'find-certificate', '-c', '3333CCCC33', '-p'], environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode 'This is a mock certificate', '', )); - final MockProcess mockOpenSslProcess = new MockProcess(); - final MockStdIn mockOpenSslStdIn = new MockStdIn(); - final MockStream mockOpenSslStdErr = new MockStream(); + final MockProcess mockOpenSslProcess = MockProcess(); + final MockStdIn mockOpenSslStdIn = MockStdIn(); + final MockStream mockOpenSslStdErr = MockStream(); when(mockProcessManager.start( argThat(contains('openssl')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenAnswer((Invocation invocation) => new Future.value(mockOpenSslProcess)); + )).thenAnswer((Invocation invocation) => Future.value(mockOpenSslProcess)); when(mockOpenSslProcess.stdin).thenReturn(mockOpenSslStdIn); when(mockOpenSslProcess.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'subject= /CN=iPhone Developer: Profile 3 (3333CCCC33)/OU=4444DDDD44/O=My Team/C=US' )) )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => Future.value(0)); when(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Profile 3 (3333CCCC33)'); final Map signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); @@ -433,7 +433,7 @@ void main() { argThat(contains('find-identity')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode ''' @@ -444,12 +444,12 @@ void main() { '' )); mockTerminalStdInStream = - new Stream.fromFuture(new Future.value('3')); + Stream.fromFuture(Future.value('3')); when(mockProcessManager.runSync( ['security', 'find-certificate', '-c', '3333CCCC33', '-p'], environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult( + )).thenReturn(ProcessResult( 1, // pid 0, // exitCode 'This is a mock certificate', @@ -457,25 +457,25 @@ void main() { )); - final MockProcess mockOpenSslProcess = new MockProcess(); - final MockStdIn mockOpenSslStdIn = new MockStdIn(); - final MockStream mockOpenSslStdErr = new MockStream(); + final MockProcess mockOpenSslProcess = MockProcess(); + final MockStdIn mockOpenSslStdIn = MockStdIn(); + final MockStream mockOpenSslStdErr = MockStream(); when(mockProcessManager.start( argThat(contains('openssl')), environment: anyNamed('environment'), workingDirectory: anyNamed('workingDirectory'), - )).thenAnswer((Invocation invocation) => new Future.value(mockOpenSslProcess)); + )).thenAnswer((Invocation invocation) => Future.value(mockOpenSslProcess)); when(mockOpenSslProcess.stdin).thenReturn(mockOpenSslStdIn); when(mockOpenSslProcess.stdout) - .thenAnswer((Invocation invocation) => new Stream>.fromFuture( - new Future>.value(utf8.encode( + .thenAnswer((Invocation invocation) => Stream>.fromFuture( + Future>.value(utf8.encode( 'subject= /CN=iPhone Developer: Profile 3 (3333CCCC33)/OU=4444DDDD44/O=My Team/C=US' )) )); when(mockOpenSslProcess.stderr).thenAnswer((Invocation invocation) => mockOpenSslStdErr); - when(mockOpenSslProcess.exitCode).thenAnswer((_) => new Future.value(0)); + when(mockOpenSslProcess.exitCode).thenAnswer((_) => Future.value(0)); when(mockConfig.getValue('ios-signing-cert')).thenReturn('iPhone Developer: Invalid Profile'); final Map signingConfigs = await getCodeSigningIdentityDevelopmentTeam(iosApp: app); @@ -499,14 +499,14 @@ void main() { }); } -final ProcessResult exitsHappy = new ProcessResult( +final ProcessResult exitsHappy = ProcessResult( 1, // pid 0, // exitCode '', // stdout '', // stderr ); -final ProcessResult exitsFail = new ProcessResult( +final ProcessResult exitsFail = ProcessResult( 2, // pid 1, // exitCode '', // stdout diff --git a/packages/flutter_tools/test/ios/devices_test.dart b/packages/flutter_tools/test/ios/devices_test.dart index b2a129122f..39518a6d58 100644 --- a/packages/flutter_tools/test/ios/devices_test.dart +++ b/packages/flutter_tools/test/ios/devices_test.dart @@ -26,14 +26,14 @@ class MockFile extends Mock implements File {} class MockProcess extends Mock implements Process {} void main() { - final FakePlatform osx = new FakePlatform.fromPlatform(const LocalPlatform()); + final FakePlatform osx = FakePlatform.fromPlatform(const LocalPlatform()); osx.operatingSystem = 'macos'; group('getAttachedDevices', () { MockIMobileDevice mockIMobileDevice; setUp(() { - mockIMobileDevice = new MockIMobileDevice(); + mockIMobileDevice = MockIMobileDevice(); }); testUsingContext('return no devices if Xcode is not installed', () async { @@ -46,7 +46,7 @@ void main() { testUsingContext('returns no devices if none are attached', () async { when(iMobileDevice.isInstalled).thenReturn(true); when(iMobileDevice.getAvailableDeviceIDs()) - .thenAnswer((Invocation invocation) => new Future.value('')); + .thenAnswer((Invocation invocation) => Future.value('')); final List devices = await IOSDevice.getAttachedDevices(); expect(devices, isEmpty); }, overrides: { @@ -56,18 +56,18 @@ void main() { testUsingContext('returns attached devices', () async { when(iMobileDevice.isInstalled).thenReturn(true); when(iMobileDevice.getAvailableDeviceIDs()) - .thenAnswer((Invocation invocation) => new Future.value(''' + .thenAnswer((Invocation invocation) => Future.value(''' 98206e7a4afd4aedaff06e687594e089dede3c44 f577a7903cc54959be2e34bc4f7f80b7009efcf4 ''')); when(iMobileDevice.getInfoForDevice('98206e7a4afd4aedaff06e687594e089dede3c44', 'DeviceName')) - .thenAnswer((_) => new Future.value('La tele me regarde')); + .thenAnswer((_) => Future.value('La tele me regarde')); when(iMobileDevice.getInfoForDevice('98206e7a4afd4aedaff06e687594e089dede3c44', 'ProductVersion')) - .thenAnswer((_) => new Future.value('10.3.2')); + .thenAnswer((_) => Future.value('10.3.2')); when(iMobileDevice.getInfoForDevice('f577a7903cc54959be2e34bc4f7f80b7009efcf4', 'DeviceName')) - .thenAnswer((_) => new Future.value('Puits sans fond')); + .thenAnswer((_) => Future.value('Puits sans fond')); when(iMobileDevice.getInfoForDevice('f577a7903cc54959be2e34bc4f7f80b7009efcf4', 'ProductVersion')) - .thenAnswer((_) => new Future.value('11.0')); + .thenAnswer((_) => Future.value('11.0')); final List devices = await IOSDevice.getAttachedDevices(); expect(devices, hasLength(2)); expect(devices[0].id, '98206e7a4afd4aedaff06e687594e089dede3c44'); @@ -95,15 +95,15 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4 MockIosProject mockIosProject; setUp(() { - mockIMobileDevice = new MockIMobileDevice(); - mockIosProject = new MockIosProject(); + mockIMobileDevice = MockIMobileDevice(); + mockIosProject = MockIosProject(); }); testUsingContext('suppresses non-Flutter lines from output', () async { when(mockIMobileDevice.startLogger()).thenAnswer((Invocation invocation) { - final Process mockProcess = new MockProcess(); + final Process mockProcess = MockProcess(); when(mockProcess.stdout).thenAnswer((Invocation invocation) => - new Stream>.fromIterable(>[''' + Stream>.fromIterable(>[''' Runner(Flutter)[297] : A is for ari Runner(libsystem_asl.dylib)[297] : libMobileGestalt MobileGestaltSupport.m:153: pid 123 (Runner) does not have sandbox access for frZQaeyWLUvLjeuEK43hmg and IS NOT appropriately entitled Runner(libsystem_asl.dylib)[297] : libMobileGestalt MobileGestalt.c:550: no access to InverseDeviceID (see ) @@ -114,13 +114,13 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4 .thenAnswer((Invocation invocation) => const Stream>.empty()); // Delay return of exitCode until after stdout stream data, since it terminates the logger. when(mockProcess.exitCode) - .thenAnswer((Invocation invocation) => new Future.delayed(Duration.zero, () => 0)); - return new Future.value(mockProcess); + .thenAnswer((Invocation invocation) => Future.delayed(Duration.zero, () => 0)); + return Future.value(mockProcess); }); - final IOSDevice device = new IOSDevice('123456'); + final IOSDevice device = IOSDevice('123456'); final DeviceLogReader logReader = device.getLogReader( - app: new BuildableIOSApp(mockIosProject), + app: BuildableIOSApp(mockIosProject), ); final List lines = await logReader.logLines.toList(); @@ -131,9 +131,9 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4 testUsingContext('includes multi-line Flutter logs in the output', () async { when(mockIMobileDevice.startLogger()).thenAnswer((Invocation invocation) { - final Process mockProcess = new MockProcess(); + final Process mockProcess = MockProcess(); when(mockProcess.stdout).thenAnswer((Invocation invocation) => - new Stream>.fromIterable(>[''' + Stream>.fromIterable(>[''' Runner(Flutter)[297] : This is a multi-line message, with another Flutter message following it. Runner(Flutter)[297] : This is a multi-line message, @@ -144,13 +144,13 @@ f577a7903cc54959be2e34bc4f7f80b7009efcf4 .thenAnswer((Invocation invocation) => const Stream>.empty()); // Delay return of exitCode until after stdout stream data, since it terminates the logger. when(mockProcess.exitCode) - .thenAnswer((Invocation invocation) => new Future.delayed(Duration.zero, () => 0)); - return new Future.value(mockProcess); + .thenAnswer((Invocation invocation) => Future.delayed(Duration.zero, () => 0)); + return Future.value(mockProcess); }); - final IOSDevice device = new IOSDevice('123456'); + final IOSDevice device = IOSDevice('123456'); final DeviceLogReader logReader = device.getLogReader( - app: new BuildableIOSApp(mockIosProject), + app: BuildableIOSApp(mockIosProject), ); final List lines = await logReader.logLines.toList(); diff --git a/packages/flutter_tools/test/ios/ios_workflow_test.dart b/packages/flutter_tools/test/ios/ios_workflow_test.dart index 981d4a7d17..a4cacf7bb2 100644 --- a/packages/flutter_tools/test/ios/ios_workflow_test.dart +++ b/packages/flutter_tools/test/ios/ios_workflow_test.dart @@ -27,11 +27,11 @@ void main() { FileSystem fs; setUp(() { - iMobileDevice = new MockIMobileDevice(); - xcode = new MockXcode(); - processManager = new MockProcessManager(); - cocoaPods = new MockCocoaPods(); - fs = new MemoryFileSystem(); + iMobileDevice = MockIMobileDevice(); + xcode = MockXcode(); + processManager = MockProcessManager(); + cocoaPods = MockCocoaPods(); + fs = MemoryFileSystem(); when(cocoaPods.evaluateCocoaPodsInstallation) .thenAnswer((_) async => CocoaPodsStatus.recommended); @@ -42,7 +42,7 @@ void main() { testUsingContext('Emit missing status when nothing is installed', () async { when(xcode.isInstalled).thenReturn(false); when(xcode.xcodeSelectPath).thenReturn(null); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget( + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget( hasHomebrew: false, hasIosDeploy: false, ); @@ -57,7 +57,7 @@ void main() { testUsingContext('Emits partial status when Xcode is not installed', () async { when(xcode.isInstalled).thenReturn(false); when(xcode.xcodeSelectPath).thenReturn(null); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -69,7 +69,7 @@ void main() { testUsingContext('Emits partial status when Xcode is partially installed', () async { when(xcode.isInstalled).thenReturn(false); when(xcode.xcodeSelectPath).thenReturn('/Library/Developer/CommandLineTools'); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -85,7 +85,7 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(false); when(xcode.eulaSigned).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -101,7 +101,7 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(false); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -117,7 +117,7 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(hasHomebrew: false); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(hasHomebrew: false); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -133,11 +133,11 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { - IMobileDevice: () => new MockIMobileDevice(isInstalled: false, isWorking: false), + IMobileDevice: () => MockIMobileDevice(isInstalled: false, isWorking: false), Xcode: () => xcode, CocoaPods: () => cocoaPods, }); @@ -149,11 +149,11 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { - IMobileDevice: () => new MockIMobileDevice(isWorking: false), + IMobileDevice: () => MockIMobileDevice(isWorking: false), Xcode: () => xcode, CocoaPods: () => cocoaPods, }); @@ -165,7 +165,7 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(hasIosDeploy: false); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(hasIosDeploy: false); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -181,7 +181,7 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(iosDeployVersionText: '1.8.0'); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(iosDeployVersionText: '1.8.0'); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -199,7 +199,7 @@ void main() { when(cocoaPods.evaluateCocoaPodsInstallation) .thenAnswer((_) async => CocoaPodsStatus.notInstalled); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -217,7 +217,7 @@ void main() { when(cocoaPods.evaluateCocoaPodsInstallation) .thenAnswer((_) async => CocoaPodsStatus.belowRecommendedVersion); when(xcode.isSimctlInstalled).thenReturn(true); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -235,7 +235,7 @@ void main() { when(cocoaPods.isCocoaPodsInitialized).thenAnswer((_) async => false); when(xcode.isSimctlInstalled).thenReturn(true); - final ValidationResult result = await new IOSWorkflowTestTarget().validate(); + final ValidationResult result = await IOSWorkflowTestTarget().validate(); expect(result.type, ValidationType.partial); }, overrides: { FileSystem: () => fs, @@ -252,7 +252,7 @@ void main() { when(xcode.isInstalledAndMeetsVersionCheck).thenReturn(true); when(xcode.eulaSigned).thenReturn(true); when(xcode.isSimctlInstalled).thenReturn(false); - final IOSWorkflowTestTarget workflow = new IOSWorkflowTestTarget(); + final IOSWorkflowTestTarget workflow = IOSWorkflowTestTarget(); final ValidationResult result = await workflow.validate(); expect(result.type, ValidationType.partial); }, overrides: { @@ -272,7 +272,7 @@ void main() { ensureDirectoryExists(fs.path.join(homeDirPath, '.cocoapods', 'repos', 'master', 'README.md')); - final ValidationResult result = await new IOSWorkflowTestTarget().validate(); + final ValidationResult result = await IOSWorkflowTestTarget().validate(); expect(result.type, ValidationType.installed); }, overrides: { FileSystem: () => fs, @@ -284,7 +284,7 @@ void main() { }); } -final ProcessResult exitsHappy = new ProcessResult( +final ProcessResult exitsHappy = ProcessResult( 1, // pid 0, // exitCode '', // stdout @@ -295,7 +295,7 @@ class MockIMobileDevice extends IMobileDevice { MockIMobileDevice({ this.isInstalled = true, bool isWorking = true, - }) : isWorking = new Future.value(isWorking); + }) : isWorking = Future.value(isWorking); @override final bool isInstalled; @@ -314,9 +314,9 @@ class IOSWorkflowTestTarget extends IOSValidator { bool hasIosDeploy = true, String iosDeployVersionText = '1.9.2', bool hasIDeviceInstaller = true, - }) : hasIosDeploy = new Future.value(hasIosDeploy), - iosDeployVersionText = new Future.value(iosDeployVersionText), - hasIDeviceInstaller = new Future.value(hasIDeviceInstaller); + }) : hasIosDeploy = Future.value(hasIosDeploy), + iosDeployVersionText = Future.value(iosDeployVersionText), + hasIDeviceInstaller = Future.value(hasIDeviceInstaller); @override final bool hasHomebrew; diff --git a/packages/flutter_tools/test/ios/mac_test.dart b/packages/flutter_tools/test/ios/mac_test.dart index c30631e541..8e3ccc3cfe 100644 --- a/packages/flutter_tools/test/ios/mac_test.dart +++ b/packages/flutter_tools/test/ios/mac_test.dart @@ -22,12 +22,12 @@ class MockXcodeProjectInterpreter extends Mock implements XcodeProjectInterprete void main() { group('IMobileDevice', () { - final FakePlatform osx = new FakePlatform.fromPlatform(const LocalPlatform()) + final FakePlatform osx = FakePlatform.fromPlatform(const LocalPlatform()) ..operatingSystem = 'macos'; MockProcessManager mockProcessManager; setUp(() { - mockProcessManager = new MockProcessManager(); + mockProcessManager = MockProcessManager(); }); testUsingContext('getAvailableDeviceIDs throws ToolExit when libimobiledevice is not installed', () async { @@ -40,7 +40,7 @@ void main() { testUsingContext('getAvailableDeviceIDs throws ToolExit when idevice_id returns non-zero', () async { when(mockProcessManager.run(['idevice_id', '-l'])) - .thenAnswer((_) => new Future.value(new ProcessResult(1, 1, '', 'Sad today'))); + .thenAnswer((_) => Future.value(ProcessResult(1, 1, '', 'Sad today'))); expect(() async => await iMobileDevice.getAvailableDeviceIDs(), throwsToolExit()); }, overrides: { ProcessManager: () => mockProcessManager, @@ -48,7 +48,7 @@ void main() { testUsingContext('getAvailableDeviceIDs returns idevice_id output when installed', () async { when(mockProcessManager.run(['idevice_id', '-l'])) - .thenAnswer((_) => new Future.value(new ProcessResult(1, 0, 'foo', ''))); + .thenAnswer((_) => Future.value(ProcessResult(1, 0, 'foo', ''))); expect(await iMobileDevice.getAvailableDeviceIDs(), 'foo'); }, overrides: { ProcessManager: () => mockProcessManager, @@ -60,8 +60,8 @@ void main() { MockFile mockOutputFile; setUp(() { - mockProcessManager = new MockProcessManager(); - mockOutputFile = new MockFile(); + mockProcessManager = MockProcessManager(); + mockOutputFile = MockFile(); }); testUsingContext('error if idevicescreenshot is not installed', () async { @@ -71,7 +71,7 @@ void main() { when(mockProcessManager.run(['idevicescreenshot', outputPath], environment: null, workingDirectory: null - )).thenAnswer((_) => new Future.value(new ProcessResult(4, 1, '', ''))); + )).thenAnswer((_) => Future.value(ProcessResult(4, 1, '', ''))); expect(() async => await iMobileDevice.takeScreenshot(mockOutputFile), throwsA(anything)); }, overrides: { @@ -82,7 +82,7 @@ void main() { testUsingContext('idevicescreenshot captures and returns screenshot', () async { when(mockOutputFile.path).thenReturn(outputPath); when(mockProcessManager.run(any, environment: null, workingDirectory: null)).thenAnswer( - (Invocation invocation) => new Future.value(new ProcessResult(4, 0, '', ''))); + (Invocation invocation) => Future.value(ProcessResult(4, 0, '', ''))); await iMobileDevice.takeScreenshot(mockOutputFile); verify(mockProcessManager.run(['idevicescreenshot', outputPath], @@ -101,9 +101,9 @@ void main() { MockXcodeProjectInterpreter mockXcodeProjectInterpreter; setUp(() { - mockProcessManager = new MockProcessManager(); - mockXcodeProjectInterpreter = new MockXcodeProjectInterpreter(); - xcode = new Xcode(); + mockProcessManager = MockProcessManager(); + mockXcodeProjectInterpreter = MockXcodeProjectInterpreter(); + xcode = Xcode(); }); testUsingContext('xcodeSelectPath returns null when xcode-select is not installed', () { @@ -117,7 +117,7 @@ void main() { testUsingContext('xcodeSelectPath returns path when xcode-select is installed', () { const String xcodePath = '/Applications/Xcode8.0.app/Contents/Developer'; when(mockProcessManager.runSync(['/usr/bin/xcode-select', '--print-path'])) - .thenReturn(new ProcessResult(1, 0, xcodePath, '')); + .thenReturn(ProcessResult(1, 0, xcodePath, '')); expect(xcode.xcodeSelectPath, xcodePath); }, overrides: { ProcessManager: () => mockProcessManager, @@ -176,7 +176,7 @@ void main() { testUsingContext('eulaSigned is false when clang output indicates EULA not yet accepted', () { when(mockProcessManager.runSync(['/usr/bin/xcrun', 'clang'])) - .thenReturn(new ProcessResult(1, 1, '', 'Xcode EULA has not been accepted.\nLaunch Xcode and accept the license.')); + .thenReturn(ProcessResult(1, 1, '', 'Xcode EULA has not been accepted.\nLaunch Xcode and accept the license.')); expect(xcode.eulaSigned, isFalse); }, overrides: { ProcessManager: () => mockProcessManager, @@ -184,7 +184,7 @@ void main() { testUsingContext('eulaSigned is true when clang output indicates EULA has been accepted', () { when(mockProcessManager.runSync(['/usr/bin/xcrun', 'clang'])) - .thenReturn(new ProcessResult(1, 1, '', 'clang: error: no input files')); + .thenReturn(ProcessResult(1, 1, '', 'clang: error: no input files')); expect(xcode.eulaSigned, isTrue); }, overrides: { ProcessManager: () => mockProcessManager, @@ -201,7 +201,7 @@ void main() { }); testUsingContext('No provisioning profile shows message', () async { - final XcodeBuildResult buildResult = new XcodeBuildResult( + final XcodeBuildResult buildResult = XcodeBuildResult( success: false, stdout: ''' Launching lib/main.dart on iPhone in debug mode... @@ -258,7 +258,7 @@ Xcode's output: Could not build the precompiled application for the device. Error launching application on iPhone.''', - xcodeBuildExecution: new XcodeBuildExecution( + xcodeBuildExecution: XcodeBuildExecution( buildCommands: ['xcrun', 'xcodebuild', 'blah'], appDirectory: '/blah/blah', buildForPhysicalDevice: true, @@ -274,7 +274,7 @@ Error launching application on iPhone.''', }); testUsingContext('No development team shows message', () async { - final XcodeBuildResult buildResult = new XcodeBuildResult( + final XcodeBuildResult buildResult = XcodeBuildResult( success: false, stdout: ''' Running "flutter packages get" in flutter_gallery... 0.6s @@ -339,7 +339,7 @@ Xcode's output: Code signing is required for product type 'Application' in SDK 'iOS 10.3' Could not build the precompiled application for the device.''', - xcodeBuildExecution: new XcodeBuildExecution( + xcodeBuildExecution: XcodeBuildExecution( buildCommands: ['xcrun', 'xcodebuild', 'blah'], appDirectory: '/blah/blah', buildForPhysicalDevice: true, diff --git a/packages/flutter_tools/test/ios/simulators_test.dart b/packages/flutter_tools/test/ios/simulators_test.dart index 5517e359fc..24507b5bd2 100644 --- a/packages/flutter_tools/test/ios/simulators_test.dart +++ b/packages/flutter_tools/test/ios/simulators_test.dart @@ -25,14 +25,14 @@ void main() { FakePlatform osx; setUp(() { - osx = new FakePlatform.fromPlatform(const LocalPlatform()); + osx = FakePlatform.fromPlatform(const LocalPlatform()); osx.operatingSystem = 'macos'; }); group('logFilePath', () { testUsingContext('defaults to rooted from HOME', () { osx.environment['HOME'] = '/foo/bar'; - expect(new IOSSimulator('123').logFilePath, '/foo/bar/Library/Logs/CoreSimulator/123/system.log'); + expect(IOSSimulator('123').logFilePath, '/foo/bar/Library/Logs/CoreSimulator/123/system.log'); }, overrides: { Platform: () => osx, }, testOn: 'posix'); @@ -40,7 +40,7 @@ void main() { testUsingContext('respects IOS_SIMULATOR_LOG_FILE_PATH', () { osx.environment['HOME'] = '/foo/bar'; osx.environment['IOS_SIMULATOR_LOG_FILE_PATH'] = '/baz/qux/%{id}/system.log'; - expect(new IOSSimulator('456').logFilePath, '/baz/qux/456/system.log'); + expect(IOSSimulator('456').logFilePath, '/baz/qux/456/system.log'); }, overrides: { Platform: () => osx, }); @@ -98,13 +98,13 @@ void main() { group('sdkMajorVersion', () { // This new version string appears in SimulatorApp-850 CoreSimulator-518.16 beta. test('can be parsed from iOS-11-3', () async { - final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3'); + final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', category: 'com.apple.CoreSimulator.SimRuntime.iOS-11-3'); expect(await device.sdkMajorVersion, 11); }); test('can be parsed from iOS 11.2', () async { - final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.2'); + final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.2'); expect(await device.sdkMajorVersion, 11); }); @@ -112,55 +112,55 @@ void main() { group('IOSSimulator.isSupported', () { testUsingContext('Apple TV is unsupported', () { - expect(new IOSSimulator('x', name: 'Apple TV').isSupported(), false); + expect(IOSSimulator('x', name: 'Apple TV').isSupported(), false); }, overrides: { Platform: () => osx, }); testUsingContext('Apple Watch is unsupported', () { - expect(new IOSSimulator('x', name: 'Apple Watch').isSupported(), false); + expect(IOSSimulator('x', name: 'Apple Watch').isSupported(), false); }, overrides: { Platform: () => osx, }); testUsingContext('iPad 2 is supported', () { - expect(new IOSSimulator('x', name: 'iPad 2').isSupported(), true); + expect(IOSSimulator('x', name: 'iPad 2').isSupported(), true); }, overrides: { Platform: () => osx, }); testUsingContext('iPad Retina is supported', () { - expect(new IOSSimulator('x', name: 'iPad Retina').isSupported(), true); + expect(IOSSimulator('x', name: 'iPad Retina').isSupported(), true); }, overrides: { Platform: () => osx, }); testUsingContext('iPhone 5 is supported', () { - expect(new IOSSimulator('x', name: 'iPhone 5').isSupported(), true); + expect(IOSSimulator('x', name: 'iPhone 5').isSupported(), true); }, overrides: { Platform: () => osx, }); testUsingContext('iPhone 5s is supported', () { - expect(new IOSSimulator('x', name: 'iPhone 5s').isSupported(), true); + expect(IOSSimulator('x', name: 'iPhone 5s').isSupported(), true); }, overrides: { Platform: () => osx, }); testUsingContext('iPhone SE is supported', () { - expect(new IOSSimulator('x', name: 'iPhone SE').isSupported(), true); + expect(IOSSimulator('x', name: 'iPhone SE').isSupported(), true); }, overrides: { Platform: () => osx, }); testUsingContext('iPhone 7 Plus is supported', () { - expect(new IOSSimulator('x', name: 'iPhone 7 Plus').isSupported(), true); + expect(IOSSimulator('x', name: 'iPhone 7 Plus').isSupported(), true); }, overrides: { Platform: () => osx, }); testUsingContext('iPhone X is supported', () { - expect(new IOSSimulator('x', name: 'iPhone X').isSupported(), true); + expect(IOSSimulator('x', name: 'iPhone X').isSupported(), true); }, overrides: { Platform: () => osx, }); @@ -172,16 +172,16 @@ void main() { IOSSimulator deviceUnderTest; setUp(() { - mockXcode = new MockXcode(); - mockProcessManager = new MockProcessManager(); + mockXcode = MockXcode(); + mockProcessManager = MockProcessManager(); // Let everything else return exit code 0 so process.dart doesn't crash. when( mockProcessManager.run(any, environment: null, workingDirectory: null) ).thenAnswer((Invocation invocation) => - new Future.value(new ProcessResult(2, 0, '', '')) + Future.value(ProcessResult(2, 0, '', '')) ); // Doesn't matter what the device is. - deviceUnderTest = new IOSSimulator('x', name: 'iPhone SE'); + deviceUnderTest = IOSSimulator('x', name: 'iPhone SE'); }); testUsingContext( @@ -200,7 +200,7 @@ void main() { when(mockXcode.majorVersion).thenReturn(8); when(mockXcode.minorVersion).thenReturn(2); expect(deviceUnderTest.supportsScreenshot, true); - final MockFile mockFile = new MockFile(); + final MockFile mockFile = MockFile(); when(mockFile.path).thenReturn(fs.path.join('some', 'path', 'to', 'screenshot.png')); await deviceUnderTest.takeScreenshot(mockFile); verify(mockProcessManager.run( @@ -219,7 +219,7 @@ void main() { overrides: { ProcessManager: () => mockProcessManager, // Test a real one. Screenshot doesn't require instance states. - SimControl: () => new SimControl(), + SimControl: () => SimControl(), Xcode: () => mockXcode, } ); @@ -229,13 +229,13 @@ void main() { MockProcessManager mockProcessManager; setUp(() { - mockProcessManager = new MockProcessManager(); + mockProcessManager = MockProcessManager(); when(mockProcessManager.start(any, environment: null, workingDirectory: null)) - .thenAnswer((Invocation invocation) => new Future.value(new MockProcess())); + .thenAnswer((Invocation invocation) => Future.value(MockProcess())); }); testUsingContext('uses tail on iOS versions prior to iOS 11', () async { - final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'iOS 9.3'); + final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', category: 'iOS 9.3'); await launchDeviceLogTool(device); expect( verify(mockProcessManager.start(captureAny, environment: null, workingDirectory: null)).captured.single, @@ -247,7 +247,7 @@ void main() { }); testUsingContext('uses /usr/bin/log on iOS 11 and above', () async { - final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.0'); + final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.0'); await launchDeviceLogTool(device); expect( verify(mockProcessManager.start(captureAny, environment: null, workingDirectory: null)).captured.single, @@ -263,13 +263,13 @@ void main() { MockProcessManager mockProcessManager; setUp(() { - mockProcessManager = new MockProcessManager(); + mockProcessManager = MockProcessManager(); when(mockProcessManager.start(any, environment: null, workingDirectory: null)) - .thenAnswer((Invocation invocation) => new Future.value(new MockProcess())); + .thenAnswer((Invocation invocation) => Future.value(MockProcess())); }); testUsingContext('uses tail on iOS versions prior to iOS 11', () async { - final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'iOS 9.3'); + final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', category: 'iOS 9.3'); await launchSystemLogTool(device); expect( verify(mockProcessManager.start(captureAny, environment: null, workingDirectory: null)).captured.single, @@ -281,7 +281,7 @@ void main() { }); testUsingContext('uses /usr/bin/log on iOS 11 and above', () async { - final IOSSimulator device = new IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.0'); + final IOSSimulator device = IOSSimulator('x', name: 'iPhone SE', category: 'iOS 11.0'); await launchSystemLogTool(device); verifyNever(mockProcessManager.start(any, environment: null, workingDirectory: null)); }, @@ -295,16 +295,16 @@ void main() { MockIosProject mockIosProject; setUp(() { - mockProcessManager = new MockProcessManager(); - mockIosProject = new MockIosProject(); + mockProcessManager = MockProcessManager(); + mockIosProject = MockIosProject(); }); testUsingContext('simulator can output `)`', () async { when(mockProcessManager.start(any, environment: null, workingDirectory: null)) .thenAnswer((Invocation invocation) { - final Process mockProcess = new MockProcess(); + final Process mockProcess = MockProcess(); when(mockProcess.stdout).thenAnswer((Invocation invocation) => - new Stream>.fromIterable(>[''' + Stream>.fromIterable(>[''' 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) Observatory listening on http://127.0.0.1:57701/ 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) )))))))))) 2017-09-13 15:26:57.228948-0700 localhost Runner[37195]: (Flutter) #0 Object.noSuchMethod (dart:core-patch/dart:core/object_patch.dart:46)''' @@ -313,13 +313,13 @@ void main() { .thenAnswer((Invocation invocation) => const Stream>.empty()); // Delay return of exitCode until after stdout stream data, since it terminates the logger. when(mockProcess.exitCode) - .thenAnswer((Invocation invocation) => new Future.delayed(Duration.zero, () => 0)); - return new Future.value(mockProcess); + .thenAnswer((Invocation invocation) => Future.delayed(Duration.zero, () => 0)); + return Future.value(mockProcess); }); - final IOSSimulator device = new IOSSimulator('123456', category: 'iOS 11.0'); + final IOSSimulator device = IOSSimulator('123456', category: 'iOS 11.0'); final DeviceLogReader logReader = device.getLogReader( - app: new BuildableIOSApp(mockIosProject), + app: BuildableIOSApp(mockIosProject), ); final List lines = await logReader.logLines.toList(); @@ -370,11 +370,11 @@ void main() { SimControl simControl; setUp(() { - mockProcessManager = new MockProcessManager(); + mockProcessManager = MockProcessManager(); when(mockProcessManager.runSync(any)) - .thenReturn(new ProcessResult(mockPid, 0, validSimControlOutput, '')); + .thenReturn(ProcessResult(mockPid, 0, validSimControlOutput, '')); - simControl = new SimControl(); + simControl = SimControl(); }); testUsingContext('getDevices succeeds', () { diff --git a/packages/flutter_tools/test/ios/xcodeproj_test.dart b/packages/flutter_tools/test/ios/xcodeproj_test.dart index 204fe44f9a..d80fbc13c8 100644 --- a/packages/flutter_tools/test/ios/xcodeproj_test.dart +++ b/packages/flutter_tools/test/ios/xcodeproj_test.dart @@ -29,10 +29,10 @@ void main() { FileSystem fs; setUp(() { - mockProcessManager = new MockProcessManager(); - xcodeProjectInterpreter = new XcodeProjectInterpreter(); + mockProcessManager = MockProcessManager(); + xcodeProjectInterpreter = XcodeProjectInterpreter(); macOS = fakePlatform('macos'); - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); fs.file(xcodebuild).createSync(recursive: true); }); @@ -52,7 +52,7 @@ void main() { testUsingOsxContext('versionText returns null when xcodebuild is not fully installed', () { when(mockProcessManager.runSync([xcodebuild, '-version'])).thenReturn( - new ProcessResult( + ProcessResult( 0, 1, "xcode-select: error: tool 'xcodebuild' requires Xcode, " @@ -66,43 +66,43 @@ void main() { testUsingOsxContext('versionText returns formatted version text', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.versionText, 'Xcode 8.3.3, Build version 8E3004b'); }); testUsingOsxContext('versionText handles Xcode version string with unexpected format', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.versionText, 'Xcode Ultra5000, Build version 8E3004b'); }); testUsingOsxContext('majorVersion returns major version', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.majorVersion, 8); }); testUsingOsxContext('majorVersion is null when version has unexpected format', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.majorVersion, isNull); }); testUsingOsxContext('minorVersion returns minor version', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.minorVersion, 3); }); testUsingOsxContext('minorVersion returns 0 when minor version is unspecified', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode 8\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode 8\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.minorVersion, 0); }); testUsingOsxContext('minorVersion is null when version has unexpected format', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.minorVersion, isNull); }); @@ -120,7 +120,7 @@ void main() { testUsingOsxContext('isInstalled is false when Xcode is not fully installed', () { when(mockProcessManager.runSync([xcodebuild, '-version'])).thenReturn( - new ProcessResult( + ProcessResult( 0, 1, "xcode-select: error: tool 'xcodebuild' requires Xcode, " @@ -134,13 +134,13 @@ void main() { testUsingOsxContext('isInstalled is false when version has unexpected format', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode Ultra5000\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.isInstalled, isFalse); }); testUsingOsxContext('isInstalled is true when version has expected format', () { when(mockProcessManager.runSync([xcodebuild, '-version'])) - .thenReturn(new ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); + .thenReturn(ProcessResult(1, 0, 'Xcode 8.3.3\nBuild version 8E3004b', '')); expect(xcodeProjectInterpreter.isInstalled, isTrue); }); }); @@ -161,7 +161,7 @@ Information about project "Runner": Runner '''; - final XcodeProjectInfo info = new XcodeProjectInfo.fromXcodeBuildOutput(output); + final XcodeProjectInfo info = XcodeProjectInfo.fromXcodeBuildOutput(output); expect(info.targets, ['Runner']); expect(info.schemes, ['Runner']); expect(info.buildConfigurations, ['Debug', 'Release']); @@ -185,7 +185,7 @@ Information about project "Runner": Paid '''; - final XcodeProjectInfo info = new XcodeProjectInfo.fromXcodeBuildOutput(output); + final XcodeProjectInfo info = XcodeProjectInfo.fromXcodeBuildOutput(output); expect(info.targets, ['Runner']); expect(info.schemes, ['Free', 'Paid']); expect(info.buildConfigurations, ['Debug (Free)', 'Debug (Paid)', 'Release (Free)', 'Release (Paid)']); @@ -211,20 +211,20 @@ Information about project "Runner": expect(XcodeProjectInfo.expectedBuildConfigurationFor(const BuildInfo(BuildMode.release, 'Hello'), 'Hello'), 'Release-Hello'); }); test('scheme for default project is Runner', () { - final XcodeProjectInfo info = new XcodeProjectInfo(['Runner'], ['Debug', 'Release'], ['Runner']); + final XcodeProjectInfo info = XcodeProjectInfo(['Runner'], ['Debug', 'Release'], ['Runner']); expect(info.schemeFor(BuildInfo.debug), 'Runner'); expect(info.schemeFor(BuildInfo.profile), 'Runner'); expect(info.schemeFor(BuildInfo.release), 'Runner'); expect(info.schemeFor(const BuildInfo(BuildMode.debug, 'unknown')), isNull); }); test('build configuration for default project is matched against BuildMode', () { - final XcodeProjectInfo info = new XcodeProjectInfo(['Runner'], ['Debug', 'Release'], ['Runner']); + final XcodeProjectInfo info = XcodeProjectInfo(['Runner'], ['Debug', 'Release'], ['Runner']); expect(info.buildConfigurationFor(BuildInfo.debug, 'Runner'), 'Debug'); expect(info.buildConfigurationFor(BuildInfo.profile, 'Runner'), 'Release'); expect(info.buildConfigurationFor(BuildInfo.release, 'Runner'), 'Release'); }); test('scheme for project with custom schemes is matched against flavor', () { - final XcodeProjectInfo info = new XcodeProjectInfo( + final XcodeProjectInfo info = XcodeProjectInfo( ['Runner'], ['Debug (Free)', 'Debug (Paid)', 'Release (Free)', 'Release (Paid)'], ['Free', 'Paid'], @@ -236,7 +236,7 @@ Information about project "Runner": expect(info.schemeFor(const BuildInfo(BuildMode.debug, 'unknown')), isNull); }); test('build configuration for project with custom schemes is matched against BuildMode and flavor', () { - final XcodeProjectInfo info = new XcodeProjectInfo( + final XcodeProjectInfo info = XcodeProjectInfo( ['Runner'], ['debug (free)', 'Debug paid', 'release - Free', 'Release-Paid'], ['Free', 'Paid'], @@ -247,7 +247,7 @@ Information about project "Runner": expect(info.buildConfigurationFor(const BuildInfo(BuildMode.release, 'paid'), 'Paid'), 'Release-Paid'); }); test('build configuration for project with inconsistent naming is null', () { - final XcodeProjectInfo info = new XcodeProjectInfo( + final XcodeProjectInfo info = XcodeProjectInfo( ['Runner'], ['Debug-F', 'Dbg Paid', 'Rel Free', 'Release Full'], ['Free', 'Paid'], @@ -265,9 +265,9 @@ Information about project "Runner": FileSystem fs; setUp(() { - fs = new MemoryFileSystem(); - mockArtifacts = new MockLocalEngineArtifacts(); - mockProcessManager = new MockProcessManager(); + fs = MemoryFileSystem(); + mockArtifacts = MockLocalEngineArtifacts(); + mockProcessManager = MockProcessManager(); macOS = fakePlatform('macos'); fs.file(xcodebuild).createSync(recursive: true); }); @@ -515,7 +515,7 @@ flutter: } Platform fakePlatform(String name) { - return new FakePlatform.fromPlatform(const LocalPlatform())..operatingSystem = name; + return FakePlatform.fromPlatform(const LocalPlatform())..operatingSystem = name; } class MockLocalEngineArtifacts extends Mock implements LocalEngineArtifacts {} diff --git a/packages/flutter_tools/test/project_test.dart b/packages/flutter_tools/test/project_test.dart index 5ab8100548..aa737b0661 100644 --- a/packages/flutter_tools/test/project_test.dart +++ b/packages/flutter_tools/test/project_test.dart @@ -137,7 +137,7 @@ void main() { group('ensure ready for platform-specific tooling', () { testInMemory('does nothing, if project is not created', () async { - final FlutterProject project = new FlutterProject( + final FlutterProject project = FlutterProject( fs.directory('not_created'), FlutterManifest.empty(), FlutterManifest.empty(), @@ -229,9 +229,9 @@ void main() { MockIOSWorkflow mockIOSWorkflow; MockXcodeProjectInterpreter mockXcodeProjectInterpreter; setUp(() { - fs = new MemoryFileSystem(); - mockIOSWorkflow = new MockIOSWorkflow(); - mockXcodeProjectInterpreter = new MockXcodeProjectInterpreter(); + fs = MemoryFileSystem(); + mockIOSWorkflow = MockIOSWorkflow(); + mockXcodeProjectInterpreter = MockXcodeProjectInterpreter(); }); void testWithMocks(String description, Future testMethod()) { @@ -367,12 +367,12 @@ flutter: /// is in memory. void testInMemory(String description, Future testMethod()) { Cache.flutterRoot = getFlutterRoot(); - final FileSystem testFileSystem = new MemoryFileSystem( + final FileSystem testFileSystem = MemoryFileSystem( style: platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix, ); // Transfer needed parts of the Flutter installation folder // to the in-memory file system used during testing. - transfer(new Cache().getArtifactDirectory('gradle_wrapper'), testFileSystem); + transfer(Cache().getArtifactDirectory('gradle_wrapper'), testFileSystem); transfer(fs.directory(Cache.flutterRoot) .childDirectory('packages') .childDirectory('flutter_tools') @@ -386,7 +386,7 @@ void testInMemory(String description, Future testMethod()) { testMethod, overrides: { FileSystem: () => testFileSystem, - Cache: () => new Cache(), + Cache: () => Cache(), }, ); } diff --git a/packages/flutter_tools/test/protocol_discovery_test.dart b/packages/flutter_tools/test/protocol_discovery_test.dart index 1b84b11b35..0f4fb42e6a 100644 --- a/packages/flutter_tools/test/protocol_discovery_test.dart +++ b/packages/flutter_tools/test/protocol_discovery_test.dart @@ -35,8 +35,8 @@ void main() { /// /// See also: [runZoned] void initialize() { - logReader = new MockDeviceLogReader(); - discoverer = new ProtocolDiscovery.observatory(logReader); + logReader = MockDeviceLogReader(); + discoverer = ProtocolDiscovery.observatory(logReader); } tearDown(() { @@ -124,10 +124,10 @@ void main() { group('port forwarding', () { testUsingContext('default port', () async { - final MockDeviceLogReader logReader = new MockDeviceLogReader(); - final ProtocolDiscovery discoverer = new ProtocolDiscovery.observatory( + final MockDeviceLogReader logReader = MockDeviceLogReader(); + final ProtocolDiscovery discoverer = ProtocolDiscovery.observatory( logReader, - portForwarder: new MockPortForwarder(99), + portForwarder: MockPortForwarder(99), ); // Get next port future. @@ -142,10 +142,10 @@ void main() { }); testUsingContext('specified port', () async { - final MockDeviceLogReader logReader = new MockDeviceLogReader(); - final ProtocolDiscovery discoverer = new ProtocolDiscovery.observatory( + final MockDeviceLogReader logReader = MockDeviceLogReader(); + final ProtocolDiscovery discoverer = ProtocolDiscovery.observatory( logReader, - portForwarder: new MockPortForwarder(99), + portForwarder: MockPortForwarder(99), hostPort: 1243, ); @@ -161,10 +161,10 @@ void main() { }); testUsingContext('specified port zero', () async { - final MockDeviceLogReader logReader = new MockDeviceLogReader(); - final ProtocolDiscovery discoverer = new ProtocolDiscovery.observatory( + final MockDeviceLogReader logReader = MockDeviceLogReader(); + final ProtocolDiscovery discoverer = ProtocolDiscovery.observatory( logReader, - portForwarder: new MockPortForwarder(99), + portForwarder: MockPortForwarder(99), hostPort: 0, ); @@ -180,10 +180,10 @@ void main() { }); testUsingContext('ipv6', () async { - final MockDeviceLogReader logReader = new MockDeviceLogReader(); - final ProtocolDiscovery discoverer = new ProtocolDiscovery.observatory( + final MockDeviceLogReader logReader = MockDeviceLogReader(); + final ProtocolDiscovery discoverer = ProtocolDiscovery.observatory( logReader, - portForwarder: new MockPortForwarder(99), + portForwarder: MockPortForwarder(99), hostPort: 54777, ipv6: true, ); @@ -200,10 +200,10 @@ void main() { }); testUsingContext('ipv6 with Ascii Escape code', () async { - final MockDeviceLogReader logReader = new MockDeviceLogReader(); - final ProtocolDiscovery discoverer = new ProtocolDiscovery.observatory( + final MockDeviceLogReader logReader = MockDeviceLogReader(); + final ProtocolDiscovery discoverer = ProtocolDiscovery.observatory( logReader, - portForwarder: new MockPortForwarder(99), + portForwarder: MockPortForwarder(99), hostPort: 54777, ipv6: true, ); diff --git a/packages/flutter_tools/test/resident_runner_test.dart b/packages/flutter_tools/test/resident_runner_test.dart index 55eeab1864..fd50df4a88 100644 --- a/packages/flutter_tools/test/resident_runner_test.dart +++ b/packages/flutter_tools/test/resident_runner_test.dart @@ -46,8 +46,8 @@ void main() { TestRunner createTestRunner() { // TODO(jacobr): make these tests run with `trackWidgetCreation: true` as // well as the default flags. - return new TestRunner( - [new FlutterDevice(new MockDevice(), trackWidgetCreation: false)], + return TestRunner( + [FlutterDevice(MockDevice(), trackWidgetCreation: false)], ); } diff --git a/packages/flutter_tools/test/runner/flutter_command_runner_test.dart b/packages/flutter_tools/test/runner/flutter_command_runner_test.dart index 827692a15b..bda0f61360 100644 --- a/packages/flutter_tools/test/runner/flutter_command_runner_test.dart +++ b/packages/flutter_tools/test/runner/flutter_command_runner_test.dart @@ -30,16 +30,16 @@ void main() { }); setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); fs.directory(_kFlutterRoot).createSync(recursive: true); fs.directory(_kProjectRoot).createSync(recursive: true); fs.currentDirectory = _kProjectRoot; - platform = new FakePlatform(environment: { + platform = FakePlatform(environment: { 'FLUTTER_ROOT': _kFlutterRoot, }); - runner = createTestCommandRunner(new DummyFlutterCommand()); + runner = createTestCommandRunner(DummyFlutterCommand()); }); group('run', () { diff --git a/packages/flutter_tools/test/runner/flutter_command_test.dart b/packages/flutter_tools/test/runner/flutter_command_test.dart index f5c5b08567..29ab6df327 100644 --- a/packages/flutter_tools/test/runner/flutter_command_test.dart +++ b/packages/flutter_tools/test/runner/flutter_command_test.dart @@ -24,17 +24,17 @@ void main() { List mockTimes; setUp(() { - cache = new MockCache(); - clock = new MockClock(); - usage = new MockUsage(); + cache = MockCache(); + clock = MockClock(); + usage = MockUsage(); when(usage.isFirstRun).thenReturn(false); when(clock.now()).thenAnswer( - (Invocation _) => new DateTime.fromMillisecondsSinceEpoch(mockTimes.removeAt(0)) + (Invocation _) => DateTime.fromMillisecondsSinceEpoch(mockTimes.removeAt(0)) ); }); testUsingContext('honors shouldUpdateCache false', () async { - final DummyFlutterCommand flutterCommand = new DummyFlutterCommand(shouldUpdateCache: false); + final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: false); await flutterCommand.run(); verifyZeroInteractions(cache); }, @@ -43,7 +43,7 @@ void main() { }); testUsingContext('honors shouldUpdateCache true', () async { - final DummyFlutterCommand flutterCommand = new DummyFlutterCommand(shouldUpdateCache: true); + final DummyFlutterCommand flutterCommand = DummyFlutterCommand(shouldUpdateCache: true); await flutterCommand.run(); verify(cache.updateAll()).called(1); }, @@ -55,7 +55,7 @@ void main() { // Crash if called a third time which is unexpected. mockTimes = [1000, 2000]; - final DummyFlutterCommand flutterCommand = new DummyFlutterCommand(); + final DummyFlutterCommand flutterCommand = DummyFlutterCommand(); await flutterCommand.run(); verify(clock.now()).called(2); @@ -76,7 +76,7 @@ void main() { mockTimes = [1000, 2000]; final DummyFlutterCommand flutterCommand = - new DummyFlutterCommand(noUsagePath: true); + DummyFlutterCommand(noUsagePath: true); await flutterCommand.run(); verify(clock.now()).called(2); verifyNever(usage.sendTiming( @@ -92,14 +92,14 @@ void main() { // Crash if called a third time which is unexpected. mockTimes = [1000, 2000]; - final FlutterCommandResult commandResult = new FlutterCommandResult( + final FlutterCommandResult commandResult = FlutterCommandResult( ExitStatus.success, // nulls should be cleaned up. timingLabelParts: ['blah1', 'blah2', null, 'blah3'], - endTimeOverride: new DateTime.fromMillisecondsSinceEpoch(1500) + endTimeOverride: DateTime.fromMillisecondsSinceEpoch(1500) ); - final DummyFlutterCommand flutterCommand = new DummyFlutterCommand( + final DummyFlutterCommand flutterCommand = DummyFlutterCommand( commandFunction: () async => commandResult ); await flutterCommand.run(); @@ -125,7 +125,7 @@ void main() { // Crash if called a third time which is unexpected. mockTimes = [1000, 2000]; - final DummyFlutterCommand flutterCommand = new DummyFlutterCommand( + final DummyFlutterCommand flutterCommand = DummyFlutterCommand( commandFunction: () async { throwToolExit('fail'); return null; // unreachable diff --git a/packages/flutter_tools/test/src/common.dart b/packages/flutter_tools/test/src/common.dart index b932cf8517..2424667b75 100644 --- a/packages/flutter_tools/test/src/common.dart +++ b/packages/flutter_tools/test/src/common.dart @@ -20,7 +20,7 @@ export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; // Defines a 'pa /// A matcher that compares the type of the actual value to the type argument T. // TODO(ianh): Remove this once https://github.com/dart-lang/matcher/issues/98 is fixed -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 void tryToDelete(Directory directory) { // This should not be necessary, but it turns out that @@ -42,7 +42,7 @@ String getFlutterRoot() { if (platform.environment.containsKey('FLUTTER_ROOT')) return platform.environment['FLUTTER_ROOT']; - Error invalidScript() => new StateError('Invalid script: ${platform.script}'); + Error invalidScript() => StateError('Invalid script: ${platform.script}'); Uri scriptUri; switch (platform.script.scheme) { @@ -50,7 +50,7 @@ String getFlutterRoot() { scriptUri = platform.script; break; case 'data': - final RegExp flutterTools = new RegExp(r'(file://[^"]*[/\\]flutter_tools[/\\][^"]+\.dart)', multiLine: true); + final RegExp flutterTools = RegExp(r'(file://[^"]*[/\\]flutter_tools[/\\][^"]+\.dart)', multiLine: true); final Match match = flutterTools.firstMatch(Uri.decodeFull(platform.script.path)); if (match == null) throw invalidScript(); @@ -69,7 +69,7 @@ String getFlutterRoot() { } CommandRunner createTestCommandRunner([FlutterCommand command]) { - final FlutterCommandRunner runner = new FlutterCommandRunner(); + final FlutterCommandRunner runner = FlutterCommandRunner(); if (command != null) runner.addCommand(command); return runner; @@ -79,7 +79,7 @@ CommandRunner createTestCommandRunner([FlutterCommand command]) { void updateFileModificationTime(String path, DateTime baseTime, int seconds) { - final DateTime modificationTime = baseTime.add(new Duration(seconds: seconds)); + final DateTime modificationTime = baseTime.add(Duration(seconds: seconds)); fs.file(path).setLastModifiedSync(modificationTime); } @@ -112,7 +112,7 @@ final Matcher isProcessExit = isInstanceOf(); Future createProject(Directory temp, {List arguments}) async { arguments ??= ['--no-pub']; final String projectPath = fs.path.join(temp.path, 'flutter_project'); - final CreateCommand command = new CreateCommand(); + final CreateCommand command = CreateCommand(); final CommandRunner runner = createTestCommandRunner(command); await runner.run(['create']..addAll(arguments)..add(projectPath)); return projectPath; diff --git a/packages/flutter_tools/test/src/context.dart b/packages/flutter_tools/test/src/context.dart index bc37d0ed1a..0885212de3 100644 --- a/packages/flutter_tools/test/src/context.dart +++ b/packages/flutter_tools/test/src/context.dart @@ -58,7 +58,7 @@ void testUsingContext(String description, dynamic testMethod(), { final File settingsFile = fs.file( fs.path.join(configDir.path, '.flutter_settings') ); - return new Config(settingsFile); + return Config(settingsFile); } test(description, () async { @@ -67,20 +67,20 @@ void testUsingContext(String description, dynamic testMethod(), { name: 'mocks', overrides: { Config: () => buildConfig(fs), - DeviceManager: () => new MockDeviceManager(), - Doctor: () => new MockDoctor(), - FlutterVersion: () => new MockFlutterVersion(), - HttpClient: () => new MockHttpClient(), + DeviceManager: () => MockDeviceManager(), + Doctor: () => MockDoctor(), + FlutterVersion: () => MockFlutterVersion(), + HttpClient: () => MockHttpClient(), IOSSimulatorUtils: () { - final MockIOSSimulatorUtils mock = new MockIOSSimulatorUtils(); + final MockIOSSimulatorUtils mock = MockIOSSimulatorUtils(); when(mock.getAttachedDevices()).thenReturn([]); return mock; }, - Logger: () => new BufferLogger(), - OperatingSystemUtils: () => new MockOperatingSystemUtils(), - SimControl: () => new MockSimControl(), - Usage: () => new MockUsage(), - XcodeProjectInterpreter: () => new MockXcodeProjectInterpreter(), + Logger: () => BufferLogger(), + OperatingSystemUtils: () => MockOperatingSystemUtils(), + SimControl: () => MockSimControl(), + Usage: () => MockUsage(), + XcodeProjectInterpreter: () => MockXcodeProjectInterpreter(), }, body: () { final String flutterRoot = getFlutterRoot(); @@ -154,11 +154,11 @@ class MockDeviceManager implements DeviceManager { } @override - Stream getAllConnectedDevices() => new Stream.fromIterable(devices); + Stream getAllConnectedDevices() => Stream.fromIterable(devices); @override Stream getDevicesById(String deviceId) { - return new Stream.fromIterable( + return Stream.fromIterable( devices.where((Device device) => device.id == deviceId)); } @@ -200,7 +200,7 @@ class MockDoctor extends Doctor { final List superValidators = super.validators; return superValidators.map((DoctorValidator v) { if (v is AndroidValidator) { - return new MockAndroidWorkflowValidator(); + return MockAndroidWorkflowValidator(); } return v; }).toList(); @@ -261,7 +261,7 @@ class MockUsage implements Usage { Stream> get onSend => null; @override - Future ensureAnalyticsSent() => new Future.value(); + Future ensureAnalyticsSent() => Future.value(); @override void printWelcome() { } @@ -287,7 +287,7 @@ class MockXcodeProjectInterpreter implements XcodeProjectInterpreter { @override XcodeProjectInfo getInfo(String projectPath) { - return new XcodeProjectInfo( + return XcodeProjectInfo( ['Runner'], ['Debug', 'Release'], ['Runner'], diff --git a/packages/flutter_tools/test/src/mocks.dart b/packages/flutter_tools/test/src/mocks.dart index b87a343ec8..1aab448fc1 100644 --- a/packages/flutter_tools/test/src/mocks.dart +++ b/packages/flutter_tools/test/src/mocks.dart @@ -26,12 +26,12 @@ import 'common.dart'; class MockApplicationPackageStore extends ApplicationPackageStore { MockApplicationPackageStore() : super( - android: new AndroidApk( + android: AndroidApk( id: 'io.flutter.android.mock', file: fs.file('/mock/path/to/android/SkyShell.apk'), launchActivity: 'io.flutter.android.mock.MockActivity' ), - iOS: new BuildableIOSApp(new MockIosProject()) + iOS: BuildableIOSApp(MockIosProject()) ); } @@ -113,7 +113,7 @@ typedef Process ProcessFactory(List command); /// A ProcessManager that starts Processes by delegating to a ProcessFactory. class MockProcessManager implements ProcessManager { - ProcessFactory processFactory = (List commands) => new MockProcess(); + ProcessFactory processFactory = (List commands) => MockProcess(); bool succeed = true; List commands; @@ -132,11 +132,11 @@ class MockProcessManager implements ProcessManager { if (!succeed) { final String executable = command[0]; final List arguments = command.length > 1 ? command.sublist(1) : []; - throw new ProcessException(executable, arguments); + throw ProcessException(executable, arguments); } commands = command; - return new Future.value(processFactory(command)); + return Future.value(processFactory(command)); } @override @@ -151,8 +151,8 @@ class MockProcess extends Mock implements Process { Stream> stdin, this.stdout = const Stream>.empty(), this.stderr = const Stream>.empty(), - }) : exitCode = exitCode ?? new Future.value(0), - stdin = stdin ?? new MemoryIOSink(); + }) : exitCode = exitCode ?? Future.value(0), + stdin = stdin ?? MemoryIOSink(); @override final int pid; @@ -185,8 +185,8 @@ class PromptingProcess implements Process { await _stdoutController.close(); } - final StreamController> _stdoutController = new StreamController>(); - final CompleterIOSink _stdin = new CompleterIOSink(); + final StreamController> _stdoutController = StreamController>(); + final CompleterIOSink _stdin = CompleterIOSink(); @override Stream> get stdout => _stdoutController.stream; @@ -209,7 +209,7 @@ class PromptingProcess implements Process { /// An IOSink that completes a future with the first line written to it. class CompleterIOSink extends MemoryIOSink { - final Completer> _completer = new Completer>(); + final Completer> _completer = Completer>(); Future> get future => _completer.future; @@ -235,7 +235,7 @@ class MemoryIOSink implements IOSink { @override Future addStream(Stream> stream) { - final Completer completer = new Completer(); + final Completer completer = Completer(); stream.listen((List data) { add(data); }).onDone(() => completer.complete(null)); @@ -271,7 +271,7 @@ class MemoryIOSink implements IOSink { @override void addError(dynamic error, [StackTrace stackTrace]) { - throw new UnimplementedError(); + throw UnimplementedError(); } @override @@ -286,8 +286,8 @@ class MemoryIOSink implements IOSink { /// A Stdio that collects stdout and supports simulated stdin. class MockStdio extends Stdio { - final MemoryIOSink _stdout = new MemoryIOSink(); - final StreamController> _stdin = new StreamController>(); + final MemoryIOSink _stdout = MemoryIOSink(); + final StreamController> _stdin = StreamController>(); @override IOSink get stdout => _stdout; @@ -304,8 +304,8 @@ class MockStdio extends Stdio { class MockPollingDeviceDiscovery extends PollingDeviceDiscovery { final List _devices = []; - final StreamController _onAddedController = new StreamController.broadcast(); - final StreamController _onRemovedController = new StreamController.broadcast(); + final StreamController _onAddedController = StreamController.broadcast(); + final StreamController _onRemovedController = StreamController.broadcast(); MockPollingDeviceDiscovery() : super('mock'); @@ -370,7 +370,7 @@ class MockDeviceLogReader extends DeviceLogReader { @override String get name => 'MockLogReader'; - final StreamController _linesController = new StreamController.broadcast(); + final StreamController _linesController = StreamController.broadcast(); @override Stream get logLines => _linesController.stream; @@ -384,7 +384,7 @@ class MockDeviceLogReader extends DeviceLogReader { void applyMocksToCommand(FlutterCommand command) { command - ..applicationPackages = new MockApplicationPackageStore(); + ..applicationPackages = MockApplicationPackageStore(); } /// Common functionality for tracking mock interaction @@ -392,7 +392,7 @@ class BasicMock { final List messages = []; void expectMessages(List expectedMessages) { - final List actualMessages = new List.from(messages); + final List actualMessages = List.from(messages); messages.clear(); expect(actualMessages, unorderedEquals(expectedMessages)); } @@ -461,6 +461,6 @@ class MockResidentCompiler extends BasicMock implements ResidentCompiler { Future recompile(String mainPath, List invalidatedFiles, {String outputPath, String packagesFilePath}) async { fs.file(outputPath).createSync(recursive: true); fs.file(outputPath).writeAsStringSync('compiled_kernel_output'); - return new CompilerOutput(outputPath, 0); + return CompilerOutput(outputPath, 0); } } diff --git a/packages/flutter_tools/test/stop_test.dart b/packages/flutter_tools/test/stop_test.dart index e74e42af85..b30813d1ea 100644 --- a/packages/flutter_tools/test/stop_test.dart +++ b/packages/flutter_tools/test/stop_test.dart @@ -19,19 +19,19 @@ void main() { }); testUsingContext('returns 0 when Android is connected and ready to be stopped', () async { - final StopCommand command = new StopCommand(); + final StopCommand command = StopCommand(); applyMocksToCommand(command); - final MockAndroidDevice device = new MockAndroidDevice(); - when(device.stopApp(any)).thenAnswer((Invocation invocation) => new Future.value(true)); + final MockAndroidDevice device = MockAndroidDevice(); + when(device.stopApp(any)).thenAnswer((Invocation invocation) => Future.value(true)); testDeviceManager.addDevice(device); await createTestCommandRunner(command).run(['stop']); }); testUsingContext('returns 0 when iOS is connected and ready to be stopped', () async { - final StopCommand command = new StopCommand(); + final StopCommand command = StopCommand(); applyMocksToCommand(command); - final MockIOSDevice device = new MockIOSDevice(); - when(device.stopApp(any)).thenAnswer((Invocation invocation) => new Future.value(true)); + final MockIOSDevice device = MockIOSDevice(); + when(device.stopApp(any)).thenAnswer((Invocation invocation) => Future.value(true)); testDeviceManager.addDevice(device); await createTestCommandRunner(command).run(['stop']); diff --git a/packages/flutter_tools/test/tester/flutter_tester_test.dart b/packages/flutter_tools/test/tester/flutter_tester_test.dart index 3ca867d219..5b7aa26d8c 100644 --- a/packages/flutter_tools/test/tester/flutter_tester_test.dart +++ b/packages/flutter_tools/test/tester/flutter_tester_test.dart @@ -24,7 +24,7 @@ void main() { MemoryFileSystem fs; setUp(() { - fs = new MemoryFileSystem(); + fs = MemoryFileSystem(); }); group('FlutterTesterApp', () { @@ -33,7 +33,7 @@ void main() { await fs.directory(projectPath).create(recursive: true); fs.currentDirectory = projectPath; - final FlutterTesterApp app = new FlutterTesterApp.fromCurrentDirectory(); + final FlutterTesterApp app = FlutterTesterApp.fromCurrentDirectory(); expect(app.name, 'my_project'); expect(app.packagesFile.path, fs.path.join(projectPath, '.packages')); }, overrides: { @@ -47,7 +47,7 @@ void main() { }); testUsingContext('no device', () async { - final FlutterTesterDevices discoverer = new FlutterTesterDevices(); + final FlutterTesterDevices discoverer = FlutterTesterDevices(); final List devices = await discoverer.devices; expect(devices, isEmpty); @@ -55,7 +55,7 @@ void main() { testUsingContext('has device', () async { FlutterTesterDevices.showFlutterTesterDevice = true; - final FlutterTesterDevices discoverer = new FlutterTesterDevices(); + final FlutterTesterDevices discoverer = FlutterTesterDevices(); final List devices = await discoverer.devices; expect(devices, hasLength(1)); @@ -71,7 +71,7 @@ void main() { List logLines; setUp(() { - device = new FlutterTesterDevice('flutter-tester'); + device = FlutterTesterDevice('flutter-tester'); logLines = []; device.getLogReader().logLines.listen(logLines.add); @@ -105,9 +105,9 @@ void main() { MockProcess mockProcess; final Map startOverrides = { - Platform: () => new FakePlatform(operatingSystem: 'linux'), + Platform: () => FakePlatform(operatingSystem: 'linux'), FileSystem: () => fs, - Cache: () => new Cache(rootOverride: fs.directory(flutterRoot)), + Cache: () => Cache(rootOverride: fs.directory(flutterRoot)), ProcessManager: () => mockProcessManager, KernelCompiler: () => mockKernelCompiler, Artifacts: () => mockArtifacts, @@ -125,22 +125,22 @@ void main() { projectPath = fs.path.join('home', 'me', 'hello'); mainPath = fs.path.join(projectPath, 'lin', 'main.dart'); - mockProcessManager = new MockProcessManager(); + mockProcessManager = MockProcessManager(); mockProcessManager.processFactory = (List commands) => mockProcess; - mockArtifacts = new MockArtifacts(); + mockArtifacts = MockArtifacts(); final String artifactPath = fs.path.join(flutterRoot, 'artifact'); fs.file(artifactPath).createSync(recursive: true); when(mockArtifacts.getArtifactPath(any)).thenReturn(artifactPath); - mockKernelCompiler = new MockKernelCompiler(); + mockKernelCompiler = MockKernelCompiler(); }); testUsingContext('not debug', () async { final LaunchResult result = await device.startApp(null, mainPath: mainPath, - debuggingOptions: new DebuggingOptions.disabled(const BuildInfo(BuildMode.release, null))); + debuggingOptions: DebuggingOptions.disabled(const BuildInfo(BuildMode.release, null))); expect(result.started, isFalse); }, overrides: startOverrides); @@ -149,14 +149,14 @@ void main() { expect(() async { await device.startApp(null, mainPath: mainPath, - debuggingOptions: new DebuggingOptions.disabled(const BuildInfo(BuildMode.debug, null))); + debuggingOptions: DebuggingOptions.disabled(const BuildInfo(BuildMode.debug, null))); }, throwsToolExit()); }, overrides: startOverrides); testUsingContext('start', () async { final Uri observatoryUri = Uri.parse('http://127.0.0.1:6666/'); - mockProcess = new MockProcess( - stdout: new Stream>.fromIterable(>[ + mockProcess = MockProcess( + stdout: Stream>.fromIterable(>[ ''' Observatory listening on $observatoryUri Hello! @@ -177,12 +177,12 @@ Hello! packagesPath: anyNamed('packagesPath'), )).thenAnswer((_) async { fs.file('$mainPath.dill').createSync(recursive: true); - return new CompilerOutput('$mainPath.dill', 0); + return CompilerOutput('$mainPath.dill', 0); }); final LaunchResult result = await device.startApp(null, mainPath: mainPath, - debuggingOptions: new DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null))); + debuggingOptions: DebuggingOptions.enabled(const BuildInfo(BuildMode.debug, null))); expect(result.started, isTrue); expect(result.observatoryUri, observatoryUri); diff --git a/packages/flutter_tools/test/trace_test.dart b/packages/flutter_tools/test/trace_test.dart index d824934235..f8cbcc46f2 100644 --- a/packages/flutter_tools/test/trace_test.dart +++ b/packages/flutter_tools/test/trace_test.dart @@ -12,7 +12,7 @@ import 'src/mocks.dart'; void main() { group('trace', () { testUsingContext('returns 1 when no Android device is connected', () async { - final TraceCommand command = new TraceCommand(); + final TraceCommand command = TraceCommand(); applyMocksToCommand(command); try { await createTestCommandRunner(command).run(['trace']); diff --git a/packages/flutter_tools/test/utils_test.dart b/packages/flutter_tools/test/utils_test.dart index a638dec96e..513a75dbd9 100644 --- a/packages/flutter_tools/test/utils_test.dart +++ b/packages/flutter_tools/test/utils_test.dart @@ -12,7 +12,7 @@ import 'src/common.dart'; void main() { group('SettingsFile', () { test('parse', () { - final SettingsFile file = new SettingsFile.parse(''' + final SettingsFile file = SettingsFile.parse(''' # ignore comment foo=bar baz=qux @@ -26,7 +26,7 @@ baz=qux group('uuid', () { // xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx test('simple', () { - final Uuid uuid = new Uuid(); + final Uuid uuid = Uuid(); final String result = uuid.generateV4(); expect(result.length, 36); expect(result[8], '-'); @@ -36,7 +36,7 @@ baz=qux }); test('can parse', () { - final Uuid uuid = new Uuid(); + final Uuid uuid = Uuid(); final String result = uuid.generateV4(); expect(int.parse(result.substring(0, 8), radix: 16), isNotNull); expect(int.parse(result.substring(9, 13), radix: 16), isNotNull); @@ -46,7 +46,7 @@ baz=qux }); test('special bits', () { - final Uuid uuid = new Uuid(); + final Uuid uuid = Uuid(); String result = uuid.generateV4(); expect(result[14], '4'); expect(result[19].toLowerCase(), isIn('89ab')); @@ -59,23 +59,23 @@ baz=qux }); test('is pretty random', () { - final Set set = new Set(); + final Set set = Set(); - Uuid uuid = new Uuid(); + Uuid uuid = Uuid(); for (int i = 0; i < 64; i++) { final String val = uuid.generateV4(); expect(set, isNot(contains(val))); set.add(val); } - uuid = new Uuid(); + uuid = Uuid(); for (int i = 0; i < 64; i++) { final String val = uuid.generateV4(); expect(set, isNot(contains(val))); set.add(val); } - uuid = new Uuid(); + uuid = Uuid(); for (int i = 0; i < 64; i++) { final String val = uuid.generateV4(); expect(set, isNot(contains(val))); @@ -87,35 +87,35 @@ baz=qux group('Version', () { test('can parse and compare', () { expect(Version.unknown.toString(), equals('unknown')); - expect(new Version(null, null, null).toString(), equals('0')); + expect(Version(null, null, null).toString(), equals('0')); - final Version v1 = new Version.parse('1'); + final Version v1 = Version.parse('1'); expect(v1.major, equals(1)); expect(v1.minor, equals(0)); expect(v1.patch, equals(0)); expect(v1, greaterThan(Version.unknown)); - final Version v2 = new Version.parse('1.2'); + final Version v2 = Version.parse('1.2'); expect(v2.major, equals(1)); expect(v2.minor, equals(2)); expect(v2.patch, equals(0)); - final Version v3 = new Version.parse('1.2.3'); + final Version v3 = Version.parse('1.2.3'); expect(v3.major, equals(1)); expect(v3.minor, equals(2)); expect(v3.patch, equals(3)); - final Version v4 = new Version.parse('1.12'); + final Version v4 = Version.parse('1.12'); expect(v4, greaterThan(v2)); expect(v3, greaterThan(v2)); expect(v2, greaterThan(v1)); - final Version v5 = new Version(1, 2, 0, text: 'foo'); + final Version v5 = Version(1, 2, 0, text: 'foo'); expect(v5, equals(v2)); - expect(new Version.parse('Preview2.2'), isNull); + expect(Version.parse('Preview2.2'), isNull); }); }); @@ -130,40 +130,40 @@ baz=qux test('fires at start', () async { bool called = false; - poller = new Poller(() async { + poller = Poller(() async { called = true; }, const Duration(seconds: 1)); expect(called, false); - await new Future.delayed(kShortDelay); + await Future.delayed(kShortDelay); expect(called, true); }); test('runs periodically', () async { // Ensure we get the first (no-delay) callback, and one of the periodic callbacks. int callCount = 0; - poller = new Poller(() async { + poller = Poller(() async { callCount++; - }, new Duration(milliseconds: kShortDelay.inMilliseconds ~/ 2)); + }, Duration(milliseconds: kShortDelay.inMilliseconds ~/ 2)); expect(callCount, 0); - await new Future.delayed(kShortDelay); + await Future.delayed(kShortDelay); expect(callCount, greaterThanOrEqualTo(2)); }); test('no quicker then the periodic delay', () async { // Make sure that the poller polls at delay + the time it took to run the callback. - final Completer completer = new Completer(); + final Completer completer = Completer(); DateTime firstTime; - poller = new Poller(() async { + poller = Poller(() async { if (firstTime == null) - firstTime = new DateTime.now(); + firstTime = DateTime.now(); else - completer.complete(new DateTime.now().difference(firstTime)); + completer.complete(DateTime.now().difference(firstTime)); // introduce a delay - await new Future.delayed(kShortDelay); + await Future.delayed(kShortDelay); }, kShortDelay); final Duration duration = await completer.future; - expect(duration, greaterThanOrEqualTo(new Duration(milliseconds: kShortDelay.inMilliseconds * 2))); + expect(duration, greaterThanOrEqualTo(Duration(milliseconds: kShortDelay.inMilliseconds * 2))); }); }); diff --git a/packages/flutter_tools/test/version_test.dart b/packages/flutter_tools/test/version_test.dart index 6060d5f10f..bd2cbcdf13 100644 --- a/packages/flutter_tools/test/version_test.dart +++ b/packages/flutter_tools/test/version_test.dart @@ -18,7 +18,7 @@ import 'package:flutter_tools/src/version.dart'; import 'src/common.dart'; import 'src/context.dart'; -final Clock _testClock = new Clock.fixed(new DateTime(2015, 1, 1)); +final Clock _testClock = Clock.fixed(DateTime(2015, 1, 1)); final DateTime _upToDateVersion = _testClock.agoBy(FlutterVersion.kVersionAgeConsideredUpToDate ~/ 2); final DateTime _outOfDateVersion = _testClock.agoBy(FlutterVersion.kVersionAgeConsideredUpToDate * 2); final DateTime _stampUpToDate = _testClock.agoBy(FlutterVersion.kCheckAgeConsideredUpToDate ~/ 2); @@ -29,8 +29,8 @@ void main() { MockCache mockCache; setUp(() { - mockProcessManager = new MockProcessManager(); - mockCache = new MockCache(); + mockProcessManager = MockProcessManager(); + mockCache = MockCache(); }); group('$FlutterVersion', () { @@ -51,7 +51,7 @@ void main() { await FlutterVersion.instance.checkFlutterVersionFreshness(); _expectVersionMessage(''); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -61,7 +61,7 @@ void main() { mockProcessManager, mockCache, localCommitDate: _outOfDateVersion, - stamp: new VersionCheckStamp( + stamp: VersionCheckStamp( lastTimeVersionWasChecked: _stampOutOfDate, lastKnownRemoteVersion: _outOfDateVersion, ), @@ -74,7 +74,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(''); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -84,7 +84,7 @@ void main() { mockProcessManager, mockCache, localCommitDate: _outOfDateVersion, - stamp: new VersionCheckStamp( + stamp: VersionCheckStamp( lastTimeVersionWasChecked: _stampUpToDate, lastKnownRemoteVersion: _upToDateVersion, ), @@ -95,7 +95,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -105,7 +105,7 @@ void main() { mockProcessManager, mockCache, localCommitDate: _outOfDateVersion, - stamp: new VersionCheckStamp( + stamp: VersionCheckStamp( lastTimeVersionWasChecked: _stampUpToDate, lastKnownRemoteVersion: _upToDateVersion, ), @@ -120,7 +120,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(''); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -149,7 +149,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(''); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -159,7 +159,7 @@ void main() { mockProcessManager, mockCache, localCommitDate: _outOfDateVersion, - stamp: new VersionCheckStamp( + stamp: VersionCheckStamp( lastTimeVersionWasChecked: _stampOutOfDate, lastKnownRemoteVersion: _testClock.ago(days: 2), ), @@ -172,7 +172,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(FlutterVersion.newVersionAvailableMessage()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -191,7 +191,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(''); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -210,7 +210,7 @@ void main() { await version.checkFlutterVersionFreshness(); _expectVersionMessage(FlutterVersion.versionOutOfDateMessage(_testClock.now().difference(_outOfDateVersion))); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -229,7 +229,7 @@ void main() { when(mockProcessManager.runSync( ['git', 'merge-base', '--is-ancestor', 'abcdef', '123456'], workingDirectory: anyNamed('workingDirectory'), - )).thenReturn(new ProcessResult(1, 0, '', '')); + )).thenReturn(ProcessResult(1, 0, '', '')); expect( version.checkRevisionAncestry( @@ -245,7 +245,7 @@ void main() { )); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, }); }); @@ -261,7 +261,7 @@ void main() { fakeData(mockProcessManager, mockCache); _expectDefault(await VersionCheckStamp.load()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -270,7 +270,7 @@ void main() { fakeData(mockProcessManager, mockCache, stampJson: '<'); _expectDefault(await VersionCheckStamp.load()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -279,7 +279,7 @@ void main() { fakeData(mockProcessManager, mockCache, stampJson: '[]'); _expectDefault(await VersionCheckStamp.load()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -298,7 +298,7 @@ void main() { expect(stamp.lastTimeVersionWasChecked, _testClock.ago(days: 2)); expect(stamp.lastTimeWarningWasPrinted, _testClock.now()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -308,7 +308,7 @@ void main() { _expectDefault(await VersionCheckStamp.load()); - final VersionCheckStamp stamp = new VersionCheckStamp( + final VersionCheckStamp stamp = VersionCheckStamp( lastKnownRemoteVersion: _testClock.ago(days: 1), lastTimeVersionWasChecked: _testClock.ago(days: 2), lastTimeWarningWasPrinted: _testClock.now(), @@ -320,7 +320,7 @@ void main() { expect(storedStamp.lastTimeVersionWasChecked, _testClock.ago(days: 2)); expect(storedStamp.lastTimeWarningWasPrinted, _testClock.now()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -330,7 +330,7 @@ void main() { _expectDefault(await VersionCheckStamp.load()); - final VersionCheckStamp stamp = new VersionCheckStamp( + final VersionCheckStamp stamp = VersionCheckStamp( lastKnownRemoteVersion: _testClock.ago(days: 10), lastTimeVersionWasChecked: _testClock.ago(days: 9), lastTimeWarningWasPrinted: _testClock.ago(days: 8), @@ -346,7 +346,7 @@ void main() { expect(storedStamp.lastTimeVersionWasChecked, _testClock.ago(days: 2)); expect(storedStamp.lastTimeWarningWasPrinted, _testClock.now()); }, overrides: { - FlutterVersion: () => new FlutterVersion(_testClock), + FlutterVersion: () => FlutterVersion(_testClock), ProcessManager: () => mockProcessManager, Cache: () => mockCache, }); @@ -371,11 +371,11 @@ void fakeData( bool expectServerPing = false, }) { ProcessResult success(String standardOutput) { - return new ProcessResult(1, 0, standardOutput, ''); + return ProcessResult(1, 0, standardOutput, ''); } ProcessResult failure(int exitCode) { - return new ProcessResult(1, exitCode, '', 'error'); + return ProcessResult(1, exitCode, '', 'error'); } when(cache.getStampFor(any)).thenAnswer((Invocation invocation) { @@ -398,7 +398,7 @@ void fakeData( return null; } - throw new StateError('Unexpected call to Cache.setStampFor(${invocation.positionalArguments}, ${invocation.namedArguments})'); + throw StateError('Unexpected call to Cache.setStampFor(${invocation.positionalArguments}, ${invocation.namedArguments})'); }); final Answering syncAnswer = (Invocation invocation) { @@ -426,7 +426,7 @@ void fakeData( return success(remoteCommitDate.toString()); } - throw new StateError('Unexpected call to ProcessManager.run(${invocation.positionalArguments}, ${invocation.namedArguments})'); + throw StateError('Unexpected call to ProcessManager.run(${invocation.positionalArguments}, ${invocation.namedArguments})'); }; when(pm.runSync(any, workingDirectory: anyNamed('workingDirectory'))).thenAnswer(syncAnswer); @@ -438,27 +438,27 @@ void fakeData( ['git', 'rev-parse', '--abbrev-ref', '--symbolic', '@{u}'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenReturn(new ProcessResult(101, 0, 'master', '')); + )).thenReturn(ProcessResult(101, 0, 'master', '')); when(pm.runSync( ['git', 'rev-parse', '--abbrev-ref', 'HEAD'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenReturn(new ProcessResult(102, 0, 'branch', '')); + )).thenReturn(ProcessResult(102, 0, 'branch', '')); when(pm.runSync( ['git', 'log', '-n', '1', '--pretty=format:%H'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenReturn(new ProcessResult(103, 0, '1234abcd', '')); + )).thenReturn(ProcessResult(103, 0, '1234abcd', '')); when(pm.runSync( ['git', 'log', '-n', '1', '--pretty=format:%ar'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenReturn(new ProcessResult(104, 0, '1 second ago', '')); + )).thenReturn(ProcessResult(104, 0, '1 second ago', '')); when(pm.runSync( ['git', 'describe', '--match', 'v*.*.*', '--first-parent', '--long', '--tags'], workingDirectory: anyNamed('workingDirectory'), environment: anyNamed('environment'), - )).thenReturn(new ProcessResult(105, 0, 'v0.1.2-3-1234abcd', '')); + )).thenReturn(ProcessResult(105, 0, 'v0.1.2-3-1234abcd', '')); } class MockProcessManager extends Mock implements ProcessManager {} diff --git a/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart b/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart index 8b35150def..04451040bb 100644 --- a/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart +++ b/packages/fuchsia_remote_debug_protocol/examples/drive_todo_list_scroll.dart @@ -56,7 +56,7 @@ Future main(List args) async { // Scrolls down 300px. await driver.scroll(find.byType('Scaffold'), 0.0, -300.0, const Duration(milliseconds: 300)); - await new Future.delayed(const Duration(milliseconds: 500)); + await Future.delayed(const Duration(milliseconds: 500)); // Scrolls up 300px. await driver.scroll(find.byType('Scaffold'), 300.0, 300.0, const Duration(milliseconds: 300)); diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart index 196643f83e..d44c5d6457 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/common/logging.dart @@ -72,7 +72,7 @@ class LogMessage { LogMessage(this.message, this.tag, this.level) : this.levelName = level.toString().substring(level.toString().indexOf('.') + 1), - this.time = new DateTime.now(); + this.time = DateTime.now(); /// The actual log message. final String message; @@ -124,27 +124,27 @@ class Logger { /// /// Severe messages are always logged, regardless of what level is set. void severe(String message) { - loggingFunction(new LogMessage(message, tag, LoggingLevel.severe)); + loggingFunction(LogMessage(message, tag, LoggingLevel.severe)); } /// Logs a [LoggingLevel.warning] level `message`. void warning(String message) { if (globalLevel.index >= LoggingLevel.warning.index) { - loggingFunction(new LogMessage(message, tag, LoggingLevel.warning)); + loggingFunction(LogMessage(message, tag, LoggingLevel.warning)); } } /// Logs a [LoggingLevel.info] level `message`. void info(String message) { if (globalLevel.index >= LoggingLevel.info.index) { - loggingFunction(new LogMessage(message, tag, LoggingLevel.info)); + loggingFunction(LogMessage(message, tag, LoggingLevel.info)); } } /// Logs a [LoggingLevel.fine] level `message`. void fine(String message) { if (globalLevel.index >= LoggingLevel.fine.index) { - loggingFunction(new LogMessage(message, tag, LoggingLevel.fine)); + loggingFunction(LogMessage(message, tag, LoggingLevel.fine)); } } } diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/common/network.dart b/packages/fuchsia_remote_debug_protocol/lib/src/common/network.dart index 48d54756b1..559377ec24 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/common/network.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/common/network.dart @@ -9,7 +9,7 @@ import 'dart:core'; /// Throws an [ArgumentError] if the address is neither. void validateAddress(String address) { if (!(isIpV4Address(address) || isIpV6Address(address))) { - throw new ArgumentError( + throw ArgumentError( '"$address" is neither a valid IPv4 nor IPv6 address'); } } diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart index d0f217335e..0156885844 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/dart/dart_vm.dart @@ -16,7 +16,7 @@ const Duration _kReconnectAttemptInterval = Duration(seconds: 3); const Duration _kRpcTimeout = Duration(seconds: 5); -final Logger _log = new Logger('DartVm'); +final Logger _log = Logger('DartVm'); /// Signature of an asynchronous function for astablishing a JSON RPC-2 /// connection to a [Uri]. @@ -32,7 +32,7 @@ RpcPeerConnectionFunction fuchsiaVmServiceConnectionFunction = _waitAndConnect; /// /// Gives up after `_kConnectTimeout` has elapsed. Future _waitAndConnect(Uri uri) async { - final Stopwatch timer = new Stopwatch()..start(); + final Stopwatch timer = Stopwatch()..start(); Future attemptConnection(Uri uri) async { WebSocket socket; @@ -40,7 +40,7 @@ Future _waitAndConnect(Uri uri) async { try { socket = await WebSocket.connect(uri.toString()).timeout(_kConnectTimeout); - peer = new json_rpc.Peer(new IOWebSocketChannel(socket).cast())..listen(); + peer = json_rpc.Peer(IOWebSocketChannel(socket).cast())..listen(); return peer; } on HttpException catch (e) { // This is a fine warning as this most likely means the port is stale. @@ -55,7 +55,7 @@ Future _waitAndConnect(Uri uri) async { await socket?.close(); if (timer.elapsed < _kConnectTimeout) { _log.info('Attempting to reconnect'); - await new Future.delayed(_kReconnectAttemptInterval); + await Future.delayed(_kReconnectAttemptInterval); return attemptConnection(uri); } else { _log.warning('Connection to Fuchsia\'s Dart VM timed out at ' @@ -113,7 +113,7 @@ class DartVm { if (peer == null) { return null; } - return new DartVm._(peer, uri); + return DartVm._(peer, uri); } /// Returns a [List] of [IsolateRef] objects whose name matches `pattern`. @@ -125,8 +125,8 @@ class DartVm { final List result = []; for (Map jsonIsolate in jsonVmRef['isolates']) { final String name = jsonIsolate['name']; - if (name.contains(pattern) && name.contains(new RegExp(r':main\(\)'))) { - result.add(new IsolateRef._fromJson(jsonIsolate, this)); + if (name.contains(pattern) && name.contains(RegExp(r':main\(\)'))) { + result.add(IsolateRef._fromJson(jsonIsolate, this)); } } return result; @@ -145,7 +145,7 @@ class DartVm { final Map result = await _peer .sendRequest(function, params ?? {}) .timeout(timeout, onTimeout: () { - throw new TimeoutException( + throw TimeoutException( 'Peer connection timed out during RPC call', timeout, ); @@ -164,7 +164,7 @@ class DartVm { final Map rpcResponse = await invokeRpc('_flutter.listViews', timeout: _kRpcTimeout); for (Map jsonView in rpcResponse['views']) { - final FlutterView flutterView = new FlutterView._fromJson(jsonView); + final FlutterView flutterView = FlutterView._fromJson(jsonView); if (flutterView != null) { views.add(flutterView); } @@ -199,14 +199,14 @@ class FlutterView { if (isolate != null) { name = isolate['name']; if (name == null) { - throw new RpcFormatError('Unable to find name for isolate "$isolate"'); + throw RpcFormatError('Unable to find name for isolate "$isolate"'); } } if (id == null) { - throw new RpcFormatError( + throw RpcFormatError( 'Unable to find view name for the following JSON structure "$json"'); } - return new FlutterView._(name, id); + return FlutterView._(name, id); } /// Determines the name of the isolate associated with this view. If there is @@ -240,20 +240,20 @@ class IsolateRef { final String name = json['name']; final String type = json['type']; if (type == null) { - throw new RpcFormatError('Unable to find type within JSON "$json"'); + throw RpcFormatError('Unable to find type within JSON "$json"'); } if (type != '@Isolate') { - throw new RpcFormatError('Type "$type" does not match for IsolateRef'); + throw RpcFormatError('Type "$type" does not match for IsolateRef'); } if (number == null) { - throw new RpcFormatError( + throw RpcFormatError( 'Unable to find number for isolate ref within JSON "$json"'); } if (name == null) { - throw new RpcFormatError( + throw RpcFormatError( 'Unable to find name for isolate ref within JSON "$json"'); } - return new IsolateRef._(name, int.parse(number), dartVm); + return IsolateRef._(name, int.parse(number), dartVm); } /// The full name of this Isolate (not guaranteed to be unique). diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart index e8b2559070..a99ab506bd 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/fuchsia_remote_connection.dart @@ -23,7 +23,7 @@ const Duration _kIsolateFindTimeout = Duration(minutes: 1); const Duration _kVmPollInterval = Duration(milliseconds: 1500); -final Logger _log = new Logger('FuchsiaRemoteConnection'); +final Logger _log = Logger('FuchsiaRemoteConnection'); /// A function for forwarding ports on the local machine to a remote device. /// @@ -113,13 +113,13 @@ class FuchsiaRemoteConnection { final Map _dartVmPortMap = {}; /// Tracks stale ports so as not to reconnect while polling. - final Set _stalePorts = new Set(); + final Set _stalePorts = Set(); /// A broadcast stream that emits events relating to Dart VM's as they update. Stream get onDartVmEvent => _onDartVmEvent; Stream _onDartVmEvent; final StreamController _dartVmEventController = - new StreamController(); + StreamController(); /// VM service cache to avoid repeating handshakes across function /// calls. Keys a forwarded port to a DartVm connection instance. @@ -130,7 +130,7 @@ class FuchsiaRemoteConnection { @visibleForTesting static Future connectWithSshCommandRunner( SshCommandRunner commandRunner) async { - final FuchsiaRemoteConnection connection = new FuchsiaRemoteConnection._( + final FuchsiaRemoteConnection connection = FuchsiaRemoteConnection._( isIpV6Address(commandRunner.address), commandRunner); await connection._forwardLocalPortsToDeviceServicePorts(); @@ -138,7 +138,7 @@ class FuchsiaRemoteConnection { Future listen() async { while (connection._pollDartVms) { await connection._pollVms(); - await new Future.delayed(_kVmPollInterval); + await Future.delayed(_kVmPollInterval); } connection._dartVmEventController.close(); } @@ -193,7 +193,7 @@ class FuchsiaRemoteConnection { address ??= Platform.environment['FUCHSIA_DEVICE_URL']; sshConfigPath ??= Platform.environment['FUCHSIA_SSH_CONFIG']; if (address == null) { - throw new FuchsiaRemoteConnectionError( + throw FuchsiaRemoteConnectionError( 'No address supplied, and \$FUCHSIA_DEVICE_URL not found.'); } const String interfaceDelimiter = '%'; @@ -205,7 +205,7 @@ class FuchsiaRemoteConnection { } return await FuchsiaRemoteConnection.connectWithSshCommandRunner( - new SshCommandRunner( + SshCommandRunner( address: address, interface: interface, sshConfigPath: sshConfigPath, @@ -250,7 +250,7 @@ class FuchsiaRemoteConnection { Duration timeout = _kIsolateFindTimeout, ]) async { final Completer> completer = - new Completer>(); + Completer>(); _onDartVmEvent.listen( (DartVmEvent event) async { if (event.eventType == DartVmEventType.started) { @@ -307,7 +307,7 @@ class FuchsiaRemoteConnection { .timeout(timeout) .then((List> listOfLists) { final List> mutableListOfLists = - new List>.from(listOfLists) + List>.from(listOfLists) ..retainWhere((List list) => list.isNotEmpty); // Folds the list of lists into one flat list. return mutableListOfLists.fold>( @@ -351,7 +351,7 @@ class FuchsiaRemoteConnection { acc.addAll(element); return acc; }); - return new List.unmodifiable(results); + return List.unmodifiable(results); } // Calls all Dart VM's, returning a list of results. @@ -370,7 +370,7 @@ class FuchsiaRemoteConnection { await pf.stop(); _stalePorts.add(pf.remotePort); if (queueEvents) { - _dartVmEventController.add(new DartVmEvent._( + _dartVmEventController.add(DartVmEvent._( eventType: DartVmEventType.stopped, servicePort: pf.remotePort, uri: _getDartVmUri(pf.port), @@ -431,7 +431,7 @@ class FuchsiaRemoteConnection { _sshCommandRunner.interface, _sshCommandRunner.sshConfigPath); - _dartVmEventController.add(new DartVmEvent._( + _dartVmEventController.add(DartVmEvent._( eventType: DartVmEventType.started, servicePort: servicePort, uri: _getDartVmUri(_dartVmPortMap[servicePort].port), @@ -606,7 +606,7 @@ class _SshPortForwarder implements PortForwarder { if (processResult.exitCode != 0) { return null; } - final _SshPortForwarder result = new _SshPortForwarder._( + final _SshPortForwarder result = _SshPortForwarder._( address, remotePort, localSocket, interface, sshConfigPath, isIpV6); _log.fine('Set up forwarding from ${localSocket.port} ' 'to $address port $remotePort'); diff --git a/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart b/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart index 3145ce449c..f24ba7da88 100644 --- a/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart +++ b/packages/fuchsia_remote_debug_protocol/lib/src/runners/ssh_command_runner.dart @@ -64,7 +64,7 @@ class SshCommandRunner { validateAddress(address); } - final Logger _log = new Logger('SshCommandRunner'); + final Logger _log = Logger('SshCommandRunner'); final ProcessManager _processManager; @@ -98,7 +98,7 @@ class SshCommandRunner { _log.fine('Running command through SSH: ${args.join(' ')}'); final ProcessResult result = await _processManager.run(args); if (result.exitCode != 0) { - throw new SshCommandError( + throw SshCommandError( 'Command failed: $command\nstdout: ${result.stdout}\nstderr: ${result.stderr}'); } _log.fine('SSH command stdout in brackets:[${result.stdout}]'); diff --git a/packages/fuchsia_remote_debug_protocol/test/common.dart b/packages/fuchsia_remote_debug_protocol/test/common.dart index 79d7310b12..55d44ba91e 100644 --- a/packages/fuchsia_remote_debug_protocol/test/common.dart +++ b/packages/fuchsia_remote_debug_protocol/test/common.dart @@ -11,4 +11,4 @@ import 'package:test/test.dart' as test_package show TypeMatcher; export 'package:test/test.dart' hide TypeMatcher, isInstanceOf; /// A matcher that compares the type of the actual value to the type argument T. -Matcher isInstanceOf() => new test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 +Matcher isInstanceOf() => test_package.TypeMatcher(); // ignore: prefer_const_constructors, https://github.com/dart-lang/sdk/issues/32544 diff --git a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart index 40e7de80ff..7d266d36fe 100644 --- a/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/fuchsia_remote_connection_test.dart @@ -19,10 +19,10 @@ void main() { List uriConnections; setUp(() { - mockRunner = new MockSshCommandRunner(); + mockRunner = MockSshCommandRunner(); // Adds some extra junk to make sure the strings will be cleaned up. when(mockRunner.run(any)).thenAnswer((_) => - new Future>.value( + Future>.value( ['123\n\n\n', '456 ', '789'])); const String address = 'fe80::8eae:4cff:fef4:9247'; const String interface = 'eno1'; @@ -33,8 +33,8 @@ void main() { Future mockPortForwardingFunction( String address, int remotePort, [String interface = '', String configFile]) { - return new Future(() { - final MockPortForwarder pf = new MockPortForwarder(); + return Future(() { + final MockPortForwarder pf = MockPortForwarder(); forwardedPorts.add(pf); when(pf.port).thenReturn(port++); when(pf.remotePort).thenReturn(remotePort); @@ -87,14 +87,14 @@ void main() { mockPeerConnections = []; uriConnections = []; Future mockVmConnectionFunction(Uri uri) { - return new Future(() async { - final MockPeer mp = new MockPeer(); + return Future(() async { + final MockPeer mp = MockPeer(); mockPeerConnections.add(mp); uriConnections.add(uri); when(mp.sendRequest(any, any)) // The local ports match the desired indices for now, so get the // canned response from the URI port. - .thenAnswer((_) => new Future>( + .thenAnswer((_) => Future>( () => flutterViewCannedResponses[uri.port])); return mp; }); diff --git a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart index be717c1ff9..9df970f566 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/dart/dart_vm_test.dart @@ -18,7 +18,7 @@ void main() { test('null connector', () async { Future mockServiceFunction(Uri uri) { - return new Future(() => null); + return Future(() => null); } fuchsiaVmServiceConnectionFunction = mockServiceFunction; @@ -27,9 +27,9 @@ void main() { }); test('disconnect closes peer', () async { - final MockPeer peer = new MockPeer(); + final MockPeer peer = MockPeer(); Future mockServiceFunction(Uri uri) { - return new Future(() => peer); + return Future(() => peer); } fuchsiaVmServiceConnectionFunction = mockServiceFunction; @@ -45,7 +45,7 @@ void main() { MockPeer mockPeer; setUp(() { - mockPeer = new MockPeer(); + mockPeer = MockPeer(); }); tearDown(() { @@ -86,9 +86,9 @@ void main() { Future mockVmConnectionFunction(Uri uri) { when(mockPeer.sendRequest(any, any)) - .thenAnswer((_) => new Future>( + .thenAnswer((_) => Future>( () => flutterViewCannedResponses)); - return new Future(() => mockPeer); + return Future(() => mockPeer); } fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; @@ -142,9 +142,9 @@ void main() { Future mockVmConnectionFunction(Uri uri) { when(mockPeer.sendRequest(any, any)) - .thenAnswer((_) => new Future>( + .thenAnswer((_) => Future>( () => flutterViewCannedResponses)); - return new Future(() => mockPeer); + return Future(() => mockPeer); } fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; @@ -190,9 +190,9 @@ void main() { Future mockVmConnectionFunction(Uri uri) { when(mockPeer.sendRequest(any, any)) - .thenAnswer((_) => new Future>( + .thenAnswer((_) => Future>( () => flutterViewCannedResponseMissingId)); - return new Future(() => mockPeer); + return Future(() => mockPeer); } fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; @@ -237,8 +237,8 @@ void main() { Future mockVmConnectionFunction(Uri uri) { when(mockPeer.sendRequest(any, any)) .thenAnswer((_) => - new Future>(() => vmCannedResponse)); - return new Future(() => mockPeer); + Future>(() => vmCannedResponse)); + return Future(() => mockPeer); } fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; @@ -270,9 +270,9 @@ void main() { Future mockVmConnectionFunction(Uri uri) { when(mockPeer.sendRequest(any, any)) - .thenAnswer((_) => new Future>( + .thenAnswer((_) => Future>( () => flutterViewCannedResponseMissingIsolateName)); - return new Future(() => mockPeer); + return Future(() => mockPeer); } fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; @@ -292,7 +292,7 @@ void main() { MockPeer mockPeer; setUp(() { - mockPeer = new MockPeer(); + mockPeer = MockPeer(); }); tearDown(() { @@ -304,8 +304,8 @@ void main() { Future mockVmConnectionFunction(Uri uri) { // Return a command that will never complete. when(mockPeer.sendRequest(any, any)) - .thenAnswer((_) => new Completer>().future); - return new Future(() => mockPeer); + .thenAnswer((_) => Completer>().future); + return Future(() => mockPeer); } fuchsiaVmServiceConnectionFunction = mockVmConnectionFunction; diff --git a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart index 2fb9ef6db0..29554d7858 100644 --- a/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart +++ b/packages/fuchsia_remote_debug_protocol/test/src/runners/ssh_command_runner_test.dart @@ -15,7 +15,7 @@ void main() { group('SshCommandRunner.constructors', () { test('throws exception with invalid address', () async { SshCommandRunner newCommandRunner() { - return new SshCommandRunner(address: 'sillyaddress.what'); + return SshCommandRunner(address: 'sillyaddress.what'); } expect(newCommandRunner, throwsArgumentError); @@ -24,7 +24,7 @@ void main() { test('throws exception from injection constructor with invalid addr', () async { SshCommandRunner newCommandRunner() { - return new SshCommandRunner.withProcessManager( + return SshCommandRunner.withProcessManager( const LocalProcessManager(), address: '192.168.1.1.1'); } @@ -39,16 +39,16 @@ void main() { SshCommandRunner runner; setUp(() { - mockProcessManager = new MockProcessManager(); - mockProcessResult = new MockProcessResult(); + mockProcessManager = MockProcessManager(); + mockProcessResult = MockProcessResult(); when(mockProcessManager.run(any)).thenAnswer( - (_) => new Future.value(mockProcessResult)); + (_) => Future.value(mockProcessResult)); }); test('verify interface is appended to ipv6 address', () async { const String ipV6Addr = 'fe80::8eae:4cff:fef4:9247'; const String interface = 'eno1'; - runner = new SshCommandRunner.withProcessManager( + runner = SshCommandRunner.withProcessManager( mockProcessManager, address: ipV6Addr, interface: interface, @@ -65,7 +65,7 @@ void main() { test('verify no percentage symbol is added when no ipv6 interface', () async { const String ipV6Addr = 'fe80::8eae:4cff:fef4:9247'; - runner = new SshCommandRunner.withProcessManager( + runner = SshCommandRunner.withProcessManager( mockProcessManager, address: ipV6Addr, ); @@ -79,7 +79,7 @@ void main() { test('verify commands are split into multiple lines', () async { const String addr = '192.168.1.1'; - runner = new SshCommandRunner.withProcessManager(mockProcessManager, + runner = SshCommandRunner.withProcessManager(mockProcessManager, address: addr); when(mockProcessResult.stdout).thenReturn('''this has @@ -92,7 +92,7 @@ void main() { test('verify exception on nonzero process result exit code', () async { const String addr = '192.168.1.1'; - runner = new SshCommandRunner.withProcessManager(mockProcessManager, + runner = SshCommandRunner.withProcessManager(mockProcessManager, address: addr); when(mockProcessResult.stdout).thenReturn('whatever'); when(mockProcessResult.exitCode).thenReturn(1); @@ -106,7 +106,7 @@ void main() { test('verify correct args with config', () async { const String addr = 'fe80::8eae:4cff:fef4:9247'; const String config = '/this/that/this/and/uh'; - runner = new SshCommandRunner.withProcessManager( + runner = SshCommandRunner.withProcessManager( mockProcessManager, address: addr, sshConfigPath: config, @@ -124,7 +124,7 @@ void main() { test('verify config is excluded correctly', () async { const String addr = 'fe80::8eae:4cff:fef4:9247'; - runner = new SshCommandRunner.withProcessManager( + runner = SshCommandRunner.withProcessManager( mockProcessManager, address: addr, );