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

Build error while using Riverpod #147

Open
Solido opened this issue Jun 9, 2023 · 0 comments
Open

Build error while using Riverpod #147

Solido opened this issue Jun 9, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@Solido
Copy link

Solido commented Jun 9, 2023

Seems linked to #140

I created a very basic Riverpod app and it cannot be build by zapp.run but the most curious part is if I load it from a github repo it will work.

Capture d’écran 2023-06-09 à 11 14 41

Here's the code and riverpod_flutter is in the dependencies even if IDE display otherwise.

Thank you!

import 'dart:async';
import 'dart:math';

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

main() {

  runApp(const ProviderScope(
    child: MaterialApp(
        debugShowCheckedModeBanner: false,
        home: Scaffold(
          body: AffichagePlanetes(),
        )),
  ));
}

final commission =
    StreamProvider((ref) => Stream.periodic(const Duration(milliseconds: 800), (_) => Random().nextBool()));

final planetes = Provider<Planetes>((ref) =>
    ref.watch(commission).maybeWhen(data: (decision) => Planetes(etendu: decision), orElse: () => const Planetes()));

class AffichagePlanetes extends ConsumerWidget {
  const AffichagePlanetes({super.key});

  @override
  Widget build(context, ref) => ListView(children: [
        // Surveiller la décision de la Commission
        for (final planet in ref.watch(planetes).liste)
          ListTile(title: Text(planet, style: const TextStyle(fontSize: 22))),
      ]);
}

class Planetes {
  static const _liste = [
    'Mercure',
    'Vénus',
    'Terre',
    'Mars',
    'Jupiter',
    'Saturne',
    'Uranus',
    'Neptune',
  ];

  List<String> get liste => etendu ? [..._liste, 'Pluton'] : _liste;

  final bool etendu;

  const Planetes({this.etendu = false});
}
@Solido Solido added the bug Something isn't working label Jun 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant