Search
 
SCRIPT & CODE EXAMPLE
 

DART

flutter snackbar

    ScaffoldMessenger.of(context).showSnackBar(SnackBar(
                content: Text("Your Text"),
                duration: Duration(milliseconds: 300),
              ));
Comment

flutter dissmis snackbar

ScaffoldMessenger.of(context).hideCurrentSnackBar();
Comment

flutter snackbar

final snackBar = SnackBar(
            content: const Text('Yay! A SnackBar!'),
            action: SnackBarAction(
              label: 'Undo',
              onPressed: () {},
            ),
          );
ScaffoldMessenger.of(context).showSnackBar(snackBar);
Comment

flutter snackbar

final snackBar = SnackBar(
  content: Text('Yay! A SnackBar!'),
  action: SnackBarAction(
    label: 'Undo',
    onPressed: () {
      // Some code to undo the change.
    },
  ),
);

 // Find the Scaffold in the widget tree and use
 // it to show a SnackBar.
 Scaffold.of(context).showSnackBar(snackBar);
Comment

flutter snackbar

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return new MaterialApp(
      title: 'Flutter',
      theme: new ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: new MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => new _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {

  final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

  @override
  void initState() {
    super.initState();
    showInSnackBar("Some text");
  }

  @override
  Widget build(BuildContext context) {
    return new Padding(
            key: _scaffoldKey,
            padding: const EdgeInsets.all(16.0),
            child: new Text("Simple Text")
    );
  }

  void showInSnackBar(String value) {
    _scaffoldKey.currentState.showSnackBar(new SnackBar(
        content: new Text(value)
    ));
  }
}
Comment

show snackbar flutter

final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();

void showInSnackBar(String value) {
    _scaffoldKey.currentState.showSnackBar(new SnackBar(content: new Text(value)));
}
Comment

PREVIOUS NEXT
Code Example
Dart :: dart inset all 
Dart :: cross icon flutter 
Dart :: dart to double 
Dart :: cannot add to a fixed-length list 
Dart :: flutter listtile color 
Dart :: flutter dropdownbutton enum 
Dart :: How do I rotate widget in flutter? 
Dart :: Add image with circular shape from corners in Flutter 
Dart :: dart jsonEncode 
Dart :: flutter display widget based on device orientation 
Dart :: dartpad missing browser features 
Dart :: flutter vertical space between containers 
Dart :: change password firebase flutter 
Dart :: flutter send json body to api 
Dart :: flutter main.dart 
Dart :: how to get terminal http request time 
Dart :: flutter add value to list<map<string, int 
Dart :: how to format a date in Dart 
Dart :: flutter padding 
Dart :: fibonacci numbers in dart 
Dart :: flutter int max value 
Dart :: flutter clipoval 
Dart :: Add background image to container in Flutter 
Dart :: flutter tooltip 
Dart :: flutter auto size text 
Dart :: flutter check application direction 
Dart :: flutter iterate over list widget 
Dart :: dart contains method 
Dart :: flutter pageview show next page 
Dart :: dart strip html 
ADD CONTENT
Topic
Content
Source link
Name
9+4 =