“Super” selalu error saat buat stateless maupun statefull

Beranda › Forums › Belajar Flutter Mobile Apps Tingkat Pemula › “Super” selalu error saat buat stateless maupun statefull

  • This topic has 3 replies, 2 voices, and was last updated 3 years ago by Anonymous.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #209511
    akmalullah.id
    Participant

      Hello COach

      Kenapa ya saat buat stateless maupun statefull, untuk “super” selalu error :
      error: ‘super’ can’t be used as an identifier because it’s a keyword. (expected_identifier_but_got_keyword at [loginregister] lib\screens\wrapper.dart:8)

      import ‘package:flutter/material.dart’;

      class Handler extends StatefulWidget {
      const Handler({super.key});

      @override
      State<Handler> createState() => _HandlerState();
      }

      class _HandlerState extends State<Handler> {
      @override
      Widget build(BuildContext context) {
      return const Placeholder();
      }
      }

      #209618
      Anonymous

        super sekarang tidak support untuk stateless dan statefull, sekarang hanya key saja

        #209625
        akmalullah.id
        Participant

          Berarti cukup gini aja coach ?

          class Handler extends StatefulWidget {
          const Handler({key});

          @override
          State<Handler> createState() => _HandlerState();
          }

          class _HandlerState extends State<Handler> {
          @override
          Widget build(BuildContext context) {
          return const Placeholder();
          }

          #222708
          Anonymous

            Mohon diganti menjadi seperti ini ya
            const Handler({Key? key}) : super(key: key);

          Viewing 4 posts - 1 through 4 (of 4 total)
          • You must be logged in to reply to this topic.
          Shopping cart0
          There are no products in the cart!
          Continue shopping