0

I've just started learning AWS Amplify and followed the step given in

https://docs.amplify.aws/start/getting-started/setup/q/integration/flutter#create-a-new-flutter-application

then I faced an error in this question The method 'Amplify' isn't defined for the type '_MyAppState'. -FlutterAmplify

then I do what it says but then a had a new error say

Amplify() The expression doesn’t evaluate a function, so it can’t be invoked.

I am following this video https://www.youtube.com/watch?v=x8xEkNCd3Vg

and this is my code lib/screens/entry.dart


import 'package:flutter/material.dart';
import 'package:amplify_flutter/amplify.dart';
import 'package:amplify_auth_cognito/amplify_auth_cognito.dart';
import 'package:amplify_analytics_pinpoint/amplify_analytics_pinpoint.dart';



class EntryScreen extends StatefulWidget {
  @override
  _EntryScreenState createState() => _EntryScreenState();
}

class _EntryScreenState extends State<EntryScreen> {

  final amplify = Amplify();


  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

and this is my pubspec.yaml


environment:
  sdk: ">=2.12.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter

  amplify_flutter: '<1.0.0'
  amplify_datastore: '<0.2.0'
  amplify_auth_cognito: '<1.0.0'
  amplify_analytics_pinpoint : '<1.0.0'
  flutter_login: '<1.0.14'

and i edited minSdkVersion 21 in the android/app/build.gradle enter image description here

2 Answers2

1

try with below dependencies

  amplify_core: ^0.2.2
  amplify_flutter: ^0.2.2
  amplify_auth_cognito: ^0.2.2
  amplify_api: ^0.2.2

not sure what you are using flutter_login for

raaone7
  • 529
  • 1
  • 7
  • 16
1

Try changing the amplify version, in dev versions var amplify = new Amplify() but in latest releases its been changed to static class hence you have to use Amplify.configure(config) like this.

Manish
  • 417
  • 5
  • 10