About a week ago, I created a new flutter project using:
flutter create -t app my_app
But when I opened the resulting project in the IDE, I was surprised to find the project has some key differences compared to what I’m used to:
- there is a folder inside the lib folder, "src"
- the main.dart does not contain the usual "counter app" and looks like this:
import 'package:flutter/material.dart';
import 'src/app.dart';
import 'src/settings/settings_controller.dart';
import 'src/settings/settings_service.dart';
void main() async {
// Set up the SettingsController, which will glue user settings to multiple
// Flutter Widgets.
final settingsController = SettingsController(SettingsService());
// Load the user's preferred theme while the splash screen is displayed.
// This prevents a sudden theme change when the app is first displayed.
await settingsController.loadSettings();
// Run the app and pass in the SettingsController. The app listens to the
// SettingsController for changes, then passes it further down to the
// SettingsView.
runApp(MyApp(settingsController: settingsController));
}
I tried creating other new projects and I verified it also happened when using "flutter create -t skeleton."
Now, after a week, it seems to have gone back to the old behavior.
Does anyone know the explanation for this?
2
Answers
At first let me describe what is
flutter create -t skeleton
:For many years Flutter has provided the basic
Counter App
each time you created a new project.While that example provides a nice introduction to the foundational concepts of
StatefulWidget
and basic font/asset management, it does not really resemble the structure of acomplete app
.This has left developers without guidance for anything beyond a basic single page app.
To fix this issue the Flutter team have been hard at work on a new template with the stated goals:
Make it easier for developers to continue their learning journey beyond the Counter app.Co-exist with the original Counter app template.It is not a replacement.
The new template was merged into master in June 2021, and you can create it with this command:
flutter create -t skeleton your_project_name
Now what happened to you ?
I guess your name of project is
my_app
.And this code created by run
flutter create -t skeleton my_app
and very similar toflutter create -t app my_app
statement .You probably ran the command
Then that’s exactly what your project will look like, as you described. This can be seen here.
If you run
or
then a default counter application must be created, as here
There may have been an undiscovered error. But to do this, you need to know the exact version of flutter you were using at the time, and the 100% command you entered. That’s how it could be repeated. Is everything all right now?