GithubHelp home page GithubHelp logo

@rrousselGit @josh-burton I also encountered the same stack information, but I'm not sure if it's the same problem. about riverpod HOT 2 CLOSED

rrousselGit avatar rrousselGit commented on May 30, 2024 1
@rrousselGit @josh-burton I also encountered the same stack information, but I'm not sure if it's the same problem.

from riverpod.

Comments (2)

rrousselGit avatar rrousselGit commented on May 30, 2024 1

I cannot reproduce the issue with either of the examples given. This most likely was fixed indirectly at an earlier point.

I'll therefore close this

from riverpod.

hcanyz avatar hcanyz commented on May 30, 2024

@rrousselGit The conditions for recurrence seem to be simpler

There are problems with these versions: flutter_riverpod: ^2.4.6 and flutter_riverpod: ^2.4.5

import 'dart:math';

import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:riverpod_annotation/riverpod_annotation.dart';

part 'main.g.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
      ),
      home: const MyHomePage(title: 'Flutter Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  const MyHomePage({super.key, required this.title});

  final String title;

  @override
  State<MyHomePage> createState() => _MyHomePageState();
}

@Riverpod(dependencies: [])
String overrideData(OverrideDataRef ref) => throw UnimplementedError();

@Riverpod(dependencies: [overrideData])
String dataCombo(DataComboRef ref) =>
    "${ref.watch(overrideDataProvider)} combo";

class _MyHomePageState extends State<MyHomePage> {
  String? _overrideData1;

  String? _overrideData2;

  void _onPressed() {
    setState(() {
      _overrideData1 = "${Random().nextDouble()}";
      _overrideData2 = "${Random().nextDouble()}";
    });
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Theme.of(context).colorScheme.inversePrimary,
        title: Text(widget.title),
      ),
      body: Column(
        children: [
          if (_overrideData1 != null)
            ShowDataWidget(overrideData: _overrideData1!),
          if (_overrideData2 != null)
            ShowDataWidget(overrideData: _overrideData2!),
        ],
      ),
      floatingActionButton: FloatingActionButton(
        onPressed: _onPressed,
        child: const Icon(Icons.add),
      ),
    );
  }
}

class ShowDataWidget extends StatelessWidget {
  const ShowDataWidget({super.key, required this.overrideData});

  final String overrideData;

  @override
  Widget build(BuildContext context) {
    return ProviderScope(
        overrides: [overrideDataProvider.overrideWithValue(overrideData)],
        child: Consumer(builder: (
          BuildContext context,
          WidgetRef ref,
          Widget? child,
        ) {
          return Text(ref.watch(dataComboProvider));
        }));
  }
}

from riverpod.

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.