flutter

How do you create a Flutter App without the Counter MyApp boilerplate code being created?


Using flutter create myapp and File -> New Flutter Project... in Android Studio/IntelliJ both result in the sample code for MyApp (the increment counter app) being created. Is there a way to:

Something like:

import 'package:flutter/material.dart';

void main() => runApp(new HelloWorld());

class HelloWorld extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return new Container();
  }
}

Solution

  • No, currently flutter create (and the new project wizards in the IDEs) only create that one example. That's useful in that there are fewer questions asked for new users, who may not have the context to answer a lot of framework questions up front. I think the template is also a good balance between having too much boilerplate code while still providing enough exposure to the framework to be a good pedagogical example.

    It likely should borrow a bit of its name from the project name (i.e., hello_world.dart ==> a class name of HelloWorld). For suggestions like that, https://github.com/flutter/flutter/issues/new is the best place to provide feedback.