Open monkeydaichan opened 2 years ago
動画3 RaisedButtonを書くと”The named parameter 'onPressed' is required, but there's no corresponding argument.”エラーが出た。 エラー内容をクリックすると、下にonPressedが配置されてエラーが消えた
https://zenn.dev/sugitlab/articles/772e107b515908 RaisedButton -> ElevatedButtonへの名称変更? 上記の方法で動いているのでそのままRaisedButton使用
https://zenn.dev/sugitlab/articles/772e107b515908 RaisedButton -> ElevatedButtonへの名称変更? 上記の方法で動いているのでそのままRaisedButton使用
@TakuroNagasawa ElevatedButtonを使うようにしてください. RaisedButtonは将来的になるなるので.
動画3 RaisedButtonを書くと”The named parameter 'onPressed' is required, but there's no corresponding argument.”エラーが出た。 エラー内容をクリックすると、下にonPressedが配置されてエラーが消えた
The named parameter 'onPressed' is required, but there's no corresponding argument
エラー通りです.onPressedというパラメータは必須です.
https://zenn.dev/sugitlab/articles/772e107b515908 RaisedButton -> ElevatedButtonへの名称変更? 上記の方法で動いているのでそのままRaisedButton使用 @TakuroNagasawa ElevatedButtonを使うようにしてください. RaisedButtonは将来的になるなるので.
了解です。 Ya.
https://youtu.be/EJOA0plae_s?list=PLuLRJz1UnJzEDjRr1XkqyOzFzUi3Df4B0&t=663 @monkeydaichan @TakuroNagasawa 動画1のColumを消してRowを使うところでうまく動かせない。 本来は文字の順列が縦になっていたものが横並びに出るはず エラーの見方がわからない。Problemsというところに15個くらい赤字で表示されているのでそれが問題だと思うが、どこに問題があるのかがわからない。
DEBUG CONSOLEにエラーメッセージが表示されます. @KyoheiTaniguchi
@KyoheiTaniguchi エラー内容が知りたいです。
動画7 TextFieldを使っても、キーボードが表示されない。VS Codeにエラーはなし。 https://qiita.com/ctak/items/75fca7094c50f7364cbd Simulator -> I/O -> Keyboard -> Connect Hardware Keyboardのチェックを外す。 でキーボード表示された
@TakuroNagasawa
@KyoheiTaniguchi エラー内容が知りたいです。
@KyoheiTaniguchi
コードがYouTubeのものとおなじか確認し直してください.
多分全く違います.
あとコードも貼り付けてください.
@KyoheiTaniguchi
エラーメッセージなどは画像じゃなくてテキストで貼り付けてください.
調べるときに調べる側の手間が増えるので
@monkeydaichan
: Error: No named parameter with the name 'mainAxisAlignment'.
lib/main.dart:63
mainAxisAlignment: MainAxisAlignment.center,
^^^^^^^^^^^^^^^^^
: Context: Found this candidate, but the arguments don't match.
../…/material/scaffold.dart:1470
const Scaffold({
^^^^^^^^
: Error: Expected ';' after this.
lib/main.dart:73
),
^
: Error: Expected an identifier, but got ','.
lib/main.dart:73
Try inserting an identifier before ','.
),
^
: Error: Unexpected token ';'.
lib/main.dart:73
),
^
: Error: Expected an identifier, but got ')'.
lib/main.dart:74
Try inserting an identifier before ')'.
);;,
^
: Error: Expected ';' after this.
lib/main.dart:73
),
^
: Error: Unexpected token ';'.
lib/main.dart:74
);;,
^
: Error: Expected an identifier, but got ','.
lib/main.dart:74
Try inserting an identifier before ','.
);;,
^
: Error: Expected ';' after this.
lib/main.dart:74
);;,
^
Error: Unexpected token ';'.
lib/main.dart:74
);;,
^
: Error: Expected ';' after this.
lib/main.dart:79
), // This trailing comma makes auto-formatting nicer for build methods.
^
: Error: Expected an identifier, but got ','.
lib/main.dart:79
Try inserting an identifier before ','.
), // This trailing comma makes auto-formatting nicer for build methods.
^
: Error: Unexpected token ';'.
lib/main.dart:79
), // This trailing comma makes auto-formatting nicer for build methods.
^
: Error: Expected an identifier, but got ')'.
lib/main.dart:80
Try inserting an identifier before ')'.
);
^
: Error: Expected ';' after this.
lib/main.dart:79
), // This trailing comma makes auto-formatting nicer for build methods.
^
: Error: Unexpected token ';'.
lib/main.dart:80
);
^
@KyoheiTaniguchi コードがYouTubeのものとおなじか確認し直してください. 多分全く違います.
あとコードも貼り付けてください.
コードは恭ちゃんがいま書いてるコードのことです.
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: const MyHomePage(title: 'Flutter Demo Home Page'),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({Key? key, required this.title}) : super(key: key);
final String title;
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
@override
Widget build(BuildContext context) {
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('asigar'),
actions: [
Icon(Icons.add), Icon(Icons.share), ],
),
body: Center(
child: Row(
children: [
Text('とてもわかる')
],),),
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
const Text(
'なんでもいい',
),
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.
-;
}
}
@monkeydaichan 今のコードです
@KyoheiTaniguchi 画像で送ります.
The named parameter 'mainAxisAlignment' isn't defined.
Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'mainAxisAlignment'
これが出ているエラー.
The named parameter 'mainAxisAlignment' isn't defined. Try correcting the name to an existing named parameter's name, or defining a named parameter with the name 'mainAxisAlignment'
@monkeydaichan 問題原因の表記はどこから確認や表示できますか?
動画7
ElevatedButton(
child: Text('新規登録する'),
onPressed: () {
Print(myController.text);
エラー内容 The method 'Print' isn't defined for the type '_MyHomePageState'. Try correcting the name to the name of an existing method, or defining a method named 'Print'
Print -> debugprintに変更したらエラー解消した
動画7
String name;
final myController = TextEditingController();
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('KboyのFlutter大学'),
),
body: Container(
width: double.infinity,
child: Column(
children: [
TextField(
autofocus: true,
decoration: InputDecoration(
hintText: 'Tanaka Taro',
),
onChanged: (text) {
name = text;
エラー内容 Non-nullable instance field 'name' must be initialized. Try adding an initializer expression, or a generative constructor that initializes it, or mark it 'late'
-> ヒントアイコン💡から、Add 'late' modifierを選択したら、動いた。
動画7
ElevatedButton(
child: Text('新規登録する'),
onPressed: () {
showDialog(
context: context,
builder: (context) {
return AlertDialog(
content: Text(name),
エラー内容 新規登録ボタンを押したら入力内容のがボタンの下に表示されるが、シミュレーターのname欄を空白にしたままボタンを押したらエラーがでて動かなくなった。 Field 'name' has not been initialized. 再度ビルドし、nameに値を入力してからボタンを押したら、エラーは出なくなった。
エラー内容 LateError (LateInitializationError: Field 'name' has not been initialized.)
String name; null許さない String? name; null許す late String name; null許さない.nameが使われる前にnameに値を代入する必要がある late final String name; null許さない.後から値を代入することも許さない
動画8
body: Container(
width: double.infinity,
child: ListView(
children: const <Widget>[
ListTile(
leading: Icon(Icons.info),
title: Text('お問い合わせ'),
trailing: Icon(Icons.arrow_forward_ios),
onTap: () {
//Todo: 画面遷移
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => NextPage('ジーコさん'),
),
);
},
),
エラー内容 The values in a const list literal must be constants. Try removing the keyword 'const' from the list literal.
constを消すと、エラーは出なくなった。
動画3 Raisedbutton https://youtu.be/PXnqg_Ozouk?list=PLuLRJz1UnJzEDjRr1XkqyOzFzUi3Df4B0&t=92 Raisedbuttonは今は推奨されていないのか使えないようなので、elevatedbuttonを使用する。 https://techracho.bpsinc.jp/wingdoor/2021_04_01/106337
動画9
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(primaryColor: Colors.white),
home: Scaffold(
appBar: AppBar(
title: const Text('Youtubeアプリ'),
),
body: Container(),
),
);
}
}
Appバーの色をホワイトにするためにPrimaryColorでホワイトを指定したが、色が変わらない。
@TakuroNagasawa
Widgetの使い方は古い可能性があります.
最新は公式のドキュメントを見てみてください.
https://api.flutter.dev/flutter/material/AppBar-class.html
@monkeydaichan 画面遷移して画面を戻すときに値も戻したい。 consoleには戻したいものが表示されるようにはなったが、アプリに表示ができない。 また、この作業で動かしたとこ以外にエラーが急に出てそこの問題解決方法がわからない。
import 'package:flutter/material.dart';
import 'package:test1/next_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
initialRoute: '/',
routes: {
// When navigating to the "/" route, build the FirstScreen widget.
'/': (context) => MyHomePage(title: 'KBOYのFlutter大学',),
// When navigating to the "/second" route, build the SecondScreen widget.
'/Next': (context) => NextPage('Kboyさんカッコイ'),
},
)
;
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key? key, required this.title}) : super(key: key);
String text;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
String? text =('次へ');
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('KBOYのFlutter大学!!'),
),
body: Center(
child: ElevatedButton(
child: Text(text),
onPressed: ()async {
final result = await Navigator.pushNamed(context, '/NextPage');
;
text = result;
print(result);
}
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
// This trailing comma makes auto-formatting nicer for build methods.
),
);
}}
@KyoheiTaniguchi エラーがわからないから解決方法がわからない。 コードは バッククォート3つで囲って下さい
@KyoheiTaniguchi
Commentする前にPreview
で確認してからCommentしてください
コードはコードブロック内に書いてほしいです。見にくいので
@monkeydaichan
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
エラー内容 Error: The parameter 'title' can't have a value of 'null' because of its type 'String', but the implicit default value is 'null'. lib/main.dart:26 Try adding either an explicit non-'null' default value or the 'required' modifier. MyHomePage({Key key, this.title}) : super(key: key); "Key"と"Title"にNullを許さない。
import 'package:flutter/material.dart';
import 'package:test1/next_page.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
theme: ThemeData(
primarySwatch: Colors.blue,
),
home: MyHomePage(title: 'Flatter demo Home page')
);
}
}
class MyHomePage extends StatefulWidget {
MyHomePage({Key key, this.title}) : super(key: key);
final String title;
@override
_MyHomePageState createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
int _counter = 0;
void _incrementCounter() {
setState(() {
_counter++;
});
}
String text = '次へ';
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('KBOYのFlutter大学!!'),
),
body: Center(
child: ElevatedButton(
child: Text(text),
onPressed: () async {
final result = await Navigator.push(
context,
MaterialPageRoute(builder: (context) => NextPage('じーこさん'),
),
);
text = result;
print(result);
},
),
),
floatingActionButton: FloatingActionButton(
onPressed: _incrementCounter,
tooltip: 'Increment',
child: Icon(Icons.add),
// This trailing comma makes auto-formatting nicer for build methods.
),
);
}}
動画9
AppBarの背景色を白、アイコン・テキストを黒で表示するために使用したコード
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData.from(
colorScheme: const ColorScheme.light(primary: Colors.white),
),
home: Scaffold(
appBar: AppBar(
centerTitle: false,
leading: const Icon(
Icons.videocam,
color: Colors.black,
),
title: const Text(
'KBOYのflutter大学',
),
actions: [
SizedBox(
width: 44,
child: TextButton(
child: const Icon(Icons.search),
style: TextButton.styleFrom(primary: Colors.black),
onPressed: () {},
),
),
SizedBox(
width: 44,
child: TextButton(
child: const Icon(Icons.more_vert),
style: TextButton.styleFrom(primary: Colors.black),
onPressed: () {},
),
)
],
titleTextStyle: const TextStyle(color: Colors.black),
),
body: Container(),
),
);
@TakuroNagasawa Another option. https://github.com/asbloom-py/flutter-study/issues/2#issuecomment-1063910809
title: Text(
'KBOYのflutter大学',
style: TextStyle(color: Colors.black), // 追加
),
// 下の一行を削除
titleTextStyle: const TextStyle(color: Colors.black),
Launching lib/main.dart on iPhone 13 in debug mode...
Xcode build done. 13.9s
Failed to build iOS app
Error output from Xcode build:
↳
** BUILD FAILED **
Xcode's output:
↳
Writing result bundle at path:
/var/folders/97/33j8ryhs4qj7hcq3083_7k8w0000gr/T/flutter_tools.BOWmZA/flutter_ios_build_temp_diruWpuIe/temporary_xcresult_bundle
: Error: Type 'ImageErrorWidgetBuilder' not found.
final ImageErrorWidgetBuilder? placeholderErrorBuilder;
^^^^^^^^^^^^^^^^^^^^^^^
: Error: Type 'ImageErrorWidgetBuilder' not found.
final ImageErrorWidgetBuilder? imageErrorBuilder;
^^^^^^^^^^^^^^^^^^^^^^^
: Error: Type 'Image' not found.
Image _image({
^^^^^
: Error: Type 'ImageErrorWidgetBuilder' not found.
ImageErrorWidgetBuilder? errorBuilder,
^^^^^^^^^^^^^^^^^^^^^^^
: Error: Type 'ImageFrameBuilder' not found.
ImageFrameBuilder? frameBuilder,
^^^^^^^^^^^^^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class '_InkState'.
- '_InkState' is from 'package:flutter/src/material/ink_decoration.dart' ('../../Developer/flutter/packages/flutter/lib/src/material/ink_decoration.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
configuration: createLocalImageConfiguration(context),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class '_InkState'.
- '_InkState' is from 'package:flutter/src/material/ink_decoration.dart' ('../../Developer/flutter/packages/flutter/lib/src/material/ink_decoration.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
_ink!.configuration = createLocalImageConfiguration(context);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class '_MaterialSwitchState'.
- '_MaterialSwitchState' is from 'package:flutter/src/material/switch.dart' ('../../Developer/flutter/packages/flutter/lib/src/material/switch.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
..configuration = createLocalImageConfiguration(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class 'DecoratedBox'.
- 'DecoratedBox' is from 'package:flutter/src/widgets/container.dart' ('../../Developer/flutter/packages/flutter/lib/src/widgets/container.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
configuration: createLocalImageConfiguration(context),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class 'DecoratedBox'.
- 'DecoratedBox' is from 'package:flutter/src/widgets/container.dart' ('../../Developer/flutter/packages/flutter/lib/src/widgets/container.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
..configuration = createLocalImageConfiguration(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: 'ImageErrorWidgetBuilder' isn't a type.
final ImageErrorWidgetBuilder? placeholderErrorBuilder;
^^^^^^^^^^^^^^^^^^^^^^^
: Error: 'ImageErrorWidgetBuilder' isn't a type.
final ImageErrorWidgetBuilder? imageErrorBuilder;
^^^^^^^^^^^^^^^^^^^^^^^
: Error: 'ImageErrorWidgetBuilder' isn't a type.
ImageErrorWidgetBuilder? errorBuilder,
^^^^^^^^^^^^^^^^^^^^^^^
: Error: 'ImageFrameBuilder' isn't a type.
ImageFrameBuilder? frameBuilder,
^^^^^^^^^^^^^^^^^
: Error: The method 'Image' isn't defined for the class '_FadeInImageState'.
- '_FadeInImageState' is from 'package:flutter/src/widgets/fade_in_image.dart' ('../../Developer/flutter/packages/flutter/lib/src/widgets/fade_in_image.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Image'.
return Image(
^^^^^
: Error: The method 'Image' isn't defined for the class 'ImageIcon'.
- 'ImageIcon' is from 'package:flutter/src/widgets/image_icon.dart' ('../../Developer/flutter/packages/flutter/lib/src/widgets/image_icon.dart').
Try correcting the name to the name of an existing method, or defining a method named 'Image'.
child: Image(
^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class 'Table'.
- 'Table' is from 'package:flutter/src/widgets/table.dart' ('../../Developer/flutter/packages/flutter/lib/src/widgets/table.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
configuration: createLocalImageConfiguration(context),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
: Error: The method 'createLocalImageConfiguration' isn't defined for the class 'Table'.
- 'Table' is from 'package:flutter/src/widgets/table.dart' ('../../Developer/flutter/packages/flutter/lib/src/widgets/table.dart').
Try correcting the name to the name of an existing method, or defining a method named 'createLocalImageConfiguration'.
..configuration = createLocalImageConfiguration(context)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Failed to package /Users/kyohei/StudioProjects/test1.
Command PhaseScriptExecution failed with a nonzero exit code
note: Using new build system
note: Planning
note: Build preparation complete
note: Building targets in parallel
warning: Capabilities for Signing & Capabilities may not function correctly because its entitlements use a placeholder team ID. To resolve this, select a development team in the Runner editor. (in target 'Runner' from project 'Runner')
Result bundle written to path:
/var/folders/97/33j8ryhs4qj7hcq3083_7k8w0000gr/T/flutter_tools.BOWmZA/flutter_ios_build_temp_diruWpuIe/temporary_xcresult_bundle
Could not build the application for the simulator.
Error launching application on iPhone 13.
Exited (sigterm)
@monkeydaichan
ListTile(
leading: Icon(Icons.info),
title: Text('問い合わせ'),
trailing: Icon(Icons.arrow_forward_ios),
onTap: () {
// ignore: lines_longer_than_80_chars
Navigator.push<void>(
context,
MaterialPageRoute(builder: (context) => NextPage('じーこ')),
);
},
),
: Error: Not a constant expression. lib/main.dart:54 MaterialPageRoute(builder: (context) => NextPage('じーこ')), ^^^^^^^^^ : Error: Cannot invoke a non-'const' constructor where a const expression is expected. lib/main.dart:54 Try using a constructor or factory that is 'const'. MaterialPageRoute(builder: (context) => NextPage('じーこ')), ^^^^^^^^^^^^^^^^^ : Error: Not a constant expression. lib/main.dart:53 context,
: Error: Method invocation is not a constant expression. lib/main.dart:52 Navigator.push( ^^^^ : Error: Not a constant expression. lib/main.dart:50 onTap: () { ^^
@KyoheiTaniguchi https://stackoverflow.com/questions/60740759/listtile-ontap-trigger-error-error-not-a-constant-expression
constは値の変わらないもののみに使用できるため、constを使用していると、値が変わる変数を使用するものとは一緒に使えない。
$を使用するのは$の後が変数という意味。
https://www.youtube.com/watch?v=-G7nW26N7_4&list=PLuLRJz1UnJzEDjRr1XkqyOzFzUi3Df4B0&index=1
1から9まで手を動かしながらなんとなく動かす