Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web app, import amplify_storage_s3.dart cause drift-2.14.1/lib/src/web/wasm_setup/shared.dart The argument type 'LegacySyncFileHandle' can't be assigned to the parameter type 'Object' because 'LegacySyncFileHandle' is nullable and 'Object' isn't. #4874

Closed
2 of 14 tasks
minganp opened this issue May 11, 2024 · 5 comments
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced core Issues related to the Amplify Core Plugin pending-response Issue is pending response from the issue requestor

Comments

@minganp
Copy link

minganp commented May 11, 2024

Description

After import 'package:amplify_storage_s3/amplify_storage_s3.dart' for a flutter web project, When run it , it cause an error: Waiting for connection from debug service on Chrome...
../../../AppData/Local/Pub/Cache/hosted/pub.dev/drift-2.14.1/lib/src/web/wasm_setup/shared.dart:40:47: Error: The argument type 'LegacySyncFileHandle' can't be assigned to the parameter type 'Object' because 'LegacySyncFileHandle' is nullable and 'Object' isn't.

  • 'Object' is from 'dart:core'.
    final getSizeResult = callMethod<Object?>(openedFile, 'getSize', []);

Categories

  • Analytics
  • API (REST)
  • API (GraphQL)
  • Auth
  • Authenticator
  • DataStore
  • Notifications (Push)
  • Storage

Steps to Reproduce

  1. yaml add: amplify_flutter: 2.0.0 amplify_storage_s3: 2.0.0 aws_common: ^0.7.0 or 1.8.0 or 1.6.0,
  2. import 'package:amplify_storage_s3/amplify_storage_s3.dart'; in dart file
  3. run with chrome

Screenshots

Screenshot 2024-05-11 214848

Platforms

  • iOS
  • Android
  • Web
  • macOS
  • Windows
  • Linux

Flutter Version

3.19.3

Amplify Flutter Version

1.6.0, 1.8.0, or 2.0.0

Deployment Method

Amplify CLI

Schema

No response

@NikaHsn
Copy link
Contributor

NikaHsn commented May 13, 2024

@minganp thanks for taking the time to raise this issue. Could you please share a code snippet from your main.dart file that utilizes Amplify Storage? This will help us in reproducing the issue.

@NikaHsn NikaHsn added Investigating Issues that are assigned and are being looked into storage Issues related to the Storage Category pending-response Issue is pending response from the issue requestor labels May 13, 2024
@minganp
Copy link
Author

minganp commented May 14, 2024

import 'dart:html' as html;

import 'package:amplify_flutter/amplify_flutter.dart';
import 'package:amplify_storage_s3/amplify_storage_s3.dart';
import 'package:flutter/material.dart';
//import 'package:lhms_guest_web/user_service.dart';
import 'amplifyconfiguration.dart';
void main() {

  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        // This is the theme of your application.
        //
        // TRY THIS: Try running your application with "flutter run". You'll see
        // the application has a purple toolbar. Then, without quitting the app,
        // try changing the seedColor in the colorScheme below to Colors.green
        // and then invoke "hot reload" (save your changes or press the "hot
        // reload" button in a Flutter-supported IDE, or press "r" if you used
        // the command line to start the app).
        //
        // Notice that the counter didn't reset back to zero; the application
        // state is not lost during the reload. To reset the state, use hot
        // restart instead.
        //
        // This works for code too, not just values: Most code changes can be
        // tested with just a hot reload.
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  // This widget is the home page of your application. It is stateful, meaning
  // that it has a State object (defined below) that contains fields that affect
  // how it looks.

  // This class is the configuration for the state. It holds the values (in this
  // case the title) provided by the parent (in this case the App widget) and
  // used by the build method of the State. Fields in a Widget subclass are
  // always marked "final".

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  int _counter = 0;

  void _incrementCounter() {
    setState(() {
      // This call to setState tells the Flutter framework that something has
      // changed in this State, which causes it to rerun the build method below
      // so that the display can reflect the updated values. If we changed
      // _counter without calling setState(), then the build method would not be
      // called again, and so nothing would appear to happen.
      _counter++;
    });
  }
  /*
  Future _uploadDocFile()async{
    const String hotelId = 'HO_RG_VTC_01_xTHw';
    const String docCategory = 'ID';
    // Select a file from the device
    try {
      await UserService.uploadImage(
        hotelId,
        docCategory,
      );
    } catch (e) {
      safePrint(e);
    }
  }

   */
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    /*
    WidgetsBinding.instance.addPostFrameCallback((timeStamp) async{
      try{
        final storage = AmplifyStorageS3();
        await Amplify.addPlugins([storage]);
        await Amplify.configure(amplifyconfig);
        print('Amplify configured');
      } on Exception catch (e){
        safePrint(e);
      }
    });

     */
  }

  @override
  Widget build(BuildContext context) {
    // This method is rerun every time setState is called, for instance as done
    // by the _incrementCounter method above.
    //
    // The Flutter framework has been optimized to make rerunning build methods
    // fast, so that you can just rebuild anything that needs updating rather
    // than having to individually change instances of widgets.
    return Scaffold(
      appBar: AppBar(
        // TRY THIS: Try changing the color here to a specific color (to
        // Colors.amber, perhaps?) and trigger a hot reload to see the AppBar
        // change color while the other colors stay the same.
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        // Here we take the value from the MyHomePage object that was created by
        // the App.build method, and use it to set our appbar title.
        title: Text(widget.title),
      ),
      body: Center(
        // Center is a layout widget. It takes a single child and positions it
        // in the middle of the parent.
        child: Column(
          // Column is also a layout widget. It takes a list of children and
          // arranges them vertically. By default, it sizes itself to fit its
          // children horizontally, and tries to be as tall as its parent.
          //
          // Column has various properties to control how it sizes itself and
          // how it positions its children. Here we use mainAxisAlignment to
          // center the children vertically; the main axis here is the vertical
          // axis because Columns are vertical (the cross axis would be
          // horizontal).
          //
          // TRY THIS: Invoke "debug painting" (choose the "Toggle Debug Paint"
          // action in the IDE, or press "p" in the console), to see the
          // wireframe for each widget.
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            const Text(
              'You have pushed the button this many times:',
            ),
            Text(
              '$_counter',
              style: Theme.of(context).textTheme.headlineMedium,
            ),
          ],
        ),
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _incrementCounter,
        tooltip: 'Increment',
        child: const Icon(Icons.add),
      ), // This trailing comma makes auto-formatting nicer for build methods.
    );
  }
}

I do nothing, just import

@Jordan-Nelson
Copy link
Contributor

Hello @minganp - This appears to be due to an issue introduced in sqlite3 v2.4.3, which is a dependency of Amplify S3 Storage. For now you should be able to work around this by adding a dependency on v2.4.2 to your project to prevent 2.4.3 from being installed.

dependencies:
  amplify_flutter: ^2.0.0
  amplify_storage_s3: ^2.0.0
+ sqlite3: 2.4.2

@NikaHsn
Copy link
Contributor

NikaHsn commented May 14, 2024

@minganp we have released a fix to Amplify Flutter 2.0.0. you may need to run flutter pub upgrade to get latest versions of dependecies. please let us know if you are still facing this issue.

@NikaHsn NikaHsn added bug Something is not working; the issue has reproducible steps and has been reproduced core Issues related to the Amplify Core Plugin and removed storage Issues related to the Storage Category Investigating Issues that are assigned and are being looked into labels May 14, 2024
@Equartey
Copy link
Contributor

Hi @minganp, I'm going to close this issue as we've released a fix for it. If you see otherwise or have additional questions, please open a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something is not working; the issue has reproducible steps and has been reproduced core Issues related to the Amplify Core Plugin pending-response Issue is pending response from the issue requestor
Projects
None yet
Development

No branches or pull requests

4 participants