waseemdev / vscode-flutter.xml-layout

XML Layout for Flutter. Brings Angular's style to Flutter!
MIT License
73 stars 11 forks source link

What about the compatibility with flutter 2? #11

Open KevinHua opened 3 years ago

KevinHua commented 3 years ago

Thanks!

abulka commented 3 years ago

Agreed - is this flutter xml layout extension actually usable in Flutter 2, because I'm getting

Error: Cannot run with sound null safety, because the following dependencies
don't support null safety:

- package:flutter_xmllayout_helpers

and

import 'package:flutter_xmllayout_helpers/flutter_xmllayout_helpers.dart';
The library 'package:flutter_xmllayout_helpers/flutter_xmllayout_helpers.dart' is legacy, 
and should not be imported into a null safe library.
Try migrating the imported library.dart(import_of_legacy_library_into_null_safe)
flutter_xmllayout_helpers

And even when I use this launch config to turn off null safety:

{
    "name": "xml_layout1 (debug mode)",
    "request": "launch",
    "type": "dart",
    "args": ["--no-sound-null-safety"],
    "flutterMode": "debug"
}

I still get issues dealing with such an old version of provider: ^3.0.0+1

../../../flutter/.pub-cache/hosted/pub.dartlang.org/provider-3.2.0/lib/src/provider.dart:259:19: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../../flutter/packages/flutter/lib/src/widgets/framework.dart').
Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
        ? context.inheritFromWidgetOfExactType(type) as InheritedProvider<T>

because it seems InheritFromWidgetOfExactType method is deprecated , Use dependOnInheritedWidgetOfExactType method instead.

This looks like a great tool - any chance of an update?

abulka commented 3 years ago

I ditched trying to use the old provider and the problems it brings with the latest Flutter 2. Luckily it looks like flutter_xmllayout_helpers can be updated to use the latest provider: ^5.0.0

RxDart 0.23.x moves away from the Observable class, utilizing Dart 2.6's new extension methods instead. This requires several small refactors that can be easily automated -- which is just what we've done! Please follow the instructions on the rxdart_codemod package to automatically upgrade your code to support RxDart 0.23.x.

Running the above tool made the following changes which just seem to be replacing Observable with Rx:

+++ b/lib/forms/FormGroup.dart
@@ -80,8 +80,7 @@ class FormGroup {
       _controlsStatusSubscription.cancel();
       _controlsStatusSubscription = null;
     }
-    _controlsStatusSubscription = Observable
-      .merge(streams)
+    _controlsStatusSubscription = Rx.merge(streams)
       .listen((value) {
         final old = _statusStream.value;
         if (value != old) {
@@ -107,7 +106,7 @@ class FormGroup {
       _submitEnabledSubscription.cancel();
       _submitEnabledSubscription = null;
     }
-    _submitEnabledSubscription = Observable.merge([_statusStream, _submitting]).listen((data) {
+    _submitEnabledSubscription = Rx.merge([_statusStream, _submitting]).listen((data) {
Jamesweng commented 3 years ago

We're using this extension with Flutter 2 in our project, with null-safety disabled and following package overrides the extension run well -

dependency_overrides: path_provider: ^2.0.1 rxdart: ^0.22.0 xml: ^5.0.0