Home > OS >  I am getting some errors in flutter(dart)
I am getting some errors in flutter(dart)

Time:10-23

I'm watching a tutorial on Flutter on Youtube. I came to the Firebase part. However, I am getting an error in this part. I am getting an error even though I type the same. I think I got such an error because there are updates in Flutter language. I'm sorry my English is bad. Thank you in advance for helping me.

Error image:

enter image description here

enter image description here

enter image description here

enter link description here

main.dart

import 'package:firebasedenemem/singup_screen.dart';
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 SignupScreen());
  }
}

signup_screen.dart

import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:flutter/material.dart';
import 'dart:io';

class SignupScreen extends StatefulWidget {
  const SignupScreen({Key? key}) : super(key: key);

  @override
  _SignupScreenState createState() => _SignupScreenState();
}

class _SignupScreenState extends State<SignupScreen> {
  final GlobalKey<FormState> _formKey = GlobalKey<FormState>();

  final picUrl = "";
  File? _image;

  final TextEditingController _nameController = TextEditingController();
  final TextEditingController _lastnameController = TextEditingController();
  final TextEditingController _emailController = TextEditingController();

  FirebaseAuth auth = FirebaseAuth.instance;

  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.only(top: 30),
      color: Colors.grey[800],
      child: Column(
        mainAxisSize: MainAxisSize.min,
        children: <Widget>[
          const Image(
            image: AssetImage("assets/images/logo.png"),
            width: 200,
            height: 100,
          ),
          Container(
            margin: const EdgeInsets.only(top: 10),
            decoration: BoxDecoration(
                border: Border.all(color: Colors.white, width: 11),
                color: Colors.white,
                borderRadius: const BorderRadius.only(
                  topRight: Radius.circular(122),
                  bottomLeft: Radius.circular(122),
                )),
          ),
        ],
      ),
    );
  }
}

CodePudding user response:

Open the /android/app/build.gradle file. Under dependencies add the multidex module, and enable it within the defaultConfig:

android {
    defaultConfig {
        // ...
        minSdkVersion 16
        targetSdkVersion 28
        multiDexEnabled true
    }
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'

More details in this link: https://firebase.flutter.dev/docs/installation/android

See also this answer, it applies to your case: Flutter Firestore causing D8: Cannot fit requested classes in a single dex file (# methods: 71610 > 65536) in Android Studio

  • Related