1

(Flutter -WindowsAPP - Flutter 1.26.0-1.0.pre • channel dev • https://github.com/flutter/flutter.git Framework • revision 63062a6443 (12 days ago) • 2020-12-13 23:19:13 +0800 Engine • revision 4797b06652 Tools • Dart 2.12.0 (build 2.12.0-141.0.dev) ).

Flutter keeps running the default Counter App , even after Code has been change to a StreamBuilder App.
There is only one main.dart in lib folder(no additional "Counter APP" code in build/test folders) and the Run-edit configuration points to this file.

However ,after deleting the code for the default "Counter App"(compiled before ), and replacing it with the code for a Streambuilder app and SAVING 'main.dart' , the Counter App STILL RUN's .

Tried restarting Android Studio along with hot reload/hot restart but still the Counter App runs.

IMAGE enter image description here

TERMINAL

flutter run -d windows

CODE

import 'package:flutter/material.dart';

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

/// This is the main application widget.
class MyApp extends StatelessWidget {
  static const String _title = 'Flutter Code Sample';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: _title,
      home: MyStatefulWidget(),
    );
  }
}

/// This is the stateful widget that the main application instantiates.
class MyStatefulWidget extends StatefulWidget {
  MyStatefulWidget({Key key}) : super(key: key);

  @override
  _MyStatefulWidgetState createState() => _MyStatefulWidgetState();
}

/// This is the private State class that goes with MyStatefulWidget.
class _MyStatefulWidgetState extends State<MyStatefulWidget> {
  Stream<int> _bids = (() async* {
    await Future<void>.delayed(Duration(seconds: 1));
    yield 1;
    await Future<void>.delayed(Duration(seconds: 1));
  })();

  Widget build(BuildContext context) {
    return DefaultTextStyle(
      style: Theme.of(context).textTheme.headline2,
      textAlign: TextAlign.center,
      child: Container(
        alignment: FractionalOffset.center,
        color: Colors.white,
        child: StreamBuilder<int>(
          stream: _bids,
          builder: (BuildContext context, AsyncSnapshot<int> snapshot) {
            List<Widget> children;
            if (snapshot.hasError) {
              children = <Widget>[
                Icon(
                  Icons.error_outline,
                  color: Colors.red,
                  size: 60,
                ),
                Padding(
                  padding: const EdgeInsets.only(top: 16),
                  child: Text('Error: ${snapshot.error}'),
                )
              ];
            } else {
              switch (snapshot.connectionState) {
                case ConnectionState.none:
                  children = <Widget>[
                    Icon(
                      Icons.info,
                      color: Colors.blue,
                      size: 60,
                    ),
                    const Padding(
                      padding: EdgeInsets.only(top: 16),
                      child: Text('Select a lot'),
                    )
                  ];
                  break;
                case ConnectionState.waiting:
                  children = <Widget>[
                    SizedBox(
                      child: const CircularProgressIndicator(),
                      width: 60,
                      height: 60,
                    ),
                    const Padding(
                      padding: EdgeInsets.only(top: 16),
                      child: Text('Awaiting bids...'),
                    )
                  ];
                  break;
                case ConnectionState.active:
                  children = <Widget>[
                    Icon(
                      Icons.check_circle_outline,
                      color: Colors.green,
                      size: 60,
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 16),
                      child: Text('\$${snapshot.data}'),
                    )
                  ];
                  break;
                case ConnectionState.done:
                  children = <Widget>[
                    Icon(
                      Icons.info,
                      color: Colors.blue,
                      size: 60,
                    ),
                    Padding(
                      padding: const EdgeInsets.only(top: 16),
                      child: Text('\$${snapshot.data} (closed)'),
                    )
                  ];
                  break;
              }
            }

            return Column(
              mainAxisAlignment: MainAxisAlignment.center,
              crossAxisAlignment: CrossAxisAlignment.center,
              children: children,
            );
          },
        ),
      ),
    );
  }
}

EDIT-1

Even after flutter clean , running the above script still runs the default Counter app.

TERMINAL

F:\Flutter\flutter_windows\windows_test_1>flutter clean
Deleting build...                                                  784ms
Deleting .dart_tool...                                               9ms
Deleting Generated.xcconfig...                                       1ms
Deleting flutter_export_environment.sh...                            0ms
Deleting ephemeral...                                               22ms
Deleting .flutter-plugins-dependencies...                            2ms
Deleting .flutter-plugins...                                         0ms

F:\Flutter\flutter_windows\windows_test_1>flutter run -d windows
Running "flutter pub get" in windows_test_1...                     433ms
Launching lib\main.dart on Windows in debug mode...
Building Windows application...
Syncing files to device Windows...                                 104ms
srt111
  • 1,079
  • 11
  • 20
  • 2
    flutter clean? But I'm guessing you didn't actually compile something to run because of errors, and something is picking up the old stuff. – Randal Schwartz Dec 25 '20 at 04:42
  • Even after flutter clean , running the above script runs the Counter app (the question has been updated ). – srt111 Dec 25 '20 at 04:58

1 Answers1

0

This Flutter Windows App was created for the very first time (with installation of the required dependencies).

Creating a completely New Project solved the issue.

srt111
  • 1,079
  • 11
  • 20