How to define Dart parameter

Asked

Viewed 204 times

0

class Checkbox extends StatelessWidget {
  final String title = 'Checkbox';
  // final String value ='CheckboxValue';




  @override
  Widget build(BuildContext context) {
    return BasePage(
        title: title,
        child: MetalonCheckbox(
          checkbox: ['lala', 'lele', 'lili'],
          enabled: true,
        ));
  }
}

1 answer

1

Taking into account that you want to pass the value of the parameter via constructor would be:

void main() => runApp(Checkbox('meu parametro'));

class Checkbox extends StatelessWidget {
  Checkbox(this.title);
  final String title;
  // final String value ='CheckboxValue';

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      debugShowCheckedModeBanner: false,
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'Flutter Demo Home Page ' + title),
    );
  }
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.