How can I successfully build the Flutter Gallery app?

Viewed 596

I tried to build the Gallery app of Flutter and got two times the same error. Can you please help me build it ? NB : I ran

flutter run -d macos

Here is the error :

lib/demos/material/picker_demo.dart:23:9: Error: Type 'RestorableTimeOfDay' not found.

final RestorableTimeOfDay _fromTime = RestorableTimeOfDay(
^^^^^^^^^^^^^^^^^^^
lib/demos/material/picker_demo.dart:23:9: Error: 'RestorableTimeOfDay' isn't a type. final RestorableTimeOfDay _fromTime = RestorableTimeOfDay(
^^^^^^^^^^^^^^^^^^^
lib/demos/material/picker_demo.dart:23:41: Error: Method not found: 'RestorableTimeOfDay'. final RestorableTimeOfDay _fromTime = RestorableTimeOfDay(
^^^^^^^^^^^^^^^^^^^
lib/demos/material/picker_demo.dart:88:16: Error: Method not found: 'TimePickerDialog'. return TimePickerDialog(

Thanks for any help

1 Answers

The errors were due to the fact that I was on the stable channel

$ flutter channel
Flutter channels:
  master
  dev
  beta
* stable

As indicated on the github page, it's necessary to use the master channel.

$ flutter channel master
Switching to flutter channel 'master'...
git: From https://github.com/flutter/flutter
git:  + f9c825981c...fa5883b78e dev            -> origin/dev  (forced update)
git:  * [new branch]            flutter-2.3-candidate.19 -> origin/flutter-2.3-candidate.19
git:  * [new branch]            flutter-2.3-candidate.20 -> origin/flutter-2.3-candidate.20
git:  * [new branch]            flutter-2.3-candidate.21 -> origin/flutter-2.3-candidate.21
git:  * [new branch]            flutter-2.3-candidate.22 -> origin/flutter-2.3-candidate.22
git:    58ac7b85d9..811f0d9a15  master         -> origin/master
git:  * [new tag]               2.3.0-16.0.pre -> 2.3.0-16.0.pre
git: Switched to a new branch 'master'
git: Branch 'master' set up to track remote branch 'master' from 'origin'.
Successfully switched to flutter channel 'master'.
To ensure that you're on the latest build from this channel, run 'flutter upgrade'

$ flutter upgrade
Downloading Dart SDK from Flutter engine 03d645e782db18812d33a843f61c7b220f3db107...
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  216M  100  216M    0     0  8057k      0  0:00:27  0:00:27 --:--:-- 8515k
Building flutter tool...
Flutter is already up to date on channel master
Flutter 2.3.0-17.0.pre.223 • channel master • https://github.com/flutter/flutter.git
Framework • revision 811f0d9a15 (4 hours ago) • 2021-06-04 22:14:03 -0700
Engine • revision 03d645e782
Tools • Dart 2.14.0 (build 2.14.0-182.0.dev)

$ flutter channel
Downloading package sky_engine...                                  883ms
Downloading flutter_patched_sdk tools...                           977ms
Downloading flutter_patched_sdk_product tools...                   616ms
Downloading linux-x64 tools...                                      3.8s
Downloading linux-x64/font-subset tools...                         562ms
Flutter channels:
* master
  dev
  beta
  stable

Now it runs:

$ flutter run
Downloading linux-x64/linux-x64-flutter-gtk tools...             2,750ms
Downloading linux-x64-profile/linux-x64-flutter-gtk tools...      1,810ms
Downloading linux-x64-release/linux-x64-flutter-gtk tools...      2,001ms
Running "flutter pub get" in gallery...                          2,791ms
Launching lib/main.dart on Linux in debug mode...
Building Linux application...                                           
Syncing files to device Linux...                                   635ms

Flutter run key commands.
r Hot reload. 
R Hot restart.
h List all available interactive commands.
d Detach (terminate "flutter run" but leave application running).
c Clear the screen
q Quit (terminate the application on the device).

Running with unsound null safety
For more information see https://dart.dev/null-safety/unsound-null-safety
Related