Why this Flutter Web app opens a dart file every time I run the app?

Issue

It all happened with when I changed the main() in main.dart to async function for sqflite package.

When I run the app Chrome opens for debugging but shows a whole white empty screen and in the Visual Studio Code a file named web_entrypoint.dart opens showing this line:

enter image description here

Here is the main() inside the main.dart:

//These are the imports you should consider
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:path/path.dart';
import 'package:sqflite/sqflite.dart';

void main() async {
  final GlobalKey<NavigatorState> navigatorKey =
        new GlobalKey<NavigatorState>();
// This part was added later      
  final database = openDatabase(
    join(await getDatabasesPath(), 'mDb.db'),
    onCreate: (db, version) {
      return db.execute(
        "CREATE TABLE  musteri(ad TEXT, telefon INTEGER, sigorta TEXT, dosya TEXT, eksper TEXT, hasar TEXT,  adres TEXT , ilkGelis DATETIME, km INTEGER, marka TEXT, model TEXT, motor TEXT, plaka TEXT, renk TEXT, sase TEXT, tc PRIMARY KEY INTEGER, sonGelis DATETIME, tahTeslim DATETIME )",
      );
    },
    version: 1,
  );

  runApp(MaterialApp(
    title: 'Title',
    
    initialRoute: '/',
    routes: {
     
      '/': (context) => SignIn(),
      
      '/home': (context) => Menu(),
      '/verify': (context) => EmailVerification(),
      '/yenikayit': (context) => Kayit("New Record"),
    },
    navigatorKey: navigatorKey,
  ));
}

Nothing wrong with pubspec.yaml. I assume this is something about platform specifications but couldn’t figure it out why. Also I get no error message. Before this I only had runApp and NavigatorKey in my main() function and it was working perfectly.

Solution

sqflite has no support for the web. Not only is the tag missing from the package, it even directly says so:

Other platforms support:

  • […]
  • Web is not supported.

So whatever causes your exact problem, you won’t be able to use the database this way anyway. Chances are, what you see is the result of this.

Answered By – nvoigt

Answer Checked By – Pedro (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.