Flutter: Unimplemented handling of missing static target

The same error occurred for me at first ... but it worked when I did a 'hot restart'


Your code works for me...

Have you tried a hot restart? The shortcut is CTRL+SHIFT+\ or just click the button with the green circle-arrow in the console-window

I'm not sure what that error is, since I can't replicate it. However, this is more like what your app should look like. Give this a shot and see if it works.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Text('Hello World'),
    );
  }
}

Just compile the project again and it will work. The error occurs because static variables are hard compiled on the executable and are not dynamic. If you hot reload the changes, it will not rebuild the executable (apk), so that's why you need to rebuild the app.

Tags:

Dart

Flutter