Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null Sound Safety Migration #43

Closed
Bilonik opened this issue Mar 5, 2021 · 9 comments
Closed

Null Sound Safety Migration #43

Bilonik opened this issue Mar 5, 2021 · 9 comments
Labels
documentation Improvements or additions to documentation enhancement New feature or request Published This new feature has been published.

Comments

@Bilonik
Copy link

Bilonik commented Mar 5, 2021

Do you plan to support null safety?

@xamantra
Copy link
Owner

xamantra commented Mar 5, 2021

Yes. I plan to upgrade all my packages to null-safety.
Yesterday, I upgraded my relative_scale package to null-safety.
I think for momentum it might take longer though.

@xamantra
Copy link
Owner

xamantra commented Mar 5, 2021

Ok so. I'm now currently migrating this to null-safety.
I decided to do it by hand because the dart migrate command produced a lot of errors after and when I tried to fix them all, a lot of unit tests failed.

@xamantra xamantra added enhancement New feature or request In Progress Issues that are currently being worked on. labels Mar 5, 2021
@xamantra
Copy link
Owner

xamantra commented Mar 5, 2021

All unit tests need to pass without any edits in the test codes.

@xamantra
Copy link
Owner

xamantra commented Mar 6, 2021

Okay so. This is harder than I've thought.
This won't be done today. I'll continue tomorrow.

xamantra pushed a commit that referenced this issue Mar 13, 2021
@xamantra
Copy link
Owner

xamantra commented Mar 13, 2021

Migrated to null safety now!
Can be used from momentum's dev latest commit:

dependencies:
  # other deps here
  momentum:
    git:
      url: https://github.com/xamantra/momentum.git
      ref: 5ed04cba9e859ba3802ed02a7dc24b1f84c4de27
  # other deps here

There are still some important things that need to be updated before publishing to pub.dev. Like updating readme to have null safe code, the entire docs website, and the comment docs.

@xamantra xamantra added the documentation Improvements or additions to documentation label Mar 13, 2021
@xamantra xamantra pinned this issue Mar 13, 2021
@xamantra
Copy link
Owner

Null safety is now available on pub.dev

dependencies:
  momentum: ^2.0.0

@xamantra xamantra added Published This new feature has been published. and removed In Progress Issues that are currently being worked on. labels Mar 22, 2021
@exts
Copy link

exts commented Apr 8, 2021

@xamantra not sure if it's me trying to use it for desktop (windows) or if it's momentum itself, but I'm getting this error

error

======== Exception caught by widgets library =======================================================
The following _CastError was thrown building FutureBuilder<bool>(dirty, state: _FutureBuilderState<bool>#330a6):
Null check operator used on a null value

The relevant error-causing widget was: 
  Momentum file:///Z:/Programming/Flutter/tfx/lib/main.dart:7:10
When the exception was thrown, this was the stack: 
#0      _MomentumRootState.build.<anonymous closure> (package:momentum/src/momentum_base.dart:1286:32)
#1      _FutureBuilderState.build (package:flutter/src/widgets/async.dart:773:55)
#2      StatefulElement.build (package:flutter/src/widgets/framework.dart:4612:27)
#3      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4495:15)
#4      StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4667:11)

image

code

import 'package:flutter/material.dart';
import 'package:momentum/momentum.dart';
import 'package:tfx/screens/index_screen.dart';

void main() {
  // runApp(MyApp());
  runApp(Momentum(
    disabledPersistentState: true,
    controllers: [],
    services: [
      MomentumRouter([
        IndexScreen(),
      ])
    ],
  ));
}

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'TFX',
      theme: ThemeData(
        primarySwatch: Colors.blue,
        visualDensity: VisualDensity.adaptivePlatformDensity,
      ),
      home: IndexScreen(),
    );
  }
}
import 'package:flutter/material.dart';

class IndexScreen extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("TFX"),
      ),
      body: Container(
        child: Center(
          child: Text("Body"),
        ),
      ),
    );
  }
}

It's been a while since I played with momentum, not sure if every screen needs to be a momentum state or not

@xamantra
Copy link
Owner

xamantra commented Apr 8, 2021

I think this:
image

should be like this:

void main() {
  // runApp(MyApp());
  runApp(Momentum(
    child: MyApp(),
    disabledPersistentState: true,
    controllers: [],

@exts
Copy link

exts commented Apr 8, 2021

Oh I'm an idiot, I now know what happened.

So before I was using 1.3.x and was trying to figure out why it was derping out. I think I was commenting stuff out to try finding the bug (problem was null safety) then noticed 2.0 was out. And forgot to uncomment that back 😂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation enhancement New feature or request Published This new feature has been published.
Projects
None yet
Development

No branches or pull requests

3 participants