1

次のコードでは、「コントローラー:urlController」でエラーが発生しました。この行

      var url;
      final urlController = TextEditingController();
    
      @override
      void dispose() {
        urlController.dispose();
        super.dispose();
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            backgroundColor: const Color(0xff16352A),
            title: const Text(
              'Downloader',
              style: TextStyle(color: Color(0xffEDAB24)),
            ),
          ),
          body: Container(
            padding: const EdgeInsets.all(20.0),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.center,
              children: [
                const SizedBox(height: 50.0),
                const TextField(
                  controller: urlController,
                  decoration: InputDecoration(
                    border: OutlineInputBorder(),
                    labelText: 'Paste URL',
                  ),
                ),
            

const SizedBox(height: 20.0),
            Row(
              mainAxisAlignment: MainAxisAlignment.spaceAround,
              children: [
                TextButton(
                  onPressed: () {},
                  child: const Text(
                    'Download',
                    style: TextStyle(fontSize: 30.0),
                  ),
                  style: TextButton.styleFrom(
                    primary: Colors.white,
                    backgroundColor: const Color(0xff284635),
                  ),
                ),
                const SizedBox(width: 20.0),
                TextButton(
                  onPressed: () {
                    setState(() {
                      url = urlController.text;
                    });
                  },
                  child: const Text(
                    'Clear',
                    style: TextStyle(fontSize: 30.0),
                  ),
                  style: TextButton.styleFrom(
                    primary: Colors.white,
                    backgroundColor: const Color(0xff284635),
                  ),
                ),
              ],
            )
          ],
        ),
      ),
    );
  }
}
4

1 に答える 1