fix: rename layout in app template
This commit is contained in:
parent
cae5f242e5
commit
1d1e7637cc
@ -37,6 +37,7 @@ vars:
|
|||||||
prompt: "What is the project name?"
|
prompt: "What is the project name?"
|
||||||
formats:
|
formats:
|
||||||
- snake_case
|
- snake_case
|
||||||
|
- pascal_case
|
||||||
|
|
||||||
bundle_id:
|
bundle_id:
|
||||||
compilable: io.wyattapp.start
|
compilable: io.wyattapp.start
|
||||||
|
@ -1,115 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
runApp(const MyApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
const MyApp({super.key});
|
|
||||||
|
|
||||||
// This widget is the root of your application.
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MaterialApp(
|
|
||||||
title: 'Flutter Demo',
|
|
||||||
theme: ThemeData(
|
|
||||||
// This is the theme of your application.
|
|
||||||
//
|
|
||||||
// Try running your application with "flutter run". You'll see the
|
|
||||||
// application has a blue toolbar. Then, without quitting the app, try
|
|
||||||
// changing the primarySwatch below to Colors.green and then invoke
|
|
||||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
|
||||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
|
||||||
// Notice that the counter didn't reset back to zero; the application
|
|
||||||
// is not restarted.
|
|
||||||
primarySwatch: Colors.blue,
|
|
||||||
),
|
|
||||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
const MyHomePage({super.key, required this.title});
|
|
||||||
|
|
||||||
// This widget is the home page of your application. It is stateful, meaning
|
|
||||||
// that it has a State object (defined below) that contains fields that affect
|
|
||||||
// how it looks.
|
|
||||||
|
|
||||||
// This class is the configuration for the state. It holds the values (in this
|
|
||||||
// case the title) provided by the parent (in this case the App widget) and
|
|
||||||
// used by the build method of the State. Fields in a Widget subclass are
|
|
||||||
// always marked "final".
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
// This call to setState tells the Flutter framework that something has
|
|
||||||
// changed in this State, which causes it to rerun the build method below
|
|
||||||
// so that the display can reflect the updated values. If we changed
|
|
||||||
// _counter without calling setState(), then the build method would not be
|
|
||||||
// called again, and so nothing would appear to happen.
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// This method is rerun every time setState is called, for instance as done
|
|
||||||
// by the _incrementCounter method above.
|
|
||||||
//
|
|
||||||
// The Flutter framework has been optimized to make rerunning build methods
|
|
||||||
// fast, so that you can just rebuild anything that needs updating rather
|
|
||||||
// than having to individually change instances of widgets.
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
// Here we take the value from the MyHomePage object that was created by
|
|
||||||
// the App.build method, and use it to set our appbar title.
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
// Center is a layout widget. It takes a single child and positions it
|
|
||||||
// in the middle of the parent.
|
|
||||||
child: Column(
|
|
||||||
// Column is also a layout widget. It takes a list of children and
|
|
||||||
// arranges them vertically. By default, it sizes itself to fit its
|
|
||||||
// children horizontally, and tries to be as tall as its parent.
|
|
||||||
//
|
|
||||||
// Invoke "debug painting" (press "p" in the console, choose the
|
|
||||||
// "Toggle Debug Paint" action from the Flutter Inspector in Android
|
|
||||||
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
|
|
||||||
// to see the wireframe for each widget.
|
|
||||||
//
|
|
||||||
// Column has various properties to control how it sizes itself and
|
|
||||||
// how it positions its children. Here we use mainAxisAlignment to
|
|
||||||
// center the children vertically; the main axis here is the vertical
|
|
||||||
// axis because Columns are vertical (the cross axis would be
|
|
||||||
// horizontal).
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
const Text(
|
|
||||||
'You have pushed the button this many times:',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'$_counter',
|
|
||||||
style: Theme.of(context).textTheme.headline4,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: _incrementCounter,
|
|
||||||
tooltip: 'Increment',
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import 'package:starting_template/domain/usecases/counter/increment.dart';
|
|||||||
import 'package:starting_template/domain/usecases/counter/reset.dart';
|
import 'package:starting_template/domain/usecases/counter/reset.dart';
|
||||||
import 'package:starting_template/presentation/features/counter/blocs/counter_cubit/counter_cubit.dart';
|
import 'package:starting_template/presentation/features/counter/blocs/counter_cubit/counter_cubit.dart';
|
||||||
import 'package:starting_template/presentation/features/counter/screens/widgets/counter_consumer_widget.dart';
|
import 'package:starting_template/presentation/features/counter/screens/widgets/counter_consumer_widget.dart';
|
||||||
import 'package:starting_template/presentation/shared/layouts/wyatt_app_template_scaffold.dart';
|
import 'package:starting_template/presentation/shared/layouts/starting_template_scaffold.dart';
|
||||||
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
||||||
|
|
||||||
/// {@template counter_provider}
|
/// {@template counter_provider}
|
||||||
@ -38,7 +38,7 @@ class CounterProvider extends CubitProviderScreen<CounterCubit, CounterState> {
|
|||||||
bloc..getCurrent();
|
bloc..getCurrent();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget builder(BuildContext context) => WyattAppTemplateScaffold(
|
Widget builder(BuildContext context) => StartingTemplateScaffold(
|
||||||
title: Text(context.l10n.counterAppBarTitle),
|
title: Text(context.l10n.counterAppBarTitle),
|
||||||
body: const CounterConsumerWidget(),
|
body: const CounterConsumerWidget(),
|
||||||
fabChildren: [
|
fabChildren: [
|
||||||
|
@ -4,7 +4,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:starting_template/core/extensions/build_context_extension.dart';
|
import 'package:starting_template/core/extensions/build_context_extension.dart';
|
||||||
import 'package:starting_template/gen/assets.gen.dart';
|
import 'package:starting_template/gen/assets.gen.dart';
|
||||||
import 'package:starting_template/presentation/features/counter/counter.dart';
|
import 'package:starting_template/presentation/features/counter/counter.dart';
|
||||||
import 'package:starting_template/presentation/shared/layouts/wyatt_app_template_scaffold.dart';
|
import 'package:starting_template/presentation/shared/layouts/starting_template_scaffold.dart';
|
||||||
|
|
||||||
class Home extends StatelessWidget {
|
class Home extends StatelessWidget {
|
||||||
const Home({super.key});
|
const Home({super.key});
|
||||||
@ -12,7 +12,7 @@ class Home extends StatelessWidget {
|
|||||||
static const String pageName = 'homePage';
|
static const String pageName = 'homePage';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => WyattAppTemplateScaffold(
|
Widget build(BuildContext context) => StartingTemplateScaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class WyattAppTemplateScaffold extends StatelessWidget {
|
class StartingTemplateScaffold extends StatelessWidget {
|
||||||
const WyattAppTemplateScaffold({
|
const StartingTemplateScaffold({
|
||||||
required this.body,
|
required this.body,
|
||||||
super.key,
|
super.key,
|
||||||
this.title,
|
this.title,
|
@ -1,115 +0,0 @@
|
|||||||
import 'package:flutter/material.dart';
|
|
||||||
|
|
||||||
void main() {
|
|
||||||
runApp(const MyApp());
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyApp extends StatelessWidget {
|
|
||||||
const MyApp({super.key});
|
|
||||||
|
|
||||||
// This widget is the root of your application.
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
return MaterialApp(
|
|
||||||
title: 'Flutter Demo',
|
|
||||||
theme: ThemeData(
|
|
||||||
// This is the theme of your application.
|
|
||||||
//
|
|
||||||
// Try running your application with "flutter run". You'll see the
|
|
||||||
// application has a blue toolbar. Then, without quitting the app, try
|
|
||||||
// changing the primarySwatch below to Colors.green and then invoke
|
|
||||||
// "hot reload" (press "r" in the console where you ran "flutter run",
|
|
||||||
// or simply save your changes to "hot reload" in a Flutter IDE).
|
|
||||||
// Notice that the counter didn't reset back to zero; the application
|
|
||||||
// is not restarted.
|
|
||||||
primarySwatch: Colors.blue,
|
|
||||||
),
|
|
||||||
home: const MyHomePage(title: 'Flutter Demo Home Page'),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class MyHomePage extends StatefulWidget {
|
|
||||||
const MyHomePage({super.key, required this.title});
|
|
||||||
|
|
||||||
// This widget is the home page of your application. It is stateful, meaning
|
|
||||||
// that it has a State object (defined below) that contains fields that affect
|
|
||||||
// how it looks.
|
|
||||||
|
|
||||||
// This class is the configuration for the state. It holds the values (in this
|
|
||||||
// case the title) provided by the parent (in this case the App widget) and
|
|
||||||
// used by the build method of the State. Fields in a Widget subclass are
|
|
||||||
// always marked "final".
|
|
||||||
|
|
||||||
final String title;
|
|
||||||
|
|
||||||
@override
|
|
||||||
State<MyHomePage> createState() => _MyHomePageState();
|
|
||||||
}
|
|
||||||
|
|
||||||
class _MyHomePageState extends State<MyHomePage> {
|
|
||||||
int _counter = 0;
|
|
||||||
|
|
||||||
void _incrementCounter() {
|
|
||||||
setState(() {
|
|
||||||
// This call to setState tells the Flutter framework that something has
|
|
||||||
// changed in this State, which causes it to rerun the build method below
|
|
||||||
// so that the display can reflect the updated values. If we changed
|
|
||||||
// _counter without calling setState(), then the build method would not be
|
|
||||||
// called again, and so nothing would appear to happen.
|
|
||||||
_counter++;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
Widget build(BuildContext context) {
|
|
||||||
// This method is rerun every time setState is called, for instance as done
|
|
||||||
// by the _incrementCounter method above.
|
|
||||||
//
|
|
||||||
// The Flutter framework has been optimized to make rerunning build methods
|
|
||||||
// fast, so that you can just rebuild anything that needs updating rather
|
|
||||||
// than having to individually change instances of widgets.
|
|
||||||
return Scaffold(
|
|
||||||
appBar: AppBar(
|
|
||||||
// Here we take the value from the MyHomePage object that was created by
|
|
||||||
// the App.build method, and use it to set our appbar title.
|
|
||||||
title: Text(widget.title),
|
|
||||||
),
|
|
||||||
body: Center(
|
|
||||||
// Center is a layout widget. It takes a single child and positions it
|
|
||||||
// in the middle of the parent.
|
|
||||||
child: Column(
|
|
||||||
// Column is also a layout widget. It takes a list of children and
|
|
||||||
// arranges them vertically. By default, it sizes itself to fit its
|
|
||||||
// children horizontally, and tries to be as tall as its parent.
|
|
||||||
//
|
|
||||||
// Invoke "debug painting" (press "p" in the console, choose the
|
|
||||||
// "Toggle Debug Paint" action from the Flutter Inspector in Android
|
|
||||||
// Studio, or the "Toggle Debug Paint" command in Visual Studio Code)
|
|
||||||
// to see the wireframe for each widget.
|
|
||||||
//
|
|
||||||
// Column has various properties to control how it sizes itself and
|
|
||||||
// how it positions its children. Here we use mainAxisAlignment to
|
|
||||||
// center the children vertically; the main axis here is the vertical
|
|
||||||
// axis because Columns are vertical (the cross axis would be
|
|
||||||
// horizontal).
|
|
||||||
mainAxisAlignment: MainAxisAlignment.center,
|
|
||||||
children: <Widget>[
|
|
||||||
const Text(
|
|
||||||
'You have pushed the button this many times:',
|
|
||||||
),
|
|
||||||
Text(
|
|
||||||
'$_counter',
|
|
||||||
style: Theme.of(context).textTheme.headline4,
|
|
||||||
),
|
|
||||||
],
|
|
||||||
),
|
|
||||||
),
|
|
||||||
floatingActionButton: FloatingActionButton(
|
|
||||||
onPressed: _incrementCounter,
|
|
||||||
tooltip: 'Increment',
|
|
||||||
child: const Icon(Icons.add),
|
|
||||||
), // This trailing comma makes auto-formatting nicer for build methods.
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
@ -7,7 +7,7 @@ import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/domain/usecases/cou
|
|||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/domain/usecases/counter/reset.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/domain/usecases/counter/reset.dart';
|
||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/blocs/counter_cubit/counter_cubit.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/blocs/counter_cubit/counter_cubit.dart';
|
||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/screens/widgets/counter_consumer_widget.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/screens/widgets/counter_consumer_widget.dart';
|
||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/wyatt_app_template_scaffold.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/{{#snakeCase}}{{project_name}}{{/snakeCase}}_scaffold.dart';
|
||||||
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
import 'package:wyatt_bloc_helper/wyatt_bloc_helper.dart';
|
||||||
|
|
||||||
/// {@template counter_provider}
|
/// {@template counter_provider}
|
||||||
@ -38,7 +38,7 @@ class CounterProvider extends CubitProviderScreen<CounterCubit, CounterState> {
|
|||||||
bloc..getCurrent();
|
bloc..getCurrent();
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget builder(BuildContext context) => WyattAppTemplateScaffold(
|
Widget builder(BuildContext context) => {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold(
|
||||||
title: Text(context.l10n.counterAppBarTitle),
|
title: Text(context.l10n.counterAppBarTitle),
|
||||||
body: const CounterConsumerWidget(),
|
body: const CounterConsumerWidget(),
|
||||||
fabChildren: [
|
fabChildren: [
|
||||||
|
@ -4,7 +4,7 @@ import 'package:go_router/go_router.dart';
|
|||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/core/extensions/build_context_extension.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/core/extensions/build_context_extension.dart';
|
||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/gen/assets.gen.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/gen/assets.gen.dart';
|
||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/counter.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/features/counter/counter.dart';
|
||||||
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/wyatt_app_template_scaffold.dart';
|
import 'package:{{#snakeCase}}{{project_name}}{{/snakeCase}}/presentation/shared/layouts/{{#snakeCase}}{{project_name}}{{/snakeCase}}_scaffold.dart';
|
||||||
|
|
||||||
class Home extends StatelessWidget {
|
class Home extends StatelessWidget {
|
||||||
const Home({super.key});
|
const Home({super.key});
|
||||||
@ -12,7 +12,7 @@ class Home extends StatelessWidget {
|
|||||||
static const String pageName = 'homePage';
|
static const String pageName = 'homePage';
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) => WyattAppTemplateScaffold(
|
Widget build(BuildContext context) => {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold(
|
||||||
body: Center(
|
body: Center(
|
||||||
child: Column(
|
child: Column(
|
||||||
children: [
|
children: [
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
|
||||||
class WyattAppTemplateScaffold extends StatelessWidget {
|
class {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold extends StatelessWidget {
|
||||||
const WyattAppTemplateScaffold({
|
const {{#pascalCase}}{{project_name}}{{/pascalCase}}Scaffold({
|
||||||
required this.body,
|
required this.body,
|
||||||
super.key,
|
super.key,
|
||||||
this.title,
|
this.title,
|
Loading…
x
Reference in New Issue
Block a user