Target of URI doesn't exist 'package:flutter/material.dart'
- ctrl -> Shift -> A (Find Action)
- Search for "Dart Analysis"
- Click the icon that says "Restart the Dart Analysis server"
- The red underline disappears from the package import and everything works.
I tried this solution and it worked just perfect:
open terminal from the project directory and run
flutter packages get