全くの初心者で大変基本的な質問で申し訳ないのですが、AndroidStudio環境
flutter dart で入力した数字の文字列を数字に変換するので、エラーが出ます。解決するにはimport文以外に何か処理が必要ですか?また、入力した文字列を_kekka で表示するのにエラーが出ますがなぜでしょうか
main.dart 文
import 'package:flutter/material.dart';
import 'dart:math';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'test',
home: MyCustomForm(),
);
}
}
class MyCustomForm extends StatefulWidget {
@override
_MyCustomFormState createState() => _MyCustomFormState();
}
class _MyCustomFormState extends State<MyCustomForm> {
@override
Widget build(BuildContext context) {
final searchHint = Text("キーワード: "); final searchText = new Flexible( child: TextField( controller: myController, onSubmitted: (String txt) { setState(() { txt = "0-50";//入力値の例 List st_en = [0, 50]; st_en = txt.split("-"); var start = Math.parseInt(st_en[0]);//●● var end = Math.parseInt(st_en[1]); _kekka = txt;//●● }); }, ), ); return Scaffold( appBar: AppBar( title: Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ Text("テスト"), //searchHint, SizedBox(width: 5), searchText, ]), ), body: Text(_kekka), );
}
final myController = TextEditingController();
final _kekka = "123";
}
処理結果のエラー文
Launching lib\main.dart on FIG LA1 in debug mode...
Running Gradle task 'assembleDebug'...
Compiler message:
lib/main.dart:35:25: Error: The getter 'Math' isn't defined for the class '_MyCustomFormState'.
- '_MyCustomFormState' is from 'package:flutter_app_int/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Math'.
var start = Math.parseInt(st_en[0]);
^^^^
lib/main.dart:36:23: Error: The getter 'Math' isn't defined for the class '_MyCustomFormState'.
- '_MyCustomFormState' is from 'package:flutter_app_int/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'Math'.
var end = Math.parseInt(st_en[1]);
^^^^
lib/main.dart:37:13: Error:** The setter '_kekka' isn't defined for the class '_MyCustomFormState'.**
- '_MyCustomFormState' is from 'package:flutter_app_int/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing setter, or defining a setter or field named '_kekka'.
_kekka = txt;
^^^^^^
Target kernel_snapshot failed: Exception: Errors during snapshot creation: null
build failed.
FAILURE: Build failed with an exception.
- Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 780
- What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
Process 'command 'C:\flutter\bin\flutter.bat'' finished with non-zero exit value 1
- Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
- Get more help at https://help.gradle.org
BUILD FAILED in 14s
Finished with error: Gradle task assembleDebug failed with exit code 1
回答1件
あなたの回答
tips
プレビュー