Coder Social home page Coder Social logo

Null Sound Safety Migration about momentum HOT 9 CLOSED

xamantra avatar xamantra commented on May 17, 2024
Null Sound Safety Migration

from momentum.

Comments (9)

xamantra avatar xamantra commented on May 17, 2024 1

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

from momentum.

xamantra avatar xamantra commented on May 17, 2024 1

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.

from momentum.

xamantra avatar xamantra commented on May 17, 2024

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.

from momentum.

xamantra avatar xamantra commented on May 17, 2024

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.

from momentum.

xamantra avatar xamantra commented on May 17, 2024

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

from momentum.

xamantra avatar xamantra commented on May 17, 2024

Null safety is now available on pub.dev

dependencies:
  momentum: ^2.0.0

from momentum.

exts avatar exts commented on May 17, 2024

@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

from momentum.

xamantra avatar xamantra commented on May 17, 2024

I think this:
image

should be like this:

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

from momentum.

exts avatar exts commented on May 17, 2024

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 😂

from momentum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.